Theme My Login - Version 6.4.6

Version Description

  • Fix errors and messages not displaying
  • Don't add reCAPTCHA errors when adding a user via wp-admin or WP-CLI
  • Improve PHP 7 compatibility
  • Introduce tml_page_id filter
  • Improve deliverability of HTML emails
  • Fix disabling of User Denial email notification
  • Pass locale to reCAPTCHA script allowing reCAPTCHA to be localized
  • Don't allow pending users to log in using their email address
  • Fix email content types from being reset
Download this release

Release Info

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

Code changes from version 6.4.5 to 6.4.6

Files changed (35) hide show
  1. admin/class-theme-my-login-admin.php +430 -430
  2. includes/class-theme-my-login-common.php +1 -0
  3. includes/class-theme-my-login-ms-signup.php +567 -567
  4. includes/class-theme-my-login-template.php +594 -594
  5. includes/class-theme-my-login-widget.php +147 -147
  6. includes/class-theme-my-login.php +1193 -1193
  7. languages/theme-my-login.pot +34 -34
  8. modules/custom-email/admin/custom-email-admin.php +613 -613
  9. modules/custom-email/custom-email.php +938 -921
  10. modules/custom-passwords/custom-passwords.php +314 -314
  11. modules/custom-redirection/custom-redirection.php +236 -236
  12. modules/custom-user-links/admin/css/custom-user-links-admin.css +30 -30
  13. modules/custom-user-links/admin/custom-user-links-admin.php +412 -412
  14. modules/custom-user-links/admin/js/custom-user-links-admin.js +42 -42
  15. modules/custom-user-links/custom-user-links.php +130 -130
  16. modules/recaptcha/recaptcha.php +8 -1
  17. modules/security/admin/js/security-admin.js +2 -2
  18. modules/security/admin/security-admin.php +313 -313
  19. modules/security/security.php +623 -623
  20. modules/themed-profiles/themed-profiles.css +51 -51
  21. modules/themed-profiles/themed-profiles.php +396 -396
  22. modules/user-moderation/admin/user-moderation-admin.php +443 -443
  23. modules/user-moderation/user-moderation.php +482 -480
  24. readme.txt +533 -521
  25. templates/login-form.php +46 -46
  26. templates/lostpassword-form.php +31 -31
  27. templates/ms-signup-another-blog-form.php +84 -84
  28. templates/ms-signup-blog-form.php +66 -66
  29. templates/ms-signup-user-form.php +51 -51
  30. templates/profile-form.php +195 -195
  31. templates/register-form.php +35 -35
  32. templates/resetpass-form.php +47 -47
  33. templates/user-panel.php +15 -15
  34. theme-my-login.css +200 -200
  35. theme-my-login.php +59 -59
admin/class-theme-my-login-admin.php CHANGED
@@ -1,430 +1,430 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @since 6.0
7
- */
8
-
9
- if ( ! class_exists( 'Theme_My_Login_Admin' ) ) :
10
- /**
11
- * Theme My Login Admin class
12
- *
13
- * @since 6.0
14
- */
15
- class Theme_My_Login_Admin extends Theme_My_Login_Abstract {
16
- /**
17
- * Holds options key
18
- *
19
- * @since 6.3
20
- * @access protected
21
- * @var string
22
- */
23
- protected $options_key = 'theme_my_login';
24
-
25
- /**
26
- * Returns singleton instance
27
- *
28
- * @since 6.3
29
- * @access public
30
- * @return Theme_My_Login
31
- */
32
- public static function get_object( $class = null ) {
33
- return parent::get_object( __CLASS__ );
34
- }
35
-
36
- /**
37
- * Returns default options
38
- *
39
- * @since 6.3
40
- * @access public
41
- */
42
- public static function default_options() {
43
- return Theme_My_Login::default_options();
44
- }
45
-
46
- /**
47
- * Loads object
48
- *
49
- * @since 6.3
50
- * @access public
51
- */
52
- protected function load() {
53
- add_action( 'admin_init', array( $this, 'admin_init' ) );
54
- add_action( 'admin_menu', array( $this, 'admin_menu' ), 8 );
55
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 11 );
56
-
57
- register_uninstall_hook( THEME_MY_LOGIN_PATH . '/theme-my-login.php', array( 'Theme_My_Login_Admin', 'uninstall' ) );
58
- }
59
-
60
- /**
61
- * Builds plugin admin menu and pages
62
- *
63
- * @since 6.0
64
- * @access public
65
- */
66
- public function admin_menu() {
67
- add_menu_page(
68
- __( 'Theme My Login Settings', 'theme-my-login' ),
69
- __( 'TML', 'theme-my-login' ),
70
- 'manage_options',
71
- 'theme_my_login',
72
- array( 'Theme_My_Login_Admin', 'settings_page' )
73
- );
74
-
75
- add_submenu_page(
76
- 'theme_my_login',
77
- __( 'General', 'theme-my-login' ),
78
- __( 'General', 'theme-my-login' ),
79
- 'manage_options',
80
- 'theme_my_login',
81
- array( 'Theme_My_Login_Admin', 'settings_page' )
82
- );
83
- }
84
-
85
- /**
86
- * Registers TML settings
87
- *
88
- * This is used because register_setting() isn't available until the "admin_init" hook.
89
- *
90
- * @since 6.0
91
- * @access public
92
- */
93
- public function admin_init() {
94
-
95
- // Register setting
96
- register_setting( 'theme_my_login', 'theme_my_login', array( $this, 'save_settings' ) );
97
-
98
- // Install/Upgrade
99
- if ( version_compare( $this->get_option( 'version', 0 ), Theme_My_Login::VERSION, '<' ) )
100
- $this->install();
101
-
102
- // Add sections
103
- add_settings_section( 'general', __( 'General', 'theme-my-login' ), '__return_false', $this->options_key );
104
- add_settings_section( 'modules', __( 'Modules', 'theme-my-login' ), '__return_false', $this->options_key );
105
-
106
- // Add fields
107
- add_settings_field( 'enable_css', __( 'Stylesheet', 'theme-my-login' ), array( $this, 'settings_field_enable_css' ), $this->options_key, 'general' );
108
- add_settings_field( 'login_type', __( 'Login Type', 'theme-my-login' ), array( $this, 'settings_field_login_type' ), $this->options_key, 'general' );
109
- add_settings_field( 'modules', __( 'Modules', 'theme-my-login' ), array( $this, 'settings_field_modules' ), $this->options_key, 'modules' );
110
- }
111
-
112
- /**
113
- * Enqueues TML scripts
114
- *
115
- * @since 6.3.11
116
- * @access public
117
- */
118
- public function admin_enqueue_scripts() {
119
- wp_enqueue_script( 'theme-my-login-admin', plugins_url( 'js/theme-my-login-admin.js', __FILE__ ), array( 'jquery' ), Theme_My_Login::VERSION, true );
120
- wp_localize_script( 'theme-my-login-admin', 'tmlAdmin', array(
121
- 'interim_login_url' => site_url( 'wp-login.php?interim-login=1', 'login' )
122
- ) );
123
- }
124
-
125
- /**
126
- * Renders the settings page
127
- *
128
- * @since 6.0
129
- * @access public
130
- */
131
- public static function settings_page( $args = '' ) {
132
- extract( wp_parse_args( $args, array(
133
- 'title' => __( 'Theme My Login Settings', 'theme-my-login' ),
134
- 'options_key' => 'theme_my_login'
135
- ) ) );
136
- ?>
137
- <div id="<?php echo $options_key; ?>" class="wrap">
138
- <h2><?php echo esc_html( $title ); ?></h2>
139
- <?php settings_errors(); ?>
140
-
141
- <form method="post" action="options.php">
142
- <?php
143
- settings_fields( $options_key );
144
- do_settings_sections( $options_key );
145
- submit_button();
146
- ?>
147
- </form>
148
- </div>
149
- <?php
150
- }
151
-
152
- /**
153
- * Renders Stylesheet settings field
154
- *
155
- * @since 6.3
156
- * @access public
157
- */
158
- public function settings_field_enable_css() {
159
- ?>
160
- <input name="theme_my_login[enable_css]" type="checkbox" id="theme_my_login_enable_css" value="1"<?php checked( 1, $this->get_option( 'enable_css' ) ); ?> />
161
- <label for="theme_my_login_enable_css"><?php _e( 'Enable "theme-my-login.css"', 'theme-my-login' ); ?></label>
162
- <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>
163
- <?php
164
- }
165
-
166
- /**
167
- * Renders Login Type settings field
168
- *
169
- * @since 6.3
170
- * @access public
171
- */
172
- public function settings_field_login_type() {
173
- ?>
174
-
175
- <ul>
176
-
177
- <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_default" value="default"<?php checked( 'default', $this->get_option( 'login_type' ) ); ?> />
178
- <label for="theme_my_login_login_type_default"><?php _e( 'Username or E-mail', 'theme-my-login' ); ?></label></li>
179
-
180
- <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_username" value="username"<?php checked( 'username', $this->get_option( 'login_type' ) ); ?> />
181
- <label for="theme_my_login_login_type_username"><?php _e( 'Username only', 'theme-my-login' ); ?></label></li>
182
-
183
- <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_email" value="email"<?php checked( 'email', $this->get_option( 'login_type' ) ); ?> />
184
- <label for="theme_my_login_login_type_email"><?php _e( 'E-mail only', 'theme-my-login' ); ?></label></li>
185
-
186
- </ul>
187
-
188
- <p class="description"><?php _e( 'Allow users to login using their username and/or e-mail address.', 'theme-my-login' ); ?></p>
189
-
190
- <?php
191
- }
192
-
193
- /**
194
- * Renders Modules settings field
195
- *
196
- * @since 6.3
197
- * @access public
198
- */
199
- public function settings_field_modules() {
200
- foreach ( get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) ) as $path => $data ) {
201
- $id = sanitize_key( $data['Name'] );
202
- ?>
203
- <input name="theme_my_login[active_modules][]" type="checkbox" id="theme_my_login_active_modules_<?php echo $id; ?>" value="<?php echo $path; ?>"<?php checked( in_array( $path, (array) $this->get_option( 'active_modules' ) ) ); ?> />
204
- <label for="theme_my_login_active_modules_<?php echo $id; ?>"><?php printf( __( 'Enable %s', 'theme-my-login' ), $data['Name'] ); ?></label><br />
205
- <?php if ( $data['Description'] ) : ?>
206
- <p class="description"><?php echo $data['Description']; ?></p>
207
- <?php endif;
208
- }
209
- }
210
-
211
- /**
212
- * Sanitizes TML settings
213
- *
214
- * This is the callback for register_setting()
215
- *
216
- * @since 6.0
217
- * @access public
218
- *
219
- * @param string|array $settings Settings passed in from filter
220
- * @return string|array Sanitized settings
221
- */
222
- public function save_settings( $settings ) {
223
- $settings['enable_css'] = ! empty( $settings['enable_css'] );
224
- $settings['login_type'] = in_array( $settings['login_type'], array( 'default', 'username', 'email' ) ) ? $settings['login_type'] : 'default';
225
- $settings['active_modules'] = isset( $settings['active_modules'] ) ? (array) $settings['active_modules'] : array();
226
-
227
- // If we have modules to activate
228
- if ( $activate = array_diff( $settings['active_modules'], $this->get_option( 'active_modules', array() ) ) ) {
229
- foreach ( $activate as $module ) {
230
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
231
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
232
- do_action( 'tml_activate_' . $module );
233
- }
234
- }
235
-
236
- // If we have modules to deactivate
237
- if ( $deactivate = array_diff( $this->get_option( 'active_modules', array() ), $settings['active_modules'] ) ) {
238
- foreach ( $deactivate as $module ) {
239
- do_action( 'tml_deactivate_' . $module );
240
- }
241
- }
242
-
243
- $settings = wp_parse_args( $settings, $this->get_options() );
244
-
245
- return $settings;
246
- }
247
-
248
- /**
249
- * Installs TML
250
- *
251
- * @since 6.0
252
- * @access public
253
- */
254
- public function install() {
255
- global $wpdb;
256
-
257
- // Current version
258
- $version = $this->get_option( 'version', Theme_My_Login::VERSION );
259
-
260
- // Check if legacy page exists
261
- if ( $page_id = $this->get_option( 'page_id' ) ) {
262
- $page = get_post( $page_id );
263
- } else {
264
- $page = get_page_by_title( 'Login' );
265
- }
266
-
267
- // 4.4 upgrade
268
- if ( version_compare( $version, '4.4', '<' ) ) {
269
- remove_role( 'denied' );
270
- }
271
-
272
- // 6.0 upgrade
273
- if ( version_compare( $version, '6.0', '<' ) ) {
274
- // Replace shortcode
275
- if ( $page ) {
276
- $page->post_content = str_replace( '[theme-my-login-page]', '[theme-my-login]', $page->post_content );
277
- wp_update_post( $page );
278
- }
279
- }
280
-
281
- // 6.3 upgrade
282
- if ( version_compare( $version, '6.3.3', '<' ) ) {
283
- // Delete obsolete options
284
- $this->delete_option( 'page_id' );
285
- $this->delete_option( 'show_page' );
286
- $this->delete_option( 'initial_nag' );
287
- $this->delete_option( 'permalinks' );
288
- $this->delete_option( 'flush_rules' );
289
-
290
- // Move options to their own rows
291
- foreach ( $this->get_options() as $key => $value ) {
292
- if ( in_array( $key, array( 'active_modules' ) ) )
293
- continue;
294
-
295
- if ( ! is_array( $value ) )
296
- continue;
297
-
298
- update_option( "theme_my_login_{$key}", $value );
299
-
300
- $this->delete_option( $key );
301
- }
302
-
303
- // Maybe create login page?
304
- if ( $page ) {
305
- // Make sure the page is not in the trash
306
- if ( 'trash' == $page->post_status )
307
- wp_untrash_post( $page->ID );
308
-
309
- update_post_meta( $page->ID, '_tml_action', 'login' );
310
- }
311
- }
312
-
313
- // 6.3.7 upgrade
314
- if ( version_compare( $version, '6.3.7', '<' ) ) {
315
- // Convert TML pages to regular pages
316
- $wpdb->update( $wpdb->posts, array( 'post_type' => 'page' ), array( 'post_type' => 'tml_page' ) );
317
-
318
- // Get rid of stale rewrite rules
319
- flush_rewrite_rules( false );
320
- }
321
-
322
- // 6.4 upgrade
323
- if ( version_compare( $version, '6.4', '<' ) ) {
324
- // Convert e-mail login option
325
- if ( $this->get_option( 'email_login' ) )
326
- $this->set_option( 'login_type', 'both' );
327
- $this->delete_option( 'email_login' );
328
- }
329
-
330
- // 6.4.5 upgrade
331
- if ( version_compare( $version, '6.4.5', '<' ) ) {
332
- // Convert login type option
333
- $login_type = $this->get_option( 'login_type' );
334
- if ( 'both' == $login_type ) {
335
- $this->set_option( 'login_type', 'default' );
336
- } elseif ( 'default' == $login_type ) {
337
- $this->set_option( 'login_type', 'username' );
338
- }
339
- }
340
-
341
- // Setup default pages
342
- foreach ( Theme_My_Login::default_pages() as $action => $title ) {
343
- if ( ! $page_id = Theme_My_Login::get_page_id( $action ) ) {
344
- $page_id = wp_insert_post( array(
345
- 'post_title' => $title,
346
- 'post_name' => $action,
347
- 'post_status' => 'publish',
348
- 'post_type' => 'page',
349
- 'post_content' => '[theme-my-login]',
350
- 'comment_status' => 'closed',
351
- 'ping_status' => 'closed'
352
- ) );
353
- update_post_meta( $page_id, '_tml_action', $action );
354
- }
355
- }
356
-
357
- // Activate modules
358
- foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
359
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
360
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
361
- do_action( 'tml_activate_' . $module );
362
- }
363
-
364
- $this->set_option( 'version', Theme_My_Login::VERSION );
365
- $this->save_options();
366
- }
367
-
368
- /**
369
- * Wrapper for multisite uninstallation
370
- *
371
- * @since 6.1
372
- * @access public
373
- */
374
- public static function uninstall() {
375
- global $wpdb;
376
-
377
- if ( is_multisite() ) {
378
- if ( isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
379
- $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
380
- foreach ( $blogids as $blog_id ) {
381
- switch_to_blog( $blog_id );
382
- self::_uninstall();
383
- }
384
- restore_current_blog();
385
- return;
386
- }
387
- }
388
- self::_uninstall();
389
- }
390
-
391
- /**
392
- * Uninstalls TML
393
- *
394
- * @since 6.0
395
- * @access protected
396
- */
397
- protected static function _uninstall() {
398
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
399
-
400
- // Run module uninstall hooks
401
- $modules = get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) );
402
- foreach ( array_keys( $modules ) as $module ) {
403
- $module = plugin_basename( trim( $module ) );
404
-
405
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
406
- @include ( THEME_MY_LOGIN_PATH . '/modules/' . $module );
407
-
408
- do_action( 'tml_uninstall_' . $module );
409
- }
410
-
411
- // Get pages
412
- $pages = get_posts( array(
413
- 'post_type' => 'page',
414
- 'post_status' => 'any',
415
- 'meta_key' => '_tml_action',
416
- 'posts_per_page' => -1
417
- ) );
418
-
419
- // Delete pages
420
- foreach ( $pages as $page ) {
421
- wp_delete_post( $page->ID, true );
422
- }
423
-
424
- // Delete options
425
- delete_option( 'theme_my_login' );
426
- delete_option( 'widget_theme-my-login' );
427
- }
428
- }
429
- endif; // Class exists
430
-
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login Admin class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @since 6.0
7
+ */
8
+
9
+ if ( ! class_exists( 'Theme_My_Login_Admin' ) ) :
10
+ /**
11
+ * Theme My Login Admin class
12
+ *
13
+ * @since 6.0
14
+ */
15
+ class Theme_My_Login_Admin extends Theme_My_Login_Abstract {
16
+ /**
17
+ * Holds options key
18
+ *
19
+ * @since 6.3
20
+ * @access protected
21
+ * @var string
22
+ */
23
+ protected $options_key = 'theme_my_login';
24
+
25
+ /**
26
+ * Returns singleton instance
27
+ *
28
+ * @since 6.3
29
+ * @access public
30
+ * @return Theme_My_Login
31
+ */
32
+ public static function get_object( $class = null ) {
33
+ return parent::get_object( __CLASS__ );
34
+ }
35
+
36
+ /**
37
+ * Returns default options
38
+ *
39
+ * @since 6.3
40
+ * @access public
41
+ */
42
+ public static function default_options() {
43
+ return Theme_My_Login::default_options();
44
+ }
45
+
46
+ /**
47
+ * Loads object
48
+ *
49
+ * @since 6.3
50
+ * @access public
51
+ */
52
+ protected function load() {
53
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
54
+ add_action( 'admin_menu', array( $this, 'admin_menu' ), 8 );
55
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 11 );
56
+
57
+ register_uninstall_hook( THEME_MY_LOGIN_PATH . '/theme-my-login.php', array( 'Theme_My_Login_Admin', 'uninstall' ) );
58
+ }
59
+
60
+ /**
61
+ * Builds plugin admin menu and pages
62
+ *
63
+ * @since 6.0
64
+ * @access public
65
+ */
66
+ public function admin_menu() {
67
+ add_menu_page(
68
+ __( 'Theme My Login Settings', 'theme-my-login' ),
69
+ __( 'TML', 'theme-my-login' ),
70
+ 'manage_options',
71
+ 'theme_my_login',
72
+ array( 'Theme_My_Login_Admin', 'settings_page' )
73
+ );
74
+
75
+ add_submenu_page(
76
+ 'theme_my_login',
77
+ __( 'General', 'theme-my-login' ),
78
+ __( 'General', 'theme-my-login' ),
79
+ 'manage_options',
80
+ 'theme_my_login',
81
+ array( 'Theme_My_Login_Admin', 'settings_page' )
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Registers TML settings
87
+ *
88
+ * This is used because register_setting() isn't available until the "admin_init" hook.
89
+ *
90
+ * @since 6.0
91
+ * @access public
92
+ */
93
+ public function admin_init() {
94
+
95
+ // Register setting
96
+ register_setting( 'theme_my_login', 'theme_my_login', array( $this, 'save_settings' ) );
97
+
98
+ // Install/Upgrade
99
+ if ( version_compare( $this->get_option( 'version', 0 ), Theme_My_Login::VERSION, '<' ) )
100
+ $this->install();
101
+
102
+ // Add sections
103
+ add_settings_section( 'general', __( 'General', 'theme-my-login' ), '__return_false', $this->options_key );
104
+ add_settings_section( 'modules', __( 'Modules', 'theme-my-login' ), '__return_false', $this->options_key );
105
+
106
+ // Add fields
107
+ add_settings_field( 'enable_css', __( 'Stylesheet', 'theme-my-login' ), array( $this, 'settings_field_enable_css' ), $this->options_key, 'general' );
108
+ add_settings_field( 'login_type', __( 'Login Type', 'theme-my-login' ), array( $this, 'settings_field_login_type' ), $this->options_key, 'general' );
109
+ add_settings_field( 'modules', __( 'Modules', 'theme-my-login' ), array( $this, 'settings_field_modules' ), $this->options_key, 'modules' );
110
+ }
111
+
112
+ /**
113
+ * Enqueues TML scripts
114
+ *
115
+ * @since 6.3.11
116
+ * @access public
117
+ */
118
+ public function admin_enqueue_scripts() {
119
+ wp_enqueue_script( 'theme-my-login-admin', plugins_url( 'js/theme-my-login-admin.js', __FILE__ ), array( 'jquery' ), Theme_My_Login::VERSION, true );
120
+ wp_localize_script( 'theme-my-login-admin', 'tmlAdmin', array(
121
+ 'interim_login_url' => site_url( 'wp-login.php?interim-login=1', 'login' )
122
+ ) );
123
+ }
124
+
125
+ /**
126
+ * Renders the settings page
127
+ *
128
+ * @since 6.0
129
+ * @access public
130
+ */
131
+ public static function settings_page( $args = '' ) {
132
+ extract( wp_parse_args( $args, array(
133
+ 'title' => __( 'Theme My Login Settings', 'theme-my-login' ),
134
+ 'options_key' => 'theme_my_login'
135
+ ) ) );
136
+ ?>
137
+ <div id="<?php echo $options_key; ?>" class="wrap">
138
+ <h2><?php echo esc_html( $title ); ?></h2>
139
+ <?php settings_errors(); ?>
140
+
141
+ <form method="post" action="options.php">
142
+ <?php
143
+ settings_fields( $options_key );
144
+ do_settings_sections( $options_key );
145
+ submit_button();
146
+ ?>
147
+ </form>
148
+ </div>
149
+ <?php
150
+ }
151
+
152
+ /**
153
+ * Renders Stylesheet settings field
154
+ *
155
+ * @since 6.3
156
+ * @access public
157
+ */
158
+ public function settings_field_enable_css() {
159
+ ?>
160
+ <input name="theme_my_login[enable_css]" type="checkbox" id="theme_my_login_enable_css" value="1"<?php checked( 1, $this->get_option( 'enable_css' ) ); ?> />
161
+ <label for="theme_my_login_enable_css"><?php _e( 'Enable "theme-my-login.css"', 'theme-my-login' ); ?></label>
162
+ <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>
163
+ <?php
164
+ }
165
+
166
+ /**
167
+ * Renders Login Type settings field
168
+ *
169
+ * @since 6.3
170
+ * @access public
171
+ */
172
+ public function settings_field_login_type() {
173
+ ?>
174
+
175
+ <ul>
176
+
177
+ <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_default" value="default"<?php checked( 'default', $this->get_option( 'login_type' ) ); ?> />
178
+ <label for="theme_my_login_login_type_default"><?php _e( 'Username or E-mail', 'theme-my-login' ); ?></label></li>
179
+
180
+ <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_username" value="username"<?php checked( 'username', $this->get_option( 'login_type' ) ); ?> />
181
+ <label for="theme_my_login_login_type_username"><?php _e( 'Username only', 'theme-my-login' ); ?></label></li>
182
+
183
+ <li><input name="theme_my_login[login_type]" type="radio" id="theme_my_login_login_type_email" value="email"<?php checked( 'email', $this->get_option( 'login_type' ) ); ?> />
184
+ <label for="theme_my_login_login_type_email"><?php _e( 'E-mail only', 'theme-my-login' ); ?></label></li>
185
+
186
+ </ul>
187
+
188
+ <p class="description"><?php _e( 'Allow users to login using their username and/or e-mail address.', 'theme-my-login' ); ?></p>
189
+
190
+ <?php
191
+ }
192
+
193
+ /**
194
+ * Renders Modules settings field
195
+ *
196
+ * @since 6.3
197
+ * @access public
198
+ */
199
+ public function settings_field_modules() {
200
+ foreach ( get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) ) as $path => $data ) {
201
+ $id = sanitize_key( $data['Name'] );
202
+ ?>
203
+ <input name="theme_my_login[active_modules][]" type="checkbox" id="theme_my_login_active_modules_<?php echo $id; ?>" value="<?php echo $path; ?>"<?php checked( in_array( $path, (array) $this->get_option( 'active_modules' ) ) ); ?> />
204
+ <label for="theme_my_login_active_modules_<?php echo $id; ?>"><?php printf( __( 'Enable %s', 'theme-my-login' ), $data['Name'] ); ?></label><br />
205
+ <?php if ( $data['Description'] ) : ?>
206
+ <p class="description"><?php echo $data['Description']; ?></p>
207
+ <?php endif;
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Sanitizes TML settings
213
+ *
214
+ * This is the callback for register_setting()
215
+ *
216
+ * @since 6.0
217
+ * @access public
218
+ *
219
+ * @param string|array $settings Settings passed in from filter
220
+ * @return string|array Sanitized settings
221
+ */
222
+ public function save_settings( $settings ) {
223
+ $settings['enable_css'] = ! empty( $settings['enable_css'] );
224
+ $settings['login_type'] = in_array( $settings['login_type'], array( 'default', 'username', 'email' ) ) ? $settings['login_type'] : 'default';
225
+ $settings['active_modules'] = isset( $settings['active_modules'] ) ? (array) $settings['active_modules'] : array();
226
+
227
+ // If we have modules to activate
228
+ if ( $activate = array_diff( $settings['active_modules'], $this->get_option( 'active_modules', array() ) ) ) {
229
+ foreach ( $activate as $module ) {
230
+ if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
231
+ include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
232
+ do_action( 'tml_activate_' . $module );
233
+ }
234
+ }
235
+
236
+ // If we have modules to deactivate
237
+ if ( $deactivate = array_diff( $this->get_option( 'active_modules', array() ), $settings['active_modules'] ) ) {
238
+ foreach ( $deactivate as $module ) {
239
+ do_action( 'tml_deactivate_' . $module );
240
+ }
241
+ }
242
+
243
+ $settings = wp_parse_args( $settings, $this->get_options() );
244
+
245
+ return $settings;
246
+ }
247
+
248
+ /**
249
+ * Installs TML
250
+ *
251
+ * @since 6.0
252
+ * @access public
253
+ */
254
+ public function install() {
255
+ global $wpdb;
256
+
257
+ // Current version
258
+ $version = $this->get_option( 'version', Theme_My_Login::VERSION );
259
+
260
+ // Check if legacy page exists
261
+ if ( $page_id = $this->get_option( 'page_id' ) ) {
262
+ $page = get_post( $page_id );
263
+ } else {
264
+ $page = get_page_by_title( 'Login' );
265
+ }
266
+
267
+ // 4.4 upgrade
268
+ if ( version_compare( $version, '4.4', '<' ) ) {
269
+ remove_role( 'denied' );
270
+ }
271
+
272
+ // 6.0 upgrade
273
+ if ( version_compare( $version, '6.0', '<' ) ) {
274
+ // Replace shortcode
275
+ if ( $page ) {
276
+ $page->post_content = str_replace( '[theme-my-login-page]', '[theme-my-login]', $page->post_content );
277
+ wp_update_post( $page );
278
+ }
279
+ }
280
+
281
+ // 6.3 upgrade
282
+ if ( version_compare( $version, '6.3.3', '<' ) ) {
283
+ // Delete obsolete options
284
+ $this->delete_option( 'page_id' );
285
+ $this->delete_option( 'show_page' );
286
+ $this->delete_option( 'initial_nag' );
287
+ $this->delete_option( 'permalinks' );
288
+ $this->delete_option( 'flush_rules' );
289
+
290
+ // Move options to their own rows
291
+ foreach ( $this->get_options() as $key => $value ) {
292
+ if ( in_array( $key, array( 'active_modules' ) ) )
293
+ continue;
294
+
295
+ if ( ! is_array( $value ) )
296
+ continue;
297
+
298
+ update_option( "theme_my_login_{$key}", $value );
299
+
300
+ $this->delete_option( $key );
301
+ }
302
+
303
+ // Maybe create login page?
304
+ if ( $page ) {
305
+ // Make sure the page is not in the trash
306
+ if ( 'trash' == $page->post_status )
307
+ wp_untrash_post( $page->ID );
308
+
309
+ update_post_meta( $page->ID, '_tml_action', 'login' );
310
+ }
311
+ }
312
+
313
+ // 6.3.7 upgrade
314
+ if ( version_compare( $version, '6.3.7', '<' ) ) {
315
+ // Convert TML pages to regular pages
316
+ $wpdb->update( $wpdb->posts, array( 'post_type' => 'page' ), array( 'post_type' => 'tml_page' ) );
317
+
318
+ // Get rid of stale rewrite rules
319
+ flush_rewrite_rules( false );
320
+ }
321
+
322
+ // 6.4 upgrade
323
+ if ( version_compare( $version, '6.4', '<' ) ) {
324
+ // Convert e-mail login option
325
+ if ( $this->get_option( 'email_login' ) )
326
+ $this->set_option( 'login_type', 'both' );
327
+ $this->delete_option( 'email_login' );
328
+ }
329
+
330
+ // 6.4.5 upgrade
331
+ if ( version_compare( $version, '6.4.5', '<' ) ) {
332
+ // Convert login type option
333
+ $login_type = $this->get_option( 'login_type' );
334
+ if ( 'both' == $login_type ) {
335
+ $this->set_option( 'login_type', 'default' );
336
+ } elseif ( 'default' == $login_type ) {
337
+ $this->set_option( 'login_type', 'username' );
338
+ }
339
+ }
340
+
341
+ // Setup default pages
342
+ foreach ( Theme_My_Login::default_pages() as $action => $title ) {
343
+ if ( ! $page_id = Theme_My_Login::get_page_id( $action ) ) {
344
+ $page_id = wp_insert_post( array(
345
+ 'post_title' => $title,
346
+ 'post_name' => $action,
347
+ 'post_status' => 'publish',
348
+ 'post_type' => 'page',
349
+ 'post_content' => '[theme-my-login]',
350
+ 'comment_status' => 'closed',
351
+ 'ping_status' => 'closed'
352
+ ) );
353
+ update_post_meta( $page_id, '_tml_action', $action );
354
+ }
355
+ }
356
+
357
+ // Activate modules
358
+ foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
359
+ if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
360
+ include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
361
+ do_action( 'tml_activate_' . $module );
362
+ }
363
+
364
+ $this->set_option( 'version', Theme_My_Login::VERSION );
365
+ $this->save_options();
366
+ }
367
+
368
+ /**
369
+ * Wrapper for multisite uninstallation
370
+ *
371
+ * @since 6.1
372
+ * @access public
373
+ */
374
+ public static function uninstall() {
375
+ global $wpdb;
376
+
377
+ if ( is_multisite() ) {
378
+ if ( isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
379
+ $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
380
+ foreach ( $blogids as $blog_id ) {
381
+ switch_to_blog( $blog_id );
382
+ self::_uninstall();
383
+ }
384
+ restore_current_blog();
385
+ return;
386
+ }
387
+ }
388
+ self::_uninstall();
389
+ }
390
+
391
+ /**
392
+ * Uninstalls TML
393
+ *
394
+ * @since 6.0
395
+ * @access protected
396
+ */
397
+ protected static function _uninstall() {
398
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
399
+
400
+ // Run module uninstall hooks
401
+ $modules = get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) );
402
+ foreach ( array_keys( $modules ) as $module ) {
403
+ $module = plugin_basename( trim( $module ) );
404
+
405
+ if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
406
+ @include ( THEME_MY_LOGIN_PATH . '/modules/' . $module );
407
+
408
+ do_action( 'tml_uninstall_' . $module );
409
+ }
410
+
411
+ // Get pages
412
+ $pages = get_posts( array(
413
+ 'post_type' => 'page',
414
+ 'post_status' => 'any',
415
+ 'meta_key' => '_tml_action',
416
+ 'posts_per_page' => -1
417
+ ) );
418
+
419
+ // Delete pages
420
+ foreach ( $pages as $page ) {
421
+ wp_delete_post( $page->ID, true );
422
+ }
423
+
424
+ // Delete options
425
+ delete_option( 'theme_my_login' );
426
+ delete_option( 'widget_theme-my-login' );
427
+ }
428
+ }
429
+ endif; // Class exists
430
+
includes/class-theme-my-login-common.php CHANGED
@@ -86,6 +86,7 @@ class Theme_My_Login_Common {
86
  public static function replace_vars( $input, $user_id = '', $replacements = array() ) {
87
  $defaults = array(
88
  '%site_url%' => get_bloginfo( 'url' ),
 
89
  '%user_ip%' => $_SERVER['REMOTE_ADDR']
90
  );
91
  $replacements = wp_parse_args( $replacements, $defaults );
86
  public static function replace_vars( $input, $user_id = '', $replacements = array() ) {
87
  $defaults = array(
88
  '%site_url%' => get_bloginfo( 'url' ),
89
+ '%siteurl%' => get_bloginfo( 'url' ),
90
  '%user_ip%' => $_SERVER['REMOTE_ADDR']
91
  );
92
  $replacements = wp_parse_args( $replacements, $defaults );
includes/class-theme-my-login-ms-signup.php CHANGED
@@ -1,567 +1,567 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login multisite signup class
4
- *
5
- * @package Theme_My_Login
6
- * @since 6.1
7
- */
8
-
9
- if ( ! class_exists( 'Theme_My_Login_MS_Signup' ) ) :
10
- /*
11
- * Theme My Login multisite signup class
12
- *
13
- * This class contains properties and methods common to the multisite signup process.
14
- *
15
- * @since 6.1
16
- */
17
- class Theme_My_Login_MS_Signup extends Theme_My_Login_Abstract {
18
- /**
19
- * Returns singleton instance
20
- *
21
- * @since 6.3
22
- * @access public
23
- * @return object
24
- */
25
- public static function get_object( $class = null ) {
26
- return parent::get_object( __CLASS__ );
27
- }
28
-
29
- /**
30
- * Loads the object
31
- *
32
- * @since 6.1
33
- * @access public
34
- */
35
- public function load() {
36
-
37
- $theme_my_login = Theme_My_Login::get_object();
38
-
39
- add_action( 'tml_request_register', array( $this, 'tml_request_register' ) );
40
- add_action( 'tml_request_activate', array( $this, 'tml_request_activate' ) );
41
- add_action( 'tml_display_register', array( $this, 'tml_display_register' ) );
42
- add_action( 'tml_display_activate', array( $this, 'tml_display_activate' ) );
43
- add_filter( 'tml_title', array( $this, 'tml_title' ), 10, 2 );
44
-
45
- add_action( 'switch_blog', array( $theme_my_login, 'load_options' ) );
46
- add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 10, 2 );
47
-
48
- add_filter( 'site_url', array( $this, 'site_url' ), 9, 3 );
49
- add_filter( 'home_url', array( $this, 'site_url' ), 9, 3 );
50
- add_filter( 'network_site_url', array( $this, 'network_site_url' ), 10, 3 );
51
- add_filter( 'network_home_url', array( $this, 'network_site_url' ), 10, 3 );
52
- add_filter( 'clean_url', array( $this, 'clean_url' ), 10, 3 );
53
- }
54
-
55
- /**
56
- * Handles register action
57
- *
58
- * @since 6.1
59
- * @access public
60
- *
61
- * @param object $theme_my_login Theme_My_Login object
62
- */
63
- public function tml_request_register( &$theme_my_login ) {
64
- global $current_site;
65
-
66
- add_action( 'wp_head', 'wp_no_robots' );
67
- add_action( 'wp_head', array( $this, 'signup_header' ) );
68
-
69
- if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
70
- wp_redirect( network_home_url() );
71
- exit;
72
- }
73
-
74
- if ( ! is_main_site() ) {
75
- wp_redirect( network_home_url( 'wp-signup.php' ) );
76
- exit;
77
- }
78
- }
79
-
80
- /**
81
- * Displays the registration page
82
- *
83
- * @since 6.1
84
- * @access public
85
- *
86
- * @param object $template Theme_My_Login_Template object
87
- */
88
- public function tml_display_register( &$template ) {
89
- global $wpdb, $blogname, $blog_title, $domain, $path, $active_signup;
90
-
91
- $theme_my_login = Theme_My_Login::get_object();
92
-
93
- do_action( 'before_signup_form' );
94
-
95
- echo '<div class="login mu_register" id="theme-my-login' . esc_attr( $template->get_option( 'instance' ) ) . '">';
96
-
97
- $active_signup = get_site_option( 'registration' );
98
- if ( ! $active_signup )
99
- $active_signup = 'all';
100
-
101
- $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
102
-
103
- // Make the signup type translatable.
104
- $i18n_signup['all'] = _x( 'all', 'Multisite active signup type' );
105
- $i18n_signup['none'] = _x( 'none', 'Multisite active signup type' );
106
- $i18n_signup['blog'] = _x( 'blog', 'Multisite active signup type' );
107
- $i18n_signup['user'] = _x( 'user', 'Multisite active signup type' );
108
-
109
- if ( is_super_admin() )
110
- echo '<p class="message">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.', 'theme-my-login' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'ms-options.php' ) ) ) . '</p>';
111
-
112
- $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
113
-
114
- $current_user = wp_get_current_user();
115
- if ( $active_signup == "none" ) {
116
- _e( 'Registration has been disabled.', 'theme-my-login' );
117
- } elseif ( $active_signup == 'blog' && ! is_user_logged_in() ) {
118
- printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.', 'theme-my-login' ), wp_login_url( Theme_My_Login_Common::get_current_url() ) );
119
- } else {
120
- $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
121
- switch ( $stage ) {
122
- case 'validate-user-signup' :
123
- if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) {
124
- $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
125
- extract( $result );
126
-
127
- $theme_my_login->errors = $errors;
128
-
129
- if ( $errors->get_error_code() ) {
130
- $this->signup_user( $user_name, $user_email );
131
- break;
132
- }
133
-
134
- if ( 'blog' == $_POST['signup_for'] ) {
135
- $this->signup_blog( $user_name, $user_email );
136
- break;
137
- }
138
-
139
- wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
140
-
141
- ?>
142
- <h2><?php printf( __( '%s is your new username', 'theme-my-login' ), $user_name) ?></h2>
143
- <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.', 'theme-my-login' ) ?></p>
144
- <p><?php printf(__( 'Check your inbox at <strong>%1$s</strong> and click the link given.', 'theme-my-login' ), $user_email) ?></p>
145
- <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.', 'theme-my-login' ); ?></p>
146
- <?php
147
- do_action( 'signup_finished' );
148
- } else {
149
- _e( 'User registration has been disabled.', 'theme-my-login' );
150
- }
151
- break;
152
- case 'validate-blog-signup':
153
- if ( $active_signup == 'all' || $active_signup == 'blog' ) {
154
- // Re-validate user info.
155
- $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
156
- extract( $result );
157
-
158
- $theme_my_login->errors = $errors;
159
-
160
- if ( $errors->get_error_code() ) {
161
- $this->signup_user( $user_name, $user_email );
162
- break;
163
- }
164
-
165
- $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
166
- extract( $result );
167
-
168
- $theme_my_login->errors = $errors;
169
-
170
- if ( $errors->get_error_code() ) {
171
- $this->signup_blog( $user_name, $user_email, $blogname, $blog_title );
172
- break;
173
- }
174
-
175
- $public = (int) $_POST['blog_public'];
176
- $meta = array ('lang_id' => 1, 'public' => $public);
177
- $meta = apply_filters( 'add_signup_meta', $meta );
178
-
179
- wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
180
- ?>
181
- <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.', 'theme-my-login' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
182
-
183
- <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.', 'theme-my-login' ) ?></p>
184
- <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.', 'theme-my-login' ), $user_email) ?></p>
185
- <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.', 'theme-my-login' ); ?></p>
186
- <h2><?php _e( 'Still waiting for your email?', 'theme-my-login' ); ?></h2>
187
- <p>
188
- <?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:', 'theme-my-login' ) ?>
189
- <ul id="noemail-tips">
190
- <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'theme-my-login' ) ?></strong></p></li>
191
- <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.', 'theme-my-login' ) ?></p></li>
192
- <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.', 'theme-my-login' ), $user_email ) ?></li>
193
- </ul>
194
- </p>
195
- <?php
196
- do_action( 'signup_finished' );
197
- } else {
198
- _e( 'Site registration has been disabled.', 'theme-my-login' );
199
- }
200
- break;
201
- case 'gimmeanotherblog':
202
- $current_user = wp_get_current_user();
203
- if ( ! is_user_logged_in() )
204
- die();
205
-
206
- $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $current_user );
207
- extract( $result );
208
-
209
- $theme_my_login->errors = $errors;
210
-
211
- if ( $errors->get_error_code() ) {
212
- $this->signup_another_blog( $blogname, $blog_title );
213
- break;
214
- }
215
-
216
- $public = (int) $_POST['blog_public'];
217
- $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated
218
- $meta = apply_filters( 'add_signup_meta', $meta );
219
-
220
- wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
221
- ?>
222
- <h2><?php printf( __( 'The site %s is yours.', 'theme-my-login' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
223
- <p>
224
- <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.', 'theme-my-login' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $current_user->user_login ) ?>
225
- </p>
226
- <?php
227
- do_action( 'signup_finished' );
228
- break;
229
- case 'default':
230
- default :
231
- $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
232
-
233
- do_action( 'preprocess_signup_form' ); // populate the form from invites, elsewhere?
234
-
235
- if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
236
- $this->signup_another_blog( $newblogname );
237
- elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
238
- $this->signup_user( $newblogname, $user_email );
239
- elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
240
- _e( 'Sorry, new registrations are not allowed at this time.', 'theme-my-login' );
241
- else
242
- _e( 'You are logged in already. No need to register again!', 'theme-my-login' );
243
-
244
- if ( $newblogname ) {
245
- $newblog = get_blogaddress_by_name( $newblogname );
246
-
247
- if ( $active_signup == 'blog' || $active_signup == 'all' )
248
- printf( __( '<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>', 'theme-my-login' ), $newblog );
249
- else
250
- printf( __( '<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>', 'theme-my-login' ), $newblog );
251
- }
252
- break;
253
- }
254
- }
255
- echo '</div>';
256
- do_action( 'after_signup_form' );
257
- }
258
-
259
- /**
260
- * Fires WP signup hooks
261
- *
262
- * @since 6.1
263
- * @access public
264
- */
265
- public function signup_header() {
266
- do_action( 'signup_header' );
267
- }
268
-
269
- /**
270
- * Processes/displays user signup form
271
- *
272
- * @since 6.1
273
- * @access public
274
- *
275
- * @param string $user_name The posted username
276
- * @param string $user_email The posted user e-mail
277
- */
278
- public function signup_user( $user_name = '', $user_email = '' ) {
279
- global $current_site, $active_signup;
280
-
281
- $theme_my_login = Theme_My_Login::get_object();
282
-
283
- $template = $theme_my_login->get_active_instance();
284
-
285
- // allow definition of default variables
286
- $filtered_results = apply_filters( 'signup_user_init', array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $theme_my_login->errors ) );
287
- $user_name = $filtered_results['user_name'];
288
- $user_email = $filtered_results['user_email'];
289
- $errors = $filtered_results['errors'];
290
-
291
- $templates = (array) $template->get_option( 'ms_signup_user_template', array() );
292
- $templates[] = 'ms-signup-user-form.php';
293
-
294
- $template->get_template( $templates, true, compact( 'current_site', 'active_signup', 'user_name', 'user_email', 'errors' ) );
295
- }
296
-
297
- /**
298
- * Processes/displays blog signup form
299
- *
300
- * @since 6.1
301
- * @access public
302
- *
303
- * @param string $user_name The posted username
304
- * @param string $user_email The posted user e-mail
305
- * @param string $blogname The posted blog name
306
- * @param string $blog_title The posted blog title
307
- */
308
- public function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '' ) {
309
- global $current_site;
310
-
311
- $theme_my_login = Theme_My_Login::get_object();
312
-
313
- $template = $theme_my_login->get_active_instance();
314
-
315
- // allow definition of default variables
316
- $filtered_results = apply_filters( 'signup_blog_init', array( 'user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $theme_my_login->errors ) );
317
- $user_name = $filtered_results['user_name'];
318
- $user_email = $filtered_results['user_email'];
319
- $blogname = $filtered_results['blogname'];
320
- $blog_title = $filtered_results['blog_title'];
321
- $errors = $filtered_results['errors'];
322
-
323
- if ( empty( $blogname ) )
324
- $blogname = $user_name;
325
-
326
- $templates = (array) $template->get_option( 'ms_signup_blog_template', array() );
327
- $templates[] = 'ms-signup-blog-form.php';
328
-
329
- $template->get_template( $templates, true, compact( 'current_site', 'user_name', 'user_email', 'blogname', 'blog_title', 'errors' ) );
330
- }
331
-
332
- /**
333
- * Processes/displays another blog signup form
334
- *
335
- * @since 6.1
336
- * @access public
337
- *
338
- * @param string $blogname The posted blog name
339
- * @param string $blog_title The posted blog title
340
- */
341
- public function signup_another_blog( $blogname = '', $blog_title = '' ) {
342
- global $current_site;
343
-
344
- $theme_my_login = Theme_My_Login::get_object();
345
-
346
- $template = $theme_my_login->get_active_instance();
347
-
348
- // allow definition of default variables
349
- $filtered_results = apply_filters( 'signup_another_blog_init', array( 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $theme_my_login->errors ) );
350
- $blogname = $filtered_results['blogname'];
351
- $blog_title = $filtered_results['blog_title'];
352
- $errors = $filtered_results['errors'];
353
-
354
- $templates = (array) $template->get_option( 'ms_signup_another_blog_template', array() );
355
- $templates[] = 'ms-signup-another-blog-form.php';
356
-
357
- $template->get_template( $templates, true, compact( 'current_site', 'blogname', 'blog_title', 'errors' ) );
358
- }
359
-
360
- /**
361
- * Handles activation action
362
- *
363
- * @since 6.1
364
- * @access public
365
- *
366
- * @param object $theme_my_login Theme_My_Login object
367
- */
368
- public function tml_request_activate( &$theme_my_login ) {
369
- global $current_site, $wp_object_cache;
370
-
371
- if ( is_object( $wp_object_cache ) )
372
- $wp_object_cache->cache_enabled = false;
373
-
374
- add_action( 'wp_head', array( $this, 'activate_header' ) );
375
- }
376
-
377
- /**
378
- * Outputs the activation page
379
- *
380
- * @since 6.1
381
- * @access public
382
- *
383
- * @param object $template Theme_My_Login_Template object
384
- */
385
- public function tml_display_activate( &$template ) {
386
- global $blog_id;
387
-
388
- echo '<div class="login" id="theme-my-login' . esc_attr( $template->get_option( 'instance' ) ) . '">';
389
-
390
- if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
391
-
392
- <h2><?php _e( 'Activation Key Required', 'theme-my-login' ) ?></h2>
393
- <form name="activateform" id="activateform" method="post" action="<?php $template->the_action_url( 'activate' ); ?>">
394
- <p>
395
- <label for="key<?php $template->the_instance(); ?>"><?php _e( 'Activation Key:', 'theme-my-login' ) ?></label>
396
- <br /><input type="text" name="key<?php $template->the_instance(); ?>" id="key" value="" size="50" />
397
- </p>
398
- <p class="submit">
399
- <input id="submit<?php $template->the_instance(); ?>" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate', 'theme-my-login' ) ?>" />
400
- </p>
401
- </form>
402
-
403
- <?php } else {
404
-
405
- $key = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
406
- $result = wpmu_activate_signup( $key );
407
- if ( is_wp_error( $result ) ) {
408
- if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
409
- $signup = $result->get_error_data();
410
- ?>
411
- <h2><?php _e( 'Your account is now active!', 'theme-my-login' ); ?></h2>
412
- <?php
413
- echo '<p class="lead-in">';
414
- if ( $signup->domain . $signup->path == '' ) {
415
- printf( __( 'Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.', 'theme-my-login' ), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) );
416
- } else {
417
- printf( __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.', 'theme-my-login' ), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword' ) );
418
- }
419
- echo '</p>';
420
- } else {
421
- ?>
422
- <h2><?php _e( 'An error occurred during the activation', 'theme-my-login' ); ?></h2>
423
- <?php
424
- echo '<p>' . $result->get_error_message() . '</p>';
425
- }
426
- } else {
427
- extract( $result );
428
- $url = get_blogaddress_by_id( (int) $blog_id );
429
- $user = new WP_User( (int) $user_id );
430
- ?>
431
- <h2><?php _e( 'Your account is now active!', 'theme-my-login' ); ?></h2>
432
-
433
- <div id="signup-welcome">
434
- <p><span class="h3"><?php _e( 'Username:', 'theme-my-login' ); ?></span> <?php echo $user->user_login ?></p>
435
- <p><span class="h3"><?php _e( 'Password:', 'theme-my-login' ); ?></span> <?php echo $password; ?></p>
436
- </div>
437
-
438
- <?php if ( $url != network_home_url( '', 'http' ) ) : switch_to_blog( (int) $blog_id ); ?>
439
- <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>', 'theme-my-login' ), $url, wp_login_url() ); ?></p>
440
- <?php restore_current_blog(); else: ?>
441
- <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'theme-my-login' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); ?></p>
442
- <?php endif;
443
- }
444
- }
445
- echo '</div>';
446
- }
447
-
448
- /**
449
- * Fires WP activation hooks
450
- *
451
- * @since 6.1
452
- * @access public
453
- */
454
- public function activate_header() {
455
- do_action( 'activate_header' );
456
- do_action( 'activate_wp_head' );
457
- }
458
-
459
- /**
460
- * Changes page title for activation action
461
- *
462
- * @since 6.1
463
- * @access public
464
- *
465
- * @param string $title The page title
466
- * @param string $action The requested action
467
- * @return string The filtered title
468
- */
469
- public function tml_title( $title, $action ) {
470
- if ( 'activate' == $action )
471
- $title = __( 'Activate', 'theme-my-login' );
472
- return $title;
473
- }
474
-
475
- /**
476
- * Activates plugin for new multisite blogs
477
- *
478
- * @since 6.1
479
- * @access public
480
- *
481
- * @param int $blog_id ID of new blog
482
- * @param int $user_id ID of blog owner
483
- */
484
- public function wpmu_new_blog( $blog_id, $user_id ) {
485
- global $wpdb;
486
- require_once ( ABSPATH . '/wp-admin/includes/plugin.php' );
487
- if ( is_plugin_active_for_network( plugin_basename( THEME_MY_LOGIN_PATH ) . '/theme-my-login.php' ) ) {
488
- require_once( THEME_MY_LOGIN_PATH . '/admin/class-theme-my-login-admin.php' );
489
- switch_to_blog( $blog_id );
490
- $admin = Theme_My_Login_Admin::get_object();
491
- $admin->install();
492
- unset( $admin );
493
- restore_current_blog();
494
- }
495
- }
496
-
497
- /**
498
- * Rewrites URL's created by site_url containing wp-signup.php or wp-activate.php
499
- *
500
- * @since 6.1
501
- * @access public
502
- *
503
- * @param string $url The URL
504
- * @param string $path The path specified
505
- * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
506
- * @return string The modified URL
507
- */
508
- public function site_url( $url, $path, $orig_scheme ) {
509
- global $pagenow;
510
-
511
- $theme_my_login = Theme_My_Login::get_object();
512
-
513
- if ( in_array( $pagenow, array( 'wp-login.php', 'wp-signup.php', 'wp-activate.php' ) ) )
514
- return $url;
515
-
516
- $actions = array(
517
- 'wp-signup.php' => 'register',
518
- 'wp-activate.php' => 'activate'
519
- );
520
-
521
- foreach ( $actions as $page => $action ) {
522
- if ( false !== strpos( $url, $page ) ) {
523
- $url = add_query_arg( 'action', $action, str_replace( $page, 'wp-login.php', $url ) );
524
- break;
525
- }
526
- }
527
- return $url;
528
- }
529
-
530
- /**
531
- * Rewrites URL's created by network_site_url
532
- *
533
- * @since 6.3
534
- * @access public
535
- *
536
- * @param string $url The URL
537
- * @param string $path The path specified
538
- * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
539
- * @return string The modified URL
540
- */
541
- public function network_site_url( $url, $path, $orig_scheme ) {
542
- global $current_site;
543
-
544
- $url = $this->site_url( $url, $path, $orig_scheme );
545
-
546
- switch_to_blog( 1 );
547
-
548
- $url = Theme_My_Login::get_object()->site_url( $url, $path, $orig_scheme, $current_site->blog_id );
549
-
550
- restore_current_blog();
551
-
552
- return $url;
553
- }
554
-
555
- /**
556
- * Don't clean activate URL
557
- *
558
- * @since 6.1
559
- * @access public
560
- */
561
- public function clean_url( $url, $original_url, $context ) {
562
- if ( strpos( $original_url, 'action=activate' ) !== false )
563
- return $original_url;
564
- return $url;
565
- }
566
- }
567
- endif; // Class exists
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login multisite signup class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @since 6.1
7
+ */
8
+
9
+ if ( ! class_exists( 'Theme_My_Login_MS_Signup' ) ) :
10
+ /*
11
+ * Theme My Login multisite signup class
12
+ *
13
+ * This class contains properties and methods common to the multisite signup process.
14
+ *
15
+ * @since 6.1
16
+ */
17
+ class Theme_My_Login_MS_Signup extends Theme_My_Login_Abstract {
18
+ /**
19
+ * Returns singleton instance
20
+ *
21
+ * @since 6.3
22
+ * @access public
23
+ * @return object
24
+ */
25
+ public static function get_object( $class = null ) {
26
+ return parent::get_object( __CLASS__ );
27
+ }
28
+
29
+ /**
30
+ * Loads the object
31
+ *
32
+ * @since 6.1
33
+ * @access public
34
+ */
35
+ public function load() {
36
+
37
+ $theme_my_login = Theme_My_Login::get_object();
38
+
39
+ add_action( 'tml_request_register', array( $this, 'tml_request_register' ) );
40
+ add_action( 'tml_request_activate', array( $this, 'tml_request_activate' ) );
41
+ add_action( 'tml_display_register', array( $this, 'tml_display_register' ) );
42
+ add_action( 'tml_display_activate', array( $this, 'tml_display_activate' ) );
43
+ add_filter( 'tml_title', array( $this, 'tml_title' ), 10, 2 );
44
+
45
+ add_action( 'switch_blog', array( $theme_my_login, 'load_options' ) );
46
+ add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 10, 2 );
47
+
48
+ add_filter( 'site_url', array( $this, 'site_url' ), 9, 3 );
49
+ add_filter( 'home_url', array( $this, 'site_url' ), 9, 3 );
50
+ add_filter( 'network_site_url', array( $this, 'network_site_url' ), 10, 3 );
51
+ add_filter( 'network_home_url', array( $this, 'network_site_url' ), 10, 3 );
52
+ add_filter( 'clean_url', array( $this, 'clean_url' ), 10, 3 );
53
+ }
54
+
55
+ /**
56
+ * Handles register action
57
+ *
58
+ * @since 6.1
59
+ * @access public
60
+ *
61
+ * @param object $theme_my_login Theme_My_Login object
62
+ */
63
+ public function tml_request_register( &$theme_my_login ) {
64
+ global $current_site;
65
+
66
+ add_action( 'wp_head', 'wp_no_robots' );
67
+ add_action( 'wp_head', array( $this, 'signup_header' ) );
68
+
69
+ if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) {
70
+ wp_redirect( network_home_url() );
71
+ exit;
72
+ }
73
+
74
+ if ( ! is_main_site() ) {
75
+ wp_redirect( network_home_url( 'wp-signup.php' ) );
76
+ exit;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Displays the registration page
82
+ *
83
+ * @since 6.1
84
+ * @access public
85
+ *
86
+ * @param object $template Theme_My_Login_Template object
87
+ */
88
+ public function tml_display_register( &$template ) {
89
+ global $wpdb, $blogname, $blog_title, $domain, $path, $active_signup;
90
+
91
+ $theme_my_login = Theme_My_Login::get_object();
92
+
93
+ do_action( 'before_signup_form' );
94
+
95
+ echo '<div class="login mu_register" id="theme-my-login' . esc_attr( $template->get_option( 'instance' ) ) . '">';
96
+
97
+ $active_signup = get_site_option( 'registration' );
98
+ if ( ! $active_signup )
99
+ $active_signup = 'all';
100
+
101
+ $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
102
+
103
+ // Make the signup type translatable.
104
+ $i18n_signup['all'] = _x( 'all', 'Multisite active signup type' );
105
+ $i18n_signup['none'] = _x( 'none', 'Multisite active signup type' );
106
+ $i18n_signup['blog'] = _x( 'blog', 'Multisite active signup type' );
107
+ $i18n_signup['user'] = _x( 'user', 'Multisite active signup type' );
108
+
109
+ if ( is_super_admin() )
110
+ echo '<p class="message">' . sprintf( __( 'Greetings Site Administrator! You are currently allowing &#8220;%s&#8221; registrations. To change or disable registration go to your <a href="%s">Options page</a>.', 'theme-my-login' ), $i18n_signup[$active_signup], esc_url( network_admin_url( 'ms-options.php' ) ) ) . '</p>';
111
+
112
+ $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
113
+
114
+ $current_user = wp_get_current_user();
115
+ if ( $active_signup == "none" ) {
116
+ _e( 'Registration has been disabled.', 'theme-my-login' );
117
+ } elseif ( $active_signup == 'blog' && ! is_user_logged_in() ) {
118
+ printf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.', 'theme-my-login' ), wp_login_url( Theme_My_Login_Common::get_current_url() ) );
119
+ } else {
120
+ $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
121
+ switch ( $stage ) {
122
+ case 'validate-user-signup' :
123
+ if ( $active_signup == 'all' || $_POST[ 'signup_for' ] == 'blog' && $active_signup == 'blog' || $_POST[ 'signup_for' ] == 'user' && $active_signup == 'user' ) {
124
+ $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
125
+ extract( $result );
126
+
127
+ $theme_my_login->errors = $errors;
128
+
129
+ if ( $errors->get_error_code() ) {
130
+ $this->signup_user( $user_name, $user_email );
131
+ break;
132
+ }
133
+
134
+ if ( 'blog' == $_POST['signup_for'] ) {
135
+ $this->signup_blog( $user_name, $user_email );
136
+ break;
137
+ }
138
+
139
+ wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
140
+
141
+ ?>
142
+ <h2><?php printf( __( '%s is your new username', 'theme-my-login' ), $user_name) ?></h2>
143
+ <p><?php _e( 'But, before you can start using your new username, <strong>you must activate it</strong>.', 'theme-my-login' ) ?></p>
144
+ <p><?php printf(__( 'Check your inbox at <strong>%1$s</strong> and click the link given.', 'theme-my-login' ), $user_email) ?></p>
145
+ <p><?php _e( 'If you do not activate your username within two days, you will have to sign up again.', 'theme-my-login' ); ?></p>
146
+ <?php
147
+ do_action( 'signup_finished' );
148
+ } else {
149
+ _e( 'User registration has been disabled.', 'theme-my-login' );
150
+ }
151
+ break;
152
+ case 'validate-blog-signup':
153
+ if ( $active_signup == 'all' || $active_signup == 'blog' ) {
154
+ // Re-validate user info.
155
+ $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
156
+ extract( $result );
157
+
158
+ $theme_my_login->errors = $errors;
159
+
160
+ if ( $errors->get_error_code() ) {
161
+ $this->signup_user( $user_name, $user_email );
162
+ break;
163
+ }
164
+
165
+ $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
166
+ extract( $result );
167
+
168
+ $theme_my_login->errors = $errors;
169
+
170
+ if ( $errors->get_error_code() ) {
171
+ $this->signup_blog( $user_name, $user_email, $blogname, $blog_title );
172
+ break;
173
+ }
174
+
175
+ $public = (int) $_POST['blog_public'];
176
+ $meta = array ('lang_id' => 1, 'public' => $public);
177
+ $meta = apply_filters( 'add_signup_meta', $meta );
178
+
179
+ wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
180
+ ?>
181
+ <h2><?php printf( __( 'Congratulations! Your new site, %s, is almost ready.', 'theme-my-login' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
182
+
183
+ <p><?php _e( 'But, before you can start using your site, <strong>you must activate it</strong>.', 'theme-my-login' ) ?></p>
184
+ <p><?php printf( __( 'Check your inbox at <strong>%s</strong> and click the link given.', 'theme-my-login' ), $user_email) ?></p>
185
+ <p><?php _e( 'If you do not activate your site within two days, you will have to sign up again.', 'theme-my-login' ); ?></p>
186
+ <h2><?php _e( 'Still waiting for your email?', 'theme-my-login' ); ?></h2>
187
+ <p>
188
+ <?php _e( 'If you haven&#8217;t received your email yet, there are a number of things you can do:', 'theme-my-login' ) ?>
189
+ <ul id="noemail-tips">
190
+ <li><p><strong><?php _e( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'theme-my-login' ) ?></strong></p></li>
191
+ <li><p><?php _e( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.', 'theme-my-login' ) ?></p></li>
192
+ <li><?php printf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.', 'theme-my-login' ), $user_email ) ?></li>
193
+ </ul>
194
+ </p>
195
+ <?php
196
+ do_action( 'signup_finished' );
197
+ } else {
198
+ _e( 'Site registration has been disabled.', 'theme-my-login' );
199
+ }
200
+ break;
201
+ case 'gimmeanotherblog':
202
+ $current_user = wp_get_current_user();
203
+ if ( ! is_user_logged_in() )
204
+ die();
205
+
206
+ $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $current_user );
207
+ extract( $result );
208
+
209
+ $theme_my_login->errors = $errors;
210
+
211
+ if ( $errors->get_error_code() ) {
212
+ $this->signup_another_blog( $blogname, $blog_title );
213
+ break;
214
+ }
215
+
216
+ $public = (int) $_POST['blog_public'];
217
+ $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // deprecated
218
+ $meta = apply_filters( 'add_signup_meta', $meta );
219
+
220
+ wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );
221
+ ?>
222
+ <h2><?php printf( __( 'The site %s is yours.', 'theme-my-login' ), "<a href='http://{$domain}{$path}'>{$blog_title}</a>" ) ?></h2>
223
+ <p>
224
+ <?php printf( __( '<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as &#8220;%4$s&#8221; using your existing password.', 'theme-my-login' ), $domain.$path, $domain.$path, "http://" . $domain.$path . "wp-login.php", $current_user->user_login ) ?>
225
+ </p>
226
+ <?php
227
+ do_action( 'signup_finished' );
228
+ break;
229
+ case 'default':
230
+ default :
231
+ $user_email = isset( $_POST[ 'user_email' ] ) ? $_POST[ 'user_email' ] : '';
232
+
233
+ do_action( 'preprocess_signup_form' ); // populate the form from invites, elsewhere?
234
+
235
+ if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
236
+ $this->signup_another_blog( $newblogname );
237
+ elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
238
+ $this->signup_user( $newblogname, $user_email );
239
+ elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
240
+ _e( 'Sorry, new registrations are not allowed at this time.', 'theme-my-login' );
241
+ else
242
+ _e( 'You are logged in already. No need to register again!', 'theme-my-login' );
243
+
244
+ if ( $newblogname ) {
245
+ $newblog = get_blogaddress_by_name( $newblogname );
246
+
247
+ if ( $active_signup == 'blog' || $active_signup == 'all' )
248
+ printf( __( '<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>', 'theme-my-login' ), $newblog );
249
+ else
250
+ printf( __( '<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>', 'theme-my-login' ), $newblog );
251
+ }
252
+ break;
253
+ }
254
+ }
255
+ echo '</div>';
256
+ do_action( 'after_signup_form' );
257
+ }
258
+
259
+ /**
260
+ * Fires WP signup hooks
261
+ *
262
+ * @since 6.1
263
+ * @access public
264
+ */
265
+ public function signup_header() {
266
+ do_action( 'signup_header' );
267
+ }
268
+
269
+ /**
270
+ * Processes/displays user signup form
271
+ *
272
+ * @since 6.1
273
+ * @access public
274
+ *
275
+ * @param string $user_name The posted username
276
+ * @param string $user_email The posted user e-mail
277
+ */
278
+ public function signup_user( $user_name = '', $user_email = '' ) {
279
+ global $current_site, $active_signup;
280
+
281
+ $theme_my_login = Theme_My_Login::get_object();
282
+
283
+ $template = $theme_my_login->get_active_instance();
284
+
285
+ // allow definition of default variables
286
+ $filtered_results = apply_filters( 'signup_user_init', array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $theme_my_login->errors ) );
287
+ $user_name = $filtered_results['user_name'];
288
+ $user_email = $filtered_results['user_email'];
289
+ $errors = $filtered_results['errors'];
290
+
291
+ $templates = (array) $template->get_option( 'ms_signup_user_template', array() );
292
+ $templates[] = 'ms-signup-user-form.php';
293
+
294
+ $template->get_template( $templates, true, compact( 'current_site', 'active_signup', 'user_name', 'user_email', 'errors' ) );
295
+ }
296
+
297
+ /**
298
+ * Processes/displays blog signup form
299
+ *
300
+ * @since 6.1
301
+ * @access public
302
+ *
303
+ * @param string $user_name The posted username
304
+ * @param string $user_email The posted user e-mail
305
+ * @param string $blogname The posted blog name
306
+ * @param string $blog_title The posted blog title
307
+ */
308
+ public function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '' ) {
309
+ global $current_site;
310
+
311
+ $theme_my_login = Theme_My_Login::get_object();
312
+
313
+ $template = $theme_my_login->get_active_instance();
314
+
315
+ // allow definition of default variables
316
+ $filtered_results = apply_filters( 'signup_blog_init', array( 'user_name' => $user_name, 'user_email' => $user_email, 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $theme_my_login->errors ) );
317
+ $user_name = $filtered_results['user_name'];
318
+ $user_email = $filtered_results['user_email'];
319
+ $blogname = $filtered_results['blogname'];
320
+ $blog_title = $filtered_results['blog_title'];
321
+ $errors = $filtered_results['errors'];
322
+
323
+ if ( empty( $blogname ) )
324
+ $blogname = $user_name;
325
+
326
+ $templates = (array) $template->get_option( 'ms_signup_blog_template', array() );
327
+ $templates[] = 'ms-signup-blog-form.php';
328
+
329
+ $template->get_template( $templates, true, compact( 'current_site', 'user_name', 'user_email', 'blogname', 'blog_title', 'errors' ) );
330
+ }
331
+
332
+ /**
333
+ * Processes/displays another blog signup form
334
+ *
335
+ * @since 6.1
336
+ * @access public
337
+ *
338
+ * @param string $blogname The posted blog name
339
+ * @param string $blog_title The posted blog title
340
+ */
341
+ public function signup_another_blog( $blogname = '', $blog_title = '' ) {
342
+ global $current_site;
343
+
344
+ $theme_my_login = Theme_My_Login::get_object();
345
+
346
+ $template = $theme_my_login->get_active_instance();
347
+
348
+ // allow definition of default variables
349
+ $filtered_results = apply_filters( 'signup_another_blog_init', array( 'blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $theme_my_login->errors ) );
350
+ $blogname = $filtered_results['blogname'];
351
+ $blog_title = $filtered_results['blog_title'];
352
+ $errors = $filtered_results['errors'];
353
+
354
+ $templates = (array) $template->get_option( 'ms_signup_another_blog_template', array() );
355
+ $templates[] = 'ms-signup-another-blog-form.php';
356
+
357
+ $template->get_template( $templates, true, compact( 'current_site', 'blogname', 'blog_title', 'errors' ) );
358
+ }
359
+
360
+ /**
361
+ * Handles activation action
362
+ *
363
+ * @since 6.1
364
+ * @access public
365
+ *
366
+ * @param object $theme_my_login Theme_My_Login object
367
+ */
368
+ public function tml_request_activate( &$theme_my_login ) {
369
+ global $current_site, $wp_object_cache;
370
+
371
+ if ( is_object( $wp_object_cache ) )
372
+ $wp_object_cache->cache_enabled = false;
373
+
374
+ add_action( 'wp_head', array( $this, 'activate_header' ) );
375
+ }
376
+
377
+ /**
378
+ * Outputs the activation page
379
+ *
380
+ * @since 6.1
381
+ * @access public
382
+ *
383
+ * @param object $template Theme_My_Login_Template object
384
+ */
385
+ public function tml_display_activate( &$template ) {
386
+ global $blog_id;
387
+
388
+ echo '<div class="login" id="theme-my-login' . esc_attr( $template->get_option( 'instance' ) ) . '">';
389
+
390
+ if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
391
+
392
+ <h2><?php _e( 'Activation Key Required', 'theme-my-login' ) ?></h2>
393
+ <form name="activateform" id="activateform" method="post" action="<?php $template->the_action_url( 'activate' ); ?>">
394
+ <p>
395
+ <label for="key<?php $template->the_instance(); ?>"><?php _e( 'Activation Key:', 'theme-my-login' ) ?></label>
396
+ <br /><input type="text" name="key<?php $template->the_instance(); ?>" id="key" value="" size="50" />
397
+ </p>
398
+ <p class="submit">
399
+ <input id="submit<?php $template->the_instance(); ?>" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate', 'theme-my-login' ) ?>" />
400
+ </p>
401
+ </form>
402
+
403
+ <?php } else {
404
+
405
+ $key = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
406
+ $result = wpmu_activate_signup( $key );
407
+ if ( is_wp_error( $result ) ) {
408
+ if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
409
+ $signup = $result->get_error_data();
410
+ ?>
411
+ <h2><?php _e( 'Your account is now active!', 'theme-my-login' ); ?></h2>
412
+ <?php
413
+ echo '<p class="lead-in">';
414
+ if ( $signup->domain . $signup->path == '' ) {
415
+ printf( __( 'Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.', 'theme-my-login' ), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword', 'login' ) );
416
+ } else {
417
+ printf( __( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.', 'theme-my-login' ), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url( 'wp-login.php?action=lostpassword' ) );
418
+ }
419
+ echo '</p>';
420
+ } else {
421
+ ?>
422
+ <h2><?php _e( 'An error occurred during the activation', 'theme-my-login' ); ?></h2>
423
+ <?php
424
+ echo '<p>' . $result->get_error_message() . '</p>';
425
+ }
426
+ } else {
427
+ extract( $result );
428
+ $url = get_blogaddress_by_id( (int) $blog_id );
429
+ $user = new WP_User( (int) $user_id );
430
+ ?>
431
+ <h2><?php _e( 'Your account is now active!', 'theme-my-login' ); ?></h2>
432
+
433
+ <div id="signup-welcome">
434
+ <p><span class="h3"><?php _e( 'Username:', 'theme-my-login' ); ?></span> <?php echo $user->user_login ?></p>
435
+ <p><span class="h3"><?php _e( 'Password:', 'theme-my-login' ); ?></span> <?php echo $password; ?></p>
436
+ </div>
437
+
438
+ <?php if ( $url != network_home_url( '', 'http' ) ) : switch_to_blog( (int) $blog_id ); ?>
439
+ <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>', 'theme-my-login' ), $url, wp_login_url() ); ?></p>
440
+ <?php restore_current_blog(); else: ?>
441
+ <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'theme-my-login' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() ); ?></p>
442
+ <?php endif;
443
+ }
444
+ }
445
+ echo '</div>';
446
+ }
447
+
448
+ /**
449
+ * Fires WP activation hooks
450
+ *
451
+ * @since 6.1
452
+ * @access public
453
+ */
454
+ public function activate_header() {
455
+ do_action( 'activate_header' );
456
+ do_action( 'activate_wp_head' );
457
+ }
458
+
459
+ /**
460
+ * Changes page title for activation action
461
+ *
462
+ * @since 6.1
463
+ * @access public
464
+ *
465
+ * @param string $title The page title
466
+ * @param string $action The requested action
467
+ * @return string The filtered title
468
+ */
469
+ public function tml_title( $title, $action ) {
470
+ if ( 'activate' == $action )
471
+ $title = __( 'Activate', 'theme-my-login' );
472
+ return $title;
473
+ }
474
+
475
+ /**
476
+ * Activates plugin for new multisite blogs
477
+ *
478
+ * @since 6.1
479
+ * @access public
480
+ *
481
+ * @param int $blog_id ID of new blog
482
+ * @param int $user_id ID of blog owner
483
+ */
484
+ public function wpmu_new_blog( $blog_id, $user_id ) {
485
+ global $wpdb;
486
+ require_once ( ABSPATH . '/wp-admin/includes/plugin.php' );
487
+ if ( is_plugin_active_for_network( plugin_basename( THEME_MY_LOGIN_PATH ) . '/theme-my-login.php' ) ) {
488
+ require_once( THEME_MY_LOGIN_PATH . '/admin/class-theme-my-login-admin.php' );
489
+ switch_to_blog( $blog_id );
490
+ $admin = Theme_My_Login_Admin::get_object();
491
+ $admin->install();
492
+ unset( $admin );
493
+ restore_current_blog();
494
+ }
495
+ }
496
+
497
+ /**
498
+ * Rewrites URL's created by site_url containing wp-signup.php or wp-activate.php
499
+ *
500
+ * @since 6.1
501
+ * @access public
502
+ *
503
+ * @param string $url The URL
504
+ * @param string $path The path specified
505
+ * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
506
+ * @return string The modified URL
507
+ */
508
+ public function site_url( $url, $path, $orig_scheme ) {
509
+ global $pagenow;
510
+
511
+ $theme_my_login = Theme_My_Login::get_object();
512
+
513
+ if ( in_array( $pagenow, array( 'wp-login.php', 'wp-signup.php', 'wp-activate.php' ) ) )
514
+ return $url;
515
+
516
+ $actions = array(
517
+ 'wp-signup.php' => 'register',
518
+ 'wp-activate.php' => 'activate'
519
+ );
520
+
521
+ foreach ( $actions as $page => $action ) {
522
+ if ( false !== strpos( $url, $page ) ) {
523
+ $url = add_query_arg( 'action', $action, str_replace( $page, 'wp-login.php', $url ) );
524
+ break;
525
+ }
526
+ }
527
+ return $url;
528
+ }
529
+
530
+ /**
531
+ * Rewrites URL's created by network_site_url
532
+ *
533
+ * @since 6.3
534
+ * @access public
535
+ *
536
+ * @param string $url The URL
537
+ * @param string $path The path specified
538
+ * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
539
+ * @return string The modified URL
540
+ */
541
+ public function network_site_url( $url, $path, $orig_scheme ) {
542
+ global $current_site;
543
+
544
+ $url = $this->site_url( $url, $path, $orig_scheme );
545
+
546
+ switch_to_blog( 1 );
547
+
548
+ $url = Theme_My_Login::get_object()->site_url( $url, $path, $orig_scheme, $current_site->blog_id );
549
+
550
+ restore_current_blog();
551
+
552
+ return $url;
553
+ }
554
+
555
+ /**
556
+ * Don't clean activate URL
557
+ *
558
+ * @since 6.1
559
+ * @access public
560
+ */
561
+ public function clean_url( $url, $original_url, $context ) {
562
+ if ( strpos( $original_url, 'action=activate' ) !== false )
563
+ return $original_url;
564
+ return $url;
565
+ }
566
+ }
567
+ endif; // Class exists
includes/class-theme-my-login-template.php CHANGED
@@ -1,594 +1,594 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login template class
4
- *
5
- * @package Theme_My_Login
6
- * @since 6.0
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 extends Theme_My_Login_Abstract {
18
- /**
19
- * Holds active instance flag
20
- *
21
- * @since 6.3
22
- * @access private
23
- * @var bool
24
- */
25
- private $is_active = false;
26
-
27
- /**
28
- * Constructor
29
- *
30
- * @since 6.0
31
- * @access public
32
- *
33
- * @param array $options Instance options
34
- */
35
- public function __construct( $options = '' ) {
36
- $options = wp_parse_args( $options );
37
- $options = shortcode_atts( self::default_options(), $options );
38
-
39
- $this->set_options( $options );
40
- }
41
-
42
- /**
43
- * Retrieves default options
44
- *
45
- * @since 6.3
46
- * @access public
47
- *
48
- * @return array Default options
49
- */
50
- public static function default_options() {
51
- return array(
52
- 'instance' => 0,
53
- 'default_action' => '',
54
- 'login_template' => '',
55
- 'register_template' => '',
56
- 'lostpassword_template' => '',
57
- 'resetpass_template' => '',
58
- 'user_template' => '',
59
- 'show_title' => true,
60
- 'show_log_link' => true,
61
- 'show_reg_link' => true,
62
- 'show_pass_link' => true,
63
- 'logged_in_widget' => true,
64
- 'logged_out_widget' => true,
65
- 'show_gravatar' => true,
66
- 'gravatar_size' => 50,
67
- 'before_widget' => '',
68
- 'after_widget' => '',
69
- 'before_title' => '',
70
- 'after_title' => ''
71
- );
72
- }
73
-
74
- /**
75
- * Displays output according to current action
76
- *
77
- * @since 6.0
78
- * @access public
79
- *
80
- * @return string HTML output
81
- */
82
- public function display( $action = '' ) {
83
- if ( empty( $action ) )
84
- $action = $this->get_option( 'default_action' );
85
-
86
- ob_start();
87
- echo $this->get_option( 'before_widget' );
88
- if ( $this->get_option( 'show_title' ) )
89
- echo $this->get_option( 'before_title' ) . $this->get_title( $action ) . $this->get_option( 'after_title' ) . "\n";
90
- // Is there a specified template?
91
- if ( has_action( 'tml_display_' . $action ) ) {
92
- do_action_ref_array( 'tml_display_' . $action, array( &$this ) );
93
- } else {
94
- $template = array();
95
- if ( is_user_logged_in() && 'login' == $action ) {
96
- if ( $this->get_option( 'user_template' ) )
97
- $template[] = $this->get_option( 'user_template' );
98
- $template[] = 'user-panel.php';
99
- } else {
100
- switch ( $action ) {
101
- case 'lostpassword':
102
- case 'retrievepassword':
103
- if ( $this->get_option( 'lostpassword_template' ) )
104
- $template[] = $this->get_option( 'lostpassword_template' );
105
- $template[] = 'lostpassword-form.php';
106
- break;
107
- case 'resetpass':
108
- case 'rp':
109
- if ( $this->get_option( 'resetpass_template' ) )
110
- $template[] = $this->get_option( 'resetpass_template' );
111
- $template[] = 'resetpass-form.php';
112
- break;
113
- case 'register':
114
- if ( $this->get_option( 'register_template' ) )
115
- $template[] = $this->get_option( 'register_template' );
116
- $template[] = 'register-form.php';
117
- break;
118
- case 'login':
119
- default :
120
- if ( $this->get_option( 'login_template' ) )
121
- $template[] = $this->get_option( 'login_template' );
122
- $template[] = 'login-form.php';
123
- }
124
- }
125
- $this->get_template( $template );
126
- }
127
- echo $this->get_option( 'after_widget' ) . "\n";
128
- $output = ob_get_contents();
129
- ob_end_clean();
130
- return apply_filters_ref_array( 'tml_display', array( $output, $action, $this ) );
131
- }
132
-
133
- /**
134
- * Returns action title
135
- *
136
- * @since 6.0
137
- * @access public
138
- *
139
- * @param string $action The action to retrieve. Defaults to current action.
140
- * @return string Title of $action
141
- */
142
- public function get_title( $action = '' ) {
143
- if ( empty( $action ) )
144
- $action = $this->get_option( 'default_action' );
145
-
146
- if ( is_admin() )
147
- return;
148
-
149
- if ( is_user_logged_in() && 'login' == $action && $action == $this->get_option( 'default_action' ) ) {
150
- $title = sprintf( __( 'Welcome, %s', 'theme-my-login' ), wp_get_current_user()->display_name );
151
- } else {
152
- if ( $page_id = Theme_My_Login::get_page_id( $action ) ) {
153
- $title = get_post_field( 'post_title', $page_id );
154
- } else {
155
- switch ( $action ) {
156
- case 'register':
157
- $title = __( 'Register', 'theme-my-login' );
158
- break;
159
- case 'lostpassword':
160
- case 'retrievepassword':
161
- case 'resetpass':
162
- case 'rp':
163
- $title = __( 'Lost Password', 'theme-my-login' );
164
- break;
165
- case 'login':
166
- default:
167
- $title = __( 'Log In', 'theme-my-login' );
168
- }
169
- }
170
- }
171
- return apply_filters( 'tml_title', $title, $action );
172
- }
173
-
174
- /**
175
- * Outputs action title
176
- *
177
- * @since 6.0
178
- * @access public
179
- *
180
- * @param string $action The action to retieve. Defaults to current action.
181
- */
182
- public function the_title( $action = '' ) {
183
- echo $this->get_title( $action );
184
- }
185
-
186
- /**
187
- * Returns plugin errors
188
- *
189
- * @since 6.0
190
- * @access public
191
- */
192
- public function get_errors() {
193
- global $error;
194
-
195
- $theme_my_login = Theme_My_Login::get_object();
196
-
197
- $wp_error = $theme_my_login->errors;
198
-
199
- if ( empty( $wp_error ) )
200
- $wp_error = new WP_Error();
201
-
202
- // Incase a plugin uses $error rather than the $errors object
203
- if ( ! empty( $error ) ) {
204
- $wp_error->add('error', $error);
205
- unset($error);
206
- }
207
-
208
- $output = '';
209
- if ( $this->is_active() ) {
210
- if ( $wp_error->get_error_code() ) {
211
- $errors = '';
212
- $messages = '';
213
- foreach ( $wp_error->get_error_codes() as $code ) {
214
- $severity = $wp_error->get_error_data( $code );
215
- foreach ( $wp_error->get_error_messages( $code ) as $error ) {
216
- if ( 'message' == $severity )
217
- $messages .= ' ' . $error . "<br />\n";
218
- else
219
- $errors .= ' ' . $error . "<br />\n";
220
- }
221
- }
222
- if ( ! empty( $errors ) )
223
- $output .= '<p class="error">' . apply_filters( 'login_errors', $errors ) . "</p>\n";
224
- if ( ! empty( $messages ) )
225
- $output .= '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
226
- }
227
- }
228
- return $output;
229
- }
230
-
231
- /**
232
- * Prints plugin errors
233
- *
234
- * @since 6.0
235
- * @access public
236
- */
237
- public function the_errors() {
238
- echo $this->get_errors();
239
- }
240
-
241
- /**
242
- * Returns requested action URL
243
- *
244
- * @since 6.0
245
- * @access public
246
- *
247
- * @param string $action Action to retrieve
248
- * @param string $scheme Scheme to give the URL context
249
- * @return string The requested action URL
250
- */
251
- public function get_action_url( $action = '', $scheme = 'login' ) {
252
-
253
- $instance = $this->get_option( 'instance' );
254
-
255
- if ( $action == $this->get_option( 'default_action' ) ) {
256
- $args = array();
257
- if ( $instance )
258
- $args['instance'] = $instance;
259
- $url = Theme_My_Login_Common::get_current_url( $args );
260
- } else {
261
- $url = Theme_My_Login::get_page_link( $action );
262
- }
263
-
264
- $url = set_url_scheme( $url, $scheme );
265
-
266
- return apply_filters( 'tml_action_url', $url, $action, $scheme, $instance );
267
- }
268
-
269
- /**
270
- * Outputs requested action URL
271
- *
272
- * @since 6.0
273
- * @access public
274
- *
275
- * @param string $action Action to retrieve
276
- * @param string $scheme Scheme to give the URL context
277
- */
278
- public function the_action_url( $action = 'login', $scheme = 'login' ) {
279
- echo esc_url( $this->get_action_url( $action, $scheme ) );
280
- }
281
-
282
- /**
283
- * Returns the action links
284
- *
285
- * @since 6.0
286
- * @access public
287
- *
288
- * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
289
- */
290
- public function get_action_links( $args = '' ) {
291
- $args = wp_parse_args( $args, array(
292
- 'login' => true,
293
- 'register' => true,
294
- 'lostpassword' => true
295
- ) );
296
-
297
- $action_links = array();
298
- if ( $args['login'] && $this->get_option( 'show_log_link' ) ) {
299
- $action_links[] = array(
300
- 'title' => $this->get_title( 'login' ),
301
- 'url' => $this->get_action_url( 'login' )
302
- );
303
- }
304
- if ( $args['register'] && $this->get_option( 'show_reg_link' ) && get_option( 'users_can_register' ) ) {
305
- $action_links[] = array(
306
- 'title' => $this->get_title( 'register' ),
307
- 'url' => $this->get_action_url( 'register' )
308
- );
309
- }
310
- if ( $args['lostpassword'] && $this->get_option( 'show_pass_link' ) ) {
311
- $action_links[] = array(
312
- 'title' => $this->get_title( 'lostpassword' ),
313
- 'url' => $this->get_action_url( 'lostpassword' )
314
- );
315
- }
316
- return apply_filters( 'tml_action_links', $action_links, $args );
317
- }
318
-
319
- /**
320
- * Outputs the action links
321
- *
322
- * @since 6.0
323
- * @access public
324
- *
325
- * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
326
- */
327
- public function the_action_links( $args = '' ) {
328
- if ( $action_links = $this->get_action_links( $args ) ) {
329
- echo '<ul class="tml-action-links">' . "\n";
330
- foreach ( (array) $action_links as $link ) {
331
- echo '<li><a href="' . esc_url( $link['url'] ) . '" rel="nofollow">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
332
- }
333
- echo '</ul>' . "\n";
334
- }
335
- }
336
-
337
- /**
338
- * Returns logged-in user links
339
- *
340
- * @since 6.0
341
- * @access public
342
- *
343
- * @return array Logged-in user links
344
- */
345
- public static function get_user_links() {
346
- $user_links = array(
347
- array(
348
- 'title' => __( 'Dashboard', 'theme-my-login' ),
349
- 'url' => admin_url() ),
350
- array(
351
- 'title' => __( 'Profile', 'theme-my-login' ),
352
- 'url' => admin_url( 'profile.php' )
353
- )
354
- );
355
- return apply_filters( 'tml_user_links', $user_links );
356
- }
357
-
358
- /**
359
- * Outputs logged-in user links
360
- *
361
- * @since 6.0
362
- * @access public
363
- */
364
- public function the_user_links() {
365
- echo '<ul class="tml-user-links">';
366
- foreach ( (array) self::get_user_links() as $link ) {
367
- echo '<li><a href="' . esc_url( $link['url'] ) . '">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
368
- }
369
- echo '<li><a href="' . wp_logout_url() . '">' . self::get_title( 'logout' ) . '</a></li>' . "\n";
370
- echo '</ul>';
371
- }
372
-
373
- /**
374
- * Displays user avatar
375
- *
376
- * @since 6.0
377
- * @access public
378
- */
379
- public function the_user_avatar( $size = '' ) {
380
- if ( empty( $size ) )
381
- $size = $this->get_option( 'gravatar_size', 50 );
382
-
383
- $current_user = wp_get_current_user();
384
-
385
- echo get_avatar( $current_user->ID, $size );
386
- }
387
-
388
- /**
389
- * Returns template message for requested action
390
- *
391
- * @since 6.0
392
- * @access public
393
- *
394
- * @param string $action Action to retrieve
395
- * @return string The requested template message
396
- */
397
- public static function get_action_template_message( $action = '' ) {
398
- switch ( $action ) {
399
- case 'register':
400
- $message = __( 'Register For This Site', 'theme-my-login' );
401
- break;
402
- case 'lostpassword':
403
- $message = __( 'Please enter your username or email address. You will receive a link to create a new password via email.', 'theme-my-login' );
404
- break;
405
- case 'resetpass':
406
- $message = __( 'Enter your new password below.', 'theme-my-login' );
407
- break;
408
- default:
409
- $message = '';
410
- }
411
- $message = apply_filters( 'login_message', $message );
412
-
413
- return apply_filters( 'tml_action_template_message', $message, $action );
414
- }
415
-
416
- /**
417
- * Outputs template message for requested action
418
- *
419
- * @since 6.0
420
- * @access public
421
- *
422
- * @param string $action Action to retrieve
423
- * @param string $before_message Text/HTML to add before the message
424
- * @param string $after_message Text/HTML to add after the message
425
- */
426
- public function the_action_template_message( $action = 'login', $before_message = '<p class="message">', $after_message = '</p>' ) {
427
- if ( $message = self::get_action_template_message( $action ) )
428
- echo $before_message . $message . $after_message;
429
- }
430
-
431
- /**
432
- * Locates specified template
433
- *
434
- * @since 6.0
435
- * @access public
436
- *
437
- * @param string|array $template_names The template(s) to locate
438
- * @param bool $load If true, the template will be included if found
439
- * @param array $args Array of extra variables to make available to template
440
- * @return string|bool Template path if found, false if not
441
- */
442
- public function get_template( $template_names, $load = true, $args = array() ) {
443
-
444
- $theme_my_login = Theme_My_Login::get_object();
445
-
446
- // User friendly access to this
447
- $template = $this;
448
-
449
- // Easy access to current user
450
- $current_user = wp_get_current_user();
451
-
452
- extract( apply_filters_ref_array( 'tml_template_args', array( $args, $this ) ) );
453
-
454
- $template_paths = apply_filters( 'tml_template_paths', array(
455
- get_stylesheet_directory() . '/theme-my-login',
456
- get_stylesheet_directory(),
457
- get_template_directory() . '/theme-my-login',
458
- get_template_directory(),
459
- THEME_MY_LOGIN_PATH . '/templates'
460
- ) );
461
-
462
- foreach ( (array) $template_names as $template_name ) {
463
-
464
- if ( ! $template_name )
465
- continue;
466
-
467
- if ( preg_match( '/\/|\\\\/', $template_name ) )
468
- continue;
469
-
470
- foreach ( $template_paths as $template_path ) {
471
- if ( file_exists( $template_path . '/' . $template_name ) ) {
472
- $located = $template_path . '/' . $template_name;
473
- break 2;
474
- }
475
- }
476
- }
477
-
478
- $located = apply_filters_ref_array( 'tml_template', array( $located, $template_names, $this ) );
479
-
480
- if ( $load && '' != $located )
481
- include( $located );
482
-
483
- return $located;
484
- }
485
-
486
- /**
487
- * Returns the proper redirect URL according to action
488
- *
489
- * @since 6.0
490
- * @access public
491
- *
492
- * @param string $action The action
493
- * @return string The redirect URL
494
- */
495
- public function get_redirect_url( $action = '' ) {
496
-
497
- $theme_my_login = Theme_My_Login::get_object();
498
-
499
- if ( empty( $action ) )
500
- $action = $this->get_option( 'default_action' );
501
-
502
- $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
503
-
504
- switch ( $action ) {
505
- case 'lostpassword' :
506
- case 'retrievepassword' :
507
- $url = apply_filters( 'lostpassword_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=confirm' ) );
508
- break;
509
- case 'register' :
510
- $url = apply_filters( 'registration_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=registered' ) );
511
- break;
512
- case 'login' :
513
- default :
514
- $url = apply_filters( 'login_redirect', ! empty( $redirect_to ) ? $redirect_to : admin_url(), $redirect_to, null );
515
- }
516
- return apply_filters( 'tml_redirect_url', $url, $action );
517
- }
518
-
519
- /**
520
- * Outputs redirect URL
521
- *
522
- * @since 6.0
523
- * @access public
524
- *
525
- * @param string $action The action
526
- */
527
- public function the_redirect_url( $action = '' ) {
528
- echo esc_attr( $this->get_redirect_url( $action ) );
529
- }
530
-
531
- /**
532
- * Outputs current template instance ID
533
- *
534
- * @since 6.0
535
- * @access public
536
- */
537
- public function the_instance() {
538
- if ( $this->get_option( 'instance' ) )
539
- echo esc_attr( $this->get_option( 'instance' ) );
540
- }
541
-
542
- /**
543
- * Returns requested $value
544
- *
545
- * @since 6.0
546
- * @access public
547
- *
548
- * @param string $value The value to retrieve
549
- * @return string|bool The value if it exists, false if not
550
- */
551
- public function get_posted_value( $value ) {
552
- if ( $this->is_active() && isset( $_REQUEST[$value] ) )
553
- return stripslashes( $_REQUEST[$value] );
554
- return false;
555
- }
556
-
557
- /**
558
- * Outputs requested value
559
- *
560
- * @since 6.0
561
- * @access public
562
- *
563
- * @param string $value The value to retrieve
564
- */
565
- public function the_posted_value( $value ) {
566
- echo esc_attr( $this->get_posted_value( $value ) );
567
- }
568
-
569
- /**
570
- * Returns active status
571
- *
572
- * @since 6.3
573
- * @access public
574
- *
575
- * @return bool True if instance is active, false if not
576
- */
577
- public function is_active() {
578
- return $this->is_active;
579
- }
580
-
581
- /**
582
- * Sets active status
583
- *
584
- * @since 6.3
585
- * @access public
586
- *
587
- * @param bool $active Active status
588
- */
589
- public function set_active( $active = true ) {
590
- $this->is_active = $active;
591
- }
592
- }
593
- endif; // Class exists
594
-
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login template class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @since 6.0
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 extends Theme_My_Login_Abstract {
18
+ /**
19
+ * Holds active instance flag
20
+ *
21
+ * @since 6.3
22
+ * @access private
23
+ * @var bool
24
+ */
25
+ private $is_active = false;
26
+
27
+ /**
28
+ * Constructor
29
+ *
30
+ * @since 6.0
31
+ * @access public
32
+ *
33
+ * @param array $options Instance options
34
+ */
35
+ public function __construct( $options = '' ) {
36
+ $options = wp_parse_args( $options );
37
+ $options = shortcode_atts( self::default_options(), $options );
38
+
39
+ $this->set_options( $options );
40
+ }
41
+
42
+ /**
43
+ * Retrieves default options
44
+ *
45
+ * @since 6.3
46
+ * @access public
47
+ *
48
+ * @return array Default options
49
+ */
50
+ public static function default_options() {
51
+ return array(
52
+ 'instance' => 0,
53
+ 'default_action' => '',
54
+ 'login_template' => '',
55
+ 'register_template' => '',
56
+ 'lostpassword_template' => '',
57
+ 'resetpass_template' => '',
58
+ 'user_template' => '',
59
+ 'show_title' => true,
60
+ 'show_log_link' => true,
61
+ 'show_reg_link' => true,
62
+ 'show_pass_link' => true,
63
+ 'logged_in_widget' => true,
64
+ 'logged_out_widget' => true,
65
+ 'show_gravatar' => true,
66
+ 'gravatar_size' => 50,
67
+ 'before_widget' => '',
68
+ 'after_widget' => '',
69
+ 'before_title' => '',
70
+ 'after_title' => ''
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Displays output according to current action
76
+ *
77
+ * @since 6.0
78
+ * @access public
79
+ *
80
+ * @return string HTML output
81
+ */
82
+ public function display( $action = '' ) {
83
+ if ( empty( $action ) )
84
+ $action = $this->get_option( 'default_action' );
85
+
86
+ ob_start();
87
+ echo $this->get_option( 'before_widget' );
88
+ if ( $this->get_option( 'show_title' ) )
89
+ echo $this->get_option( 'before_title' ) . $this->get_title( $action ) . $this->get_option( 'after_title' ) . "\n";
90
+ // Is there a specified template?
91
+ if ( has_action( 'tml_display_' . $action ) ) {
92
+ do_action_ref_array( 'tml_display_' . $action, array( &$this ) );
93
+ } else {
94
+ $template = array();
95
+ if ( is_user_logged_in() && 'login' == $action ) {
96
+ if ( $this->get_option( 'user_template' ) )
97
+ $template[] = $this->get_option( 'user_template' );
98
+ $template[] = 'user-panel.php';
99
+ } else {
100
+ switch ( $action ) {
101
+ case 'lostpassword':
102
+ case 'retrievepassword':
103
+ if ( $this->get_option( 'lostpassword_template' ) )
104
+ $template[] = $this->get_option( 'lostpassword_template' );
105
+ $template[] = 'lostpassword-form.php';
106
+ break;
107
+ case 'resetpass':
108
+ case 'rp':
109
+ if ( $this->get_option( 'resetpass_template' ) )
110
+ $template[] = $this->get_option( 'resetpass_template' );
111
+ $template[] = 'resetpass-form.php';
112
+ break;
113
+ case 'register':
114
+ if ( $this->get_option( 'register_template' ) )
115
+ $template[] = $this->get_option( 'register_template' );
116
+ $template[] = 'register-form.php';
117
+ break;
118
+ case 'login':
119
+ default :
120
+ if ( $this->get_option( 'login_template' ) )
121
+ $template[] = $this->get_option( 'login_template' );
122
+ $template[] = 'login-form.php';
123
+ }
124
+ }
125
+ $this->get_template( $template );
126
+ }
127
+ echo $this->get_option( 'after_widget' ) . "\n";
128
+ $output = ob_get_contents();
129
+ ob_end_clean();
130
+ return apply_filters_ref_array( 'tml_display', array( $output, $action, $this ) );
131
+ }
132
+
133
+ /**
134
+ * Returns action title
135
+ *
136
+ * @since 6.0
137
+ * @access public
138
+ *
139
+ * @param string $action The action to retrieve. Defaults to current action.
140
+ * @return string Title of $action
141
+ */
142
+ public function get_title( $action = '' ) {
143
+ if ( empty( $action ) )
144
+ $action = $this->get_option( 'default_action' );
145
+
146
+ if ( is_admin() )
147
+ return;
148
+
149
+ if ( is_user_logged_in() && 'login' == $action && $action == $this->get_option( 'default_action' ) ) {
150
+ $title = sprintf( __( 'Welcome, %s', 'theme-my-login' ), wp_get_current_user()->display_name );
151
+ } else {
152
+ if ( $page_id = Theme_My_Login::get_page_id( $action ) ) {
153
+ $title = get_post_field( 'post_title', $page_id );
154
+ } else {
155
+ switch ( $action ) {
156
+ case 'register':
157
+ $title = __( 'Register', 'theme-my-login' );
158
+ break;
159
+ case 'lostpassword':
160
+ case 'retrievepassword':
161
+ case 'resetpass':
162
+ case 'rp':
163
+ $title = __( 'Lost Password', 'theme-my-login' );
164
+ break;
165
+ case 'login':
166
+ default:
167
+ $title = __( 'Log In', 'theme-my-login' );
168
+ }
169
+ }
170
+ }
171
+ return apply_filters( 'tml_title', $title, $action );
172
+ }
173
+
174
+ /**
175
+ * Outputs action title
176
+ *
177
+ * @since 6.0
178
+ * @access public
179
+ *
180
+ * @param string $action The action to retieve. Defaults to current action.
181
+ */
182
+ public function the_title( $action = '' ) {
183
+ echo $this->get_title( $action );
184
+ }
185
+
186
+ /**
187
+ * Returns plugin errors
188
+ *
189
+ * @since 6.0
190
+ * @access public
191
+ */
192
+ public function get_errors() {
193
+ global $error;
194
+
195
+ $theme_my_login = Theme_My_Login::get_object();
196
+
197
+ $wp_error = $theme_my_login->errors;
198
+
199
+ if ( empty( $wp_error ) )
200
+ $wp_error = new WP_Error();
201
+
202
+ // Incase a plugin uses $error rather than the $errors object
203
+ if ( ! empty( $error ) ) {
204
+ $wp_error->add('error', $error);
205
+ unset($error);
206
+ }
207
+
208
+ $output = '';
209
+ if ( $this->is_active() ) {
210
+ if ( $wp_error->get_error_code() ) {
211
+ $errors = '';
212
+ $messages = '';
213
+ foreach ( $wp_error->get_error_codes() as $code ) {
214
+ $severity = $wp_error->get_error_data( $code );
215
+ foreach ( $wp_error->get_error_messages( $code ) as $error ) {
216
+ if ( 'message' == $severity )
217
+ $messages .= ' ' . $error . "<br />\n";
218
+ else
219
+ $errors .= ' ' . $error . "<br />\n";
220
+ }
221
+ }
222
+ if ( ! empty( $errors ) )
223
+ $output .= '<p class="error">' . apply_filters( 'login_errors', $errors ) . "</p>\n";
224
+ if ( ! empty( $messages ) )
225
+ $output .= '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
226
+ }
227
+ }
228
+ return $output;
229
+ }
230
+
231
+ /**
232
+ * Prints plugin errors
233
+ *
234
+ * @since 6.0
235
+ * @access public
236
+ */
237
+ public function the_errors() {
238
+ echo $this->get_errors();
239
+ }
240
+
241
+ /**
242
+ * Returns requested action URL
243
+ *
244
+ * @since 6.0
245
+ * @access public
246
+ *
247
+ * @param string $action Action to retrieve
248
+ * @param string $scheme Scheme to give the URL context
249
+ * @return string The requested action URL
250
+ */
251
+ public function get_action_url( $action = '', $scheme = 'login' ) {
252
+
253
+ $instance = $this->get_option( 'instance' );
254
+
255
+ if ( $action == $this->get_option( 'default_action' ) ) {
256
+ $args = array();
257
+ if ( $instance )
258
+ $args['instance'] = $instance;
259
+ $url = Theme_My_Login_Common::get_current_url( $args );
260
+ } else {
261
+ $url = Theme_My_Login::get_page_link( $action );
262
+ }
263
+
264
+ $url = set_url_scheme( $url, $scheme );
265
+
266
+ return apply_filters( 'tml_action_url', $url, $action, $scheme, $instance );
267
+ }
268
+
269
+ /**
270
+ * Outputs requested action URL
271
+ *
272
+ * @since 6.0
273
+ * @access public
274
+ *
275
+ * @param string $action Action to retrieve
276
+ * @param string $scheme Scheme to give the URL context
277
+ */
278
+ public function the_action_url( $action = 'login', $scheme = 'login' ) {
279
+ echo esc_url( $this->get_action_url( $action, $scheme ) );
280
+ }
281
+
282
+ /**
283
+ * Returns the action links
284
+ *
285
+ * @since 6.0
286
+ * @access public
287
+ *
288
+ * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
289
+ */
290
+ public function get_action_links( $args = '' ) {
291
+ $args = wp_parse_args( $args, array(
292
+ 'login' => true,
293
+ 'register' => true,
294
+ 'lostpassword' => true
295
+ ) );
296
+
297
+ $action_links = array();
298
+ if ( $args['login'] && $this->get_option( 'show_log_link' ) ) {
299
+ $action_links[] = array(
300
+ 'title' => $this->get_title( 'login' ),
301
+ 'url' => $this->get_action_url( 'login' )
302
+ );
303
+ }
304
+ if ( $args['register'] && $this->get_option( 'show_reg_link' ) && get_option( 'users_can_register' ) ) {
305
+ $action_links[] = array(
306
+ 'title' => $this->get_title( 'register' ),
307
+ 'url' => $this->get_action_url( 'register' )
308
+ );
309
+ }
310
+ if ( $args['lostpassword'] && $this->get_option( 'show_pass_link' ) ) {
311
+ $action_links[] = array(
312
+ 'title' => $this->get_title( 'lostpassword' ),
313
+ 'url' => $this->get_action_url( 'lostpassword' )
314
+ );
315
+ }
316
+ return apply_filters( 'tml_action_links', $action_links, $args );
317
+ }
318
+
319
+ /**
320
+ * Outputs the action links
321
+ *
322
+ * @since 6.0
323
+ * @access public
324
+ *
325
+ * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
326
+ */
327
+ public function the_action_links( $args = '' ) {
328
+ if ( $action_links = $this->get_action_links( $args ) ) {
329
+ echo '<ul class="tml-action-links">' . "\n";
330
+ foreach ( (array) $action_links as $link ) {
331
+ echo '<li><a href="' . esc_url( $link['url'] ) . '" rel="nofollow">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
332
+ }
333
+ echo '</ul>' . "\n";
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Returns logged-in user links
339
+ *
340
+ * @since 6.0
341
+ * @access public
342
+ *
343
+ * @return array Logged-in user links
344
+ */
345
+ public static function get_user_links() {
346
+ $user_links = array(
347
+ array(
348
+ 'title' => __( 'Dashboard', 'theme-my-login' ),
349
+ 'url' => admin_url() ),
350
+ array(
351
+ 'title' => __( 'Profile', 'theme-my-login' ),
352
+ 'url' => admin_url( 'profile.php' )
353
+ )
354
+ );
355
+ return apply_filters( 'tml_user_links', $user_links );
356
+ }
357
+
358
+ /**
359
+ * Outputs logged-in user links
360
+ *
361
+ * @since 6.0
362
+ * @access public
363
+ */
364
+ public function the_user_links() {
365
+ echo '<ul class="tml-user-links">';
366
+ foreach ( (array) self::get_user_links() as $link ) {
367
+ echo '<li><a href="' . esc_url( $link['url'] ) . '">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
368
+ }
369
+ echo '<li><a href="' . wp_logout_url() . '">' . self::get_title( 'logout' ) . '</a></li>' . "\n";
370
+ echo '</ul>';
371
+ }
372
+
373
+ /**
374
+ * Displays user avatar
375
+ *
376
+ * @since 6.0
377
+ * @access public
378
+ */
379
+ public function the_user_avatar( $size = '' ) {
380
+ if ( empty( $size ) )
381
+ $size = $this->get_option( 'gravatar_size', 50 );
382
+
383
+ $current_user = wp_get_current_user();
384
+
385
+ echo get_avatar( $current_user->ID, $size );
386
+ }
387
+
388
+ /**
389
+ * Returns template message for requested action
390
+ *
391
+ * @since 6.0
392
+ * @access public
393
+ *
394
+ * @param string $action Action to retrieve
395
+ * @return string The requested template message
396
+ */
397
+ public static function get_action_template_message( $action = '' ) {
398
+ switch ( $action ) {
399
+ case 'register':
400
+ $message = __( 'Register For This Site', 'theme-my-login' );
401
+ break;
402
+ case 'lostpassword':
403
+ $message = __( 'Please enter your username or email address. You will receive a link to create a new password via email.', 'theme-my-login' );
404
+ break;
405
+ case 'resetpass':
406
+ $message = __( 'Enter your new password below.', 'theme-my-login' );
407
+ break;
408
+ default:
409
+ $message = '';
410
+ }
411
+ $message = apply_filters( 'login_message', $message );
412
+
413
+ return apply_filters( 'tml_action_template_message', $message, $action );
414
+ }
415
+
416
+ /**
417
+ * Outputs template message for requested action
418
+ *
419
+ * @since 6.0
420
+ * @access public
421
+ *
422
+ * @param string $action Action to retrieve
423
+ * @param string $before_message Text/HTML to add before the message
424
+ * @param string $after_message Text/HTML to add after the message
425
+ */
426
+ public function the_action_template_message( $action = 'login', $before_message = '<p class="message">', $after_message = '</p>' ) {
427
+ if ( $message = self::get_action_template_message( $action ) )
428
+ echo $before_message . $message . $after_message;
429
+ }
430
+
431
+ /**
432
+ * Locates specified template
433
+ *
434
+ * @since 6.0
435
+ * @access public
436
+ *
437
+ * @param string|array $template_names The template(s) to locate
438
+ * @param bool $load If true, the template will be included if found
439
+ * @param array $args Array of extra variables to make available to template
440
+ * @return string|bool Template path if found, false if not
441
+ */
442
+ public function get_template( $template_names, $load = true, $args = array() ) {
443
+
444
+ $theme_my_login = Theme_My_Login::get_object();
445
+
446
+ // User friendly access to this
447
+ $template = $this;
448
+
449
+ // Easy access to current user
450
+ $current_user = wp_get_current_user();
451
+
452
+ extract( apply_filters_ref_array( 'tml_template_args', array( $args, $this ) ) );
453
+
454
+ $template_paths = apply_filters( 'tml_template_paths', array(
455
+ get_stylesheet_directory() . '/theme-my-login',
456
+ get_stylesheet_directory(),
457
+ get_template_directory() . '/theme-my-login',
458
+ get_template_directory(),
459
+ THEME_MY_LOGIN_PATH . '/templates'
460
+ ) );
461
+
462
+ foreach ( (array) $template_names as $template_name ) {
463
+
464
+ if ( ! $template_name )
465
+ continue;
466
+
467
+ if ( preg_match( '/\/|\\\\/', $template_name ) )
468
+ continue;
469
+
470
+ foreach ( $template_paths as $template_path ) {
471
+ if ( file_exists( $template_path . '/' . $template_name ) ) {
472
+ $located = $template_path . '/' . $template_name;
473
+ break 2;
474
+ }
475
+ }
476
+ }
477
+
478
+ $located = apply_filters_ref_array( 'tml_template', array( $located, $template_names, $this ) );
479
+
480
+ if ( $load && '' != $located )
481
+ include( $located );
482
+
483
+ return $located;
484
+ }
485
+
486
+ /**
487
+ * Returns the proper redirect URL according to action
488
+ *
489
+ * @since 6.0
490
+ * @access public
491
+ *
492
+ * @param string $action The action
493
+ * @return string The redirect URL
494
+ */
495
+ public function get_redirect_url( $action = '' ) {
496
+
497
+ $theme_my_login = Theme_My_Login::get_object();
498
+
499
+ if ( empty( $action ) )
500
+ $action = $this->get_option( 'default_action' );
501
+
502
+ $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
503
+
504
+ switch ( $action ) {
505
+ case 'lostpassword' :
506
+ case 'retrievepassword' :
507
+ $url = apply_filters( 'lostpassword_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=confirm' ) );
508
+ break;
509
+ case 'register' :
510
+ $url = apply_filters( 'registration_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=registered' ) );
511
+ break;
512
+ case 'login' :
513
+ default :
514
+ $url = apply_filters( 'login_redirect', ! empty( $redirect_to ) ? $redirect_to : admin_url(), $redirect_to, null );
515
+ }
516
+ return apply_filters( 'tml_redirect_url', $url, $action );
517
+ }
518
+
519
+ /**
520
+ * Outputs redirect URL
521
+ *
522
+ * @since 6.0
523
+ * @access public
524
+ *
525
+ * @param string $action The action
526
+ */
527
+ public function the_redirect_url( $action = '' ) {
528
+ echo esc_attr( $this->get_redirect_url( $action ) );
529
+ }
530
+
531
+ /**
532
+ * Outputs current template instance ID
533
+ *
534
+ * @since 6.0
535
+ * @access public
536
+ */
537
+ public function the_instance() {
538
+ if ( $this->get_option( 'instance' ) )
539
+ echo esc_attr( $this->get_option( 'instance' ) );
540
+ }
541
+
542
+ /**
543
+ * Returns requested $value
544
+ *
545
+ * @since 6.0
546
+ * @access public
547
+ *
548
+ * @param string $value The value to retrieve
549
+ * @return string|bool The value if it exists, false if not
550
+ */
551
+ public function get_posted_value( $value ) {
552
+ if ( $this->is_active() && isset( $_REQUEST[$value] ) )
553
+ return stripslashes( $_REQUEST[$value] );
554
+ return false;
555
+ }
556
+
557
+ /**
558
+ * Outputs requested value
559
+ *
560
+ * @since 6.0
561
+ * @access public
562
+ *
563
+ * @param string $value The value to retrieve
564
+ */
565
+ public function the_posted_value( $value ) {
566
+ echo esc_attr( $this->get_posted_value( $value ) );
567
+ }
568
+
569
+ /**
570
+ * Returns active status
571
+ *
572
+ * @since 6.3
573
+ * @access public
574
+ *
575
+ * @return bool True if instance is active, false if not
576
+ */
577
+ public function is_active() {
578
+ return $this->is_active;
579
+ }
580
+
581
+ /**
582
+ * Sets active status
583
+ *
584
+ * @since 6.3
585
+ * @access public
586
+ *
587
+ * @param bool $active Active status
588
+ */
589
+ public function set_active( $active = true ) {
590
+ $this->is_active = $active;
591
+ }
592
+ }
593
+ endif; // Class exists
594
+
includes/class-theme-my-login-widget.php CHANGED
@@ -1,147 +1,147 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login widget class
4
- *
5
- * @package Theme_My_Login
6
- */
7
-
8
- if ( ! class_exists( 'Theme_My_Login_Widget' ) ) :
9
- /*
10
- * Theme My Login widget class
11
- *
12
- * @since 6.0
13
- */
14
- class Theme_My_Login_Widget extends WP_Widget {
15
- /**
16
- * Constructor
17
- *
18
- * @since 6.0
19
- * @access public
20
- */
21
- public function __construct() {
22
- $widget_options = array(
23
- 'classname' => 'widget_theme_my_login',
24
- 'description' => __( 'A login form for your blog.', 'theme-my-login' )
25
- );
26
- parent::__construct( 'theme-my-login', __( 'Theme My Login', 'theme-my-login' ), $widget_options );
27
- }
28
-
29
- /**
30
- * Displays the widget
31
- *
32
- * @since 6.0
33
- * @access public
34
- *
35
- * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
36
- * @param array $instance The settings for the particular instance of the widget
37
- */
38
- public function widget( $args, $instance ) {
39
-
40
- $theme_my_login = Theme_My_Login::get_object();
41
-
42
- $instance = wp_parse_args( $instance, array(
43
- 'default_action' => 'login',
44
- 'logged_in_widget' => true,
45
- 'logged_out_widget' => true,
46
- 'show_title' => true,
47
- 'show_log_link' => true,
48
- 'show_reg_link' => true,
49
- 'show_pass_link' => true,
50
- 'show_gravatar' => true,
51
- 'gravatar_size' => 50
52
- ) );
53
-
54
- // Show if logged in?
55
- if ( is_user_logged_in() && ! $instance['logged_in_widget'] )
56
- return;
57
-
58
- // Show if logged out?
59
- if ( ! is_user_logged_in() && ! $instance['logged_out_widget'] )
60
- return;
61
-
62
- $args = array_merge( $args, $instance );
63
-
64
- echo $theme_my_login->shortcode( $args );
65
- }
66
-
67
- /**
68
- * Updates the widget
69
- *
70
- * @since 6.0
71
- * @access public
72
- */
73
- public function update( $new_instance, $old_instance ) {
74
- $instance = $old_instance;
75
- $instance['default_action'] = in_array( $new_instance['default_action'], array( 'login', 'register', 'lostpassword' ) ) ? $new_instance['default_action'] : 'login';
76
- $instance['logged_in_widget'] = ! empty( $new_instance['logged_in_widget'] );
77
- $instance['logged_out_widget'] = ! empty( $new_instance['logged_out_widget'] );
78
- $instance['show_title'] = ! empty( $new_instance['show_title'] );
79
- $instance['show_log_link'] = ! empty( $new_instance['show_log_link'] );
80
- $instance['show_reg_link'] = ! empty( $new_instance['show_reg_link'] );
81
- $instance['show_pass_link'] = ! empty( $new_instance['show_pass_link'] );
82
- $instance['show_gravatar'] = ! empty( $new_instance['show_gravatar'] );
83
- $instance['gravatar_size'] = absint( $new_instance['gravatar_size'] );
84
- return $instance;
85
- }
86
-
87
- /**
88
- * Displays the widget admin form
89
- *
90
- * @since 6.0
91
- * @access public
92
- */
93
- public function form( $instance ) {
94
- $defaults = array(
95
- 'default_action' => 'login',
96
- 'logged_in_widget' => 1,
97
- 'logged_out_widget' => 1,
98
- 'show_title' => 1,
99
- 'show_log_link' => 1,
100
- 'show_reg_link' => 1,
101
- 'show_pass_link' => 1,
102
- 'show_gravatar' => 1,
103
- 'gravatar_size' => 50,
104
- 'register_widget' => 1,
105
- 'lostpassword_widget' => 1
106
- );
107
- $instance = wp_parse_args( $instance, $defaults );
108
-
109
- $actions = array(
110
- 'login' => __( 'Login', 'theme-my-login' ),
111
- 'register' => __( 'Register', 'theme-my-login' ),
112
- 'lostpassword' => __( 'Lost Password', 'theme-my-login' )
113
- );
114
-
115
- echo '<p>' . __( 'Default Action', 'theme-my-login' ) . '<br /><select name="' . $this->get_field_name( 'default_action' ) . '" id="' . $this->get_field_id( 'default_action' ) . '">';
116
- foreach ( $actions as $action => $title ) {
117
- $is_selected = ( $instance['default_action'] == $action ) ? ' selected="selected"' : '';
118
- echo '<option value="' . $action . '"' . $is_selected . '>' . $title . '</option>';
119
- }
120
- echo '</select></p>' . "\n";
121
-
122
- $is_checked = ( empty( $instance['logged_in_widget'] ) ) ? '' : 'checked="checked" ';
123
- 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";
124
-
125
- $is_checked = ( empty( $instance['logged_out_widget'] ) ) ? '' : 'checked="checked" ';
126
- echo '<p><input name="' . $this->get_field_name( 'logged_out_widget' ) . '" type="checkbox" id="' . $this->get_field_id( 'logged_out_widget' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'logged_out_widget' ) . '">' . __( 'Show When Logged Out', 'theme-my-login' ) . '</label></p>' . "\n";
127
-
128
- $is_checked = ( empty( $instance['show_title'] ) ) ? '' : 'checked="checked" ';
129
- 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";
130
-
131
- $is_checked = ( empty( $instance['show_log_link'] ) ) ? '' : 'checked="checked" ';
132
- 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";
133
-
134
- $is_checked = ( empty( $instance['show_reg_link'] ) ) ? '' : 'checked="checked" ';
135
- 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";
136
-
137
- $is_checked = ( empty( $instance['show_pass_link'] ) ) ? '' : 'checked="checked" ';
138
- 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";
139
-
140
- $is_checked = ( empty( $instance['show_gravatar'] ) ) ? '' : 'checked="checked" ';
141
- 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";
142
-
143
- 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";
144
- }
145
- }
146
- endif; // Class exists
147
-
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login widget class
4
+ *
5
+ * @package Theme_My_Login
6
+ */
7
+
8
+ if ( ! class_exists( 'Theme_My_Login_Widget' ) ) :
9
+ /*
10
+ * Theme My Login widget class
11
+ *
12
+ * @since 6.0
13
+ */
14
+ class Theme_My_Login_Widget extends WP_Widget {
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @since 6.0
19
+ * @access public
20
+ */
21
+ public function __construct() {
22
+ $widget_options = array(
23
+ 'classname' => 'widget_theme_my_login',
24
+ 'description' => __( 'A login form for your blog.', 'theme-my-login' )
25
+ );
26
+ parent::__construct( 'theme-my-login', __( 'Theme My Login', 'theme-my-login' ), $widget_options );
27
+ }
28
+
29
+ /**
30
+ * Displays the widget
31
+ *
32
+ * @since 6.0
33
+ * @access public
34
+ *
35
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
36
+ * @param array $instance The settings for the particular instance of the widget
37
+ */
38
+ public function widget( $args, $instance ) {
39
+
40
+ $theme_my_login = Theme_My_Login::get_object();
41
+
42
+ $instance = wp_parse_args( $instance, array(
43
+ 'default_action' => 'login',
44
+ 'logged_in_widget' => true,
45
+ 'logged_out_widget' => true,
46
+ 'show_title' => true,
47
+ 'show_log_link' => true,
48
+ 'show_reg_link' => true,
49
+ 'show_pass_link' => true,
50
+ 'show_gravatar' => true,
51
+ 'gravatar_size' => 50
52
+ ) );
53
+
54
+ // Show if logged in?
55
+ if ( is_user_logged_in() && ! $instance['logged_in_widget'] )
56
+ return;
57
+
58
+ // Show if logged out?
59
+ if ( ! is_user_logged_in() && ! $instance['logged_out_widget'] )
60
+ return;
61
+
62
+ $args = array_merge( $args, $instance );
63
+
64
+ echo $theme_my_login->shortcode( $args );
65
+ }
66
+
67
+ /**
68
+ * Updates the widget
69
+ *
70
+ * @since 6.0
71
+ * @access public
72
+ */
73
+ public function update( $new_instance, $old_instance ) {
74
+ $instance = $old_instance;
75
+ $instance['default_action'] = in_array( $new_instance['default_action'], array( 'login', 'register', 'lostpassword' ) ) ? $new_instance['default_action'] : 'login';
76
+ $instance['logged_in_widget'] = ! empty( $new_instance['logged_in_widget'] );
77
+ $instance['logged_out_widget'] = ! empty( $new_instance['logged_out_widget'] );
78
+ $instance['show_title'] = ! empty( $new_instance['show_title'] );
79
+ $instance['show_log_link'] = ! empty( $new_instance['show_log_link'] );
80
+ $instance['show_reg_link'] = ! empty( $new_instance['show_reg_link'] );
81
+ $instance['show_pass_link'] = ! empty( $new_instance['show_pass_link'] );
82
+ $instance['show_gravatar'] = ! empty( $new_instance['show_gravatar'] );
83
+ $instance['gravatar_size'] = absint( $new_instance['gravatar_size'] );
84
+ return $instance;
85
+ }
86
+
87
+ /**
88
+ * Displays the widget admin form
89
+ *
90
+ * @since 6.0
91
+ * @access public
92
+ */
93
+ public function form( $instance ) {
94
+ $defaults = array(
95
+ 'default_action' => 'login',
96
+ 'logged_in_widget' => 1,
97
+ 'logged_out_widget' => 1,
98
+ 'show_title' => 1,
99
+ 'show_log_link' => 1,
100
+ 'show_reg_link' => 1,
101
+ 'show_pass_link' => 1,
102
+ 'show_gravatar' => 1,
103
+ 'gravatar_size' => 50,
104
+ 'register_widget' => 1,
105
+ 'lostpassword_widget' => 1
106
+ );
107
+ $instance = wp_parse_args( $instance, $defaults );
108
+
109
+ $actions = array(
110
+ 'login' => __( 'Login', 'theme-my-login' ),
111
+ 'register' => __( 'Register', 'theme-my-login' ),
112
+ 'lostpassword' => __( 'Lost Password', 'theme-my-login' )
113
+ );
114
+
115
+ echo '<p>' . __( 'Default Action', 'theme-my-login' ) . '<br /><select name="' . $this->get_field_name( 'default_action' ) . '" id="' . $this->get_field_id( 'default_action' ) . '">';
116
+ foreach ( $actions as $action => $title ) {
117
+ $is_selected = ( $instance['default_action'] == $action ) ? ' selected="selected"' : '';
118
+ echo '<option value="' . $action . '"' . $is_selected . '>' . $title . '</option>';
119
+ }
120
+ echo '</select></p>' . "\n";
121
+
122
+ $is_checked = ( empty( $instance['logged_in_widget'] ) ) ? '' : 'checked="checked" ';
123
+ 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";
124
+
125
+ $is_checked = ( empty( $instance['logged_out_widget'] ) ) ? '' : 'checked="checked" ';
126
+ echo '<p><input name="' . $this->get_field_name( 'logged_out_widget' ) . '" type="checkbox" id="' . $this->get_field_id( 'logged_out_widget' ) . '" value="1" ' . $is_checked . '/> <label for="' . $this->get_field_id( 'logged_out_widget' ) . '">' . __( 'Show When Logged Out', 'theme-my-login' ) . '</label></p>' . "\n";
127
+
128
+ $is_checked = ( empty( $instance['show_title'] ) ) ? '' : 'checked="checked" ';
129
+ 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";
130
+
131
+ $is_checked = ( empty( $instance['show_log_link'] ) ) ? '' : 'checked="checked" ';
132
+ 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";
133
+
134
+ $is_checked = ( empty( $instance['show_reg_link'] ) ) ? '' : 'checked="checked" ';
135
+ 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";
136
+
137
+ $is_checked = ( empty( $instance['show_pass_link'] ) ) ? '' : 'checked="checked" ';
138
+ 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";
139
+
140
+ $is_checked = ( empty( $instance['show_gravatar'] ) ) ? '' : 'checked="checked" ';
141
+ 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";
142
+
143
+ 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";
144
+ }
145
+ }
146
+ endif; // Class exists
147
+
includes/class-theme-my-login.php CHANGED
@@ -1,1193 +1,1193 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login class
4
- *
5
- * @package Theme_My_Login
6
- * @since 6.0
7
- */
8
-
9
- if ( ! class_exists( 'Theme_My_Login' ) ) :
10
- /*
11
- * Theme My Login class
12
- *
13
- * This class contains properties and methods common to the front-end.
14
- *
15
- * @since 6.0
16
- */
17
- class Theme_My_Login extends Theme_My_Login_Abstract {
18
- /**
19
- * Holds plugin version
20
- *
21
- * @since 6.3.2
22
- * @const string
23
- */
24
- const VERSION = '6.4.5';
25
-
26
- /**
27
- * Holds options key
28
- *
29
- * @since 6.3
30
- * @access protected
31
- * @var string
32
- */
33
- protected $options_key = 'theme_my_login';
34
-
35
- /**
36
- * Holds errors object
37
- *
38
- * @since 6.0
39
- * @access public
40
- * @var object
41
- */
42
- public $errors;
43
-
44
- /**
45
- * Holds current page being requested
46
- *
47
- * @since 6.3
48
- * @access public
49
- * @var string
50
- */
51
- public $request_page;
52
-
53
- /**
54
- * Holds current action being requested
55
- *
56
- * @since 6.0
57
- * @access public
58
- * @var string
59
- */
60
- public $request_action;
61
-
62
- /**
63
- * Holds current instance being requested
64
- *
65
- * @since 6.0
66
- * @access public
67
- * @var int
68
- */
69
- public $request_instance;
70
-
71
- /**
72
- * Holds loaded instances
73
- *
74
- * @since 6.3
75
- * @access protected
76
- * @var array
77
- */
78
- protected $loaded_instances = array();
79
-
80
- /**
81
- * Returns singleton instance
82
- *
83
- * @since 6.3
84
- * @access public
85
- * @return object
86
- */
87
- public static function get_object( $class = null ) {
88
- return parent::get_object( __CLASS__ );
89
- }
90
-
91
- /**
92
- * Returns default options
93
- *
94
- * @since 6.3
95
- * @access public
96
- *
97
- * @return array Default options
98
- */
99
- public static function default_options() {
100
- return apply_filters( 'tml_default_options', array(
101
- 'enable_css' => true,
102
- 'login_type' => 'default',
103
- 'active_modules' => array()
104
- ) );
105
- }
106
-
107
- /**
108
- * Returns default pages
109
- *
110
- * @since 6.3
111
- * @access public
112
- *
113
- * @return array Default pages
114
- */
115
- public static function default_pages() {
116
- return apply_filters( 'tml_default_pages', array(
117
- 'login' => __( 'Log In' , 'theme-my-login' ),
118
- 'logout' => __( 'Log Out' , 'theme-my-login' ),
119
- 'register' => __( 'Register' , 'theme-my-login' ),
120
- 'lostpassword' => __( 'Lost Password' , 'theme-my-login' ),
121
- 'resetpass' => __( 'Reset Password', 'theme-my-login' )
122
- ) );
123
- }
124
-
125
- /**
126
- * Loads the plugin
127
- *
128
- * @since 6.0
129
- * @access public
130
- */
131
- protected function load() {
132
-
133
- $this->load_instance();
134
-
135
- add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
136
- add_action( 'init', array( $this, 'init' ) );
137
- add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
138
- add_action( 'widgets_init', array( $this, 'widgets_init' ) );
139
- add_action( 'wp', array( $this, 'wp' ) );
140
- add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
141
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
142
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
143
- add_action( 'wp_head', array( $this, 'wp_head' ) );
144
- add_action( 'wp_footer', array( $this, 'wp_footer' ) );
145
- add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
146
-
147
- add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
148
- add_filter( 'logout_url', array( $this, 'logout_url' ), 10, 2 );
149
- add_filter( 'single_post_title', array( $this, 'single_post_title' ) );
150
- add_filter( 'the_title', array( $this, 'the_title' ), 10, 2 );
151
- add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ) );
152
- add_filter( 'wp_list_pages_excludes', array( $this, 'wp_list_pages_excludes' ) );
153
- add_filter( 'page_link', array( $this, 'page_link' ), 10, 2 );
154
- add_filter( 'authenticate', array( $this, 'authenticate' ), 20, 3 );
155
-
156
- add_shortcode( 'theme-my-login', array( $this, 'shortcode' ) );
157
-
158
- if ( 'username' == $this->get_option( 'login_type' ) ) {
159
- remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
160
- } elseif ( 'email' == $this->get_option( 'login_type' ) ) {
161
- remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );
162
- }
163
- }
164
-
165
-
166
- /************************************************************************************************************************
167
- * Actions
168
- ************************************************************************************************************************/
169
-
170
- /**
171
- * Loads active modules
172
- *
173
- * @since 6.3
174
- * @access public
175
- */
176
- public function plugins_loaded() {
177
- foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
178
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
179
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
180
- }
181
- do_action_ref_array( 'tml_modules_loaded', array( &$this ) );
182
- }
183
-
184
- /**
185
- * Initializes the plugin
186
- *
187
- * @since 6.0
188
- * @access public
189
- */
190
- public function init() {
191
- global $pagenow;
192
-
193
- load_plugin_textdomain( 'theme-my-login', false, plugin_basename( THEME_MY_LOGIN_PATH ) . '/languages' );
194
-
195
- $this->errors = new WP_Error();
196
-
197
- if ( ! is_admin() && 'wp-login.php' != $pagenow && $this->get_option( 'enable_css' ) )
198
- wp_enqueue_style( 'theme-my-login', self::get_stylesheet(), false, $this->get_option( 'version' ) );
199
- }
200
-
201
- /**
202
- * Registers the widget
203
- *
204
- * @since 6.0
205
- * @access public
206
- */
207
- public function widgets_init() {
208
- if ( class_exists( 'Theme_My_Login_Widget' ) )
209
- register_widget( 'Theme_My_Login_Widget' );
210
- }
211
-
212
- /**
213
- * Used to add/remove filters from login page
214
- *
215
- * @since 6.1.1
216
- * @access public
217
- */
218
- public function wp() {
219
- if ( self::is_tml_page() ) {
220
- do_action( 'login_init' );
221
-
222
- remove_action( 'wp_head', 'feed_links', 2 );
223
- remove_action( 'wp_head', 'feed_links_extra', 3 );
224
- remove_action( 'wp_head', 'rsd_link' );
225
- remove_action( 'wp_head', 'wlwmanifest_link' );
226
- remove_action( 'wp_head', 'parent_post_rel_link', 10 );
227
- remove_action( 'wp_head', 'start_post_rel_link', 10 );
228
- remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
229
- remove_action( 'wp_head', 'rel_canonical' );
230
-
231
- // Don't index any of these forms
232
- add_action( 'login_head', 'wp_no_robots' );
233
-
234
- if ( force_ssl_admin() && ! is_ssl() ) {
235
- if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
236
- wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
237
- exit;
238
- } else {
239
- wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
240
- exit;
241
- }
242
- }
243
-
244
- nocache_headers();
245
- }
246
- }
247
-
248
- /**
249
- * Exclude TML pages from search
250
- *
251
- * @since 6.1.13
252
- * @access public
253
- */
254
- public function pre_get_posts( &$query ) {
255
-
256
- // Bail if not a search
257
- if ( ! $query->is_search )
258
- return;
259
-
260
- // Get the requested post type
261
- $post_type = $query->get( 'post_type' );
262
-
263
- // Bail if not querying pages
264
- if ( ! empty( $post_type ) && ! in_array( 'page', (array) $post_type ) )
265
- return;
266
-
267
- // Get TML pages
268
- $pages = get_posts( array(
269
- 'post_type' => 'page',
270
- 'post_status' => 'any',
271
- 'meta_key' => '_tml_action',
272
- 'posts_per_page' => -1
273
- ) );
274
-
275
- // Get the page IDs
276
- $pages = wp_list_pluck( $pages, 'ID' );
277
-
278
- // Get any currently exclude posts
279
- $excludes = (array) $query->get( 'post__not_in' );
280
-
281
- // Merge the excludes
282
- $excludes = array_merge( $excludes, $pages );
283
-
284
- // Set the excludes
285
- $query->set( 'post__not_in', $excludes );
286
- }
287
-
288
- /**
289
- * Proccesses the request
290
- *
291
- * Callback for "template_redirect" hook in template-loader.php
292
- *
293
- * @since 6.3
294
- * @access public
295
- */
296
- public function template_redirect() {
297
- $this->request_action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
298
- if ( ! $this->request_action && self::is_tml_page() )
299
- $this->request_action = self::get_page_action( get_the_id() );
300
- $this->request_instance = isset( $_REQUEST['instance'] ) ? sanitize_key( $_REQUEST['instance'] ) : 0;
301
-
302
- do_action_ref_array( 'tml_request', array( &$this ) );
303
-
304
- // allow plugins to override the default actions, and to add extra actions if they want
305
- do_action( 'login_form_' . $this->request_action );
306
-
307
- if ( has_action( 'tml_request_' . $this->request_action ) ) {
308
- do_action_ref_array( 'tml_request_' . $this->request_action, array( &$this ) );
309
- } else {
310
- $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
311
- switch ( $this->request_action ) {
312
- case 'postpass' :
313
- if ( ! array_key_exists( 'post_password', $_POST ) ) {
314
- wp_safe_redirect( wp_get_referer() );
315
- exit();
316
- }
317
-
318
- require_once( ABSPATH . 'wp-includes/class-phpass.php' );
319
- $hasher = new PasswordHash( 8, true );
320
-
321
- $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
322
- if ( $referer ) {
323
- $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
324
- } else {
325
- $secure = false;
326
- }
327
- setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
328
-
329
- wp_safe_redirect( wp_get_referer() );
330
- exit;
331
-
332
- break;
333
- case 'logout' :
334
- check_admin_referer( 'log-out' );
335
-
336
- $user = wp_get_current_user();
337
-
338
- wp_logout();
339
-
340
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
341
- $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
342
- } else {
343
- $redirect_to = site_url( 'wp-login.php?loggedout=true' );
344
- $requested_redirect_to = '';
345
- }
346
-
347
- $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
348
- wp_safe_redirect( $redirect_to );
349
- exit;
350
- break;
351
- case 'lostpassword' :
352
- case 'retrievepassword' :
353
- if ( $http_post ) {
354
- $this->errors = self::retrieve_password();
355
- if ( ! is_wp_error( $this->errors ) ) {
356
- $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url( 'wp-login.php?checkemail=confirm' );
357
- wp_safe_redirect( $redirect_to );
358
- exit;
359
- }
360
- }
361
-
362
- if ( isset( $_REQUEST['error'] ) ) {
363
- if ( 'invalidkey' == $_REQUEST['error'] )
364
- $this->errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.', 'theme-my-login' ) );
365
- elseif ( 'expiredkey' == $_REQUEST['error'] )
366
- $this->errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.', 'theme-my-login' ) );
367
- }
368
-
369
- do_action( 'lost_password' );
370
- break;
371
- case 'resetpass' :
372
- case 'rp' :
373
- // Dirty hack for now
374
- global $rp_login, $rp_key;
375
-
376
- $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
377
- if ( isset( $_GET['key'] ) ) {
378
- $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
379
- setcookie( $rp_cookie, $value, 0, '/', COOKIE_DOMAIN, is_ssl(), true );
380
- wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
381
- exit;
382
- }
383
-
384
- if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
385
- list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
386
- $user = check_password_reset_key( $rp_key, $rp_login );
387
- if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
388
- $user = false;
389
- }
390
- } else {
391
- $user = false;
392
- }
393
-
394
- if ( ! $user || is_wp_error( $user ) ) {
395
- setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
396
- if ( $user && $user->get_error_code() === 'expired_key' )
397
- wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
398
- else
399
- wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
400
- exit;
401
- }
402
-
403
- if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] )
404
- $this->errors->add( 'password_reset_mismatch', __( 'The passwords do not match.', 'theme-my-login' ) );
405
-
406
- do_action( 'validate_password_reset', $this->errors, $user );
407
-
408
- if ( ( ! $this->errors->get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
409
- reset_password( $user, $_POST['pass1'] );
410
- setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
411
- $redirect_to = site_url( 'wp-login.php?resetpass=complete' );
412
- wp_safe_redirect( $redirect_to );
413
- exit;
414
- }
415
-
416
- wp_enqueue_script( 'utils' );
417
- wp_enqueue_script( 'user-profile' );
418
- break;
419
- case 'register' :
420
- if ( ! get_option( 'users_can_register' ) ) {
421
- $redirect_to = site_url( 'wp-login.php?registration=disabled' );
422
- wp_redirect( $redirect_to );
423
- exit;
424
- }
425
-
426
- $user_login = '';
427
- $user_email = '';
428
- if ( $http_post ) {
429
- if ( 'email' == $this->get_option( 'login_type' ) ) {
430
- $user_login = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
431
- } else {
432
- $user_login = isset( $_POST['user_login'] ) ? $_POST['user_login'] : '';
433
- }
434
- $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
435
-
436
- $this->errors = register_new_user( $user_login, $user_email );
437
- if ( ! is_wp_error( $this->errors ) ) {
438
- $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : site_url( 'wp-login.php?checkemail=registered' );
439
- wp_safe_redirect( $redirect_to );
440
- exit;
441
- }
442
- }
443
- break;
444
- case 'login' :
445
- default:
446
- $secure_cookie = '';
447
- $interim_login = isset( $_REQUEST['interim-login'] );
448
-
449
- // If the user wants ssl but the session is not ssl, force a secure cookie.
450
- if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
451
- $user_name = sanitize_user( $_POST['log'] );
452
- if ( $user = get_user_by( 'login', $user_name ) ) {
453
- if ( get_user_option( 'use_ssl', $user->ID ) ) {
454
- $secure_cookie = true;
455
- force_ssl_admin( true );
456
- }
457
- }
458
- }
459
-
460
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
461
- $redirect_to = $_REQUEST['redirect_to'];
462
- // Redirect to https if user wants ssl
463
- if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) )
464
- $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
465
- } else {
466
- $redirect_to = admin_url();
467
- }
468
-
469
- $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
470
-
471
- if ( $http_post && isset( $_POST['log'] ) ) {
472
-
473
- $user = wp_signon( '', $secure_cookie );
474
-
475
- $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
476
-
477
- if ( ! is_wp_error( $user ) && ! $reauth ) {
478
- if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
479
- // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
480
- if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) )
481
- $redirect_to = user_admin_url();
482
- elseif ( is_multisite() && ! $user->has_cap( 'read' ) )
483
- $redirect_to = get_dashboard_url( $user->ID );
484
- elseif ( ! $user->has_cap( 'edit_posts' ) )
485
- $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
486
-
487
- wp_redirect( $redirect_to );
488
- exit;
489
- }
490
- wp_safe_redirect( $redirect_to );
491
- exit;
492
- }
493
-
494
- $this->errors = $user;
495
- }
496
-
497
- // Clear errors if loggedout is set.
498
- if ( ! empty( $_GET['loggedout'] ) || $reauth )
499
- $this->errors = new WP_Error();
500
-
501
- // Some parts of this script use the main login form to display a message
502
- if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] )
503
- $this->errors->add( 'loggedout', __( 'You are now logged out.', 'theme-my-login' ), 'message' );
504
- elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] )
505
- $this->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'theme-my-login' ) );
506
- elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] )
507
- $this->errors->add( 'confirm', __( 'Check your e-mail for the confirmation link.', 'theme-my-login' ), 'message' );
508
- elseif ( isset( $_GET['resetpass'] ) && 'complete' == $_GET['resetpass'] )
509
- $this->errors->add( 'password_reset', __( 'Your password has been reset.', 'theme-my-login' ), 'message' );
510
- elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] )
511
- $this->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'theme-my-login' ), 'message' );
512
- elseif ( $interim_login )
513
- $this->errors->add( 'expired', __( 'Your session has expired. Please log-in again.', 'theme-my-login' ), 'message' );
514
- elseif ( strpos( $redirect_to, 'about.php?updated' ) )
515
- $this->errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.', 'theme-my-login' ), 'message' );
516
- elseif ( $reauth )
517
- $this->errors->add( 'reauth', __( 'Please log in to continue.', 'theme-my-login' ), 'message' );
518
-
519
- // Clear any stale cookies.
520
- if ( $reauth )
521
- wp_clear_auth_cookie();
522
- break;
523
- } // end switch
524
- } // endif has_filter()
525
- }
526
-
527
- /**
528
- * Calls "login_enqueue_scripts" on login page
529
- *
530
- * Callback for "wp_enqueue_scripts" hook
531
- *
532
- * @since 6.3
533
- */
534
- public function wp_enqueue_scripts() {
535
- if ( self::is_tml_page() )
536
- do_action( 'login_enqueue_scripts' );
537
- }
538
-
539
- /**
540
- * Calls "login_head" hook on login page
541
- *
542
- * Callback for "wp_head" hook
543
- *
544
- * @since 6.0
545
- * @access public
546
- */
547
- public function wp_head() {
548
- if ( self::is_tml_page() ) {
549
- // This is already attached to "wp_head"
550
- remove_action( 'login_head', 'wp_print_head_scripts', 9 );
551
-
552
- do_action( 'login_head' );
553
- }
554
- }
555
-
556
- /**
557
- * Calls "login_footer" hook on login page
558
- *
559
- * Callback for "wp_footer" hook
560
- *
561
- * @since 6.3
562
- */
563
- public function wp_footer() {
564
- if ( self::is_tml_page() ) {
565
- // This is already attached to "wp_footer"
566
- remove_action( 'login_footer', 'wp_print_footer_scripts', 20 );
567
-
568
- do_action( 'login_footer' );
569
- }
570
- }
571
-
572
- /**
573
- * Prints javascript in the footer
574
- *
575
- * @since 6.0
576
- * @access public
577
- */
578
- public function wp_print_footer_scripts() {
579
- if ( ! self::is_tml_page() )
580
- return;
581
-
582
- switch ( $this->request_action ) {
583
- case 'lostpassword' :
584
- case 'retrievepassword' :
585
- case 'register' :
586
- ?>
587
- <script type="text/javascript">
588
- try{document.getElementById('user_login').focus();}catch(e){}
589
- if(typeof wpOnload=='function')wpOnload()
590
- </script>
591
- <?php
592
- break;
593
- case 'resetpass' :
594
- case 'rp' :
595
- ?>
596
- <script type="text/javascript">
597
- try{document.getElementById('pass1').focus();}catch(e){}
598
- if(typeof wpOnload=='function')wpOnload()
599
- </script>
600
- <?php
601
- break;
602
- case 'login' :
603
- $user_login = '';
604
- if ( isset($_POST['log']) )
605
- $user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? esc_attr( stripslashes( $_POST['log'] ) ) : '';
606
- ?>
607
- <script type="text/javascript">
608
- function wp_attempt_focus() {
609
- setTimeout( function() {
610
- try {
611
- <?php if ( $user_login ) { ?>
612
- d = document.getElementById('user_pass');
613
- d.value = '';
614
- <?php } else { ?>
615
- d = document.getElementById('user_login');
616
- <?php if ( 'invalid_username' == $this->errors->get_error_code() ) { ?>
617
- if ( d.value != '' )
618
- d.value = '';
619
- <?php
620
- }
621
- } ?>
622
- d.focus();
623
- d.select();
624
- } catch(e){}
625
- }, 200 );
626
- }
627
-
628
- wp_attempt_focus();
629
- if(typeof wpOnload=='function')wpOnload()
630
- </script>
631
- <?php
632
- break;
633
- }
634
- }
635
-
636
- /************************************************************************************************************************
637
- * Filters
638
- ************************************************************************************************************************/
639
-
640
- /**
641
- * Rewrites URL's containing wp-login.php created by site_url()
642
- *
643
- * @since 6.0
644
- * @access public
645
- *
646
- * @param string $url The URL
647
- * @param string $path The path specified
648
- * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
649
- * @param int $blog_id Blog ID
650
- * @return string The modified URL
651
- */
652
- public function site_url( $url, $path, $orig_scheme ) {
653
- global $pagenow;
654
-
655
- // Bail if currently viewing wp-login.php
656
- if ( 'wp-login.php' == $pagenow )
657
- return $url;
658
-
659
- // Bail if the URL isn't a login URL
660
- if ( false === strpos( $url, 'wp-login.php' ) )
661
- return $url;
662
-
663
- // Parse the query string from the URL
664
- parse_str( parse_url( $url, PHP_URL_QUERY ), $query );
665
-
666
- /**
667
- * Bail if the URL is an interim-login URL
668
- *
669
- * This only works using the javascript workaround as implemented in
670
- * admin/theme-my-login-admin.php and admin/js/theme-my-login-admin.js.
671
- *
672
- * @see http://core.trac.wordpress.org/ticket/31821
673
- */
674
- if ( isset( $query['interim-login'] ) )
675
- return $url;
676
-
677
- // Determine the action
678
- $action = isset( $query['action'] ) ? $query['action'] : 'login';
679
-
680
- // Get the action's page link
681
- $url = self::get_page_link( $action, $query );
682
-
683
- // Change the connection scheme to HTTPS, if needed
684
- if ( 'https' == strtolower( $orig_scheme ) )
685
- $url = preg_replace( '|^http://|', 'https://', $url );
686
-
687
- return $url;
688
- }
689
-
690
- /**
691
- * Filters logout URL to allow for logout permalink
692
- *
693
- * This is needed because WP doesn't pass the action parameter to site_url
694
- *
695
- * @since 6.3
696
- * @access public
697
- *
698
- * @param string $logout_url Logout URL
699
- * @param string $redirect Redirect URL
700
- * @return string Logout URL
701
- */
702
- public function logout_url( $logout_url, $redirect ) {
703
- $logout_url = self::get_page_link( 'logout' );
704
- if ( $redirect )
705
- $logout_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $logout_url );
706
- return $logout_url;
707
- }
708
-
709
- /**
710
- * Changes single_post_title() to reflect the current action
711
- *
712
- * Callback for "single_post_title" hook in single_post_title()
713
- *
714
- * @see single_post_title()
715
- * @since 6.0
716
- * @access public
717
- *
718
- * @param string $title The current post title
719
- * @return string The modified post title
720
- */
721
- function single_post_title( $title ) {
722
- if ( self::is_tml_page( 'login' ) && is_user_logged_in() )
723
- $title = $this->get_instance()->get_title( 'login' );
724
- return $title;
725
- }
726
-
727
- /**
728
- * Changes the_title() to reflect the current action
729
- *
730
- * Callback for "the_title" hook in the_title()
731
- *
732
- * @see the_title()
733
- * @since 6.0
734
- * @acess public
735
- *
736
- * @param string $title The current post title
737
- * @param int $post_id The current post ID
738
- * @return string The modified post title
739
- */
740
- public function the_title( $title, $post_id = 0 ) {
741
- if ( is_admin() )
742
- return $title;
743
-
744
- if ( self::is_tml_page( 'login', $post_id ) && is_user_logged_in() ) {
745
- if ( in_the_loop() )
746
- $title = $this->get_instance()->get_title( 'login' );
747
- }
748
- return $title;
749
- }
750
-
751
- /**
752
- * Hide Login & Register if user is logged in, hide Logout if not
753
- *
754
- * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
755
- *
756
- * @see wp_setup_nav_menu_item()
757
- * @since 6.0
758
- * @access public
759
- *
760
- * @param object $menu_item The menu item
761
- * @return object The (possibly) modified menu item
762
- */
763
- public function wp_setup_nav_menu_item( $menu_item ) {
764
- if ( is_admin() )
765
- return $menu_item;
766
-
767
- if ( 'page' != $menu_item->object )
768
- return $menu_item;
769
-
770
- // User is logged in
771
- if ( is_user_logged_in() ) {
772
-
773
- // Hide login, register and lost password
774
- if ( self::is_tml_page( array( 'login', 'register', 'lostpassword' ), $menu_item->object_id ) ) {
775
- $menu_item->_invalid = true;
776
- }
777
-
778
- // User is not logged in
779
- } else {
780
-
781
- // Hide Logout
782
- if ( self::is_tml_page( 'logout', $menu_item->object_id ) ) {
783
- $menu_item->_invalid = true;
784
- }
785
- }
786
-
787
- return $menu_item;
788
- }
789
-
790
- /**
791
- * Excludes pages from wp_list_pages
792
- *
793
- * @since 6.3.7
794
- *
795
- * @param array $exclude Page IDs to exclude
796
- * @return array Page IDs to exclude
797
- */
798
- public function wp_list_pages_excludes( $exclude ) {
799
- $pages = get_posts( array(
800
- 'post_type' => 'page',
801
- 'post_status' => 'any',
802
- 'meta_key' => '_tml_action',
803
- 'posts_per_page' => -1
804
- ) );
805
- $pages = wp_list_pluck( $pages, 'ID' );
806
-
807
- return array_merge( $exclude, $pages );
808
- }
809
-
810
- /**
811
- * Adds nonce to logout link
812
- *
813
- * @since 6.3.7
814
- *
815
- * @param string $link Page link
816
- * @param int $post_id Post ID
817
- * @return string Page link
818
- */
819
- public function page_link( $link, $post_id ) {
820
- if ( self::is_tml_page( 'logout', $post_id ) )
821
- $link = add_query_arg( '_wpnonce', wp_create_nonce( 'log-out' ), $link );
822
- return $link;
823
- }
824
-
825
- /**
826
- * Add proper message in case of e-mail login error
827
- *
828
- * @since 6.4.5
829
- *
830
- * @param null|WP_Error|WP_User $user
831
- * @param string $username
832
- * @param string $password
833
- * @return null|WP_User|WP_Error
834
- */
835
- public function authenticate( $user, $username, $password ) {
836
- if ( 'email' == $this->get_option( 'login_type' ) && null == $user ) {
837
- return new WP_Error( 'invalid_email', __( '<strong>ERROR</strong>: Invalid email address.', 'theme-my-login' ) );
838
- }
839
-
840
- return $user;
841
- }
842
-
843
-
844
- /************************************************************************************************************************
845
- * Utilities
846
- ************************************************************************************************************************/
847
-
848
- /**
849
- * Handler for "theme-my-login" shortcode
850
- *
851
- * Optional $atts contents:
852
- *
853
- * - instance - A unqiue instance ID for this instance.
854
- * - default_action - The action to display. Defaults to "login".
855
- * - login_template - The template used for the login form. Defaults to "login-form.php".
856
- * - register_template - The template used for the register form. Defaults to "register-form.php".
857
- * - lostpassword_template - The template used for the lost password form. Defaults to "lostpassword-form.php".
858
- * - resetpass_template - The template used for the reset password form. Defaults to "resetpass-form.php".
859
- * - user_template - The templated used for when a user is logged in. Defalts to "user-panel.php".
860
- * - show_title - True to display the current title, false to hide. Defaults to true.
861
- * - show_log_link - True to display the login link, false to hide. Defaults to true.
862
- * - show_reg_link - True to display the register link, false to hide. Defaults to true.
863
- * - show_pass_link - True to display the lost password link, false to hide. Defaults to true.
864
- * - logged_in_widget - True to display the widget when logged in, false to hide. Defaults to true.
865
- * - logged_out_widget - True to display the widget when logged out, false to hide. Defaults to true.
866
- * - show_gravatar - True to display the user's gravatar, false to hide. Defaults to true.
867
- * - gravatar_size - The size of the user's gravatar. Defaults to "50".
868
- *
869
- * @since 6.0
870
- * @access public
871
- *
872
- * @param string|array $atts Attributes passed from the shortcode
873
- * @return string HTML output from Theme_My_Login_Template->display()
874
- */
875
- public function shortcode( $atts = '' ) {
876
- static $did_main_instance = false;
877
-
878
- $atts = wp_parse_args( $atts );
879
-
880
- if ( self::is_tml_page() && in_the_loop() && is_main_query() && ! $did_main_instance ) {
881
- $instance = $this->get_instance();
882
-
883
- if ( ! empty( $this->request_instance ) )
884
- $instance->set_active( false );
885
-
886
- if ( ! empty( $this->request_action ) )
887
- $atts['default_action'] = $this->request_action;
888
-
889
- if ( ! isset( $atts['show_title'] ) )
890
- $atts['show_title'] = false;
891
-
892
- foreach ( $atts as $option => $value ) {
893
- $instance->set_option( $option, $value );
894
- }
895
-
896
- $did_main_instance = true;
897
- } else {
898
- $instance = $this->load_instance( $atts );
899
- }
900
- return $instance->display();
901
- }
902
-
903
- /**
904
- * Determines if $action is for $page
905
- *
906
- * @since 6.3
907
- *
908
- * @param array|string $action An action or array of actions to check
909
- * @param int|object Post ID or object
910
- * @return bool True if $action is for $page, false otherwise
911
- */
912
- public static function is_tml_page( $action = '', $page = '' ) {
913
- if ( ! $page = get_post( $page ) )
914
- return false;
915
-
916
- if ( 'page' != $page->post_type )
917
- return false;
918
-
919
- if ( ! $page_action = self::get_page_action( $page->ID ) )
920
- return false;
921
-
922
- if ( empty( $action ) )
923
- return true;
924
-
925
- if ( in_array( $page_action, (array) $action ) )
926
- return true;
927
-
928
- return false;
929
- }
930
-
931
- /**
932
- * Returns link for a login page
933
- *
934
- * @since 6.3
935
- * @access public
936
- *
937
- * @param string $action The action
938
- * @param string|array $query Optional. Query arguments to add to link
939
- * @return string Login page link with optional $query arguments appended
940
- */
941
- public static function get_page_link( $action, $query = '' ) {
942
- $page_id = self::get_page_id( $action );
943
-
944
- if ( $page_id ) {
945
- $link = get_permalink( $page_id );
946
- } elseif ( $page_id = self::get_page_id( 'login' ) ) {
947
- $link = add_query_arg( 'action', $action, get_permalink( $page_id ) );
948
- } else {
949
- // Remove site_url filter so we can use wp-login.php
950
- remove_filter( 'site_url', array( self::get_object(), 'site_url' ), 10, 3 );
951
-
952
- $link = site_url( "wp-login.php?action=$action" );
953
- }
954
-
955
- if ( ! empty( $query ) ) {
956
- $args = wp_parse_args( $query );
957
-
958
- if ( isset( $args['action'] ) && $action == $args['action'] )
959
- unset( $args['action'] );
960
-
961
- $link = add_query_arg( array_map( 'rawurlencode', $args ), $link );
962
- }
963
-
964
- $link = set_url_scheme( $link, 'login' );
965
-
966
- return apply_filters( 'tml_page_link', $link, $action, $query );
967
- }
968
-
969
- /**
970
- * Retrieves a page ID for an action
971
- *
972
- * @since 6.3
973
- *
974
- * @param string $action The action
975
- * @return int|bool The page ID if exists, false otherwise
976
- */
977
- public static function get_page_id( $action ) {
978
- global $wpdb;
979
-
980
- if ( 'rp' == $action )
981
- $action = 'resetpass';
982
- elseif ( 'retrievepassword' == $action )
983
- $action = 'lostpassword';
984
-
985
- if ( ! $page_id = wp_cache_get( $action, 'tml_page_ids' ) ) {
986
- $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pmeta ON p.ID = pmeta.post_id WHERE p.post_type = 'page' AND pmeta.meta_key = '_tml_action' AND pmeta.meta_value = %s", $action ) );
987
- if ( ! $page_id )
988
- return null;
989
- wp_cache_add( $action, $page_id, 'tml_page_ids' );
990
- }
991
- return $page_id;
992
- }
993
-
994
- /**
995
- * Get the action for a page
996
- *
997
- * @since 6.3
998
- *
999
- * @param int|object Post ID or object
1000
- * @return string|bool Action name if exists, false otherwise
1001
- */
1002
- public static function get_page_action( $page ) {
1003
- if ( ! $page = get_post( $page ) )
1004
- return false;
1005
-
1006
- return get_post_meta( $page->ID, '_tml_action', true );
1007
- }
1008
-
1009
- /**
1010
- * Enqueues the specified sylesheet
1011
- *
1012
- * First looks in theme/template directories for the stylesheet, falling back to plugin directory
1013
- *
1014
- * @since 6.0
1015
- * @access public
1016
- *
1017
- * @param string $file Filename of stylesheet to load
1018
- * @return string Path to stylesheet
1019
- */
1020
- public static function get_stylesheet( $file = 'theme-my-login.css' ) {
1021
- if ( file_exists( get_stylesheet_directory() . '/' . $file ) )
1022
- $stylesheet = get_stylesheet_directory_uri() . '/' . $file;
1023
- elseif ( file_exists( get_template_directory() . '/' . $file ) )
1024
- $stylesheet = get_template_directory_uri() . '/' . $file;
1025
- else
1026
- $stylesheet = plugins_url( $file, dirname( __FILE__ ) );
1027
- return $stylesheet;
1028
- }
1029
-
1030
- /**
1031
- * Retrieves active instance object
1032
- *
1033
- * @since 6.3
1034
- * @access public
1035
- *
1036
- * @return object Instance object
1037
- */
1038
- public function get_active_instance() {
1039
- return $this->get_instance( (int) $this->request_instance );
1040
- }
1041
-
1042
- /**
1043
- * Retrieves a loaded instance object
1044
- *
1045
- * @since 6.3
1046
- * @access public
1047
- *
1048
- * @param int $id Instance ID
1049
- * @return object Instance object
1050
-
1051
- */
1052
- public function get_instance( $id = 0 ) {
1053
- if ( isset( $this->loaded_instances[$id] ) )
1054
- return $this->loaded_instances[$id];
1055
- }
1056
-
1057
- /**
1058
- * Sets an instance object
1059
- *
1060
- * @since 6.3
1061
- * @access public
1062
- *
1063
- * @param object $object Instance object
1064
- */
1065
- public function set_instance( $object ) {
1066
- $this->loaded_instances[] = $object;
1067
- }
1068
-
1069
- /**
1070
- * Instantiates an instance
1071
- *
1072
- * @since 6.3
1073
- * @access public
1074
- *
1075
- * @param array|string $args Array or query string of arguments
1076
-
1077
- * @return object Instance object
1078
- */
1079
- public function load_instance( $args = '' ) {
1080
- $args['instance'] = count( $this->loaded_instances );
1081
-
1082
- $instance = new Theme_My_Login_Template( $args );
1083
-
1084
- if ( $args['instance'] == $this->request_instance ) {
1085
- $instance->set_active();
1086
- $instance->set_option( 'default_action', $this->request_action );
1087
- }
1088
-
1089
- $this->loaded_instances[] = $instance;
1090
-
1091
- return $instance;
1092
- }
1093
-
1094
- /**
1095
- * Load a custom translation file for current language if available.
1096
- *
1097
- * Note that custom translation files inside the plugin folder
1098
- * will be removed on plugin updates. If you're creating custom
1099
- * translation files, please place them in a '/theme-my-login/'
1100
- * directory within the global language folder.
1101
- *
1102
- * @since 6.4.4
1103
- *
1104
- * @param string $domain The domain for which a language file is being loaded.
1105
- * @param string $mofile Full path to the target mofile.
1106
- */
1107
- public function load_custom_textdomain( $domain, $mofile ) {
1108
- if ( 'theme-my-login' === $domain ) {
1109
- remove_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1110
-
1111
- // Look in global /wp-content/languages/theme-my-login folder for a translation
1112
- // and load it if available.
1113
- $mofile = basename( $mofile );
1114
- if ( file_exists( WP_LANG_DIR . '/theme-my-login/' . $mofile ) ) {
1115
- load_textdomain( 'theme-my-login', WP_LANG_DIR . '/theme-my-login/' . $mofile );
1116
- }
1117
-
1118
- add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1119
- }
1120
- }
1121
-
1122
- /**
1123
- * Handles sending password retrieval email to user.
1124
- *
1125
- * @since 6.0
1126
- * @access public
1127
- * @uses $wpdb WordPress Database object
1128
- *
1129
- * @return bool|WP_Error True: when finish. WP_Error on error
1130
- */
1131
- public static function retrieve_password() {
1132
- global $wpdb, $wp_hasher;
1133
-
1134
- $errors = new WP_Error();
1135
-
1136
- if ( empty( $_POST['user_login'] ) ) {
1137
- $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or e-mail address.', 'theme-my-login' ) );
1138
- } else if ( strpos( $_POST['user_login'], '@' ) ) {
1139
- $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
1140
- if ( empty( $user_data ) )
1141
- $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no user registered with that email address.', 'theme-my-login' ) );
1142
- } else {
1143
- $login = trim( $_POST['user_login'] );
1144
- $user_data = get_user_by( 'login', $login );
1145
- }
1146
-
1147
- do_action( 'lostpassword_post', $errors );
1148
-
1149
- if ( $errors->get_error_code() )
1150
- return $errors;
1151
-
1152
- if ( ! $user_data ) {
1153
- $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: Invalid username or e-mail.', 'theme-my-login' ) );
1154
- return $errors;
1155
- }
1156
-
1157
- // redefining user_login ensures we return the right case in the email
1158
- $user_login = $user_data->user_login;
1159
- $user_email = $user_data->user_email;
1160
- $key = get_password_reset_key( $user_data );
1161
-
1162
- if ( is_wp_error( $key ) ) {
1163
- return $key;
1164
- }
1165
-
1166
- $message = __( 'Someone requested that the password be reset for the following account:', 'theme-my-login' ) . "\r\n\r\n";
1167
- $message .= network_home_url( '/' ) . "\r\n\r\n";
1168
- $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n\r\n";
1169
- $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'theme-my-login' ) . "\r\n\r\n";
1170
- $message .= __( 'To reset your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
1171
- $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n";
1172
-
1173
- if ( is_multisite() ) {
1174
- $blogname = $GLOBALS['current_site']->site_name;
1175
- } else {
1176
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
1177
- // we want to reverse this for the plain text arena of emails.
1178
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1179
- }
1180
-
1181
- $title = sprintf( __( '[%s] Password Reset', 'theme-my-login' ), $blogname );
1182
-
1183
- $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
1184
- $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
1185
-
1186
- if ( $message && ! wp_mail( $user_email, $title, $message ) )
1187
- wp_die( __( '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' ) );
1188
-
1189
- return true;
1190
- }
1191
- }
1192
- endif; // Class exists
1193
-
1
+ <?php
2
+ /**
3
+ * Holds the Theme My Login class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @since 6.0
7
+ */
8
+
9
+ if ( ! class_exists( 'Theme_My_Login' ) ) :
10
+ /*
11
+ * Theme My Login class
12
+ *
13
+ * This class contains properties and methods common to the front-end.
14
+ *
15
+ * @since 6.0
16
+ */
17
+ class Theme_My_Login extends Theme_My_Login_Abstract {
18
+ /**
19
+ * Holds plugin version
20
+ *
21
+ * @since 6.3.2
22
+ * @const string
23
+ */
24
+ const VERSION = '6.4.6';
25
+
26
+ /**
27
+ * Holds options key
28
+ *
29
+ * @since 6.3
30
+ * @access protected
31
+ * @var string
32
+ */
33
+ protected $options_key = 'theme_my_login';
34
+
35
+ /**
36
+ * Holds errors object
37
+ *
38
+ * @since 6.0
39
+ * @access public
40
+ * @var object
41
+ */
42
+ public $errors;
43
+
44
+ /**
45
+ * Holds current page being requested
46
+ *
47
+ * @since 6.3
48
+ * @access public
49
+ * @var string
50
+ */
51
+ public $request_page;
52
+
53
+ /**
54
+ * Holds current action being requested
55
+ *
56
+ * @since 6.0
57
+ * @access public
58
+ * @var string
59
+ */
60
+ public $request_action;
61
+
62
+ /**
63
+ * Holds current instance being requested
64
+ *
65
+ * @since 6.0
66
+ * @access public
67
+ * @var int
68
+ */
69
+ public $request_instance = 0;
70
+
71
+ /**
72
+ * Holds loaded instances
73
+ *
74
+ * @since 6.3
75
+ * @access protected
76
+ * @var array
77
+ */
78
+ protected $loaded_instances = array();
79
+
80
+ /**
81
+ * Returns singleton instance
82
+ *
83
+ * @since 6.3
84
+ * @access public
85
+ * @return object
86
+ */
87
+ public static function get_object( $class = null ) {
88
+ return parent::get_object( __CLASS__ );
89
+ }
90
+
91
+ /**
92
+ * Returns default options
93
+ *
94
+ * @since 6.3
95
+ * @access public
96
+ *
97
+ * @return array Default options
98
+ */
99
+ public static function default_options() {
100
+ return apply_filters( 'tml_default_options', array(
101
+ 'enable_css' => true,
102
+ 'login_type' => 'default',
103
+ 'active_modules' => array()
104
+ ) );
105
+ }
106
+
107
+ /**
108
+ * Returns default pages
109
+ *
110
+ * @since 6.3
111
+ * @access public
112
+ *
113
+ * @return array Default pages
114
+ */
115
+ public static function default_pages() {
116
+ return apply_filters( 'tml_default_pages', array(
117
+ 'login' => __( 'Log In' , 'theme-my-login' ),
118
+ 'logout' => __( 'Log Out' , 'theme-my-login' ),
119
+ 'register' => __( 'Register' , 'theme-my-login' ),
120
+ 'lostpassword' => __( 'Lost Password' , 'theme-my-login' ),
121
+ 'resetpass' => __( 'Reset Password', 'theme-my-login' )
122
+ ) );
123
+ }
124
+
125
+ /**
126
+ * Loads the plugin
127
+ *
128
+ * @since 6.0
129
+ * @access public
130
+ */
131
+ protected function load() {
132
+
133
+ $this->load_instance();
134
+
135
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
136
+ add_action( 'init', array( $this, 'init' ) );
137
+ add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
138
+ add_action( 'widgets_init', array( $this, 'widgets_init' ) );
139
+ add_action( 'wp', array( $this, 'wp' ) );
140
+ add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
141
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
142
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
143
+ add_action( 'wp_head', array( $this, 'wp_head' ) );
144
+ add_action( 'wp_footer', array( $this, 'wp_footer' ) );
145
+ add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
146
+
147
+ add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
148
+ add_filter( 'logout_url', array( $this, 'logout_url' ), 10, 2 );
149
+ add_filter( 'single_post_title', array( $this, 'single_post_title' ) );
150
+ add_filter( 'the_title', array( $this, 'the_title' ), 10, 2 );
151
+ add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ) );
152
+ add_filter( 'wp_list_pages_excludes', array( $this, 'wp_list_pages_excludes' ) );
153
+ add_filter( 'page_link', array( $this, 'page_link' ), 10, 2 );
154
+ add_filter( 'authenticate', array( $this, 'authenticate' ), 20, 3 );
155
+
156
+ add_shortcode( 'theme-my-login', array( $this, 'shortcode' ) );
157
+
158
+ if ( 'username' == $this->get_option( 'login_type' ) ) {
159
+ remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
160
+ } elseif ( 'email' == $this->get_option( 'login_type' ) ) {
161
+ remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );
162
+ }
163
+ }
164
+
165
+
166
+ /************************************************************************************************************************
167
+ * Actions
168
+ ************************************************************************************************************************/
169
+
170
+ /**
171
+ * Loads active modules
172
+ *
173
+ * @since 6.3
174
+ * @access public
175
+ */
176
+ public function plugins_loaded() {
177
+ foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
178
+ if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
179
+ include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
180
+ }
181
+ do_action_ref_array( 'tml_modules_loaded', array( &$this ) );
182
+ }
183
+
184
+ /**
185
+ * Initializes the plugin
186
+ *
187
+ * @since 6.0
188
+ * @access public
189
+ */
190
+ public function init() {
191
+ global $pagenow;
192
+
193
+ load_plugin_textdomain( 'theme-my-login', false, plugin_basename( THEME_MY_LOGIN_PATH ) . '/languages' );
194
+
195
+ $this->errors = new WP_Error();
196
+
197
+ if ( ! is_admin() && 'wp-login.php' != $pagenow && $this->get_option( 'enable_css' ) )
198
+ wp_enqueue_style( 'theme-my-login', self::get_stylesheet(), false, $this->get_option( 'version' ) );
199
+ }
200
+
201
+ /**
202
+ * Registers the widget
203
+ *
204
+ * @since 6.0
205
+ * @access public
206
+ */
207
+ public function widgets_init() {
208
+ if ( class_exists( 'Theme_My_Login_Widget' ) )
209
+ register_widget( 'Theme_My_Login_Widget' );
210
+ }
211
+
212
+ /**
213
+ * Used to add/remove filters from login page
214
+ *
215
+ * @since 6.1.1
216
+ * @access public
217
+ */
218
+ public function wp() {
219
+ if ( self::is_tml_page() ) {
220
+ do_action( 'login_init' );
221
+
222
+ remove_action( 'wp_head', 'feed_links', 2 );
223
+ remove_action( 'wp_head', 'feed_links_extra', 3 );
224
+ remove_action( 'wp_head', 'rsd_link' );
225
+ remove_action( 'wp_head', 'wlwmanifest_link' );
226
+ remove_action( 'wp_head', 'parent_post_rel_link', 10 );
227
+ remove_action( 'wp_head', 'start_post_rel_link', 10 );
228
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
229
+ remove_action( 'wp_head', 'rel_canonical' );
230
+
231
+ // Don't index any of these forms
232
+ add_action( 'login_head', 'wp_no_robots' );
233
+
234
+ if ( force_ssl_admin() && ! is_ssl() ) {
235
+ if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
236
+ wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
237
+ exit;
238
+ } else {
239
+ wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
240
+ exit;
241
+ }
242
+ }
243
+
244
+ nocache_headers();
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Exclude TML pages from search
250
+ *
251
+ * @since 6.1.13
252
+ * @access public
253
+ */
254
+ public function pre_get_posts( $query ) {
255
+
256
+ // Bail if not a search
257
+ if ( ! $query->is_search )
258
+ return;
259
+
260
+ // Get the requested post type
261
+ $post_type = $query->get( 'post_type' );
262
+
263
+ // Bail if not querying pages
264
+ if ( ! empty( $post_type ) && ! in_array( 'page', (array) $post_type ) )
265
+ return;
266
+
267
+ // Get TML pages
268
+ $pages = get_posts( array(
269
+ 'post_type' => 'page',
270
+ 'post_status' => 'any',
271
+ 'meta_key' => '_tml_action',
272
+ 'posts_per_page' => -1
273
+ ) );
274
+
275
+ // Get the page IDs
276
+ $pages = wp_list_pluck( $pages, 'ID' );
277
+
278
+ // Get any currently exclude posts
279
+ $excludes = (array) $query->get( 'post__not_in' );
280
+
281
+ // Merge the excludes
282
+ $excludes = array_merge( $excludes, $pages );
283
+
284
+ // Set the excludes
285
+ $query->set( 'post__not_in', $excludes );
286
+ }
287
+
288
+ /**
289
+ * Proccesses the request
290
+ *
291
+ * Callback for "template_redirect" hook in template-loader.php
292
+ *
293
+ * @since 6.3
294
+ * @access public
295
+ */
296
+ public function template_redirect() {
297
+ $this->request_action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
298
+ if ( ! $this->request_action && self::is_tml_page() )
299
+ $this->request_action = self::get_page_action( get_the_id() );
300
+ $this->request_instance = isset( $_REQUEST['instance'] ) ? sanitize_key( $_REQUEST['instance'] ) : 0;
301
+
302
+ do_action_ref_array( 'tml_request', array( &$this ) );
303
+
304
+ // allow plugins to override the default actions, and to add extra actions if they want
305
+ do_action( 'login_form_' . $this->request_action );
306
+
307
+ if ( has_action( 'tml_request_' . $this->request_action ) ) {
308
+ do_action_ref_array( 'tml_request_' . $this->request_action, array( &$this ) );
309
+ } else {
310
+ $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
311
+ switch ( $this->request_action ) {
312
+ case 'postpass' :
313
+ if ( ! array_key_exists( 'post_password', $_POST ) ) {
314
+ wp_safe_redirect( wp_get_referer() );
315
+ exit();
316
+ }
317
+
318
+ require_once( ABSPATH . 'wp-includes/class-phpass.php' );
319
+ $hasher = new PasswordHash( 8, true );
320
+
321
+ $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
322
+ if ( $referer ) {
323
+ $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
324
+ } else {
325
+ $secure = false;
326
+ }
327
+ setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
328
+
329
+ wp_safe_redirect( wp_get_referer() );
330
+ exit;
331
+
332
+ break;
333
+ case 'logout' :
334
+ check_admin_referer( 'log-out' );
335
+
336
+ $user = wp_get_current_user();
337
+
338
+ wp_logout();
339
+
340
+ if ( ! empty( $_REQUEST['redirect_to'] ) ) {
341
+ $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
342
+ } else {
343
+ $redirect_to = site_url( 'wp-login.php?loggedout=true' );
344
+ $requested_redirect_to = '';
345
+ }
346
+
347
+ $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
348
+ wp_safe_redirect( $redirect_to );
349
+ exit;
350
+ break;
351
+ case 'lostpassword' :
352
+ case 'retrievepassword' :
353
+ if ( $http_post ) {
354
+ $this->errors = self::retrieve_password();
355
+ if ( ! is_wp_error( $this->errors ) ) {
356
+ $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url( 'wp-login.php?checkemail=confirm' );
357
+ wp_safe_redirect( $redirect_to );
358
+ exit;
359
+ }
360
+ }
361
+
362
+ if ( isset( $_REQUEST['error'] ) ) {
363
+ if ( 'invalidkey' == $_REQUEST['error'] )
364
+ $this->errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.', 'theme-my-login' ) );
365
+ elseif ( 'expiredkey' == $_REQUEST['error'] )
366
+ $this->errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.', 'theme-my-login' ) );
367
+ }
368
+
369
+ do_action( 'lost_password' );
370
+ break;
371
+ case 'resetpass' :
372
+ case 'rp' :
373
+ // Dirty hack for now
374
+ global $rp_login, $rp_key;
375
+
376
+ $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
377
+ if ( isset( $_GET['key'] ) ) {
378
+ $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
379
+ setcookie( $rp_cookie, $value, 0, '/', COOKIE_DOMAIN, is_ssl(), true );
380
+ wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
381
+ exit;
382
+ }
383
+
384
+ if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
385
+ list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
386
+ $user = check_password_reset_key( $rp_key, $rp_login );
387
+ if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
388
+ $user = false;
389
+ }
390
+ } else {
391
+ $user = false;
392
+ }
393
+
394
+ if ( ! $user || is_wp_error( $user ) ) {
395
+ setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
396
+ if ( $user && $user->get_error_code() === 'expired_key' )
397
+ wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
398
+ else
399
+ wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
400
+ exit;
401
+ }
402
+
403
+ if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] )
404
+ $this->errors->add( 'password_reset_mismatch', __( 'The passwords do not match.', 'theme-my-login' ) );
405
+
406
+ do_action( 'validate_password_reset', $this->errors, $user );
407
+
408
+ if ( ( ! $this->errors->get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
409
+ reset_password( $user, $_POST['pass1'] );
410
+ setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
411
+ $redirect_to = site_url( 'wp-login.php?resetpass=complete' );
412
+ wp_safe_redirect( $redirect_to );
413
+ exit;
414
+ }
415
+
416
+ wp_enqueue_script( 'utils' );
417
+ wp_enqueue_script( 'user-profile' );
418
+ break;
419
+ case 'register' :
420
+ if ( ! get_option( 'users_can_register' ) ) {
421
+ $redirect_to = site_url( 'wp-login.php?registration=disabled' );
422
+ wp_redirect( $redirect_to );
423
+ exit;
424
+ }
425
+
426
+ $user_login = '';
427
+ $user_email = '';
428
+ if ( $http_post ) {
429
+ if ( 'email' == $this->get_option( 'login_type' ) ) {
430
+ $user_login = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
431
+ } else {
432
+ $user_login = isset( $_POST['user_login'] ) ? $_POST['user_login'] : '';
433
+ }
434
+ $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
435
+
436
+ $this->errors = register_new_user( $user_login, $user_email );
437
+ if ( ! is_wp_error( $this->errors ) ) {
438
+ $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : site_url( 'wp-login.php?checkemail=registered' );
439
+ wp_safe_redirect( $redirect_to );
440
+ exit;
441
+ }
442
+ }
443
+ break;
444
+ case 'login' :
445
+ default:
446
+ $secure_cookie = '';
447
+ $interim_login = isset( $_REQUEST['interim-login'] );
448
+
449
+ // If the user wants ssl but the session is not ssl, force a secure cookie.
450
+ if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
451
+ $user_name = sanitize_user( $_POST['log'] );
452
+ if ( $user = get_user_by( 'login', $user_name ) ) {
453
+ if ( get_user_option( 'use_ssl', $user->ID ) ) {
454
+ $secure_cookie = true;
455
+ force_ssl_admin( true );
456
+ }
457
+ }
458
+ }
459
+
460
+ if ( ! empty( $_REQUEST['redirect_to'] ) ) {
461
+ $redirect_to = $_REQUEST['redirect_to'];
462
+ // Redirect to https if user wants ssl
463
+ if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) )
464
+ $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
465
+ } else {
466
+ $redirect_to = admin_url();
467
+ }
468
+
469
+ $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
470
+
471
+ if ( $http_post && isset( $_POST['log'] ) ) {
472
+
473
+ $user = wp_signon( '', $secure_cookie );
474
+
475
+ $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
476
+
477
+ if ( ! is_wp_error( $user ) && ! $reauth ) {
478
+ if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
479
+ // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile.
480
+ if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) )
481
+ $redirect_to = user_admin_url();
482
+ elseif ( is_multisite() && ! $user->has_cap( 'read' ) )
483
+ $redirect_to = get_dashboard_url( $user->ID );
484
+ elseif ( ! $user->has_cap( 'edit_posts' ) )
485
+ $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
486
+
487
+ wp_redirect( $redirect_to );
488
+ exit;
489
+ }
490
+ wp_safe_redirect( $redirect_to );
491
+ exit;
492
+ }
493
+
494
+ $this->errors = $user;
495
+ }
496
+
497
+ // Clear errors if loggedout is set.
498
+ if ( ! empty( $_GET['loggedout'] ) || $reauth )
499
+ $this->errors = new WP_Error();
500
+
501
+ // Some parts of this script use the main login form to display a message
502
+ if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] )
503
+ $this->errors->add( 'loggedout', __( 'You are now logged out.', 'theme-my-login' ), 'message' );
504
+ elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] )
505
+ $this->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'theme-my-login' ) );
506
+ elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] )
507
+ $this->errors->add( 'confirm', __( 'Check your e-mail for the confirmation link.', 'theme-my-login' ), 'message' );
508
+ elseif ( isset( $_GET['resetpass'] ) && 'complete' == $_GET['resetpass'] )
509
+ $this->errors->add( 'password_reset', __( 'Your password has been reset.', 'theme-my-login' ), 'message' );
510
+ elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] )
511
+ $this->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'theme-my-login' ), 'message' );
512
+ elseif ( $interim_login )
513
+ $this->errors->add( 'expired', __( 'Your session has expired. Please log-in again.', 'theme-my-login' ), 'message' );
514
+ elseif ( strpos( $redirect_to, 'about.php?updated' ) )
515
+ $this->errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.', 'theme-my-login' ), 'message' );
516
+ elseif ( $reauth )
517
+ $this->errors->add( 'reauth', __( 'Please log in to continue.', 'theme-my-login' ), 'message' );
518
+
519
+ // Clear any stale cookies.
520
+ if ( $reauth )
521
+ wp_clear_auth_cookie();
522
+ break;
523
+ } // end switch
524
+ } // endif has_filter()
525
+ }
526
+
527
+ /**
528
+ * Calls "login_enqueue_scripts" on login page
529
+ *
530
+ * Callback for "wp_enqueue_scripts" hook
531
+ *
532
+ * @since 6.3
533
+ */
534
+ public function wp_enqueue_scripts() {
535
+ if ( self::is_tml_page() )
536
+ do_action( 'login_enqueue_scripts' );
537
+ }
538
+
539
+ /**
540
+ * Calls "login_head" hook on login page
541
+ *
542
+ * Callback for "wp_head" hook
543
+ *
544
+ * @since 6.0
545
+ * @access public
546
+ */
547
+ public function wp_head() {
548
+ if ( self::is_tml_page() ) {
549
+ // This is already attached to "wp_head"
550
+ remove_action( 'login_head', 'wp_print_head_scripts', 9 );
551
+
552
+ do_action( 'login_head' );
553
+ }
554
+ }
555
+
556
+ /**
557
+ * Calls "login_footer" hook on login page
558
+ *
559
+ * Callback for "wp_footer" hook
560
+ *
561
+ * @since 6.3
562
+ */
563
+ public function wp_footer() {
564
+ if ( self::is_tml_page() ) {
565
+ // This is already attached to "wp_footer"
566
+ remove_action( 'login_footer', 'wp_print_footer_scripts', 20 );
567
+
568
+ do_action( 'login_footer' );
569
+ }
570
+ }
571
+
572
+ /**
573
+ * Prints javascript in the footer
574
+ *
575
+ * @since 6.0
576
+ * @access public
577
+ */
578
+ public function wp_print_footer_scripts() {
579
+ if ( ! self::is_tml_page() )
580
+ return;
581
+
582
+ switch ( $this->request_action ) {
583
+ case 'lostpassword' :
584
+ case 'retrievepassword' :
585
+ case 'register' :
586
+ ?>
587
+ <script type="text/javascript">
588
+ try{document.getElementById('user_login').focus();}catch(e){}
589
+ if(typeof wpOnload=='function')wpOnload()
590
+ </script>
591
+ <?php
592
+ break;
593
+ case 'resetpass' :
594
+ case 'rp' :
595
+ ?>
596
+ <script type="text/javascript">
597
+ try{document.getElementById('pass1').focus();}catch(e){}
598
+ if(typeof wpOnload=='function')wpOnload()
599
+ </script>
600
+ <?php
601
+ break;
602
+ case 'login' :
603
+ $user_login = '';
604
+ if ( isset($_POST['log']) )
605
+ $user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? esc_attr( stripslashes( $_POST['log'] ) ) : '';
606
+ ?>
607
+ <script type="text/javascript">
608
+ function wp_attempt_focus() {
609
+ setTimeout( function() {
610
+ try {
611
+ <?php if ( $user_login ) { ?>
612
+ d = document.getElementById('user_pass');
613
+ d.value = '';
614
+ <?php } else { ?>
615
+ d = document.getElementById('user_login');
616
+ <?php if ( 'invalid_username' == $this->errors->get_error_code() ) { ?>
617
+ if ( d.value != '' )
618
+ d.value = '';
619
+ <?php
620
+ }
621
+ } ?>
622
+ d.focus();
623
+ d.select();
624
+ } catch(e){}
625
+ }, 200 );
626
+ }
627
+
628
+ wp_attempt_focus();
629
+ if(typeof wpOnload=='function')wpOnload()
630
+ </script>
631
+ <?php
632
+ break;
633
+ }
634
+ }
635
+
636
+ /************************************************************************************************************************
637
+ * Filters
638
+ ************************************************************************************************************************/
639
+
640
+ /**
641
+ * Rewrites URL's containing wp-login.php created by site_url()
642
+ *
643
+ * @since 6.0
644
+ * @access public
645
+ *
646
+ * @param string $url The URL
647
+ * @param string $path The path specified
648
+ * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
649
+ * @param int $blog_id Blog ID
650
+ * @return string The modified URL
651
+ */
652
+ public function site_url( $url, $path, $orig_scheme ) {
653
+ global $pagenow;
654
+
655
+ // Bail if currently viewing wp-login.php
656
+ if ( 'wp-login.php' == $pagenow )
657
+ return $url;
658
+
659
+ // Bail if the URL isn't a login URL
660
+ if ( false === strpos( $url, 'wp-login.php' ) )
661
+ return $url;
662
+
663
+ // Parse the query string from the URL
664
+ parse_str( parse_url( $url, PHP_URL_QUERY ), $query );
665
+
666
+ /**
667
+ * Bail if the URL is an interim-login URL
668
+ *
669
+ * This only works using the javascript workaround as implemented in
670
+ * admin/theme-my-login-admin.php and admin/js/theme-my-login-admin.js.
671
+ *
672
+ * @see http://core.trac.wordpress.org/ticket/31821
673
+ */
674
+ if ( isset( $query['interim-login'] ) )
675
+ return $url;
676
+
677
+ // Determine the action
678
+ $action = isset( $query['action'] ) ? $query['action'] : 'login';
679
+
680
+ // Get the action's page link
681
+ $url = self::get_page_link( $action, $query );
682
+
683
+ // Change the connection scheme to HTTPS, if needed
684
+ if ( 'https' == strtolower( $orig_scheme ) )
685
+ $url = preg_replace( '|^http://|', 'https://', $url );
686
+
687
+ return $url;
688
+ }
689
+
690
+ /**
691
+ * Filters logout URL to allow for logout permalink
692
+ *
693
+ * This is needed because WP doesn't pass the action parameter to site_url
694
+ *
695
+ * @since 6.3
696
+ * @access public
697
+ *
698
+ * @param string $logout_url Logout URL
699
+ * @param string $redirect Redirect URL
700
+ * @return string Logout URL
701
+ */
702
+ public function logout_url( $logout_url, $redirect ) {
703
+ $logout_url = self::get_page_link( 'logout' );
704
+ if ( $redirect )
705
+ $logout_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $logout_url );
706
+ return $logout_url;
707
+ }
708
+
709
+ /**
710
+ * Changes single_post_title() to reflect the current action
711
+ *
712
+ * Callback for "single_post_title" hook in single_post_title()
713
+ *
714
+ * @see single_post_title()
715
+ * @since 6.0
716
+ * @access public
717
+ *
718
+ * @param string $title The current post title
719
+ * @return string The modified post title
720
+ */
721
+ function single_post_title( $title ) {
722
+ if ( self::is_tml_page( 'login' ) && is_user_logged_in() )
723
+ $title = $this->get_instance()->get_title( 'login' );
724
+ return $title;
725
+ }
726
+
727
+ /**
728
+ * Changes the_title() to reflect the current action
729
+ *
730
+ * Callback for "the_title" hook in the_title()
731
+ *
732
+ * @see the_title()
733
+ * @since 6.0
734
+ * @acess public
735
+ *
736
+ * @param string $title The current post title
737
+ * @param int $post_id The current post ID
738
+ * @return string The modified post title
739
+ */
740
+ public function the_title( $title, $post_id = 0 ) {
741
+ if ( is_admin() )
742
+ return $title;
743
+
744
+ if ( self::is_tml_page( 'login', $post_id ) && is_user_logged_in() ) {
745
+ if ( in_the_loop() )
746
+ $title = $this->get_instance()->get_title( 'login' );
747
+ }
748
+ return $title;
749
+ }
750
+
751
+ /**
752
+ * Hide Login & Register if user is logged in, hide Logout if not
753
+ *
754
+ * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
755
+ *
756
+ * @see wp_setup_nav_menu_item()
757
+ * @since 6.0
758
+ * @access public
759
+ *
760
+ * @param object $menu_item The menu item
761
+ * @return object The (possibly) modified menu item
762
+ */
763
+ public function wp_setup_nav_menu_item( $menu_item ) {
764
+ if ( is_admin() )
765
+ return $menu_item;
766
+
767
+ if ( 'page' != $menu_item->object )
768
+ return $menu_item;
769
+
770
+ // User is logged in
771
+ if ( is_user_logged_in() ) {
772
+
773
+ // Hide login, register and lost password
774
+ if ( self::is_tml_page( array( 'login', 'register', 'lostpassword' ), $menu_item->object_id ) ) {
775
+ $menu_item->_invalid = true;
776
+ }
777
+
778
+ // User is not logged in
779
+ } else {
780
+
781
+ // Hide Logout
782
+ if ( self::is_tml_page( 'logout', $menu_item->object_id ) ) {
783
+ $menu_item->_invalid = true;
784
+ }
785
+ }
786
+
787
+ return $menu_item;
788
+ }
789
+
790
+ /**
791
+ * Excludes pages from wp_list_pages
792
+ *
793
+ * @since 6.3.7
794
+ *
795
+ * @param array $exclude Page IDs to exclude
796
+ * @return array Page IDs to exclude
797
+ */
798
+ public function wp_list_pages_excludes( $exclude ) {
799
+ $pages = get_posts( array(
800
+ 'post_type' => 'page',
801
+ 'post_status' => 'any',
802
+ 'meta_key' => '_tml_action',
803
+ 'posts_per_page' => -1
804
+ ) );
805
+ $pages = wp_list_pluck( $pages, 'ID' );
806
+
807
+ return array_merge( $exclude, $pages );
808
+ }
809
+
810
+ /**
811
+ * Adds nonce to logout link
812
+ *
813
+ * @since 6.3.7
814
+ *
815
+ * @param string $link Page link
816
+ * @param int $post_id Post ID
817
+ * @return string Page link
818
+ */
819
+ public function page_link( $link, $post_id ) {
820
+ if ( self::is_tml_page( 'logout', $post_id ) )
821
+ $link = add_query_arg( '_wpnonce', wp_create_nonce( 'log-out' ), $link );
822
+ return $link;
823
+ }
824
+
825
+ /**
826
+ * Add proper message in case of e-mail login error
827
+ *
828
+ * @since 6.4.5
829
+ *
830
+ * @param null|WP_Error|WP_User $user
831
+ * @param string $username
832
+ * @param string $password
833
+ * @return null|WP_User|WP_Error
834
+ */
835
+ public function authenticate( $user, $username, $password ) {
836
+ if ( 'email' == $this->get_option( 'login_type' ) && null == $user ) {
837
+ return new WP_Error( 'invalid_email', __( '<strong>ERROR</strong>: Invalid email address.', 'theme-my-login' ) );
838
+ }
839
+
840
+ return $user;
841
+ }
842
+
843
+
844
+ /************************************************************************************************************************
845
+ * Utilities
846
+ ************************************************************************************************************************/
847
+
848
+ /**
849
+ * Handler for "theme-my-login" shortcode
850
+ *
851
+ * Optional $atts contents:
852
+ *
853
+ * - instance - A unqiue instance ID for this instance.
854
+ * - default_action - The action to display. Defaults to "login".
855
+ * - login_template - The template used for the login form. Defaults to "login-form.php".
856
+ * - register_template - The template used for the register form. Defaults to "register-form.php".
857
+ * - lostpassword_template - The template used for the lost password form. Defaults to "lostpassword-form.php".
858
+ * - resetpass_template - The template used for the reset password form. Defaults to "resetpass-form.php".
859
+ * - user_template - The templated used for when a user is logged in. Defalts to "user-panel.php".
860
+ * - show_title - True to display the current title, false to hide. Defaults to true.
861
+ * - show_log_link - True to display the login link, false to hide. Defaults to true.
862
+ * - show_reg_link - True to display the register link, false to hide. Defaults to true.
863
+ * - show_pass_link - True to display the lost password link, false to hide. Defaults to true.
864
+ * - logged_in_widget - True to display the widget when logged in, false to hide. Defaults to true.
865
+ * - logged_out_widget - True to display the widget when logged out, false to hide. Defaults to true.
866
+ * - show_gravatar - True to display the user's gravatar, false to hide. Defaults to true.
867
+ * - gravatar_size - The size of the user's gravatar. Defaults to "50".
868
+ *
869
+ * @since 6.0
870
+ * @access public
871
+ *
872
+ * @param string|array $atts Attributes passed from the shortcode
873
+ * @return string HTML output from Theme_My_Login_Template->display()
874
+ */
875
+ public function shortcode( $atts = '' ) {
876
+ static $did_main_instance = false;
877
+
878
+ $atts = wp_parse_args( $atts );
879
+
880
+ if ( self::is_tml_page() && in_the_loop() && is_main_query() && ! $did_main_instance ) {
881
+ $instance = $this->get_instance();
882
+
883
+ if ( ! empty( $this->request_instance ) )
884
+ $instance->set_active( false );
885
+
886
+ if ( ! empty( $this->request_action ) )
887
+ $atts['default_action'] = $this->request_action;
888
+
889
+ if ( ! isset( $atts['show_title'] ) )
890
+ $atts['show_title'] = false;
891
+
892
+ foreach ( $atts as $option => $value ) {
893
+ $instance->set_option( $option, $value );
894
+ }
895
+
896
+ $did_main_instance = true;
897
+ } else {
898
+ $instance = $this->load_instance( $atts );
899
+ }
900
+ return $instance->display();
901
+ }
902
+
903
+ /**
904
+ * Determines if $action is for $page
905
+ *
906
+ * @since 6.3
907
+ *
908
+ * @param array|string $action An action or array of actions to check
909
+ * @param int|object Post ID or object
910
+ * @return bool True if $action is for $page, false otherwise
911
+ */
912
+ public static function is_tml_page( $action = '', $page = '' ) {
913
+ if ( ! $page = get_post( $page ) )
914
+ return false;
915
+
916
+ if ( 'page' != $page->post_type )
917
+ return false;
918
+
919
+ if ( ! $page_action = self::get_page_action( $page->ID ) )
920
+ return false;
921
+
922
+ if ( empty( $action ) )
923
+ return true;
924
+
925
+ if ( in_array( $page_action, (array) $action ) )
926
+ return true;
927
+
928
+ return false;
929
+ }
930
+
931
+ /**
932
+ * Returns link for a login page
933
+ *
934
+ * @since 6.3
935
+ * @access public
936
+ *
937
+ * @param string $action The action
938
+ * @param string|array $query Optional. Query arguments to add to link
939
+ * @return string Login page link with optional $query arguments appended
940
+ */
941
+ public static function get_page_link( $action, $query = '' ) {
942
+ $page_id = self::get_page_id( $action );
943
+
944
+ if ( $page_id ) {
945
+ $link = get_permalink( $page_id );
946
+ } elseif ( $page_id = self::get_page_id( 'login' ) ) {
947
+ $link = add_query_arg( 'action', $action, get_permalink( $page_id ) );
948
+ } else {
949
+ // Remove site_url filter so we can use wp-login.php
950
+ remove_filter( 'site_url', array( self::get_object(), 'site_url' ), 10, 3 );
951
+
952
+ $link = site_url( "wp-login.php?action=$action" );
953
+ }
954
+
955
+ if ( ! empty( $query ) ) {
956
+ $args = wp_parse_args( $query );
957
+
958
+ if ( isset( $args['action'] ) && $action == $args['action'] )
959
+ unset( $args['action'] );
960
+
961
+ $link = add_query_arg( array_map( 'rawurlencode', $args ), $link );
962
+ }
963
+
964
+ $link = set_url_scheme( $link, 'login' );
965
+
966
+ return apply_filters( 'tml_page_link', $link, $action, $query );
967
+ }
968
+
969
+ /**
970
+ * Retrieves a page ID for an action
971
+ *
972
+ * @since 6.3
973
+ *
974
+ * @param string $action The action
975
+ * @return int|bool The page ID if exists, false otherwise
976
+ */
977
+ public static function get_page_id( $action ) {
978
+ global $wpdb;
979
+
980
+ if ( 'rp' == $action )
981
+ $action = 'resetpass';
982
+ elseif ( 'retrievepassword' == $action )
983
+ $action = 'lostpassword';
984
+
985
+ if ( ! $page_id = wp_cache_get( $action, 'tml_page_ids' ) ) {
986
+ $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT p.ID FROM $wpdb->posts p LEFT JOIN $wpdb->postmeta pmeta ON p.ID = pmeta.post_id WHERE p.post_type = 'page' AND pmeta.meta_key = '_tml_action' AND pmeta.meta_value = %s", $action ) );
987
+ if ( ! $page_id )
988
+ return null;
989
+ wp_cache_add( $action, $page_id, 'tml_page_ids' );
990
+ }
991
+ return apply_filters( 'tml_page_id', $page_id, $action );
992
+ }
993
+
994
+ /**
995
+ * Get the action for a page
996
+ *
997
+ * @since 6.3
998
+ *
999
+ * @param int|object Post ID or object
1000
+ * @return string|bool Action name if exists, false otherwise
1001
+ */
1002
+ public static function get_page_action( $page ) {
1003
+ if ( ! $page = get_post( $page ) )
1004
+ return false;
1005
+
1006
+ return get_post_meta( $page->ID, '_tml_action', true );
1007
+ }
1008
+
1009
+ /**
1010
+ * Enqueues the specified sylesheet
1011
+ *
1012
+ * First looks in theme/template directories for the stylesheet, falling back to plugin directory
1013
+ *
1014
+ * @since 6.0
1015
+ * @access public
1016
+ *
1017
+ * @param string $file Filename of stylesheet to load
1018
+ * @return string Path to stylesheet
1019
+ */
1020
+ public static function get_stylesheet( $file = 'theme-my-login.css' ) {
1021
+ if ( file_exists( get_stylesheet_directory() . '/' . $file ) )
1022
+ $stylesheet = get_stylesheet_directory_uri() . '/' . $file;
1023
+ elseif ( file_exists( get_template_directory() . '/' . $file ) )
1024
+ $stylesheet = get_template_directory_uri() . '/' . $file;
1025
+ else
1026
+ $stylesheet = plugins_url( $file, dirname( __FILE__ ) );
1027
+ return $stylesheet;
1028
+ }
1029
+
1030
+ /**
1031
+ * Retrieves active instance object
1032
+ *
1033
+ * @since 6.3
1034
+ * @access public
1035
+ *
1036
+ * @return object Instance object
1037
+ */
1038
+ public function get_active_instance() {
1039
+ return $this->get_instance( (int) $this->request_instance );
1040
+ }
1041
+
1042
+ /**
1043
+ * Retrieves a loaded instance object
1044
+ *
1045
+ * @since 6.3
1046
+ * @access public
1047
+ *
1048
+ * @param int $id Instance ID
1049
+ * @return object Instance object
1050
+
1051
+ */
1052
+ public function get_instance( $id = 0 ) {
1053
+ if ( isset( $this->loaded_instances[$id] ) )
1054
+ return $this->loaded_instances[$id];
1055
+ }
1056
+
1057
+ /**
1058
+ * Sets an instance object
1059
+ *
1060
+ * @since 6.3
1061
+ * @access public
1062
+ *
1063
+ * @param object $object Instance object
1064
+ */
1065
+ public function set_instance( $object ) {
1066
+ $this->loaded_instances[] = $object;
1067
+ }
1068
+
1069
+ /**
1070
+ * Instantiates an instance
1071
+ *
1072
+ * @since 6.3
1073
+ * @access public
1074
+ *
1075
+ * @param array|string $args Array or query string of arguments
1076
+
1077
+ * @return object Instance object
1078
+ */
1079
+ public function load_instance( $args = '' ) {
1080
+
1081
+ $instance = new Theme_My_Login_Template( $args );
1082
+ $instance->set_option( 'instance', count( $this->loaded_instances ) );
1083
+
1084
+ if ( $instance->get_option( 'instance' ) === $this->request_instance ) {
1085
+ $instance->set_active();
1086
+ $instance->set_option( 'default_action', $this->request_action );
1087
+ }
1088
+
1089
+ $this->loaded_instances[] = $instance;
1090
+
1091
+ return $instance;
1092
+ }
1093
+
1094
+ /**
1095
+ * Load a custom translation file for current language if available.
1096
+ *
1097
+ * Note that custom translation files inside the plugin folder
1098
+ * will be removed on plugin updates. If you're creating custom
1099
+ * translation files, please place them in a '/theme-my-login/'
1100
+ * directory within the global language folder.
1101
+ *
1102
+ * @since 6.4.4
1103
+ *
1104
+ * @param string $domain The domain for which a language file is being loaded.
1105
+ * @param string $mofile Full path to the target mofile.
1106
+ */
1107
+ public function load_custom_textdomain( $domain, $mofile ) {
1108
+ if ( 'theme-my-login' === $domain ) {
1109
+ remove_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1110
+
1111
+ // Look in global /wp-content/languages/theme-my-login folder for a translation
1112
+ // and load it if available.
1113
+ $mofile = basename( $mofile );
1114
+ if ( file_exists( WP_LANG_DIR . '/theme-my-login/' . $mofile ) ) {
1115
+ load_textdomain( 'theme-my-login', WP_LANG_DIR . '/theme-my-login/' . $mofile );
1116
+ }
1117
+
1118
+ add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1119
+ }
1120
+ }
1121
+
1122
+ /**
1123
+ * Handles sending password retrieval email to user.
1124
+ *
1125
+ * @since 6.0
1126
+ * @access public
1127
+ * @uses $wpdb WordPress Database object
1128
+ *
1129
+ * @return bool|WP_Error True: when finish. WP_Error on error
1130
+ */
1131
+ public static function retrieve_password() {
1132
+ global $wpdb, $wp_hasher;
1133
+
1134
+ $errors = new WP_Error();
1135
+
1136
+ if ( empty( $_POST['user_login'] ) ) {
1137
+ $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or e-mail address.', 'theme-my-login' ) );
1138
+ } else if ( strpos( $_POST['user_login'], '@' ) ) {
1139
+ $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
1140
+ if ( empty( $user_data ) )
1141
+ $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no user registered with that email address.', 'theme-my-login' ) );
1142
+ } else {
1143
+ $login = trim( $_POST['user_login'] );
1144
+ $user_data = get_user_by( 'login', $login );
1145
+ }
1146
+
1147
+ do_action( 'lostpassword_post', $errors );
1148
+
1149
+ if ( $errors->get_error_code() )
1150
+ return $errors;
1151
+
1152
+ if ( ! $user_data ) {
1153
+ $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: Invalid username or e-mail.', 'theme-my-login' ) );
1154
+ return $errors;
1155
+ }
1156
+
1157
+ // redefining user_login ensures we return the right case in the email
1158
+ $user_login = $user_data->user_login;
1159
+ $user_email = $user_data->user_email;
1160
+ $key = get_password_reset_key( $user_data );
1161
+
1162
+ if ( is_wp_error( $key ) ) {
1163
+ return $key;
1164
+ }
1165
+
1166
+ $message = __( 'Someone requested that the password be reset for the following account:', 'theme-my-login' ) . "\r\n\r\n";
1167
+ $message .= network_home_url( '/' ) . "\r\n\r\n";
1168
+ $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n\r\n";
1169
+ $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'theme-my-login' ) . "\r\n\r\n";
1170
+ $message .= __( 'To reset your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
1171
+ $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n";
1172
+
1173
+ if ( is_multisite() ) {
1174
+ $blogname = $GLOBALS['current_site']->site_name;
1175
+ } else {
1176
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
1177
+ // we want to reverse this for the plain text arena of emails.
1178
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1179
+ }
1180
+
1181
+ $title = sprintf( __( '[%s] Password Reset', 'theme-my-login' ), $blogname );
1182
+
1183
+ $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
1184
+ $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
1185
+
1186
+ if ( $message && ! wp_mail( $user_email, $title, $message ) )
1187
+ wp_die( __( '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' ) );
1188
+
1189
+ return true;
1190
+ }
1191
+ }
1192
+ endif; // Class exists
1193
+
languages/theme-my-login.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Theme My Login package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Theme My Login 6.4.x\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/theme-my-login\n"
7
- "POT-Creation-Date: 2016-05-21 23:51:25+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -325,7 +325,7 @@ msgstr ""
325
  msgid "A login form for your blog."
326
  msgstr ""
327
 
328
- #. #-#-#-#-# plugin.pot (Theme My Login 6.4.4) #-#-#-#-#
329
  #. Plugin Name of the plugin/theme
330
  #: includes/class-theme-my-login-widget.php:26
331
  msgid "Theme My Login"
@@ -451,10 +451,10 @@ msgid "Someone requested that the password be reset for the following account:"
451
  msgstr ""
452
 
453
  #: includes/class-theme-my-login.php:1168
454
- #: modules/custom-email/custom-email.php:841
455
- #: modules/custom-email/custom-email.php:870
456
  #: modules/user-moderation/admin/user-moderation-admin.php:382
457
- #: modules/user-moderation/user-moderation.php:460
458
  msgid "Username: %s"
459
  msgstr ""
460
 
@@ -702,33 +702,33 @@ msgstr ""
702
  msgid "Disable Notification"
703
  msgstr ""
704
 
705
- #: modules/custom-email/custom-email.php:840
706
  msgid "New user registration on your site %s:"
707
  msgstr ""
708
 
709
- #: modules/custom-email/custom-email.php:842
710
- #: modules/user-moderation/user-moderation.php:461
711
  msgid "E-mail: %s"
712
  msgstr ""
713
 
714
- #: modules/custom-email/custom-email.php:844
715
  msgid "[%s] New User Registration"
716
  msgstr ""
717
 
718
- #: modules/custom-email/custom-email.php:871
719
  #: modules/user-moderation/admin/user-moderation-admin.php:383
720
  msgid "To set your password, visit the following address:"
721
  msgstr ""
722
 
723
- #: modules/custom-email/custom-email.php:876
724
  msgid "[%s] Your username and password info"
725
  msgstr ""
726
 
727
- #: modules/custom-email/custom-email.php:904
728
  msgid "[%s] Password Lost/Changed"
729
  msgstr ""
730
 
731
- #: modules/custom-email/custom-email.php:905
732
  msgid "Password Lost and Changed for user: %s"
733
  msgstr ""
734
 
@@ -898,17 +898,17 @@ msgctxt "recaptcha theme"
898
  msgid "Dark"
899
  msgstr ""
900
 
901
- #: modules/recaptcha/recaptcha.php:108
902
  msgid "<strong>ERROR</strong>: Invalid reCAPTCHA secret key."
903
  msgstr ""
904
 
905
- #: modules/recaptcha/recaptcha.php:112
906
  msgid ""
907
  "<strong>ERROR</strong>: Please check the box to prove that you are not a "
908
  "robot."
909
  msgstr ""
910
 
911
- #: modules/recaptcha/recaptcha.php:116
912
  msgid "<strong>ERROR</strong>: Unable to reach the reCAPTCHA server."
913
  msgstr ""
914
 
@@ -988,9 +988,9 @@ msgstr ""
988
 
989
  #: modules/security/security.php:185 modules/security/security.php:188
990
  #: modules/security/security.php:191 modules/security/security.php:194
991
- #: modules/user-moderation/user-moderation.php:344
992
- #: modules/user-moderation/user-moderation.php:347
993
- #: modules/user-moderation/user-moderation.php:352
994
  msgid "Invalid key"
995
  msgstr ""
996
 
@@ -1145,72 +1145,72 @@ msgstr ""
1145
  msgid "[%s] Registration Denied"
1146
  msgstr ""
1147
 
1148
- #: modules/user-moderation/user-moderation.php:157
1149
  msgid ""
1150
  "<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a "
1151
  "href=\"%s\">Resend activation</a>?"
1152
  msgstr ""
1153
 
1154
- #: modules/user-moderation/user-moderation.php:161
1155
  msgid "<strong>ERROR</strong>: Your registration has not yet been approved."
1156
  msgstr ""
1157
 
1158
- #: modules/user-moderation/user-moderation.php:200
1159
  msgid ""
1160
  "Your registration was successful but you must now confirm your email address "
1161
  "before you can log in. Please check your email and click on the link "
1162
  "provided."
1163
  msgstr ""
1164
 
1165
- #: modules/user-moderation/user-moderation.php:203
1166
  msgid ""
1167
  "Your registration was successful but you must now be approved by an "
1168
  "administrator before you can log in. You will be notified by e-mail once "
1169
  "your account has been reviewed."
1170
  msgstr ""
1171
 
1172
- #: modules/user-moderation/user-moderation.php:212
1173
  msgid "Your account has been activated. You may now log in."
1174
  msgstr ""
1175
 
1176
- #: modules/user-moderation/user-moderation.php:214
1177
  msgid ""
1178
  "Your account has been activated. Please check your e-mail for your password."
1179
  msgstr ""
1180
 
1181
- #: modules/user-moderation/user-moderation.php:217
1182
  msgid "<strong>ERROR</strong>: Sorry, that key does not appear to be valid."
1183
  msgstr ""
1184
 
1185
- #: modules/user-moderation/user-moderation.php:225
1186
  msgid "<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent."
1187
  msgstr ""
1188
 
1189
- #: modules/user-moderation/user-moderation.php:228
1190
  msgid ""
1191
  "The activation e-mail has been sent to the e-mail address with which you "
1192
  "registered. Please check your email and click on the link provided."
1193
  msgstr ""
1194
 
1195
- #: modules/user-moderation/user-moderation.php:420
1196
  msgid "[%s] Activate Your Account"
1197
  msgstr ""
1198
 
1199
- #: modules/user-moderation/user-moderation.php:421
1200
  msgid ""
1201
  "Thanks for registering at %s! To complete the activation of your account "
1202
  "please click the following link: "
1203
  msgstr ""
1204
 
1205
- #: modules/user-moderation/user-moderation.php:457
1206
  msgid "[%s] New User Awaiting Approval"
1207
  msgstr ""
1208
 
1209
- #: modules/user-moderation/user-moderation.php:459
1210
  msgid "New user requires approval on your blog %s:"
1211
  msgstr ""
1212
 
1213
- #: modules/user-moderation/user-moderation.php:462
1214
  msgid "To approve or deny this user:"
1215
  msgstr ""
1216
 
2
  # This file is distributed under the same license as the Theme My Login package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Theme My Login 6.4.6\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/theme-my-login\n"
7
+ "POT-Creation-Date: 2016-10-22 19:06:57+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
325
  msgid "A login form for your blog."
326
  msgstr ""
327
 
328
+ #. #-#-#-#-# plugin.pot (Theme My Login 6.4.6) #-#-#-#-#
329
  #. Plugin Name of the plugin/theme
330
  #: includes/class-theme-my-login-widget.php:26
331
  msgid "Theme My Login"
451
  msgstr ""
452
 
453
  #: includes/class-theme-my-login.php:1168
454
+ #: modules/custom-email/custom-email.php:843
455
+ #: modules/custom-email/custom-email.php:872
456
  #: modules/user-moderation/admin/user-moderation-admin.php:382
457
+ #: modules/user-moderation/user-moderation.php:462
458
  msgid "Username: %s"
459
  msgstr ""
460
 
702
  msgid "Disable Notification"
703
  msgstr ""
704
 
705
+ #: modules/custom-email/custom-email.php:842
706
  msgid "New user registration on your site %s:"
707
  msgstr ""
708
 
709
+ #: modules/custom-email/custom-email.php:844
710
+ #: modules/user-moderation/user-moderation.php:463
711
  msgid "E-mail: %s"
712
  msgstr ""
713
 
714
+ #: modules/custom-email/custom-email.php:846
715
  msgid "[%s] New User Registration"
716
  msgstr ""
717
 
718
+ #: modules/custom-email/custom-email.php:873
719
  #: modules/user-moderation/admin/user-moderation-admin.php:383
720
  msgid "To set your password, visit the following address:"
721
  msgstr ""
722
 
723
+ #: modules/custom-email/custom-email.php:878
724
  msgid "[%s] Your username and password info"
725
  msgstr ""
726
 
727
+ #: modules/custom-email/custom-email.php:906
728
  msgid "[%s] Password Lost/Changed"
729
  msgstr ""
730
 
731
+ #: modules/custom-email/custom-email.php:907
732
  msgid "Password Lost and Changed for user: %s"
733
  msgstr ""
734
 
898
  msgid "Dark"
899
  msgstr ""
900
 
901
+ #: modules/recaptcha/recaptcha.php:110
902
  msgid "<strong>ERROR</strong>: Invalid reCAPTCHA secret key."
903
  msgstr ""
904
 
905
+ #: modules/recaptcha/recaptcha.php:114
906
  msgid ""
907
  "<strong>ERROR</strong>: Please check the box to prove that you are not a "
908
  "robot."
909
  msgstr ""
910
 
911
+ #: modules/recaptcha/recaptcha.php:118
912
  msgid "<strong>ERROR</strong>: Unable to reach the reCAPTCHA server."
913
  msgstr ""
914
 
988
 
989
  #: modules/security/security.php:185 modules/security/security.php:188
990
  #: modules/security/security.php:191 modules/security/security.php:194
991
+ #: modules/user-moderation/user-moderation.php:346
992
+ #: modules/user-moderation/user-moderation.php:349
993
+ #: modules/user-moderation/user-moderation.php:354
994
  msgid "Invalid key"
995
  msgstr ""
996
 
1145
  msgid "[%s] Registration Denied"
1146
  msgstr ""
1147
 
1148
+ #: modules/user-moderation/user-moderation.php:159
1149
  msgid ""
1150
  "<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a "
1151
  "href=\"%s\">Resend activation</a>?"
1152
  msgstr ""
1153
 
1154
+ #: modules/user-moderation/user-moderation.php:163
1155
  msgid "<strong>ERROR</strong>: Your registration has not yet been approved."
1156
  msgstr ""
1157
 
1158
+ #: modules/user-moderation/user-moderation.php:202
1159
  msgid ""
1160
  "Your registration was successful but you must now confirm your email address "
1161
  "before you can log in. Please check your email and click on the link "
1162
  "provided."
1163
  msgstr ""
1164
 
1165
+ #: modules/user-moderation/user-moderation.php:205
1166
  msgid ""
1167
  "Your registration was successful but you must now be approved by an "
1168
  "administrator before you can log in. You will be notified by e-mail once "
1169
  "your account has been reviewed."
1170
  msgstr ""
1171
 
1172
+ #: modules/user-moderation/user-moderation.php:214
1173
  msgid "Your account has been activated. You may now log in."
1174
  msgstr ""
1175
 
1176
+ #: modules/user-moderation/user-moderation.php:216
1177
  msgid ""
1178
  "Your account has been activated. Please check your e-mail for your password."
1179
  msgstr ""
1180
 
1181
+ #: modules/user-moderation/user-moderation.php:219
1182
  msgid "<strong>ERROR</strong>: Sorry, that key does not appear to be valid."
1183
  msgstr ""
1184
 
1185
+ #: modules/user-moderation/user-moderation.php:227
1186
  msgid "<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent."
1187
  msgstr ""
1188
 
1189
+ #: modules/user-moderation/user-moderation.php:230
1190
  msgid ""
1191
  "The activation e-mail has been sent to the e-mail address with which you "
1192
  "registered. Please check your email and click on the link provided."
1193
  msgstr ""
1194
 
1195
+ #: modules/user-moderation/user-moderation.php:422
1196
  msgid "[%s] Activate Your Account"
1197
  msgstr ""
1198
 
1199
+ #: modules/user-moderation/user-moderation.php:423
1200
  msgid ""
1201
  "Thanks for registering at %s! To complete the activation of your account "
1202
  "please click the following link: "
1203
  msgstr ""
1204
 
1205
+ #: modules/user-moderation/user-moderation.php:459
1206
  msgid "[%s] New User Awaiting Approval"
1207
  msgstr ""
1208
 
1209
+ #: modules/user-moderation/user-moderation.php:461
1210
  msgid "New user requires approval on your blog %s:"
1211
  msgstr ""
1212
 
1213
+ #: modules/user-moderation/user-moderation.php:464
1214
  msgid "To approve or deny this user:"
1215
  msgstr ""
1216
 
modules/custom-email/admin/custom-email-admin.php CHANGED
@@ -1,613 +1,613 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Custom E-mail Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Custom_Email
7
- * @since 6.0
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Custom_Email_Admin' ) ) :
11
- /**
12
- * Theme My Login Custom E-mail Admin class
13
- *
14
- * @since 6.0
15
- */
16
- class Theme_My_Login_Custom_Email_Admin extends Theme_My_Login_Abstract {
17
- /**
18
- * Holds options key
19
- *
20
- * @since 6.3
21
- * @access protected
22
- * @var string
23
- */
24
- protected $options_key = 'theme_my_login_email';
25
-
26
- /**
27
- * Returns singleton instance
28
- *
29
- * @since 6.3
30
- * @access public
31
- * @return object
32
- */
33
- public static function get_object( $class = null ) {
34
- return parent::get_object( __CLASS__ );
35
- }
36
-
37
- /**
38
- * Loads the module
39
- *
40
- * Called by Theme_My_Login_Abstract::__construct()
41
- *
42
- * @see Theme_My_Login_Abstract::__construct()
43
- * @since 6.0
44
- * @access protected
45
- */
46
- protected function load() {
47
- add_action( 'tml_uninstall_custom-email/custom-email.php', array( $this, 'uninstall' ) );
48
-
49
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
50
- add_action( 'admin_init', array( $this, 'admin_init' ) );
51
-
52
- add_action( 'load-tml_page_theme_my_login_email', array( $this, 'load_settings_page' ) );
53
- }
54
-
55
- /**
56
- * Returns default options
57
- *
58
- * @since 6.3
59
- * @access public
60
- */
61
- public static function default_options() {
62
- return Theme_My_Login_Custom_Email::default_options();
63
- }
64
-
65
- /**
66
- * Uninstalls the module
67
- *
68
- * Callback for "tml_uninstall_custom-email/custom-email.php" hook in method Theme_My_Login_Admin::uninstall()
69
- *
70
- * @see Theme_My_Login_Admin::uninstall()
71
- * @since 6.3
72
- * @access public
73
- */
74
- public function uninstall() {
75
- delete_option( $this->options_key );
76
- }
77
-
78
- /**
79
- * Adds "E-mail" to the Theme My Login menu
80
- *
81
- * Callback for "admin_menu" hook
82
- *
83
- * @since 6.0
84
- * @access public
85
- */
86
- public function admin_menu() {
87
-
88
- add_submenu_page(
89
- 'theme_my_login',
90
- __( 'Theme My Login Custom E-mail Settings', 'theme-my-login' ),
91
- __( 'E-mail', 'theme-my-login' ),
92
- 'manage_options',
93
- $this->options_key,
94
- array( $this, 'settings_page' )
95
- );
96
-
97
- add_meta_box( 'new_user', __( 'New User', 'theme-my-login' ), array( $this, 'new_user_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
98
- add_meta_box( 'new_user_admin', __( 'New User Admin', 'theme-my-login' ), array( $this, 'new_user_admin_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
99
- add_meta_box( 'retrieve_pass', __( 'Retrieve Password', 'theme-my-login' ), array( $this, 'retrieve_pass_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
100
- add_meta_box( 'reset_pass', __( 'Reset Password', 'theme-my-login' ), array( $this, 'reset_pass_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
101
-
102
- // Check for User Moderation module
103
- if ( class_exists( 'Theme_My_Login_User_Moderation' ) ) {
104
- add_meta_box( 'user_activation', __( 'User Activation', 'theme-my-login' ), array( $this, 'user_activation_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
105
- add_meta_box( 'user_approval', __( 'User Approval', 'theme-my-login' ), array( $this, 'user_approval_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
106
- add_meta_box( 'user_approval_admin', __( 'User Approval Admin', 'theme-my-login'), array( $this, 'user_approval_admin_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
107
- add_meta_box( 'user_denial', __( 'User Denial', 'theme-my-login' ), array( $this, 'user_denial_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
108
- }
109
- }
110
-
111
- /**
112
- * Registers options group
113
- *
114
- * Callback for "admin_init" hook
115
- *
116
- * @since 6.3
117
- * @access public
118
- */
119
- public function admin_init() {
120
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
121
- }
122
-
123
- /**
124
- * Loads admin styles and scripts
125
- *
126
- * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
127
- *
128
- * @since 6.0
129
- * @access public
130
- */
131
- public function load_settings_page() {
132
- wp_enqueue_script( 'tml-custom-email-admin', plugins_url( 'js/custom-email-admin.js', __FILE__ ), array( 'postbox' ) );
133
- }
134
-
135
- /**
136
- * Renders settings page
137
- *
138
- * Callback for add_submenu_page()
139
- *
140
- * @since 6.3
141
- * @access public
142
- */
143
- public function settings_page() {
144
- global $current_screen;
145
- ?>
146
- <div class="wrap">
147
- <h2><?php esc_html_e( 'Theme My Login Custom E-mail Settings', 'theme-my-login' ); ?></h2>
148
- <?php settings_errors(); ?>
149
-
150
- <form method="post" action="options.php">
151
- <?php
152
- settings_fields( $this->options_key );
153
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
154
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
155
- ?>
156
- <div id="<?php echo $this->options_key; ?>" class="metabox-holder">
157
- <?php do_meta_boxes( $current_screen->id, 'normal', null ); ?>
158
- </div>
159
- <?php submit_button(); ?>
160
- </form>
161
- </div>
162
- <?php
163
- }
164
-
165
- /**
166
- * Renders New User Notification settings section
167
- *
168
- * This is the callback for add_meta_box()
169
- *
170
- * @since 6.3
171
- * @access public
172
- */
173
- public function new_user_meta_box() {
174
- ?>
175
- <p class="description">
176
- <?php _e( 'This e-mail will be sent to a new user upon registration.', 'theme-my-login' ); ?>
177
- <?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' ); ?>
178
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
179
- </p>
180
- <table class="form-table">
181
- <tr valign="top">
182
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
183
- <td><input name="<?php echo $this->options_key; ?>[new_user][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_new_user_mail_from_name" value="<?php echo $this->get_option( array( 'new_user', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
184
- </tr>
185
- <tr valign="top">
186
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
187
- <td><input name="<?php echo $this->options_key; ?>[new_user][mail_from]" type="text" id="<?php echo $this->options_key; ?>_new_user_mail_from" value="<?php echo $this->get_option( array( 'new_user', 'mail_from' ) ); ?>" class="regular-text" /></td>
188
- </tr>
189
- <tr valign="top">
190
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
191
- <td>
192
- <select name="<?php echo $this->options_key; ?>[new_user][mail_content_type]" id="<?php echo $this->options_key; ?>_new_user_mail_content_type">
193
- <option value="plain"<?php selected( $this->get_option( array( 'new_user', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
194
- <option value="html"<?php selected( $this->get_option( array( 'new_user', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
195
- </select>
196
- </td>
197
- </tr>
198
- <tr valign="top">
199
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
200
- <td><input name="<?php echo $this->options_key; ?>[new_user][title]" type="text" id="<?php echo $this->options_key; ?>_new_user_title" value="<?php echo $this->get_option( array( 'new_user', 'title' ) ); ?>" class="large-text" /></td>
201
- </tr>
202
- <tr valign="top">
203
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
204
- <td>
205
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</p>
206
- <textarea name="<?php echo $this->options_key; ?>[new_user][message]" id="<?php echo $this->options_key; ?>_new_user_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'new_user', 'message' ) ); ?></textarea></p>
207
- </td>
208
- </tr>
209
- </table>
210
- <?php
211
- }
212
-
213
- /**
214
- * Renders New User Admin Notification settings section
215
- *
216
- * This is the callback for add_meta_box()
217
- *
218
- * @since 6.3
219
- * @access public
220
- */
221
- public function new_user_admin_meta_box() {
222
- ?>
223
- <p class="description">
224
- <?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.', 'theme-my-login' ); ?>
225
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
226
- </p>
227
- <table class="form-table">
228
- <tr valign="top">
229
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
230
- <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_to" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
231
- </tr>
232
- <tr valign="top">
233
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
234
- <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_from_name" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
235
- </tr>
236
- <tr valign="top">
237
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
238
- <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_from" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
239
- </tr>
240
- <tr valign="top">
241
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
242
- <td>
243
- <select name="<?php echo $this->options_key; ?>[new_user][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_new_user_admin_mail_content_type">
244
- <option value="plain"<?php selected( $this->get_option( array( 'new_user', 'admin_mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
245
- <option value="html"<?php selected( $this->get_option( array( 'new_user', 'admin_mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
246
- </select>
247
- </td>
248
- <tr valign="top">
249
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
250
- <td><input name="<?php echo $this->options_key; ?>[new_user][admin_title]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_title" value="<?php echo $this->get_option( array( 'new_user', 'admin_title' ) ); ?>" class="large-text" /></td>
251
- </tr>
252
- <tr valign="top">
253
- <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
254
- <td>
255
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
256
- <textarea name="<?php echo $this->options_key; ?>[new_user][admin_message]" id="<?php echo $this->options_key; ?>_new_user_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'new_user', 'admin_message' ) ); ?></textarea>
257
- </td>
258
- </tr>
259
- <tr valign="top">
260
- <th scope="row">&nbsp;</th>
261
- <td>
262
- <input name="<?php echo $this->options_key; ?>[new_user][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_new_user_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'new_user', 'admin_disable' ) ) ); ?> />
263
- <label for="<?php echo $this->options_key; ?>_new_user_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
264
- </td>
265
- </tr>
266
- </table>
267
- <?php
268
- }
269
-
270
- /**
271
- * Renders Retrieve Password settings section
272
- *
273
- * This is the callback for add_meta_box()
274
- *
275
- * @since 6.3
276
- * @access public
277
- */
278
- public function retrieve_pass_meta_box() {
279
- ?>
280
- <p class="description">
281
- <?php _e( 'This e-mail will be sent to a user when they attempt to recover their password.', 'theme-my-login' ); ?>
282
- <?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' ); ?>
283
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
284
- </p>
285
- <table class="form-table">
286
- <tr valign="top">
287
- <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
288
- <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_from_name" value="<?php echo $this->get_option( array( 'retrieve_pass', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
289
- </tr>
290
- <tr valign="top">
291
- <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
292
- <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][mail_from]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_from" value="<?php echo $this->get_option( array( 'retrieve_pass', 'mail_from' ) ); ?>" class="regular-text" /></td>
293
- </tr>
294
- <tr valign="top">
295
- <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
296
- <td>
297
- <select name="<?php echo $this->options_key; ?>[retrieve_pass][mail_content_type]" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_content_type">
298
- <option value="plain"<?php selected( $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
299
- <option value="html"<?php selected( $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
300
- </select>
301
- </td>
302
- </tr>
303
- <tr valign="top">
304
- <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
305
- <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][title]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_title" value="<?php echo $this->get_option( array( 'retrieve_pass', 'title' ) ); ?>" class="large-text" /></td>
306
- </tr>
307
- <tr valign="top">
308
- <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
309
- <td>
310
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</p>
311
- <textarea name="<?php echo $this->options_key; ?>[retrieve_pass][message]" id="<?php echo $this->options_key; ?>_retrieve_pass_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'retrieve_pass', 'message' ) ); ?></textarea>
312
- </td>
313
- </tr>
314
- </table>
315
- <?php
316
- }
317
-
318
- /**
319
- * Renders Reset Password settings section
320
- *
321
- * This is the callback for add_meta_box()
322
- *
323
- * @since 6.3
324
- * @access public
325
- */
326
- public function reset_pass_meta_box() {
327
- ?>
328
- <p class="description">
329
- <?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.', 'theme-my-login' ); ?>
330
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
331
- </p>
332
- <table class="form-table">
333
- <tr valign="top">
334
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
335
- <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_to" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
336
- </tr>
337
- <tr valign="top">
338
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
339
- <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from_name" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
340
- </tr>
341
- <tr valign="top">
342
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
343
- <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
344
- </tr>
345
- <tr valign="top">
346
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
347
- <td>
348
- <select name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_content_type">
349
- <option value="plain"<?php selected( $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
350
- <option value="html"<?php selected( $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
351
- </select>
352
- </td>
353
- </tr>
354
- <tr valign="top">
355
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
356
- <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_title]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_title" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_title' ) ); ?>" class="large-text" /></td>
357
- </tr>
358
- <tr valign="top">
359
- <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
360
- <td>
361
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
362
- <textarea name="<?php echo $this->options_key; ?>[reset_pass][admin_message]" id="<?php echo $this->options_key; ?>_reset_pass_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'reset_pass', 'admin_message' ) ); ?></textarea>
363
- </td>
364
- </tr>
365
- <tr valign="top">
366
- <th scope="row">&nbsp;</th>
367
- <td>
368
- <input name="<?php echo $this->options_key; ?>[reset_pass][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_reset_pass_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'reset_pass', 'admin_disable' ) ) ); ?> />
369
- <label for="<?php echo $this->options_key; ?>_reset_pass_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
370
- </td>
371
- </tr>
372
- </table>
373
- <?php
374
- }
375
-
376
- /**
377
- * Renders User Activation settings section
378
- *
379
- * This is the callback for add_meta_box()
380
- *
381
- * @since 6.3
382
- * @access public
383
- */
384
- public function user_activation_meta_box() {
385
- ?>
386
- <p class="description">
387
- <?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' ); ?>
388
- <?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' ); ?>
389
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
390
- </p>
391
- <table class="form-table">
392
- <tr valign="top">
393
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
394
- <td><input name="<?php echo $this->options_key; ?>[user_activation][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_activation_mail_from_name" value="<?php echo $this->get_option( array( 'user_activation', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
395
- </tr>
396
- <tr valign="top">
397
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
398
- <td><input name="<?php echo $this->options_key; ?>[user_activation][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_activation_mail_from" value="<?php echo $this->get_option( array( 'user_activation', 'mail_from' ) ); ?>" class="regular-text" /></td>
399
- </tr>
400
- <tr valign="top">
401
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
402
- <td>
403
- <select name="<?php echo $this->options_key; ?>[user_activation][mail_content_type]" id="<?php echo $this->options_key; ?>_user_activation_mail_content_type">
404
- <option value="plain"<?php selected( $this->get_option( array( 'user_activation', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
405
- <option value="html"<?php selected( $this->get_option( array( 'user_activation', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
406
- </select>
407
- </td>
408
- </tr>
409
- <tr valign="top">
410
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
411
- <td><input name="<?php echo $this->options_key; ?>[user_activation][title]" type="text" id="<?php echo $this->options_key; ?>_user_activation_title" value="<?php echo $this->get_option( array( 'user_activation', 'title' ) ); ?>" class="large-text" /></td>
412
- </tr>
413
- <tr valign="top">
414
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
415
- <td>
416
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %activateurl%, %user_login%, %user_email%, %user_ip%</p>
417
- <textarea name="<?php echo $this->options_key; ?>[user_activation][message]" id="<?php echo $this->options_key; ?>_user_activation_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_activation', 'message' ) ); ?></textarea>
418
- </td>
419
- </tr>
420
- </table>
421
- <?php
422
- }
423
-
424
- /**
425
- * Renders User Approval settings section
426
- *
427
- * This is the callback for add_meta_box()
428
- *
429
- * @since 6.3
430
- * @access public
431
- */
432
- public function user_approval_meta_box() {
433
- ?>
434
- <p class="description">
435
- <?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' ); ?>
436
- <?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' ); ?>
437
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
438
- </p>
439
- <table class="form-table">
440
- <tr valign="top">
441
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
442
- <td><input name="<?php echo $this->options_key; ?>[user_approval][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_approval_mail_from_name" value="<?php echo $this->get_option( array( 'user_approval', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
443
- </tr>
444
- <tr valign="top">
445
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
446
- <td><input name="<?php echo $this->options_key; ?>[user_approval][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_approval_mail_from" value="<?php echo $this->get_option( array( 'user_approval', 'mail_from' ) ); ?>" class="regular-text" /></td>
447
- </tr>
448
- <tr valign="top">
449
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
450
- <td>
451
- <select name="<?php echo $this->options_key; ?>[user_approval][mail_content_type]" id="<?php echo $this->options_key; ?>_user_approval_mail_content_type">
452
- <option value="plain"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
453
- <option value="html"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
454
- </select>
455
- </td>
456
- </tr>
457
- <tr valign="top">
458
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
459
- <td><input name="<?php echo $this->options_key; ?>[user_approval][title]" type="text" id="<?php echo $this->options_key; ?>_user_approval_title" value="<?php echo $this->get_option( array( 'user_approval', 'title' ) ); ?>" class="large-text" /></td>
460
- </tr>
461
- <tr valign="top">
462
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
463
- <td>
464
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %loginurl%, %user_login%, %user_email%</p>
465
- <textarea name="<?php echo $this->options_key; ?>[user_approval][message]" id="<?php echo $this->options_key; ?>_user_approval_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_approval', 'message' ) ); ?></textarea></td>
466
- </td>
467
- </tr>
468
- </table>
469
- <?php
470
- }
471
-
472
- /**
473
- * Renders User Approval Admin settings section
474
- *
475
- * This is the callback for add_meta_box()
476
- *
477
- * @since 6.3
478
- * @access public
479
- */
480
- public function user_approval_admin_meta_box() {
481
- ?>
482
- <p class="description">
483
- <?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' ); ?>
484
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
485
- </p>
486
- <table class="form-table">
487
- <tr valign="top">
488
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
489
- <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_to" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
490
- </tr>
491
- <tr valign="top">
492
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
493
- <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_from_name" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
494
- </tr>
495
- <tr valign="top">
496
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
497
- <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_from" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
498
- </tr>
499
- <tr valign="top">
500
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
501
- <td>
502
- <select name="<?php echo $this->options_key; ?>[user_approval][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_content_type">
503
- <option value="plain"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
504
- <option value="html"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
505
- </select>
506
- </td>
507
- </tr>
508
- <tr valign="top">
509
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
510
- <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_title]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_title" value="<?php echo $this->get_option( array( 'user_approval', 'admin_title' ) ); ?>" class="large-text" /></td>
511
- </tr>
512
- <tr valign="top">
513
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
514
- <td>
515
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %pendingurl%, %user_login%, %user_email%, %user_ip%</p>
516
- <textarea name="<?php echo $this->options_key; ?>[user_approval][admin_message]" id="<?php echo $this->options_key; ?>_user_approval_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_approval', 'admin_message' ) ); ?></textarea></td>
517
- </td>
518
- </tr>
519
- <tr valign="top">
520
- <th scope="row">&nbsp;</th>
521
- <td>
522
- <input name="<?php echo $this->options_key; ?>[user_approval][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_user_approval_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'user_approval', 'admin_disable' ) ) ); ?> />
523
- <label for="<?php echo $this->options_key; ?>_user_approval_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
524
- </td>
525
- </tr>
526
- </table>
527
- <?php
528
- }
529
-
530
- /**
531
- * Renders User Denial settings section
532
- *
533
- * This is the callback for add_meta_box()
534
- *
535
- * @since 6.3
536
- * @access public
537
- */
538
- public function user_denial_meta_box() {
539
- ?>
540
- <p class="description">
541
- <?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' ); ?>
542
- <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
543
- </p>
544
- <table class="form-table">
545
- <tr valign="top">
546
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
547
- <td><input name="<?php echo $this->options_key; ?>[user_denial][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_denial_mail_from_name" value="<?php echo $this->get_option( array( 'user_denial', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
548
- </tr>
549
- <tr valign="top">
550
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
551
- <td><input name="<?php echo $this->options_key; ?>[user_denial][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_denial_mail_from" value="<?php echo $this->get_option( array( 'user_denial', 'mail_from' ) ); ?>" class="regular-text" /></td>
552
- </tr>
553
- <tr valign="top">
554
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
555
- <td>
556
- <select name="<?php echo $this->options_key; ?>[user_denial][mail_content_type]" id="<?php echo $this->options_key; ?>_user_denial_mail_content_type">
557
- <option value="plain"<?php selected( $this->get_option( array( 'user_denial', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
558
- <option value="html"<?php selected( $this->get_option( array( 'user_denial', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
559
- </select>
560
- </td>
561
- </tr>
562
- <tr valign="top">
563
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_title"><?php _e('Subject', 'theme-my-login'); ?></label></th>
564
- <td><input name="<?php echo $this->options_key; ?>[user_denial][title]" type="text" id="<?php echo $this->options_key; ?>_user_denial_title" value="<?php echo $this->get_option( array( 'user_denial', 'title' ) ); ?>" class="large-text" /></td>
565
- </tr>
566
- <tr valign="top">
567
- <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_message"><?php _e('Message', 'theme-my-login'); ?></label></th>
568
- <td>
569
- <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%</p>
570
- <textarea name="<?php echo $this->options_key; ?>[user_denial][message]" id="<?php echo $this->options_key; ?>_user_denial_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_denial', 'message' ) ); ?></textarea>
571
- </td>
572
- </tr>
573
- <tr valign="top">
574
- <th scope="row">&nbsp;</th>
575
- <td>
576
- <input name="<?php echo $this->options_key; ?>[user_denial][disable]" type="checkbox" id="<?php echo $this->options_key; ?>_user_denial_disable" value="1"<?php checked( 1, $this->get_option( array( 'user_denial', 'disable' ) ) ); ?> />
577
- <label for="<?php echo $this->options_key; ?>_user_denial_disable"><?php _e( 'Disable Notification', 'theme-my-login' ); ?></label>
578
- </td>
579
- </tr>
580
- </table>
581
- <?php
582
- }
583
-
584
- /**
585
- * Sanitizes settings
586
- *
587
- * Callback for register_setting()
588
- *
589
- * @since 6.0
590
- * @access public
591
- *
592
- * @param string|array $settings Settings passed in from filter
593
- * @return string|array Sanitized settings
594
- */
595
- public function save_settings( $settings ) {
596
- $settings['new_user']['admin_disable'] = isset( $settings['new_user']['admin_disable'] ) ? (bool) $settings['new_user']['admin_disable'] : false;
597
- $settings['reset_pass']['admin_disable'] = isset( $settings['reset_pass']['admin_disable'] ) ? (bool) $settings['reset_pass']['admin_disable'] : false;
598
-
599
- if ( class_exists( 'Theme_My_Login_User_Moderation' ) ) {
600
- $settings['user_approval']['admin_disable'] = isset( $settings['user_approval']['admin_disable'] ) ? (bool) $settings['user_approval']['admin_disable'] : false;
601
- $settings['user_denial']['disable'] = isset( $settings['user_denial']['disable'] ) ? (bool) $settings['user_denial']['admin_disable'] : false;
602
- }
603
-
604
- $settings = Theme_My_Login_Common::array_merge_recursive( $this->get_options(), $settings );
605
-
606
- return $settings;
607
- }
608
- }
609
-
610
- Theme_My_Login_Custom_Email_Admin::get_object();
611
-
612
- endif;
613
-
1
+ <?php
2
+ /**
3
+ * Holds Theme My Login Custom E-mail Admin class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @subpackage Theme_My_Login_Custom_Email
7
+ * @since 6.0
8
+ */
9
+
10
+ if ( ! class_exists( 'Theme_My_Login_Custom_Email_Admin' ) ) :
11
+ /**
12
+ * Theme My Login Custom E-mail Admin class
13
+ *
14
+ * @since 6.0
15
+ */
16
+ class Theme_My_Login_Custom_Email_Admin extends Theme_My_Login_Abstract {
17
+ /**
18
+ * Holds options key
19
+ *
20
+ * @since 6.3
21
+ * @access protected
22
+ * @var string
23
+ */
24
+ protected $options_key = 'theme_my_login_email';
25
+
26
+ /**
27
+ * Returns singleton instance
28
+ *
29
+ * @since 6.3
30
+ * @access public
31
+ * @return object
32
+ */
33
+ public static function get_object( $class = null ) {
34
+ return parent::get_object( __CLASS__ );
35
+ }
36
+
37
+ /**
38
+ * Loads the module
39
+ *
40
+ * Called by Theme_My_Login_Abstract::__construct()
41
+ *
42
+ * @see Theme_My_Login_Abstract::__construct()
43
+ * @since 6.0
44
+ * @access protected
45
+ */
46
+ protected function load() {
47
+ add_action( 'tml_uninstall_custom-email/custom-email.php', array( $this, 'uninstall' ) );
48
+
49
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
50
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
51
+
52
+ add_action( 'load-tml_page_theme_my_login_email', array( $this, 'load_settings_page' ) );
53
+ }
54
+
55
+ /**
56
+ * Returns default options
57
+ *
58
+ * @since 6.3
59
+ * @access public
60
+ */
61
+ public static function default_options() {
62
+ return Theme_My_Login_Custom_Email::default_options();
63
+ }
64
+
65
+ /**
66
+ * Uninstalls the module
67
+ *
68
+ * Callback for "tml_uninstall_custom-email/custom-email.php" hook in method Theme_My_Login_Admin::uninstall()
69
+ *
70
+ * @see Theme_My_Login_Admin::uninstall()
71
+ * @since 6.3
72
+ * @access public
73
+ */
74
+ public function uninstall() {
75
+ delete_option( $this->options_key );
76
+ }
77
+
78
+ /**
79
+ * Adds "E-mail" to the Theme My Login menu
80
+ *
81
+ * Callback for "admin_menu" hook
82
+ *
83
+ * @since 6.0
84
+ * @access public
85
+ */
86
+ public function admin_menu() {
87
+
88
+ add_submenu_page(
89
+ 'theme_my_login',
90
+ __( 'Theme My Login Custom E-mail Settings', 'theme-my-login' ),
91
+ __( 'E-mail', 'theme-my-login' ),
92
+ 'manage_options',
93
+ $this->options_key,
94
+ array( $this, 'settings_page' )
95
+ );
96
+
97
+ add_meta_box( 'new_user', __( 'New User', 'theme-my-login' ), array( $this, 'new_user_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
98
+ add_meta_box( 'new_user_admin', __( 'New User Admin', 'theme-my-login' ), array( $this, 'new_user_admin_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
99
+ add_meta_box( 'retrieve_pass', __( 'Retrieve Password', 'theme-my-login' ), array( $this, 'retrieve_pass_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
100
+ add_meta_box( 'reset_pass', __( 'Reset Password', 'theme-my-login' ), array( $this, 'reset_pass_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
101
+
102
+ // Check for User Moderation module
103
+ if ( class_exists( 'Theme_My_Login_User_Moderation' ) ) {
104
+ add_meta_box( 'user_activation', __( 'User Activation', 'theme-my-login' ), array( $this, 'user_activation_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
105
+ add_meta_box( 'user_approval', __( 'User Approval', 'theme-my-login' ), array( $this, 'user_approval_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
106
+ add_meta_box( 'user_approval_admin', __( 'User Approval Admin', 'theme-my-login'), array( $this, 'user_approval_admin_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
107
+ add_meta_box( 'user_denial', __( 'User Denial', 'theme-my-login' ), array( $this, 'user_denial_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Registers options group
113
+ *
114
+ * Callback for "admin_init" hook
115
+ *
116
+ * @since 6.3
117
+ * @access public
118
+ */
119
+ public function admin_init() {
120
+ register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
121
+ }
122
+
123
+ /**
124
+ * Loads admin styles and scripts
125
+ *
126
+ * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
127
+ *
128
+ * @since 6.0
129
+ * @access public
130
+ */
131
+ public function load_settings_page() {
132
+ wp_enqueue_script( 'tml-custom-email-admin', plugins_url( 'js/custom-email-admin.js', __FILE__ ), array( 'postbox' ) );
133
+ }
134
+
135
+ /**
136
+ * Renders settings page
137
+ *
138
+ * Callback for add_submenu_page()
139
+ *
140
+ * @since 6.3
141
+ * @access public
142
+ */
143
+ public function settings_page() {
144
+ global $current_screen;
145
+ ?>
146
+ <div class="wrap">
147
+ <h2><?php esc_html_e( 'Theme My Login Custom E-mail Settings', 'theme-my-login' ); ?></h2>
148
+ <?php settings_errors(); ?>
149
+
150
+ <form method="post" action="options.php">
151
+ <?php
152
+ settings_fields( $this->options_key );
153
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
154
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
155
+ ?>
156
+ <div id="<?php echo $this->options_key; ?>" class="metabox-holder">
157
+ <?php do_meta_boxes( $current_screen->id, 'normal', null ); ?>
158
+ </div>
159
+ <?php submit_button(); ?>
160
+ </form>
161
+ </div>
162
+ <?php
163
+ }
164
+
165
+ /**
166
+ * Renders New User Notification settings section
167
+ *
168
+ * This is the callback for add_meta_box()
169
+ *
170
+ * @since 6.3
171
+ * @access public
172
+ */
173
+ public function new_user_meta_box() {
174
+ ?>
175
+ <p class="description">
176
+ <?php _e( 'This e-mail will be sent to a new user upon registration.', 'theme-my-login' ); ?>
177
+ <?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' ); ?>
178
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
179
+ </p>
180
+ <table class="form-table">
181
+ <tr valign="top">
182
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
183
+ <td><input name="<?php echo $this->options_key; ?>[new_user][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_new_user_mail_from_name" value="<?php echo $this->get_option( array( 'new_user', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
184
+ </tr>
185
+ <tr valign="top">
186
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
187
+ <td><input name="<?php echo $this->options_key; ?>[new_user][mail_from]" type="text" id="<?php echo $this->options_key; ?>_new_user_mail_from" value="<?php echo $this->get_option( array( 'new_user', 'mail_from' ) ); ?>" class="regular-text" /></td>
188
+ </tr>
189
+ <tr valign="top">
190
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
191
+ <td>
192
+ <select name="<?php echo $this->options_key; ?>[new_user][mail_content_type]" id="<?php echo $this->options_key; ?>_new_user_mail_content_type">
193
+ <option value="plain"<?php selected( $this->get_option( array( 'new_user', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
194
+ <option value="html"<?php selected( $this->get_option( array( 'new_user', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
195
+ </select>
196
+ </td>
197
+ </tr>
198
+ <tr valign="top">
199
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
200
+ <td><input name="<?php echo $this->options_key; ?>[new_user][title]" type="text" id="<?php echo $this->options_key; ?>_new_user_title" value="<?php echo $this->get_option( array( 'new_user', 'title' ) ); ?>" class="large-text" /></td>
201
+ </tr>
202
+ <tr valign="top">
203
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
204
+ <td>
205
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</p>
206
+ <textarea name="<?php echo $this->options_key; ?>[new_user][message]" id="<?php echo $this->options_key; ?>_new_user_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'new_user', 'message' ) ); ?></textarea></p>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ <?php
211
+ }
212
+
213
+ /**
214
+ * Renders New User Admin Notification settings section
215
+ *
216
+ * This is the callback for add_meta_box()
217
+ *
218
+ * @since 6.3
219
+ * @access public
220
+ */
221
+ public function new_user_admin_meta_box() {
222
+ ?>
223
+ <p class="description">
224
+ <?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.', 'theme-my-login' ); ?>
225
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
226
+ </p>
227
+ <table class="form-table">
228
+ <tr valign="top">
229
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
230
+ <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_to" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
231
+ </tr>
232
+ <tr valign="top">
233
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
234
+ <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_from_name" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
235
+ </tr>
236
+ <tr valign="top">
237
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
238
+ <td><input name="<?php echo $this->options_key; ?>[new_user][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_mail_from" value="<?php echo $this->get_option( array( 'new_user', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
239
+ </tr>
240
+ <tr valign="top">
241
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
242
+ <td>
243
+ <select name="<?php echo $this->options_key; ?>[new_user][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_new_user_admin_mail_content_type">
244
+ <option value="plain"<?php selected( $this->get_option( array( 'new_user', 'admin_mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
245
+ <option value="html"<?php selected( $this->get_option( array( 'new_user', 'admin_mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
246
+ </select>
247
+ </td>
248
+ <tr valign="top">
249
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
250
+ <td><input name="<?php echo $this->options_key; ?>[new_user][admin_title]" type="text" id="<?php echo $this->options_key; ?>_new_user_admin_title" value="<?php echo $this->get_option( array( 'new_user', 'admin_title' ) ); ?>" class="large-text" /></td>
251
+ </tr>
252
+ <tr valign="top">
253
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_new_user_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
254
+ <td>
255
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
256
+ <textarea name="<?php echo $this->options_key; ?>[new_user][admin_message]" id="<?php echo $this->options_key; ?>_new_user_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'new_user', 'admin_message' ) ); ?></textarea>
257
+ </td>
258
+ </tr>
259
+ <tr valign="top">
260
+ <th scope="row">&nbsp;</th>
261
+ <td>
262
+ <input name="<?php echo $this->options_key; ?>[new_user][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_new_user_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'new_user', 'admin_disable' ) ) ); ?> />
263
+ <label for="<?php echo $this->options_key; ?>_new_user_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
264
+ </td>
265
+ </tr>
266
+ </table>
267
+ <?php
268
+ }
269
+
270
+ /**
271
+ * Renders Retrieve Password settings section
272
+ *
273
+ * This is the callback for add_meta_box()
274
+ *
275
+ * @since 6.3
276
+ * @access public
277
+ */
278
+ public function retrieve_pass_meta_box() {
279
+ ?>
280
+ <p class="description">
281
+ <?php _e( 'This e-mail will be sent to a user when they attempt to recover their password.', 'theme-my-login' ); ?>
282
+ <?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' ); ?>
283
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
284
+ </p>
285
+ <table class="form-table">
286
+ <tr valign="top">
287
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
288
+ <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_from_name" value="<?php echo $this->get_option( array( 'retrieve_pass', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
289
+ </tr>
290
+ <tr valign="top">
291
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
292
+ <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][mail_from]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_from" value="<?php echo $this->get_option( array( 'retrieve_pass', 'mail_from' ) ); ?>" class="regular-text" /></td>
293
+ </tr>
294
+ <tr valign="top">
295
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
296
+ <td>
297
+ <select name="<?php echo $this->options_key; ?>[retrieve_pass][mail_content_type]" id="<?php echo $this->options_key; ?>_retrieve_pass_mail_content_type">
298
+ <option value="plain"<?php selected( $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
299
+ <option value="html"<?php selected( $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
300
+ </select>
301
+ </td>
302
+ </tr>
303
+ <tr valign="top">
304
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
305
+ <td><input name="<?php echo $this->options_key; ?>[retrieve_pass][title]" type="text" id="<?php echo $this->options_key; ?>_retrieve_pass_title" value="<?php echo $this->get_option( array( 'retrieve_pass', 'title' ) ); ?>" class="large-text" /></td>
306
+ </tr>
307
+ <tr valign="top">
308
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_retrieve_pass_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
309
+ <td>
310
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %user_login%, %user_email%, %user_ip%</p>
311
+ <textarea name="<?php echo $this->options_key; ?>[retrieve_pass][message]" id="<?php echo $this->options_key; ?>_retrieve_pass_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'retrieve_pass', 'message' ) ); ?></textarea>
312
+ </td>
313
+ </tr>
314
+ </table>
315
+ <?php
316
+ }
317
+
318
+ /**
319
+ * Renders Reset Password settings section
320
+ *
321
+ * This is the callback for add_meta_box()
322
+ *
323
+ * @since 6.3
324
+ * @access public
325
+ */
326
+ public function reset_pass_meta_box() {
327
+ ?>
328
+ <p class="description">
329
+ <?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.', 'theme-my-login' ); ?>
330
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
331
+ </p>
332
+ <table class="form-table">
333
+ <tr valign="top">
334
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
335
+ <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_to" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
336
+ </tr>
337
+ <tr valign="top">
338
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
339
+ <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from_name" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
340
+ </tr>
341
+ <tr valign="top">
342
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
343
+ <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_from" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
344
+ </tr>
345
+ <tr valign="top">
346
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
347
+ <td>
348
+ <select name="<?php echo $this->options_key; ?>[reset_pass][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_reset_pass_admin_mail_content_type">
349
+ <option value="plain"<?php selected( $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
350
+ <option value="html"<?php selected( $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
351
+ </select>
352
+ </td>
353
+ </tr>
354
+ <tr valign="top">
355
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
356
+ <td><input name="<?php echo $this->options_key; ?>[reset_pass][admin_title]" type="text" id="<?php echo $this->options_key; ?>_reset_pass_admin_title" value="<?php echo $this->get_option( array( 'reset_pass', 'admin_title' ) ); ?>" class="large-text" /></td>
357
+ </tr>
358
+ <tr valign="top">
359
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_reset_pass_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
360
+ <td>
361
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%, %user_ip%</p>
362
+ <textarea name="<?php echo $this->options_key; ?>[reset_pass][admin_message]" id="<?php echo $this->options_key; ?>_reset_pass_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'reset_pass', 'admin_message' ) ); ?></textarea>
363
+ </td>
364
+ </tr>
365
+ <tr valign="top">
366
+ <th scope="row">&nbsp;</th>
367
+ <td>
368
+ <input name="<?php echo $this->options_key; ?>[reset_pass][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_reset_pass_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'reset_pass', 'admin_disable' ) ) ); ?> />
369
+ <label for="<?php echo $this->options_key; ?>_reset_pass_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
370
+ </td>
371
+ </tr>
372
+ </table>
373
+ <?php
374
+ }
375
+
376
+ /**
377
+ * Renders User Activation settings section
378
+ *
379
+ * This is the callback for add_meta_box()
380
+ *
381
+ * @since 6.3
382
+ * @access public
383
+ */
384
+ public function user_activation_meta_box() {
385
+ ?>
386
+ <p class="description">
387
+ <?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' ); ?>
388
+ <?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' ); ?>
389
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
390
+ </p>
391
+ <table class="form-table">
392
+ <tr valign="top">
393
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
394
+ <td><input name="<?php echo $this->options_key; ?>[user_activation][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_activation_mail_from_name" value="<?php echo $this->get_option( array( 'user_activation', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
395
+ </tr>
396
+ <tr valign="top">
397
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
398
+ <td><input name="<?php echo $this->options_key; ?>[user_activation][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_activation_mail_from" value="<?php echo $this->get_option( array( 'user_activation', 'mail_from' ) ); ?>" class="regular-text" /></td>
399
+ </tr>
400
+ <tr valign="top">
401
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
402
+ <td>
403
+ <select name="<?php echo $this->options_key; ?>[user_activation][mail_content_type]" id="<?php echo $this->options_key; ?>_user_activation_mail_content_type">
404
+ <option value="plain"<?php selected( $this->get_option( array( 'user_activation', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
405
+ <option value="html"<?php selected( $this->get_option( array( 'user_activation', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
406
+ </select>
407
+ </td>
408
+ </tr>
409
+ <tr valign="top">
410
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
411
+ <td><input name="<?php echo $this->options_key; ?>[user_activation][title]" type="text" id="<?php echo $this->options_key; ?>_user_activation_title" value="<?php echo $this->get_option( array( 'user_activation', 'title' ) ); ?>" class="large-text" /></td>
412
+ </tr>
413
+ <tr valign="top">
414
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_activation_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
415
+ <td>
416
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %activateurl%, %user_login%, %user_email%, %user_ip%</p>
417
+ <textarea name="<?php echo $this->options_key; ?>[user_activation][message]" id="<?php echo $this->options_key; ?>_user_activation_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_activation', 'message' ) ); ?></textarea>
418
+ </td>
419
+ </tr>
420
+ </table>
421
+ <?php
422
+ }
423
+
424
+ /**
425
+ * Renders User Approval settings section
426
+ *
427
+ * This is the callback for add_meta_box()
428
+ *
429
+ * @since 6.3
430
+ * @access public
431
+ */
432
+ public function user_approval_meta_box() {
433
+ ?>
434
+ <p class="description">
435
+ <?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' ); ?>
436
+ <?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' ); ?>
437
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
438
+ </p>
439
+ <table class="form-table">
440
+ <tr valign="top">
441
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
442
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_approval_mail_from_name" value="<?php echo $this->get_option( array( 'user_approval', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
443
+ </tr>
444
+ <tr valign="top">
445
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
446
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_approval_mail_from" value="<?php echo $this->get_option( array( 'user_approval', 'mail_from' ) ); ?>" class="regular-text" /></td>
447
+ </tr>
448
+ <tr valign="top">
449
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
450
+ <td>
451
+ <select name="<?php echo $this->options_key; ?>[user_approval][mail_content_type]" id="<?php echo $this->options_key; ?>_user_approval_mail_content_type">
452
+ <option value="plain"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
453
+ <option value="html"<?php selected( $this->get_option( array( 'user_approval', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
454
+ </select>
455
+ </td>
456
+ </tr>
457
+ <tr valign="top">
458
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
459
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][title]" type="text" id="<?php echo $this->options_key; ?>_user_approval_title" value="<?php echo $this->get_option( array( 'user_approval', 'title' ) ); ?>" class="large-text" /></td>
460
+ </tr>
461
+ <tr valign="top">
462
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
463
+ <td>
464
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %reseturl%, %loginurl%, %user_login%, %user_email%</p>
465
+ <textarea name="<?php echo $this->options_key; ?>[user_approval][message]" id="<?php echo $this->options_key; ?>_user_approval_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_approval', 'message' ) ); ?></textarea></td>
466
+ </td>
467
+ </tr>
468
+ </table>
469
+ <?php
470
+ }
471
+
472
+ /**
473
+ * Renders User Approval Admin settings section
474
+ *
475
+ * This is the callback for add_meta_box()
476
+ *
477
+ * @since 6.3
478
+ * @access public
479
+ */
480
+ public function user_approval_admin_meta_box() {
481
+ ?>
482
+ <p class="description">
483
+ <?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' ); ?>
484
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
485
+ </p>
486
+ <table class="form-table">
487
+ <tr valign="top">
488
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_to"><?php _e( 'To', 'theme-my-login' ); ?></label></th>
489
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_to]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_to" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_to' ) ); ?>" class="regular-text" /></td>
490
+ </tr>
491
+ <tr valign="top">
492
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
493
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_from_name" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_from_name' ) ); ?>" class="regular-text" /></td>
494
+ </tr>
495
+ <tr valign="top">
496
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
497
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_from" value="<?php echo $this->get_option( array( 'user_approval', 'admin_mail_from' ) ); ?>" class="regular-text" /></td>
498
+ </tr>
499
+ <tr valign="top">
500
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
501
+ <td>
502
+ <select name="<?php echo $this->options_key; ?>[user_approval][admin_mail_content_type]" id="<?php echo $this->options_key; ?>_user_approval_admin_mail_content_type">
503
+ <option value="plain"<?php selected( $this->get_option( array( 'user_approval', 'admin_mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
504
+ <option value="html"<?php selected( $this->get_option( array( 'user_approval', 'admin_mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
505
+ </select>
506
+ </td>
507
+ </tr>
508
+ <tr valign="top">
509
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_title"><?php _e( 'Subject', 'theme-my-login' ); ?></label></th>
510
+ <td><input name="<?php echo $this->options_key; ?>[user_approval][admin_title]" type="text" id="<?php echo $this->options_key; ?>_user_approval_admin_title" value="<?php echo $this->get_option( array( 'user_approval', 'admin_title' ) ); ?>" class="large-text" /></td>
511
+ </tr>
512
+ <tr valign="top">
513
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_approval_admin_message"><?php _e( 'Message', 'theme-my-login' ); ?></label></th>
514
+ <td>
515
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %pendingurl%, %user_login%, %user_email%, %user_ip%</p>
516
+ <textarea name="<?php echo $this->options_key; ?>[user_approval][admin_message]" id="<?php echo $this->options_key; ?>_user_approval_admin_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_approval', 'admin_message' ) ); ?></textarea></td>
517
+ </td>
518
+ </tr>
519
+ <tr valign="top">
520
+ <th scope="row">&nbsp;</th>
521
+ <td>
522
+ <input name="<?php echo $this->options_key; ?>[user_approval][admin_disable]" type="checkbox" id="<?php echo $this->options_key; ?>_user_approval_admin_disable" value="1"<?php checked( 1, $this->get_option( array( 'user_approval', 'admin_disable' ) ) ); ?> />
523
+ <label for="<?php echo $this->options_key; ?>_user_approval_admin_disable"><?php _e( 'Disable Admin Notification', 'theme-my-login' ); ?></label>
524
+ </td>
525
+ </tr>
526
+ </table>
527
+ <?php
528
+ }
529
+
530
+ /**
531
+ * Renders User Denial settings section
532
+ *
533
+ * This is the callback for add_meta_box()
534
+ *
535
+ * @since 6.3
536
+ * @access public
537
+ */
538
+ public function user_denial_meta_box() {
539
+ ?>
540
+ <p class="description">
541
+ <?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' ); ?>
542
+ <?php _e( 'If any field is left empty, the default will be used instead.', 'theme-my-login' ); ?>
543
+ </p>
544
+ <table class="form-table">
545
+ <tr valign="top">
546
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_from_name"><?php _e( 'From Name', 'theme-my-login' ); ?></label></th>
547
+ <td><input name="<?php echo $this->options_key; ?>[user_denial][mail_from_name]" type="text" id="<?php echo $this->options_key; ?>_user_denial_mail_from_name" value="<?php echo $this->get_option( array( 'user_denial', 'mail_from_name' ) ); ?>" class="regular-text" /></td>
548
+ </tr>
549
+ <tr valign="top">
550
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_from"><?php _e( 'From E-mail', 'theme-my-login' ); ?></label></th>
551
+ <td><input name="<?php echo $this->options_key; ?>[user_denial][mail_from]" type="text" id="<?php echo $this->options_key; ?>_user_denial_mail_from" value="<?php echo $this->get_option( array( 'user_denial', 'mail_from' ) ); ?>" class="regular-text" /></td>
552
+ </tr>
553
+ <tr valign="top">
554
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_mail_content_type"><?php _e( 'E-mail Format', 'theme-my-login' ); ?></label></th>
555
+ <td>
556
+ <select name="<?php echo $this->options_key; ?>[user_denial][mail_content_type]" id="<?php echo $this->options_key; ?>_user_denial_mail_content_type">
557
+ <option value="plain"<?php selected( $this->get_option( array( 'user_denial', 'mail_content_type' ) ), 'plain' ); ?>><?php _e( 'Plain Text', 'theme-my-login' ); ?></option>
558
+ <option value="html"<?php selected( $this->get_option( array( 'user_denial', 'mail_content_type' ) ), 'html' ); ?>><?php _e( 'HTML', 'theme-my-login' ); ?></option>
559
+ </select>
560
+ </td>
561
+ </tr>
562
+ <tr valign="top">
563
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_title"><?php _e('Subject', 'theme-my-login'); ?></label></th>
564
+ <td><input name="<?php echo $this->options_key; ?>[user_denial][title]" type="text" id="<?php echo $this->options_key; ?>_user_denial_title" value="<?php echo $this->get_option( array( 'user_denial', 'title' ) ); ?>" class="large-text" /></td>
565
+ </tr>
566
+ <tr valign="top">
567
+ <th scope="row"><label for="<?php echo $this->options_key; ?>_user_denial_message"><?php _e('Message', 'theme-my-login'); ?></label></th>
568
+ <td>
569
+ <p class="description"><?php _e( 'Available Variables', 'theme-my-login' ); ?>: %blogname%, %siteurl%, %user_login%, %user_email%</p>
570
+ <textarea name="<?php echo $this->options_key; ?>[user_denial][message]" id="<?php echo $this->options_key; ?>_user_denial_message" class="large-text" rows="10"><?php echo $this->get_option( array( 'user_denial', 'message' ) ); ?></textarea>
571
+ </td>
572
+ </tr>
573
+ <tr valign="top">
574
+ <th scope="row">&nbsp;</th>
575
+ <td>
576
+ <input name="<?php echo $this->options_key; ?>[user_denial][disable]" type="checkbox" id="<?php echo $this->options_key; ?>_user_denial_disable" value="1"<?php checked( 1, $this->get_option( array( 'user_denial', 'disable' ) ) ); ?> />
577
+ <label for="<?php echo $this->options_key; ?>_user_denial_disable"><?php _e( 'Disable Notification', 'theme-my-login' ); ?></label>
578
+ </td>
579
+ </tr>
580
+ </table>
581
+ <?php
582
+ }
583
+
584
+ /**
585
+ * Sanitizes settings
586
+ *
587
+ * Callback for register_setting()
588
+ *
589
+ * @since 6.0
590
+ * @access public
591
+ *
592
+ * @param string|array $settings Settings passed in from filter
593
+ * @return string|array Sanitized settings
594
+ */
595
+ public function save_settings( $settings ) {
596
+ $settings['new_user']['admin_disable'] = isset( $settings['new_user']['admin_disable'] ) ? (bool) $settings['new_user']['admin_disable'] : false;
597
+ $settings['reset_pass']['admin_disable'] = isset( $settings['reset_pass']['admin_disable'] ) ? (bool) $settings['reset_pass']['admin_disable'] : false;
598
+
599
+ if ( class_exists( 'Theme_My_Login_User_Moderation' ) ) {
600
+ $settings['user_approval']['admin_disable'] = isset( $settings['user_approval']['admin_disable'] ) ? (bool) $settings['user_approval']['admin_disable'] : false;
601
+ $settings['user_denial']['disable'] = isset( $settings['user_denial']['disable'] ) ? (bool) $settings['user_denial']['disable'] : false;
602
+ }
603
+
604
+ $settings = Theme_My_Login_Common::array_merge_recursive( $this->get_options(), $settings );
605
+
606
+ return $settings;
607
+ }
608
+ }
609
+
610
+ Theme_My_Login_Custom_Email_Admin::get_object();
611
+
612
+ endif;
613
+
modules/custom-email/custom-email.php CHANGED
@@ -1,921 +1,938 @@
1
- <?php
2
- /*
3
- * 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
- * Holds Theme My Login Custom E-mail class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Custom_Email
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Custom_Email' ) ) :
14
- /**
15
- * Theme My Login Custom E-mail class
16
- *
17
- * @since 6.0
18
- */
19
- class Theme_My_Login_Custom_Email extends Theme_My_Login_Abstract {
20
- /**
21
- * Holds options key
22
- *
23
- * @since 6.3
24
- * @access protected
25
- * @var string
26
- */
27
- protected $options_key = 'theme_my_login_email';
28
-
29
- /**
30
- * Mail from
31
- *
32
- * @since 6.0
33
- * @access protected
34
- * @var string
35
- */
36
- protected $mail_from;
37
-
38
- /**
39
- * Mail from name
40
- *
41
- * @since 6.0
42
- * @access protected
43
- * @var string
44
- */
45
- protected $mail_from_name;
46
-
47
- /**
48
- * Mail content type
49
- *
50
- * @since 6.0
51
- * @access protected
52
- * @var string
53
- */
54
- protected $mail_content_type;
55
-
56
- /**
57
- * Returns singleton instance
58
- *
59
- * @since 6.3
60
- * @access public
61
- * @return object
62
- */
63
- public static function get_object( $class = null ) {
64
- return parent::get_object( __CLASS__ );
65
- }
66
-
67
- /**
68
- * Returns default options
69
- *
70
- * @since 6.3
71
- * @access public
72
- */
73
- public static function default_options() {
74
- return array(
75
- 'new_user' => array(
76
- 'mail_from' => '',
77
- 'mail_from_name' => '',
78
- 'mail_content_type' => '',
79
- 'title' => '',
80
- 'message' => '',
81
- 'admin_mail_to' => '',
82
- 'admin_mail_from' => '',
83
- 'admin_mail_from_name' => '',
84
- 'admin_mail_content_type' => '',
85
- 'admin_title' => '',
86
- 'admin_message' => ''
87
- ),
88
- 'retrieve_pass' => array(
89
- 'mail_from' => '',
90
- 'mail_from_name' => '',
91
- 'mail_content_type' => '',
92
- 'title' => '',
93
- 'message' => ''
94
- ),
95
- 'reset_pass' => array(
96
- 'admin_mail_to' => '',
97
- 'admin_mail_from' => '',
98
- 'admin_mail_from_name' => '',
99
- 'admin_mail_content_type' => '',
100
- 'admin_title' => '',
101
- 'admin_message' => ''
102
- )
103
- );
104
- }
105
-
106
- /**
107
- * Loads the module
108
- *
109
- * @since 6.0
110
- * @access protected
111
- */
112
- protected function load() {
113
- add_filter( 'wp_mail_from', array( $this, 'mail_from_filter' ) );
114
- add_filter( 'wp_mail_from_name', array( $this, 'mail_from_name_filter' ) );
115
- add_filter( 'wp_mail_content_type', array( $this, 'mail_content_type_filter' ) );
116
-
117
- add_action( 'retrieve_password', array( $this, 'apply_retrieve_pass_filters' ) );
118
- add_action( 'password_reset', array( $this, 'apply_password_reset_filters' ) );
119
- add_action( 'tml_new_user_notification', array( $this, 'apply_new_user_filters' ) );
120
-
121
- remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
122
- remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );
123
- remove_action( 'after_password_reset', 'wp_password_change_notification' );
124
-
125
- add_action( 'register_new_user', array( $this, 'new_user_notification' ) );
126
- add_action( 'edit_user_created_user', array( $this, 'new_user_notification' ), 10, 2 );
127
- add_action( 'after_password_reset', array( $this, 'password_change_notification' ) );
128
-
129
- add_action( 'register_post', array( $this, 'apply_user_moderation_notification_filters' ) );
130
- add_action( 'tml_user_activation_resend', array( $this, 'apply_user_moderation_notification_filters' ) );
131
- add_action( 'approve_user', array( $this, 'apply_user_approval_notification_filters' ) );
132
- add_action( 'deny_user', array( $this, 'apply_user_denial_notification_filters' ) );
133
- }
134
-
135
- /**
136
- * Sets variables to be used with mail header filters
137
- *
138
- * @since 6.0
139
- * @access public
140
- *
141
- * @param string $mail_from E-mail address to send the mail from
142
- * @param string $mail_from_name Name to send the mail from
143
- * @param string $mail_content_type Content type for the message
144
- */
145
- public function set_mail_headers( $mail_from = '', $mail_from_name = '', $mail_content_type = 'text' ) {
146
- $this->mail_from = $mail_from;
147
- $this->mail_from_name = $mail_from_name;
148
- $this->mail_content_type = $mail_content_type;
149
- }
150
-
151
- /**
152
- * Applies all password retrieval mail filters
153
- *
154
- * Callback for "retrieve_password" hook in Theme_My_Login::retrieve_password()
155
- *
156
- * @see Theme_My_Login::retrieve_password()
157
- * @since 6.0
158
- * @access public
159
- */
160
- public function apply_retrieve_pass_filters() {
161
- $this->set_mail_headers(
162
- $this->get_option( array( 'retrieve_pass', 'mail_from' ) ),
163
- $this->get_option( array( 'retrieve_pass', 'mail_from_name' ) ),
164
- $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) )
165
- );
166
- add_filter( 'retrieve_password_title', array( $this, 'retrieve_pass_title_filter' ), 10, 3 );
167
- add_filter( 'retrieve_password_message', array( $this, 'retrieve_pass_message_filter' ), 10, 4 );
168
- }
169
-
170
- /**
171
- * Applies all password reset mail filters
172
- *
173
- * Callback for "password_reset" hook in Theme_My_Login::reset_password()
174
- *
175
- * @see Theme_My_Login::reset_password()
176
- * @since 6.2
177
- * @access public
178
- */
179
- public function apply_password_reset_filters() {
180
- $this->set_mail_headers(
181
- $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ),
182
- $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ),
183
- $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) )
184
- );
185
- add_filter( 'password_change_notification_mail_to', array( $this, 'password_change_notification_mail_to_filter' ) );
186
- add_filter( 'password_change_notification_title', array( $this, 'password_change_notification_title_filter' ), 10, 2 );
187
- add_filter( 'password_change_notification_message', array( $this, 'password_change_notification_message_filter' ), 10, 2 );
188
- add_filter( 'send_password_change_notification', array( $this, 'send_password_change_notification_filter' ) );
189
- }
190
-
191
- /**
192
- * Applies all new user mail filters
193
- *
194
- * Callback for "register_post" hook in Theme_My_Login::register_new_user()
195
- *
196
- * @see Theme_My_Login::register_new_user()
197
- * @since 6.0
198
- * @access public
199
- */
200
- public function apply_new_user_filters() {
201
- add_filter( 'new_user_notification_title', array( $this, 'new_user_notification_title_filter' ), 10, 2 );
202
- add_filter( 'new_user_notification_message', array( $this, 'new_user_notification_message_filter' ), 10, 3 );
203
- add_filter( 'send_new_user_notification', array( $this, 'send_new_user_notification_filter' ) );
204
- add_filter( 'new_user_admin_notification_mail_to', array( $this, 'new_user_admin_notification_mail_to_filter' ) );
205
- add_filter( 'new_user_admin_notification_title', array( $this, 'new_user_admin_notification_title_filter' ), 10, 2 );
206
- add_filter( 'new_user_admin_notification_message', array( $this, 'new_user_admin_notification_message_filter' ), 10, 2 );
207
- add_filter( 'send_new_user_admin_notification', array( $this, 'send_new_user_admin_notification_filter' ) );
208
- }
209
-
210
- /**
211
- * Changes the mail from address
212
- *
213
- * Callback for "wp_mail_from" hook in wp_mail()
214
- *
215
- * @see wp_mail()
216
- * @since 6.0
217
- * @access public
218
- *
219
- * @param string $from_email Default from email
220
- * @return string New from email
221
- */
222
- public function mail_from_filter( $from_email ) {
223
- return empty( $this->mail_from ) ? $from_email : $this->mail_from;
224
- }
225
-
226
- /**
227
- * Changes the mail from name
228
- *
229
- * Callback for "wp_mail_from_name" hook in wp_mail()
230
- *
231
- * @see wp_mail()
232
- * @since 6.0
233
- * @access public
234
- *
235
- * @param string $from_name Default from name
236
- * @return string New from name
237
- */
238
- public function mail_from_name_filter( $from_name ) {
239
- return empty( $this->mail_from_name ) ? $from_name : $this->mail_from_name;
240
- }
241
-
242
- /**
243
- * Changes the mail content type
244
- *
245
- * Callback for "wp_mail_content_type" hook in wp_mail()
246
- *
247
- * @see wp_mail()
248
- * @since 6.0
249
- * @access public
250
- *
251
- * @param string $content_type Default content type
252
- * @return string New content type
253
- */
254
- public function mail_content_type_filter( $content_type ) {
255
- return empty( $this->mail_content_type ) ? $content_type : 'text/' . $this->mail_content_type;
256
- }
257
-
258
- /**
259
- * Changes the retrieve password e-mail subject
260
- *
261
- * Callback for "retrieve_pass_title" hook in Theme_My_Login::retrieve_password()
262
- *
263
- * @see Theme_My_Login::retrieve_password()
264
- * @since 6.0
265
- * @access public
266
- *
267
- * @param string $title Default subject
268
- * @param string $user_login User login
269
- * @param object $user_data User data
270
- * @return string New subject
271
- */
272
- public function retrieve_pass_title_filter( $title, $user_login, $user_data ) {
273
- $_title = $this->get_option( array( 'retrieve_pass', 'title' ) );
274
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_data->ID );
275
- }
276
-
277
- /**
278
- * Changes the retrieve password e-mail message
279
- *
280
- * Callback for "retrieve_password_message" hook in Theme_My_Login::retrieve_password()
281
- *
282
- * @see Theme_My_Login::retrieve_password()
283
- * @since 6.0
284
- * @access public
285
- *
286
- * @param string $message Default message
287
- * @param string $key The user's reset key
288
- * @param string $user_login User login
289
- * @param object $user_data User data
290
- * @return string New message
291
- */
292
- public function retrieve_pass_message_filter( $message, $key, $user_login, $user_data ) {
293
- $_message = $this->get_option( array( 'retrieve_pass', 'message' ) );
294
- if ( ! empty( $_message ) ) {
295
- $message = Theme_My_Login_Common::replace_vars( $_message, $user_data->ID, array(
296
- '%loginurl%' => site_url( 'wp-login.php', 'login' ),
297
- '%reseturl%' => site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' )
298
- ) );
299
- }
300
- return $message;
301
- }
302
-
303
- /**
304
- * Changes who the password change notification e-mail is sent to
305
- *
306
- * Callback for "password_change_notification_mail_to" hook in $this->password_change_notification()
307
- *
308
- * @see $this->password_change_notification()
309
- * @since 6.0
310
- * @access public
311
- *
312
- * @param string $to Default admin e-mail address
313
- * @return string New e-mail address(es)
314
- */
315
- public function password_change_notification_mail_to_filter( $to ) {
316
- $_to = $this->get_option( array( 'reset_pass', 'admin_mail_to' ) );
317
- return empty( $_to ) ? $to : $_to;
318
- }
319
-
320
- /**
321
- * Changes the password change notification e-mail subject
322
- *
323
- * Callback for "password_change_notification_title" hook in $this->password_change_notification()
324
- *
325
- * @see $this->password_change_notification()
326
- * @since 6.0
327
- * @access public
328
- *
329
- * @param string $title Default subject
330
- * @param int $user_id User ID
331
- * @return string New subject
332
- */
333
- public function password_change_notification_title_filter( $title, $user_id ) {
334
- $_title = $this->get_option( array( 'reset_pass', 'admin_title' ) );
335
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
336
- }
337
-
338
- /**
339
- * Changes the password change notification e-mail message
340
- *
341
- * Callback for "password_change_notification_message" hook in $this->password_change_notification()
342
- *
343
- * @see $this->password_change_notification()
344
- * @since 6.0
345
- * @access public
346
- *
347
- * @param string $title Default message
348
- * @param int $user_id User ID
349
- * @return string New message
350
- */
351
- public function password_change_notification_message_filter( $message, $user_id ) {
352
- $_message = $this->get_option( array( 'reset_pass', 'admin_message' ) );
353
- return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
354
- }
355
-
356
- /**
357
- * Determines whether or not to send the password change notification e-mail
358
- *
359
- * Callback for "send_password_change_notification" hook in $this->password_change_notification()
360
- *
361
- * @see $this->password_change_notification()
362
- * @since 6.0
363
- * @access public
364
- *
365
- * @param bool $enable Default setting
366
- * @return bool New setting
367
- */
368
- public function send_password_change_notification_filter( $enable ) {
369
- // We'll cheat and set our headers here
370
- $this->set_mail_headers(
371
- $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ),
372
- $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ),
373
- $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) )
374
- );
375
-
376
- if ( $this->get_option( array( 'reset_pass', 'admin_disable' ) ) )
377
- return false;
378
-
379
- return $enable;
380
- }
381
-
382
- /**
383
- * Changes the new user e-mail subject
384
- *
385
- * Callback for "new_user_notification_title" hook in $this->new_user_notification()
386
- *
387
- * @see $this->new_user_notification()
388
- * @since 6.0
389
- * @access public
390
- *
391
- * @param string $title Default title
392
- * @param int $user_id User ID
393
- * @return string New title
394
- */
395
- public function new_user_notification_title_filter( $title, $user_id ) {
396
- $_title = $this->get_option( array( 'new_user', 'title' ) );
397
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
398
- }
399
-
400
- /**
401
- * Changes the new user e-mail message
402
- *
403
- * Callback for "new_user_notification_message" hook in $this->new_user_notification()
404
- *
405
- * @see $this->new_user_notification()
406
- * @since 6.0
407
- * @access public
408
- *
409
- * @param string $title Default message
410
- * @param string $key The user's password reset key
411
- * @param int $user_id User ID
412
- * @return string New message
413
- */
414
- public function new_user_notification_message_filter( $message, $key, $user_id ) {
415
- $_message = $this->get_option( array( 'new_user', 'message' ) );
416
- if ( ! empty( $_message ) ) {
417
- $user = get_userdata( $user_id );
418
- $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
419
- '%reseturl%' => network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ),
420
- '%loginurl%' => site_url( 'wp-login.php', 'login' )
421
- ) );
422
- }
423
- return $message;
424
- }
425
-
426
- /**
427
- * Determines whether or not to send the new user e-mail
428
- *
429
- * Callback for "send_new_user_notification" hook in $this->new_user_notification()
430
- *
431
- * @see $this->new_user_notification()
432
- * @since 6.0
433
- * @access public
434
- *
435
- * @param bool $enable Default setting
436
- * @return bool New setting
437
- */
438
- public function send_new_user_notification_filter( $enable ) {
439
- // We'll cheat and set out headers here
440
- $this->set_mail_headers(
441
- $this->get_option( array( 'new_user', 'mail_from' ) ),
442
- $this->get_option( array( 'new_user', 'mail_from_name' ) ),
443
- $this->get_option( array( 'new_user', 'mail_content_type' ) )
444
- );
445
- return $enable;
446
- }
447
-
448
- /**
449
- * Changes who the new user admin notification e-mail is sent to
450
- *
451
- * Callback for "new_user_admin_notification_mail_to" hook in $this->new_user_notification()
452
- *
453
- * @see $this->new_user_notification()
454
- * @since 6.0
455
- * @access public
456
- *
457
- * @param string $to Default admin e-mail address
458
- * @return string New e-mail address(es)
459
- */
460
- public function new_user_admin_notification_mail_to_filter( $to ) {
461
- $_to = $this->get_option( array( 'new_user', 'admin_mail_to' ) );
462
- return empty( $_to ) ? $to : $_to;
463
- }
464
-
465
- /**
466
- * Changes the new user admin notification e-mail subject
467
- *
468
- * Callback for "new_user_admin_notification_title" hook in $this->new_user_notification()
469
- *
470
- * @see $this->new_user_notification()
471
- * @since 6.0
472
- * @access public
473
- *
474
- * @param string $title Default subject
475
- * @param int $user_id User ID
476
- * @return string New subject
477
- */
478
- public function new_user_admin_notification_title_filter( $title, $user_id ) {
479
- $_title = $this->get_option( array( 'new_user', 'admin_title' ) );
480
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
481
- }
482
-
483
- /**
484
- * Changes the new user admin notification e-mail message
485
- *
486
- * Callback for "new_user_admin_notification_message" hook in $this->new_user_notification()
487
- *
488
- * @see $this->new_user_notification()
489
- * @since 6.0
490
- * @access public
491
- *
492
- * @param string $title Default message
493
- * @param int $user_id User ID
494
- * @return string New message
495
- */
496
- public function new_user_admin_notification_message_filter( $message, $user_id ) {
497
- $_message = $this->get_option( array( 'new_user', 'admin_message' ) );
498
- return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
499
- }
500
-
501
- /**
502
- * Determines whether or not to send the new user admin notification e-mail
503
- *
504
- * Callback for "send_new_user_admin_notification" hook in $this->new_user_notification()
505
- *
506
- * @see $this->new_user_notification()
507
- * @since 6.0
508
- * @access public
509
- *
510
- * @param bool $enable Default setting
511
- * @return bool New setting
512
- */
513
- public function send_new_user_admin_notification_filter( $enable ) {
514
- // We'll cheat and set out headers here
515
- $this->set_mail_headers(
516
- $this->get_option( array( 'new_user', 'admin_mail_from' ) ),
517
- $this->get_option( array( 'new_user', 'admin_mail_from_name' ) ),
518
- $this->get_option( array( 'new_user', 'admin_mail_content_type' ) )
519
- );
520
-
521
- if ( $this->get_option( array( 'new_user', 'admin_disable' ) ) )
522
- return false;
523
-
524
- return $enable;
525
- }
526
-
527
- /**
528
- * Applies user moderation mail filters according to moderation type
529
- *
530
- * Callback for "register_post" hook in Theme_My_Login::register_new_user()
531
- *
532
- * @see Theme_My_Login::register_new_user()
533
- * @since 6.1
534
- * @access public
535
- */
536
- public function apply_user_moderation_notification_filters() {
537
-
538
- if ( ! class_exists( 'Theme_My_Login_User_Moderation' ) )
539
- return;
540
-
541
- $moderation_type = Theme_My_Login_User_Moderation::get_object()->get_option( 'type' );
542
- switch ( $moderation_type ) {
543
- case 'email' :
544
- $this->set_mail_headers(
545
- $this->get_option( array( 'user_activation', 'mail_from' ) ),
546
- $this->get_option( array( 'user_activation', 'mail_from_name' ) ),
547
- $this->get_option( array( 'user_activation', 'mail_content_type' ) )
548
- );
549
- add_filter( 'user_activation_notification_title', array( $this, 'user_activation_notification_title_filter' ), 10, 2 );
550
- add_filter( 'user_activation_notification_message', array( $this, 'user_activation_notification_message_filter' ), 10, 3 );
551
- break;
552
- case 'admin' :
553
- $this->set_mail_headers(
554
- $this->get_option( array( 'user_approval', 'admin_mail_from' ) ),
555
- $this->get_option( array( 'user_approval', 'admin_mail_from_name' ) ),
556
- $this->get_option( array( 'user_approval', 'admin_mail_content_type' ) )
557
- );
558
- add_filter( 'user_approval_admin_notification_mail_to', array( $this, 'user_approval_admin_notification_mail_to_filter' ) );
559
- add_filter( 'user_approval_admin_notification_title', array( $this, 'user_approval_admin_notification_title_filter' ), 10, 2 );
560
- add_filter( 'user_approval_admin_notification_message', array( $this, 'user_approval_admin_notification_message_filter' ), 10, 2 );
561
- add_filter( 'send_new_user_approval_admin_notification', array( $this, 'send_new_user_approval_admin_notification_filter' ) );
562
- break;
563
- }
564
- }
565
-
566
- /**
567
- * Applies all user approval mail filters
568
- *
569
- * Callback for "approve_user" hook in Theme_My_Login_User_Moderation::approve_user()
570
- *
571
- * @see Theme_My_Login_User_Moderation::approve_user()
572
- * @since 6.1
573
- * @access public
574
- */
575
- public function apply_user_approval_notification_filters() {
576
- $this->set_mail_headers(
577
- $this->get_option( array( 'user_approval', 'mail_from' ) ),
578
- $this->get_option( array( 'user_approval', 'mail_from_name' ) ),
579
- $this->get_option( array( 'user_approval', 'mail_content_type' ) )
580
- );
581
- add_filter( 'user_approval_notification_title', array( $this, 'user_approval_notification_title_filter' ), 10, 2 );
582
- add_filter( 'user_approval_notification_message', array( $this, 'user_approval_notification_message_filter' ), 10, 3 );
583
- }
584
-
585
- /**
586
- * Applies all user denial mail filters
587
- *
588
- * Callback for "deny_user" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
589
- *
590
- * @see Theme_My_Login_User_Moderation_Admin::deny_user()
591
- * @since 6.1
592
- * @access public
593
- */
594
- public function apply_user_denial_notification_filters() {
595
- $this->set_mail_headers(
596
- $this->get_option( array( 'user_denial', 'mail_from' ) ),
597
- $this->get_option( array( 'user_denial', 'mail_from_name' ) ),
598
- $this->get_option( array( 'user_denial', 'mail_content_type' ) )
599
- );
600
- add_filter( 'user_denial_notification_title', array( $this, 'user_denial_notification_title_filter' ), 10, 2 );
601
- add_filter( 'user_denial_notification_message', array( $this, 'user_denial_notification_message_filter' ), 10, 2 );
602
- add_filter( 'send_new_user_denial_notification', array( $this, 'send_new_user_denial_notification_filter' ) );
603
- }
604
-
605
- /**
606
- * Changes the user activation e-mail subject
607
- *
608
- * Callback for "user_activation_notification_title" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
609
- *
610
- * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
611
- * @since 6.1
612
- * @access public
613
- *
614
- * @param string $title The default subject
615
- * @param int $user_id The user's ID
616
- * @return string The filtered subject
617
- */
618
- public function user_activation_notification_title_filter( $title, $user_id ) {
619
- $_title = $this->get_option( array( 'user_activation', 'title' ) );
620
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
621
- }
622
-
623
- /**
624
- * Changes the user activation e-mail message
625
- *
626
- * Callback for "user_activation_notification_message" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
627
- *
628
- * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
629
- * @since 6.1
630
- * @access public
631
- *
632
- * @param string $title The default message
633
- * @param int $user_id The user's ID
634
- * @param string $activation_url The activation URL
635
- * @return string The filtered message
636
- */
637
- public function user_activation_notification_message_filter( $message, $activation_url, $user_id ) {
638
- $_message = $this->get_option( array( 'user_activation', 'message' ) );
639
- if ( ! empty( $_message ) ) {
640
- $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
641
- '%activateurl%' => $activation_url
642
- ) );
643
- }
644
- return $message;
645
- }
646
-
647
- /**
648
- * Changes the user approval e-mail subject
649
- *
650
- * Callback for "user_approval_notification_title" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
651
- *
652
- * @see Theme_My_Login_User_Moderation_Admin::approve_user()
653
- * @since 6.1
654
- * @access public
655
- *
656
- * @param string $title The default subject
657
- * @param int $user_id The user's ID
658
- * @return string The filtered subject
659
- */
660
- public function user_approval_notification_title_filter( $title, $user_id ) {
661
- $_title = $this->get_option( array( 'user_approval', 'title' ) );
662
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
663
- }
664
-
665
- /**
666
- * Changes the user approval e-mail message
667
- *
668
- * Callback for "user_approval_notification_message" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
669
- *
670
- * @see Theme_My_Login_User_Moderation_Admin::approve_user()
671
- * @since 6.1
672
- * @access public
673
- *
674
- * @param string $title The default message
675
- * @param string $key The user's reset key
676
- * @param int $user_id The user's ID
677
- * @return string The filtered message
678
- */
679
- public function user_approval_notification_message_filter( $message, $key, $user_id ) {
680
- $_message = $this->get_option( array( 'user_approval', 'message' ) );
681
- if ( ! empty( $_message ) ) {
682
- $user = get_user_by( 'id', $user_id );
683
- $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
684
- '%loginurl%' => Theme_My_Login::get_object()->get_page_link( 'login' ),
685
- '%reseturl%' => site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' )
686
- ) );
687
- }
688
- return $message;
689
- }
690
-
691
- /**
692
- * Changes the user approval admin e-mail recipient
693
- *
694
- * Callback for "user_approval_admin_notification_mail_to" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
695
- *
696
- * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
697
- * @since 6.1
698
- * @access public
699
- *
700
- * @param string $to The default recipient
701
- * @return string The filtered recipient
702
- */
703
- public function user_approval_admin_notification_mail_to_filter( $to ) {
704
- $_to = $this->get_option( array( 'user_approval', 'admin_mail_to' ) );
705
- return empty( $_to ) ? $to : $_to;
706
- }
707
-
708
- /**
709
- * Changes the user approval admin e-mail subject
710
- *
711
- * Callback for "user_approval_admin_notification_title" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
712
- *
713
- * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
714
- * @since 6.1
715
- * @access public
716
- *
717
- * @param string $title The default subject
718
- * @param int $user_id The user's ID
719
- * @return string The filtered subject
720
- */
721
- public function user_approval_admin_notification_title_filter( $title, $user_id ) {
722
- $_title = $this->get_option( array( 'user_approval', 'admin_title' ) );
723
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
724
- }
725
-
726
- /**
727
- * Changes the user approval admin e-mail message
728
- *
729
- * Callback for "user_approval_admin_notification_message" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
730
- *
731
- * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
732
- * @since 6.1
733
- * @access public
734
- *
735
- * @param string $message The default message
736
- * @param int $user_id The user's ID
737
- * @return string The filtered message
738
- */
739
- public function user_approval_admin_notification_message_filter( $message, $user_id ) {
740
- $_message = $this->get_option( array( 'user_approval', 'admin_message' ) );
741
- if ( ! empty( $_message ) ) {
742
- $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
743
- '%pendingurl%' => admin_url( 'users.php?role=pending' )
744
- ) );
745
- }
746
- return $message;
747
- }
748
-
749
- /**
750
- * Determines whether or not to send the new user admin approval notification e-mail
751
- *
752
- * Callback for "send_new_user_approval_admin_notification" hook
753
- *
754
- * @since 6.4
755
- * @access public
756
- *
757
- * @param bool $enable Default setting
758
- * @return bool New setting
759
- */
760
- public function send_new_user_approval_admin_notification_filter( $enable ) {
761
- if ( $this->get_option( array( 'user_approval', 'admin_disable' ) ) )
762
- return false;
763
-
764
- return $enable;
765
- }
766
-
767
- /**
768
- * Changes the user denial e-mail subject
769
- *
770
- * Callback for "user_denial_notification_title" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
771
- *
772
- * @see Theme_My_Login_User_Moderation_Admin::deny_user()
773
- * @since 6.1
774
- * @access public
775
- *
776
- * @param string $title The default subject
777
- * @param int $user_id The user's ID
778
- * @return string The filtered subject
779
- */
780
- public function user_denial_notification_title_filter( $title, $user_id ) {
781
- $_title = $this->get_option( array( 'user_denial', 'title' ) );
782
- return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
783
- }
784
-
785
- /**
786
- * Changes the user denial e-mail message
787
- *
788
- * Callback for "user_denial_notification_message" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
789
- *
790
- * @see Theme_My_Login_User_Moderation_Admin::deny_user()
791
- * @since 6.1
792
- * @access public
793
- *
794
- * @param string $message The default message
795
- * @param int $user_id The user's ID
796
- * @return string The filtered message
797
- */
798
- public function user_denial_notification_message_filter( $message, $user_id ) {
799
- $_message = $this->get_option( array( 'user_denial', 'message' ) );
800
- return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
801
- }
802
-
803
- /**
804
- * Determines whether or not to send the new user denial notification e-mail
805
- *
806
- * @since 6.4
807
- * @access public
808
- *
809
- * @param bool $enable Default setting
810
- * @return bool New setting
811
- */
812
- public function send_new_user_denial_notification_filter( $enable ) {
813
- if ( $this->get_option( array( 'user_denial', 'disable' ) ) )
814
- return false;
815
-
816
- return $enable;
817
- }
818
-
819
- /**
820
- * Notify the blog admin of a new user
821
- *
822
- * @since 6.0
823
- * @access public
824
- *
825
- * @param int $user_id User ID
826
- * @param string $notify Type of notification that should happen
827
- */
828
- public function new_user_notification( $user_id, $notify = 'both' ) {
829
- global $wpdb;
830
-
831
- $user = get_userdata( $user_id );
832
-
833
- do_action( 'tml_new_user_notification', $user_id, $notify );
834
-
835
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
836
- // we want to reverse this for the plain text arena of emails.
837
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
838
-
839
- if ( apply_filters( 'send_new_user_admin_notification', true ) ) {
840
- $message = sprintf( __( 'New user registration on your site %s:', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
841
- $message .= sprintf( __( 'Username: %s' , 'theme-my-login' ), $user->user_login ) . "\r\n\r\n";
842
- $message .= sprintf( __( 'E-mail: %s' , 'theme-my-login' ), $user->user_email ) . "\r\n";
843
-
844
- $title = sprintf( __( '[%s] New User Registration' , 'theme-my-login' ), $blogname );
845
-
846
- $title = apply_filters( 'new_user_admin_notification_title', $title, $user_id );
847
- $message = apply_filters( 'new_user_admin_notification_message', $message, $user_id );
848
-
849
- $to = apply_filters( 'new_user_admin_notification_mail_to', get_option( 'admin_email' ) );
850
-
851
- @wp_mail( $to, $title, $message );
852
- }
853
-
854
- if ( 'admin' == $notify || empty( $notify ) )
855
- return;
856
-
857
- // Generate something random for a password reset key
858
- $key = wp_generate_password( 20, false );
859
-
860
- do_action( 'retrieve_password_key', $user->user_login, $key );
861
-
862
- // Now insert the key, hashed, into the DB
863
- require_once ABSPATH . WPINC . '/class-phpass.php';
864
- $wp_hasher = new PasswordHash( 8, true );
865
-
866
- $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
867
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
868
-
869
- if ( apply_filters( 'send_new_user_notification', true ) ) {
870
- $message = sprintf( __( 'Username: %s', 'theme-my-login' ), $user->user_login ) . "\r\n\r\n";
871
- $message .= __( 'To set your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
872
- $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n";
873
-
874
- $message .= wp_login_url() . "\r\n";
875
-
876
- $title = sprintf( __( '[%s] Your username and password info', 'theme-my-login' ), $blogname );
877
-
878
- $title = apply_filters( 'new_user_notification_title', $title, $user_id );
879
- $message = apply_filters( 'new_user_notification_message', $message, $key, $user_id );
880
-
881
- wp_mail( $user->user_email, $title, $message );
882
- }
883
- }
884
-
885
- /**
886
- * Notify the blog admin of a user changing password
887
- *
888
- * @since 6.0
889
- * @access public
890
- *
891
- * @param object $user User object
892
- */
893
- public function password_change_notification( $user ) {
894
- global $current_site;
895
-
896
- $to = apply_filters( 'password_change_notification_mail_to', get_option( 'admin_email' ) );
897
- // send a copy of password change notification to the admin
898
- // but check to see if it's the admin whose password we're changing, and skip this
899
- if ( $user->user_email != $to && apply_filters( 'send_password_change_notification', true ) ) {
900
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
901
- // we want to reverse this for the plain text arena of emails.
902
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
903
-
904
- $title = sprintf( __( '[%s] Password Lost/Changed' , 'theme-my-login' ), $blogname );
905
- $message = sprintf( __( 'Password Lost and Changed for user: %s', 'theme-my-login' ), $user->user_login ) . "\r\n";
906
-
907
- $title = apply_filters( 'password_change_notification_title', $title, $user->ID );
908
- $message = apply_filters( 'password_change_notification_message', $message, $user->ID );
909
-
910
- wp_mail( $to, $title, $message );
911
- }
912
- }
913
- }
914
-
915
- Theme_My_Login_Custom_Email::get_object();
916
-
917
- endif;
918
-
919
- if ( is_admin() )
920
- include_once( dirname( __FILE__ ) . '/admin/custom-email-admin.php' );
921
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * 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
+ * Holds Theme My Login Custom E-mail class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Custom_Email
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Custom_Email' ) ) :
14
+ /**
15
+ * Theme My Login Custom E-mail class
16
+ *
17
+ * @since 6.0
18
+ */
19
+ class Theme_My_Login_Custom_Email extends Theme_My_Login_Abstract {
20
+ /**
21
+ * Holds options key
22
+ *
23
+ * @since 6.3
24
+ * @access protected
25
+ * @var string
26
+ */
27
+ protected $options_key = 'theme_my_login_email';
28
+
29
+ /**
30
+ * Mail from
31
+ *
32
+ * @since 6.0
33
+ * @access protected
34
+ * @var string
35
+ */
36
+ protected $mail_from;
37
+
38
+ /**
39
+ * Mail from name
40
+ *
41
+ * @since 6.0
42
+ * @access protected
43
+ * @var string
44
+ */
45
+ protected $mail_from_name;
46
+
47
+ /**
48
+ * Mail content type
49
+ *
50
+ * @since 6.0
51
+ * @access protected
52
+ * @var string
53
+ */
54
+ protected $mail_content_type;
55
+
56
+ /**
57
+ * Returns singleton instance
58
+ *
59
+ * @since 6.3
60
+ * @access public
61
+ * @return object
62
+ */
63
+ public static function get_object( $class = null ) {
64
+ return parent::get_object( __CLASS__ );
65
+ }
66
+
67
+ /**
68
+ * Returns default options
69
+ *
70
+ * @since 6.3
71
+ * @access public
72
+ */
73
+ public static function default_options() {
74
+ return array(
75
+ 'new_user' => array(
76
+ 'mail_from' => '',
77
+ 'mail_from_name' => '',
78
+ 'mail_content_type' => '',
79
+ 'title' => '',
80
+ 'message' => '',
81
+ 'admin_mail_to' => '',
82
+ 'admin_mail_from' => '',
83
+ 'admin_mail_from_name' => '',
84
+ 'admin_mail_content_type' => '',
85
+ 'admin_title' => '',
86
+ 'admin_message' => ''
87
+ ),
88
+ 'retrieve_pass' => array(
89
+ 'mail_from' => '',
90
+ 'mail_from_name' => '',
91
+ 'mail_content_type' => '',
92
+ 'title' => '',
93
+ 'message' => ''
94
+ ),
95
+ 'reset_pass' => array(
96
+ 'admin_mail_to' => '',
97
+ 'admin_mail_from' => '',
98
+ 'admin_mail_from_name' => '',
99
+ 'admin_mail_content_type' => '',
100
+ 'admin_title' => '',
101
+ 'admin_message' => ''
102
+ )
103
+ );
104
+ }
105
+
106
+ /**
107
+ * Loads the module
108
+ *
109
+ * @since 6.0
110
+ * @access protected
111
+ */
112
+ protected function load() {
113
+ add_filter( 'wp_mail_from', array( $this, 'mail_from_filter' ) );
114
+ add_filter( 'wp_mail_from_name', array( $this, 'mail_from_name_filter' ) );
115
+ add_filter( 'wp_mail_content_type', array( $this, 'mail_content_type_filter' ) );
116
+
117
+ add_action( 'retrieve_password', array( $this, 'apply_retrieve_pass_filters' ) );
118
+ add_action( 'password_reset', array( $this, 'apply_password_reset_filters' ) );
119
+ add_action( 'tml_new_user_notification', array( $this, 'apply_new_user_filters' ) );
120
+
121
+ remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
122
+ remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );
123
+ remove_action( 'after_password_reset', 'wp_password_change_notification' );
124
+
125
+ add_action( 'register_new_user', array( $this, 'new_user_notification' ) );
126
+ add_action( 'edit_user_created_user', array( $this, 'new_user_notification' ), 10, 2 );
127
+ add_action( 'after_password_reset', array( $this, 'password_change_notification' ) );
128
+
129
+ add_action( 'register_post', array( $this, 'apply_user_moderation_notification_filters' ) );
130
+ add_action( 'tml_user_activation_resend', array( $this, 'apply_user_moderation_notification_filters' ) );
131
+ add_action( 'approve_user', array( $this, 'apply_user_approval_notification_filters' ) );
132
+ add_action( 'deny_user', array( $this, 'apply_user_denial_notification_filters' ) );
133
+
134
+ add_action( 'phpmailer_init', array( $this, 'phpmailer_init' ) );
135
+ }
136
+
137
+ /**
138
+ * Sets variables to be used with mail header filters
139
+ *
140
+ * @since 6.0
141
+ * @access public
142
+ *
143
+ * @param string $mail_from E-mail address to send the mail from
144
+ * @param string $mail_from_name Name to send the mail from
145
+ * @param string $mail_content_type Content type for the message
146
+ */
147
+ public function set_mail_headers( $mail_from = '', $mail_from_name = '', $mail_content_type = 'text' ) {
148
+ $this->mail_from = $mail_from;
149
+ $this->mail_from_name = $mail_from_name;
150
+ $this->mail_content_type = $mail_content_type;
151
+ }
152
+
153
+ /**
154
+ * Applies all password retrieval mail filters
155
+ *
156
+ * Callback for "retrieve_password" hook in Theme_My_Login::retrieve_password()
157
+ *
158
+ * @see Theme_My_Login::retrieve_password()
159
+ * @since 6.0
160
+ * @access public
161
+ */
162
+ public function apply_retrieve_pass_filters() {
163
+ $this->set_mail_headers(
164
+ $this->get_option( array( 'retrieve_pass', 'mail_from' ) ),
165
+ $this->get_option( array( 'retrieve_pass', 'mail_from_name' ) ),
166
+ $this->get_option( array( 'retrieve_pass', 'mail_content_type' ) )
167
+ );
168
+ add_filter( 'retrieve_password_title', array( $this, 'retrieve_pass_title_filter' ), 10, 3 );
169
+ add_filter( 'retrieve_password_message', array( $this, 'retrieve_pass_message_filter' ), 10, 4 );
170
+ }
171
+
172
+ /**
173
+ * Applies all password reset mail filters
174
+ *
175
+ * Callback for "password_reset" hook in Theme_My_Login::reset_password()
176
+ *
177
+ * @see Theme_My_Login::reset_password()
178
+ * @since 6.2
179
+ * @access public
180
+ */
181
+ public function apply_password_reset_filters() {
182
+ $this->set_mail_headers(
183
+ $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ),
184
+ $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ),
185
+ $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) )
186
+ );
187
+ add_filter( 'password_change_notification_mail_to', array( $this, 'password_change_notification_mail_to_filter' ) );
188
+ add_filter( 'password_change_notification_title', array( $this, 'password_change_notification_title_filter' ), 10, 2 );
189
+ add_filter( 'password_change_notification_message', array( $this, 'password_change_notification_message_filter' ), 10, 2 );
190
+ add_filter( 'send_password_change_notification', array( $this, 'send_password_change_notification_filter' ) );
191
+ }
192
+
193
+ /**
194
+ * Applies all new user mail filters
195
+ *
196
+ * Callback for "register_post" hook in Theme_My_Login::register_new_user()
197
+ *
198
+ * @see Theme_My_Login::register_new_user()
199
+ * @since 6.0
200
+ * @access public
201
+ */
202
+ public function apply_new_user_filters() {
203
+ add_filter( 'new_user_notification_title', array( $this, 'new_user_notification_title_filter' ), 10, 2 );
204
+ add_filter( 'new_user_notification_message', array( $this, 'new_user_notification_message_filter' ), 10, 3 );
205
+ add_filter( 'send_new_user_notification', array( $this, 'send_new_user_notification_filter' ) );
206
+ add_filter( 'new_user_admin_notification_mail_to', array( $this, 'new_user_admin_notification_mail_to_filter' ) );
207
+ add_filter( 'new_user_admin_notification_title', array( $this, 'new_user_admin_notification_title_filter' ), 10, 2 );
208
+ add_filter( 'new_user_admin_notification_message', array( $this, 'new_user_admin_notification_message_filter' ), 10, 2 );
209
+ add_filter( 'send_new_user_admin_notification', array( $this, 'send_new_user_admin_notification_filter' ) );
210
+ }
211
+
212
+ /**
213
+ * Changes the mail from address
214
+ *
215
+ * Callback for "wp_mail_from" hook in wp_mail()
216
+ *
217
+ * @see wp_mail()
218
+ * @since 6.0
219
+ * @access public
220
+ *
221
+ * @param string $from_email Default from email
222
+ * @return string New from email
223
+ */
224
+ public function mail_from_filter( $from_email ) {
225
+ return empty( $this->mail_from ) ? $from_email : $this->mail_from;
226
+ }
227
+
228
+ /**
229
+ * Changes the mail from name
230
+ *
231
+ * Callback for "wp_mail_from_name" hook in wp_mail()
232
+ *
233
+ * @see wp_mail()
234
+ * @since 6.0
235
+ * @access public
236
+ *
237
+ * @param string $from_name Default from name
238
+ * @return string New from name
239
+ */
240
+ public function mail_from_name_filter( $from_name ) {
241
+ return empty( $this->mail_from_name ) ? $from_name : $this->mail_from_name;
242
+ }
243
+
244
+ /**
245
+ * Changes the mail content type
246
+ *
247
+ * Callback for "wp_mail_content_type" hook in wp_mail()
248
+ *
249
+ * @see wp_mail()
250
+ * @since 6.0
251
+ * @access public
252
+ *
253
+ * @param string $content_type Default content type
254
+ * @return string New content type
255
+ */
256
+ public function mail_content_type_filter( $content_type ) {
257
+ return empty( $this->mail_content_type ) ? $content_type : 'text/' . $this->mail_content_type;
258
+ }
259
+
260
+ /**
261
+ * Changes the retrieve password e-mail subject
262
+ *
263
+ * Callback for "retrieve_pass_title" hook in Theme_My_Login::retrieve_password()
264
+ *
265
+ * @see Theme_My_Login::retrieve_password()
266
+ * @since 6.0
267
+ * @access public
268
+ *
269
+ * @param string $title Default subject
270
+ * @param string $user_login User login
271
+ * @param object $user_data User data
272
+ * @return string New subject
273
+ */
274
+ public function retrieve_pass_title_filter( $title, $user_login, $user_data ) {
275
+ $_title = $this->get_option( array( 'retrieve_pass', 'title' ) );
276
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_data->ID );
277
+ }
278
+
279
+ /**
280
+ * Changes the retrieve password e-mail message
281
+ *
282
+ * Callback for "retrieve_password_message" hook in Theme_My_Login::retrieve_password()
283
+ *
284
+ * @see Theme_My_Login::retrieve_password()
285
+ * @since 6.0
286
+ * @access public
287
+ *
288
+ * @param string $message Default message
289
+ * @param string $key The user's reset key
290
+ * @param string $user_login User login
291
+ * @param object $user_data User data
292
+ * @return string New message
293
+ */
294
+ public function retrieve_pass_message_filter( $message, $key, $user_login, $user_data ) {
295
+ $_message = $this->get_option( array( 'retrieve_pass', 'message' ) );
296
+ if ( ! empty( $_message ) ) {
297
+ $message = Theme_My_Login_Common::replace_vars( $_message, $user_data->ID, array(
298
+ '%loginurl%' => site_url( 'wp-login.php', 'login' ),
299
+ '%reseturl%' => site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' )
300
+ ) );
301
+ }
302
+ return $message;
303
+ }
304
+
305
+ /**
306
+ * Changes who the password change notification e-mail is sent to
307
+ *
308
+ * Callback for "password_change_notification_mail_to" hook in $this->password_change_notification()
309
+ *
310
+ * @see $this->password_change_notification()
311
+ * @since 6.0
312
+ * @access public
313
+ *
314
+ * @param string $to Default admin e-mail address
315
+ * @return string New e-mail address(es)
316
+ */
317
+ public function password_change_notification_mail_to_filter( $to ) {
318
+ $_to = $this->get_option( array( 'reset_pass', 'admin_mail_to' ) );
319
+ return empty( $_to ) ? $to : $_to;
320
+ }
321
+
322
+ /**
323
+ * Changes the password change notification e-mail subject
324
+ *
325
+ * Callback for "password_change_notification_title" hook in $this->password_change_notification()
326
+ *
327
+ * @see $this->password_change_notification()
328
+ * @since 6.0
329
+ * @access public
330
+ *
331
+ * @param string $title Default subject
332
+ * @param int $user_id User ID
333
+ * @return string New subject
334
+ */
335
+ public function password_change_notification_title_filter( $title, $user_id ) {
336
+ $_title = $this->get_option( array( 'reset_pass', 'admin_title' ) );
337
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
338
+ }
339
+
340
+ /**
341
+ * Changes the password change notification e-mail message
342
+ *
343
+ * Callback for "password_change_notification_message" hook in $this->password_change_notification()
344
+ *
345
+ * @see $this->password_change_notification()
346
+ * @since 6.0
347
+ * @access public
348
+ *
349
+ * @param string $title Default message
350
+ * @param int $user_id User ID
351
+ * @return string New message
352
+ */
353
+ public function password_change_notification_message_filter( $message, $user_id ) {
354
+ $_message = $this->get_option( array( 'reset_pass', 'admin_message' ) );
355
+ return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
356
+ }
357
+
358
+ /**
359
+ * Determines whether or not to send the password change notification e-mail
360
+ *
361
+ * Callback for "send_password_change_notification" hook in $this->password_change_notification()
362
+ *
363
+ * @see $this->password_change_notification()
364
+ * @since 6.0
365
+ * @access public
366
+ *
367
+ * @param bool $enable Default setting
368
+ * @return bool New setting
369
+ */
370
+ public function send_password_change_notification_filter( $enable ) {
371
+ // We'll cheat and set our headers here
372
+ $this->set_mail_headers(
373
+ $this->get_option( array( 'reset_pass', 'admin_mail_from' ) ),
374
+ $this->get_option( array( 'reset_pass', 'admin_mail_from_name' ) ),
375
+ $this->get_option( array( 'reset_pass', 'admin_mail_content_type' ) )
376
+ );
377
+
378
+ if ( $this->get_option( array( 'reset_pass', 'admin_disable' ) ) )
379
+ return false;
380
+
381
+ return $enable;
382
+ }
383
+
384
+ /**
385
+ * Changes the new user e-mail subject
386
+ *
387
+ * Callback for "new_user_notification_title" hook in $this->new_user_notification()
388
+ *
389
+ * @see $this->new_user_notification()
390
+ * @since 6.0
391
+ * @access public
392
+ *
393
+ * @param string $title Default title
394
+ * @param int $user_id User ID
395
+ * @return string New title
396
+ */
397
+ public function new_user_notification_title_filter( $title, $user_id ) {
398
+ $_title = $this->get_option( array( 'new_user', 'title' ) );
399
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
400
+ }
401
+
402
+ /**
403
+ * Changes the new user e-mail message
404
+ *
405
+ * Callback for "new_user_notification_message" hook in $this->new_user_notification()
406
+ *
407
+ * @see $this->new_user_notification()
408
+ * @since 6.0
409
+ * @access public
410
+ *
411
+ * @param string $title Default message
412
+ * @param string $key The user's password reset key
413
+ * @param int $user_id User ID
414
+ * @return string New message
415
+ */
416
+ public function new_user_notification_message_filter( $message, $key, $user_id ) {
417
+ $_message = $this->get_option( array( 'new_user', 'message' ) );
418
+ if ( ! empty( $_message ) ) {
419
+ $user = get_userdata( $user_id );
420
+ $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
421
+ '%reseturl%' => network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ),
422
+ '%loginurl%' => site_url( 'wp-login.php', 'login' )
423
+ ) );
424
+ }
425
+ return $message;
426
+ }
427
+
428
+ /**
429
+ * Determines whether or not to send the new user e-mail
430
+ *
431
+ * Callback for "send_new_user_notification" hook in $this->new_user_notification()
432
+ *
433
+ * @see $this->new_user_notification()
434
+ * @since 6.0
435
+ * @access public
436
+ *
437
+ * @param bool $enable Default setting
438
+ * @return bool New setting
439
+ */
440
+ public function send_new_user_notification_filter( $enable ) {
441
+ // We'll cheat and set out headers here
442
+ $this->set_mail_headers(
443
+ $this->get_option( array( 'new_user', 'mail_from' ) ),
444
+ $this->get_option( array( 'new_user', 'mail_from_name' ) ),
445
+ $this->get_option( array( 'new_user', 'mail_content_type' ) )
446
+ );
447
+ return $enable;
448
+ }
449
+
450
+ /**
451
+ * Changes who the new user admin notification e-mail is sent to
452
+ *
453
+ * Callback for "new_user_admin_notification_mail_to" hook in $this->new_user_notification()
454
+ *
455
+ * @see $this->new_user_notification()
456
+ * @since 6.0
457
+ * @access public
458
+ *
459
+ * @param string $to Default admin e-mail address
460
+ * @return string New e-mail address(es)
461
+ */
462
+ public function new_user_admin_notification_mail_to_filter( $to ) {
463
+ $_to = $this->get_option( array( 'new_user', 'admin_mail_to' ) );
464
+ return empty( $_to ) ? $to : $_to;
465
+ }
466
+
467
+ /**
468
+ * Changes the new user admin notification e-mail subject
469
+ *
470
+ * Callback for "new_user_admin_notification_title" hook in $this->new_user_notification()
471
+ *
472
+ * @see $this->new_user_notification()
473
+ * @since 6.0
474
+ * @access public
475
+ *
476
+ * @param string $title Default subject
477
+ * @param int $user_id User ID
478
+ * @return string New subject
479
+ */
480
+ public function new_user_admin_notification_title_filter( $title, $user_id ) {
481
+ $_title = $this->get_option( array( 'new_user', 'admin_title' ) );
482
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
483
+ }
484
+
485
+ /**
486
+ * Changes the new user admin notification e-mail message
487
+ *
488
+ * Callback for "new_user_admin_notification_message" hook in $this->new_user_notification()
489
+ *
490
+ * @see $this->new_user_notification()
491
+ * @since 6.0
492
+ * @access public
493
+ *
494
+ * @param string $title Default message
495
+ * @param int $user_id User ID
496
+ * @return string New message
497
+ */
498
+ public function new_user_admin_notification_message_filter( $message, $user_id ) {
499
+ $_message = $this->get_option( array( 'new_user', 'admin_message' ) );
500
+ return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
501
+ }
502
+
503
+ /**
504
+ * Determines whether or not to send the new user admin notification e-mail
505
+ *
506
+ * Callback for "send_new_user_admin_notification" hook in $this->new_user_notification()
507
+ *
508
+ * @see $this->new_user_notification()
509
+ * @since 6.0
510
+ * @access public
511
+ *
512
+ * @param bool $enable Default setting
513
+ * @return bool New setting
514
+ */
515
+ public function send_new_user_admin_notification_filter( $enable ) {
516
+ // We'll cheat and set out headers here
517
+ $this->set_mail_headers(
518
+ $this->get_option( array( 'new_user', 'admin_mail_from' ) ),
519
+ $this->get_option( array( 'new_user', 'admin_mail_from_name' ) ),
520
+ $this->get_option( array( 'new_user', 'admin_mail_content_type' ) )
521
+ );
522
+
523
+ if ( $this->get_option( array( 'new_user', 'admin_disable' ) ) )
524
+ return false;
525
+
526
+ return $enable;
527
+ }
528
+
529
+ /**
530
+ * Applies user moderation mail filters according to moderation type
531
+ *
532
+ * Callback for "register_post" hook in Theme_My_Login::register_new_user()
533
+ *
534
+ * @see Theme_My_Login::register_new_user()
535
+ * @since 6.1
536
+ * @access public
537
+ */
538
+ public function apply_user_moderation_notification_filters() {
539
+
540
+ if ( ! class_exists( 'Theme_My_Login_User_Moderation' ) )
541
+ return;
542
+
543
+ $moderation_type = Theme_My_Login_User_Moderation::get_object()->get_option( 'type' );
544
+ switch ( $moderation_type ) {
545
+ case 'email' :
546
+ $this->set_mail_headers(
547
+ $this->get_option( array( 'user_activation', 'mail_from' ) ),
548
+ $this->get_option( array( 'user_activation', 'mail_from_name' ) ),
549
+ $this->get_option( array( 'user_activation', 'mail_content_type' ) )
550
+ );
551
+ add_filter( 'user_activation_notification_title', array( $this, 'user_activation_notification_title_filter' ), 10, 2 );
552
+ add_filter( 'user_activation_notification_message', array( $this, 'user_activation_notification_message_filter' ), 10, 3 );
553
+ break;
554
+ case 'admin' :
555
+ $this->set_mail_headers(
556
+ $this->get_option( array( 'user_approval', 'admin_mail_from' ) ),
557
+ $this->get_option( array( 'user_approval', 'admin_mail_from_name' ) ),
558
+ $this->get_option( array( 'user_approval', 'admin_mail_content_type' ) )
559
+ );
560
+ add_filter( 'user_approval_admin_notification_mail_to', array( $this, 'user_approval_admin_notification_mail_to_filter' ) );
561
+ add_filter( 'user_approval_admin_notification_title', array( $this, 'user_approval_admin_notification_title_filter' ), 10, 2 );
562
+ add_filter( 'user_approval_admin_notification_message', array( $this, 'user_approval_admin_notification_message_filter' ), 10, 2 );
563
+ add_filter( 'send_new_user_approval_admin_notification', array( $this, 'send_new_user_approval_admin_notification_filter' ) );
564
+ break;
565
+ }
566
+ }
567
+
568
+ /**
569
+ * Applies all user approval mail filters
570
+ *
571
+ * Callback for "approve_user" hook in Theme_My_Login_User_Moderation::approve_user()
572
+ *
573
+ * @see Theme_My_Login_User_Moderation::approve_user()
574
+ * @since 6.1
575
+ * @access public
576
+ */
577
+ public function apply_user_approval_notification_filters() {
578
+ $this->set_mail_headers(
579
+ $this->get_option( array( 'user_approval', 'mail_from' ) ),
580
+ $this->get_option( array( 'user_approval', 'mail_from_name' ) ),
581
+ $this->get_option( array( 'user_approval', 'mail_content_type' ) )
582
+ );
583
+ add_filter( 'user_approval_notification_title', array( $this, 'user_approval_notification_title_filter' ), 10, 2 );
584
+ add_filter( 'user_approval_notification_message', array( $this, 'user_approval_notification_message_filter' ), 10, 3 );
585
+ }
586
+
587
+ /**
588
+ * Applies all user denial mail filters
589
+ *
590
+ * Callback for "deny_user" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
591
+ *
592
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
593
+ * @since 6.1
594
+ * @access public
595
+ */
596
+ public function apply_user_denial_notification_filters() {
597
+ $this->set_mail_headers(
598
+ $this->get_option( array( 'user_denial', 'mail_from' ) ),
599
+ $this->get_option( array( 'user_denial', 'mail_from_name' ) ),
600
+ $this->get_option( array( 'user_denial', 'mail_content_type' ) )
601
+ );
602
+ add_filter( 'user_denial_notification_title', array( $this, 'user_denial_notification_title_filter' ), 10, 2 );
603
+ add_filter( 'user_denial_notification_message', array( $this, 'user_denial_notification_message_filter' ), 10, 2 );
604
+ add_filter( 'send_new_user_denial_notification', array( $this, 'send_new_user_denial_notification_filter' ) );
605
+ }
606
+
607
+ /**
608
+ * Changes the user activation e-mail subject
609
+ *
610
+ * Callback for "user_activation_notification_title" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
611
+ *
612
+ * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
613
+ * @since 6.1
614
+ * @access public
615
+ *
616
+ * @param string $title The default subject
617
+ * @param int $user_id The user's ID
618
+ * @return string The filtered subject
619
+ */
620
+ public function user_activation_notification_title_filter( $title, $user_id ) {
621
+ $_title = $this->get_option( array( 'user_activation', 'title' ) );
622
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
623
+ }
624
+
625
+ /**
626
+ * Changes the user activation e-mail message
627
+ *
628
+ * Callback for "user_activation_notification_message" hook in Theme_My_Login_User_Moderation::new_user_activation_notification()
629
+ *
630
+ * @see Theme_My_Login_User_Moderation::new_user_activation_notification()
631
+ * @since 6.1
632
+ * @access public
633
+ *
634
+ * @param string $title The default message
635
+ * @param int $user_id The user's ID
636
+ * @param string $activation_url The activation URL
637
+ * @return string The filtered message
638
+ */
639
+ public function user_activation_notification_message_filter( $message, $activation_url, $user_id ) {
640
+ $_message = $this->get_option( array( 'user_activation', 'message' ) );
641
+ if ( ! empty( $_message ) ) {
642
+ $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
643
+ '%activateurl%' => $activation_url
644
+ ) );
645
+ }
646
+ return $message;
647
+ }
648
+
649
+ /**
650
+ * Changes the user approval e-mail subject
651
+ *
652
+ * Callback for "user_approval_notification_title" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
653
+ *
654
+ * @see Theme_My_Login_User_Moderation_Admin::approve_user()
655
+ * @since 6.1
656
+ * @access public
657
+ *
658
+ * @param string $title The default subject
659
+ * @param int $user_id The user's ID
660
+ * @return string The filtered subject
661
+ */
662
+ public function user_approval_notification_title_filter( $title, $user_id ) {
663
+ $_title = $this->get_option( array( 'user_approval', 'title' ) );
664
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
665
+ }
666
+
667
+ /**
668
+ * Changes the user approval e-mail message
669
+ *
670
+ * Callback for "user_approval_notification_message" hook in Theme_My_Login_User_Moderation_Admin::approve_user()
671
+ *
672
+ * @see Theme_My_Login_User_Moderation_Admin::approve_user()
673
+ * @since 6.1
674
+ * @access public
675
+ *
676
+ * @param string $title The default message
677
+ * @param string $key The user's reset key
678
+ * @param int $user_id The user's ID
679
+ * @return string The filtered message
680
+ */
681
+ public function user_approval_notification_message_filter( $message, $key, $user_id ) {
682
+ $_message = $this->get_option( array( 'user_approval', 'message' ) );
683
+ if ( ! empty( $_message ) ) {
684
+ $user = get_user_by( 'id', $user_id );
685
+ $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
686
+ '%loginurl%' => Theme_My_Login::get_object()->get_page_link( 'login' ),
687
+ '%reseturl%' => site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' )
688
+ ) );
689
+ }
690
+ return $message;
691
+ }
692
+
693
+ /**
694
+ * Changes the user approval admin e-mail recipient
695
+ *
696
+ * Callback for "user_approval_admin_notification_mail_to" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
697
+ *
698
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
699
+ * @since 6.1
700
+ * @access public
701
+ *
702
+ * @param string $to The default recipient
703
+ * @return string The filtered recipient
704
+ */
705
+ public function user_approval_admin_notification_mail_to_filter( $to ) {
706
+ $_to = $this->get_option( array( 'user_approval', 'admin_mail_to' ) );
707
+ return empty( $_to ) ? $to : $_to;
708
+ }
709
+
710
+ /**
711
+ * Changes the user approval admin e-mail subject
712
+ *
713
+ * Callback for "user_approval_admin_notification_title" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
714
+ *
715
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
716
+ * @since 6.1
717
+ * @access public
718
+ *
719
+ * @param string $title The default subject
720
+ * @param int $user_id The user's ID
721
+ * @return string The filtered subject
722
+ */
723
+ public function user_approval_admin_notification_title_filter( $title, $user_id ) {
724
+ $_title = $this->get_option( array( 'user_approval', 'admin_title' ) );
725
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
726
+ }
727
+
728
+ /**
729
+ * Changes the user approval admin e-mail message
730
+ *
731
+ * Callback for "user_approval_admin_notification_message" hook in Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
732
+ *
733
+ * @see Theme_My_Login_User_Moderation::new_user_approval_admin_notification()
734
+ * @since 6.1
735
+ * @access public
736
+ *
737
+ * @param string $message The default message
738
+ * @param int $user_id The user's ID
739
+ * @return string The filtered message
740
+ */
741
+ public function user_approval_admin_notification_message_filter( $message, $user_id ) {
742
+ $_message = $this->get_option( array( 'user_approval', 'admin_message' ) );
743
+ if ( ! empty( $_message ) ) {
744
+ $message = Theme_My_Login_Common::replace_vars( $_message, $user_id, array(
745
+ '%pendingurl%' => admin_url( 'users.php?role=pending' )
746
+ ) );
747
+ }
748
+ return $message;
749
+ }
750
+
751
+ /**
752
+ * Determines whether or not to send the new user admin approval notification e-mail
753
+ *
754
+ * Callback for "send_new_user_approval_admin_notification" hook
755
+ *
756
+ * @since 6.4
757
+ * @access public
758
+ *
759
+ * @param bool $enable Default setting
760
+ * @return bool New setting
761
+ */
762
+ public function send_new_user_approval_admin_notification_filter( $enable ) {
763
+ if ( $this->get_option( array( 'user_approval', 'admin_disable' ) ) )
764
+ return false;
765
+
766
+ return $enable;
767
+ }
768
+
769
+ /**
770
+ * Changes the user denial e-mail subject
771
+ *
772
+ * Callback for "user_denial_notification_title" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
773
+ *
774
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
775
+ * @since 6.1
776
+ * @access public
777
+ *
778
+ * @param string $title The default subject
779
+ * @param int $user_id The user's ID
780
+ * @return string The filtered subject
781
+ */
782
+ public function user_denial_notification_title_filter( $title, $user_id ) {
783
+ $_title = $this->get_option( array( 'user_denial', 'title' ) );
784
+ return empty( $_title ) ? $title : Theme_My_Login_Common::replace_vars( $_title, $user_id );
785
+ }
786
+
787
+ /**
788
+ * Changes the user denial e-mail message
789
+ *
790
+ * Callback for "user_denial_notification_message" hook in Theme_My_Login_User_Moderation_Admin::deny_user()
791
+ *
792
+ * @see Theme_My_Login_User_Moderation_Admin::deny_user()
793
+ * @since 6.1
794
+ * @access public
795
+ *
796
+ * @param string $message The default message
797
+ * @param int $user_id The user's ID
798
+ * @return string The filtered message
799
+ */
800
+ public function user_denial_notification_message_filter( $message, $user_id ) {
801
+ $_message = $this->get_option( array( 'user_denial', 'message' ) );
802
+ return empty( $_message ) ? $message : Theme_My_Login_Common::replace_vars( $_message, $user_id );
803
+ }
804
+
805
+ /**
806
+ * Determines whether or not to send the new user denial notification e-mail
807
+ *
808
+ * @since 6.4
809
+ * @access public
810
+ *
811
+ * @param bool $enable Default setting
812
+ * @return bool New setting
813
+ */
814
+ public function send_new_user_denial_notification_filter( $enable ) {
815
+ if ( $this->get_option( array( 'user_denial', 'disable' ) ) )
816
+ return false;
817
+
818
+ return $enable;
819
+ }
820
+
821
+ /**
822
+ * Notify the blog admin of a new user
823
+ *
824
+ * @since 6.0
825
+ * @access public
826
+ *
827
+ * @param int $user_id User ID
828
+ * @param string $notify Type of notification that should happen
829
+ */
830
+ public function new_user_notification( $user_id, $notify = 'both' ) {
831
+ global $wpdb;
832
+
833
+ $user = get_userdata( $user_id );
834
+
835
+ do_action( 'tml_new_user_notification', $user_id, $notify );
836
+
837
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
838
+ // we want to reverse this for the plain text arena of emails.
839
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
840
+
841
+ if ( apply_filters( 'send_new_user_admin_notification', true ) ) {
842
+ $message = sprintf( __( 'New user registration on your site %s:', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
843
+ $message .= sprintf( __( 'Username: %s' , 'theme-my-login' ), $user->user_login ) . "\r\n\r\n";
844
+ $message .= sprintf( __( 'E-mail: %s' , 'theme-my-login' ), $user->user_email ) . "\r\n";
845
+
846
+ $title = sprintf( __( '[%s] New User Registration' , 'theme-my-login' ), $blogname );
847
+
848
+ $title = apply_filters( 'new_user_admin_notification_title', $title, $user_id );
849
+ $message = apply_filters( 'new_user_admin_notification_message', $message, $user_id );
850
+
851
+ $to = apply_filters( 'new_user_admin_notification_mail_to', get_option( 'admin_email' ) );
852
+
853
+ @wp_mail( $to, $title, $message );
854
+ }
855
+
856
+ if ( 'admin' == $notify || empty( $notify ) )
857
+ return;
858
+
859
+ // Generate something random for a password reset key
860
+ $key = wp_generate_password( 20, false );
861
+
862
+ do_action( 'retrieve_password_key', $user->user_login, $key );
863
+
864
+ // Now insert the key, hashed, into the DB
865
+ require_once ABSPATH . WPINC . '/class-phpass.php';
866
+ $wp_hasher = new PasswordHash( 8, true );
867
+
868
+ $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
869
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
870
+
871
+ if ( apply_filters( 'send_new_user_notification', true ) ) {
872
+ $message = sprintf( __( 'Username: %s', 'theme-my-login' ), $user->user_login ) . "\r\n\r\n";
873
+ $message .= __( 'To set your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
874
+ $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n";
875
+
876
+ $message .= wp_login_url() . "\r\n";
877
+
878
+ $title = sprintf( __( '[%s] Your username and password info', 'theme-my-login' ), $blogname );
879
+
880
+ $title = apply_filters( 'new_user_notification_title', $title, $user_id );
881
+ $message = apply_filters( 'new_user_notification_message', $message, $key, $user_id );
882
+
883
+ wp_mail( $user->user_email, $title, $message );
884
+ }
885
+ }
886
+
887
+ /**
888
+ * Notify the blog admin of a user changing password
889
+ *
890
+ * @since 6.0
891
+ * @access public
892
+ *
893
+ * @param object $user User object
894
+ */
895
+ public function password_change_notification( $user ) {
896
+ global $current_site;
897
+
898
+ $to = apply_filters( 'password_change_notification_mail_to', get_option( 'admin_email' ) );
899
+ // send a copy of password change notification to the admin
900
+ // but check to see if it's the admin whose password we're changing, and skip this
901
+ if ( $user->user_email != $to && apply_filters( 'send_password_change_notification', true ) ) {
902
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
903
+ // we want to reverse this for the plain text arena of emails.
904
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
905
+
906
+ $title = sprintf( __( '[%s] Password Lost/Changed' , 'theme-my-login' ), $blogname );
907
+ $message = sprintf( __( 'Password Lost and Changed for user: %s', 'theme-my-login' ), $user->user_login ) . "\r\n";
908
+
909
+ $title = apply_filters( 'password_change_notification_title', $title, $user->ID );
910
+ $message = apply_filters( 'password_change_notification_message', $message, $user->ID );
911
+
912
+ wp_mail( $to, $title, $message );
913
+ }
914
+ }
915
+
916
+ /**
917
+ * Modify PHPMailer settings.
918
+ *
919
+ * @since 6.4.6
920
+ *
921
+ * @param PHPMailer $phpmailer PHPMailer object.
922
+ */
923
+ public function phpmailer_init( $phpmailer ) {
924
+
925
+ // Supply a plaintext alternate body if sending HTML
926
+ if ( 'text/html' == $phpmailer->ContentType && empty( $phpmailer->AltBody ) ) {
927
+ $phpmailer->AltBody = wp_strip_all_tags( $phpmailer->Body );
928
+ }
929
+ }
930
+ }
931
+
932
+ Theme_My_Login_Custom_Email::get_object();
933
+
934
+ endif;
935
+
936
+ if ( is_admin() )
937
+ include_once( dirname( __FILE__ ) . '/admin/custom-email-admin.php' );
938
+
modules/custom-passwords/custom-passwords.php CHANGED
@@ -1,314 +1,314 @@
1
- <?php
2
- /**
3
- * 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
- * Holds the Theme My Login Custom Passwords class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Custom_Passwords
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Custom_Passwords' ) ) :
14
- /**
15
- * Theme My Login Custom Passwords module class
16
- *
17
- * @since 6.0
18
- */
19
- class Theme_My_Login_Custom_Passwords extends Theme_My_Login_Abstract {
20
- /**
21
- * Returns singleton instance
22
- *
23
- * @since 6.3
24
- * @access public
25
- * @return object
26
- */
27
- public static function get_object( $class = null ) {
28
- return parent::get_object( __CLASS__ );
29
- }
30
-
31
- /**
32
- * Loads the module
33
- *
34
- * @since 6.0
35
- * @access protected
36
- */
37
- protected function load() {
38
- add_action( 'register_form', array( $this, 'password_fields' ) );
39
- add_filter( 'registration_errors', array( $this, 'password_errors' ) );
40
- add_filter( 'random_password', array( $this, 'set_password' ) );
41
-
42
- add_action( 'signup_extra_fields', array( $this, 'ms_password_fields' ) );
43
- add_action( 'signup_hidden_fields', array( $this, 'ms_hidden_password_field' ) );
44
- add_filter( 'wpmu_validate_user_signup', array( $this, 'ms_password_errors' ) );
45
- add_filter( 'add_signup_meta', array( $this, 'ms_save_password' ) );
46
-
47
- add_action( 'register_new_user', array( $this, 'remove_default_password_nag' ) );
48
- add_action( 'approve_user', array( $this, 'remove_default_password_nag' ) );
49
-
50
- add_filter( 'tml_register_passmail_template_message', array( $this, 'register_passmail_template_message' ) );
51
- add_action( 'tml_request', array( $this, 'action_messages' ) );
52
-
53
- add_filter( 'registration_redirect', array( $this, 'registration_redirect' ) );
54
- }
55
-
56
- /**
57
- * Outputs password fields to registration form
58
- *
59
- * Callback for "register_form" hook in file "register-form.php", included by Theme_My_Login_Template::display()
60
- *
61
- * @see Theme_My_Login::display()
62
- * @since 6.0
63
- * @access public
64
- */
65
- public function password_fields() {
66
- $template = Theme_My_Login::get_object()->get_active_instance();
67
- ?>
68
- <p class="tml-user-pass1-wrap">
69
- <label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'Password', 'theme-my-login' ); ?></label>
70
- <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
71
- </p>
72
- <p class="tml-user-pass2-wrap">
73
- <label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password', 'theme-my-login' ); ?></label>
74
- <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
75
- </p>
76
- <?php
77
- }
78
-
79
- /**
80
- * Outputs password fields to multisite signup user form
81
- *
82
- * Callback for "signup_extra_fields" hook in file "ms-signup-user-form.php", included by Theme_My_Login_Template::display()
83
- *
84
- * @see Theme_My_Login::display()
85
- * @since 6.1
86
- * @access public
87
- */
88
- public function ms_password_fields() {
89
- $theme_my_login = Theme_My_Login::get_object();
90
-
91
- $template = $theme_my_login->get_active_instance();
92
-
93
- $errors = array();
94
- foreach ( $theme_my_login->errors->get_error_codes() as $code ) {
95
- if ( in_array( $code, array( 'empty_password', 'password_mismatch', 'password_length' ) ) )
96
- $errors[] = $theme_my_login->errors->get_error_message( $code );
97
- }
98
- ?>
99
- <label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'Password:', 'theme-my-login' ); ?></label>
100
- <?php if ( ! empty( $errors ) ) { ?>
101
- <p class="error"><?php echo implode( '<br />', $errors ); ?></p>
102
- <?php } ?>
103
- <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /><br />
104
- <span class="hint"><?php echo apply_filters( 'tml_password_hint', __( '(Must be at least 6 characters.)', 'theme-my-login' ) ); ?></span>
105
-
106
- <label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password:', 'theme-my-login' ); ?></label>
107
- <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /><br />
108
- <span class="hint"><?php echo apply_filters( 'tml_password_confirm_hint', __( 'Confirm that you\'ve typed your password correctly.', 'theme-my-login' ) ); ?></span>
109
- <?php
110
- }
111
-
112
- /**
113
- * Outputs password field to multisite signup blog form
114
- *
115
- * Callback for "signup_hidden_fields" hook in file "ms-signup-blog-form.php", included by Theme_My_Login_Template::display()
116
- *
117
- * @see Theme_My_Login::display()
118
- * @since 6.1
119
- * @access public
120
- */
121
- public function ms_hidden_password_field() {
122
- if ( isset( $_POST['user_pass'] ) )
123
- echo '<input type="hidden" name="user_pass" value="' . $_POST['user_pass'] . '" />' . "\n";
124
- }
125
-
126
- /**
127
- * Handles password errors for registration form
128
- *
129
- * Callback for "registration_errors" hook in Theme_My_Login::register_new_user()
130
- *
131
- * @see Theme_My_Login::register_new_user()
132
- * @since 6.0
133
- * @access public
134
- *
135
- * @param WP_Error $errors WP_Error object
136
- * @return WP_Error WP_Error object
137
- */
138
- public function password_errors( $errors = '' ) {
139
- // Make sure $errors is a WP_Error object
140
- if ( empty( $errors ) )
141
- $errors = new WP_Error();
142
-
143
- // Make sure passwords aren't empty
144
- if ( empty( $_POST['pass1'] ) || empty( $_POST['pass2'] ) ) {
145
- $errors->add( 'empty_password', __( '<strong>ERROR</strong>: Please enter your password twice.', 'theme-my-login' ) );
146
-
147
- // Make sure there's no "\" in the password
148
- } elseif ( false !== strpos( stripslashes( $_POST['pass1'] ), "\\" ) ) {
149
- $errors->add( 'password_backslash', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".', 'theme-my-login' ) );
150
-
151
- // Make sure passwords match
152
- } elseif ( $_POST['pass1'] != $_POST['pass2'] ) {
153
- $errors->add( 'password_mismatch', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.', 'theme-my-login' ) );
154
-
155
- // Make sure password is long enough
156
- } elseif ( strlen( $_POST['pass1'] ) < 6 ) {
157
- $errors->add( 'password_length', __( '<strong>ERROR</strong>: Your password must be at least 6 characters in length.', 'theme-my-login' ) );
158
-
159
- // All is good, assign password to a friendlier key
160
- } else {
161
- $_POST['user_pass'] = $_POST['pass1'];
162
- }
163
-
164
- return $errors;
165
- }
166
-
167
- /**
168
- * Handles password errors for multisite signup form
169
- *
170
- * Callback for "registration_errors" hook in Theme_My_Login::register_new_user()
171
- *
172
- * @see Theme_My_Login::register_new_user()
173
- * @since 6.1
174
- * @access public
175
- *
176
- * @param WP_Error $errors WP_Error object
177
- * @return WP_Error WP_Error object
178
- */
179
- public function ms_password_errors( $result ) {
180
- if ( isset( $_POST['stage'] ) && 'validate-user-signup' == $_POST['stage'] ) {
181
- $errors = $this->password_errors();
182
- foreach ( $errors->get_error_codes() as $code ) {
183
- foreach ( $errors->get_error_messages( $code ) as $error ) {
184
- $result['errors']->add( $code, preg_replace( '/<strong>([^<]+)<\/strong>: /', '', $error ) );
185
- }
186
- }
187
- }
188
- return $result;
189
- }
190
-
191
- /**
192
- * Adds password to signup meta array
193
- *
194
- * Callback for "add_signup_meta" hook
195
- *
196
- * @since 6.1
197
- * @access public
198
- *
199
- * @param array $meta Signup meta
200
- * @return array $meta Signup meta
201
- */
202
- public function ms_save_password( $meta ) {
203
- if ( isset( $_POST['user_pass'] ) )
204
- $meta['user_pass'] = $_POST['user_pass'];
205
- return $meta;
206
- }
207
-
208
- /**
209
- * Sets the user password
210
- *
211
- * Callback for "random_password" hook in wp_generate_password()
212
- *
213
- * @see wp_generate_password()
214
- * @since 6.0
215
- * @access public
216
- *
217
- * @param string $password Auto-generated password passed in from filter
218
- * @return string Password chosen by user
219
- */
220
- public function set_password( $password ) {
221
- global $wpdb;
222
-
223
- // Remove filter as not to filter User Moderation activation key
224
- remove_filter( 'random_password', array( $this, 'set_password' ) );
225
-
226
- if ( is_multisite() && isset( $_REQUEST['key'] ) ) {
227
- if ( $meta = $wpdb->get_var( $wpdb->prepare( "SELECT meta FROM $wpdb->signups WHERE activation_key = %s", $_REQUEST['key'] ) ) ) {
228
- $meta = unserialize( $meta );
229
- if ( isset( $meta['user_pass'] ) ) {
230
- $password = $meta['user_pass'];
231
- unset( $meta['user_pass'] );
232
- $wpdb->update( $wpdb->signups, array( 'meta' => serialize( $meta ) ), array( 'activation_key' => $_REQUEST['key'] ) );
233
- }
234
- }
235
- } else {
236
- // Make sure password isn't empty
237
- if ( ! empty( $_POST['user_pass'] ) )
238
- $password = $_POST['user_pass'];
239
- }
240
- return $password;
241
- }
242
-
243
- /**
244
- * Removes the default password nag
245
- *
246
- * Callback for "register_new_user" hook in register_new_user()
247
- *
248
- * @see register_new_user()
249
- * @since 6.0
250
- * @access public
251
- *
252
- * @param int $user_id The user's ID
253
- */
254
- public function remove_default_password_nag( $user_id ) {
255
- update_user_meta( $user_id, 'default_password_nag', false );
256
- }
257
-
258
- /**
259
- * Changes the register template message
260
- *
261
- * Callback for "tml_register_passmail_template_message" hook
262
- *
263
- * @since 6.0
264
- * @access public
265
- *
266
- * @return string The new register message
267
- */
268
- public function register_passmail_template_message() {
269
- // Removes "A password will be e-mailed to you." from register form
270
- return;
271
- }
272
-
273
- /**
274
- * Handles display of various action/status messages
275
- *
276
- * Callback for "tml_request" hook in Theme_My_Login::the_request()
277
- *
278
- * @since 6.0
279
- * @access public
280
- *
281
- * @param object $theme_my_login Reference to global $theme_my_login object
282
- */
283
- public function action_messages( &$theme_my_login ) {
284
- // Change "Registration complete. Please check your e-mail." to reflect the fact that they already set a password
285
- if ( isset( $_GET['registration'] ) && 'complete' == $_GET['registration'] )
286
- $theme_my_login->errors->add( 'registration_complete', __( 'Registration complete. You may now log in.', 'theme-my-login' ), 'message' );
287
- }
288
-
289
- /**
290
- * Changes where the user is redirected upon successful registration
291
- *
292
- * Callback for "registration_redirect" hook in Theme_My_Login_Template::get_redirect_url()
293
- *
294
- * @see Theme_My_Login_Template::get_redirect_url()
295
- * @since 6.0
296
- * @access public
297
- *
298
- * @return string $redirect_to Default redirect
299
- * @return string URL to redirect to
300
- */
301
- public function registration_redirect( $redirect_to ) {
302
- // Redirect to login page with "registration=complete" added to the query
303
- $redirect_to = site_url( 'wp-login.php?registration=complete' );
304
- // Add instance to the query if specified
305
- if ( ! empty( $_REQUEST['instance'] ) )
306
- $redirect_to = add_query_arg( 'instance', $_REQUEST['instance'], $redirect_to );
307
- return $redirect_to;
308
- }
309
- }
310
-
311
- Theme_My_Login_Custom_Passwords::get_object();
312
-
313
- endif;
314
-
1
+ <?php
2
+ /**
3
+ * 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
+ * Holds the Theme My Login Custom Passwords class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Custom_Passwords
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Custom_Passwords' ) ) :
14
+ /**
15
+ * Theme My Login Custom Passwords module class
16
+ *
17
+ * @since 6.0
18
+ */
19
+ class Theme_My_Login_Custom_Passwords extends Theme_My_Login_Abstract {
20
+ /**
21
+ * Returns singleton instance
22
+ *
23
+ * @since 6.3
24
+ * @access public
25
+ * @return object
26
+ */
27
+ public static function get_object( $class = null ) {
28
+ return parent::get_object( __CLASS__ );
29
+ }
30
+
31
+ /**
32
+ * Loads the module
33
+ *
34
+ * @since 6.0
35
+ * @access protected
36
+ */
37
+ protected function load() {
38
+ add_action( 'register_form', array( $this, 'password_fields' ) );
39
+ add_filter( 'registration_errors', array( $this, 'password_errors' ) );
40
+ add_filter( 'random_password', array( $this, 'set_password' ) );
41
+
42
+ add_action( 'signup_extra_fields', array( $this, 'ms_password_fields' ) );
43
+ add_action( 'signup_hidden_fields', array( $this, 'ms_hidden_password_field' ) );
44
+ add_filter( 'wpmu_validate_user_signup', array( $this, 'ms_password_errors' ) );
45
+ add_filter( 'add_signup_meta', array( $this, 'ms_save_password' ) );
46
+
47
+ add_action( 'register_new_user', array( $this, 'remove_default_password_nag' ) );
48
+ add_action( 'approve_user', array( $this, 'remove_default_password_nag' ) );
49
+
50
+ add_filter( 'tml_register_passmail_template_message', array( $this, 'register_passmail_template_message' ) );
51
+ add_action( 'tml_request', array( $this, 'action_messages' ) );
52
+
53
+ add_filter( 'registration_redirect', array( $this, 'registration_redirect' ) );
54
+ }
55
+
56
+ /**
57
+ * Outputs password fields to registration form
58
+ *
59
+ * Callback for "register_form" hook in file "register-form.php", included by Theme_My_Login_Template::display()
60
+ *
61
+ * @see Theme_My_Login::display()
62
+ * @since 6.0
63
+ * @access public
64
+ */
65
+ public function password_fields() {
66
+ $template = Theme_My_Login::get_object()->get_active_instance();
67
+ ?>
68
+ <p class="tml-user-pass1-wrap">
69
+ <label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'Password', 'theme-my-login' ); ?></label>
70
+ <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
71
+ </p>
72
+ <p class="tml-user-pass2-wrap">
73
+ <label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password', 'theme-my-login' ); ?></label>
74
+ <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" />
75
+ </p>
76
+ <?php
77
+ }
78
+
79
+ /**
80
+ * Outputs password fields to multisite signup user form
81
+ *
82
+ * Callback for "signup_extra_fields" hook in file "ms-signup-user-form.php", included by Theme_My_Login_Template::display()
83
+ *
84
+ * @see Theme_My_Login::display()
85
+ * @since 6.1
86
+ * @access public
87
+ */
88
+ public function ms_password_fields() {
89
+ $theme_my_login = Theme_My_Login::get_object();
90
+
91
+ $template = $theme_my_login->get_active_instance();
92
+
93
+ $errors = array();
94
+ foreach ( $theme_my_login->errors->get_error_codes() as $code ) {
95
+ if ( in_array( $code, array( 'empty_password', 'password_mismatch', 'password_length' ) ) )
96
+ $errors[] = $theme_my_login->errors->get_error_message( $code );
97
+ }
98
+ ?>
99
+ <label for="pass1<?php $template->the_instance(); ?>"><?php _e( 'Password:', 'theme-my-login' ); ?></label>
100
+ <?php if ( ! empty( $errors ) ) { ?>
101
+ <p class="error"><?php echo implode( '<br />', $errors ); ?></p>
102
+ <?php } ?>
103
+ <input autocomplete="off" name="pass1" id="pass1<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /><br />
104
+ <span class="hint"><?php echo apply_filters( 'tml_password_hint', __( '(Must be at least 6 characters.)', 'theme-my-login' ) ); ?></span>
105
+
106
+ <label for="pass2<?php $template->the_instance(); ?>"><?php _e( 'Confirm Password:', 'theme-my-login' ); ?></label>
107
+ <input autocomplete="off" name="pass2" id="pass2<?php $template->the_instance(); ?>" class="input" size="20" value="" type="password" /><br />
108
+ <span class="hint"><?php echo apply_filters( 'tml_password_confirm_hint', __( 'Confirm that you\'ve typed your password correctly.', 'theme-my-login' ) ); ?></span>
109
+ <?php
110
+ }
111
+
112
+ /**
113
+ * Outputs password field to multisite signup blog form
114
+ *
115
+ * Callback for "signup_hidden_fields" hook in file "ms-signup-blog-form.php", included by Theme_My_Login_Template::display()
116
+ *
117
+ * @see Theme_My_Login::display()
118
+ * @since 6.1
119
+ * @access public
120
+ */
121
+ public function ms_hidden_password_field() {
122
+ if ( isset( $_POST['user_pass'] ) )
123
+ echo '<input type="hidden" name="user_pass" value="' . $_POST['user_pass'] . '" />' . "\n";
124
+ }
125
+
126
+ /**
127
+ * Handles password errors for registration form
128
+ *
129
+ * Callback for "registration_errors" hook in Theme_My_Login::register_new_user()
130
+ *
131
+ * @see Theme_My_Login::register_new_user()
132
+ * @since 6.0
133
+ * @access public
134
+ *
135
+ * @param WP_Error $errors WP_Error object
136
+ * @return WP_Error WP_Error object
137
+ */
138
+ public function password_errors( $errors = '' ) {
139
+ // Make sure $errors is a WP_Error object
140
+ if ( empty( $errors ) )
141
+ $errors = new WP_Error();
142
+
143
+ // Make sure passwords aren't empty
144
+ if ( empty( $_POST['pass1'] ) || empty( $_POST['pass2'] ) ) {
145
+ $errors->add( 'empty_password', __( '<strong>ERROR</strong>: Please enter your password twice.', 'theme-my-login' ) );
146
+
147
+ // Make sure there's no "\" in the password
148
+ } elseif ( false !== strpos( stripslashes( $_POST['pass1'] ), "\\" ) ) {
149
+ $errors->add( 'password_backslash', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".', 'theme-my-login' ) );
150
+
151
+ // Make sure passwords match
152
+ } elseif ( $_POST['pass1'] != $_POST['pass2'] ) {
153
+ $errors->add( 'password_mismatch', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.', 'theme-my-login' ) );
154
+
155
+ // Make sure password is long enough
156
+ } elseif ( strlen( $_POST['pass1'] ) < 6 ) {
157
+ $errors->add( 'password_length', __( '<strong>ERROR</strong>: Your password must be at least 6 characters in length.', 'theme-my-login' ) );
158
+
159
+ // All is good, assign password to a friendlier key
160
+ } else {
161
+ $_POST['user_pass'] = $_POST['pass1'];
162
+ }
163
+
164
+ return $errors;
165
+ }
166
+
167
+ /**
168
+ * Handles password errors for multisite signup form
169
+ *
170
+ * Callback for "registration_errors" hook in Theme_My_Login::register_new_user()
171
+ *
172
+ * @see Theme_My_Login::register_new_user()
173
+ * @since 6.1
174
+ * @access public
175
+ *
176
+ * @param WP_Error $errors WP_Error object
177
+ * @return WP_Error WP_Error object
178
+ */
179
+ public function ms_password_errors( $result ) {
180
+ if ( isset( $_POST['stage'] ) && 'validate-user-signup' == $_POST['stage'] ) {
181
+ $errors = $this->password_errors();
182
+ foreach ( $errors->get_error_codes() as $code ) {
183
+ foreach ( $errors->get_error_messages( $code ) as $error ) {
184
+ $result['errors']->add( $code, preg_replace( '/<strong>([^<]+)<\/strong>: /', '', $error ) );
185
+ }
186
+ }
187
+ }
188
+ return $result;
189
+ }
190
+
191
+ /**
192
+ * Adds password to signup meta array
193
+ *
194
+ * Callback for "add_signup_meta" hook
195
+ *
196
+ * @since 6.1
197
+ * @access public
198
+ *
199
+ * @param array $meta Signup meta
200
+ * @return array $meta Signup meta
201
+ */
202
+ public function ms_save_password( $meta ) {
203
+ if ( isset( $_POST['user_pass'] ) )
204
+ $meta['user_pass'] = $_POST['user_pass'];
205
+ return $meta;
206
+ }
207
+
208
+ /**
209
+ * Sets the user password
210
+ *
211
+ * Callback for "random_password" hook in wp_generate_password()
212
+ *
213
+ * @see wp_generate_password()
214
+ * @since 6.0
215
+ * @access public
216
+ *
217
+ * @param string $password Auto-generated password passed in from filter
218
+ * @return string Password chosen by user
219
+ */
220
+ public function set_password( $password ) {
221
+ global $wpdb;
222
+
223
+ // Remove filter as not to filter User Moderation activation key
224
+ remove_filter( 'random_password', array( $this, 'set_password' ) );
225
+
226
+ if ( is_multisite() && isset( $_REQUEST['key'] ) ) {
227
+ if ( $meta = $wpdb->get_var( $wpdb->prepare( "SELECT meta FROM $wpdb->signups WHERE activation_key = %s", $_REQUEST['key'] ) ) ) {
228
+ $meta = unserialize( $meta );
229
+ if ( isset( $meta['user_pass'] ) ) {
230
+ $password = $meta['user_pass'];
231
+ unset( $meta['user_pass'] );
232
+ $wpdb->update( $wpdb->signups, array( 'meta' => serialize( $meta ) ), array( 'activation_key' => $_REQUEST['key'] ) );
233
+ }
234
+ }
235
+ } else {
236
+ // Make sure password isn't empty
237
+ if ( ! empty( $_POST['user_pass'] ) )
238
+ $password = $_POST['user_pass'];
239
+ }
240
+ return $password;
241
+ }
242
+
243
+ /**
244
+ * Removes the default password nag
245
+ *
246
+ * Callback for "register_new_user" hook in register_new_user()
247
+ *
248
+ * @see register_new_user()
249
+ * @since 6.0
250
+ * @access public
251
+ *
252
+ * @param int $user_id The user's ID
253
+ */
254
+ public function remove_default_password_nag( $user_id ) {
255
+ update_user_meta( $user_id, 'default_password_nag', false );
256
+ }
257
+
258
+ /**
259
+ * Changes the register template message
260
+ *
261
+ * Callback for "tml_register_passmail_template_message" hook
262
+ *
263
+ * @since 6.0
264
+ * @access public
265
+ *
266
+ * @return string The new register message
267
+ */
268
+ public function register_passmail_template_message() {
269
+ // Removes "A password will be e-mailed to you." from register form
270
+ return;
271
+ }
272
+
273
+ /**
274
+ * Handles display of various action/status messages
275
+ *
276
+ * Callback for "tml_request" hook in Theme_My_Login::the_request()
277
+ *
278
+ * @since 6.0
279
+ * @access public
280
+ *
281
+ * @param object $theme_my_login Reference to global $theme_my_login object
282
+ */
283
+ public function action_messages( &$theme_my_login ) {
284
+ // Change "Registration complete. Please check your e-mail." to reflect the fact that they already set a password
285
+ if ( isset( $_GET['registration'] ) && 'complete' == $_GET['registration'] )
286
+ $theme_my_login->errors->add( 'registration_complete', __( 'Registration complete. You may now log in.', 'theme-my-login' ), 'message' );
287
+ }
288
+
289
+ /**
290
+ * Changes where the user is redirected upon successful registration
291
+ *
292
+ * Callback for "registration_redirect" hook in Theme_My_Login_Template::get_redirect_url()
293
+ *
294
+ * @see Theme_My_Login_Template::get_redirect_url()
295
+ * @since 6.0
296
+ * @access public
297
+ *
298
+ * @return string $redirect_to Default redirect
299
+ * @return string URL to redirect to
300
+ */
301
+ public function registration_redirect( $redirect_to ) {
302
+ // Redirect to login page with "registration=complete" added to the query
303
+ $redirect_to = site_url( 'wp-login.php?registration=complete' );
304
+ // Add instance to the query if specified
305
+ if ( ! empty( $_REQUEST['instance'] ) )
306
+ $redirect_to = add_query_arg( 'instance', $_REQUEST['instance'], $redirect_to );
307
+ return $redirect_to;
308
+ }
309
+ }
310
+
311
+ Theme_My_Login_Custom_Passwords::get_object();
312
+
313
+ endif;
314
+
modules/custom-redirection/custom-redirection.php CHANGED
@@ -1,236 +1,236 @@
1
- <?php
2
- /**
3
- * 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
- * Holds Theme My Login Custom Redirection class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Custom_Redirection
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Custom_Redirection' ) ) :
14
- /**
15
- * Theme My Login Custom Redirection class
16
- *
17
- * Adds the ability to redirect users when logging in/out based upon their "user role".
18
- *
19
- * @since 6.0
20
- */
21
- class Theme_My_Login_Custom_Redirection extends Theme_My_Login_Abstract {
22
- /**
23
- * Holds options key
24
- *
25
- * @since 6.3
26
- * @access protected
27
- * @var string
28
- */
29
- protected $options_key = 'theme_my_login_redirection';
30
-
31
- /**
32
- * Returns singleton instance
33
- *
34
- * @since 6.3
35
- * @access public
36
- * @return object
37
- */
38
- public static function get_object( $class = null ) {
39
- return parent::get_object( __CLASS__ );
40
- }
41
-
42
- /**
43
- * Called on Theme_My_Login_Abstract::__construct
44
- *
45
- * @since 6.0
46
- * @access protected
47
- */
48
- protected function load() {
49
- add_action( 'login_form', array( $this, 'login_form' ) );
50
- add_filter( 'login_redirect', array( $this, 'login_redirect' ), 10, 3 );
51
- add_filter( 'logout_redirect', array( $this, 'logout_redirect' ), 10, 3 );
52
- }
53
-
54
- /**
55
- * Returns default options
56
- *
57
- * @since 6.3
58
- * @access public
59
- *
60
- * @return array Default options
61
- */
62
- public static function default_options() {
63
- global $wp_roles;
64
-
65
- if ( empty( $wp_roles ) )
66
- $wp_roles = new WP_Roles;
67
-
68
- $options = array();
69
- foreach ( $wp_roles->get_names() as $role => $label ) {
70
- if ( 'pending' != $role ) {
71
- $options[$role] = array(
72
- 'login_type' => 'default',
73
- 'login_url' => '',
74
- 'logout_type' => 'default',
75
- 'logout_url' => ''
76
- );
77
- }
78
- }
79
- return $options;
80
- }
81
-
82
- /**
83
- * Get the redirect URL for a user.
84
- *
85
- * @since 6.4.1
86
- *
87
- * @param WP_User $user User object
88
- * @param string $type Optional. Type of redirect. Accepts 'login'
89
- * or 'logout'. Default is 'login'.
90
- * @param string $default Optional. Default URL if somehow not found
91
- * @return string Redirect URL
92
- */
93
- public function get_redirect_for_user( $user, $type = 'login', $default = '' ) {
94
- // Make sure we have a default
95
- if ( empty( $default ) )
96
- $default = admin_url( 'profile.php' );
97
-
98
- // Bail if $user is not a WP_User
99
- if ( ! $user instanceof WP_User )
100
- return $default;
101
-
102
- // Make sure $type is valid
103
- if ( ! ( 'login' == $type || 'logout' == $type ) )
104
- $type = 'login';
105
-
106
- // Make sure the user has a role
107
- if ( is_multisite() && empty( $user->roles ) ) {
108
- $user->roles = array( 'subscriber' );
109
- }
110
-
111
- // Get the user's role
112
- $user_role = reset( $user->roles );
113
-
114
- // Get the redirection settings for the user's role
115
- $redirection = $this->get_option( $user_role, array() );
116
-
117
- // Determine which redirection type is being used
118
- switch ( $redirection["{$type}_type"] ) {
119
-
120
- case 'referer' :
121
- // Get the referer
122
- if ( ! $referer = wp_get_original_referer() )
123
- $referer = wp_get_referer();
124
-
125
- // Strip unwanted arguments from the referer
126
- $referer = Theme_My_Login_Common::strip_query_args( $referer );
127
-
128
- // Is the URL a single post type?
129
- if ( $page_id = url_to_postid( $referer ) ) {
130
- // Bail if the referer is TML page
131
- if ( Theme_My_Login::is_tml_page( null, $page_id ) )
132
- return $default;
133
- }
134
-
135
- // Send 'em back to the referer
136
- $redirect_to = $referer;
137
- break;
138
-
139
- case 'custom' :
140
- // Send 'em to the specified URL
141
- $redirect_to = $redirection["{$type}_url"];
142
-
143
- // Allow a few user specific variables
144
- $redirect_to = str_replace(
145
- array(
146
- '%user_id%',
147
- '%user_nicename%'
148
- ),
149
- array(
150
- $user->ID,
151
- $user->user_nicename
152
- ),
153
- $redirect_to
154
- );
155
- break;
156
- }
157
-
158
- // Make sure $redirect_to isn't empty
159
- if ( empty( $redirect_to ) )
160
- $redirect_to = $default;
161
-
162
- return $redirect_to;
163
- }
164
-
165
- /**
166
- * Adds "_wp_original_referer" field to login form
167
- *
168
- * Callback for "login_form" hook in file "login-form.php", included by method Theme_My_Login_Template::display()
169
- *
170
- * @see Theme_My_Login_Template::display()
171
- * @since 6.0
172
- * @access public
173
- */
174
- public function login_form() {
175
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
176
- $referer = wp_unslash( $_REQUEST['redirect_to'] );
177
- } elseif ( wp_get_original_referer() ) {
178
- $referer = wp_get_original_referer();
179
- } else {
180
- $referer = Theme_My_Login::is_tml_page() ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
181
- }
182
- echo '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $referer ) . '" />';
183
- }
184
-
185
- /**
186
- * Handles login redirection
187
- *
188
- * Callback for "login_redirect" hook in method Theme_My_Login::the_request()
189
- *
190
- * @see Theme_My_Login::the_request()
191
- * @since 6.0
192
- * @access public
193
- *
194
- * @param string $redirect_to Default redirect
195
- * @param string $request Requested redirect
196
- * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
197
- * @return string New redirect
198
- */
199
- public function login_redirect( $redirect_to, $request, $user ) {
200
- // Return the redirect URL for the user
201
- return $this->get_redirect_for_user( $user, 'login', $redirect_to );
202
- }
203
-
204
- /**
205
- * Handles logout redirection
206
- *
207
- * Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
208
- *
209
- * @see Theme_My_Login::the_request()
210
- * @since 6.0
211
- * @access public
212
- *
213
- * @param string $redirect_to Default redirect
214
- * @param string $request Requested redirect
215
- * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
216
- * @return string New redirect
217
- */
218
- public function logout_redirect( $redirect_to, $request, $user ) {
219
- // Get the redirect URL for the user
220
- $redirect_to = $this->get_redirect_for_user( $user, 'logout', $redirect_to );
221
-
222
- // Make sure we're not trying to redirect to an admin URL
223
- if ( false !== strpos( $redirect_to, 'wp-admin' ) )
224
- $redirect_to = add_query_arg( 'loggedout', 'true', wp_login_url() );
225
-
226
- // Return the redirect URL for the user
227
- return $redirect_to;
228
- }
229
- }
230
-
231
- Theme_My_Login_Custom_Redirection::get_object();
232
-
233
- endif;
234
-
235
- if ( is_admin() )
236
- include_once( dirname( __FILE__ ) . '/admin/custom-redirection-admin.php' );
1
+ <?php
2
+ /**
3
+ * 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
+ * Holds Theme My Login Custom Redirection class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Custom_Redirection
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Custom_Redirection' ) ) :
14
+ /**
15
+ * Theme My Login Custom Redirection class
16
+ *
17
+ * Adds the ability to redirect users when logging in/out based upon their "user role".
18
+ *
19
+ * @since 6.0
20
+ */
21
+ class Theme_My_Login_Custom_Redirection extends Theme_My_Login_Abstract {
22
+ /**
23
+ * Holds options key
24
+ *
25
+ * @since 6.3
26
+ * @access protected
27
+ * @var string
28
+ */
29
+ protected $options_key = 'theme_my_login_redirection';
30
+
31
+ /**
32
+ * Returns singleton instance
33
+ *
34
+ * @since 6.3
35
+ * @access public
36
+ * @return object
37
+ */
38
+ public static function get_object( $class = null ) {
39
+ return parent::get_object( __CLASS__ );
40
+ }
41
+
42
+ /**
43
+ * Called on Theme_My_Login_Abstract::__construct
44
+ *
45
+ * @since 6.0
46
+ * @access protected
47
+ */
48
+ protected function load() {
49
+ add_action( 'login_form', array( $this, 'login_form' ) );
50
+ add_filter( 'login_redirect', array( $this, 'login_redirect' ), 10, 3 );
51
+ add_filter( 'logout_redirect', array( $this, 'logout_redirect' ), 10, 3 );
52
+ }
53
+
54
+ /**
55
+ * Returns default options
56
+ *
57
+ * @since 6.3
58
+ * @access public
59
+ *
60
+ * @return array Default options
61
+ */
62
+ public static function default_options() {
63
+ global $wp_roles;
64
+
65
+ if ( empty( $wp_roles ) )
66
+ $wp_roles = new WP_Roles;
67
+
68
+ $options = array();
69
+ foreach ( $wp_roles->get_names() as $role => $label ) {
70
+ if ( 'pending' != $role ) {
71
+ $options[$role] = array(
72
+ 'login_type' => 'default',
73
+ 'login_url' => '',
74
+ 'logout_type' => 'default',
75
+ 'logout_url' => ''
76
+ );
77
+ }
78
+ }
79
+ return $options;
80
+ }
81
+
82
+ /**
83
+ * Get the redirect URL for a user.
84
+ *
85
+ * @since 6.4.1
86
+ *
87
+ * @param WP_User $user User object
88
+ * @param string $type Optional. Type of redirect. Accepts 'login'
89
+ * or 'logout'. Default is 'login'.
90
+ * @param string $default Optional. Default URL if somehow not found
91
+ * @return string Redirect URL
92
+ */
93
+ public function get_redirect_for_user( $user, $type = 'login', $default = '' ) {
94
+ // Make sure we have a default
95
+ if ( empty( $default ) )
96
+ $default = admin_url( 'profile.php' );
97
+
98
+ // Bail if $user is not a WP_User
99
+ if ( ! $user instanceof WP_User )
100
+ return $default;
101
+
102
+ // Make sure $type is valid
103
+ if ( ! ( 'login' == $type || 'logout' == $type ) )
104
+ $type = 'login';
105
+
106
+ // Make sure the user has a role
107
+ if ( is_multisite() && empty( $user->roles ) ) {
108
+ $user->roles = array( 'subscriber' );
109
+ }
110
+
111
+ // Get the user's role
112
+ $user_role = reset( $user->roles );
113
+
114
+ // Get the redirection settings for the user's role
115
+ $redirection = $this->get_option( $user_role, array() );
116
+
117
+ // Determine which redirection type is being used
118
+ switch ( $redirection["{$type}_type"] ) {
119
+
120
+ case 'referer' :
121
+ // Get the referer
122
+ if ( ! $referer = wp_get_original_referer() )
123
+ $referer = wp_get_referer();
124
+
125
+ // Strip unwanted arguments from the referer
126
+ $referer = Theme_My_Login_Common::strip_query_args( $referer );
127
+
128
+ // Is the URL a single post type?
129
+ if ( $page_id = url_to_postid( $referer ) ) {
130
+ // Bail if the referer is TML page
131
+ if ( Theme_My_Login::is_tml_page( null, $page_id ) )
132
+ return $default;
133
+ }
134
+
135
+ // Send 'em back to the referer
136
+ $redirect_to = $referer;
137
+ break;
138
+
139
+ case 'custom' :
140
+ // Send 'em to the specified URL
141
+ $redirect_to = $redirection["{$type}_url"];
142
+
143
+ // Allow a few user specific variables
144
+ $redirect_to = str_replace(
145
+ array(
146
+ '%user_id%',
147
+ '%user_nicename%'
148
+ ),
149
+ array(
150
+ $user->ID,
151
+ $user->user_nicename
152
+ ),
153
+ $redirect_to
154
+ );
155
+ break;
156
+ }
157
+
158
+ // Make sure $redirect_to isn't empty
159
+ if ( empty( $redirect_to ) )
160
+ $redirect_to = $default;
161
+
162
+ return $redirect_to;
163
+ }
164
+
165
+ /**
166
+ * Adds "_wp_original_referer" field to login form
167
+ *
168
+ * Callback for "login_form" hook in file "login-form.php", included by method Theme_My_Login_Template::display()
169
+ *
170
+ * @see Theme_My_Login_Template::display()
171
+ * @since 6.0
172
+ * @access public
173
+ */
174
+ public function login_form() {
175
+ if ( ! empty( $_REQUEST['redirect_to'] ) ) {
176
+ $referer = wp_unslash( $_REQUEST['redirect_to'] );
177
+ } elseif ( wp_get_original_referer() ) {
178
+ $referer = wp_get_original_referer();
179
+ } else {
180
+ $referer = Theme_My_Login::is_tml_page() ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
181
+ }
182
+ echo '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $referer ) . '" />';
183
+ }
184
+
185
+ /**
186
+ * Handles login redirection
187
+ *
188
+ * Callback for "login_redirect" hook in method Theme_My_Login::the_request()
189
+ *
190
+ * @see Theme_My_Login::the_request()
191
+ * @since 6.0
192
+ * @access public
193
+ *
194
+ * @param string $redirect_to Default redirect
195
+ * @param string $request Requested redirect
196
+ * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
197
+ * @return string New redirect
198
+ */
199
+ public function login_redirect( $redirect_to, $request, $user ) {
200
+ // Return the redirect URL for the user
201
+ return $this->get_redirect_for_user( $user, 'login', $redirect_to );
202
+ }
203
+
204
+ /**
205
+ * Handles logout redirection
206
+ *
207
+ * Callback for "logout_redirect" hook in method Theme_My_Login::the_request()
208
+ *
209
+ * @see Theme_My_Login::the_request()
210
+ * @since 6.0
211
+ * @access public
212
+ *
213
+ * @param string $redirect_to Default redirect
214
+ * @param string $request Requested redirect
215
+ * @param WP_User|WP_Error WP_User if user logged in, WP_Error otherwise
216
+ * @return string New redirect
217
+ */
218
+ public function logout_redirect( $redirect_to, $request, $user ) {
219
+ // Get the redirect URL for the user
220
+ $redirect_to = $this->get_redirect_for_user( $user, 'logout', $redirect_to );
221
+
222
+ // Make sure we're not trying to redirect to an admin URL
223
+ if ( false !== strpos( $redirect_to, 'wp-admin' ) )
224
+ $redirect_to = add_query_arg( 'loggedout', 'true', wp_login_url() );
225
+
226
+ // Return the redirect URL for the user
227
+ return $redirect_to;
228
+ }
229
+ }
230
+
231
+ Theme_My_Login_Custom_Redirection::get_object();
232
+
233
+ endif;
234
+
235
+ if ( is_admin() )
236
+ include_once( dirname( __FILE__ ) . '/admin/custom-redirection-admin.php' );
modules/custom-user-links/admin/css/custom-user-links-admin.css CHANGED
@@ -1,30 +1,30 @@
1
- #theme_my_login_user_links div.ajax-response {
2
- border: none;
3
- }
4
- #theme_my_login_user_links table {
5
- width: 100%;
6
- margin: 0;
7
- border-spacing: 0;
8
- }
9
- #theme_my_login_user_links table input[type="text"] {
10
- width: 95%;
11
- }
12
- #theme_my_login_user_links th.left,
13
- #theme_my_login_user_links td.left {
14
- width: 35%;
15
- }
16
- #theme_my_login_user_links td.center {
17
- text-align: center;
18
- }
19
- #theme_my_login_user_links td.submit {
20
- border: 0 none;
21
- float: none !important;
22
- padding: 5px 8px !important;
23
- width: 25%;
24
- }
25
- #theme_my_login_user_links td.submit input {
26
- min-width: 75px;
27
- }
28
- #theme_my_login_user_links .alternate {
29
- background-color: transparent;
30
- }
1
+ #theme_my_login_user_links div.ajax-response {
2
+ border: none;
3
+ }
4
+ #theme_my_login_user_links table {
5
+ width: 100%;
6
+ margin: 0;
7
+ border-spacing: 0;
8
+ }
9
+ #theme_my_login_user_links table input[type="text"] {
10
+ width: 95%;
11
+ }
12
+ #theme_my_login_user_links th.left,
13
+ #theme_my_login_user_links td.left {
14
+ width: 35%;
15
+ }
16
+ #theme_my_login_user_links td.center {
17
+ text-align: center;
18
+ }
19
+ #theme_my_login_user_links td.submit {
20
+ border: 0 none;
21
+ float: none !important;
22
+ padding: 5px 8px !important;
23
+ width: 25%;
24
+ }
25
+ #theme_my_login_user_links td.submit input {
26
+ min-width: 75px;
27
+ }
28
+ #theme_my_login_user_links .alternate {
29
+ background-color: transparent;
30
+ }
modules/custom-user-links/admin/custom-user-links-admin.php CHANGED
@@ -1,412 +1,412 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Custom User Links Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Custom_User_Links
7
- * @since 6.0
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Custom_User_Links_Admin' ) ) :
11
- /**
12
- * Theme My Login Custom User Links Admin class
13
- *
14
- * @since 6.0
15
- */
16
- class Theme_My_Login_Custom_User_Links_Admin extends Theme_My_Login_Abstract {
17
- /**
18
- * Holds options key
19
- *
20
- * @since 6.3
21
- * @access protected
22
- * @var string
23
- */
24
- protected $options_key = 'theme_my_login_user_links';
25
-
26
- /**
27
- * Returns singleton instance
28
- *
29
- * @since 6.3
30
- * @access public
31
- * @return object
32
- */
33
- public static function get_object( $class = null ) {
34
- return parent::get_object( __CLASS__ );
35
- }
36
-
37
- /**
38
- * Loads the module
39
- *
40
- * Called by Theme_My_Login_Abstract::__construct()
41
- *
42
- * @see Theme_My_Login_Abstract::__construct()
43
- * @since 6.0
44
- * @access protected
45
- */
46
- protected function load() {
47
- add_action( 'tml_uninstall_custom-user-links/custom-user-links.php', array( $this, 'uninstall' ) );
48
-
49
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
50
- add_action( 'admin_init', array( $this, 'admin_init' ) );
51
-
52
- add_action( 'load-tml_page_theme_my_login_user_links', array( $this, 'load_settings_page' ) );
53
-
54
- add_action( 'wp_ajax_add-user-link', array( $this, 'add_user_link_ajax' ) );
55
- add_action( 'wp_ajax_delete-user-link', array( $this, 'delete_user_link_ajax' ) );
56
- }
57
-
58
- /**
59
- * Returns default options
60
- *
61
- * @since 6.3
62
- * @access public
63
- *
64
- * @return array Default options
65
- */
66
- public static function default_options() {
67
- return Theme_My_login_Custom_User_Links::default_options();
68
- }
69
-
70
- /**
71
- * Uninstalls the module
72
- *
73
- * Callback for "tml_uninstall_custom-user-links/custom-user-links.php" hook in method Theme_My_Login_Admin::uninstall()
74
- *
75
- * @see Theme_My_Login_Admin::uninstall()
76
- * @since 6.3
77
- * @access public
78
- */
79
- public function uninstall() {
80
- delete_option( $this->options_key );
81
- }
82
-
83
- /**
84
- * Adds "User Links" to Theme My Login menu
85
- *
86
- * @since 6.0
87
- * @access public
88
- */
89
- public function admin_menu() {
90
- global $wp_roles;
91
-
92
- add_submenu_page(
93
- 'theme_my_login',
94
- __( 'Theme My Login Custom User Links Settings', 'theme-my-login' ),
95
- __( 'User Links', 'theme-my-login' ),
96
- 'manage_options',
97
- $this->options_key,
98
- array( $this, 'settings_page' )
99
- );
100
-
101
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
102
- if ( 'pending' != $role )
103
- add_meta_box( $role, translate_user_role( $role_name ), array( $this, 'user_links_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
104
- }
105
- }
106
-
107
- /**
108
- * Registers options group
109
- *
110
- * Callback for "admin_init" hook
111
- *
112
- * @since 6.3
113
- * @access public
114
- */
115
- public function admin_init() {
116
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
117
- }
118
-
119
- /**
120
- * Loads admin styles and scripts
121
- *
122
- * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
123
- *
124
- * @since 6.0
125
- * @access public
126
- */
127
- public function load_settings_page() {
128
- wp_enqueue_style( 'tml-custom-user-links-admin', plugins_url( 'css/custom-user-links-admin.css', __FILE__ ) );
129
- wp_enqueue_script( 'tml-custom-user-links-admin', plugins_url( 'js/custom-user-links-admin.js', __FILE__ ), array( 'wp-lists', 'postbox', 'jquery-ui-sortable' ) );
130
- }
131
-
132
- /**
133
- * Renders settings page
134
- *
135
- * Callback for add_submenu_page()
136
- *
137
- * @since 6.3
138
- * @access public
139
- */
140
- public function settings_page() {
141
- global $current_screen;
142
- ?>
143
- <div class="wrap">
144
- <h2><?php esc_html_e( 'Theme My Login Custom User Links Settings', 'theme-my-login' ); ?></h2>
145
- <?php settings_errors(); ?>
146
-
147
- <form method="post" action="options.php">
148
- <?php
149
- settings_fields( $this->options_key );
150
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
151
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
152
- ?>
153
- <div id="<?php echo $this->options_key; ?>" class="metabox-holder">
154
- <?php do_meta_boxes( $current_screen->id, 'normal', null ); ?>
155
- </div>
156
- <?php submit_button(); ?>
157
- </form>
158
- </div>
159
- <?php
160
- }
161
-
162
- /**
163
- * Outputs user links admin menu for specified role
164
- *
165
- * Callback for add_settings_section()
166
- *
167
- * @since 6.0
168
- * @access public
169
- *
170
- * @param array $args Arguments passed in by add_settings_section()
171
- */
172
- public function user_links_meta_box( $object, $box ) {
173
- $role = $box['id'];
174
- $links = $this->get_option( $role, array() );
175
- ?>
176
- <div id="ajax-response-<?php echo $role; ?>" class="ajax-response"></div>
177
-
178
- <table id="<?php echo $role; ?>-link-table"<?php if ( empty( $links ) ) echo ' style="display: none;"'; ?> class="sortable user-links">
179
- <thead>
180
- <tr>
181
- <th class="left"><?php _e( 'Title', 'theme-my-login' ); ?></th>
182
- <th><?php _e( 'URL', 'theme-my-login' ); ?></th>
183
- <th></th>
184
- </tr>
185
- </thead>
186
- <tbody id="<?php echo $role; ?>-link-list" class="list:user-link" data-wp-lists="list:user-link"><?php
187
- if ( empty( $links ) ) {
188
- echo '<tr><td></td></tr>';
189
- } else {
190
- $count = 0;
191
- foreach ( $links as $key => $link ) {
192
- $link['id'] = $key;
193
- echo self::get_link_row( $link, $role );
194
- }
195
- } ?>
196
- </tbody>
197
- </table>
198
-
199
- <table id="new-<?php echo $role; ?>-link" class="new-link">
200
- <tbody>
201
- <tr>
202
- <td class="left"><input id="new_user_link[<?php echo $role; ?>][title]" name="new_user_link[<?php echo $role; ?>][title]" type="text" size="20" /></td>
203
- <td class="center"><input id="new_user_link[<?php echo $role; ?>][url]" name="new_user_link[<?php echo $role; ?>][url]" type="text" size="20" /></td>
204
- <td class="submit">
205
- <?php submit_button( __( 'Add Link', 'theme-my-login' ), "add:$role-link-list:new-$role-link", "add_new_user_link[$role]", false, array( 'id' => "new-$role-link-submit", 'data-wp-lists' => "add:$role-link-list:new-$role-link" ) ); ?>
206
- <?php wp_nonce_field( 'add-user-link', '_ajax_nonce-add-user-link', false ); ?>
207
- </td>
208
- </tr>
209
- </tbody>
210
- </table>
211
- <?php
212
- }
213
-
214
- /**
215
- * Outputs a link row to the table
216
- *
217
- * @since 6.0
218
- * @access private
219
- *
220
- * @param array $link Link data
221
- * @param string $role Name of user role
222
- * @return string Link row
223
- */
224
- private static function get_link_row( $link, $role ) {
225
- $r = '';
226
-
227
- $delete_nonce = wp_create_nonce( 'delete-user-link_' . $link['id'] );
228
- $update_nonce = wp_create_nonce( 'add-user-link' );
229
-
230
- $r .= "\n\t\t<tr id='$role-link-{$link['id']}'>";
231
- $r .= "\n\t\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]' type='text' size='20' value='{$link['title']}' /></td>";
232
- $r .= "\n\t\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]' type='text' size='20' value='{$link['url']}' /></td>";
233
- $r .= "\n\t\t\t<td class='submit'>";
234
- $r .= "\n\t\t\t\t";
235
- $r .= get_submit_button( __( 'Delete', 'theme-my-login' ), "delete:$role-link-list:$role-link-{$link['id']}::_ajax_nonce=$delete_nonce deletelink", "deletelink[{$link['id']}]", false, array( 'data-wp-lists' => "delete:$role-link-list:$role-link-{$link['id']}::_ajax_nonce=$delete_nonce" ) );
236
- $r .= "\n\t\t\t\t";
237
- $r .= get_submit_button( __( 'Update', 'theme-my-login' ), "add:$role-link-list:$role-link-{$link['id']}::_ajax_nonce-add-user-link=$update_nonce updatelink", "$role-link-{$link['id']}-submit", false, array( 'data-wp-lists' => "add:$role-link-list:$role-link-{$link['id']}::_ajax_nonce-add-user-link=$update_nonce" ) );
238
- $r .= "\n\t\t\t\t";
239
- $r .= wp_nonce_field( 'change-user-link', '_ajax_nonce', false, false );
240
- $r .= "\n\t\t\t</td>";
241
- $r .= "\n\t\t</tr>";
242
- return $r;
243
- }
244
-
245
- /**
246
- * Sanitizes settings
247
- *
248
- * Callback for register_setting()
249
- *
250
- * @since 6.0
251
- * @access public
252
- *
253
- * @param string|array $settings Settings passed in from filter
254
- * @return string|array Sanitized settings
255
- */
256
- public function save_settings( $settings ) {
257
- global $wp_roles;
258
-
259
- // Bail-out if doing AJAX because it has it's own saving routine
260
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
261
- return $settings;
262
-
263
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
264
- if ( 'pending' == $role )
265
- continue;
266
-
267
- $settings[$role] = array();
268
-
269
- // Handle updating/deleting of links
270
- if ( ! empty( $_POST['user_links'] ) && ! empty( $_POST['user_links'][$role] ) ) {
271
- foreach ( (array) $_POST['user_links'][$role] as $key => $link ) {
272
- $clean_title = wp_kses( $link['title'], null );
273
- $clean_url = wp_kses( $link['url'], null );
274
- if ( ! empty( $clean_title ) && ! empty( $clean_url ) && ! isset( $_POST['delete_user_link'][$role][$key] ) ) {
275
- $settings[$role][] = array(
276
- 'title' => $clean_title,
277
- 'url' => $clean_url
278
- );
279
- }
280
- }
281
- }
282
-
283
- // Handle new links
284
- if ( ! empty( $_POST['new_user_link'] ) && ! empty( $_POST['new_user_link'][$role] ) ) {
285
- $clean_title = wp_kses( $_POST['new_user_link'][$role]['title'], null );
286
- $clean_url = wp_kses( $_POST['new_user_link'][$role]['url'], null );
287
- if ( ! empty( $clean_title ) && ! empty( $clean_url ) ) {
288
- $settings[$role][] = array(
289
- 'title' => $clean_title,
290
- 'url' => $clean_url
291
- );
292
- }
293
- }
294
- }
295
-
296
- return $settings;
297
- }
298
-
299
- /**
300
- * AJAX handler for adding/updating a link
301
- *
302
- * Callback for "wp_ajax_add-user-link" hook in file "wp-admin/admin-ajax.php"
303
- *
304
- * @since 6.0
305
- * @access public
306
- */
307
- public function add_user_link_ajax() {
308
- if ( ! current_user_can( 'manage_options' ) )
309
- die( '-1' );
310
-
311
- check_ajax_referer( 'add-user-link', '_ajax_nonce-add-user-link' );
312
-
313
- if ( isset( $_POST['new_user_link'] ) ) {
314
- foreach ( $_POST['new_user_link'] as $user_role => $link ) {
315
- if ( is_array( $link ) && ! empty( $link ) ) {
316
- $clean_title = wp_kses( $link['title'], null );
317
- $clean_url = wp_kses( $link['url'], null );
318
-
319
- if ( empty( $clean_title ) || empty( $clean_url ) )
320
- wp_die( -1 );
321
-
322
- $links = $this->get_option( $user_role );
323
-
324
- $links[] = array(
325
- 'title' => $clean_title,
326
- 'url' => $clean_url
327
- );
328
-
329
- $this->set_option( $user_role, $links );
330
-
331
- $link_row = end( $links );
332
- $link_row['id'] = key( $links );
333
-
334
- $x = new WP_Ajax_Response( array(
335
- 'what' => $user_role . '-link',
336
- 'id' => $link_row['id'],
337
- 'data' => self::get_link_row( $link_row, $user_role ),
338
- 'position' => 1,
339
- 'supplemental' => compact( 'user_role' )
340
- ) );
341
- }
342
- }
343
- } else {
344
- foreach ( $_POST['user_links'] as $user_role => $link ) {
345
- $id = key( $link );
346
-
347
- $clean_title = wp_kses( $link[$id]['title'], null );
348
- $clean_url = wp_kses( $link[$id]['url'], null );
349
-
350
- if ( empty( $clean_title ) || empty( $clean_url ) )
351
- wp_die( -1 );
352
-
353
- if ( ! $link = $this->get_option( array( $user_role, $id ) ) )
354
- wp_die( 0 );
355
-
356
- $link = array(
357
- 'title' => $clean_title,
358
- 'url' => $clean_url
359
- );
360
-
361
- $this->set_option( array( $user_role, $id ), $link );
362
-
363
- $link['id'] = $id;
364
-
365
- $x = new WP_Ajax_Response( array(
366
- 'what' => $user_role . '-link',
367
- 'id' => $id,
368
- 'old_id' => $id,
369
- 'data' => self::get_link_row( $link, $user_role ),
370
- 'position' => 0,
371
- 'supplemental' => compact( 'user_role' )
372
- ) );
373
- }
374
- }
375
- $this->save_options();
376
-
377
- $x->send();
378
- }
379
-
380
- /**
381
- * AJAX handler for deleting a link
382
- *
383
- * Callback for "wp_ajax_delete-user-link" hook in file "wp-admin/admin-ajax.php"
384
- *
385
- * @since 6.0
386
- * @access public
387
- */
388
- public function delete_user_link_ajax() {
389
- if ( ! current_user_can( 'manage_options' ) )
390
- wp_die( -1 );
391
-
392
- $user_role = isset( $_POST['user_role'] ) ? $_POST['user_role'] : '';
393
- if ( empty( $user_role ) )
394
- wp_die( -1 );
395
-
396
- $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
397
-
398
- check_ajax_referer( "delete-user-link_$id" );
399
-
400
- if ( $this->get_option( array( $user_role, $id ) ) ) {
401
- $this->delete_option( array( $user_role, $id ) );
402
- $this->save_options();
403
- wp_die( 1 );
404
- }
405
- wp_die( 0 );
406
- }
407
- }
408
-
409
- Theme_My_Login_Custom_User_Links_Admin::get_object();
410
-
411
- endif;
412
-
1
+ <?php
2
+ /**
3
+ * Holds Theme My Login Custom User Links Admin class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @subpackage Theme_My_Login_Custom_User_Links
7
+ * @since 6.0
8
+ */
9
+
10
+ if ( ! class_exists( 'Theme_My_Login_Custom_User_Links_Admin' ) ) :
11
+ /**
12
+ * Theme My Login Custom User Links Admin class
13
+ *
14
+ * @since 6.0
15
+ */
16
+ class Theme_My_Login_Custom_User_Links_Admin extends Theme_My_Login_Abstract {
17
+ /**
18
+ * Holds options key
19
+ *
20
+ * @since 6.3
21
+ * @access protected
22
+ * @var string
23
+ */
24
+ protected $options_key = 'theme_my_login_user_links';
25
+
26
+ /**
27
+ * Returns singleton instance
28
+ *
29
+ * @since 6.3
30
+ * @access public
31
+ * @return object
32
+ */
33
+ public static function get_object( $class = null ) {
34
+ return parent::get_object( __CLASS__ );
35
+ }
36
+
37
+ /**
38
+ * Loads the module
39
+ *
40
+ * Called by Theme_My_Login_Abstract::__construct()
41
+ *
42
+ * @see Theme_My_Login_Abstract::__construct()
43
+ * @since 6.0
44
+ * @access protected
45
+ */
46
+ protected function load() {
47
+ add_action( 'tml_uninstall_custom-user-links/custom-user-links.php', array( $this, 'uninstall' ) );
48
+
49
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
50
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
51
+
52
+ add_action( 'load-tml_page_theme_my_login_user_links', array( $this, 'load_settings_page' ) );
53
+
54
+ add_action( 'wp_ajax_add-user-link', array( $this, 'add_user_link_ajax' ) );
55
+ add_action( 'wp_ajax_delete-user-link', array( $this, 'delete_user_link_ajax' ) );
56
+ }
57
+
58
+ /**
59
+ * Returns default options
60
+ *
61
+ * @since 6.3
62
+ * @access public
63
+ *
64
+ * @return array Default options
65
+ */
66
+ public static function default_options() {
67
+ return Theme_My_login_Custom_User_Links::default_options();
68
+ }
69
+
70
+ /**
71
+ * Uninstalls the module
72
+ *
73
+ * Callback for "tml_uninstall_custom-user-links/custom-user-links.php" hook in method Theme_My_Login_Admin::uninstall()
74
+ *
75
+ * @see Theme_My_Login_Admin::uninstall()
76
+ * @since 6.3
77
+ * @access public
78
+ */
79
+ public function uninstall() {
80
+ delete_option( $this->options_key );
81
+ }
82
+
83
+ /**
84
+ * Adds "User Links" to Theme My Login menu
85
+ *
86
+ * @since 6.0
87
+ * @access public
88
+ */
89
+ public function admin_menu() {
90
+ global $wp_roles;
91
+
92
+ add_submenu_page(
93
+ 'theme_my_login',
94
+ __( 'Theme My Login Custom User Links Settings', 'theme-my-login' ),
95
+ __( 'User Links', 'theme-my-login' ),
96
+ 'manage_options',
97
+ $this->options_key,
98
+ array( $this, 'settings_page' )
99
+ );
100
+
101
+ foreach ( $wp_roles->get_names() as $role => $role_name ) {
102
+ if ( 'pending' != $role )
103
+ add_meta_box( $role, translate_user_role( $role_name ), array( $this, 'user_links_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Registers options group
109
+ *
110
+ * Callback for "admin_init" hook
111
+ *
112
+ * @since 6.3
113
+ * @access public
114
+ */
115
+ public function admin_init() {
116
+ register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
117
+ }
118
+
119
+ /**
120
+ * Loads admin styles and scripts
121
+ *
122
+ * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
123
+ *
124
+ * @since 6.0
125
+ * @access public
126
+ */
127
+ public function load_settings_page() {
128
+ wp_enqueue_style( 'tml-custom-user-links-admin', plugins_url( 'css/custom-user-links-admin.css', __FILE__ ) );
129
+ wp_enqueue_script( 'tml-custom-user-links-admin', plugins_url( 'js/custom-user-links-admin.js', __FILE__ ), array( 'wp-lists', 'postbox', 'jquery-ui-sortable' ) );
130
+ }
131
+
132
+ /**
133
+ * Renders settings page
134
+ *
135
+ * Callback for add_submenu_page()
136
+ *
137
+ * @since 6.3
138
+ * @access public
139
+ */
140
+ public function settings_page() {
141
+ global $current_screen;
142
+ ?>
143
+ <div class="wrap">
144
+ <h2><?php esc_html_e( 'Theme My Login Custom User Links Settings', 'theme-my-login' ); ?></h2>
145
+ <?php settings_errors(); ?>
146
+
147
+ <form method="post" action="options.php">
148
+ <?php
149
+ settings_fields( $this->options_key );
150
+ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
151
+ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
152
+ ?>
153
+ <div id="<?php echo $this->options_key; ?>" class="metabox-holder">
154
+ <?php do_meta_boxes( $current_screen->id, 'normal', null ); ?>
155
+ </div>
156
+ <?php submit_button(); ?>
157
+ </form>
158
+ </div>
159
+ <?php
160
+ }
161
+
162
+ /**
163
+ * Outputs user links admin menu for specified role
164
+ *
165
+ * Callback for add_settings_section()
166
+ *
167
+ * @since 6.0
168
+ * @access public
169
+ *
170
+ * @param array $args Arguments passed in by add_settings_section()
171
+ */
172
+ public function user_links_meta_box( $object, $box ) {
173
+ $role = $box['id'];
174
+ $links = $this->get_option( $role, array() );
175
+ ?>
176
+ <div id="ajax-response-<?php echo $role; ?>" class="ajax-response"></div>
177
+
178
+ <table id="<?php echo $role; ?>-link-table"<?php if ( empty( $links ) ) echo ' style="display: none;"'; ?> class="sortable user-links">
179
+ <thead>
180
+ <tr>
181
+ <th class="left"><?php _e( 'Title', 'theme-my-login' ); ?></th>
182
+ <th><?php _e( 'URL', 'theme-my-login' ); ?></th>
183
+ <th></th>
184
+ </tr>
185
+ </thead>
186
+ <tbody id="<?php echo $role; ?>-link-list" class="list:user-link" data-wp-lists="list:user-link"><?php
187
+ if ( empty( $links ) ) {
188
+ echo '<tr><td></td></tr>';
189
+ } else {
190
+ $count = 0;
191
+ foreach ( $links as $key => $link ) {
192
+ $link['id'] = $key;
193
+ echo self::get_link_row( $link, $role );
194
+ }
195
+ } ?>
196
+ </tbody>
197
+ </table>
198
+
199
+ <table id="new-<?php echo $role; ?>-link" class="new-link">
200
+ <tbody>
201
+ <tr>
202
+ <td class="left"><input id="new_user_link[<?php echo $role; ?>][title]" name="new_user_link[<?php echo $role; ?>][title]" type="text" size="20" /></td>
203
+ <td class="center"><input id="new_user_link[<?php echo $role; ?>][url]" name="new_user_link[<?php echo $role; ?>][url]" type="text" size="20" /></td>
204
+ <td class="submit">
205
+ <?php submit_button( __( 'Add Link', 'theme-my-login' ), "add:$role-link-list:new-$role-link", "add_new_user_link[$role]", false, array( 'id' => "new-$role-link-submit", 'data-wp-lists' => "add:$role-link-list:new-$role-link" ) ); ?>
206
+ <?php wp_nonce_field( 'add-user-link', '_ajax_nonce-add-user-link', false ); ?>
207
+ </td>
208
+ </tr>
209
+ </tbody>
210
+ </table>
211
+ <?php
212
+ }
213
+
214
+ /**
215
+ * Outputs a link row to the table
216
+ *
217
+ * @since 6.0
218
+ * @access private
219
+ *
220
+ * @param array $link Link data
221
+ * @param string $role Name of user role
222
+ * @return string Link row
223
+ */
224
+ private static function get_link_row( $link, $role ) {
225
+ $r = '';
226
+
227
+ $delete_nonce = wp_create_nonce( 'delete-user-link_' . $link['id'] );
228
+ $update_nonce = wp_create_nonce( 'add-user-link' );
229
+
230
+ $r .= "\n\t\t<tr id='$role-link-{$link['id']}'>";
231
+ $r .= "\n\t\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]' type='text' size='20' value='{$link['title']}' /></td>";
232
+ $r .= "\n\t\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]' type='text' size='20' value='{$link['url']}' /></td>";
233
+ $r .= "\n\t\t\t<td class='submit'>";
234
+ $r .= "\n\t\t\t\t";
235
+ $r .= get_submit_button( __( 'Delete', 'theme-my-login' ), "delete:$role-link-list:$role-link-{$link['id']}::_ajax_nonce=$delete_nonce deletelink", "deletelink[{$link['id']}]", false, array( 'data-wp-lists' => "delete:$role-link-list:$role-link-{$link['id']}::_ajax_nonce=$delete_nonce" ) );
236
+ $r .= "\n\t\t\t\t";
237
+ $r .= get_submit_button( __( 'Update', 'theme-my-login' ), "add:$role-link-list:$role-link-{$link['id']}::_ajax_nonce-add-user-link=$update_nonce updatelink", "$role-link-{$link['id']}-submit", false, array( 'data-wp-lists' => "add:$role-link-list:$role-link-{$link['id']}::_ajax_nonce-add-user-link=$update_nonce" ) );
238
+ $r .= "\n\t\t\t\t";
239
+ $r .= wp_nonce_field( 'change-user-link', '_ajax_nonce', false, false );
240
+ $r .= "\n\t\t\t</td>";
241
+ $r .= "\n\t\t</tr>";
242
+ return $r;
243
+ }
244
+
245
+ /**
246
+ * Sanitizes settings
247
+ *
248
+ * Callback for register_setting()
249
+ *
250
+ * @since 6.0
251
+ * @access public
252
+ *
253
+ * @param string|array $settings Settings passed in from filter
254
+ * @return string|array Sanitized settings
255
+ */
256
+ public function save_settings( $settings ) {
257
+ global $wp_roles;
258
+
259
+ // Bail-out if doing AJAX because it has it's own saving routine
260
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
261
+ return $settings;
262
+
263
+ foreach ( $wp_roles->get_names() as $role => $role_name ) {
264
+ if ( 'pending' == $role )
265
+ continue;
266
+
267
+ $settings[$role] = array();
268
+
269
+ // Handle updating/deleting of links
270
+ if ( ! empty( $_POST['user_links'] ) && ! empty( $_POST['user_links'][$role] ) ) {
271
+ foreach ( (array) $_POST['user_links'][$role] as $key => $link ) {
272
+ $clean_title = wp_kses( $link['title'], null );
273
+ $clean_url = wp_kses( $link['url'], null );
274
+ if ( ! empty( $clean_title ) && ! empty( $clean_url ) && ! isset( $_POST['delete_user_link'][$role][$key] ) ) {
275
+ $settings[$role][] = array(
276
+ 'title' => $clean_title,
277
+ 'url' => $clean_url
278
+ );
279
+ }
280
+ }
281
+ }
282
+
283
+ // Handle new links
284
+ if ( ! empty( $_POST['new_user_link'] ) && ! empty( $_POST['new_user_link'][$role] ) ) {
285
+ $clean_title = wp_kses( $_POST['new_user_link'][$role]['title'], null );
286
+ $clean_url = wp_kses( $_POST['new_user_link'][$role]['url'], null );
287
+ if ( ! empty( $clean_title ) && ! empty( $clean_url ) ) {
288
+ $settings[$role][] = array(
289
+ 'title' => $clean_title,
290
+ 'url' => $clean_url
291
+ );
292
+ }
293
+ }
294
+ }
295
+
296
+ return $settings;
297
+ }
298
+
299
+ /**
300
+ * AJAX handler for adding/updating a link
301
+ *
302
+ * Callback for "wp_ajax_add-user-link" hook in file "wp-admin/admin-ajax.php"
303
+ *
304
+ * @since 6.0
305
+ * @access public
306
+ */
307
+ public function add_user_link_ajax() {
308
+ if ( ! current_user_can( 'manage_options' ) )
309
+ die( '-1' );
310
+
311
+ check_ajax_referer( 'add-user-link', '_ajax_nonce-add-user-link' );
312
+
313
+ if ( isset( $_POST['new_user_link'] ) ) {
314
+ foreach ( $_POST['new_user_link'] as $user_role => $link ) {
315
+ if ( is_array( $link ) && ! empty( $link ) ) {
316
+ $clean_title = wp_kses( $link['title'], null );
317
+ $clean_url = wp_kses( $link['url'], null );
318
+
319
+ if ( empty( $clean_title ) || empty( $clean_url ) )
320
+ wp_die( -1 );
321
+
322
+ $links = $this->get_option( $user_role );
323
+
324
+ $links[] = array(
325
+ 'title' => $clean_title,
326
+ 'url' => $clean_url
327
+ );
328
+
329
+ $this->set_option( $user_role, $links );
330
+
331
+ $link_row = end( $links );
332
+ $link_row['id'] = key( $links );
333
+
334
+ $x = new WP_Ajax_Response( array(
335
+ 'what' => $user_role . '-link',
336
+ 'id' => $link_row['id'],
337
+ 'data' => self::get_link_row( $link_row, $user_role ),
338
+ 'position' => 1,
339
+ 'supplemental' => compact( 'user_role' )
340
+ ) );
341
+ }
342
+ }
343
+ } else {
344
+ foreach ( $_POST['user_links'] as $user_role => $link ) {
345
+ $id = key( $link );
346
+
347
+ $clean_title = wp_kses( $link[$id]['title'], null );
348
+ $clean_url = wp_kses( $link[$id]['url'], null );
349
+
350
+ if ( empty( $clean_title ) || empty( $clean_url ) )
351
+ wp_die( -1 );
352
+
353
+ if ( ! $link = $this->get_option( array( $user_role, $id ) ) )
354
+ wp_die( 0 );
355
+
356
+ $link = array(
357
+ 'title' => $clean_title,
358
+ 'url' => $clean_url
359
+ );
360
+
361
+ $this->set_option( array( $user_role, $id ), $link );
362
+
363
+ $link['id'] = $id;
364
+
365
+ $x = new WP_Ajax_Response( array(
366
+ 'what' => $user_role . '-link',
367
+ 'id' => $id,
368
+ 'old_id' => $id,
369
+ 'data' => self::get_link_row( $link, $user_role ),
370
+ 'position' => 0,
371
+ 'supplemental' => compact( 'user_role' )
372
+ ) );
373
+ }
374
+ }
375
+ $this->save_options();
376
+
377
+ $x->send();
378
+ }
379
+
380
+ /**
381
+ * AJAX handler for deleting a link
382
+ *
383
+ * Callback for "wp_ajax_delete-user-link" hook in file "wp-admin/admin-ajax.php"
384
+ *
385
+ * @since 6.0
386
+ * @access public
387
+ */
388
+ public function delete_user_link_ajax() {
389
+ if ( ! current_user_can( 'manage_options' ) )
390
+ wp_die( -1 );
391
+
392
+ $user_role = isset( $_POST['user_role'] ) ? $_POST['user_role'] : '';
393
+ if ( empty( $user_role ) )
394
+ wp_die( -1 );
395
+
396
+ $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
397
+
398
+ check_ajax_referer( "delete-user-link_$id" );
399
+
400
+ if ( $this->get_option( array( $user_role, $id ) ) ) {
401
+ $this->delete_option( array( $user_role, $id ) );
402
+ $this->save_options();
403
+ wp_die( 1 );
404
+ }
405
+ wp_die( 0 );
406
+ }
407
+ }
408
+
409
+ Theme_My_Login_Custom_User_Links_Admin::get_object();
410
+
411
+ endif;
412
+
modules/custom-user-links/admin/js/custom-user-links-admin.js CHANGED
@@ -1,42 +1,42 @@
1
- jQuery(document).ready( function($) {
2
- $('#theme_my_login_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
- var t = $('#' + s.element).closest('tbody');
22
- $('#' + s.element).remove();
23
- if (t.children('tr').length == 0)
24
- t.parent().hide();
25
- }
26
- } );
27
-
28
- var fixHelper = function(e, ui) {
29
- ui.children().each(function() {
30
- $(this).width($(this).width());
31
- });
32
- return ui;
33
- };
34
-
35
- $('#theme_my_login_user_links table.sortable tbody').sortable({
36
- axis: 'y',
37
- helper: fixHelper,
38
- items: 'tr'
39
- });
40
-
41
- postboxes.add_postbox_toggles(pagenow);
42
- } );
1
+ jQuery(document).ready( function($) {
2
+ $('#theme_my_login_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
+ var t = $('#' + s.element).closest('tbody');
22
+ $('#' + s.element).remove();
23
+ if (t.children('tr').length == 0)
24
+ t.parent().hide();
25
+ }
26
+ } );
27
+
28
+ var fixHelper = function(e, ui) {
29
+ ui.children().each(function() {
30
+ $(this).width($(this).width());
31
+ });
32
+ return ui;
33
+ };
34
+
35
+ $('#theme_my_login_user_links table.sortable tbody').sortable({
36
+ axis: 'y',
37
+ helper: fixHelper,
38
+ items: 'tr'
39
+ });
40
+
41
+ postboxes.add_postbox_toggles(pagenow);
42
+ } );
modules/custom-user-links/custom-user-links.php CHANGED
@@ -1,130 +1,130 @@
1
- <?php
2
- /**
3
- * 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
- * Holds Theme My Login Custom User Links class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Custom_User_Links
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Custom_User_Links' ) ) :
14
- /**
15
- * Theme My Login Custom User Links module class
16
- *
17
- * Adds the ability to define custom links to display to a user when logged in based upon their "user role".
18
- *
19
- * @since 6.0
20
- */
21
- class Theme_My_Login_Custom_User_Links extends Theme_My_Login_Abstract {
22
- /**
23
- * Holds options key
24
- *
25
- * @since 6.3
26
- * @access protected
27
- * @var string
28
- */
29
- protected $options_key = 'theme_my_login_user_links';
30
-
31
- /**
32
- * Returns singleton instance
33
- *
34
- * @since 6.3
35
- * @access public
36
- * @return object
37
- */
38
- public static function get_object( $class = null ) {
39
- return parent::get_object( __CLASS__ );
40
- }
41
-
42
- /**
43
- * Returns default options
44
- *
45
- * @since 6.3
46
- * @access public
47
- *
48
- * @return array Default options
49
- */
50
- public static function default_options() {
51
- global $wp_roles;
52
-
53
- if ( empty( $wp_roles ) )
54
- $wp_roles = new WP_Roles;
55
-
56
- $options = array();
57
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
58
- if ( 'pending' != $role ) {
59
- $options[$role] = array(
60
- array(
61
- 'title' => __( 'Dashboard', 'theme-my-login' ),
62
- 'url' => admin_url()
63
- ),
64
- array(
65
- 'title' => __( 'Profile', 'theme-my-login' ),
66
- 'url' => admin_url( 'profile.php' )
67
- )
68
- );
69
- }
70
- }
71
- return $options;
72
- }
73
-
74
- /**
75
- * Loads the module
76
- *
77
- * @since 6.0
78
- * @access protected
79
- */
80
- protected function load() {
81
- add_filter( 'tml_user_links', array( $this, 'get_user_links' ) );
82
- }
83
-
84
- /**
85
- * Gets the user links for the current user's role
86
- *
87
- * Callback for "tml_user_links" hook in method Theme_My_Login_Template::display()
88
- *
89
- * @see Theme_My_Login_Template::display()
90
- * @since 6.0
91
- * @access public
92
- *
93
- * @param array $links Default user links
94
- * @return array New user links
95
- */
96
- public function get_user_links( $links = array() ) {
97
- if ( ! is_user_logged_in() )
98
- return $links;
99
-
100
- $current_user = wp_get_current_user();
101
- if ( is_multisite() && empty( $current_user->roles ) )
102
- $current_user->roles = array( 'subscriber' );
103
-
104
- foreach( (array) $current_user->roles as $role ) {
105
- if ( $links = $this->get_option( $role ) );
106
- break;
107
- }
108
-
109
- // Define and allow filtering of replacement variables
110
- $replacements = apply_filters( 'tml_custom_user_links_variables', array(
111
- '%user_id%' => $current_user->ID,
112
- '%username%' => $current_user->user_nicename
113
- ) );
114
-
115
- // Replace variables in link
116
- foreach ( (array) $links as $key => $link ) {
117
- $links[$key]['url'] = Theme_My_Login_Common::replace_vars( $link['url'], $current_user->ID, $replacements );
118
- }
119
-
120
- return $links;
121
- }
122
- }
123
-
124
- Theme_My_Login_Custom_User_Links::get_object();
125
-
126
- endif;
127
-
128
- if ( is_admin() )
129
- include_once( dirname( __FILE__ ) . '/admin/custom-user-links-admin.php' );
130
-
1
+ <?php
2
+ /**
3
+ * 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
+ * Holds Theme My Login Custom User Links class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Custom_User_Links
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Custom_User_Links' ) ) :
14
+ /**
15
+ * Theme My Login Custom User Links module class
16
+ *
17
+ * Adds the ability to define custom links to display to a user when logged in based upon their "user role".
18
+ *
19
+ * @since 6.0
20
+ */
21
+ class Theme_My_Login_Custom_User_Links extends Theme_My_Login_Abstract {
22
+ /**
23
+ * Holds options key
24
+ *
25
+ * @since 6.3
26
+ * @access protected
27
+ * @var string
28
+ */
29
+ protected $options_key = 'theme_my_login_user_links';
30
+
31
+ /**
32
+ * Returns singleton instance
33
+ *
34
+ * @since 6.3
35
+ * @access public
36
+ * @return object
37
+ */
38
+ public static function get_object( $class = null ) {
39
+ return parent::get_object( __CLASS__ );
40
+ }
41
+
42
+ /**
43
+ * Returns default options
44
+ *
45
+ * @since 6.3
46
+ * @access public
47
+ *
48
+ * @return array Default options
49
+ */
50
+ public static function default_options() {
51
+ global $wp_roles;
52
+
53
+ if ( empty( $wp_roles ) )
54
+ $wp_roles = new WP_Roles;
55
+
56
+ $options = array();
57
+ foreach ( $wp_roles->get_names() as $role => $role_name ) {
58
+ if ( 'pending' != $role ) {
59
+ $options[$role] = array(
60
+ array(
61
+ 'title' => __( 'Dashboard', 'theme-my-login' ),
62
+ 'url' => admin_url()
63
+ ),
64
+ array(
65
+ 'title' => __( 'Profile', 'theme-my-login' ),
66
+ 'url' => admin_url( 'profile.php' )
67
+ )
68
+ );
69
+ }
70
+ }
71
+ return $options;
72
+ }
73
+
74
+ /**
75
+ * Loads the module
76
+ *
77
+ * @since 6.0
78
+ * @access protected
79
+ */
80
+ protected function load() {
81
+ add_filter( 'tml_user_links', array( $this, 'get_user_links' ) );
82
+ }
83
+
84
+ /**
85
+ * Gets the user links for the current user's role
86
+ *
87
+ * Callback for "tml_user_links" hook in method Theme_My_Login_Template::display()
88
+ *
89
+ * @see Theme_My_Login_Template::display()
90
+ * @since 6.0
91
+ * @access public
92
+ *
93
+ * @param array $links Default user links
94
+ * @return array New user links
95
+ */
96
+ public function get_user_links( $links = array() ) {
97
+ if ( ! is_user_logged_in() )
98
+ return $links;
99
+
100
+ $current_user = wp_get_current_user();
101
+ if ( is_multisite() && empty( $current_user->roles ) )
102
+ $current_user->roles = array( 'subscriber' );
103
+
104
+ foreach( (array) $current_user->roles as $role ) {
105
+ if ( $links = $this->get_option( $role ) );
106
+ break;
107
+ }
108
+
109
+ // Define and allow filtering of replacement variables
110
+ $replacements = apply_filters( 'tml_custom_user_links_variables', array(
111
+ '%user_id%' => $current_user->ID,
112
+ '%username%' => $current_user->user_nicename
113
+ ) );
114
+
115
+ // Replace variables in link
116
+ foreach ( (array) $links as $key => $link ) {
117
+ $links[$key]['url'] = Theme_My_Login_Common::replace_vars( $link['url'], $current_user->ID, $replacements );
118
+ }
119
+
120
+ return $links;
121
+ }
122
+ }
123
+
124
+ Theme_My_Login_Custom_User_Links::get_object();
125
+
126
+ endif;
127
+
128
+ if ( is_admin() )
129
+ include_once( dirname( __FILE__ ) . '/admin/custom-user-links-admin.php' );
130
+
modules/recaptcha/recaptcha.php CHANGED
@@ -83,7 +83,9 @@ class Theme_My_Login_Recaptcha extends Theme_My_Login_Abstract {
83
  * @since 6.3
84
  */
85
  function wp_enqueue_scripts() {
86
- wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js' );
 
 
87
  }
88
 
89
  /**
@@ -129,6 +131,11 @@ class Theme_My_Login_Recaptcha extends Theme_My_Login_Abstract {
129
  * @return array Signup parameters
130
  */
131
  public function wpmu_validate_signup( $result ) {
 
 
 
 
 
132
  $result['errors'] = $this->registration_errors( $result['errors'] );
133
  return $result;
134
  }
83
  * @since 6.3
84
  */
85
  function wp_enqueue_scripts() {
86
+ wp_enqueue_script( 'recaptcha', add_query_arg( array(
87
+ 'hl' => str_replace( '_', '-', get_locale() )
88
+ ), 'https://www.google.com/recaptcha/api.js' ) );
89
  }
90
 
91
  /**
131
  * @return array Signup parameters
132
  */
133
  public function wpmu_validate_signup( $result ) {
134
+ // Don't add errors if adding a user from wp-admin or WP-CLI
135
+ if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
136
+ return $result;
137
+ }
138
+
139
  $result['errors'] = $this->registration_errors( $result['errors'] );
140
  return $result;
141
  }
modules/security/admin/js/security-admin.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready( function($) {
2
- $('table .row-actions .unlock-user').parents('tr').children().css('background-color', '#ffebe8');
3
  } );
1
+ jQuery(document).ready( function($) {
2
+ $('table .row-actions .unlock-user').parents('tr').children().css('background-color', '#ffebe8');
3
  } );
modules/security/admin/security-admin.php CHANGED
@@ -1,313 +1,313 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Security Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Security
7
- * @since 6.0
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Security_Admin' ) ) :
11
- /**
12
- * Theme My Login Security Admin class
13
- *
14
- * @since 6.0
15
- */
16
- class Theme_My_Login_Security_Admin extends Theme_My_Login_Abstract {
17
- /**
18
- * Holds options key
19
- *
20
- * @ since 6.3
21
- * @access protected
22
- * @var string
23
- */
24
- protected $options_key = 'theme_my_login_security';
25
-
26
- /**
27
- * Returns singleton instance
28
- *
29
- * @since 6.3
30
- * @access public
31
- * @return object
32
- */
33
- public static function get_object( $class = null ) {
34
- return parent::get_object( __CLASS__ );
35
- }
36
-
37
- /**
38
- * Returns default options
39
- *
40
- * @since 6.3
41
- * @access public
42
- * @var array
43
- */
44
- public static function default_options() {
45
- return Theme_My_Login_Security::default_options();
46
- }
47
-
48
- /**
49
- * Loads the module
50
- *
51
- * @since 6.0
52
- * @access protected
53
- */
54
- protected function load() {
55
- add_action( 'tml_uninstall_security/security.php', array( $this, 'uninstall' ) );
56
-
57
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
58
- add_action( 'admin_init', array( $this, 'admin_init' ) );
59
-
60
- add_action( 'load-users.php', array( $this, 'load_users_page' ) );
61
- add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
62
- }
63
-
64
- /**
65
- * Uninstalls the module
66
- *
67
- * Callback for "tml_uninstall_security/security.php" hook in method Theme_My_Login_Admin::uninstall()
68
- *
69
- * @see Theme_My_Login_Admin::uninstall()
70
- * @since 6.3
71
- * @access public
72
- */
73
- public function uninstall() {
74
- delete_option( $this->options_key );
75
- }
76
-
77
- /**
78
-
79
- * Adds "Security" tab to Theme My Login menu
80
- *
81
- * Callback for "admin_menu" hook
82
- *
83
- * @since 6.0
84
- * @access public
85
- */
86
- public function admin_menu() {
87
- add_submenu_page(
88
- 'theme_my_login',
89
- __( 'Theme My Login Security Settings', 'theme-my-login' ),
90
- __( 'Security', 'theme-my-login' ),
91
- 'manage_options',
92
- $this->options_key,
93
- array( $this, 'settings_page' )
94
- );
95
-
96
- add_settings_section( 'general', null, '__return_false', $this->options_key );
97
-
98
- add_settings_field( 'private_site', __( 'Private Site', 'theme-my-login' ), array( $this, 'settings_field_private_site' ), $this->options_key, 'general' );
99
- add_settings_field( 'private_login', __( 'Private Login', 'theme-my-login' ), array( $this, 'settings_field_private_login' ), $this->options_key, 'general' );
100
- add_settings_field( 'login_attempts', __( 'Login Attempts', 'theme-my-login' ), array( $this, 'settings_field_login_attempts' ), $this->options_key, 'general' );
101
- }
102
-
103
- /**
104
- * Registers options group
105
- *
106
- * @since 6.3
107
- * @access public
108
- */
109
- public function admin_init() {
110
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
111
- }
112
-
113
- /**
114
- * Renders settings page
115
- *
116
- * @since 6.3
117
- * @access public
118
- */
119
- public function settings_page() {
120
- Theme_My_Login_Admin::settings_page( array(
121
- 'title' => __( 'Theme My Login Security Settings', 'theme-my-login' ),
122
- 'options_key' => $this->options_key
123
- ) );
124
- }
125
-
126
- /**
127
- * Renders Private Site settings field
128
- *
129
- * @since 6.3
130
- * @access public
131
- */
132
- public function settings_field_private_site() {
133
- ?>
134
- <input name="<?php echo $this->options_key; ?>[private_site]" type="checkbox" id="<?php echo $this->options_key; ?>_private_site" value="1"<?php checked( $this->get_option( 'private_site' ) ); ?> />
135
- <label for="<?php echo $this->options_key; ?>_private_site"><?php _e( 'Require users to be logged in to view site', 'theme-my-login' ); ?></label>
136
- <?php
137
- }
138
-
139
- /**
140
- * Renders Private Login settings field
141
- *
142
- * @since 6.3
143
- * @access public
144
- */
145
- public function settings_field_private_login() {
146
- ?>
147
- <input name="<?php echo $this->options_key; ?>[private_login]" type="checkbox" id="<?php echo $this->options_key; ?>_private_login" value="1"<?php checked( $this->get_option( 'private_login' ) ); ?> />
148
- <label for="<?php echo $this->options_key; ?>_private_login"><?php _e( 'Disable <tt>wp-login.php</tt>', 'theme-my-login' ); ?></label>
149
- <?php
150
- }
151
-
152
- /**
153
- * Renders Login Attempts settings field
154
- *
155
- * @since 6.3
156
- * @access public
157
- */
158
- public function settings_field_login_attempts() {
159
- // Units
160
- $units = array(
161
- 'minute' => __( 'minute(s)', 'theme-my-login' ),
162
- 'hour' => __( 'hour(s)', 'theme-my-login' ),
163
- 'day' => __( 'day(s)', 'theme-my-login' )
164
- );
165
-
166
- // Threshold
167
- $threshold = '<input type="text" name="' . $this->options_key . '[failed_login][threshold]" id="' . $this->options_key . '_failed_login_threshold" value="' . $this->get_option( array( 'failed_login', 'threshold' ) ) . '" size="1" />';
168
-
169
- // Threshold duration
170
- $threshold_duration = '<input type="text" name="' . $this->options_key . '[failed_login][threshold_duration]" id="' . $this->options_key . '_failed_login_threshold_duration" value="' . $this->get_option( array( 'failed_login', 'threshold_duration' ) ) . '" size="1" />';
171
-
172
- // Threshold duration unit
173
- $threshold_duration_unit = '<select name="' . $this->options_key . '[failed_login][threshold_duration_unit]" id="' . $this->options_key . '_failed_login_threshold_duration_unit">';
174
- foreach ( $units as $unit => $label ) {
175
- $threshold_duration_unit .= '<option value="' . $unit . '"' . selected( $this->get_option( array( 'failed_login', 'threshold_duration_unit' ) ), $unit, false ) . '>' . $label . '</option>';
176
- }
177
- $threshold_duration_unit .= '</select>';
178
-
179
- // Lockout duration
180
- $lockout_duration = '<input type="text" name="' . $this->options_key . '[failed_login][lockout_duration]" id="' . $this->options_key . '_failed_login_lockout_duration" value="' . $this->get_option( array( 'failed_login', 'lockout_duration' ) ) . '" size="1" />';
181
-
182
- // Lockout duration unit
183
- $lockout_duration_unit = '<select name="' . $this->options_key . '[failed_login][lockout_duration_unit]" id="' . $this->options_key . '_failed_login_lockout_duration_unit">';
184
- foreach ( $units as $unit => $label ) {
185
- $lockout_duration_unit .= '<option value="' . $unit . '"' . selected( $this->get_option( array( 'failed_login', 'lockout_duration_unit' ) ), $unit, false ) . '>' . $label . '</option>';
186
- }
187
- $lockout_duration_unit .= '</select>';
188
-
189
- // Output them all
190
- printf( __( 'After %1$s failed login attempts within %2$s %3$s, lockout the account for %4$s %5$s.', 'theme-my-login' ), $threshold, $threshold_duration, $threshold_duration_unit, $lockout_duration, $lockout_duration_unit );
191
- }
192
-
193
- /**
194
- * Sanitizes settings
195
- *
196
- * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
197
- *
198
- * @see Theme_My_Login_Admin::save_settings()
199
- * @since 6.0
200
- * @access public
201
- *
202
- * @param string|array $settings Settings passed in from filter
203
- * @return string|array Sanitized settings
204
- */
205
- public function save_settings( $settings ) {
206
- return array(
207
- 'private_site' => ! empty( $settings['private_site'] ),
208
- 'private_login' => ! empty( $settings['private_login'] ),
209
- 'failed_login' => array(
210
- 'threshold' => absint( $settings['failed_login']['threshold'] ),
211
- 'threshold_duration' => absint( $settings['failed_login']['threshold_duration'] ),
212
- 'threshold_duration_unit' => $settings['failed_login']['threshold_duration_unit'],
213
- 'lockout_duration' => absint( $settings['failed_login']['lockout_duration'] ),
214
- 'lockout_duration_unit' => $settings['failed_login']['lockout_duration_unit']
215
- )
216
- );
217
- }
218
-
219
- /**
220
- * Attaches actions/filters explicitly to "users.php"
221
- *
222
- * Callback for "load-users.php" hook
223
- *
224
- * @since 6.0
225
- * @access public
226
- */
227
- public function load_users_page() {
228
-
229
- $security = Theme_My_Login_Security::get_object();
230
-
231
- wp_enqueue_script( 'tml-security-admin', plugins_url( 'js/security-admin.js', __FILE__ ), array( 'jquery' ) );
232
-
233
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
234
-
235
- if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'lock', 'unlock' ) ) ) {
236
-
237
- $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
238
- $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
239
-
240
- if ( ! $user || ! current_user_can( 'edit_user', $user ) )
241
- wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
242
-
243
- if ( ! $user = get_userdata( $user ) )
244
- wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
245
-
246
- if ( 'lock' == $_GET['action'] ) {
247
- check_admin_referer( 'lock-user_' . $user->ID );
248
-
249
- $security->lock_user( $user );
250
-
251
- $redirect_to = add_query_arg( 'update', 'lock', $redirect_to );
252
- } elseif ( 'unlock' == $_GET['action'] ) {
253
- check_admin_referer( 'unlock-user_' . $user->ID );
254
-
255
- $security->unlock_user( $user );
256
-
257
- $redirect_to = add_query_arg( 'update', 'unlock', $redirect_to );
258
- }
259
-
260
- wp_redirect( $redirect_to );
261
- exit;
262
- }
263
- }
264
-
265
- /**
266
- * Adds update messages to the admin screen
267
- *
268
- * Callback for "admin_notices" hook in file admin-header.php
269
- *
270
- * @since 6.0
271
- * @access public
272
- */
273
- public function admin_notices() {
274
- if ( isset( $_GET['update'] ) ) {
275
- if ( 'lock' == $_GET['update'] )
276
- echo '<div id="message" class="updated fade"><p>' . __( 'User locked.', 'theme-my-login' ) . '</p></div>';
277
- elseif ( 'unlock' == $_GET['update'] )
278
- echo '<div id="message" class="updated fade"><p>' . __( 'User unlocked.', 'theme-my-login' ) . '</p></div>';
279
- }
280
- }
281
-
282
- /**
283
- * Adds "Lock" and "Unlock" links for each pending user on users.php
284
- *
285
- * Callback for "user_row_actions" hook in {@internal unknown}
286
- *
287
- * @since 6.0
288
- * @access public
289
- *
290
- * @param array $actions The user actions
291
- * @param WP_User $user_object The current user object
292
- * @return array The filtered user actions
293
- */
294
- public function user_row_actions( $actions, $user_object ) {
295
- $current_user = wp_get_current_user();
296
-
297
- $security_meta = isset( $user_object->theme_my_login_security ) ? (array) $user_object->theme_my_login_security : array();
298
-
299
- if ( $current_user->ID != $user_object->ID ) {
300
- if ( isset( $security_meta['is_locked'] ) && $security_meta['is_locked'] )
301
- $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', 'theme-my-login' ) . '</a>';
302
- else
303
- $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', 'theme-my-login' ) . '</a>';
304
- $actions = array_merge( $new_actions, $actions );
305
- }
306
- return $actions;
307
- }
308
- }
309
-
310
- Theme_My_Login_Security_Admin::get_object();
311
-
312
- endif;
313
-
1
+ <?php
2
+ /**
3
+ * Holds Theme My Login Security Admin class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @subpackage Theme_My_Login_Security
7
+ * @since 6.0
8
+ */
9
+
10
+ if ( ! class_exists( 'Theme_My_Login_Security_Admin' ) ) :
11
+ /**
12
+ * Theme My Login Security Admin class
13
+ *
14
+ * @since 6.0
15
+ */
16
+ class Theme_My_Login_Security_Admin extends Theme_My_Login_Abstract {
17
+ /**
18
+ * Holds options key
19
+ *
20
+ * @ since 6.3
21
+ * @access protected
22
+ * @var string
23
+ */
24
+ protected $options_key = 'theme_my_login_security';
25
+
26
+ /**
27
+ * Returns singleton instance
28
+ *
29
+ * @since 6.3
30
+ * @access public
31
+ * @return object
32
+ */
33
+ public static function get_object( $class = null ) {
34
+ return parent::get_object( __CLASS__ );
35
+ }
36
+
37
+ /**
38
+ * Returns default options
39
+ *
40
+ * @since 6.3
41
+ * @access public
42
+ * @var array
43
+ */
44
+ public static function default_options() {
45
+ return Theme_My_Login_Security::default_options();
46
+ }
47
+
48
+ /**
49
+ * Loads the module
50
+ *
51
+ * @since 6.0
52
+ * @access protected
53
+ */
54
+ protected function load() {
55
+ add_action( 'tml_uninstall_security/security.php', array( $this, 'uninstall' ) );
56
+
57
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
58
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
59
+
60
+ add_action( 'load-users.php', array( $this, 'load_users_page' ) );
61
+ add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
62
+ }
63
+
64
+ /**
65
+ * Uninstalls the module
66
+ *
67
+ * Callback for "tml_uninstall_security/security.php" hook in method Theme_My_Login_Admin::uninstall()
68
+ *
69
+ * @see Theme_My_Login_Admin::uninstall()
70
+ * @since 6.3
71
+ * @access public
72
+ */
73
+ public function uninstall() {
74
+ delete_option( $this->options_key );
75
+ }
76
+
77
+ /**
78
+
79
+ * Adds "Security" tab to Theme My Login menu
80
+ *
81
+ * Callback for "admin_menu" hook
82
+ *
83
+ * @since 6.0
84
+ * @access public
85
+ */
86
+ public function admin_menu() {
87
+ add_submenu_page(
88
+ 'theme_my_login',
89
+ __( 'Theme My Login Security Settings', 'theme-my-login' ),
90
+ __( 'Security', 'theme-my-login' ),
91
+ 'manage_options',
92
+ $this->options_key,
93
+ array( $this, 'settings_page' )
94
+ );
95
+
96
+ add_settings_section( 'general', null, '__return_false', $this->options_key );
97
+
98
+ add_settings_field( 'private_site', __( 'Private Site', 'theme-my-login' ), array( $this, 'settings_field_private_site' ), $this->options_key, 'general' );
99
+ add_settings_field( 'private_login', __( 'Private Login', 'theme-my-login' ), array( $this, 'settings_field_private_login' ), $this->options_key, 'general' );
100
+ add_settings_field( 'login_attempts', __( 'Login Attempts', 'theme-my-login' ), array( $this, 'settings_field_login_attempts' ), $this->options_key, 'general' );
101
+ }
102
+
103
+ /**
104
+ * Registers options group
105
+ *
106
+ * @since 6.3
107
+ * @access public
108
+ */
109
+ public function admin_init() {
110
+ register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
111
+ }
112
+
113
+ /**
114
+ * Renders settings page
115
+ *
116
+ * @since 6.3
117
+ * @access public
118
+ */
119
+ public function settings_page() {
120
+ Theme_My_Login_Admin::settings_page( array(
121
+ 'title' => __( 'Theme My Login Security Settings', 'theme-my-login' ),
122
+ 'options_key' => $this->options_key
123
+ ) );
124
+ }
125
+
126
+ /**
127
+ * Renders Private Site settings field
128
+ *
129
+ * @since 6.3
130
+ * @access public
131
+ */
132
+ public function settings_field_private_site() {
133
+ ?>
134
+ <input name="<?php echo $this->options_key; ?>[private_site]" type="checkbox" id="<?php echo $this->options_key; ?>_private_site" value="1"<?php checked( $this->get_option( 'private_site' ) ); ?> />
135
+ <label for="<?php echo $this->options_key; ?>_private_site"><?php _e( 'Require users to be logged in to view site', 'theme-my-login' ); ?></label>
136
+ <?php
137
+ }
138
+
139
+ /**
140
+ * Renders Private Login settings field
141
+ *
142
+ * @since 6.3
143
+ * @access public
144
+ */
145
+ public function settings_field_private_login() {
146
+ ?>
147
+ <input name="<?php echo $this->options_key; ?>[private_login]" type="checkbox" id="<?php echo $this->options_key; ?>_private_login" value="1"<?php checked( $this->get_option( 'private_login' ) ); ?> />
148
+ <label for="<?php echo $this->options_key; ?>_private_login"><?php _e( 'Disable <tt>wp-login.php</tt>', 'theme-my-login' ); ?></label>
149
+ <?php
150
+ }
151
+
152
+ /**
153
+ * Renders Login Attempts settings field
154
+ *
155
+ * @since 6.3
156
+ * @access public
157
+ */
158
+ public function settings_field_login_attempts() {
159
+ // Units
160
+ $units = array(
161
+ 'minute' => __( 'minute(s)', 'theme-my-login' ),
162
+ 'hour' => __( 'hour(s)', 'theme-my-login' ),
163
+ 'day' => __( 'day(s)', 'theme-my-login' )
164
+ );
165
+
166
+ // Threshold
167
+ $threshold = '<input type="text" name="' . $this->options_key . '[failed_login][threshold]" id="' . $this->options_key . '_failed_login_threshold" value="' . $this->get_option( array( 'failed_login', 'threshold' ) ) . '" size="1" />';
168
+
169
+ // Threshold duration
170
+ $threshold_duration = '<input type="text" name="' . $this->options_key . '[failed_login][threshold_duration]" id="' . $this->options_key . '_failed_login_threshold_duration" value="' . $this->get_option( array( 'failed_login', 'threshold_duration' ) ) . '" size="1" />';
171
+
172
+ // Threshold duration unit
173
+ $threshold_duration_unit = '<select name="' . $this->options_key . '[failed_login][threshold_duration_unit]" id="' . $this->options_key . '_failed_login_threshold_duration_unit">';
174
+ foreach ( $units as $unit => $label ) {
175
+ $threshold_duration_unit .= '<option value="' . $unit . '"' . selected( $this->get_option( array( 'failed_login', 'threshold_duration_unit' ) ), $unit, false ) . '>' . $label . '</option>';
176
+ }
177
+ $threshold_duration_unit .= '</select>';
178
+
179
+ // Lockout duration
180
+ $lockout_duration = '<input type="text" name="' . $this->options_key . '[failed_login][lockout_duration]" id="' . $this->options_key . '_failed_login_lockout_duration" value="' . $this->get_option( array( 'failed_login', 'lockout_duration' ) ) . '" size="1" />';
181
+
182
+ // Lockout duration unit
183
+ $lockout_duration_unit = '<select name="' . $this->options_key . '[failed_login][lockout_duration_unit]" id="' . $this->options_key . '_failed_login_lockout_duration_unit">';
184
+ foreach ( $units as $unit => $label ) {
185
+ $lockout_duration_unit .= '<option value="' . $unit . '"' . selected( $this->get_option( array( 'failed_login', 'lockout_duration_unit' ) ), $unit, false ) . '>' . $label . '</option>';
186
+ }
187
+ $lockout_duration_unit .= '</select>';
188
+
189
+ // Output them all
190
+ printf( __( 'After %1$s failed login attempts within %2$s %3$s, lockout the account for %4$s %5$s.', 'theme-my-login' ), $threshold, $threshold_duration, $threshold_duration_unit, $lockout_duration, $lockout_duration_unit );
191
+ }
192
+
193
+ /**
194
+ * Sanitizes settings
195
+ *
196
+ * Callback for "tml_save_settings" hook in method Theme_My_Login_Admin::save_settings()
197
+ *
198
+ * @see Theme_My_Login_Admin::save_settings()
199
+ * @since 6.0
200
+ * @access public
201
+ *
202
+ * @param string|array $settings Settings passed in from filter
203
+ * @return string|array Sanitized settings
204
+ */
205
+ public function save_settings( $settings ) {
206
+ return array(
207
+ 'private_site' => ! empty( $settings['private_site'] ),
208
+ 'private_login' => ! empty( $settings['private_login'] ),
209
+ 'failed_login' => array(
210
+ 'threshold' => absint( $settings['failed_login']['threshold'] ),
211
+ 'threshold_duration' => absint( $settings['failed_login']['threshold_duration'] ),
212
+ 'threshold_duration_unit' => $settings['failed_login']['threshold_duration_unit'],
213
+ 'lockout_duration' => absint( $settings['failed_login']['lockout_duration'] ),
214
+ 'lockout_duration_unit' => $settings['failed_login']['lockout_duration_unit']
215
+ )
216
+ );
217
+ }
218
+
219
+ /**
220
+ * Attaches actions/filters explicitly to "users.php"
221
+ *
222
+ * Callback for "load-users.php" hook
223
+ *
224
+ * @since 6.0
225
+ * @access public
226
+ */
227
+ public function load_users_page() {
228
+
229
+ $security = Theme_My_Login_Security::get_object();
230
+
231
+ wp_enqueue_script( 'tml-security-admin', plugins_url( 'js/security-admin.js', __FILE__ ), array( 'jquery' ) );
232
+
233
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
234
+
235
+ if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'lock', 'unlock' ) ) ) {
236
+
237
+ $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
238
+ $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
239
+
240
+ if ( ! $user || ! current_user_can( 'edit_user', $user ) )
241
+ wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
242
+
243
+ if ( ! $user = get_userdata( $user ) )
244
+ wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
245
+
246
+ if ( 'lock' == $_GET['action'] ) {
247
+ check_admin_referer( 'lock-user_' . $user->ID );
248
+
249
+ $security->lock_user( $user );
250
+
251
+ $redirect_to = add_query_arg( 'update', 'lock', $redirect_to );
252
+ } elseif ( 'unlock' == $_GET['action'] ) {
253
+ check_admin_referer( 'unlock-user_' . $user->ID );
254
+
255
+ $security->unlock_user( $user );
256
+
257
+ $redirect_to = add_query_arg( 'update', 'unlock', $redirect_to );
258
+ }
259
+
260
+ wp_redirect( $redirect_to );
261
+ exit;
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Adds update messages to the admin screen
267
+ *
268
+ * Callback for "admin_notices" hook in file admin-header.php
269
+ *
270
+ * @since 6.0
271
+ * @access public
272
+ */
273
+ public function admin_notices() {
274
+ if ( isset( $_GET['update'] ) ) {
275
+ if ( 'lock' == $_GET['update'] )
276
+ echo '<div id="message" class="updated fade"><p>' . __( 'User locked.', 'theme-my-login' ) . '</p></div>';
277
+ elseif ( 'unlock' == $_GET['update'] )
278
+ echo '<div id="message" class="updated fade"><p>' . __( 'User unlocked.', 'theme-my-login' ) . '</p></div>';
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Adds "Lock" and "Unlock" links for each pending user on users.php
284
+ *
285
+ * Callback for "user_row_actions" hook in {@internal unknown}
286
+ *
287
+ * @since 6.0
288
+ * @access public
289
+ *
290
+ * @param array $actions The user actions
291
+ * @param WP_User $user_object The current user object
292
+ * @return array The filtered user actions
293
+ */
294
+ public function user_row_actions( $actions, $user_object ) {
295
+ $current_user = wp_get_current_user();
296
+
297
+ $security_meta = isset( $user_object->theme_my_login_security ) ? (array) $user_object->theme_my_login_security : array();
298
+
299
+ if ( $current_user->ID != $user_object->ID ) {
300
+ if ( isset( $security_meta['is_locked'] ) && $security_meta['is_locked'] )
301
+ $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', 'theme-my-login' ) . '</a>';
302
+ else
303
+ $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', 'theme-my-login' ) . '</a>';
304
+ $actions = array_merge( $new_actions, $actions );
305
+ }
306
+ return $actions;
307
+ }
308
+ }
309
+
310
+ Theme_My_Login_Security_Admin::get_object();
311
+
312
+ endif;
313
+
modules/security/security.php CHANGED
@@ -1,623 +1,623 @@
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
- * Holds Theme My Login Security class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Security
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Security' ) ) :
14
- /**
15
- * Theme My Login Security module class
16
- *
17
- * Adds options to help protect your site.
18
- *
19
- * @since 6.0
20
- */
21
- class Theme_My_Login_Security extends Theme_My_Login_Abstract {
22
- /**
23
- * Holds options key
24
- *
25
- * @since 6.3
26
- * @access protected
27
- * @var string
28
- */
29
- protected $options_key = 'theme_my_login_security';
30
-
31
- /**
32
- * Returns singleton instance
33
- *
34
- * @since 6.3
35
- * @access public
36
- * @return object
37
- */
38
- public static function get_object( $class = null ) {
39
- return parent::get_object( __CLASS__ );
40
- }
41
-
42
- /**
43
- * Returns default options
44
- *
45
- * @since 6.0
46
- * @access public
47
- *
48
- * @return array Default options
49
- */
50
- public static function default_options() {
51
- return array(
52
- 'private_site' => 0,
53
- 'private_login' => 0,
54
- 'failed_login' => array(
55
- 'threshold' => 5,
56
- 'threshold_duration' => 1,
57
- 'threshold_duration_unit' => 'hour',
58
- 'lockout_duration' => 24,
59
- 'lockout_duration_unit' => 'hour'
60
- )
61
- );
62
- }
63
-
64
- /**
65
- * Loads the module
66
- *
67
- * @since 6.0
68
- * @access protected
69
- */
70
- protected function load() {
71
- add_action( 'init', array( $this, 'init' ) );
72
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
73
- add_action( 'tml_request_unlock', array( $this, 'request_unlock' ) );
74
- add_action( 'tml_request', array( $this, 'action_messages' ) );
75
-
76
- add_action( 'authenticate', array( $this, 'authenticate' ), 100, 3 );
77
- add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ), 10, 2 );
78
-
79
- add_action( 'show_user_profile', array( $this, 'show_user_profile' ) );
80
- add_action( 'edit_user_profile', array( $this, 'show_user_profile' ) );
81
-
82
- add_filter( 'show_admin_bar', array( $this, 'show_admin_bar' ) );
83
- }
84
-
85
- /**
86
- * Sets a 404 error for wp-login.php if it's disabled
87
- *
88
- * @since 6.3
89
- * @access public
90
- */
91
- public function init() {
92
- global $wp_query, $pagenow;
93
-
94
- if ( 'wp-login.php' == $pagenow && $this->get_option( 'private_login' ) ) {
95
-
96
- parse_str( $_SERVER['QUERY_STRING'], $q );
97
- if ( ! empty( $q['interim-login'] ) || ! empty( $_REQUEST['interim-login'] ) )
98
- return;
99
-
100
- $pagenow = 'index.php';
101
- $wp_query->set_404();
102
- status_header( 404 );
103
- nocache_headers();
104
- if ( ! $template = get_404_template() )
105
- $template = 'index.php';
106
- include( $template );
107
- exit;
108
- }
109
- }
110
-
111
- /**
112
- * Blocks entire site if user is not logged in and private site is enabled
113
- *
114
- * Callback for "template_redirect" hook in the file wp-settings.php
115
- *
116
- * @since 6.2
117
- * @access public
118
- */
119
- public function template_redirect() {
120
- if ( $this->get_option( 'private_site' ) ) {
121
- if ( ! ( is_user_logged_in() || Theme_My_Login::is_tml_page() ) ) {
122
- $redirect_to = apply_filters( 'tml_security_private_site_redirect', wp_login_url( $_SERVER['REQUEST_URI'], true ) );
123
- wp_safe_redirect( $redirect_to );
124
- exit;
125
- }
126
- }
127
- }
128
-
129
- /**
130
- * Handles "unlock" action for login page
131
- *
132
- * Callback for "tml_request_activate" hook in method Theme_My_Login::the_request();
133
- *
134
- * @see Theme_My_Login::the_request();
135
- * @since 6.3
136
- */
137
- public function request_unlock() {
138
- $user = self::check_user_unlock_key( $_GET['key'], $_GET['login'] );
139
-
140
- $redirect_to = Theme_My_Login_Common::get_current_url();
141
-
142
- if ( is_wp_error( $user ) ) {
143
- $redirect_to = add_query_arg( 'unlock', 'invalidkey', $redirect_to );
144
- wp_redirect( $redirect_to );
145
- exit;
146
- }
147
-
148
- self::unlock_user( $user->ID );
149
-
150
- $redirect_to = add_query_arg( 'unlock', 'complete', $redirect_to );
151
- wp_redirect( $redirect_to );
152
- exit;
153
- }
154
-
155
- /**
156
- * Handles display of various action/status messages
157
- *
158
- * Callback for "tml_request" hook in Theme_My_Login::the_request()
159
- *
160
- * @since 6.3
161
- * @access public
162
- *
163
- * @param object $theme_my_login Reference to global $theme_my_login object
164
- */
165
- public function action_messages( &$theme_my_login ) {
166
- if ( isset( $_GET['unlock'] ) && 'complete' == $_GET['unlock'] )
167
- $theme_my_login->errors->add( 'unlock_complete', __( 'Your account has been unlocked. You may now log in.', 'theme-my-login' ), 'message' );
168
- }
169
-
170
- /**
171
- * Validates a user unlock key
172
- *
173
- * @since 6.3
174
- *
175
- * @param string $key Unlock key
176
- * @param string $login User login
177
- * @return WP_User|WP_Error WP_User object on success, WP_Error object on failure
178
- */
179
- public static function check_user_unlock_key( $key, $login ) {
180
- global $wpdb;
181
-
182
- $key = preg_replace( '/[^a-z0-9]/i', '', $key );
183
-
184
- if ( empty( $key ) || ! is_string( $key ) )
185
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
186
-
187
- if ( empty( $login ) || ! is_string( $login ) )
188
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
189
-
190
- if ( ! $user = get_user_by( 'login', $login ) )
191
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
192
-
193
- if ( $key != self::get_user_unlock_key( $user->ID ) )
194
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
195
-
196
- return $user;
197
- }
198
-
199
- /**
200
- * Blocks locked users from logging in
201
- *
202
- * Callback for "authenticate" hook in function wp_authenticate()
203
- *
204
- * @see wp_authenticate()
205
- * @since 6.0
206
- * @access public
207
- *
208
- * @param WP_User $user WP_User object
209
- * @param string $username Username posted
210
- * @param string $password Password posted
211
- * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
212
- */
213
- public function authenticate( $user, $username, $password ) {
214
- // Make sure user exists
215
- if ( ! $userdata = get_user_by( 'login', $username ) )
216
- return $user;
217
-
218
- // Current time
219
- $time = time();
220
-
221
- if ( self::is_user_locked( $userdata->ID ) ) {
222
- if ( $expiration = self::get_user_lock_expiration( $userdata->ID ) ) {
223
- if ( $time > $expiration )
224
- self::unlock_user( $userdata->ID );
225
- else
226
- 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.', 'theme-my-login' ), human_time_diff( $time, $expiration ) ) );
227
- } else {
228
- return new WP_Error( 'locked_account', __( '<strong>ERROR</strong>: This account has been locked.', 'theme-my-login' ) );
229
- }
230
- } elseif ( is_wp_error( $user ) && 'incorrect_password' == $user->get_error_code() ) {
231
- // Get the attempts
232
- $attempts = self::get_failed_login_attempts( $userdata->ID );
233
-
234
- // Get the first valid attempt
235
- $first_attempt = reset( $attempts );
236
-
237
- // Get the relative duration
238
- $duration = $first_attempt['time'] + self::get_seconds_from_unit( $this->get_option( array( 'failed_login', 'threshold_duration' ) ), $this->get_option( array( 'failed_login', 'threshold_duration_unit' ) ) );
239
-
240
- // If current time is less than relative duration time, we're still within the defensive zone
241
- if ( $time < $duration ) {
242
- // Log this attempt
243
- self::add_failed_login_attempt( $userdata->ID, $time );
244
- // If failed attempts reach treshold, lock the account
245
- if ( self::get_failed_login_attempt_count( $userdata->ID ) >= $this->get_option( array( 'failed_login', 'threshold' ) ) ) {
246
- // Create new expiration
247
- $expiration = $time + self::get_seconds_from_unit( $this->get_option( array( 'failed_login', 'lockout_duration' ) ), $this->get_option( array( 'failed_login', 'lockout_duration_unit' ) ) );
248
- self::lock_user( $userdata->ID, $expiration );
249
- 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.', 'theme-my-login' ), human_time_diff( $time, $expiration ) ) );
250
- }
251
- } else {
252
- // Clear the attempts
253
- self::reset_failed_login_attempts( $userdata->ID );
254
- // Log this attempt
255
- self::add_failed_login_attempt( $userdata->ID, $time );
256
- }
257
- }
258
- return $user;
259
- }
260
-
261
- /**
262
- * Blocks locked users from resetting their password, if locked by admin
263
- *
264
- * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
265
- *
266
- * @see Theme_My_Login::retrieve_password()
267
- * @since 6.0
268
- * @access public
269
- *
270
- * @param bool $allow Default setting
271
- * @param int $user_id User ID
272
- * @return bool Whether to allow password reset or not
273
- */
274
- public function allow_password_reset( $allow, $user_id ) {
275
- if ( self::is_user_locked( $user_id ) && ! self::get_user_lock_expiration( $user_id ) )
276
- $allow = false;
277
- return $allow;
278
- }
279
-
280
- /**
281
- * Displays failed login attempts on users profile for administrators
282
- *
283
- * @since 6.2
284
- * @access public
285
- *
286
- * @param object $profileuser User object
287
- */
288
- public function show_user_profile( $profileuser ) {
289
- if ( ! current_user_can( 'manage_users' ) )
290
- return;
291
-
292
- if ( $failed_login_attempts = self::get_failed_login_attempts( $profileuser->ID ) ) : ?>
293
- <h3><?php _e( 'Failed Login Attempts', 'theme-my-login' ); ?></h3>
294
-
295
- <table class="form-table">
296
- <tr>
297
- <th scope="col"><?php _e( 'IP Address', 'theme-my-login' ); ?></th>
298
- <th scope="col"><?php _e( 'Date', 'theme-my-login' ); ?></th>
299
- </tr>
300
- <?php foreach ( $failed_login_attempts as $attempt ) :
301
- $t_time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
302
-
303
- $time_diff = time() - $attempt['time'];
304
-
305
- if ( $time_diff > 0 && $time_diff < 24*60*60 )
306
- $h_time = sprintf( __( '%s ago', 'theme-my-login' ), human_time_diff( $attempt['time'] ) );
307
- else
308
- $h_time = date_i18n( __( 'Y/m/d', 'theme-my-login' ), $attempt['time'] );
309
- ?>
310
- <tr>
311
- <td><?php echo $attempt['ip']; ?></td>
312
- <td><abbr title="<?php echo $t_time; ?>"><?php echo $h_time; ?></abbr></td>
313
- </tr>
314
- <?php endforeach; ?>
315
- </table>
316
- <?php endif;
317
- }
318
-
319
- /**
320
- * Shows admin bar for wp-login.php when it is disabled
321
- *
322
- * @since 6.3
323
- * @access public
324
- *
325
- * @param bool $show True to show admin bar, false to hide
326
- * @return bool True to show admin bar, false to hide
327
- */
328
- public function show_admin_bar( $show ) {
329
- global $pagenow;
330
-
331
- if ( is_user_logged_in() && 'wp-login.php' == $pagenow && $this->get_option( 'private_login' ) )
332
- return true;
333
- return $show;
334
- }
335
-
336
- /**
337
- * Locks a user
338
- *
339
- * @since 6.0
340
- * @access public
341
- *
342
- * @param int|WP_User $user User ID ir WP_User object
343
- * @param int $expires When the lock expires, in seconds from current time
344
- */
345
- public static function lock_user( $user, $expires = 0 ) {
346
- if ( is_object( $user ) )
347
- $user = $user->ID;
348
-
349
- $user = (int) $user;
350
-
351
- do_action( 'tml_lock_user', $user );
352
-
353
- $security = self::get_security_meta( $user );
354
-
355
- $security['is_locked'] = true;
356
- $security['lock_expiration'] = absint( $expires );
357
- $security['unlock_key'] = wp_generate_password( 20, false );
358
-
359
- update_user_meta( $user, 'theme_my_login_security', $security );
360
-
361
- if ( $expires )
362
- self::user_lock_notification( $user );
363
- }
364
-
365
- /**
366
- * Unlocks a user
367
- *
368
- * @since 6.0
369
- * @access public
370
- *
371
- * @param int|WP_User $user User ID or WP_User object
372
- */
373
- public static function unlock_user( $user ) {
374
- if ( is_object( $user ) )
375
- $user = $user->ID;
376
-
377
- $user = (int) $user;
378
-
379
- do_action( 'tml_unlock_user', $user );
380
-
381
- $security = self::get_security_meta( $user );
382
-
383
- $security['is_locked'] = false;
384
- $security['lock_expiration'] = 0;
385
- $security['unlock_key'] = '';
386
- $security['failed_login_attempts'] = array();
387
-
388
- return update_user_meta( $user, 'theme_my_login_security', $security );
389
- }
390
-
391
- /**
392
- * Determine if a user is locked or not
393
- *
394
- * @since 6.0
395
- * @access public
396
- *
397
- * @param int|WP_User $user User ID or WP_User object
398
- * @return bool True if user is locked, false if not
399
- */
400
- public static function is_user_locked( $user ) {
401
- if ( is_object( $user ) )
402
- $user = $user->ID;
403
-
404
- $user = (int) $user;
405
-
406
- $security = self::get_security_meta( $user );
407
-
408
- // If "is_locked" is not set, there is no lock
409
- if ( ! $security['is_locked'] )
410
- return false;
411
-
412
- // If "lock_expires" is not set, there is a lock but no expiry
413
- if ( ! $expires = self::get_user_lock_expiration( $user ) )
414
- return true;
415
-
416
- // We have a lock with an expiry
417
- $time = time();
418
- if ( $time > $expires ) {
419
- self::unlock_user( $user );
420
- return false;
421
- }
422
-
423
- return true;
424
- }
425
-
426
- /**
427
- * Get a user's security meta
428
- *
429
- * @since 6.0
430
- * @access protected
431
- *
432
- * @param int $user_id User ID
433
- * @return array User's security meta
434
- */
435
- protected static function get_security_meta( $user_id ) {
436
- $defaults = array(
437
- 'is_locked' => false,
438
- 'lock_expiration' => 0,
439
- 'unlock_key' => '',
440
- 'failed_login_attempts' => array()
441
- );
442
- $meta = get_user_meta( $user_id, 'theme_my_login_security', true );
443
- if ( ! is_array( $meta ) )
444
- $meta = array();
445
-
446
- return array_merge( $defaults, $meta );
447
- }
448
-
449
- /**
450
- * Get a user's failed login attempts
451
- *
452
- * @since 6.0
453
- * @access public
454
- *
455
- * @param int $user_id User ID
456
- * @return array User's failed login attempts
457
- */
458
- public static function get_failed_login_attempts( $user_id ) {
459
- $security_meta = self::get_security_meta( $user_id );
460
- return $security_meta['failed_login_attempts'];
461
- }
462
-
463
- /**
464
- * Reset a user's failed login attempts
465
- *
466
- * @since 6.0
467
- * @access public
468
- *
469
- * @param int $user_id User ID
470
- */
471
- public static function reset_failed_login_attempts( $user_id ) {
472
- $security_meta = self::get_security_meta( $user_id );
473
- $security_meta['failed_login_attempts'] = array();
474
- return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
475
- }
476
-
477
- /**
478
- * Get a user's failed login attempt count
479
- *
480
- * @since 6.0
481
- * @access public
482
- *
483
- * @param int $user_id User ID
484
- * @return int Number of user's failed login attempts
485
- */
486
- public static function get_failed_login_attempt_count( $user_id ) {
487
- return count( self::get_failed_login_attempts( $user_id ) );
488
- }
489
-
490
- /**
491
- * Add a failed login attempt to a user
492
- *
493
- * @since 6.0
494
- * @access public
495
- *
496
- * @param int $user_id User ID
497
- * @param int $time Time of attempt, in seconds
498
- * @param string $ip IP address of attempt
499
- */
500
- public static function add_failed_login_attempt( $user_id, $time = '', $ip = '' ) {
501
- $security_meta = self::get_security_meta( $user_id );
502
- if ( ! is_array( $security_meta['failed_login_attempts'] ) )
503
- $security_meta['failed_login_attempts'] = array();
504
-
505
- $time = absint( $time );
506
-
507
- if ( empty( $time ) )
508
- $time = time();
509
-
510
- if ( empty( $ip ) )
511
- $ip = $_SERVER['REMOTE_ADDR'];
512
-
513
- $security_meta['failed_login_attempts'][] = array( 'time' => $time, 'ip' => $ip );
514
-
515
- return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
516
- }
517
-
518
- /**
519
- * Get user's lock expiration time
520
- *
521
- * @since 6.0
522
- * @access public
523
- *
524
- * @param int $user_id User ID
525
- * @return int User's lock expiration time
526
- */
527
- public static function get_user_lock_expiration( $user_id ) {
528
- $security_meta = self::get_security_meta( $user_id );
529
- return apply_filters( 'tml_user_lock_expiration', absint( $security_meta['lock_expiration'] ), $user_id );
530
- }
531
-
532
- /**
533
- * Get a user's unlock key
534
- *
535
- * @since 6.3
536
- *
537
- * @param int $user_id User ID
538
- * @return string User's unlock key
539
- */
540
- public static function get_user_unlock_key( $user_id ) {
541
- $security_meta = self::get_security_meta( $user_id );
542
- return apply_filters( 'tml_user_unlock_key', $security_meta['unlock_key'], $user_id );
543
- }
544
-
545
- /**
546
- * Get number of secongs from days, hours and minutes
547
- *
548
- * @since 6.0
549
- * @access public
550
- *
551
- * @param int $value Number of $unit
552
- * @param string $unit Can be either "day", "hour" or "minute"
553
- * @return int Number of seconds
554
- */
555
- public static function get_seconds_from_unit( $value, $unit = 'minute' ) {
556
- switch ( $unit ) {
557
- case 'day' :
558
- $value = $value * 24 * 60 * 60;
559
- break;
560
- case 'hour' :
561
- $value = $value * 60 * 60;
562
- break;
563
- case 'minute' :
564
- $value = $value * 60;
565
- break;
566
- }
567
- return $value;
568
- }
569
-
570
- /**
571
- * Sends a user a notification that their account has been locked
572
- *
573
- * @since 6.3
574
- *
575
- * @param int $user_id User ID
576
- */
577
- public static function user_lock_notification( $user_id ) {
578
- global $wpdb, $current_site;
579
-
580
- if ( apply_filters( 'send_user_lock_notification', true ) ) {
581
- $user = new WP_User( $user_id );
582
-
583
- $user_login = stripslashes( $user->user_login );
584
- $user_email = stripslashes( $user->user_email );
585
-
586
- if ( is_multisite() ) {
587
- $blogname = $current_site->site_name;
588
- } else {
589
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
590
- // we want to reverse this for the plain text arena of emails.
591
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
592
- }
593
-
594
- $unlock_url = add_query_arg( array( 'action' => 'unlock', 'key' => self::get_user_unlock_key( $user->ID ), 'login' => rawurlencode( $user_login ) ), wp_login_url() );
595
-
596
- $title = sprintf( __( '[%s] Account Locked', 'theme-my-login' ), $blogname );
597
- $message = sprintf( __( 'For your security, your account has been locked because of too many failed login attempts. To unlock your account please click the following link: ', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
598
- $message .= $unlock_url . "\r\n";
599
-
600
- if ( $user->has_cap( 'administrator' ) ) {
601
- $message .= "\r\n";
602
- $message .= __( 'The following attempts resulted in the lock:', 'theme-my-login' ) . "\r\n\r\n";
603
- foreach ( self::get_failed_login_attempts( $user->ID ) as $attempt ) {
604
- $time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
605
- $message .= $attempt['ip'] . "\t" . $time . "\r\n";
606
- }
607
- }
608
-
609
- $title = apply_filters( 'user_lock_notification_title', $title, $user_id );
610
- $message = apply_filters( 'user_lock_notification_message', $message, $unlock_url, $user_id );
611
-
612
- wp_mail( $user_email, $title, $message );
613
- }
614
- }
615
- }
616
-
617
- Theme_My_Login_Security::get_object();
618
-
619
- endif;
620
-
621
- if ( is_admin() )
622
- include_once( dirname( __FILE__ ) . '/admin/security-admin.php' );
623
-
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
+ * Holds Theme My Login Security class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Security
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Security' ) ) :
14
+ /**
15
+ * Theme My Login Security module class
16
+ *
17
+ * Adds options to help protect your site.
18
+ *
19
+ * @since 6.0
20
+ */
21
+ class Theme_My_Login_Security extends Theme_My_Login_Abstract {
22
+ /**
23
+ * Holds options key
24
+ *
25
+ * @since 6.3
26
+ * @access protected
27
+ * @var string
28
+ */
29
+ protected $options_key = 'theme_my_login_security';
30
+
31
+ /**
32
+ * Returns singleton instance
33
+ *
34
+ * @since 6.3
35
+ * @access public
36
+ * @return object
37
+ */
38
+ public static function get_object( $class = null ) {
39
+ return parent::get_object( __CLASS__ );
40
+ }
41
+
42
+ /**
43
+ * Returns default options
44
+ *
45
+ * @since 6.0
46
+ * @access public
47
+ *
48
+ * @return array Default options
49
+ */
50
+ public static function default_options() {
51
+ return array(
52
+ 'private_site' => 0,
53
+ 'private_login' => 0,
54
+ 'failed_login' => array(
55
+ 'threshold' => 5,
56
+ 'threshold_duration' => 1,
57
+ 'threshold_duration_unit' => 'hour',
58
+ 'lockout_duration' => 24,
59
+ 'lockout_duration_unit' => 'hour'
60
+ )
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Loads the module
66
+ *
67
+ * @since 6.0
68
+ * @access protected
69
+ */
70
+ protected function load() {
71
+ add_action( 'init', array( $this, 'init' ) );
72
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
73
+ add_action( 'tml_request_unlock', array( $this, 'request_unlock' ) );
74
+ add_action( 'tml_request', array( $this, 'action_messages' ) );
75
+
76
+ add_action( 'authenticate', array( $this, 'authenticate' ), 100, 3 );
77
+ add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ), 10, 2 );
78
+
79
+ add_action( 'show_user_profile', array( $this, 'show_user_profile' ) );
80
+ add_action( 'edit_user_profile', array( $this, 'show_user_profile' ) );
81
+
82
+ add_filter( 'show_admin_bar', array( $this, 'show_admin_bar' ) );
83
+ }
84
+
85
+ /**
86
+ * Sets a 404 error for wp-login.php if it's disabled
87
+ *
88
+ * @since 6.3
89
+ * @access public
90
+ */
91
+ public function init() {
92
+ global $wp_query, $pagenow;
93
+
94
+ if ( 'wp-login.php' == $pagenow && $this->get_option( 'private_login' ) ) {
95
+
96
+ parse_str( $_SERVER['QUERY_STRING'], $q );
97
+ if ( ! empty( $q['interim-login'] ) || ! empty( $_REQUEST['interim-login'] ) )
98
+ return;
99
+
100
+ $pagenow = 'index.php';
101
+ $wp_query->set_404();
102
+ status_header( 404 );
103
+ nocache_headers();
104
+ if ( ! $template = get_404_template() )
105
+ $template = 'index.php';
106
+ include( $template );
107
+ exit;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Blocks entire site if user is not logged in and private site is enabled
113
+ *
114
+ * Callback for "template_redirect" hook in the file wp-settings.php
115
+ *
116
+ * @since 6.2
117
+ * @access public
118
+ */
119
+ public function template_redirect() {
120
+ if ( $this->get_option( 'private_site' ) ) {
121
+ if ( ! ( is_user_logged_in() || Theme_My_Login::is_tml_page() ) ) {
122
+ $redirect_to = apply_filters( 'tml_security_private_site_redirect', wp_login_url( $_SERVER['REQUEST_URI'], true ) );
123
+ wp_safe_redirect( $redirect_to );
124
+ exit;
125
+ }
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Handles "unlock" action for login page
131
+ *
132
+ * Callback for "tml_request_activate" hook in method Theme_My_Login::the_request();
133
+ *
134
+ * @see Theme_My_Login::the_request();
135
+ * @since 6.3
136
+ */
137
+ public function request_unlock() {
138
+ $user = self::check_user_unlock_key( $_GET['key'], $_GET['login'] );
139
+
140
+ $redirect_to = Theme_My_Login_Common::get_current_url();
141
+
142
+ if ( is_wp_error( $user ) ) {
143
+ $redirect_to = add_query_arg( 'unlock', 'invalidkey', $redirect_to );
144
+ wp_redirect( $redirect_to );
145
+ exit;
146
+ }
147
+
148
+ self::unlock_user( $user->ID );
149
+
150
+ $redirect_to = add_query_arg( 'unlock', 'complete', $redirect_to );
151
+ wp_redirect( $redirect_to );
152
+ exit;
153
+ }
154
+
155
+ /**
156
+ * Handles display of various action/status messages
157
+ *
158
+ * Callback for "tml_request" hook in Theme_My_Login::the_request()
159
+ *
160
+ * @since 6.3
161
+ * @access public
162
+ *
163
+ * @param object $theme_my_login Reference to global $theme_my_login object
164
+ */
165
+ public function action_messages( &$theme_my_login ) {
166
+ if ( isset( $_GET['unlock'] ) && 'complete' == $_GET['unlock'] )
167
+ $theme_my_login->errors->add( 'unlock_complete', __( 'Your account has been unlocked. You may now log in.', 'theme-my-login' ), 'message' );
168
+ }
169
+
170
+ /**
171
+ * Validates a user unlock key
172
+ *
173
+ * @since 6.3
174
+ *
175
+ * @param string $key Unlock key
176
+ * @param string $login User login
177
+ * @return WP_User|WP_Error WP_User object on success, WP_Error object on failure
178
+ */
179
+ public static function check_user_unlock_key( $key, $login ) {
180
+ global $wpdb;
181
+
182
+ $key = preg_replace( '/[^a-z0-9]/i', '', $key );
183
+
184
+ if ( empty( $key ) || ! is_string( $key ) )
185
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
186
+
187
+ if ( empty( $login ) || ! is_string( $login ) )
188
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
189
+
190
+ if ( ! $user = get_user_by( 'login', $login ) )
191
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
192
+
193
+ if ( $key != self::get_user_unlock_key( $user->ID ) )
194
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
195
+
196
+ return $user;
197
+ }
198
+
199
+ /**
200
+ * Blocks locked users from logging in
201
+ *
202
+ * Callback for "authenticate" hook in function wp_authenticate()
203
+ *
204
+ * @see wp_authenticate()
205
+ * @since 6.0
206
+ * @access public
207
+ *
208
+ * @param WP_User $user WP_User object
209
+ * @param string $username Username posted
210
+ * @param string $password Password posted
211
+ * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
212
+ */
213
+ public function authenticate( $user, $username, $password ) {
214
+ // Make sure user exists
215
+ if ( ! $userdata = get_user_by( 'login', $username ) )
216
+ return $user;
217
+
218
+ // Current time
219
+ $time = time();
220
+
221
+ if ( self::is_user_locked( $userdata->ID ) ) {
222
+ if ( $expiration = self::get_user_lock_expiration( $userdata->ID ) ) {
223
+ if ( $time > $expiration )
224
+ self::unlock_user( $userdata->ID );
225
+ else
226
+ 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.', 'theme-my-login' ), human_time_diff( $time, $expiration ) ) );
227
+ } else {
228
+ return new WP_Error( 'locked_account', __( '<strong>ERROR</strong>: This account has been locked.', 'theme-my-login' ) );
229
+ }
230
+ } elseif ( is_wp_error( $user ) && 'incorrect_password' == $user->get_error_code() ) {
231
+ // Get the attempts
232
+ $attempts = self::get_failed_login_attempts( $userdata->ID );
233
+
234
+ // Get the first valid attempt
235
+ $first_attempt = reset( $attempts );
236
+
237
+ // Get the relative duration
238
+ $duration = $first_attempt['time'] + self::get_seconds_from_unit( $this->get_option( array( 'failed_login', 'threshold_duration' ) ), $this->get_option( array( 'failed_login', 'threshold_duration_unit' ) ) );
239
+
240
+ // If current time is less than relative duration time, we're still within the defensive zone
241
+ if ( $time < $duration ) {
242
+ // Log this attempt
243
+ self::add_failed_login_attempt( $userdata->ID, $time );
244
+ // If failed attempts reach treshold, lock the account
245
+ if ( self::get_failed_login_attempt_count( $userdata->ID ) >= $this->get_option( array( 'failed_login', 'threshold' ) ) ) {
246
+ // Create new expiration
247
+ $expiration = $time + self::get_seconds_from_unit( $this->get_option( array( 'failed_login', 'lockout_duration' ) ), $this->get_option( array( 'failed_login', 'lockout_duration_unit' ) ) );
248
+ self::lock_user( $userdata->ID, $expiration );
249
+ 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.', 'theme-my-login' ), human_time_diff( $time, $expiration ) ) );
250
+ }
251
+ } else {
252
+ // Clear the attempts
253
+ self::reset_failed_login_attempts( $userdata->ID );
254
+ // Log this attempt
255
+ self::add_failed_login_attempt( $userdata->ID, $time );
256
+ }
257
+ }
258
+ return $user;
259
+ }
260
+
261
+ /**
262
+ * Blocks locked users from resetting their password, if locked by admin
263
+ *
264
+ * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
265
+ *
266
+ * @see Theme_My_Login::retrieve_password()
267
+ * @since 6.0
268
+ * @access public
269
+ *
270
+ * @param bool $allow Default setting
271
+ * @param int $user_id User ID
272
+ * @return bool Whether to allow password reset or not
273
+ */
274
+ public function allow_password_reset( $allow, $user_id ) {
275
+ if ( self::is_user_locked( $user_id ) && ! self::get_user_lock_expiration( $user_id ) )
276
+ $allow = false;
277
+ return $allow;
278
+ }
279
+
280
+ /**
281
+ * Displays failed login attempts on users profile for administrators
282
+ *
283
+ * @since 6.2
284
+ * @access public
285
+ *
286
+ * @param object $profileuser User object
287
+ */
288
+ public function show_user_profile( $profileuser ) {
289
+ if ( ! current_user_can( 'manage_users' ) )
290
+ return;
291
+
292
+ if ( $failed_login_attempts = self::get_failed_login_attempts( $profileuser->ID ) ) : ?>
293
+ <h3><?php _e( 'Failed Login Attempts', 'theme-my-login' ); ?></h3>
294
+
295
+ <table class="form-table">
296
+ <tr>
297
+ <th scope="col"><?php _e( 'IP Address', 'theme-my-login' ); ?></th>
298
+ <th scope="col"><?php _e( 'Date', 'theme-my-login' ); ?></th>
299
+ </tr>
300
+ <?php foreach ( $failed_login_attempts as $attempt ) :
301
+ $t_time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
302
+
303
+ $time_diff = time() - $attempt['time'];
304
+
305
+ if ( $time_diff > 0 && $time_diff < 24*60*60 )
306
+ $h_time = sprintf( __( '%s ago', 'theme-my-login' ), human_time_diff( $attempt['time'] ) );
307
+ else
308
+ $h_time = date_i18n( __( 'Y/m/d', 'theme-my-login' ), $attempt['time'] );
309
+ ?>
310
+ <tr>
311
+ <td><?php echo $attempt['ip']; ?></td>
312
+ <td><abbr title="<?php echo $t_time; ?>"><?php echo $h_time; ?></abbr></td>
313
+ </tr>
314
+ <?php endforeach; ?>
315
+ </table>
316
+ <?php endif;
317
+ }
318
+
319
+ /**
320
+ * Shows admin bar for wp-login.php when it is disabled
321
+ *
322
+ * @since 6.3
323
+ * @access public
324
+ *
325
+ * @param bool $show True to show admin bar, false to hide
326
+ * @return bool True to show admin bar, false to hide
327
+ */
328
+ public function show_admin_bar( $show ) {
329
+ global $pagenow;
330
+
331
+ if ( is_user_logged_in() && 'wp-login.php' == $pagenow && $this->get_option( 'private_login' ) )
332
+ return true;
333
+ return $show;
334
+ }
335
+
336
+ /**
337
+ * Locks a user
338
+ *
339
+ * @since 6.0
340
+ * @access public
341
+ *
342
+ * @param int|WP_User $user User ID ir WP_User object
343
+ * @param int $expires When the lock expires, in seconds from current time
344
+ */
345
+ public static function lock_user( $user, $expires = 0 ) {
346
+ if ( is_object( $user ) )
347
+ $user = $user->ID;
348
+
349
+ $user = (int) $user;
350
+
351
+ do_action( 'tml_lock_user', $user );
352
+
353
+ $security = self::get_security_meta( $user );
354
+
355
+ $security['is_locked'] = true;
356
+ $security['lock_expiration'] = absint( $expires );
357
+ $security['unlock_key'] = wp_generate_password( 20, false );
358
+
359
+ update_user_meta( $user, 'theme_my_login_security', $security );
360
+
361
+ if ( $expires )
362
+ self::user_lock_notification( $user );
363
+ }
364
+
365
+ /**
366
+ * Unlocks a user
367
+ *
368
+ * @since 6.0
369
+ * @access public
370
+ *
371
+ * @param int|WP_User $user User ID or WP_User object
372
+ */
373
+ public static function unlock_user( $user ) {
374
+ if ( is_object( $user ) )
375
+ $user = $user->ID;
376
+
377
+ $user = (int) $user;
378
+
379
+ do_action( 'tml_unlock_user', $user );
380
+
381
+ $security = self::get_security_meta( $user );
382
+
383
+ $security['is_locked'] = false;
384
+ $security['lock_expiration'] = 0;
385
+ $security['unlock_key'] = '';
386
+ $security['failed_login_attempts'] = array();
387
+
388
+ return update_user_meta( $user, 'theme_my_login_security', $security );
389
+ }
390
+
391
+ /**
392
+ * Determine if a user is locked or not
393
+ *
394
+ * @since 6.0
395
+ * @access public
396
+ *
397
+ * @param int|WP_User $user User ID or WP_User object
398
+ * @return bool True if user is locked, false if not
399
+ */
400
+ public static function is_user_locked( $user ) {
401
+ if ( is_object( $user ) )
402
+ $user = $user->ID;
403
+
404
+ $user = (int) $user;
405
+
406
+ $security = self::get_security_meta( $user );
407
+
408
+ // If "is_locked" is not set, there is no lock
409
+ if ( ! $security['is_locked'] )
410
+ return false;
411
+
412
+ // If "lock_expires" is not set, there is a lock but no expiry
413
+ if ( ! $expires = self::get_user_lock_expiration( $user ) )
414
+ return true;
415
+
416
+ // We have a lock with an expiry
417
+ $time = time();
418
+ if ( $time > $expires ) {
419
+ self::unlock_user( $user );
420
+ return false;
421
+ }
422
+
423
+ return true;
424
+ }
425
+
426
+ /**
427
+ * Get a user's security meta
428
+ *
429
+ * @since 6.0
430
+ * @access protected
431
+ *
432
+ * @param int $user_id User ID
433
+ * @return array User's security meta
434
+ */
435
+ protected static function get_security_meta( $user_id ) {
436
+ $defaults = array(
437
+ 'is_locked' => false,
438
+ 'lock_expiration' => 0,
439
+ 'unlock_key' => '',
440
+ 'failed_login_attempts' => array()
441
+ );
442
+ $meta = get_user_meta( $user_id, 'theme_my_login_security', true );
443
+ if ( ! is_array( $meta ) )
444
+ $meta = array();
445
+
446
+ return array_merge( $defaults, $meta );
447
+ }
448
+
449
+ /**
450
+ * Get a user's failed login attempts
451
+ *
452
+ * @since 6.0
453
+ * @access public
454
+ *
455
+ * @param int $user_id User ID
456
+ * @return array User's failed login attempts
457
+ */
458
+ public static function get_failed_login_attempts( $user_id ) {
459
+ $security_meta = self::get_security_meta( $user_id );
460
+ return $security_meta['failed_login_attempts'];
461
+ }
462
+
463
+ /**
464
+ * Reset a user's failed login attempts
465
+ *
466
+ * @since 6.0
467
+ * @access public
468
+ *
469
+ * @param int $user_id User ID
470
+ */
471
+ public static function reset_failed_login_attempts( $user_id ) {
472
+ $security_meta = self::get_security_meta( $user_id );
473
+ $security_meta['failed_login_attempts'] = array();
474
+ return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
475
+ }
476
+
477
+ /**
478
+ * Get a user's failed login attempt count
479
+ *
480
+ * @since 6.0
481
+ * @access public
482
+ *
483
+ * @param int $user_id User ID
484
+ * @return int Number of user's failed login attempts
485
+ */
486
+ public static function get_failed_login_attempt_count( $user_id ) {
487
+ return count( self::get_failed_login_attempts( $user_id ) );
488
+ }
489
+
490
+ /**
491
+ * Add a failed login attempt to a user
492
+ *
493
+ * @since 6.0
494
+ * @access public
495
+ *
496
+ * @param int $user_id User ID
497
+ * @param int $time Time of attempt, in seconds
498
+ * @param string $ip IP address of attempt
499
+ */
500
+ public static function add_failed_login_attempt( $user_id, $time = '', $ip = '' ) {
501
+ $security_meta = self::get_security_meta( $user_id );
502
+ if ( ! is_array( $security_meta['failed_login_attempts'] ) )
503
+ $security_meta['failed_login_attempts'] = array();
504
+
505
+ $time = absint( $time );
506
+
507
+ if ( empty( $time ) )
508
+ $time = time();
509
+
510
+ if ( empty( $ip ) )
511
+ $ip = $_SERVER['REMOTE_ADDR'];
512
+
513
+ $security_meta['failed_login_attempts'][] = array( 'time' => $time, 'ip' => $ip );
514
+
515
+ return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
516
+ }
517
+
518
+ /**
519
+ * Get user's lock expiration time
520
+ *
521
+ * @since 6.0
522
+ * @access public
523
+ *
524
+ * @param int $user_id User ID
525
+ * @return int User's lock expiration time
526
+ */
527
+ public static function get_user_lock_expiration( $user_id ) {
528
+ $security_meta = self::get_security_meta( $user_id );
529
+ return apply_filters( 'tml_user_lock_expiration', absint( $security_meta['lock_expiration'] ), $user_id );
530
+ }
531
+
532
+ /**
533
+ * Get a user's unlock key
534
+ *
535
+ * @since 6.3
536
+ *
537
+ * @param int $user_id User ID
538
+ * @return string User's unlock key
539
+ */
540
+ public static function get_user_unlock_key( $user_id ) {
541
+ $security_meta = self::get_security_meta( $user_id );
542
+ return apply_filters( 'tml_user_unlock_key', $security_meta['unlock_key'], $user_id );
543
+ }
544
+
545
+ /**
546
+ * Get number of secongs from days, hours and minutes
547
+ *
548
+ * @since 6.0
549
+ * @access public
550
+ *
551
+ * @param int $value Number of $unit
552
+ * @param string $unit Can be either "day", "hour" or "minute"
553
+ * @return int Number of seconds
554
+ */
555
+ public static function get_seconds_from_unit( $value, $unit = 'minute' ) {
556
+ switch ( $unit ) {
557
+ case 'day' :
558
+ $value = $value * 24 * 60 * 60;
559
+ break;
560
+ case 'hour' :
561
+ $value = $value * 60 * 60;
562
+ break;
563
+ case 'minute' :
564
+ $value = $value * 60;
565
+ break;
566
+ }
567
+ return $value;
568
+ }
569
+
570
+ /**
571
+ * Sends a user a notification that their account has been locked
572
+ *
573
+ * @since 6.3
574
+ *
575
+ * @param int $user_id User ID
576
+ */
577
+ public static function user_lock_notification( $user_id ) {
578
+ global $wpdb, $current_site;
579
+
580
+ if ( apply_filters( 'send_user_lock_notification', true ) ) {
581
+ $user = new WP_User( $user_id );
582
+
583
+ $user_login = stripslashes( $user->user_login );
584
+ $user_email = stripslashes( $user->user_email );
585
+
586
+ if ( is_multisite() ) {
587
+ $blogname = $current_site->site_name;
588
+ } else {
589
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
590
+ // we want to reverse this for the plain text arena of emails.
591
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
592
+ }
593
+
594
+ $unlock_url = add_query_arg( array( 'action' => 'unlock', 'key' => self::get_user_unlock_key( $user->ID ), 'login' => rawurlencode( $user_login ) ), wp_login_url() );
595
+
596
+ $title = sprintf( __( '[%s] Account Locked', 'theme-my-login' ), $blogname );
597
+ $message = sprintf( __( 'For your security, your account has been locked because of too many failed login attempts. To unlock your account please click the following link: ', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
598
+ $message .= $unlock_url . "\r\n";
599
+
600
+ if ( $user->has_cap( 'administrator' ) ) {
601
+ $message .= "\r\n";
602
+ $message .= __( 'The following attempts resulted in the lock:', 'theme-my-login' ) . "\r\n\r\n";
603
+ foreach ( self::get_failed_login_attempts( $user->ID ) as $attempt ) {
604
+ $time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
605
+ $message .= $attempt['ip'] . "\t" . $time . "\r\n";
606
+ }
607
+ }
608
+
609
+ $title = apply_filters( 'user_lock_notification_title', $title, $user_id );
610
+ $message = apply_filters( 'user_lock_notification_message', $message, $unlock_url, $user_id );
611
+
612
+ wp_mail( $user_email, $title, $message );
613
+ }
614
+ }
615
+ }
616
+
617
+ Theme_My_Login_Security::get_object();
618
+
619
+ endif;
620
+
621
+ if ( is_admin() )
622
+ include_once( dirname( __FILE__ ) . '/admin/security-admin.php' );
623
+
modules/themed-profiles/themed-profiles.css CHANGED
@@ -1,51 +1,51 @@
1
- .tml-profile {
2
- max-width: 100%;
3
- }
4
-
5
- .tml-profile .tml-form-table {
6
- border-collapse: collapse;
7
- }
8
-
9
- .tml-profile .tml-form-table th,
10
- .tml-profile .tml-form-table td {
11
- display: block;
12
- vertical-align: middle;
13
- width: auto;
14
- }
15
-
16
- .tml-profile .screen-reader-text,
17
- .tml-profile .screen-reader-text span {
18
- height: 1px;
19
- left: -1000em;
20
- overflow: hidden;
21
- position: absolute;
22
- width: 1px;
23
- }
24
-
25
- .tml-profile .wp-pwd {
26
- text-align: right;
27
- }
28
-
29
- .tml-profile .wp-pwd .dashicons {
30
- font-size: 1em;
31
- line-height: 1;
32
- height: 1em;
33
- width: 1em;
34
- vertical-align: middle;
35
- }
36
-
37
- .tml-profile #pass-strength-result {
38
- margin: 0.5em 0;
39
- }
40
-
41
- .hidden,
42
- .no-js .hide-if-no-js,
43
- .js .hide-if-js {
44
- display: none;
45
- }
46
-
47
- @media screen and (min-width: 768px) {
48
- .tml-profile .tml-submit-wrap input {
49
- width: auto;
50
- }
51
- }
1
+ .tml-profile {
2
+ max-width: 100%;
3
+ }
4
+
5
+ .tml-profile .tml-form-table {
6
+ border-collapse: collapse;
7
+ }
8
+
9
+ .tml-profile .tml-form-table th,
10
+ .tml-profile .tml-form-table td {
11
+ display: block;
12
+ vertical-align: middle;
13
+ width: auto;
14
+ }
15
+
16
+ .tml-profile .screen-reader-text,
17
+ .tml-profile .screen-reader-text span {
18
+ height: 1px;
19
+ left: -1000em;
20
+ overflow: hidden;
21
+ position: absolute;
22
+ width: 1px;
23
+ }
24
+
25
+ .tml-profile .wp-pwd {
26
+ text-align: right;
27
+ }
28
+
29
+ .tml-profile .wp-pwd .dashicons {
30
+ font-size: 1em;
31
+ line-height: 1;
32
+ height: 1em;
33
+ width: 1em;
34
+ vertical-align: middle;
35
+ }
36
+
37
+ .tml-profile #pass-strength-result {
38
+ margin: 0.5em 0;
39
+ }
40
+
41
+ .hidden,
42
+ .no-js .hide-if-no-js,
43
+ .js .hide-if-js {
44
+ display: none;
45
+ }
46
+
47
+ @media screen and (min-width: 768px) {
48
+ .tml-profile .tml-submit-wrap input {
49
+ width: auto;
50
+ }
51
+ }
modules/themed-profiles/themed-profiles.php CHANGED
@@ -1,396 +1,396 @@
1
- <?php
2
- /**
3
- * Plugin Name: Themed Profiles
4
- * Description: Enabling this module will initialize and enable themed profiles. You will then have to configure the settings via the "Themed Profiles" tab.
5
- *
6
- * Holds Theme My Login Themed Profiles class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Themed_Profiles
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Themed_Profiles' ) ) :
14
- /**
15
- * Theme My Login Themed Profiles class
16
- *
17
- * Allows users to edit profile on the front-end.
18
- *
19
- * @since 6.0
20
- */
21
- class Theme_My_Login_Themed_Profiles extends Theme_My_Login_Abstract {
22
- /**
23
- * Holds options key
24
- *
25
- * @since 6.3
26
- * @access protected
27
- * @var string
28
- */
29
- protected $options_key = 'theme_my_login_themed_profiles';
30
-
31
- /**
32
- * Returns singleton instance
33
- *
34
- * @since 6.3
35
- * @access public
36
- * @return object
37
- */
38
- public static function get_object( $class = null ) {
39
- return parent::get_object( __CLASS__ );
40
- }
41
-
42
- /**
43
- * Returns default options
44
- *
45
- * @since 6.3
46
- * @access public
47
- *
48
- * @return array Default options
49
- */
50
- public static function default_options() {
51
- global $wp_roles;
52
-
53
- if ( empty( $wp_roles ) )
54
- $wp_roles = new WP_Roles;
55
-
56
- $options = array();
57
- foreach ( $wp_roles->get_names() as $role => $label ) {
58
- if ( 'pending' != $role ) {
59
- $options[$role] = array(
60
- 'theme_profile' => true,
61
- 'restrict_admin' => false
62
- );
63
- }
64
- }
65
- return $options;
66
- }
67
-
68
- /**
69
- * Loads the module
70
- *
71
- * @since 6.0
72
- * @access protected
73
- */
74
- protected function load() {
75
- add_action( 'tml_modules_loaded', array( $this, 'modules_loaded' ) );
76
-
77
- add_action( 'init', array( $this, 'init' ) );
78
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
79
- add_filter( 'show_admin_bar', array( $this, 'show_admin_bar' ) );
80
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
81
- add_filter( 'body_class', array( $this, 'body_class' ) );
82
-
83
- add_action( 'tml_request_profile', array( $this, 'tml_request_profile' ) );
84
- add_action( 'tml_display_profile', array( $this, 'tml_display_profile' ) );
85
-
86
- add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ), 12 );
87
- }
88
-
89
- /**
90
- * Adds filters to site_url() and admin_url()
91
- *
92
- * Callback for "tml_modules_loaded" in file "theme-my-login.php"
93
- *
94
- * @since 6.0
95
- * @access public
96
- */
97
- public function modules_loaded() {
98
- add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
99
- add_filter( 'admin_url', array( $this, 'site_url' ), 10, 2 );
100
- }
101
-
102
- /**
103
- * Redirects "profile.php" to themed profile page
104
- *
105
- * Callback for "init" hook
106
- *
107
- * @since 6.0
108
- * @access public
109
- */
110
- public function init() {
111
- global $current_user, $pagenow;
112
-
113
- if ( is_user_logged_in() && is_admin() ) {
114
- $redirect_to = Theme_My_Login::get_page_link( 'profile' );
115
-
116
- $user_role = reset( $current_user->roles );
117
- if ( is_multisite() && empty( $user_role ) )
118
- $user_role = 'subscriber';
119
-
120
- if ( 'profile.php' == $pagenow && ! isset( $_REQUEST['page'] ) ) {
121
- if ( $this->get_option( array( $user_role, 'theme_profile' ) ) ) {
122
- if ( ! empty( $_GET ) )
123
- $redirect_to = add_query_arg( (array) $_GET, $redirect_to );
124
- wp_redirect( $redirect_to );
125
- exit;
126
- }
127
- } else {
128
- if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) ) {
129
- if ( ! defined( 'DOING_AJAX' ) ) {
130
- wp_redirect( $redirect_to );
131
- exit;
132
- }
133
- }
134
- }
135
- }
136
- }
137
-
138
- /**
139
- * Redirects login page to profile if user is logged in
140
- *
141
- * Callback for "template_redirect" hook
142
- *
143
- * @since 6.0
144
- * @access public
145
- */
146
- public function template_redirect() {
147
- $theme_my_login = Theme_My_Login::get_object();
148
-
149
- if ( Theme_My_Login::is_tml_page() ) {
150
- switch ( $theme_my_login->request_action ) {
151
- case 'profile' :
152
- // Redirect to login page if not logged in
153
- if ( ! is_user_logged_in() ) {
154
- $redirect_to = Theme_My_Login::get_page_link( 'login', 'reauth=1' );
155
- wp_redirect( $redirect_to );
156
- exit;
157
- }
158
- break;
159
- case 'logout' :
160
- // Allow logout action
161
- break;
162
- case 'register' :
163
- // Allow register action if multisite
164
- if ( is_multisite() )
165
- break;
166
- default :
167
- // Redirect to profile for any other action if logged in
168
- if ( is_user_logged_in() ) {
169
- $redirect_to = Theme_My_Login::get_page_link( 'profile' );
170
- wp_redirect( $redirect_to );
171
- exit;
172
- }
173
- }
174
- }
175
- }
176
-
177
- /**
178
- * Hides admin bar is admin is restricted
179
- *
180
- * Callback for "show_admin_bar" hook
181
- *
182
- * @since 6.2
183
- * @access public
184
- */
185
- public function show_admin_bar( $show_admin_bar ) {
186
- global $current_user;
187
-
188
- $user_role = reset( $current_user->roles );
189
- if ( is_multisite() && empty( $user_role ) )
190
- $user_role = 'subscriber';
191
-
192
- if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) )
193
- return false;
194
-
195
- return $show_admin_bar;
196
- }
197
-
198
- /**
199
- * Enqueue scripts
200
- *
201
- * @since 6.4
202
- * @access public
203
- */
204
- public function wp_enqueue_scripts() {
205
- wp_enqueue_script( 'tml-themed-profiles', plugins_url( 'themed-profiles.js', __FILE__ ), array( 'jquery' ) );
206
- }
207
-
208
- /**
209
- * Add a 'no-js' class to the body
210
- *
211
- * @since 6.4
212
- * @access public
213
- *
214
- * @param array $classes Body classes
215
- * @return array Body classes
216
- */
217
- public function body_class( $classes ) {
218
-
219
- if ( ! Theme_My_Login::is_tml_page( 'profile' ) )
220
- return $classes;
221
-
222
- if ( ! in_array( 'no-js', $classes ) )
223
- $classes[] = 'no-js';
224
-
225
- return $classes;
226
- }
227
-
228
- /**
229
- * Handles profile action
230
- *
231
- * Callback for "tml_request_profile" in method Theme_My_Login::the_request()
232
- *
233
- * @see Theme_My_Login::the_request()
234
- * @since 6.0
235
- * @access public
236
- */
237
- public function tml_request_profile() {
238
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
239
- require_once( ABSPATH . 'wp-admin/includes/misc.php' );
240
-
241
- define( 'IS_PROFILE_PAGE', true );
242
-
243
- load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
244
-
245
- register_admin_color_schemes();
246
-
247
- wp_enqueue_style( 'password-strength', plugins_url( 'themed-profiles.css', __FILE__ ) );
248
-
249
- wp_enqueue_script( 'user-profile' );
250
-
251
- $current_user = wp_get_current_user();
252
-
253
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
254
- check_admin_referer( 'update-user_' . $current_user->ID );
255
-
256
- if ( ! current_user_can( 'edit_user', $current_user->ID ) )
257
- wp_die( __( 'You do not have permission to edit this user.', 'theme-my-login' ) );
258
-
259
- do_action( 'personal_options_update', $current_user->ID );
260
-
261
- $errors = edit_user( $current_user->ID );
262
-
263
- if ( ! is_wp_error( $errors ) ) {
264
- $args = array( 'updated' => 'true' );
265
- if ( ! empty( $_REQUEST['instance'] ) )
266
- $args['instance'] = $_REQUEST['instance'];
267
- $redirect = add_query_arg( $args );
268
- wp_redirect( $redirect );
269
- exit;
270
- } else {
271
- Theme_My_Login::get_object()->errors = $errors;
272
- }
273
- }
274
- }
275
-
276
- /**
277
- * Outputs profile form HTML
278
- *
279
- * Callback for "tml_display_profile" hook in method Theme_My_login_Template::display()
280
- *
281
- * @see Theme_My_Login_Template::display()
282
- * @since 6.0
283
- * @access public
284
- *
285
- * @param object $template Reference to $theme_my_login_template object
286
- */
287
- public function tml_display_profile( &$template ) {
288
- global $current_user, $profileuser, $_wp_admin_css_colors, $wp_version;
289
-
290
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
291
- require_once( ABSPATH . 'wp-admin/includes/misc.php' );
292
-
293
- if ( isset( $_GET['updated'] ) && 'true' == $_GET['updated'] )
294
- Theme_My_Login::get_object()->errors->add( 'profile_updated', __( 'Profile updated.', 'theme-my-login' ), 'message' );
295
-
296
- $current_user = wp_get_current_user();
297
- $profileuser = get_user_to_edit( $current_user->ID );
298
-
299
- $user_role = reset( $profileuser->roles );
300
- if ( is_multisite() && empty( $user_role ) )
301
- $user_role = 'subscriber';
302
-
303
- $_template = array();
304
-
305
- // Allow template override via shortcode or template tag args
306
- if ( ! empty( $template->options['profile_template'] ) )
307
- $_template[] = $template->options['profile_template'];
308
-
309
- // Allow role template overrid via shortcode or template tag args
310
- if ( ! empty( $template->options["profile_template_{$user_role}"] ) )
311
- $_template[] = $template->options["profile_template_{$user_role}"];
312
-
313
- // Role template
314
- $_template[] = "profile-form-{$user_role}.php";
315
-
316
- // Default template
317
- $_template[] = 'profile-form.php';
318
-
319
- // Load template
320
- $template->get_template( $_template, true, compact( 'current_user', 'profileuser', 'user_role', '_wp_admin_css_colors', 'wp_version' ) );
321
- }
322
-
323
- /**
324
- * Changes links from "profile.php" to themed profile page
325
- *
326
- * Callback for "site_url" hook
327
- *
328
- * @see site_url()
329
- * @since 6.0
330
- * @access public
331
- *
332
- * @param string $url The generated link
333
- * @param string $path The specified path
334
- * @param string $orig_scheme The original connection scheme
335
- * @return string The filtered link
336
- */
337
- public function site_url( $url, $path, $orig_scheme = '' ) {
338
- global $current_user, $pagenow;
339
-
340
- if ( 'profile.php' != $pagenow && strpos( $url, 'profile.php' ) !== false ) {
341
- $user_role = reset( $current_user->roles );
342
- if ( is_multisite() && empty( $user_role ) )
343
- $user_role = 'subscriber';
344
-
345
- if ( $user_role && ! $this->get_option( array( $user_role, 'theme_profile' ) ) )
346
- return $url;
347
-
348
- $parsed_url = parse_url( $url );
349
-
350
- $url = Theme_My_Login::get_page_link( 'profile' );
351
-
352
- if ( isset( $parsed_url['query'] ) )
353
- $url = add_query_arg( array_map( 'rawurlencode', wp_parse_args( $parsed_url['query'] ) ), $url );
354
- }
355
- return $url;
356
- }
357
-
358
- /**
359
- * Hide Profile link if user is not logged in
360
- *
361
- * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
362
- *
363
- * @see wp_setup_nav_menu_item()
364
- * @since 6.4
365
- * @access public
366
- *
367
- * @param object $menu_item The menu item
368
- * @return object The (possibly) modified menu item
369
- */
370
- public function wp_setup_nav_menu_item( $menu_item ) {
371
- if ( is_admin() )
372
- return $menu_item;
373
-
374
- if ( 'page' != $menu_item->object )
375
- return $menu_item;
376
-
377
- // User is not logged in
378
- if ( ! is_user_logged_in() ) {
379
-
380
- // Hide Profile
381
- if ( Theme_My_Login::is_tml_page( 'profile', $menu_item->object_id ) ) {
382
- $menu_item->_invalid = true;
383
- }
384
- }
385
-
386
- return $menu_item;
387
- }
388
- }
389
-
390
- Theme_My_Login_Themed_Profiles::get_object();
391
-
392
- endif;
393
-
394
- if ( is_admin() )
395
- include_once( dirname( __FILE__ ) . '/admin/themed-profiles-admin.php' );
396
-
1
+ <?php
2
+ /**
3
+ * Plugin Name: Themed Profiles
4
+ * Description: Enabling this module will initialize and enable themed profiles. You will then have to configure the settings via the "Themed Profiles" tab.
5
+ *
6
+ * Holds Theme My Login Themed Profiles class
7
+ *
8
+ * @package Theme_My_Login
9
+ * @subpackage Theme_My_Login_Themed_Profiles
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_Themed_Profiles' ) ) :
14
+ /**
15
+ * Theme My Login Themed Profiles class
16
+ *
17
+ * Allows users to edit profile on the front-end.
18
+ *
19
+ * @since 6.0
20
+ */
21
+ class Theme_My_Login_Themed_Profiles extends Theme_My_Login_Abstract {
22
+ /**
23
+ * Holds options key
24
+ *
25
+ * @since 6.3
26
+ * @access protected
27
+ * @var string
28
+ */
29
+ protected $options_key = 'theme_my_login_themed_profiles';
30
+
31
+ /**
32
+ * Returns singleton instance
33
+ *
34
+ * @since 6.3
35
+ * @access public
36
+ * @return object
37
+ */
38
+ public static function get_object( $class = null ) {
39
+ return parent::get_object( __CLASS__ );
40
+ }
41
+
42
+ /**
43
+ * Returns default options
44
+ *
45
+ * @since 6.3
46
+ * @access public
47
+ *
48
+ * @return array Default options
49
+ */
50
+ public static function default_options() {
51
+ global $wp_roles;
52
+
53
+ if ( empty( $wp_roles ) )
54
+ $wp_roles = new WP_Roles;
55
+
56
+ $options = array();
57
+ foreach ( $wp_roles->get_names() as $role => $label ) {
58
+ if ( 'pending' != $role ) {
59
+ $options[$role] = array(
60
+ 'theme_profile' => true,
61
+ 'restrict_admin' => false
62
+ );
63
+ }
64
+ }
65
+ return $options;
66
+ }
67
+
68
+ /**
69
+ * Loads the module
70
+ *
71
+ * @since 6.0
72
+ * @access protected
73
+ */
74
+ protected function load() {
75
+ add_action( 'tml_modules_loaded', array( $this, 'modules_loaded' ) );
76
+
77
+ add_action( 'init', array( $this, 'init' ) );
78
+ add_action( 'template_redirect', array( $this, 'template_redirect' ) );
79
+ add_filter( 'show_admin_bar', array( $this, 'show_admin_bar' ) );
80
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
81
+ add_filter( 'body_class', array( $this, 'body_class' ) );
82
+
83
+ add_action( 'tml_request_profile', array( $this, 'tml_request_profile' ) );
84
+ add_action( 'tml_display_profile', array( $this, 'tml_display_profile' ) );
85
+
86
+ add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ), 12 );
87
+ }
88
+
89
+ /**
90
+ * Adds filters to site_url() and admin_url()
91
+ *
92
+ * Callback for "tml_modules_loaded" in file "theme-my-login.php"
93
+ *
94
+ * @since 6.0
95
+ * @access public
96
+ */
97
+ public function modules_loaded() {
98
+ add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
99
+ add_filter( 'admin_url', array( $this, 'site_url' ), 10, 2 );
100
+ }
101
+
102
+ /**
103
+ * Redirects "profile.php" to themed profile page
104
+ *
105
+ * Callback for "init" hook
106
+ *
107
+ * @since 6.0
108
+ * @access public
109
+ */
110
+ public function init() {
111
+ global $current_user, $pagenow;
112
+
113
+ if ( is_user_logged_in() && is_admin() ) {
114
+ $redirect_to = Theme_My_Login::get_page_link( 'profile' );
115
+
116
+ $user_role = reset( $current_user->roles );
117
+ if ( is_multisite() && empty( $user_role ) )
118
+ $user_role = 'subscriber';
119
+
120
+ if ( 'profile.php' == $pagenow && ! isset( $_REQUEST['page'] ) ) {
121
+ if ( $this->get_option( array( $user_role, 'theme_profile' ) ) ) {
122
+ if ( ! empty( $_GET ) )
123
+ $redirect_to = add_query_arg( (array) $_GET, $redirect_to );
124
+ wp_redirect( $redirect_to );
125
+ exit;
126
+ }
127
+ } else {
128
+ if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) ) {
129
+ if ( ! defined( 'DOING_AJAX' ) ) {
130
+ wp_redirect( $redirect_to );
131
+ exit;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Redirects login page to profile if user is logged in
140
+ *
141
+ * Callback for "template_redirect" hook
142
+ *
143
+ * @since 6.0
144
+ * @access public
145
+ */
146
+ public function template_redirect() {
147
+ $theme_my_login = Theme_My_Login::get_object();
148
+
149
+ if ( Theme_My_Login::is_tml_page() ) {
150
+ switch ( $theme_my_login->request_action ) {
151
+ case 'profile' :
152
+ // Redirect to login page if not logged in
153
+ if ( ! is_user_logged_in() ) {
154
+ $redirect_to = Theme_My_Login::get_page_link( 'login', 'reauth=1' );
155
+ wp_redirect( $redirect_to );
156
+ exit;
157
+ }
158
+ break;
159
+ case 'logout' :
160
+ // Allow logout action
161
+ break;
162
+ case 'register' :
163
+ // Allow register action if multisite
164
+ if ( is_multisite() )
165
+ break;
166
+ default :
167
+ // Redirect to profile for any other action if logged in
168
+ if ( is_user_logged_in() ) {
169
+ $redirect_to = Theme_My_Login::get_page_link( 'profile' );
170
+ wp_redirect( $redirect_to );
171
+ exit;
172
+ }
173
+ }
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Hides admin bar is admin is restricted
179
+ *
180
+ * Callback for "show_admin_bar" hook
181
+ *
182
+ * @since 6.2
183
+ * @access public
184
+ */
185
+ public function show_admin_bar( $show_admin_bar ) {
186
+ global $current_user;
187
+
188
+ $user_role = reset( $current_user->roles );
189
+ if ( is_multisite() && empty( $user_role ) )
190
+ $user_role = 'subscriber';
191
+
192
+ if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) )
193
+ return false;
194
+
195
+ return $show_admin_bar;
196
+ }
197
+
198
+ /**
199
+ * Enqueue scripts
200
+ *
201
+ * @since 6.4
202
+ * @access public
203
+ */
204
+ public function wp_enqueue_scripts() {
205
+ wp_enqueue_script( 'tml-themed-profiles', plugins_url( 'themed-profiles.js', __FILE__ ), array( 'jquery' ) );
206
+ }
207
+
208
+ /**
209
+ * Add a 'no-js' class to the body
210
+ *
211
+ * @since 6.4
212
+ * @access public
213
+ *
214
+ * @param array $classes Body classes
215
+ * @return array Body classes
216
+ */
217
+ public function body_class( $classes ) {
218
+
219
+ if ( ! Theme_My_Login::is_tml_page( 'profile' ) )
220
+ return $classes;
221
+
222
+ if ( ! in_array( 'no-js', $classes ) )
223
+ $classes[] = 'no-js';
224
+
225
+ return $classes;
226
+ }
227
+
228
+ /**
229
+ * Handles profile action
230
+ *
231
+ * Callback for "tml_request_profile" in method Theme_My_Login::the_request()
232
+ *
233
+ * @see Theme_My_Login::the_request()
234
+ * @since 6.0
235
+ * @access public
236
+ */
237
+ public function tml_request_profile() {
238
+ require_once( ABSPATH . 'wp-admin/includes/user.php' );
239
+ require_once( ABSPATH . 'wp-admin/includes/misc.php' );
240
+
241
+ define( 'IS_PROFILE_PAGE', true );
242
+
243
+ load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
244
+
245
+ register_admin_color_schemes();
246
+
247
+ wp_enqueue_style( 'password-strength', plugins_url( 'themed-profiles.css', __FILE__ ) );
248
+
249
+ wp_enqueue_script( 'user-profile' );
250
+
251
+ $current_user = wp_get_current_user();
252
+
253
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
254
+ check_admin_referer( 'update-user_' . $current_user->ID );
255
+
256
+ if ( ! current_user_can( 'edit_user', $current_user->ID ) )
257
+ wp_die( __( 'You do not have permission to edit this user.', 'theme-my-login' ) );
258
+
259
+ do_action( 'personal_options_update', $current_user->ID );
260
+
261
+ $errors = edit_user( $current_user->ID );
262
+
263
+ if ( ! is_wp_error( $errors ) ) {
264
+ $args = array( 'updated' => 'true' );
265
+ if ( ! empty( $_REQUEST['instance'] ) )
266
+ $args['instance'] = $_REQUEST['instance'];
267
+ $redirect = add_query_arg( $args );
268
+ wp_redirect( $redirect );
269
+ exit;
270
+ } else {
271
+ Theme_My_Login::get_object()->errors = $errors;
272
+ }
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Outputs profile form HTML
278
+ *
279
+ * Callback for "tml_display_profile" hook in method Theme_My_login_Template::display()
280
+ *
281
+ * @see Theme_My_Login_Template::display()
282
+ * @since 6.0
283
+ * @access public
284
+ *
285
+ * @param object $template Reference to $theme_my_login_template object
286
+ */
287
+ public function tml_display_profile( &$template ) {
288
+ global $current_user, $profileuser, $_wp_admin_css_colors, $wp_version;
289
+
290
+ require_once( ABSPATH . 'wp-admin/includes/user.php' );
291
+ require_once( ABSPATH . 'wp-admin/includes/misc.php' );
292
+
293
+ if ( isset( $_GET['updated'] ) && 'true' == $_GET['updated'] )
294
+ Theme_My_Login::get_object()->errors->add( 'profile_updated', __( 'Profile updated.', 'theme-my-login' ), 'message' );
295
+
296
+ $current_user = wp_get_current_user();
297
+ $profileuser = get_user_to_edit( $current_user->ID );
298
+
299
+ $user_role = reset( $profileuser->roles );
300
+ if ( is_multisite() && empty( $user_role ) )
301
+ $user_role = 'subscriber';
302
+
303
+ $_template = array();
304
+
305
+ // Allow template override via shortcode or template tag args
306
+ if ( ! empty( $template->options['profile_template'] ) )
307
+ $_template[] = $template->options['profile_template'];
308
+
309
+ // Allow role template overrid via shortcode or template tag args
310
+ if ( ! empty( $template->options["profile_template_{$user_role}"] ) )
311
+ $_template[] = $template->options["profile_template_{$user_role}"];
312
+
313
+ // Role template
314
+ $_template[] = "profile-form-{$user_role}.php";
315
+
316
+ // Default template
317
+ $_template[] = 'profile-form.php';
318
+
319
+ // Load template
320
+ $template->get_template( $_template, true, compact( 'current_user', 'profileuser', 'user_role', '_wp_admin_css_colors', 'wp_version' ) );
321
+ }
322
+
323
+ /**
324
+ * Changes links from "profile.php" to themed profile page
325
+ *
326
+ * Callback for "site_url" hook
327
+ *
328
+ * @see site_url()
329
+ * @since 6.0
330
+ * @access public
331
+ *
332
+ * @param string $url The generated link
333
+ * @param string $path The specified path
334
+ * @param string $orig_scheme The original connection scheme
335
+ * @return string The filtered link
336
+ */
337
+ public function site_url( $url, $path, $orig_scheme = '' ) {
338
+ global $current_user, $pagenow;
339
+
340
+ if ( 'profile.php' != $pagenow && strpos( $url, 'profile.php' ) !== false ) {
341
+ $user_role = reset( $current_user->roles );
342
+ if ( is_multisite() && empty( $user_role ) )
343
+ $user_role = 'subscriber';
344
+
345
+ if ( $user_role && ! $this->get_option( array( $user_role, 'theme_profile' ) ) )
346
+ return $url;
347
+
348
+ $parsed_url = parse_url( $url );
349
+
350
+ $url = Theme_My_Login::get_page_link( 'profile' );
351
+
352
+ if ( isset( $parsed_url['query'] ) )
353
+ $url = add_query_arg( array_map( 'rawurlencode', wp_parse_args( $parsed_url['query'] ) ), $url );
354
+ }
355
+ return $url;
356
+ }
357
+
358
+ /**
359
+ * Hide Profile link if user is not logged in
360
+ *
361
+ * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
362
+ *
363
+ * @see wp_setup_nav_menu_item()
364
+ * @since 6.4
365
+ * @access public
366
+ *
367
+ * @param object $menu_item The menu item
368
+ * @return object The (possibly) modified menu item
369
+ */
370
+ public function wp_setup_nav_menu_item( $menu_item ) {
371
+ if ( is_admin() )
372
+ return $menu_item;
373
+
374
+ if ( 'page' != $menu_item->object )
375
+ return $menu_item;
376
+
377
+ // User is not logged in
378
+ if ( ! is_user_logged_in() ) {
379
+
380
+ // Hide Profile
381
+ if ( Theme_My_Login::is_tml_page( 'profile', $menu_item->object_id ) ) {
382
+ $menu_item->_invalid = true;
383
+ }
384
+ }
385
+
386
+ return $menu_item;
387
+ }
388
+ }
389
+
390
+ Theme_My_Login_Themed_Profiles::get_object();
391
+
392
+ endif;
393
+
394
+ if ( is_admin() )
395
+ include_once( dirname( __FILE__ ) . '/admin/themed-profiles-admin.php' );
396
+
modules/user-moderation/admin/user-moderation-admin.php CHANGED
@@ -1,443 +1,443 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login User Moderation Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_User_Moderation
7
- * @since 6.0
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_User_Moderation_Admin' ) ) :
11
- /**
12
- * Theme My Login User Moderation Admin class
13
- *
14
- * @since 6.0
15
- */
16
- class Theme_My_Login_User_Moderation_Admin extends Theme_My_Login_Abstract {
17
- /**
18
- * Holds options key
19
- *
20
- * @since 6.3
21
- * @access protected
22
- * @var string
23
- */
24
- protected $options_key = 'theme_my_login_moderation';
25
-
26
- /**
27
- * Returns singleton instance
28
- *
29
- * @since 6.3
30
- * @access public
31
- * @return object
32
- */
33
- public static function get_object( $class = null ) {
34
- return parent::get_object( __CLASS__ );
35
- }
36
-
37
- /**
38
- * Loads the module
39
- *
40
- * @since 6.0
41
- * @access protected
42
- */
43
- protected function load() {
44
- add_action( 'tml_activate_user-moderation/user-moderation.php', array( $this, 'activate' ) );
45
- add_action( 'tml_uninstall_user-moderation/user-moderation.php', array( $this, 'uninstall' ) );
46
-
47
- add_action( 'tml_modules_loaded', array( $this, 'modules_loaded' ) );
48
-
49
- if ( is_multisite() )
50
- return;
51
-
52
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
53
- add_action( 'admin_init', array( $this, 'admin_init' ) );
54
-
55
- add_action( 'load-users.php', array( $this, 'load_users_page' ) );
56
- add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
57
-
58
- add_action( 'delete_user', array( $this, 'deny_user' ) );
59
- }
60
-
61
- /**
62
- * Returns default options
63
- *
64
- * @since 6.3
65
- * @access public
66
- *
67
- * @return array Default options
68
- */
69
- public static function default_options() {
70
- return Theme_My_Login_User_Moderation::default_options();
71
- }
72
-
73
- /**
74
- * Activates the module
75
- *
76
- * Callback for "tml_activate_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::activate_module()
77
- *
78
- * @see Theme_My_Login_Admin::activate_module()
79
- * @since 6.0
80
- * @access public
81
- *
82
- * @param object $theme_my_login Reference to global $theme_my_login object
83
- */
84
- public function activate() {
85
- if ( is_multisite() ) {
86
- add_settings_error( $this->options_key, 'invalid_module', __( 'User Moderation is not currently compatible with multisite.', 'theme-my-login' ) );
87
- return;
88
- }
89
- add_role( 'pending', 'Pending', array() );
90
- }
91
-
92
- /**
93
- * Uninstalls the module
94
- *
95
- * Callback for "tml_uninstall_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::uninstall()
96
- *
97
- * @see Theme_My_Login_Admin::uninstall()
98
- * @since 6.3
99
- * @access public
100
- */
101
- public function uninstall() {
102
- delete_option( $this->options_key );
103
- remove_role( 'pending' );
104
- }
105
-
106
- /**
107
- * Disables the module if multisite
108
- *
109
- * @since 6.3
110
- * @access public
111
- */
112
- public function modules_loaded() {
113
- if ( is_multisite() ) {
114
- $theme_my_login_admin = Theme_My_Login_Admin::get_object();
115
-
116
- $active_modules = $theme_my_login_admin->get_option( 'active_modules' );
117
- $active_modules = array_values( array_diff( $active_modules, array( 'user-moderation/user-moderation.php' ) ) );
118
-
119
- $theme_my_login_admin->set_option( 'active_modules', $active_modules );
120
- $theme_my_login_admin->save_options();
121
- return;
122
- }
123
- }
124
-
125
- /**
126
- * Adds "Moderation" to Theme My Login menu
127
- *
128
- * Callback for "admin_menu" hook
129
- *
130
- * @since 6.0
131
- * @access public
132
- */
133
- public function admin_menu() {
134
- add_submenu_page(
135
- 'theme_my_login',
136
- __( 'Theme My Login User Moderation Settings', 'theme-my-login' ),
137
- __( 'Moderation', 'theme-my-login' ),
138
- 'manage_options',
139
- $this->options_key,
140
- array( $this, 'settings_page' )
141
- );
142
-
143
- add_settings_section( 'general', null, '__return_false', $this->options_key );
144
-
145
- add_settings_field( 'type', __( 'Moderation Type', 'theme-my-login' ), array( $this, 'settings_field_moderation_type' ), $this->options_key, 'general' );
146
- }
147
-
148
- /**
149
- * Registers options group
150
- *
151
- * Callback for "admin_init" hook
152
- *
153
- * @since 6.0
154
- * @access public
155
- */
156
- public function admin_init() {
157
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
158
- }
159
-
160
- /**
161
- * Renders settings page
162
- *
163
- * @since 6.3
164
- * @access public
165
- */
166
- public function settings_page() {
167
- Theme_My_Login_Admin::settings_page( array(
168
- 'title' => __( 'Theme My Login User Moderation Settings', 'theme-my-login' ),
169
- 'options_key' => $this->options_key
170
- ) );
171
- }
172
-
173
- /**
174
- * Renders Moderation Type settings field
175
- *
176
- * @since 6.3
177
- * @access public
178
- */
179
- public function settings_field_moderation_type() {
180
- ?>
181
- <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_none" value="none"<?php checked( $this->get_option( 'type' ), 'none' ); ?> />
182
- <label for="<?php echo $this->options_key; ?>_type_none"><?php _e( 'None', 'theme-my-login' ); ?></label>
183
- <p class="description"><?php _e( 'Check this option to require no moderation.', 'theme-my-login' ); ?></p>
184
-
185
- <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_email" value="email" <?php checked( $this->get_option( 'type' ), 'email' ); ?> />
186
- <label for="<?php echo $this->options_key; ?>_type_email"><?php _e( 'E-mail Confirmation', 'theme-my-login' ); ?></label>
187
- <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>
188
-
189
- <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_admin" value="admin" <?php checked( $this->get_option( 'type' ), 'admin' ); ?> />
190
- <label for="<?php echo $this->options_key; ?>_type_admin"><?php _e( 'Admin Approval', 'theme-my-login' ); ?></label>
191
- <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>
192
- <?php
193
- }
194
-
195
- /**
196
- * Sanitizes settings
197
- *
198
- * @since 6.3
199
- * @access public
200
- *
201
- * @param array $settings Posted settings
202
- * @return array Sanitized settings
203
- */
204
- public function save_settings( $settings ) {
205
- return array(
206
- 'type' => in_array( $settings['type'], array( 'none', 'email', 'admin' ) ) ? $settings['type'] : 'none'
207
- );
208
- }
209
-
210
- /**
211
- * Attaches actions/filters explicitly to users.php
212
- *
213
- * Callback for "load-users.php" hook
214
- *
215
- * @since 6.0
216
- * @access public
217
- */
218
- public function load_users_page() {
219
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
220
-
221
- // Is there an action?
222
- if ( isset( $_GET['action'] ) ) {
223
-
224
- // Is it a sanctioned action?
225
- if ( in_array( $_GET['action'], array( 'approve', 'resendactivation' ) ) ) {
226
-
227
- // Is there a user ID?
228
- $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
229
-
230
- // No user ID?
231
- if ( ! $user || ! current_user_can( 'edit_user', $user ) )
232
- wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
233
-
234
- // Where did we come from?
235
- $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
236
-
237
- switch ( $_GET['action'] ) {
238
- case 'approve' :
239
- check_admin_referer( 'approve-user' );
240
-
241
- if ( ! self::approve_user( $user ) )
242
- wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
243
-
244
- $redirect_to = add_query_arg( 'update', 'approve', $redirect_to );
245
- break;
246
- case 'resendactivation' :
247
- check_admin_referer( 'resend-activation' );
248
-
249
- do_action( 'tml_user_activation_resend', $user );
250
-
251
- if ( ! Theme_My_Login_User_Moderation::new_user_activation_notification( $user ) )
252
- wp_die( __( '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' ) );
253
-
254
- $redirect_to = add_query_arg( 'update', 'sendactivation', $redirect_to );
255
- break;
256
- }
257
- wp_redirect( $redirect_to );
258
- exit;
259
- }
260
- }
261
- }
262
-
263
- /**
264
- * Adds update messages to the admin screen
265
- *
266
- * Callback for "admin_notices" hook in file admin-header.php
267
- *
268
- * @since 6.0
269
- * @access public
270
- */
271
- public function admin_notices() {
272
- if ( isset( $_GET['update'] ) && in_array( $_GET['update'], array( 'approve', 'sendactivation' ) ) ) {
273
- echo '<div id="message" class="updated fade"><p>';
274
- if ( 'approve' == $_GET['update'] )
275
- _e( 'User approved.', 'theme-my-login' );
276
- elseif ( 'sendactivation' == $_GET['update'] )
277
- _e( 'Activation sent.', 'theme-my-login' );
278
- echo '</p></div>';
279
- }
280
- }
281
-
282
- /**
283
- * Adds "Approve" link for each pending user on users.php
284
- *
285
- * Callback for "user_row_actions" hook in {@internal unknown}
286
- *
287
- * @since 6.0
288
- * @access public
289
- *
290
- * @param array $actions The user actions
291
- * @param WP_User $user_object The current user object
292
- * @return array The filtered user actions
293
- */
294
- public function user_row_actions( $actions, $user_object ) {
295
-
296
- $current_user = wp_get_current_user();
297
-
298
- if ( $current_user->ID != $user_object->ID ) {
299
- if ( in_array( 'pending', (array) $user_object->roles ) ) {
300
- switch ( $this->get_option( 'type' ) ) {
301
- case 'email' :
302
- // Add "Resend Activation" link
303
- $actions['resend-activation'] = sprintf( '<a href="%1$s">%2$s</a>',
304
- add_query_arg( 'wp_http_referer',
305
- urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
306
- wp_nonce_url( "users.php?action=resendactivation&amp;user=$user_object->ID", 'resend-activation' )
307
- ),
308
- __( 'Resend Activation', 'theme-my-login' )
309
- );
310
- break;
311
- case 'admin' :
312
- // Add "Approve" link
313
- $actions['approve-user'] = sprintf( '<a href="%1$s">%2$s</a>',
314
- add_query_arg( 'wp_http_referer',
315
- urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
316
- wp_nonce_url( "users.php?action=approve&amp;user=$user_object->ID", 'approve-user' )
317
- ),
318
- __( 'Approve', 'theme-my-login' )
319
- );
320
- break;
321
- }
322
- }
323
- }
324
- return $actions;
325
- }
326
-
327
- /**
328
- * Handles activating a new user by admin approval
329
- *
330
- * @since 6.0
331
- * @access public
332
- *
333
- * @param int $user_id User's ID
334
- * @return bool Returns false if not a valid user
335
- */
336
- public static function approve_user( $user_id ) {
337
- global $wpdb, $current_site;
338
-
339
- $user_id = (int) $user_id;
340
-
341
- // Get user by ID
342
- $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $user_id ) );
343
- if ( empty( $user ) )
344
- return false;
345
-
346
- do_action( 'approve_user', $user->ID );
347
-
348
- // Clear the activation key if there is one
349
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'ID' => $user->ID ) );
350
-
351
- $approval_role = apply_filters( 'tml_approval_role', get_option( 'default_role' ), $user->ID );
352
-
353
- // Set user role
354
- $user_object = new WP_User( $user->ID );
355
- $user_object->set_role( $approval_role );
356
- unset( $user_object );
357
-
358
- if ( ! apply_filters( 'send_new_user_approval_notification', true ) )
359
- return;
360
-
361
- if ( is_multisite() ) {
362
- $blogname = $current_site->site_name;
363
- } else {
364
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
365
- // we want to reverse this for the plain text arena of emails.
366
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
367
- }
368
-
369
- // Generate something random for a password reset key
370
- $key = wp_generate_password( 20, false );
371
-
372
- do_action( 'retrieve_password_key', $user->user_login, $key );
373
-
374
- // Now insert the key, hashed, into the DB
375
- require_once ABSPATH . WPINC . '/class-phpass.php';
376
- $wp_hasher = new PasswordHash( 8, true );
377
-
378
- $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
379
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
380
-
381
- $message = sprintf( __( 'You have been approved access to %s', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
382
- $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user->user_login ) . "\r\n";
383
- $message .= __( 'To set your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
384
- $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n";
385
-
386
- $message .= site_url( 'wp-login.php', 'login' ) . "\r\n";
387
-
388
- $title = sprintf( __( '[%s] Registration Approved', 'theme-my-login' ), $blogname );
389
-
390
- $title = apply_filters( 'user_approval_notification_title', $title, $user->ID );
391
- $message = apply_filters( 'user_approval_notification_message', $message, $key, $user->ID );
392
-
393
- if ( $message && ! wp_mail( $user->user_email, $title, $message ) )
394
- 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>' );
395
-
396
- return true;
397
- }
398
-
399
- /**
400
- * Called upon deletion of a user in the "Pending" role
401
- *
402
- * @since 6.0
403
- * @access public
404
- *
405
- * @param int $user_id User's ID
406
- */
407
- public function deny_user( $user_id ) {
408
- global $current_site;
409
-
410
- $user_id = (int) $user_id;
411
-
412
- $user = new WP_User( $user_id );
413
- if ( ! in_array( 'pending', (array) $user->roles ) )
414
- return;
415
-
416
- do_action( 'deny_user', $user->ID );
417
-
418
- if ( ! apply_filters( 'send_new_user_denial_notification', true ) )
419
- return;
420
-
421
- if ( is_multisite() ) {
422
- $blogname = $current_site->site_name;
423
- } else {
424
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
425
- // we want to reverse this for the plain text arena of emails.
426
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
427
- }
428
-
429
- $message = sprintf( __( 'You have been denied access to %s', 'theme-my-login' ), $blogname );
430
- $title = sprintf( __( '[%s] Registration Denied', 'theme-my-login' ), $blogname );
431
-
432
- $title = apply_filters( 'user_denial_notification_title', $title, $user_id );
433
- $message = apply_filters( 'user_denial_notification_message', $message, $user_id );
434
-
435
- if ( $message && ! wp_mail( $user->user_email, $title, $message ) )
436
- 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>' );
437
- }
438
- }
439
-
440
- Theme_My_Login_User_Moderation_Admin::get_object();
441
-
442
- endif;
443
-
1
+ <?php
2
+ /**
3
+ * Holds Theme My Login User Moderation Admin class
4
+ *
5
+ * @package Theme_My_Login
6
+ * @subpackage Theme_My_Login_User_Moderation
7
+ * @since 6.0
8
+ */
9
+
10
+ if ( ! class_exists( 'Theme_My_Login_User_Moderation_Admin' ) ) :
11
+ /**
12
+ * Theme My Login User Moderation Admin class
13
+ *
14
+ * @since 6.0
15
+ */
16
+ class Theme_My_Login_User_Moderation_Admin extends Theme_My_Login_Abstract {
17
+ /**
18
+ * Holds options key
19
+ *
20
+ * @since 6.3
21
+ * @access protected
22
+ * @var string
23
+ */
24
+ protected $options_key = 'theme_my_login_moderation';
25
+
26
+ /**
27
+ * Returns singleton instance
28
+ *
29
+ * @since 6.3
30
+ * @access public
31
+ * @return object
32
+ */
33
+ public static function get_object( $class = null ) {
34
+ return parent::get_object( __CLASS__ );
35
+ }
36
+
37
+ /**
38
+ * Loads the module
39
+ *
40
+ * @since 6.0
41
+ * @access protected
42
+ */
43
+ protected function load() {
44
+ add_action( 'tml_activate_user-moderation/user-moderation.php', array( $this, 'activate' ) );
45
+ add_action( 'tml_uninstall_user-moderation/user-moderation.php', array( $this, 'uninstall' ) );
46
+
47
+ add_action( 'tml_modules_loaded', array( $this, 'modules_loaded' ) );
48
+
49
+ if ( is_multisite() )
50
+ return;
51
+
52
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
53
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
54
+
55
+ add_action( 'load-users.php', array( $this, 'load_users_page' ) );
56
+ add_filter( 'user_row_actions', array( $this, 'user_row_actions' ), 10, 2 );
57
+
58
+ add_action( 'delete_user', array( $this, 'deny_user' ) );
59
+ }
60
+
61
+ /**
62
+ * Returns default options
63
+ *
64
+ * @since 6.3
65
+ * @access public
66
+ *
67
+ * @return array Default options
68
+ */
69
+ public static function default_options() {
70
+ return Theme_My_Login_User_Moderation::default_options();
71
+ }
72
+
73
+ /**
74
+ * Activates the module
75
+ *
76
+ * Callback for "tml_activate_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::activate_module()
77
+ *
78
+ * @see Theme_My_Login_Admin::activate_module()
79
+ * @since 6.0
80
+ * @access public
81
+ *
82
+ * @param object $theme_my_login Reference to global $theme_my_login object
83
+ */
84
+ public function activate() {
85
+ if ( is_multisite() ) {
86
+ add_settings_error( $this->options_key, 'invalid_module', __( 'User Moderation is not currently compatible with multisite.', 'theme-my-login' ) );
87
+ return;
88
+ }
89
+ add_role( 'pending', 'Pending', array() );
90
+ }
91
+
92
+ /**
93
+ * Uninstalls the module
94
+ *
95
+ * Callback for "tml_uninstall_user-moderation/user-moderation.php" hook in method Theme_My_Login_Admin::uninstall()
96
+ *
97
+ * @see Theme_My_Login_Admin::uninstall()
98
+ * @since 6.3
99
+ * @access public
100
+ */
101
+ public function uninstall() {
102
+ delete_option( $this->options_key );
103
+ remove_role( 'pending' );
104
+ }
105
+
106
+ /**
107
+ * Disables the module if multisite
108
+ *
109
+ * @since 6.3
110
+ * @access public
111
+ */
112
+ public function modules_loaded() {
113
+ if ( is_multisite() ) {
114
+ $theme_my_login_admin = Theme_My_Login_Admin::get_object();
115
+
116
+ $active_modules = $theme_my_login_admin->get_option( 'active_modules' );
117
+ $active_modules = array_values( array_diff( $active_modules, array( 'user-moderation/user-moderation.php' ) ) );
118
+
119
+ $theme_my_login_admin->set_option( 'active_modules', $active_modules );
120
+ $theme_my_login_admin->save_options();
121
+ return;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Adds "Moderation" to Theme My Login menu
127
+ *
128
+ * Callback for "admin_menu" hook
129
+ *
130
+ * @since 6.0
131
+ * @access public
132
+ */
133
+ public function admin_menu() {
134
+ add_submenu_page(
135
+ 'theme_my_login',
136
+ __( 'Theme My Login User Moderation Settings', 'theme-my-login' ),
137
+ __( 'Moderation', 'theme-my-login' ),
138
+ 'manage_options',
139
+ $this->options_key,
140
+ array( $this, 'settings_page' )
141
+ );
142
+
143
+ add_settings_section( 'general', null, '__return_false', $this->options_key );
144
+
145
+ add_settings_field( 'type', __( 'Moderation Type', 'theme-my-login' ), array( $this, 'settings_field_moderation_type' ), $this->options_key, 'general' );
146
+ }
147
+
148
+ /**
149
+ * Registers options group
150
+ *
151
+ * Callback for "admin_init" hook
152
+ *
153
+ * @since 6.0
154
+ * @access public
155
+ */
156
+ public function admin_init() {
157
+ register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
158
+ }
159
+
160
+ /**
161
+ * Renders settings page
162
+ *
163
+ * @since 6.3
164
+ * @access public
165
+ */
166
+ public function settings_page() {
167
+ Theme_My_Login_Admin::settings_page( array(
168
+ 'title' => __( 'Theme My Login User Moderation Settings', 'theme-my-login' ),
169
+ 'options_key' => $this->options_key
170
+ ) );
171
+ }
172
+
173
+ /**
174
+ * Renders Moderation Type settings field
175
+ *
176
+ * @since 6.3
177
+ * @access public
178
+ */
179
+ public function settings_field_moderation_type() {
180
+ ?>
181
+ <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_none" value="none"<?php checked( $this->get_option( 'type' ), 'none' ); ?> />
182
+ <label for="<?php echo $this->options_key; ?>_type_none"><?php _e( 'None', 'theme-my-login' ); ?></label>
183
+ <p class="description"><?php _e( 'Check this option to require no moderation.', 'theme-my-login' ); ?></p>
184
+
185
+ <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_email" value="email" <?php checked( $this->get_option( 'type' ), 'email' ); ?> />
186
+ <label for="<?php echo $this->options_key; ?>_type_email"><?php _e( 'E-mail Confirmation', 'theme-my-login' ); ?></label>
187
+ <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>
188
+
189
+ <input name="<?php echo $this->options_key; ?>[type]" type="radio" id="<?php echo $this->options_key; ?>_type_admin" value="admin" <?php checked( $this->get_option( 'type' ), 'admin' ); ?> />
190
+ <label for="<?php echo $this->options_key; ?>_type_admin"><?php _e( 'Admin Approval', 'theme-my-login' ); ?></label>
191
+ <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>
192
+ <?php
193
+ }
194
+
195
+ /**
196
+ * Sanitizes settings
197
+ *
198
+ * @since 6.3
199
+ * @access public
200
+ *
201
+ * @param array $settings Posted settings
202
+ * @return array Sanitized settings
203
+ */
204
+ public function save_settings( $settings ) {
205
+ return array(
206
+ 'type' => in_array( $settings['type'], array( 'none', 'email', 'admin' ) ) ? $settings['type'] : 'none'
207
+ );
208
+ }
209
+
210
+ /**
211
+ * Attaches actions/filters explicitly to users.php
212
+ *
213
+ * Callback for "load-users.php" hook
214
+ *
215
+ * @since 6.0
216
+ * @access public
217
+ */
218
+ public function load_users_page() {
219
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
220
+
221
+ // Is there an action?
222
+ if ( isset( $_GET['action'] ) ) {
223
+
224
+ // Is it a sanctioned action?
225
+ if ( in_array( $_GET['action'], array( 'approve', 'resendactivation' ) ) ) {
226
+
227
+ // Is there a user ID?
228
+ $user = isset( $_GET['user'] ) ? $_GET['user'] : '';
229
+
230
+ // No user ID?
231
+ if ( ! $user || ! current_user_can( 'edit_user', $user ) )
232
+ wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
233
+
234
+ // Where did we come from?
235
+ $redirect_to = isset( $_REQUEST['wp_http_referer'] ) ? remove_query_arg( array( 'wp_http_referer', 'updated', 'delete_count' ), stripslashes( $_REQUEST['wp_http_referer'] ) ) : 'users.php';
236
+
237
+ switch ( $_GET['action'] ) {
238
+ case 'approve' :
239
+ check_admin_referer( 'approve-user' );
240
+
241
+ if ( ! self::approve_user( $user ) )
242
+ wp_die( __( 'You can&#8217;t edit that user.', 'theme-my-login' ) );
243
+
244
+ $redirect_to = add_query_arg( 'update', 'approve', $redirect_to );
245
+ break;
246
+ case 'resendactivation' :
247
+ check_admin_referer( 'resend-activation' );
248
+
249
+ do_action( 'tml_user_activation_resend', $user );
250
+
251
+ if ( ! Theme_My_Login_User_Moderation::new_user_activation_notification( $user ) )
252
+ wp_die( __( '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' ) );
253
+
254
+ $redirect_to = add_query_arg( 'update', 'sendactivation', $redirect_to );
255
+ break;
256
+ }
257
+ wp_redirect( $redirect_to );
258
+ exit;
259
+ }
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Adds update messages to the admin screen
265
+ *
266
+ * Callback for "admin_notices" hook in file admin-header.php
267
+ *
268
+ * @since 6.0
269
+ * @access public
270
+ */
271
+ public function admin_notices() {
272
+ if ( isset( $_GET['update'] ) && in_array( $_GET['update'], array( 'approve', 'sendactivation' ) ) ) {
273
+ echo '<div id="message" class="updated fade"><p>';
274
+ if ( 'approve' == $_GET['update'] )
275
+ _e( 'User approved.', 'theme-my-login' );
276
+ elseif ( 'sendactivation' == $_GET['update'] )
277
+ _e( 'Activation sent.', 'theme-my-login' );
278
+ echo '</p></div>';
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Adds "Approve" link for each pending user on users.php
284
+ *
285
+ * Callback for "user_row_actions" hook in {@internal unknown}
286
+ *
287
+ * @since 6.0
288
+ * @access public
289
+ *
290
+ * @param array $actions The user actions
291
+ * @param WP_User $user_object The current user object
292
+ * @return array The filtered user actions
293
+ */
294
+ public function user_row_actions( $actions, $user_object ) {
295
+
296
+ $current_user = wp_get_current_user();
297
+
298
+ if ( $current_user->ID != $user_object->ID ) {
299
+ if ( in_array( 'pending', (array) $user_object->roles ) ) {
300
+ switch ( $this->get_option( 'type' ) ) {
301
+ case 'email' :
302
+ // Add "Resend Activation" link
303
+ $actions['resend-activation'] = sprintf( '<a href="%1$s">%2$s</a>',
304
+ add_query_arg( 'wp_http_referer',
305
+ urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
306
+ wp_nonce_url( "users.php?action=resendactivation&amp;user=$user_object->ID", 'resend-activation' )
307
+ ),
308
+ __( 'Resend Activation', 'theme-my-login' )
309
+ );
310
+ break;
311
+ case 'admin' :
312
+ // Add "Approve" link
313
+ $actions['approve-user'] = sprintf( '<a href="%1$s">%2$s</a>',
314
+ add_query_arg( 'wp_http_referer',
315
+ urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ),
316
+ wp_nonce_url( "users.php?action=approve&amp;user=$user_object->ID", 'approve-user' )
317
+ ),
318
+ __( 'Approve', 'theme-my-login' )
319
+ );
320
+ break;
321
+ }
322
+ }
323
+ }
324
+ return $actions;
325
+ }
326
+
327
+ /**
328
+ * Handles activating a new user by admin approval
329
+ *
330
+ * @since 6.0
331
+ * @access public
332
+ *
333
+ * @param int $user_id User's ID
334
+ * @return bool Returns false if not a valid user
335
+ */
336
+ public static function approve_user( $user_id ) {
337
+ global $wpdb, $current_site;
338
+
339
+ $user_id = (int) $user_id;
340
+
341
+ // Get user by ID
342
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $user_id ) );
343
+ if ( empty( $user ) )
344
+ return false;
345
+
346
+ do_action( 'approve_user', $user->ID );
347
+
348
+ // Clear the activation key if there is one
349
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'ID' => $user->ID ) );
350
+
351
+ $approval_role = apply_filters( 'tml_approval_role', get_option( 'default_role' ), $user->ID );
352
+
353
+ // Set user role
354
+ $user_object = new WP_User( $user->ID );
355
+ $user_object->set_role( $approval_role );
356
+ unset( $user_object );
357
+
358
+ if ( ! apply_filters( 'send_new_user_approval_notification', true ) )
359
+ return;
360
+
361
+ if ( is_multisite() ) {
362
+ $blogname = $current_site->site_name;
363
+ } else {
364
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
365
+ // we want to reverse this for the plain text arena of emails.
366
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
367
+ }
368
+
369
+ // Generate something random for a password reset key
370
+ $key = wp_generate_password( 20, false );
371
+
372
+ do_action( 'retrieve_password_key', $user->user_login, $key );
373
+
374
+ // Now insert the key, hashed, into the DB
375
+ require_once ABSPATH . WPINC . '/class-phpass.php';
376
+ $wp_hasher = new PasswordHash( 8, true );
377
+
378
+ $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
379
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
380
+
381
+ $message = sprintf( __( 'You have been approved access to %s', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
382
+ $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user->user_login ) . "\r\n";
383
+ $message .= __( 'To set your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
384
+ $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n";
385
+
386
+ $message .= site_url( 'wp-login.php', 'login' ) . "\r\n";
387
+
388
+ $title = sprintf( __( '[%s] Registration Approved', 'theme-my-login' ), $blogname );
389
+
390
+ $title = apply_filters( 'user_approval_notification_title', $title, $user->ID );
391
+ $message = apply_filters( 'user_approval_notification_message', $message, $key, $user->ID );
392
+
393
+ if ( $message && ! wp_mail( $user->user_email, $title, $message ) )
394
+ 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>' );
395
+
396
+ return true;
397
+ }
398
+
399
+ /**
400
+ * Called upon deletion of a user in the "Pending" role
401
+ *
402
+ * @since 6.0
403
+ * @access public
404
+ *
405
+ * @param int $user_id User's ID
406
+ */
407
+ public function deny_user( $user_id ) {
408
+ global $current_site;
409
+
410
+ $user_id = (int) $user_id;
411
+
412
+ $user = new WP_User( $user_id );
413
+ if ( ! in_array( 'pending', (array) $user->roles ) )
414
+ return;
415
+
416
+ do_action( 'deny_user', $user->ID );
417
+
418
+ if ( ! apply_filters( 'send_new_user_denial_notification', true ) )
419
+ return;
420
+
421
+ if ( is_multisite() ) {
422
+ $blogname = $current_site->site_name;
423
+ } else {
424
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
425
+ // we want to reverse this for the plain text arena of emails.
426
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
427
+ }
428
+
429
+ $message = sprintf( __( 'You have been denied access to %s', 'theme-my-login' ), $blogname );
430
+ $title = sprintf( __( '[%s] Registration Denied', 'theme-my-login' ), $blogname );
431
+
432
+ $title = apply_filters( 'user_denial_notification_title', $title, $user_id );
433
+ $message = apply_filters( 'user_denial_notification_message', $message, $user_id );
434
+
435
+ if ( $message && ! wp_mail( $user->user_email, $title, $message ) )
436
+ 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>' );
437
+ }
438
+ }
439
+
440
+ Theme_My_Login_User_Moderation_Admin::get_object();
441
+
442
+ endif;
443
+
modules/user-moderation/user-moderation.php CHANGED
@@ -1,480 +1,482 @@
1
- <?php
2
- /**
3
- * 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
- * Holds Theme My Login User Moderation class
7
- *
8
- * @packagae Theme_My_Login
9
- * @subpackage Theme_My_Login_User_Moderation
10
- * @since 6.0
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_User_Moderation' ) ) :
14
- /**
15
- * Theme My Login User Moderation class
16
- *
17
- * Adds the ability to require users to confirm their e-mail address or be activated by an administrator before becoming active on the site.
18
- *
19
- * @since 6.0
20
- */
21
- class Theme_My_Login_User_Moderation extends Theme_My_Login_Abstract {
22
- /**
23
- * Holds options key
24
- *
25
- * @since 6.3
26
- * @access protected
27
- * @var string
28
- */
29
- protected $options_key = 'theme_my_login_moderation';
30
-
31
- /**
32
- * Returns singleton instance
33
- *
34
- * @since 6.3
35
- * @access public
36
- * @return object
37
- */
38
- public static function get_object( $class = null ) {
39
- return parent::get_object( __CLASS__ );
40
- }
41
-
42
- /**
43
- * Returns default options
44
- *
45
- * @since 6.3
46
- * @access public
47
- *
48
- * @return array Default options
49
- */
50
- public static function default_options() {
51
- return array(
52
- 'type' => 'none'
53
- );
54
- }
55
-
56
- /**
57
- * Loads the module
58
- *
59
- * @since 6.0
60
- * @access protected
61
- */
62
- protected function load() {
63
- if ( is_multisite() )
64
- return;
65
-
66
- if ( in_array( $this->get_option( 'type' ), array( 'admin', 'email' ) ) ) {
67
-
68
- add_action( 'register_post', array( $this, 'register_post' ) );
69
- add_filter( 'registration_redirect', array( $this, 'registration_redirect' ), 100 );
70
-
71
- add_action( 'authenticate', array( $this, 'authenticate' ), 100, 3 );
72
- add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ), 10, 2 );
73
-
74
- add_action( 'tml_request', array( $this, 'action_messages' ) );
75
- add_action( 'tml_new_user_activated', array( $this, 'new_user_activated' ) );
76
-
77
- if ( 'email' == $this->get_option( 'type' ) ) {
78
- add_action( 'tml_request_activate', array( $this, 'user_activation' ) );
79
- add_action( 'tml_request_sendactivation', array( $this, 'send_activation' ) );
80
- }
81
- }
82
- }
83
-
84
- /**
85
- * Applies user moderation upon registration
86
- *
87
- * @since 6.0
88
- * @access public
89
- */
90
- public function register_post() {
91
- // Remove default new user notification
92
- if ( has_action( 'register_new_user', 'wp_send_new_user_notifications' ) )
93
- remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
94
-
95
- // Remove Custom Email new user notification
96
- if ( class_exists( 'Theme_My_Login_Custom_Email' ) ) {
97
- $custom_email = Theme_My_Login_Custom_Email::get_object();
98
- if ( has_action( 'register_new_user', array( $custom_email, 'new_user_notification' ) ) )
99
- remove_action( 'register_new_user', array( $custom_email, 'new_user_notification' ) );
100
- }
101
-
102
- // Moderate user upon registration
103
- add_action( 'register_new_user', array( $this, 'moderate_user' ), 100 );
104
- }
105
-
106
- /**
107
- * Changes the registration redirection based upon moderaton type
108
- *
109
- * Callback for "registration_redirect" hook in method Theme_My_Login_Template::get_redirect_url()
110
- *
111
- * @see Theme_My_Login_Template::get_redirect_url()
112
- * @since 6.0
113
- * @access public
114
- *
115
- * @param string $redirect_to Default redirect
116
- * @return string URL to redirect to
117
- */
118
- public function registration_redirect( $redirect_to ) {
119
-
120
- $redirect_to = Theme_My_Login::get_page_link( 'login' );
121
-
122
- switch ( $this->get_option( 'type' ) ) {
123
- case 'email' :
124
- $redirect_to = add_query_arg( 'pending', 'activation', $redirect_to );
125
- break;
126
- case 'admin' :
127
- $redirect_to = add_query_arg( 'pending', 'approval', $redirect_to );
128
- break;
129
- }
130
-
131
- return $redirect_to;
132
- }
133
-
134
- /**
135
- * Blocks "pending" users from loggin in
136
- *
137
- * Callback for "authenticate" hook in function wp_authenticate()
138
- *
139
- * @see wp_authenticate()
140
- * @since 6.0
141
- * @access public
142
- *
143
- * @param WP_User $user WP_User object
144
- * @param string $username Username posted
145
- * @param string $password Password posted
146
- * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
147
- */
148
- public function authenticate( $user, $username, $password ) {
149
- global $wpdb;
150
-
151
- $cap_key = $wpdb->prefix . 'capabilities';
152
-
153
- if ( $userdata = get_user_by( 'login', $username ) ) {
154
- if ( array_key_exists( 'pending', (array) $userdata->$cap_key ) ) {
155
- if ( 'email' == $this->get_option( 'type' ) ) {
156
- return new WP_Error( 'pending', sprintf(
157
- __( '<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a href="%s">Resend activation</a>?', 'theme-my-login' ),
158
- Theme_My_Login::get_page_link( 'login', array( 'action' => 'sendactivation', 'login' => $username ) )
159
- ) );
160
- } else {
161
- return new WP_Error( 'pending', __( '<strong>ERROR</strong>: Your registration has not yet been approved.', 'theme-my-login' ) );
162
- }
163
- }
164
- }
165
- return $user;
166
- }
167
-
168
- /**
169
- * Blocks "pending" users from resetting their password
170
- *
171
- * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
172
- *
173
- * @see Theme_My_Login::retrieve_password()
174
- * @since 6.0
175
- * @access public
176
- *
177
- * @param bool $allow Default setting
178
- * @param int $user_id User ID
179
- * @return bool Whether to allow password reset or not
180
- */
181
- public function allow_password_reset( $allow, $user_id ) {
182
- $user = get_user_by( 'id', $user_id );
183
- if ( in_array( 'pending', (array) $user->roles ) )
184
- return false;
185
- return $allow;
186
- }
187
-
188
- /**
189
- * Handles display of various action/status messages
190
- *
191
- * @since 6.0
192
- * @access public
193
- *
194
- * @param object $theme_my_login Reference to global $theme_my_login object
195
- */
196
- public function action_messages( &$theme_my_login ) {
197
- if ( isset( $_GET['pending'] ) ) {
198
- switch ( $_GET['pending'] ) {
199
- case 'activation' :
200
- $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' ), 'message' );
201
- break;
202
- case 'approval' :
203
- $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' ), 'message' );
204
- break;
205
- }
206
- }
207
-
208
- if ( isset( $_GET['activation'] ) ) {
209
- switch ( $_GET['activation'] ) {
210
- case 'complete' :
211
- if ( class_exists( 'Theme_My_Login_Custom_Passwords' ) )
212
- $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. You may now log in.', 'theme-my-login' ), 'message' );
213
- else
214
- $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. Please check your e-mail for your password.', 'theme-my-login' ), 'message' );
215
- break;
216
- case 'invalidkey' :
217
- $theme_my_login->errors->add( 'invalid_key', __( '<strong>ERROR</strong>: Sorry, that key does not appear to be valid.', 'theme-my-login' ) );
218
- break;
219
- }
220
- }
221
-
222
- if ( isset( $_GET['sendactivation'] ) ) {
223
- switch ( $_GET['sendactivation'] ) {
224
- case 'failed' :
225
- $theme_my_login->errors->add( 'sendactivation_failed', __('<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent.', 'theme-my-login' ) );
226
- break;
227
- case 'sent' :
228
- $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' ), 'message' );
229
- break;
230
- }
231
- }
232
- }
233
-
234
- /**
235
- * Applies moderation to a newly registered user
236
- *
237
- * Callback for "register_post" hook in method Theme_My_Login::register_new_user()
238
- *
239
- * @see Theme_My_Login::register_new_user()
240
- * @since 6.0
241
- * @access public
242
- *
243
- * @param int $user_id The user's ID
244
- */
245
- public function moderate_user( $user_id ) {
246
- global $wpdb;
247
-
248
- // Set user role to "pending"
249
- $user = new WP_User( $user_id );
250
-
251
- // Make sure user isn't already "Pending"
252
- if ( in_array( 'pending', (array) $user->roles ) )
253
- return;
254
-
255
- // Set user to "Pending" role
256
- $user->set_role( 'pending' );
257
-
258
- // Send appropriate e-mail depending on moderation type
259
- if ( 'email' == $this->get_option( 'type' ) ) {
260
- // Send activation e-mail
261
- self::new_user_activation_notification( $user_id );
262
- } elseif ( 'admin' == $this->get_option( 'type' ) ) {
263
- // Send approval e-mail
264
- if ( apply_filters( 'send_new_user_approval_admin_notification', true ) )
265
- self::new_user_approval_admin_notification( $user_id );
266
- }
267
- }
268
-
269
- /**
270
- * Handles "activate" action for login page
271
- *
272
- * Callback for "tml_request_activate" hook in method Theme_My_Login::the_request();
273
- *
274
- * @see Theme_My_Login::the_request();
275
- * @since 6.0
276
- * @access public
277
- */
278
- public function user_activation() {
279
- // Attempt to activate the user
280
- $errors = self::activate_new_user( $_GET['key'], $_GET['login'] );
281
-
282
- $redirect_to = Theme_My_Login_Common::get_current_url();
283
-
284
- // Make sure there are no errors
285
- if ( ! is_wp_error( $errors ) )
286
- $redirect_to = add_query_arg( 'activation', 'complete', $redirect_to );
287
- else
288
- $redirect_to = add_query_arg( 'activation', 'invalidkey', $redirect_to );
289
-
290
- wp_redirect( $redirect_to );
291
- exit;
292
- }
293
-
294
- /**
295
- * Handles "send_activation" action for login page
296
- *
297
- * Callback for "tml_request_send_activation" hook in method Theme_My_Login::the_request();
298
- *
299
- * @see Theme_My_Login::the_request();
300
- * @since 6.0
301
- * @access public
302
- */
303
- public static function send_activation() {
304
- global $wpdb;
305
-
306
- $login = isset( $_GET['login'] ) ? trim( $_GET['login'] ) : '';
307
-
308
- if ( ! $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_login = %s", $login ) ) ) {
309
- $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'failed' ) );
310
- wp_redirect( $redirect_to );
311
- exit;
312
- }
313
-
314
- do_action( 'tml_user_activation_resend', $user_id );
315
-
316
- $user = new WP_User( $user_id );
317
-
318
- if ( in_array( 'pending', (array) $user->roles ) ) {
319
- // Send activation e-mail
320
- self::new_user_activation_notification( $user->ID );
321
- // Now redirect them
322
- $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'sent' ) );
323
- wp_redirect( $redirect_to );
324
- exit;
325
- }
326
- }
327
-
328
- /**
329
- * Handles activating a new user by user email confirmation
330
- *
331
- * @since 6.0
332
- * @access public
333
- *
334
- * @param string $key Hash to validate sending confirmation email
335
- * @param string $login User's username for logging in
336
- * @return bool|WP_Error True if successful, WP_Error otherwise
337
- */
338
- public static function activate_new_user( $key, $login ) {
339
- global $wpdb;
340
-
341
- $key = preg_replace( '/[^a-z0-9]/i', '', $key );
342
-
343
- if ( empty( $key ) || ! is_string( $key ) )
344
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
345
-
346
- if ( empty( $login ) || ! is_string( $login ) )
347
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
348
-
349
- // Validate activation key
350
- $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
351
- if ( empty( $user ) )
352
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
353
-
354
- do_action( 'tml_user_activation_post', $user->user_login, $user->user_email );
355
-
356
- // Allow plugins to short-circuit process and send errors
357
- $errors = new WP_Error();
358
- $errors = apply_filters( 'tml_user_activation_errors', $errors, $user->user_login, $user->user_email );
359
-
360
- // Return errors if there are any
361
- if ( $errors->get_error_code() )
362
- return $errors;
363
-
364
- // Clear the activation key
365
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'user_login' => $login ) );
366
-
367
- // Set user role
368
- $user_object = new WP_User( $user->ID );
369
- $user_object->set_role( get_option( 'default_role' ) );
370
-
371
- do_action( 'tml_new_user_activated', $user->ID );
372
-
373
- return true;
374
- }
375
-
376
- /**
377
- * Calls the "register_new_user" hook
378
- *
379
- * @since 6.0
380
- * @access public
381
- *
382
- * @param int $user_id The user's ID
383
- */
384
- public function new_user_activated( $user_id ) {
385
- do_action( 'register_new_user', $user_id );
386
- }
387
-
388
- /**
389
- * Notifies a pending user to activate their account
390
- *
391
- * @since 6.0
392
- * @access public
393
- *
394
- * @param int $user_id The user's ID
395
- */
396
- public static function new_user_activation_notification( $user_id ) {
397
- global $wpdb, $current_site;
398
-
399
- $user = new WP_User( $user_id );
400
-
401
- $user_login = stripslashes( $user->user_login );
402
- $user_email = stripslashes( $user->user_email );
403
-
404
- // Generate an activation key
405
- $key = wp_generate_password( 20, false );
406
-
407
- // Set the activation key for the user
408
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user->user_login ) );
409
-
410
- if ( is_multisite() ) {
411
- $blogname = $current_site->site_name;
412
- } else {
413
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
414
- // we want to reverse this for the plain text arena of emails.
415
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
416
- }
417
-
418
- $activation_url = add_query_arg( array( 'action' => 'activate', 'key' => $key, 'login' => rawurlencode( $user_login ) ), wp_login_url() );
419
-
420
- $title = sprintf( __( '[%s] Activate Your Account', 'theme-my-login' ), $blogname );
421
- $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";
422
- $message .= $activation_url . "\r\n";
423
-
424
- $title = apply_filters( 'user_activation_notification_title', $title, $user_id );
425
- $message = apply_filters( 'user_activation_notification_message', $message, $activation_url, $user_id );
426
-
427
- return wp_mail( $user_email, $title, $message );
428
- }
429
-
430
- /**
431
- * Notifies the administrator of a pending user needing approval
432
- *
433
- * @since 6.0
434
- * @access public
435
- *
436
- * @param int $user_id The user's ID
437
- */
438
- public static function new_user_approval_admin_notification( $user_id ) {
439
- global $current_site;
440
-
441
- if ( ! apply_filters( 'send_new_user_approval_admin_notification', true ) )
442
- return;
443
-
444
- $user = new WP_User( $user_id );
445
-
446
- $user_login = stripslashes( $user->user_login );
447
- $user_email = stripslashes( $user->user_email );
448
-
449
- if ( is_multisite() ) {
450
- $blogname = $current_site->site_name;
451
- } else {
452
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
453
- // we want to reverse this for the plain text arena of emails.
454
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
455
- }
456
-
457
- $title = sprintf( __( '[%s] New User Awaiting Approval', 'theme-my-login' ), $blogname );
458
-
459
- $message = sprintf( __( 'New user requires approval on your blog %s:', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
460
- $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n";
461
- $message .= sprintf( __( 'E-mail: %s', 'theme-my-login' ), $user_email ) . "\r\n\r\n";
462
- $message .= __( 'To approve or deny this user:', 'theme-my-login' ) . "\r\n";
463
- $message .= admin_url( 'users.php?role=pending' );
464
-
465
- $title = apply_filters( 'user_approval_admin_notification_title', $title, $user_id );
466
- $message = apply_filters( 'user_approval_admin_notification_message', $message, $user_id );
467
-
468
- $to = apply_filters( 'user_approval_admin_notification_mail_to', get_option( 'admin_email' ) );
469
-
470
- @wp_mail( $to, $title, $message );
471
- }
472
- }
473
-
474
- Theme_My_Login_User_Moderation::get_object();
475
-
476
- endif;
477
-
478
- if ( is_admin() )
479
- include_once( dirname( __FILE__ ) . '/admin/user-moderation-admin.php' );
480
-
 
 
1
+ <?php
2
+ /**
3
+ * 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
+ * Holds Theme My Login User Moderation class
7
+ *
8
+ * @packagae Theme_My_Login
9
+ * @subpackage Theme_My_Login_User_Moderation
10
+ * @since 6.0
11
+ */
12
+
13
+ if ( ! class_exists( 'Theme_My_Login_User_Moderation' ) ) :
14
+ /**
15
+ * Theme My Login User Moderation class
16
+ *
17
+ * Adds the ability to require users to confirm their e-mail address or be activated by an administrator before becoming active on the site.
18
+ *
19
+ * @since 6.0
20
+ */
21
+ class Theme_My_Login_User_Moderation extends Theme_My_Login_Abstract {
22
+ /**
23
+ * Holds options key
24
+ *
25
+ * @since 6.3
26
+ * @access protected
27
+ * @var string
28
+ */
29
+ protected $options_key = 'theme_my_login_moderation';
30
+
31
+ /**
32
+ * Returns singleton instance
33
+ *
34
+ * @since 6.3
35
+ * @access public
36
+ * @return object
37
+ */
38
+ public static function get_object( $class = null ) {
39
+ return parent::get_object( __CLASS__ );
40
+ }
41
+
42
+ /**
43
+ * Returns default options
44
+ *
45
+ * @since 6.3
46
+ * @access public
47
+ *
48
+ * @return array Default options
49
+ */
50
+ public static function default_options() {
51
+ return array(
52
+ 'type' => 'none'
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Loads the module
58
+ *
59
+ * @since 6.0
60
+ * @access protected
61
+ */
62
+ protected function load() {
63
+ if ( is_multisite() )
64
+ return;
65
+
66
+ if ( in_array( $this->get_option( 'type' ), array( 'admin', 'email' ) ) ) {
67
+
68
+ add_action( 'register_post', array( $this, 'register_post' ) );
69
+ add_filter( 'registration_redirect', array( $this, 'registration_redirect' ), 100 );
70
+
71
+ add_action( 'authenticate', array( $this, 'authenticate' ), 100, 3 );
72
+ add_filter( 'allow_password_reset', array( $this, 'allow_password_reset' ), 10, 2 );
73
+
74
+ add_action( 'tml_request', array( $this, 'action_messages' ) );
75
+ add_action( 'tml_new_user_activated', array( $this, 'new_user_activated' ) );
76
+
77
+ if ( 'email' == $this->get_option( 'type' ) ) {
78
+ add_action( 'tml_request_activate', array( $this, 'user_activation' ) );
79
+ add_action( 'tml_request_sendactivation', array( $this, 'send_activation' ) );
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Applies user moderation upon registration
86
+ *
87
+ * @since 6.0
88
+ * @access public
89
+ */
90
+ public function register_post() {
91
+ // Remove default new user notification
92
+ if ( has_action( 'register_new_user', 'wp_send_new_user_notifications' ) )
93
+ remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
94
+
95
+ // Remove Custom Email new user notification
96
+ if ( class_exists( 'Theme_My_Login_Custom_Email' ) ) {
97
+ $custom_email = Theme_My_Login_Custom_Email::get_object();
98
+ if ( has_action( 'register_new_user', array( $custom_email, 'new_user_notification' ) ) )
99
+ remove_action( 'register_new_user', array( $custom_email, 'new_user_notification' ) );
100
+ }
101
+
102
+ // Moderate user upon registration
103
+ add_action( 'register_new_user', array( $this, 'moderate_user' ), 100 );
104
+ }
105
+
106
+ /**
107
+ * Changes the registration redirection based upon moderaton type
108
+ *
109
+ * Callback for "registration_redirect" hook in method Theme_My_Login_Template::get_redirect_url()
110
+ *
111
+ * @see Theme_My_Login_Template::get_redirect_url()
112
+ * @since 6.0
113
+ * @access public
114
+ *
115
+ * @param string $redirect_to Default redirect
116
+ * @return string URL to redirect to
117
+ */
118
+ public function registration_redirect( $redirect_to ) {
119
+
120
+ $redirect_to = Theme_My_Login::get_page_link( 'login' );
121
+
122
+ switch ( $this->get_option( 'type' ) ) {
123
+ case 'email' :
124
+ $redirect_to = add_query_arg( 'pending', 'activation', $redirect_to );
125
+ break;
126
+ case 'admin' :
127
+ $redirect_to = add_query_arg( 'pending', 'approval', $redirect_to );
128
+ break;
129
+ }
130
+
131
+ return $redirect_to;
132
+ }
133
+
134
+ /**
135
+ * Blocks "pending" users from loggin in
136
+ *
137
+ * Callback for "authenticate" hook in function wp_authenticate()
138
+ *
139
+ * @see wp_authenticate()
140
+ * @since 6.0
141
+ * @access public
142
+ *
143
+ * @param WP_User $user WP_User object
144
+ * @param string $username Username posted
145
+ * @param string $password Password posted
146
+ * @return WP_User|WP_Error WP_User if the user can login, WP_Error otherwise
147
+ */
148
+ public function authenticate( $user, $username, $password ) {
149
+ global $wpdb;
150
+
151
+ $cap_key = $wpdb->prefix . 'capabilities';
152
+
153
+ $field = is_email( $username ) ? 'email' : 'login';
154
+
155
+ if ( $userdata = get_user_by( $field, $username ) ) {
156
+ if ( array_key_exists( 'pending', (array) $userdata->$cap_key ) ) {
157
+ if ( 'email' == $this->get_option( 'type' ) ) {
158
+ return new WP_Error( 'pending', sprintf(
159
+ __( '<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a href="%s">Resend activation</a>?', 'theme-my-login' ),
160
+ Theme_My_Login::get_page_link( 'login', array( 'action' => 'sendactivation', 'login' => $username ) )
161
+ ) );
162
+ } else {
163
+ return new WP_Error( 'pending', __( '<strong>ERROR</strong>: Your registration has not yet been approved.', 'theme-my-login' ) );
164
+ }
165
+ }
166
+ }
167
+ return $user;
168
+ }
169
+
170
+ /**
171
+ * Blocks "pending" users from resetting their password
172
+ *
173
+ * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
174
+ *
175
+ * @see Theme_My_Login::retrieve_password()
176
+ * @since 6.0
177
+ * @access public
178
+ *
179
+ * @param bool $allow Default setting
180
+ * @param int $user_id User ID
181
+ * @return bool Whether to allow password reset or not
182
+ */
183
+ public function allow_password_reset( $allow, $user_id ) {
184
+ $user = get_user_by( 'id', $user_id );
185
+ if ( in_array( 'pending', (array) $user->roles ) )
186
+ return false;
187
+ return $allow;
188
+ }
189
+
190
+ /**
191
+ * Handles display of various action/status messages
192
+ *
193
+ * @since 6.0
194
+ * @access public
195
+ *
196
+ * @param object $theme_my_login Reference to global $theme_my_login object
197
+ */
198
+ public function action_messages( &$theme_my_login ) {
199
+ if ( isset( $_GET['pending'] ) ) {
200
+ switch ( $_GET['pending'] ) {
201
+ case 'activation' :
202
+ $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' ), 'message' );
203
+ break;
204
+ case 'approval' :
205
+ $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' ), 'message' );
206
+ break;
207
+ }
208
+ }
209
+
210
+ if ( isset( $_GET['activation'] ) ) {
211
+ switch ( $_GET['activation'] ) {
212
+ case 'complete' :
213
+ if ( class_exists( 'Theme_My_Login_Custom_Passwords' ) )
214
+ $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. You may now log in.', 'theme-my-login' ), 'message' );
215
+ else
216
+ $theme_my_login->errors->add( 'activation_complete', __( 'Your account has been activated. Please check your e-mail for your password.', 'theme-my-login' ), 'message' );
217
+ break;
218
+ case 'invalidkey' :
219
+ $theme_my_login->errors->add( 'invalid_key', __( '<strong>ERROR</strong>: Sorry, that key does not appear to be valid.', 'theme-my-login' ) );
220
+ break;
221
+ }
222
+ }
223
+
224
+ if ( isset( $_GET['sendactivation'] ) ) {
225
+ switch ( $_GET['sendactivation'] ) {
226
+ case 'failed' :
227
+ $theme_my_login->errors->add( 'sendactivation_failed', __('<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent.', 'theme-my-login' ) );
228
+ break;
229
+ case 'sent' :
230
+ $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' ), 'message' );
231
+ break;
232
+ }
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Applies moderation to a newly registered user
238
+ *
239
+ * Callback for "register_post" hook in method Theme_My_Login::register_new_user()
240
+ *
241
+ * @see Theme_My_Login::register_new_user()
242
+ * @since 6.0
243
+ * @access public
244
+ *
245
+ * @param int $user_id The user's ID
246
+ */
247
+ public function moderate_user( $user_id ) {
248
+ global $wpdb;
249
+
250
+ // Set user role to "pending"
251
+ $user = new WP_User( $user_id );
252
+
253
+ // Make sure user isn't already "Pending"
254
+ if ( in_array( 'pending', (array) $user->roles ) )
255
+ return;
256
+
257
+ // Set user to "Pending" role
258
+ $user->set_role( 'pending' );
259
+
260
+ // Send appropriate e-mail depending on moderation type
261
+ if ( 'email' == $this->get_option( 'type' ) ) {
262
+ // Send activation e-mail
263
+ self::new_user_activation_notification( $user_id );
264
+ } elseif ( 'admin' == $this->get_option( 'type' ) ) {
265
+ // Send approval e-mail
266
+ if ( apply_filters( 'send_new_user_approval_admin_notification', true ) )
267
+ self::new_user_approval_admin_notification( $user_id );
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Handles "activate" action for login page
273
+ *
274
+ * Callback for "tml_request_activate" hook in method Theme_My_Login::the_request();
275
+ *
276
+ * @see Theme_My_Login::the_request();
277
+ * @since 6.0
278
+ * @access public
279
+ */
280
+ public function user_activation() {
281
+ // Attempt to activate the user
282
+ $errors = self::activate_new_user( $_GET['key'], $_GET['login'] );
283
+
284
+ $redirect_to = Theme_My_Login_Common::get_current_url();
285
+
286
+ // Make sure there are no errors
287
+ if ( ! is_wp_error( $errors ) )
288
+ $redirect_to = add_query_arg( 'activation', 'complete', $redirect_to );
289
+ else
290
+ $redirect_to = add_query_arg( 'activation', 'invalidkey', $redirect_to );
291
+
292
+ wp_redirect( $redirect_to );
293
+ exit;
294
+ }
295
+
296
+ /**
297
+ * Handles "send_activation" action for login page
298
+ *
299
+ * Callback for "tml_request_send_activation" hook in method Theme_My_Login::the_request();
300
+ *
301
+ * @see Theme_My_Login::the_request();
302
+ * @since 6.0
303
+ * @access public
304
+ */
305
+ public static function send_activation() {
306
+ global $wpdb;
307
+
308
+ $login = isset( $_GET['login'] ) ? trim( $_GET['login'] ) : '';
309
+
310
+ if ( ! $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->users WHERE user_login = %s", $login ) ) ) {
311
+ $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'failed' ) );
312
+ wp_redirect( $redirect_to );
313
+ exit;
314
+ }
315
+
316
+ do_action( 'tml_user_activation_resend', $user_id );
317
+
318
+ $user = new WP_User( $user_id );
319
+
320
+ if ( in_array( 'pending', (array) $user->roles ) ) {
321
+ // Send activation e-mail
322
+ self::new_user_activation_notification( $user->ID );
323
+ // Now redirect them
324
+ $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'sent' ) );
325
+ wp_redirect( $redirect_to );
326
+ exit;
327
+ }
328
+ }
329
+
330
+ /**
331
+ * Handles activating a new user by user email confirmation
332
+ *
333
+ * @since 6.0
334
+ * @access public
335
+ *
336
+ * @param string $key Hash to validate sending confirmation email
337
+ * @param string $login User's username for logging in
338
+ * @return bool|WP_Error True if successful, WP_Error otherwise
339
+ */
340
+ public static function activate_new_user( $key, $login ) {
341
+ global $wpdb;
342
+
343
+ $key = preg_replace( '/[^a-z0-9]/i', '', $key );
344
+
345
+ if ( empty( $key ) || ! is_string( $key ) )
346
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
347
+
348
+ if ( empty( $login ) || ! is_string( $login ) )
349
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
350
+
351
+ // Validate activation key
352
+ $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
353
+ if ( empty( $user ) )
354
+ return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
355
+
356
+ do_action( 'tml_user_activation_post', $user->user_login, $user->user_email );
357
+
358
+ // Allow plugins to short-circuit process and send errors
359
+ $errors = new WP_Error();
360
+ $errors = apply_filters( 'tml_user_activation_errors', $errors, $user->user_login, $user->user_email );
361
+
362
+ // Return errors if there are any
363
+ if ( $errors->get_error_code() )
364
+ return $errors;
365
+
366
+ // Clear the activation key
367
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'user_login' => $login ) );
368
+
369
+ // Set user role
370
+ $user_object = new WP_User( $user->ID );
371
+ $user_object->set_role( get_option( 'default_role' ) );
372
+
373
+ do_action( 'tml_new_user_activated', $user->ID );
374
+
375
+ return true;
376
+ }
377
+
378
+ /**
379
+ * Calls the "register_new_user" hook
380
+ *
381
+ * @since 6.0
382
+ * @access public
383
+ *
384
+ * @param int $user_id The user's ID
385
+ */
386
+ public function new_user_activated( $user_id ) {
387
+ do_action( 'register_new_user', $user_id );
388
+ }
389
+
390
+ /**
391
+ * Notifies a pending user to activate their account
392
+ *
393
+ * @since 6.0
394
+ * @access public
395
+ *
396
+ * @param int $user_id The user's ID
397
+ */
398
+ public static function new_user_activation_notification( $user_id ) {
399
+ global $wpdb, $current_site;
400
+
401
+ $user = new WP_User( $user_id );
402
+
403
+ $user_login = stripslashes( $user->user_login );
404
+ $user_email = stripslashes( $user->user_email );
405
+
406
+ // Generate an activation key
407
+ $key = wp_generate_password( 20, false );
408
+
409
+ // Set the activation key for the user
410
+ $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user->user_login ) );
411
+
412
+ if ( is_multisite() ) {
413
+ $blogname = $current_site->site_name;
414
+ } else {
415
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
416
+ // we want to reverse this for the plain text arena of emails.
417
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
418
+ }
419
+
420
+ $activation_url = add_query_arg( array( 'action' => 'activate', 'key' => $key, 'login' => rawurlencode( $user_login ) ), wp_login_url() );
421
+
422
+ $title = sprintf( __( '[%s] Activate Your Account', 'theme-my-login' ), $blogname );
423
+ $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";
424
+ $message .= $activation_url . "\r\n";
425
+
426
+ $title = apply_filters( 'user_activation_notification_title', $title, $user_id );
427
+ $message = apply_filters( 'user_activation_notification_message', $message, $activation_url, $user_id );
428
+
429
+ return wp_mail( $user_email, $title, $message );
430
+ }
431
+
432
+ /**
433
+ * Notifies the administrator of a pending user needing approval
434
+ *
435
+ * @since 6.0
436
+ * @access public
437
+ *
438
+ * @param int $user_id The user's ID
439
+ */
440
+ public static function new_user_approval_admin_notification( $user_id ) {
441
+ global $current_site;
442
+
443
+ if ( ! apply_filters( 'send_new_user_approval_admin_notification', true ) )
444
+ return;
445
+
446
+ $user = new WP_User( $user_id );
447
+
448
+ $user_login = stripslashes( $user->user_login );
449
+ $user_email = stripslashes( $user->user_email );
450
+
451
+ if ( is_multisite() ) {
452
+ $blogname = $current_site->site_name;
453
+ } else {
454
+ // The blogname option is escaped with esc_html on the way into the database in sanitize_option
455
+ // we want to reverse this for the plain text arena of emails.
456
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
457
+ }
458
+
459
+ $title = sprintf( __( '[%s] New User Awaiting Approval', 'theme-my-login' ), $blogname );
460
+
461
+ $message = sprintf( __( 'New user requires approval on your blog %s:', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
462
+ $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n";
463
+ $message .= sprintf( __( 'E-mail: %s', 'theme-my-login' ), $user_email ) . "\r\n\r\n";
464
+ $message .= __( 'To approve or deny this user:', 'theme-my-login' ) . "\r\n";
465
+ $message .= admin_url( 'users.php?role=pending' );
466
+
467
+ $title = apply_filters( 'user_approval_admin_notification_title', $title, $user_id );
468
+ $message = apply_filters( 'user_approval_admin_notification_message', $message, $user_id );
469
+
470
+ $to = apply_filters( 'user_approval_admin_notification_mail_to', get_option( 'admin_email' ) );
471
+
472
+ @wp_mail( $to, $title, $message );
473
+ }
474
+ }
475
+
476
+ Theme_My_Login_User_Moderation::get_object();
477
+
478
+ endif;
479
+
480
+ if ( is_admin() )
481
+ include_once( dirname( __FILE__ ) . '/admin/user-moderation-admin.php' );
482
+
readme.txt CHANGED
@@ -1,521 +1,533 @@
1
- === Theme My Login ===
2
- Contributors: jfarthing84
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EZLVANPT4A9SW
4
- Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
5
- Requires at least: 4.5
6
- Tested up to: 4.5.2
7
- Stable tag: 6.4.5
8
-
9
- Themes the WordPress login pages according to your theme.
10
-
11
-
12
- == Description ==
13
-
14
- This plugin themes the WordPress login, registration and forgot password pages according to your current theme.
15
- It creates a page to use in place of wp-login.php, using a page template from your theme.
16
- Also includes a widget for sidebar login.
17
-
18
-
19
- = Features =
20
- * Your registration, log in, and password recovery pages will all match the rest of your website
21
- * Includes a customizable widget to login anywhere from your blog
22
- * Redirect users upon log in and log out based upon their role
23
- * Show gravatar to users who are logged in
24
- * Assign custom links to users who are logged in based on their role
25
- * Customize user emails for registration and/or password recovery
26
- * Send user emails in HTML format
27
- * Allow users to set their own password upon registration
28
- * Require users to be approved or confirm e-mail address upon registration
29
- * Theme user profiles
30
-
31
-
32
- == Installation ==
33
-
34
- 1. Upload the plugin to your 'wp-content/plugins' directory
35
- 1. Activate the plugin
36
-
37
-
38
- == Frequently Asked Questions ==
39
-
40
- = How do I change the look of forms? =
41
-
42
- The same way you would change the look of anything else on your site: CSS. Theme My Login uses it's own very basic stylesheet.
43
- You can copy this to your theme's directory and add additional styling there or simply add additional styling to your theme's stylesheet.
44
-
45
- = I can't get into my site! What do I do? =
46
-
47
- Visit yoursite.com/wp-login.php.
48
-
49
- = What happened to the language folder? =
50
-
51
- As of version 6.3, Theme My Login no longer ships with translation files. Translations will be available at http://translate.wordpress.org.
52
-
53
- = How do I obtain additional assistance? =
54
-
55
- Please visit http://www.jfarthing.com/development/theme-my-login.
56
-
57
-
58
- == Changelog ==
59
-
60
- = 6.4.5 =
61
- * Don't clear username input on login form when autofocusing
62
- * Fix custom e-mail disable checkboxes defaulting to being checked
63
- * Fix login type functionality
64
- * Bring wp-login.php duplicated code up to date
65
- * Require WordPress 4.5
66
-
67
- = 6.4.4 =
68
- * Fix file loading for non-standard directory setups
69
- * Fix language files not loading properly
70
- * Fix password reset cookie path
71
-
72
- = 6.4.3 =
73
- * Fix sending of custom emails when creating a user
74
- * Fix sending of custom emails on user activation/approval
75
- * Fix translation loading logic
76
- * Require WordPress 4.4
77
-
78
- = 6.4.2 =
79
- * Fix deprecated function notices
80
- * Deprecate "tml_user_password_changed" hook in favor of "after_password_reset"
81
- * Deprecate "tml_new_user_registered" hook in favor of "register_new_user"
82
-
83
- = 6.4.1 =
84
- * Allow array of actions in Theme_My_Login::is_tml_page()
85
- * Lost Password nav menu item will only show when not logged in
86
- * Hide action links on Reset Password page
87
- * Fix false password reset error caused by referer redirection
88
- * Fix PHP strict warning about abstract class constructor compatibility
89
-
90
- = 6.4 =
91
- * Add option to login using either username only, email only or both
92
- * Add option to disable user denial notification when admin approval is active
93
- * Update reCAPTCHA module to API version 2.0
94
- * Login and Register nav menu items only show when not logged in
95
- * Logout and Profile nav menu items only show when logged in
96
- * Better default stylesheet
97
- * Fix TML pages displaying in search results
98
- * Fix logout redirect
99
- * Fix broken interim login when wp-login.php is disabled
100
- * Remove AJAX module
101
- * Require WordPress 4.3.1
102
-
103
- = 6.3.12 =
104
- * Fix multiple widget custom redirect error
105
- * Add autocomplete="off" to login form password field
106
- * Fix password reset process
107
- * Fix SSL admin JS
108
-
109
- = 6.3.11 =
110
- * Fix interim login
111
- * Fix partial translations
112
- * Fix toolbar disappearing when updating a themed profile
113
-
114
- = 6.3.10 =
115
- * Fix local file include vulnerability in templating system
116
-
117
- = 6.3.9 =
118
- * Fix strict standards errors
119
- * Fix deprecated function notices
120
-
121
- = 6.3.8 =
122
- * Fix issue where pages would redirect to profile page with Themed Profiles active
123
-
124
- = 6.3.7 =
125
- * Revert tml_page post type back to default WP pages
126
- * Fix issue where SSL warnings were displayed in reCAPTCHA module
127
- * Fix issue where a blank page resulted when 404.php didn't exist in a theme
128
- * Fix issue where User Links couldn't be deleted
129
- * Fix issue where "Are you sure?" would display when attempting to log out
130
- * Fix issue where strings weren't being translated on Profile page
131
-
132
- = 6.3.6 =
133
- * Fix issue where all module options were set once activated
134
- * Fix issue where template tag was not being output
135
- * Fix issue where install failed during new blog creation on multisite
136
- * Fix issue where error messages were duplicated on login pages
137
-
138
- = 6.3.5 =
139
- * Fix issue with blank pages where page.php didn't exist in a theme
140
- * Fix issue where activating Themed Profiles resulted in a 404 for profile page
141
- * Fix issue where options were being deleted upon upgrade
142
- * Fix issue with AJAX module not working properly in Internet Explorer
143
-
144
- = 6.3.4 =
145
- * Use verbose rewrite rules for TML pages
146
-
147
- = 6.3.3 =
148
- * Fix issue where actions weren't being appended to page links
149
- * Fix issue where modules weren't being installed on upgrade
150
- * Fix fatal error in Custom E-mail module where old function name wasn't replaced
151
- * Fix private constructor issue for PHP versions less than 5.3
152
-
153
- = 6.3.2 =
154
- * Fix issue where pages weren't created when upgrading from previous versions
155
-
156
- = 6.3.1 =
157
- * Fix multisite 404 error when using Post Name permalink structure
158
- * Fix multisite redirect to main site for register
159
-
160
- = 6.3 =
161
- * Introduce tml_page post type and give each action it's own page
162
- * Introduce AJAX module
163
- * Implement user lock notifications for the Security module.
164
- * Add option to hide widget when logged out
165
- * Add option to disable wp-login.php to Security module
166
- * Removed languages from plugin
167
- * Use Custom E-mail's New User template when a user is added via wp-admin
168
- * Use Custom E-mail's User Activation template when an activation is resent via wp-admin
169
-
170
- = 6.2.3 =
171
- * Fix static front page bug
172
- * Remove tab indexes from forms
173
-
174
- = 6.2.2 =
175
- * Fix redirect loop bug
176
- * Add visual cues for permalinks
177
- * Fix iframe bug
178
-
179
- = 6.2.1 =
180
- * Add post password handling
181
- * Don't block admin when DOING_AJAX
182
- * Add WordPress updated message
183
- * Replace deprecated get_userdatabylogin with get_user_by
184
-
185
- = 6.2 =
186
- * Fix FORCE_SSL_ADMIN logic
187
- * Add tabindex to password fields
188
- * Fix removal of actions from "tml_new_user_registered" action in User Moderation module
189
- * Add %username% variable to Custom User Links module
190
- * Add custom permalinks to core
191
- * Add option to disable e-mail login
192
- * Fix potential XSS attack vulnerability
193
- * Update admin bar settings for 3.3 in Themed Profiles module
194
- * Update multisite templates for 3.3
195
- * Fix autofocus scripts to only load on login page
196
- * Require 3.1+
197
- * Fix broken login redirect logic
198
- * Add option to require login to view site in Security module
199
- * Don't change profile URL for non-themed roles in Themed Profiles module
200
- * Display failed login attempts to administrators on user profiles in Security module
201
- * Fix capability check for non-standard table prefix in User Moderation module
202
- * Add separate profile templates per user role in Themed Profiles module
203
- * Fix password recovery admin e-mail in Custom E-mail module
204
- * Don't show admin options when admin is blocked in Themed Profiles module
205
- * Treat multisite users with no role as subscribers in all modules
206
- * Fix multisite registration bug in Themed Profiles module
207
-
208
- = 6.1.4 =
209
- * Don't hijack non-related form posts
210
-
211
- = 6.1.3 =
212
- * Fix password change error
213
- * Update POT file
214
-
215
- = 6.1.2 =
216
- * Replace "self" keyword with "$this" for PHP 4
217
-
218
- = 6.1.1 =
219
- * Implement 3.1 password reset routine
220
- * Add 3.1 fields to Themed Profiles
221
- * Better default stylesheet for Themed Profiles
222
- * Add 'nofollow' attribute to action links
223
- * Check for SSL
224
- * Add nofollow and noindex to login page
225
- * Fix missing argument notices
226
- * Fix deprecated argument notices
227
- * Fix undefined method notices
228
- * Fix install/uninstall routines
229
- * Fix Custom user Links AJAX
230
- * Fix Custom E-mail "From" filters
231
- * Fix disabling of admin password change notification
232
- * Fix "resent" custom activation e-mail
233
-
234
- = 6.1 =
235
- * Fully support multisite
236
- * Require WordPress 3.0+
237
- * Add Bulgarian translation
238
- * Add (Belgian) Dutch translation
239
- * Add Romanian translation
240
-
241
- = 6.0.4 =
242
- * Fix admin e-mail notification disabling
243
- * Fix labels for login form fields
244
- * Fix wp-login.php form action URL
245
-
246
- = 6.0.3 =
247
- * Fix login reauth bug in redirection module
248
-
249
- = 6.0.2 =
250
- * Fix Login page creation during install
251
- * Fix template tag argument parsing
252
-
253
- = 6.0.1 =
254
- * Fix logout link for wp_nav_menu()
255
- * Fix issue admin page not always being tabbed
256
- * Fix issue of assigning multiple roles per user when using Moderation
257
- * Add German translation
258
- * Add Farsi (Persian) translation
259
- * Add Hebrew translation
260
- * Add Russian translation
261
- * Update other languages
262
-
263
- = 6.0 =
264
- * Complete code rewrite
265
- * Users can now log in with e-mail address as well as username
266
- * Remove option to disable template tag and widget in favor of always being enabled
267
- * Remove option to rewrite login links in favor of always being rewritten
268
- * Custom templates can now be defined per action (login, register, etc.)
269
- * User moderation activation e-mails can be resent on demand
270
- * Add various new hooks to help with custom integration with other plugins
271
- * Make custom user links sortable
272
- * Customize every aspect of every e-mail
273
- * Add a cool new random tip widget in the TML admin
274
- * Use WP 3.0 functions (such as 'network_site_url') if available
275
- * phpDoc everywhere!
276
-
277
- = 5.1.6 =
278
- * Fix issue with spaces in usernames
279
-
280
- = 5.1.5 =
281
- * Fix blank page redirect bug
282
-
283
- = 5.1.4 =
284
- * Fix the_title() bug fro WP versions before 3.0 (again)
285
- * Fix undefined is_user_logged_in() bug
286
-
287
- = 5.1.3 =
288
- * Make Themed Profiles work properly
289
-
290
- = 5.1.2 =
291
- * Fix the_title() bug for WP versions before 3.0
292
- * Fix redirection bug caused by 5.1.1 update
293
-
294
- = 5.1.1 =
295
- * Fix bug that blocked users from entire site once logged in
296
- * PROPERLY display "Log Out" when page is shown in pagelist and logged in
297
-
298
- = 5.1 =
299
- * Display "Log Out" when page is shown in pagelist and logged in
300
- * Forward profile.php to themed profile when module is active
301
- * Allow for %user_id% in custom user links
302
- * Add inline descriptions to all settings
303
- * Various tweaks and preps for WP 3.0
304
- * Add Italian translation
305
- * Add Danish translation
306
- * Add Polish translation
307
- * Add Spanish translation
308
-
309
- = 5.0.6 =
310
- * Pass $theme_my_login by reference in option functions
311
- * Remove accidental invalid characters
312
-
313
- = 5.0.5 =
314
- * Add 'theme-my-login-page' shortcode before 'theme-my-login' shortcode
315
-
316
- = 5.0.4 =
317
- * Re-introduce 'theme-my-login-page' shortcode for main login page
318
- * Add French translation
319
- * Fix typo in function override notice functions
320
- * Make 2nd argument optional in 'get_pages' filter
321
- * Remove another 'self' reference in class.php
322
- * Fix typo in readme.txt
323
-
324
- = 5.0.3 =
325
- * Fix an improper fix for PHP4 style constructor in class
326
- * Only display function override notices on TML settings page properly
327
-
328
- = 5.0.2 =
329
- * Fix improper function call for PHP4 style constructor in class
330
-
331
- = 5.0.1 =
332
- * Only display function override notices on TML settings page
333
- * Typecast arrays as arrays (Fixes invalid datatype notices)
334
- * Add plugin domain to all gettext calls
335
-
336
- = 5.0 =
337
- * Rewrite code in a modular fashion in order to speed up plugin
338
- * Convert custom e-mails, passwords, redirection, user links and user moderation to "modules"
339
- * Add the option to enable/disable link rewriting, widget and template tag
340
- * Simplify/optimize admin tabs style
341
- * Remember current admin tab after save
342
- * When using custom passwords, allow users to set their own password upon reset
343
- * When using custom redirection, specify redirection type per user role/per link type
344
- * New ajax interface for user links admin
345
- * Theme My Profile now merged into module
346
-
347
- = 4.4 =
348
- * Added the option to require new registrations to confirm e-mail address
349
- * Added the option to redirect users upon log out according to their role
350
- * Allow 'theme-my-login.css' to be loaded from current theme directory
351
- * Cleaned up and rewrote most code
352
- * Drop support for WP versions below 2.8
353
-
354
- = 4.3.4 =
355
- * Added the option to force redirect upon login
356
-
357
- = 4.3.3 =
358
- * Fixed a redirection bug where WordPress is installed in a sub-directory
359
- * Add CSS style to keep "Remember Me" label inline with checkbox
360
-
361
- = 4.3.2 =
362
- * Added the option to redirect unapproved and/or denied users to a custom URL upon login attempt
363
- * Fixed a bug where custom user password is lost if user moderation is enabled
364
- * Fixed a PHP notice in the admin (Wish more plugin authors would do this; WP_DEBUG is your friend!)
365
-
366
- = 4.3.1 =
367
- * Fixed a MAJOR security hole that allowed anyone to login without a password!!
368
-
369
- = 4.3 =
370
- * Added the option to require approval for new registrations
371
- * Added the option to enable/disable plugin stylesheet
372
- * Removed form input fields from label tags
373
- * Dropped support for WordPress versions older than 2.6
374
-
375
- = 4.2.2 =
376
- * Added the option to remove 'Register' and/or 'Lost Password' links
377
- * Fixed a bug that sent e-mail from all plugins from this plugins setting
378
-
379
- = 4.2.1 =
380
- * Fixed a bug that broke other plugins e-mail format
381
- * Fixed a bug that could break plugin upon upgrade
382
-
383
- = 4.2 =
384
- * Added the option to send e-mails in HTML format
385
- * Fixed a bug that broke custom user role links if all links were deleted
386
-
387
- = 4.1.2 =
388
- * Added the ability to change main login page ID (Only needed for debugging)
389
- * The login will now revert to default wp-login in the case of plugin failure
390
-
391
- = 4.1.1 =
392
- * Fixed a major bug dealing with saving options that broke the plugin
393
- * Fixed a CSS bug causing interference with other interfaces that use jQuery UI Tabs
394
-
395
- = 4.1 =
396
- * Implemented custom user passwords
397
- * Implemented custom e-mail from name & address
398
- * Removed template tag & shortcode restriction on main login page
399
-
400
- = 4.0 =
401
- * Implemented custom links for logged in users based on role
402
- * Implemented custom redirection upon log in based on role
403
- * Implemented custom registration/password recovery emails
404
-
405
- * Implemented true shortcode and template tag functionality
406
- * Implemented true multi-instance functionality
407
- * Implemented an easy-to-use jQuery tabbed administration menu
408
- * Implemented both 'fresh' and 'classic' colors for administration menu
409
-
410
- = 3.3.1 =
411
- * Fixed a bug that broke password recovery due to the new system from WP 2.8.4
412
-
413
- = 3.3 =
414
- * Fixed a bug that disabled error display when GET variable 'loggedout' was set
415
- * Added template tag access
416
-
417
- = 3.2.8 =
418
- * Fixed a security exploit regarding admin password reset addressed in WordPress 2.8.4
419
-
420
- = 3.2.7 =
421
- * Fixed a bug that determined how to create the widget
422
-
423
- = 3.2.6 =
424
- * Fixed a bug dealing with the version_compare() function
425
- * Included French translation
426
- * Included Spanish translation
427
-
428
- = 3.2.5 =
429
- * Fixed a bug that produced a 'headers aldready sent' error when uploading media
430
- * Included Dutch translation
431
-
432
- = 3.2.4 =
433
- * Fixed the load_plugin_textdomain() call
434
- * Added 'login_head' action hook
435
-
436
- = 3.2.3 =
437
- * Fixed and updated many gettext calls for internationalization
438
-
439
- = 3.2.2 =
440
- * Added the option to leave widget links blank for default handling
441
-
442
- = 3.2.1 =
443
- * Fixed a XHTML validation issue
444
-
445
- = 3.2 =
446
- * Added the option to allow/disallow registration and password recovery within the widget
447
- * Fixed a bug regarding color names within the CSS file that broke validation
448
-
449
- = 3.1.1 =
450
- * Fixed a bug that incorrectly determined current user role
451
-
452
- = 3.1 =
453
- * Added the ability to specify URL's for widget 'Dashboard' and 'Profile' links per user role
454
- * Implemented WordPress 2.8 widget control for multiple widget instances
455
- * Fixed a bug regarding the registration complete message
456
-
457
- = 3.0.3 =
458
- * Fixed a bug with the widget links
459
-
460
- = 3.0.2 =
461
- * Fixed a bug that didn't allow custom registration message to be displayed
462
- * Fixed a few PHP unset variable notice's with a call to isset()
463
-
464
- = 3.0.1 =
465
- * Fixed a bug that caused a redirection loop when trying to access wp-login.php
466
- * Fixed a bug that broke the widget admin interface
467
- * Added the option to show/hide login page from page list
468
-
469
- = 3.0 =
470
- * Added a login widget
471
-
472
- = 2.2 =
473
- * Removed all "bloatware"
474
-
475
- = 2.1 =
476
- * Implemented login redirection based on user role
477
-
478
- = 2.0.8 =
479
- * Fixed a bug that broke the login with permalinks
480
-
481
- = 2.0.7 =
482
- * Fixed a bug that broke the Featured Content plugin
483
-
484
- = 2.0.6 =
485
- * Added the option to turn on/off subscriber profile theming
486
-
487
- = 2.0.5 =
488
- * Fixed a bug with default redirection and hid the login form from logged in users
489
-
490
- = 2.0.4 =
491
- * Fixed a bug regarding relative URL's in redirection
492
-
493
- = 2.0.3 =
494
- * Fixed various reported bugs and cleaned up code
495
-
496
- = 2.0.2 =
497
- * Fixed a bug that broke registration and broke other plugins using the_content filter
498
-
499
- = 2.0.1 =
500
- * Fixed a bug that redirected users who were not yet logged in to profile page
501
-
502
- = 2.0 =
503
- * Completely rewrote plugin to use page template, no more specifying template files & HTML
504
-
505
- = 1.2 =
506
- * Added capability to customize page titles for all pages affected by plugin
507
-
508
- = 1.1.2 =
509
- * Updated to allow customization of text below registration form
510
-
511
- = 1.1.1 =
512
- * Prepared plugin for internationalization and fixed a PHP version bug
513
-
514
- = 1.1.0 =
515
- * Added custom profile to completely hide the back-end from subscribers
516
-
517
- = 1.0.1 =
518
- * Made backwards compatible to WordPress 2.5+
519
-
520
- = 1.0.0 =
521
- * Initial release version
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Theme My Login ===
2
+ Contributors: jfarthing84
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EZLVANPT4A9SW
4
+ Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
5
+ Requires at least: 4.5
6
+ Tested up to: 4.6.1
7
+ Stable tag: 6.4.6
8
+
9
+ Themes the WordPress login pages according to your theme.
10
+
11
+
12
+ == Description ==
13
+
14
+ This plugin themes the WordPress login, registration and forgot password pages according to your current theme.
15
+ It creates a page to use in place of wp-login.php, using a page template from your theme.
16
+ Also includes a widget for sidebar login.
17
+
18
+
19
+ = Features =
20
+ * Your registration, log in, and password recovery pages will all match the rest of your website
21
+ * Includes a customizable widget to login anywhere from your blog
22
+ * Redirect users upon log in and log out based upon their role
23
+ * Show gravatar to users who are logged in
24
+ * Assign custom links to users who are logged in based on their role
25
+ * Customize user emails for registration and/or password recovery
26
+ * Send user emails in HTML format
27
+ * Allow users to set their own password upon registration
28
+ * Require users to be approved or confirm e-mail address upon registration
29
+ * Theme user profiles
30
+
31
+
32
+ == Installation ==
33
+
34
+ 1. Upload the plugin to your 'wp-content/plugins' directory
35
+ 1. Activate the plugin
36
+
37
+
38
+ == Frequently Asked Questions ==
39
+
40
+ = How do I change the look of forms? =
41
+
42
+ The same way you would change the look of anything else on your site: CSS. Theme My Login uses it's own very basic stylesheet.
43
+ You can copy this to your theme's directory and add additional styling there or simply add additional styling to your theme's stylesheet.
44
+
45
+ = I can't get into my site! What do I do? =
46
+
47
+ Visit yoursite.com/wp-login.php.
48
+
49
+ = What happened to the language folder? =
50
+
51
+ As of version 6.3, Theme My Login no longer ships with translation files. Translations will be available at http://translate.wordpress.org.
52
+
53
+ = How do I obtain additional assistance? =
54
+
55
+ Please visit https://wordpress.org/support/plugin/theme-my-login.
56
+
57
+
58
+ == Changelog ==
59
+
60
+ = 6.4.6 =
61
+ * Fix errors and messages not displaying
62
+ * Don't add reCAPTCHA errors when adding a user via wp-admin or WP-CLI
63
+ * Improve PHP 7 compatibility
64
+ * Introduce `tml_page_id` filter
65
+ * Improve deliverability of HTML emails
66
+ * Fix disabling of User Denial email notification
67
+ * Pass locale to reCAPTCHA script allowing reCAPTCHA to be localized
68
+ * Don't allow pending users to log in using their email address
69
+ * Fix email content types from being reset
70
+
71
+ = 6.4.5 =
72
+ * Don't clear username input on login form when autofocusing
73
+ * Fix custom e-mail disable checkboxes defaulting to being checked
74
+ * Fix login type functionality
75
+ * Bring wp-login.php duplicated code up to date
76
+ * Require WordPress 4.5
77
+
78
+ = 6.4.4 =
79
+ * Fix file loading for non-standard directory setups
80
+ * Fix language files not loading properly
81
+ * Fix password reset cookie path
82
+
83
+ = 6.4.3 =
84
+ * Fix sending of custom emails when creating a user
85
+ * Fix sending of custom emails on user activation/approval
86
+ * Fix translation loading logic
87
+ * Require WordPress 4.4
88
+
89
+ = 6.4.2 =
90
+ * Fix deprecated function notices
91
+ * Deprecate "tml_user_password_changed" hook in favor of "after_password_reset"
92
+ * Deprecate "tml_new_user_registered" hook in favor of "register_new_user"
93
+
94
+ = 6.4.1 =
95
+ * Allow array of actions in Theme_My_Login::is_tml_page()
96
+ * Lost Password nav menu item will only show when not logged in
97
+ * Hide action links on Reset Password page
98
+ * Fix false password reset error caused by referer redirection
99
+ * Fix PHP strict warning about abstract class constructor compatibility
100
+
101
+ = 6.4 =
102
+ * Add option to login using either username only, email only or both
103
+ * Add option to disable user denial notification when admin approval is active
104
+ * Update reCAPTCHA module to API version 2.0
105
+ * Login and Register nav menu items only show when not logged in
106
+ * Logout and Profile nav menu items only show when logged in
107
+ * Better default stylesheet
108
+ * Fix TML pages displaying in search results
109
+ * Fix logout redirect
110
+ * Fix broken interim login when wp-login.php is disabled
111
+ * Remove AJAX module
112
+ * Require WordPress 4.3.1
113
+
114
+ = 6.3.12 =
115
+ * Fix multiple widget custom redirect error
116
+ * Add autocomplete="off" to login form password field
117
+ * Fix password reset process
118
+ * Fix SSL admin JS
119
+
120
+ = 6.3.11 =
121
+ * Fix interim login
122
+ * Fix partial translations
123
+ * Fix toolbar disappearing when updating a themed profile
124
+
125
+ = 6.3.10 =
126
+ * Fix local file include vulnerability in templating system
127
+
128
+ = 6.3.9 =
129
+ * Fix strict standards errors
130
+ * Fix deprecated function notices
131
+
132
+ = 6.3.8 =
133
+ * Fix issue where pages would redirect to profile page with Themed Profiles active
134
+
135
+ = 6.3.7 =
136
+ * Revert tml_page post type back to default WP pages
137
+ * Fix issue where SSL warnings were displayed in reCAPTCHA module
138
+ * Fix issue where a blank page resulted when 404.php didn't exist in a theme
139
+ * Fix issue where User Links couldn't be deleted
140
+ * Fix issue where "Are you sure?" would display when attempting to log out
141
+ * Fix issue where strings weren't being translated on Profile page
142
+
143
+ = 6.3.6 =
144
+ * Fix issue where all module options were set once activated
145
+ * Fix issue where template tag was not being output
146
+ * Fix issue where install failed during new blog creation on multisite
147
+ * Fix issue where error messages were duplicated on login pages
148
+
149
+ = 6.3.5 =
150
+ * Fix issue with blank pages where page.php didn't exist in a theme
151
+ * Fix issue where activating Themed Profiles resulted in a 404 for profile page
152
+ * Fix issue where options were being deleted upon upgrade
153
+ * Fix issue with AJAX module not working properly in Internet Explorer
154
+
155
+ = 6.3.4 =
156
+ * Use verbose rewrite rules for TML pages
157
+
158
+ = 6.3.3 =
159
+ * Fix issue where actions weren't being appended to page links
160
+ * Fix issue where modules weren't being installed on upgrade
161
+ * Fix fatal error in Custom E-mail module where old function name wasn't replaced
162
+ * Fix private constructor issue for PHP versions less than 5.3
163
+
164
+ = 6.3.2 =
165
+ * Fix issue where pages weren't created when upgrading from previous versions
166
+
167
+ = 6.3.1 =
168
+ * Fix multisite 404 error when using Post Name permalink structure
169
+ * Fix multisite redirect to main site for register
170
+
171
+ = 6.3 =
172
+ * Introduce tml_page post type and give each action it's own page
173
+ * Introduce AJAX module
174
+ * Implement user lock notifications for the Security module.
175
+ * Add option to hide widget when logged out
176
+ * Add option to disable wp-login.php to Security module
177
+ * Removed languages from plugin
178
+ * Use Custom E-mail's New User template when a user is added via wp-admin
179
+ * Use Custom E-mail's User Activation template when an activation is resent via wp-admin
180
+
181
+ = 6.2.3 =
182
+ * Fix static front page bug
183
+ * Remove tab indexes from forms
184
+
185
+ = 6.2.2 =
186
+ * Fix redirect loop bug
187
+ * Add visual cues for permalinks
188
+ * Fix iframe bug
189
+
190
+ = 6.2.1 =
191
+ * Add post password handling
192
+ * Don't block admin when DOING_AJAX
193
+ * Add WordPress updated message
194
+ * Replace deprecated get_userdatabylogin with get_user_by
195
+
196
+ = 6.2 =
197
+ * Fix FORCE_SSL_ADMIN logic
198
+ * Add tabindex to password fields
199
+ * Fix removal of actions from "tml_new_user_registered" action in User Moderation module
200
+ * Add %username% variable to Custom User Links module
201
+ * Add custom permalinks to core
202
+ * Add option to disable e-mail login
203
+ * Fix potential XSS attack vulnerability
204
+ * Update admin bar settings for 3.3 in Themed Profiles module
205
+ * Update multisite templates for 3.3
206
+ * Fix autofocus scripts to only load on login page
207
+ * Require 3.1+
208
+ * Fix broken login redirect logic
209
+ * Add option to require login to view site in Security module
210
+ * Don't change profile URL for non-themed roles in Themed Profiles module
211
+ * Display failed login attempts to administrators on user profiles in Security module
212
+ * Fix capability check for non-standard table prefix in User Moderation module
213
+ * Add separate profile templates per user role in Themed Profiles module
214
+ * Fix password recovery admin e-mail in Custom E-mail module
215
+ * Don't show admin options when admin is blocked in Themed Profiles module
216
+ * Treat multisite users with no role as subscribers in all modules
217
+ * Fix multisite registration bug in Themed Profiles module
218
+
219
+ = 6.1.4 =
220
+ * Don't hijack non-related form posts
221
+
222
+ = 6.1.3 =
223
+ * Fix password change error
224
+ * Update POT file
225
+
226
+ = 6.1.2 =
227
+ * Replace "self" keyword with "$this" for PHP 4
228
+
229
+ = 6.1.1 =
230
+ * Implement 3.1 password reset routine
231
+ * Add 3.1 fields to Themed Profiles
232
+ * Better default stylesheet for Themed Profiles
233
+ * Add 'nofollow' attribute to action links
234
+ * Check for SSL
235
+ * Add nofollow and noindex to login page
236
+ * Fix missing argument notices
237
+ * Fix deprecated argument notices
238
+ * Fix undefined method notices
239
+ * Fix install/uninstall routines
240
+ * Fix Custom user Links AJAX
241
+ * Fix Custom E-mail "From" filters
242
+ * Fix disabling of admin password change notification
243
+ * Fix "resent" custom activation e-mail
244
+
245
+ = 6.1 =
246
+ * Fully support multisite
247
+ * Require WordPress 3.0+
248
+ * Add Bulgarian translation
249
+ * Add (Belgian) Dutch translation
250
+ * Add Romanian translation
251
+
252
+ = 6.0.4 =
253
+ * Fix admin e-mail notification disabling
254
+ * Fix labels for login form fields
255
+ * Fix wp-login.php form action URL
256
+
257
+ = 6.0.3 =
258
+ * Fix login reauth bug in redirection module
259
+
260
+ = 6.0.2 =
261
+ * Fix Login page creation during install
262
+ * Fix template tag argument parsing
263
+
264
+ = 6.0.1 =
265
+ * Fix logout link for wp_nav_menu()
266
+ * Fix issue admin page not always being tabbed
267
+ * Fix issue of assigning multiple roles per user when using Moderation
268
+ * Add German translation
269
+ * Add Farsi (Persian) translation
270
+ * Add Hebrew translation
271
+ * Add Russian translation
272
+ * Update other languages
273
+
274
+ = 6.0 =
275
+ * Complete code rewrite
276
+ * Users can now log in with e-mail address as well as username
277
+ * Remove option to disable template tag and widget in favor of always being enabled
278
+ * Remove option to rewrite login links in favor of always being rewritten
279
+ * Custom templates can now be defined per action (login, register, etc.)
280
+ * User moderation activation e-mails can be resent on demand
281
+ * Add various new hooks to help with custom integration with other plugins
282
+ * Make custom user links sortable
283
+ * Customize every aspect of every e-mail
284
+ * Add a cool new random tip widget in the TML admin
285
+ * Use WP 3.0 functions (such as 'network_site_url') if available
286
+ * phpDoc everywhere!
287
+
288
+ = 5.1.6 =
289
+ * Fix issue with spaces in usernames
290
+
291
+ = 5.1.5 =
292
+ * Fix blank page redirect bug
293
+
294
+ = 5.1.4 =
295
+ * Fix the_title() bug fro WP versions before 3.0 (again)
296
+ * Fix undefined is_user_logged_in() bug
297
+
298
+ = 5.1.3 =
299
+ * Make Themed Profiles work properly
300
+
301
+ = 5.1.2 =
302
+ * Fix the_title() bug for WP versions before 3.0
303
+ * Fix redirection bug caused by 5.1.1 update
304
+
305
+ = 5.1.1 =
306
+ * Fix bug that blocked users from entire site once logged in
307
+ * PROPERLY display "Log Out" when page is shown in pagelist and logged in
308
+
309
+ = 5.1 =
310
+ * Display "Log Out" when page is shown in pagelist and logged in
311
+ * Forward profile.php to themed profile when module is active
312
+ * Allow for %user_id% in custom user links
313
+ * Add inline descriptions to all settings
314
+ * Various tweaks and preps for WP 3.0
315
+ * Add Italian translation
316
+ * Add Danish translation
317
+ * Add Polish translation
318
+ * Add Spanish translation
319
+
320
+ = 5.0.6 =
321
+ * Pass $theme_my_login by reference in option functions
322
+ * Remove accidental invalid characters
323
+
324
+ = 5.0.5 =
325
+ * Add 'theme-my-login-page' shortcode before 'theme-my-login' shortcode
326
+
327
+ = 5.0.4 =
328
+ * Re-introduce 'theme-my-login-page' shortcode for main login page
329
+ * Add French translation
330
+ * Fix typo in function override notice functions
331
+ * Make 2nd argument optional in 'get_pages' filter
332
+ * Remove another 'self' reference in class.php
333
+ * Fix typo in readme.txt
334
+
335
+ = 5.0.3 =
336
+ * Fix an improper fix for PHP4 style constructor in class
337
+ * Only display function override notices on TML settings page properly
338
+
339
+ = 5.0.2 =
340
+ * Fix improper function call for PHP4 style constructor in class
341
+
342
+ = 5.0.1 =
343
+ * Only display function override notices on TML settings page
344
+ * Typecast arrays as arrays (Fixes invalid datatype notices)
345
+ * Add plugin domain to all gettext calls
346
+
347
+ = 5.0 =
348
+ * Rewrite code in a modular fashion in order to speed up plugin
349
+ * Convert custom e-mails, passwords, redirection, user links and user moderation to "modules"
350
+ * Add the option to enable/disable link rewriting, widget and template tag
351
+ * Simplify/optimize admin tabs style
352
+ * Remember current admin tab after save
353
+ * When using custom passwords, allow users to set their own password upon reset
354
+ * When using custom redirection, specify redirection type per user role/per link type
355
+ * New ajax interface for user links admin
356
+ * Theme My Profile now merged into module
357
+
358
+ = 4.4 =
359
+ * Added the option to require new registrations to confirm e-mail address
360
+ * Added the option to redirect users upon log out according to their role
361
+ * Allow 'theme-my-login.css' to be loaded from current theme directory
362
+ * Cleaned up and rewrote most code
363
+ * Drop support for WP versions below 2.8
364
+
365
+ = 4.3.4 =
366
+ * Added the option to force redirect upon login
367
+
368
+ = 4.3.3 =
369
+ * Fixed a redirection bug where WordPress is installed in a sub-directory
370
+ * Add CSS style to keep "Remember Me" label inline with checkbox
371
+
372
+ = 4.3.2 =
373
+ * Added the option to redirect unapproved and/or denied users to a custom URL upon login attempt
374
+ * Fixed a bug where custom user password is lost if user moderation is enabled
375
+ * Fixed a PHP notice in the admin (Wish more plugin authors would do this; WP_DEBUG is your friend!)
376
+
377
+ = 4.3.1 =
378
+ * Fixed a MAJOR security hole that allowed anyone to login without a password!!
379
+
380
+ = 4.3 =
381
+ * Added the option to require approval for new registrations
382
+ * Added the option to enable/disable plugin stylesheet
383
+ * Removed form input fields from label tags
384
+ * Dropped support for WordPress versions older than 2.6
385
+
386
+ = 4.2.2 =
387
+ * Added the option to remove 'Register' and/or 'Lost Password' links
388
+ * Fixed a bug that sent e-mail from all plugins from this plugins setting
389
+
390
+ = 4.2.1 =
391
+ * Fixed a bug that broke other plugins e-mail format
392
+ * Fixed a bug that could break plugin upon upgrade
393
+
394
+ = 4.2 =
395
+ * Added the option to send e-mails in HTML format
396
+ * Fixed a bug that broke custom user role links if all links were deleted
397
+
398
+ = 4.1.2 =
399
+ * Added the ability to change main login page ID (Only needed for debugging)
400
+ * The login will now revert to default wp-login in the case of plugin failure
401
+
402
+ = 4.1.1 =
403
+ * Fixed a major bug dealing with saving options that broke the plugin
404
+ * Fixed a CSS bug causing interference with other interfaces that use jQuery UI Tabs
405
+
406
+ = 4.1 =
407
+ * Implemented custom user passwords
408
+ * Implemented custom e-mail from name & address
409
+ * Removed template tag & shortcode restriction on main login page
410
+
411
+ = 4.0 =
412
+ * Implemented custom links for logged in users based on role
413
+ * Implemented custom redirection upon log in based on role
414
+ * Implemented custom registration/password recovery emails
415
+
416
+ * Implemented true shortcode and template tag functionality
417
+ * Implemented true multi-instance functionality
418
+ * Implemented an easy-to-use jQuery tabbed administration menu
419
+ * Implemented both 'fresh' and 'classic' colors for administration menu
420
+
421
+ = 3.3.1 =
422
+ * Fixed a bug that broke password recovery due to the new system from WP 2.8.4
423
+
424
+ = 3.3 =
425
+ * Fixed a bug that disabled error display when GET variable 'loggedout' was set
426
+ * Added template tag access
427
+
428
+ = 3.2.8 =
429
+ * Fixed a security exploit regarding admin password reset addressed in WordPress 2.8.4
430
+
431
+ = 3.2.7 =
432
+ * Fixed a bug that determined how to create the widget
433
+
434
+ = 3.2.6 =
435
+ * Fixed a bug dealing with the version_compare() function
436
+ * Included French translation
437
+ * Included Spanish translation
438
+
439
+ = 3.2.5 =
440
+ * Fixed a bug that produced a 'headers aldready sent' error when uploading media
441
+ * Included Dutch translation
442
+
443
+ = 3.2.4 =
444
+ * Fixed the load_plugin_textdomain() call
445
+ * Added 'login_head' action hook
446
+
447
+ = 3.2.3 =
448
+ * Fixed and updated many gettext calls for internationalization
449
+
450
+ = 3.2.2 =
451
+ * Added the option to leave widget links blank for default handling
452
+
453
+ = 3.2.1 =
454
+ * Fixed a XHTML validation issue
455
+
456
+ = 3.2 =
457
+ * Added the option to allow/disallow registration and password recovery within the widget
458
+ * Fixed a bug regarding color names within the CSS file that broke validation
459
+
460
+ = 3.1.1 =
461
+ * Fixed a bug that incorrectly determined current user role
462
+
463
+ = 3.1 =
464
+ * Added the ability to specify URL's for widget 'Dashboard' and 'Profile' links per user role
465
+ * Implemented WordPress 2.8 widget control for multiple widget instances
466
+ * Fixed a bug regarding the registration complete message
467
+
468
+ = 3.0.3 =
469
+ * Fixed a bug with the widget links
470
+
471
+ = 3.0.2 =
472
+ * Fixed a bug that didn't allow custom registration message to be displayed
473
+ * Fixed a few PHP unset variable notice's with a call to isset()
474
+
475
+ = 3.0.1 =
476
+ * Fixed a bug that caused a redirection loop when trying to access wp-login.php
477
+ * Fixed a bug that broke the widget admin interface
478
+ * Added the option to show/hide login page from page list
479
+
480
+ = 3.0 =
481
+ * Added a login widget
482
+
483
+ = 2.2 =
484
+ * Removed all "bloatware"
485
+
486
+ = 2.1 =
487
+ * Implemented login redirection based on user role
488
+
489
+ = 2.0.8 =
490
+ * Fixed a bug that broke the login with permalinks
491
+
492
+ = 2.0.7 =
493
+ * Fixed a bug that broke the Featured Content plugin
494
+
495
+ = 2.0.6 =
496
+ * Added the option to turn on/off subscriber profile theming
497
+
498
+ = 2.0.5 =
499
+ * Fixed a bug with default redirection and hid the login form from logged in users
500
+
501
+ = 2.0.4 =
502
+ * Fixed a bug regarding relative URL's in redirection
503
+
504
+ = 2.0.3 =
505
+ * Fixed various reported bugs and cleaned up code
506
+
507
+ = 2.0.2 =
508
+ * Fixed a bug that broke registration and broke other plugins using the_content filter
509
+
510
+ = 2.0.1 =
511
+ * Fixed a bug that redirected users who were not yet logged in to profile page
512
+
513
+ = 2.0 =
514
+ * Completely rewrote plugin to use page template, no more specifying template files & HTML
515
+
516
+ = 1.2 =
517
+ * Added capability to customize page titles for all pages affected by plugin
518
+
519
+ = 1.1.2 =
520
+ * Updated to allow customization of text below registration form
521
+
522
+ = 1.1.1 =
523
+ * Prepared plugin for internationalization and fixed a PHP version bug
524
+
525
+ = 1.1.0 =
526
+ * Added custom profile to completely hide the back-end from subscribers
527
+
528
+ = 1.0.1 =
529
+ * Made backwards compatible to WordPress 2.5+
530
+
531
+ = 1.0.0 =
532
+ * Initial release version
533
+
templates/login-form.php CHANGED
@@ -1,46 +1,46 @@
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="tml tml-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', 'login_post' ); ?>" method="post">
11
- <p class="tml-user-login-wrap">
12
- <label for="user_login<?php $template->the_instance(); ?>"><?php
13
- if ( 'username' == $theme_my_login->get_option( 'login_type' ) ) {
14
- _e( 'Username', 'theme-my-login' );
15
- } elseif ( 'email' == $theme_my_login->get_option( 'login_type' ) ) {
16
- _e( 'E-mail', 'theme-my-login' );
17
- } else {
18
- _e( 'Username or E-mail', 'theme-my-login' );
19
- }
20
- ?></label>
21
- <input type="text" name="log" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'log' ); ?>" size="20" />
22
- </p>
23
-
24
- <p class="tml-user-pass-wrap">
25
- <label for="user_pass<?php $template->the_instance(); ?>"><?php _e( 'Password', 'theme-my-login' ); ?></label>
26
- <input type="password" name="pwd" id="user_pass<?php $template->the_instance(); ?>" class="input" value="" size="20" autocomplete="off" />
27
- </p>
28
-
29
- <?php do_action( 'login_form' ); ?>
30
-
31
- <div class="tml-rememberme-submit-wrap">
32
- <p class="tml-rememberme-wrap">
33
- <input name="rememberme" type="checkbox" id="rememberme<?php $template->the_instance(); ?>" value="forever" />
34
- <label for="rememberme<?php $template->the_instance(); ?>"><?php esc_attr_e( 'Remember Me', 'theme-my-login' ); ?></label>
35
- </p>
36
-
37
- <p class="tml-submit-wrap">
38
- <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Log In', 'theme-my-login' ); ?>" />
39
- <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'login' ); ?>" />
40
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
41
- <input type="hidden" name="action" value="login" />
42
- </p>
43
- </div>
44
- </form>
45
- <?php $template->the_action_links( array( 'login' => false ) ); ?>
46
- </div>
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="tml tml-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', 'login_post' ); ?>" method="post">
11
+ <p class="tml-user-login-wrap">
12
+ <label for="user_login<?php $template->the_instance(); ?>"><?php
13
+ if ( 'username' == $theme_my_login->get_option( 'login_type' ) ) {
14
+ _e( 'Username', 'theme-my-login' );
15
+ } elseif ( 'email' == $theme_my_login->get_option( 'login_type' ) ) {
16
+ _e( 'E-mail', 'theme-my-login' );
17
+ } else {
18
+ _e( 'Username or E-mail', 'theme-my-login' );
19
+ }
20
+ ?></label>
21
+ <input type="text" name="log" id="user_login<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'log' ); ?>" size="20" />
22
+ </p>
23
+
24
+ <p class="tml-user-pass-wrap">
25
+ <label for="user_pass<?php $template->the_instance(); ?>"><?php _e( 'Password', 'theme-my-login' ); ?></label>
26
+ <input type="password" name="pwd" id="user_pass<?php $template->the_instance(); ?>" class="input" value="" size="20" autocomplete="off" />
27
+ </p>
28
+
29
+ <?php do_action( 'login_form' ); ?>
30
+
31
+ <div class="tml-rememberme-submit-wrap">
32
+ <p class="tml-rememberme-wrap">
33
+ <input name="rememberme" type="checkbox" id="rememberme<?php $template->the_instance(); ?>" value="forever" />
34
+ <label for="rememberme<?php $template->the_instance(); ?>"><?php esc_attr_e( 'Remember Me', 'theme-my-login' ); ?></label>
35
+ </p>
36
+
37
+ <p class="tml-submit-wrap">
38
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Log In', 'theme-my-login' ); ?>" />
39
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'login' ); ?>" />
40
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
41
+ <input type="hidden" name="action" value="login" />
42
+ </p>
43
+ </div>
44
+ </form>
45
+ <?php $template->the_action_links( array( 'login' => false ) ); ?>
46
+ </div>
templates/lostpassword-form.php CHANGED
@@ -1,31 +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="tml tml-lostpassword" 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', 'login_post' ); ?>" method="post">
11
- <p class="tml-user-login-wrap">
12
- <label for="user_login<?php $template->the_instance(); ?>"><?php
13
- if ( 'email' == $theme_my_login->get_option( 'login_type' ) ) {
14
- _e( 'E-mail:', 'theme-my-login' );
15
- } else {
16
- _e( 'Username or E-mail:', 'theme-my-login' );
17
- } ?></label>
18
- <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" />
19
- </p>
20
-
21
- <?php do_action( 'lostpassword_form' ); ?>
22
-
23
- <p class="tml-submit-wrap">
24
- <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Get New Password', 'theme-my-login' ); ?>" />
25
- <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'lostpassword' ); ?>" />
26
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
27
- <input type="hidden" name="action" value="lostpassword" />
28
- </p>
29
- </form>
30
- <?php $template->the_action_links( array( 'lostpassword' => false ) ); ?>
31
- </div>
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="tml tml-lostpassword" 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', 'login_post' ); ?>" method="post">
11
+ <p class="tml-user-login-wrap">
12
+ <label for="user_login<?php $template->the_instance(); ?>"><?php
13
+ if ( 'email' == $theme_my_login->get_option( 'login_type' ) ) {
14
+ _e( 'E-mail:', 'theme-my-login' );
15
+ } else {
16
+ _e( 'Username or E-mail:', 'theme-my-login' );
17
+ } ?></label>
18
+ <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" />
19
+ </p>
20
+
21
+ <?php do_action( 'lostpassword_form' ); ?>
22
+
23
+ <p class="tml-submit-wrap">
24
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Get New Password', 'theme-my-login' ); ?>" />
25
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'lostpassword' ); ?>" />
26
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
27
+ <input type="hidden" name="action" value="lostpassword" />
28
+ </p>
29
+ </form>
30
+ <?php $template->the_action_links( array( 'lostpassword' => false ) ); ?>
31
+ </div>
templates/ms-signup-another-blog-form.php CHANGED
@@ -1,84 +1,84 @@
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
- <h2><?php printf( __( 'Get <em>another</em> %s site in seconds', 'theme-my-login' ), $current_site->site_name ); ?></h2>
8
-
9
- <?php if ( $errors->get_error_code() ) { ?>
10
- <p><?php _e( 'There was a problem, please correct the form below and try again.', 'theme-my-login' ); ?></p>
11
- <?php } ?>
12
-
13
- <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!', 'theme-my-login' ), $current_user->display_name ); ?></p>
14
-
15
- <?php
16
- $blogs = get_blogs_of_user( $current_user->ID );
17
- if ( ! empty( $blogs ) ) { ?>
18
- <p><?php _e( 'Sites you are already a member of:', 'theme-my-login' ); ?></p>
19
- <ul>
20
- <?php foreach ( $blogs as $blog ) {
21
- $home_url = get_home_url( $blog->userblog_id );
22
- echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
23
- } ?>
24
- </ul>
25
- <?php } ?>
26
-
27
- <p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!', 'theme-my-login' ); ?></p>
28
- <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
29
- <input type="hidden" name="action" value="register" />
30
- <input type="hidden" name="stage" value="gimmeanotherblog" />
31
- <?php do_action( 'signup_hidden_fields' ); ?>
32
-
33
- <?php if ( ! is_subdomain_install() ) { ?>
34
- <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Name:', 'theme-my-login' ); ?></label>
35
- <?php } else { ?>
36
- <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Domain:', 'theme-my-login' ); ?></label>
37
- <?php } ?>
38
-
39
- <?php if ( $errmsg = $errors->get_error_message( 'blogname' ) ) { ?>
40
- <p class="error"><?php echo $errmsg; ?></p>
41
- <?php } ?>
42
-
43
- <?php if ( ! is_subdomain_install() ) { ?>
44
- <span class="prefix_address"><?php echo $current_site->domain . $current_site->path; ?></span>
45
- <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" /><br />
46
- <?php } else { ?>
47
- <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" />
48
- <span class="suffix_address"><?php echo ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ); ?></span><br />
49
- <?php } ?>
50
-
51
- <?php if ( ! is_user_logged_in() ) {
52
- if ( ! is_subdomain_install() )
53
- $site = $current_site->domain . $current_site->path . __( 'sitename', 'theme-my-login' );
54
- else
55
- $site = __( 'domain', 'theme-my-login' ) . '.' . $site_domain . $current_site->path;
56
- echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.', 'theme-my-login' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!', 'theme-my-login' ) . '</p>';
57
- } ?>
58
-
59
- <label for="blog_title<?php $template->the_instance(); ?>"><?php _e( 'Site Title:', 'theme-my-login' ); ?></label>
60
- <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
61
- <p class="error"><?php echo $errmsg; ?></p>
62
- <?php } ?>
63
- <input name="blog_title" type="text" id="blog_title<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blog_title ); ?>" />
64
-
65
- <div id="privacy">
66
- <p class="privacy-intro">
67
- <label for="blog_public_on<?php $template->the_instance(); ?>"><?php _e( 'Privacy:', 'theme-my-login' ); ?></label>
68
- <?php _e( 'Allow search engines to index this site.', 'theme-my-login' ); ?>
69
- <br style="clear:both" />
70
- <label class="checkbox" for="blog_public_on<?php $template->the_instance(); ?>">
71
- <input type="radio" id="blog_public_on<?php $template->the_instance(); ?>" name="blog_public" value="1" <?php if ( ! isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
72
- <strong><?php _e( 'Yes', 'theme-my-login' ); ?></strong>
73
- </label>
74
- <label class="checkbox" for="blog_public_off<?php $template->the_instance(); ?>">
75
- <input type="radio" id="blog_public_off<?php $template->the_instance(); ?>" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
76
- <strong><?php _e( 'No', 'theme-my-login' ); ?></strong>
77
- </label>
78
- </p>
79
- </div>
80
-
81
- <?php do_action( 'signup_blogform', $errors ); ?>
82
-
83
- <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site', 'theme-my-login' ); ?>" /></p>
84
- </form>
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
+ <h2><?php printf( __( 'Get <em>another</em> %s site in seconds', 'theme-my-login' ), $current_site->site_name ); ?></h2>
8
+
9
+ <?php if ( $errors->get_error_code() ) { ?>
10
+ <p><?php _e( 'There was a problem, please correct the form below and try again.', 'theme-my-login' ); ?></p>
11
+ <?php } ?>
12
+
13
+ <p><?php printf( __( 'Welcome back, %s. By filling out the form below, you can <strong>add another site to your account</strong>. There is no limit to the number of sites you can have, so create to your heart&#8217;s content, but write responsibly!', 'theme-my-login' ), $current_user->display_name ); ?></p>
14
+
15
+ <?php
16
+ $blogs = get_blogs_of_user( $current_user->ID );
17
+ if ( ! empty( $blogs ) ) { ?>
18
+ <p><?php _e( 'Sites you are already a member of:', 'theme-my-login' ); ?></p>
19
+ <ul>
20
+ <?php foreach ( $blogs as $blog ) {
21
+ $home_url = get_home_url( $blog->userblog_id );
22
+ echo '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
23
+ } ?>
24
+ </ul>
25
+ <?php } ?>
26
+
27
+ <p><?php _e( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!', 'theme-my-login' ); ?></p>
28
+ <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
29
+ <input type="hidden" name="action" value="register" />
30
+ <input type="hidden" name="stage" value="gimmeanotherblog" />
31
+ <?php do_action( 'signup_hidden_fields' ); ?>
32
+
33
+ <?php if ( ! is_subdomain_install() ) { ?>
34
+ <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Name:', 'theme-my-login' ); ?></label>
35
+ <?php } else { ?>
36
+ <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Domain:', 'theme-my-login' ); ?></label>
37
+ <?php } ?>
38
+
39
+ <?php if ( $errmsg = $errors->get_error_message( 'blogname' ) ) { ?>
40
+ <p class="error"><?php echo $errmsg; ?></p>
41
+ <?php } ?>
42
+
43
+ <?php if ( ! is_subdomain_install() ) { ?>
44
+ <span class="prefix_address"><?php echo $current_site->domain . $current_site->path; ?></span>
45
+ <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" /><br />
46
+ <?php } else { ?>
47
+ <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" />
48
+ <span class="suffix_address"><?php echo ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ); ?></span><br />
49
+ <?php } ?>
50
+
51
+ <?php if ( ! is_user_logged_in() ) {
52
+ if ( ! is_subdomain_install() )
53
+ $site = $current_site->domain . $current_site->path . __( 'sitename', 'theme-my-login' );
54
+ else
55
+ $site = __( 'domain', 'theme-my-login' ) . '.' . $site_domain . $current_site->path;
56
+ echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.', 'theme-my-login' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!', 'theme-my-login' ) . '</p>';
57
+ } ?>
58
+
59
+ <label for="blog_title<?php $template->the_instance(); ?>"><?php _e( 'Site Title:', 'theme-my-login' ); ?></label>
60
+ <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
61
+ <p class="error"><?php echo $errmsg; ?></p>
62
+ <?php } ?>
63
+ <input name="blog_title" type="text" id="blog_title<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blog_title ); ?>" />
64
+
65
+ <div id="privacy">
66
+ <p class="privacy-intro">
67
+ <label for="blog_public_on<?php $template->the_instance(); ?>"><?php _e( 'Privacy:', 'theme-my-login' ); ?></label>
68
+ <?php _e( 'Allow search engines to index this site.', 'theme-my-login' ); ?>
69
+ <br style="clear:both" />
70
+ <label class="checkbox" for="blog_public_on<?php $template->the_instance(); ?>">
71
+ <input type="radio" id="blog_public_on<?php $template->the_instance(); ?>" name="blog_public" value="1" <?php if ( ! isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
72
+ <strong><?php _e( 'Yes', 'theme-my-login' ); ?></strong>
73
+ </label>
74
+ <label class="checkbox" for="blog_public_off<?php $template->the_instance(); ?>">
75
+ <input type="radio" id="blog_public_off<?php $template->the_instance(); ?>" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
76
+ <strong><?php _e( 'No', 'theme-my-login' ); ?></strong>
77
+ </label>
78
+ </p>
79
+ </div>
80
+
81
+ <?php do_action( 'signup_blogform', $errors ); ?>
82
+
83
+ <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Create Site', 'theme-my-login' ); ?>" /></p>
84
+ </form>
templates/ms-signup-blog-form.php CHANGED
@@ -1,66 +1,66 @@
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
- <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
8
- <input type="hidden" name="action" value="register" />
9
- <input type="hidden" name="stage" value="validate-blog-signup" />
10
- <input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
11
- <input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
12
- <?php do_action( 'signup_hidden_fields' ); ?>
13
-
14
- <?php if ( ! is_subdomain_install() ) { ?>
15
- <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Name:', 'theme-my-login' ); ?></label>
16
- <?php } else { ?>
17
- <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Domain:', 'theme-my-login' ); ?></label>
18
- <?php } ?>
19
-
20
- <?php if ( $errmsg = $errors->get_error_message( 'blogname' ) ) { ?>
21
- <p class="error"><?php echo $errmsg; ?></p>
22
- <?php } ?>
23
-
24
- <?php if ( ! is_subdomain_install() ) { ?>
25
- <span class="prefix_address"><?php echo $current_site->domain . $current_site->path; ?></span>
26
- <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" /><br />
27
- <?php } else { ?>
28
- <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" />
29
- <span class="suffix_address"><?php echo ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ); ?></span><br />
30
- <?php } ?>
31
-
32
- <?php if ( ! is_user_logged_in() ) {
33
- if ( ! is_subdomain_install() )
34
- $site = $current_site->domain . $current_site->path . __( 'sitename', 'theme-my-login' );
35
- else
36
- $site = __( 'domain', 'theme-my-login' ) . '.' . $site_domain . $current_site->path;
37
- echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.', 'theme-my-login' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!', 'theme-my-login' ) . '</p>';
38
- } ?>
39
-
40
- <label for="blog_title<?php $template->the_instance(); ?>"><?php _e( 'Site Title:', 'theme-my-login' ); ?></label>
41
- <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
42
- <p class="error"><?php echo $errmsg; ?></p>
43
- <?php } ?>
44
- <input name="blog_title" type="text" id="blog_title<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blog_title ); ?>" />
45
-
46
- <div id="privacy">
47
- <p class="privacy-intro">
48
- <label for="blog_public_on<?php $template->the_instance(); ?>"><?php _e( 'Privacy:', 'theme-my-login' ); ?></label>
49
- <?php _e( 'Allow search engines to index this site.', 'theme-my-login' ); ?>
50
- <br style="clear:both" />
51
- <label class="checkbox" for="blog_public_on<?php $template->the_instance(); ?>">
52
- <input type="radio" id="blog_public_on<?php $template->the_instance(); ?>" name="blog_public" value="1" <?php if ( ! isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
53
- <strong><?php _e( 'Yes', 'theme-my-login' ); ?></strong>
54
- </label>
55
- <label class="checkbox" for="blog_public_off<?php $template->the_instance(); ?>">
56
- <input type="radio" id="blog_public_off<?php $template->the_instance(); ?>" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
57
- <strong><?php _e( 'No', 'theme-my-login' ); ?></strong>
58
- </label>
59
- </p>
60
- </div>
61
-
62
- <?php do_action( 'signup_blogform', $errors ); ?>
63
-
64
- <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup', 'theme-my-login' ); ?>" /></p>
65
- </form>
66
- <?php $template->the_action_links( array( 'register' => false ) ); ?>
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
+ <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
8
+ <input type="hidden" name="action" value="register" />
9
+ <input type="hidden" name="stage" value="validate-blog-signup" />
10
+ <input type="hidden" name="user_name" value="<?php echo esc_attr( $user_name ); ?>" />
11
+ <input type="hidden" name="user_email" value="<?php echo esc_attr( $user_email ); ?>" />
12
+ <?php do_action( 'signup_hidden_fields' ); ?>
13
+
14
+ <?php if ( ! is_subdomain_install() ) { ?>
15
+ <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Name:', 'theme-my-login' ); ?></label>
16
+ <?php } else { ?>
17
+ <label for="blogname<?php $template->the_instance(); ?>"><?php _e( 'Site Domain:', 'theme-my-login' ); ?></label>
18
+ <?php } ?>
19
+
20
+ <?php if ( $errmsg = $errors->get_error_message( 'blogname' ) ) { ?>
21
+ <p class="error"><?php echo $errmsg; ?></p>
22
+ <?php } ?>
23
+
24
+ <?php if ( ! is_subdomain_install() ) { ?>
25
+ <span class="prefix_address"><?php echo $current_site->domain . $current_site->path; ?></span>
26
+ <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" /><br />
27
+ <?php } else { ?>
28
+ <input name="blogname" type="text" id="blogname<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blogname ); ?>" maxlength="60" />
29
+ <span class="suffix_address"><?php echo ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ); ?></span><br />
30
+ <?php } ?>
31
+
32
+ <?php if ( ! is_user_logged_in() ) {
33
+ if ( ! is_subdomain_install() )
34
+ $site = $current_site->domain . $current_site->path . __( 'sitename', 'theme-my-login' );
35
+ else
36
+ $site = __( 'domain', 'theme-my-login' ) . '.' . $site_domain . $current_site->path;
37
+ echo '<p>(<strong>' . sprintf( __( 'Your address will be %s.', 'theme-my-login' ), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!', 'theme-my-login' ) . '</p>';
38
+ } ?>
39
+
40
+ <label for="blog_title<?php $template->the_instance(); ?>"><?php _e( 'Site Title:', 'theme-my-login' ); ?></label>
41
+ <?php if ( $errmsg = $errors->get_error_message( 'blog_title' ) ) { ?>
42
+ <p class="error"><?php echo $errmsg; ?></p>
43
+ <?php } ?>
44
+ <input name="blog_title" type="text" id="blog_title<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $blog_title ); ?>" />
45
+
46
+ <div id="privacy">
47
+ <p class="privacy-intro">
48
+ <label for="blog_public_on<?php $template->the_instance(); ?>"><?php _e( 'Privacy:', 'theme-my-login' ); ?></label>
49
+ <?php _e( 'Allow search engines to index this site.', 'theme-my-login' ); ?>
50
+ <br style="clear:both" />
51
+ <label class="checkbox" for="blog_public_on<?php $template->the_instance(); ?>">
52
+ <input type="radio" id="blog_public_on<?php $template->the_instance(); ?>" name="blog_public" value="1" <?php if ( ! isset( $_POST['blog_public'] ) || $_POST['blog_public'] == '1' ) { ?>checked="checked"<?php } ?> />
53
+ <strong><?php _e( 'Yes', 'theme-my-login' ); ?></strong>
54
+ </label>
55
+ <label class="checkbox" for="blog_public_off<?php $template->the_instance(); ?>">
56
+ <input type="radio" id="blog_public_off<?php $template->the_instance(); ?>" name="blog_public" value="0" <?php if ( isset( $_POST['blog_public'] ) && $_POST['blog_public'] == '0' ) { ?>checked="checked"<?php } ?> />
57
+ <strong><?php _e( 'No', 'theme-my-login' ); ?></strong>
58
+ </label>
59
+ </p>
60
+ </div>
61
+
62
+ <?php do_action( 'signup_blogform', $errors ); ?>
63
+
64
+ <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Signup', 'theme-my-login' ); ?>" /></p>
65
+ </form>
66
+ <?php $template->the_action_links( array( 'register' => false ) ); ?>
templates/ms-signup-user-form.php CHANGED
@@ -1,51 +1,51 @@
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
- <h2><?php printf( __( 'Get your own %s account in seconds', 'theme-my-login' ), $current_site->site_name ); ?></h2>
8
-
9
- <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
10
- <input type="hidden" name="action" value="register" />
11
- <input type="hidden" name="stage" value="validate-user-signup" />
12
- <?php do_action( 'signup_hidden_fields' ); ?>
13
-
14
- <label for="user_name<?php $template->the_instance(); ?>"><?php _e( 'Username:', 'theme-my-login' ); ?></label>
15
- <?php if ( $errmsg = $errors->get_error_message( 'user_name' ) ) { ?>
16
- <p class="error"><?php echo $errmsg; ?></p>
17
- <?php } ?>
18
-
19
- <input name="user_name" type="text" id="user_name<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $user_name ); ?>" maxlength="60" /><br />
20
- <span class="hint"><?php _e( '(Must be at least 4 characters, letters and numbers only.)', 'theme-my-login' ); ?></span>
21
-
22
- <label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'Email&nbsp;Address:', 'theme-my-login' ); ?></label>
23
- <?php if ( $errmsg = $errors->get_error_message( 'user_email' ) ) { ?>
24
- <p class="error"><?php echo $errmsg; ?></p>
25
- <?php } ?>
26
-
27
- <input name="user_email" type="text" id="user_email<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" /><br />
28
- <span class="hint"><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)', 'theme-my-login' ); ?></span>
29
- <?php if ( $errmsg = $errors->get_error_message( 'generic' ) ) { ?>
30
- <p class="error"><?php echo $errmsg; ?></p>
31
- <?php } ?>
32
-
33
- <?php do_action( 'signup_extra_fields', $errors ); ?>
34
-
35
- <p>
36
- <?php if ( $active_signup == 'blog' ) { ?>
37
- <input id="signupblog<?php $template->the_instance(); ?>" type="hidden" name="signup_for" value="blog" />
38
- <?php } elseif ( $active_signup == 'user' ) { ?>
39
- <input id="signupblog<?php $template->the_instance(); ?>" type="hidden" name="signup_for" value="user" />
40
- <?php } else { ?>
41
- <input id="signupblog<?php $template->the_instance(); ?>" type="radio" name="signup_for" value="blog" <?php if ( ! isset( $_POST['signup_for'] ) || $_POST['signup_for'] == 'blog' ) { ?>checked="checked"<?php } ?> />
42
- <label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!', 'theme-my-login' ); ?></label>
43
- <br />
44
- <input id="signupuser<?php $template->the_instance(); ?>" type="radio" name="signup_for" value="user" <?php if ( isset( $_POST['signup_for'] ) && $_POST['signup_for'] == 'user' ) { ?>checked="checked"<?php } ?> />
45
- <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'theme-my-login' ); ?></label>
46
- <?php } ?>
47
- </p>
48
-
49
- <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next', 'theme-my-login' ); ?>" /></p>
50
- </form>
51
- <?php $template->the_action_links( array( 'register' => false ) ); ?>
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
+ <h2><?php printf( __( 'Get your own %s account in seconds', 'theme-my-login' ), $current_site->site_name ); ?></h2>
8
+
9
+ <form id="setupform" method="post" action="<?php $template->the_action_url( 'register', 'login_post' ); ?>">
10
+ <input type="hidden" name="action" value="register" />
11
+ <input type="hidden" name="stage" value="validate-user-signup" />
12
+ <?php do_action( 'signup_hidden_fields' ); ?>
13
+
14
+ <label for="user_name<?php $template->the_instance(); ?>"><?php _e( 'Username:', 'theme-my-login' ); ?></label>
15
+ <?php if ( $errmsg = $errors->get_error_message( 'user_name' ) ) { ?>
16
+ <p class="error"><?php echo $errmsg; ?></p>
17
+ <?php } ?>
18
+
19
+ <input name="user_name" type="text" id="user_name<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $user_name ); ?>" maxlength="60" /><br />
20
+ <span class="hint"><?php _e( '(Must be at least 4 characters, letters and numbers only.)', 'theme-my-login' ); ?></span>
21
+
22
+ <label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'Email&nbsp;Address:', 'theme-my-login' ); ?></label>
23
+ <?php if ( $errmsg = $errors->get_error_message( 'user_email' ) ) { ?>
24
+ <p class="error"><?php echo $errmsg; ?></p>
25
+ <?php } ?>
26
+
27
+ <input name="user_email" type="text" id="user_email<?php $template->the_instance(); ?>" value="<?php echo esc_attr( $user_email ); ?>" maxlength="200" /><br />
28
+ <span class="hint"><?php _e( 'We send your registration email to this address. (Double-check your email address before continuing.)', 'theme-my-login' ); ?></span>
29
+ <?php if ( $errmsg = $errors->get_error_message( 'generic' ) ) { ?>
30
+ <p class="error"><?php echo $errmsg; ?></p>
31
+ <?php } ?>
32
+
33
+ <?php do_action( 'signup_extra_fields', $errors ); ?>
34
+
35
+ <p>
36
+ <?php if ( $active_signup == 'blog' ) { ?>
37
+ <input id="signupblog<?php $template->the_instance(); ?>" type="hidden" name="signup_for" value="blog" />
38
+ <?php } elseif ( $active_signup == 'user' ) { ?>
39
+ <input id="signupblog<?php $template->the_instance(); ?>" type="hidden" name="signup_for" value="user" />
40
+ <?php } else { ?>
41
+ <input id="signupblog<?php $template->the_instance(); ?>" type="radio" name="signup_for" value="blog" <?php if ( ! isset( $_POST['signup_for'] ) || $_POST['signup_for'] == 'blog' ) { ?>checked="checked"<?php } ?> />
42
+ <label class="checkbox" for="signupblog"><?php _e( 'Gimme a site!', 'theme-my-login' ); ?></label>
43
+ <br />
44
+ <input id="signupuser<?php $template->the_instance(); ?>" type="radio" name="signup_for" value="user" <?php if ( isset( $_POST['signup_for'] ) && $_POST['signup_for'] == 'user' ) { ?>checked="checked"<?php } ?> />
45
+ <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'theme-my-login' ); ?></label>
46
+ <?php } ?>
47
+ </p>
48
+
49
+ <p class="submit"><input type="submit" name="submit" class="submit" value="<?php esc_attr_e( 'Next', 'theme-my-login' ); ?>" /></p>
50
+ </form>
51
+ <?php $template->the_action_links( array( 'register' => false ) ); ?>
templates/profile-form.php CHANGED
@@ -1,195 +1,195 @@
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="tml tml-profile" id="theme-my-login<?php $template->the_instance(); ?>">
8
- <?php $template->the_action_template_message( 'profile' ); ?>
9
- <?php $template->the_errors(); ?>
10
- <form id="your-profile" action="<?php $template->the_action_url( 'profile', 'login_post' ); ?>" method="post">
11
- <?php wp_nonce_field( 'update-user_' . $current_user->ID ); ?>
12
- <p>
13
- <input type="hidden" name="from" value="profile" />
14
- <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
15
- </p>
16
-
17
- <h3><?php _e( 'Personal Options', 'theme-my-login' ); ?></h3>
18
-
19
- <table class="tml-form-table">
20
- <tr class="tml-user-admin-bar-front-wrap">
21
- <th><label for="admin_bar_front"><?php _e( 'Toolbar', 'theme-my-login' )?></label></th>
22
- <td>
23
- <label for="admin_bar_front"><input type="checkbox" name="admin_bar_front" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
24
- <?php _e( 'Show Toolbar when viewing site', 'theme-my-login' ); ?></label>
25
- </td>
26
- </tr>
27
- <?php do_action( 'personal_options', $profileuser ); ?>
28
- </table>
29
-
30
- <?php do_action( 'profile_personal_options', $profileuser ); ?>
31
-
32
- <h3><?php _e( 'Name', 'theme-my-login' ); ?></h3>
33
-
34
- <table class="tml-form-table">
35
- <tr class="tml-user-login-wrap">
36
- <th><label for="user_login"><?php _e( 'Username', 'theme-my-login' ); ?></label></th>
37
- <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( 'Usernames cannot be changed.', 'theme-my-login' ); ?></span></td>
38
- </tr>
39
-
40
- <tr class="tml-first-name-wrap">
41
- <th><label for="first_name"><?php _e( 'First Name', 'theme-my-login' ); ?></label></th>
42
- <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
43
- </tr>
44
-
45
- <tr class="tml-last-name-wrap">
46
- <th><label for="last_name"><?php _e( 'Last Name', 'theme-my-login' ); ?></label></th>
47
- <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
48
- </tr>
49
-
50
- <tr class="tml-nickname-wrap">
51
- <th><label for="nickname"><?php _e( 'Nickname', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
52
- <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
53
- </tr>
54
-
55
- <tr class="tml-display-name-wrap">
56
- <th><label for="display_name"><?php _e( 'Display name publicly as', 'theme-my-login' ); ?></label></th>
57
- <td>
58
- <select name="display_name" id="display_name">
59
- <?php
60
- $public_display = array();
61
- $public_display['display_nickname'] = $profileuser->nickname;
62
- $public_display['display_username'] = $profileuser->user_login;
63
-
64
- if ( ! empty( $profileuser->first_name ) )
65
- $public_display['display_firstname'] = $profileuser->first_name;
66
-
67
- if ( ! empty( $profileuser->last_name ) )
68
- $public_display['display_lastname'] = $profileuser->last_name;
69
-
70
- if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
71
- $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
72
- $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
73
- }
74
-
75
- if ( ! in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
76
- $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
77
-
78
- $public_display = array_map( 'trim', $public_display );
79
- $public_display = array_unique( $public_display );
80
-
81
- foreach ( $public_display as $id => $item ) {
82
- ?>
83
- <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
84
- <?php
85
- }
86
- ?>
87
- </select>
88
- </td>
89
- </tr>
90
- </table>
91
-
92
- <h3><?php _e( 'Contact Info', 'theme-my-login' ); ?></h3>
93
-
94
- <table class="tml-form-table">
95
- <tr class="tml-user-email-wrap">
96
- <th><label for="email"><?php _e( 'E-mail', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
97
- <td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text" /></td>
98
- <?php
99
- $new_email = get_option( $current_user->ID . '_new_email' );
100
- if ( $new_email && $new_email['newemail'] != $current_user->user_email ) : ?>
101
- <div class="updated inline">
102
- <p><?php
103
- printf(
104
- __( 'There is a pending change of your e-mail to %1$s. <a href="%2$s">Cancel</a>', 'theme-my-login' ),
105
- '<code>' . $new_email['newemail'] . '</code>',
106
- esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) )
107
- ); ?></p>
108
- </div>
109
- <?php endif; ?>
110
- </tr>
111
-
112
- <tr class="tml-user-url-wrap">
113
- <th><label for="url"><?php _e( 'Website', 'theme-my-login' ); ?></label></th>
114
- <td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
115
- </tr>
116
-
117
- <?php
118
- foreach ( wp_get_user_contact_methods() as $name => $desc ) {
119
- ?>
120
- <tr class="tml-user-contact-method-<?php echo $name; ?>-wrap">
121
- <th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
122
- <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
123
- </tr>
124
- <?php
125
- }
126
- ?>
127
- </table>
128
-
129
- <h3><?php _e( 'About Yourself', 'theme-my-login' ); ?></h3>
130
-
131
- <table class="tml-form-table">
132
- <tr class="tml-user-description-wrap">
133
- <th><label for="description"><?php _e( 'Biographical Info', 'theme-my-login' ); ?></label></th>
134
- <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
135
- <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>
136
- </tr>
137
-
138
- <?php
139
- $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
140
- if ( $show_password_fields ) :
141
- ?>
142
- </table>
143
-
144
- <h3><?php _e( 'Account Management', 'theme-my-login' ); ?></h3>
145
- <table class="tml-form-table">
146
- <tr id="password" class="user-pass1-wrap">
147
- <th><label for="pass1"><?php _e( 'New Password', 'theme-my-login' ); ?></label></th>
148
- <td>
149
- <input class="hidden" value=" " /><!-- #24364 workaround -->
150
- <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password', 'theme-my-login' ); ?></button>
151
- <div class="wp-pwd hide-if-js">
152
- <span class="password-input-wrapper">
153
- <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
154
- </span>
155
- <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
156
- <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password', 'theme-my-login' ); ?>">
157
- <span class="dashicons dashicons-hidden"></span>
158
- <span class="text"><?php _e( 'Hide', 'theme-my-login' ); ?></span>
159
- </button>
160
- <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change', 'theme-my-login' ); ?>">
161
- <span class="text"><?php _e( 'Cancel', 'theme-my-login' ); ?></span>
162
- </button>
163
- </div>
164
- </td>
165
- </tr>
166
- <tr class="user-pass2-wrap hide-if-js">
167
- <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password', 'theme-my-login' ); ?></label></th>
168
- <td>
169
- <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
170
- <p class="description"><?php _e( 'Type your new password again.', 'theme-my-login' ); ?></p>
171
- </td>
172
- </tr>
173
- <tr class="pw-weak">
174
- <th><?php _e( 'Confirm Password', 'theme-my-login' ); ?></th>
175
- <td>
176
- <label>
177
- <input type="checkbox" name="pw_weak" class="pw-checkbox" />
178
- <?php _e( 'Confirm use of weak password', 'theme-my-login' ); ?>
179
- </label>
180
- </td>
181
- </tr>
182
- <?php endif; ?>
183
-
184
- </table>
185
-
186
- <?php do_action( 'show_user_profile', $profileuser ); ?>
187
-
188
- <p class="tml-submit-wrap">
189
- <input type="hidden" name="action" value="profile" />
190
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
191
- <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
192
- <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Profile', 'theme-my-login' ); ?>" name="submit" id="submit" />
193
- </p>
194
- </form>
195
- </div>
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="tml tml-profile" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'profile' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form id="your-profile" action="<?php $template->the_action_url( 'profile', 'login_post' ); ?>" method="post">
11
+ <?php wp_nonce_field( 'update-user_' . $current_user->ID ); ?>
12
+ <p>
13
+ <input type="hidden" name="from" value="profile" />
14
+ <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
15
+ </p>
16
+
17
+ <h3><?php _e( 'Personal Options', 'theme-my-login' ); ?></h3>
18
+
19
+ <table class="tml-form-table">
20
+ <tr class="tml-user-admin-bar-front-wrap">
21
+ <th><label for="admin_bar_front"><?php _e( 'Toolbar', 'theme-my-login' )?></label></th>
22
+ <td>
23
+ <label for="admin_bar_front"><input type="checkbox" name="admin_bar_front" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
24
+ <?php _e( 'Show Toolbar when viewing site', 'theme-my-login' ); ?></label>
25
+ </td>
26
+ </tr>
27
+ <?php do_action( 'personal_options', $profileuser ); ?>
28
+ </table>
29
+
30
+ <?php do_action( 'profile_personal_options', $profileuser ); ?>
31
+
32
+ <h3><?php _e( 'Name', 'theme-my-login' ); ?></h3>
33
+
34
+ <table class="tml-form-table">
35
+ <tr class="tml-user-login-wrap">
36
+ <th><label for="user_login"><?php _e( 'Username', 'theme-my-login' ); ?></label></th>
37
+ <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( 'Usernames cannot be changed.', 'theme-my-login' ); ?></span></td>
38
+ </tr>
39
+
40
+ <tr class="tml-first-name-wrap">
41
+ <th><label for="first_name"><?php _e( 'First Name', 'theme-my-login' ); ?></label></th>
42
+ <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
43
+ </tr>
44
+
45
+ <tr class="tml-last-name-wrap">
46
+ <th><label for="last_name"><?php _e( 'Last Name', 'theme-my-login' ); ?></label></th>
47
+ <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
48
+ </tr>
49
+
50
+ <tr class="tml-nickname-wrap">
51
+ <th><label for="nickname"><?php _e( 'Nickname', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
52
+ <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
53
+ </tr>
54
+
55
+ <tr class="tml-display-name-wrap">
56
+ <th><label for="display_name"><?php _e( 'Display name publicly as', 'theme-my-login' ); ?></label></th>
57
+ <td>
58
+ <select name="display_name" id="display_name">
59
+ <?php
60
+ $public_display = array();
61
+ $public_display['display_nickname'] = $profileuser->nickname;
62
+ $public_display['display_username'] = $profileuser->user_login;
63
+
64
+ if ( ! empty( $profileuser->first_name ) )
65
+ $public_display['display_firstname'] = $profileuser->first_name;
66
+
67
+ if ( ! empty( $profileuser->last_name ) )
68
+ $public_display['display_lastname'] = $profileuser->last_name;
69
+
70
+ if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
71
+ $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
72
+ $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
73
+ }
74
+
75
+ if ( ! in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
76
+ $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
77
+
78
+ $public_display = array_map( 'trim', $public_display );
79
+ $public_display = array_unique( $public_display );
80
+
81
+ foreach ( $public_display as $id => $item ) {
82
+ ?>
83
+ <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
84
+ <?php
85
+ }
86
+ ?>
87
+ </select>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+
92
+ <h3><?php _e( 'Contact Info', 'theme-my-login' ); ?></h3>
93
+
94
+ <table class="tml-form-table">
95
+ <tr class="tml-user-email-wrap">
96
+ <th><label for="email"><?php _e( 'E-mail', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
97
+ <td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text" /></td>
98
+ <?php
99
+ $new_email = get_option( $current_user->ID . '_new_email' );
100
+ if ( $new_email && $new_email['newemail'] != $current_user->user_email ) : ?>
101
+ <div class="updated inline">
102
+ <p><?php
103
+ printf(
104
+ __( 'There is a pending change of your e-mail to %1$s. <a href="%2$s">Cancel</a>', 'theme-my-login' ),
105
+ '<code>' . $new_email['newemail'] . '</code>',
106
+ esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) )
107
+ ); ?></p>
108
+ </div>
109
+ <?php endif; ?>
110
+ </tr>
111
+
112
+ <tr class="tml-user-url-wrap">
113
+ <th><label for="url"><?php _e( 'Website', 'theme-my-login' ); ?></label></th>
114
+ <td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
115
+ </tr>
116
+
117
+ <?php
118
+ foreach ( wp_get_user_contact_methods() as $name => $desc ) {
119
+ ?>
120
+ <tr class="tml-user-contact-method-<?php echo $name; ?>-wrap">
121
+ <th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
122
+ <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
123
+ </tr>
124
+ <?php
125
+ }
126
+ ?>
127
+ </table>
128
+
129
+ <h3><?php _e( 'About Yourself', 'theme-my-login' ); ?></h3>
130
+
131
+ <table class="tml-form-table">
132
+ <tr class="tml-user-description-wrap">
133
+ <th><label for="description"><?php _e( 'Biographical Info', 'theme-my-login' ); ?></label></th>
134
+ <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
135
+ <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>
136
+ </tr>
137
+
138
+ <?php
139
+ $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
140
+ if ( $show_password_fields ) :
141
+ ?>
142
+ </table>
143
+
144
+ <h3><?php _e( 'Account Management', 'theme-my-login' ); ?></h3>
145
+ <table class="tml-form-table">
146
+ <tr id="password" class="user-pass1-wrap">
147
+ <th><label for="pass1"><?php _e( 'New Password', 'theme-my-login' ); ?></label></th>
148
+ <td>
149
+ <input class="hidden" value=" " /><!-- #24364 workaround -->
150
+ <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password', 'theme-my-login' ); ?></button>
151
+ <div class="wp-pwd hide-if-js">
152
+ <span class="password-input-wrapper">
153
+ <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
154
+ </span>
155
+ <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
156
+ <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password', 'theme-my-login' ); ?>">
157
+ <span class="dashicons dashicons-hidden"></span>
158
+ <span class="text"><?php _e( 'Hide', 'theme-my-login' ); ?></span>
159
+ </button>
160
+ <button type="button" class="button button-secondary wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change', 'theme-my-login' ); ?>">
161
+ <span class="text"><?php _e( 'Cancel', 'theme-my-login' ); ?></span>
162
+ </button>
163
+ </div>
164
+ </td>
165
+ </tr>
166
+ <tr class="user-pass2-wrap hide-if-js">
167
+ <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password', 'theme-my-login' ); ?></label></th>
168
+ <td>
169
+ <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
170
+ <p class="description"><?php _e( 'Type your new password again.', 'theme-my-login' ); ?></p>
171
+ </td>
172
+ </tr>
173
+ <tr class="pw-weak">
174
+ <th><?php _e( 'Confirm Password', 'theme-my-login' ); ?></th>
175
+ <td>
176
+ <label>
177
+ <input type="checkbox" name="pw_weak" class="pw-checkbox" />
178
+ <?php _e( 'Confirm use of weak password', 'theme-my-login' ); ?>
179
+ </label>
180
+ </td>
181
+ </tr>
182
+ <?php endif; ?>
183
+
184
+ </table>
185
+
186
+ <?php do_action( 'show_user_profile', $profileuser ); ?>
187
+
188
+ <p class="tml-submit-wrap">
189
+ <input type="hidden" name="action" value="profile" />
190
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
191
+ <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
192
+ <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Profile', 'theme-my-login' ); ?>" name="submit" id="submit" />
193
+ </p>
194
+ </form>
195
+ </div>
templates/register-form.php CHANGED
@@ -1,35 +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="tml tml-register" 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', 'login_post' ); ?>" method="post">
11
- <?php if ( 'email' != $theme_my_login->get_option( 'login_type' ) ) : ?>
12
- <p class="tml-user-login-wrap">
13
- <label for="user_login<?php $template->the_instance(); ?>"><?php _e( 'Username', 'theme-my-login' ); ?></label>
14
- <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" />
15
- </p>
16
- <?php endif; ?>
17
-
18
- <p class="tml-user-email-wrap">
19
- <label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'E-mail', 'theme-my-login' ); ?></label>
20
- <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" />
21
- </p>
22
-
23
- <?php do_action( 'register_form' ); ?>
24
-
25
- <p class="tml-registration-confirmation" id="reg_passmail<?php $template->the_instance(); ?>"><?php echo apply_filters( 'tml_register_passmail_template_message', __( 'Registration confirmation will be e-mailed to you.', 'theme-my-login' ) ); ?></p>
26
-
27
- <p class="tml-submit-wrap">
28
- <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Register', 'theme-my-login' ); ?>" />
29
- <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'register' ); ?>" />
30
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
31
- <input type="hidden" name="action" value="register" />
32
- </p>
33
- </form>
34
- <?php $template->the_action_links( array( 'register' => false ) ); ?>
35
- </div>
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="tml tml-register" 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', 'login_post' ); ?>" method="post">
11
+ <?php if ( 'email' != $theme_my_login->get_option( 'login_type' ) ) : ?>
12
+ <p class="tml-user-login-wrap">
13
+ <label for="user_login<?php $template->the_instance(); ?>"><?php _e( 'Username', 'theme-my-login' ); ?></label>
14
+ <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" />
15
+ </p>
16
+ <?php endif; ?>
17
+
18
+ <p class="tml-user-email-wrap">
19
+ <label for="user_email<?php $template->the_instance(); ?>"><?php _e( 'E-mail', 'theme-my-login' ); ?></label>
20
+ <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" />
21
+ </p>
22
+
23
+ <?php do_action( 'register_form' ); ?>
24
+
25
+ <p class="tml-registration-confirmation" id="reg_passmail<?php $template->the_instance(); ?>"><?php echo apply_filters( 'tml_register_passmail_template_message', __( 'Registration confirmation will be e-mailed to you.', 'theme-my-login' ) ); ?></p>
26
+
27
+ <p class="tml-submit-wrap">
28
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Register', 'theme-my-login' ); ?>" />
29
+ <input type="hidden" name="redirect_to" value="<?php $template->the_redirect_url( 'register' ); ?>" />
30
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
31
+ <input type="hidden" name="action" value="register" />
32
+ </p>
33
+ </form>
34
+ <?php $template->the_action_links( array( 'register' => false ) ); ?>
35
+ </div>
templates/resetpass-form.php CHANGED
@@ -1,47 +1,47 @@
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="tml tml-resetpass" id="theme-my-login<?php $template->the_instance(); ?>">
8
- <?php $template->the_action_template_message( 'resetpass' ); ?>
9
- <?php $template->the_errors(); ?>
10
- <form name="resetpassform" id="resetpassform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'resetpass', 'login_post' ); ?>" method="post" autocomplete="off">
11
-
12
- <div class="user-pass1-wrap">
13
- <p>
14
- <label for="pass1"><?php _e( 'New password', 'theme-my-login' ); ?></label>
15
- </p>
16
-
17
- <div class="wp-pwd">
18
- <span class="password-input-wrapper">
19
- <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" />
20
- </span>
21
- <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator', 'theme-my-login' ); ?></div>
22
- </div>
23
- </div>
24
-
25
- <p class="user-pass2-wrap">
26
- <label for="pass2"><?php _e( 'Confirm new password', 'theme-my-login' ); ?></label>
27
- <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
28
- </p>
29
-
30
- <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
31
-
32
- <?php do_action( 'resetpassword_form' ); ?>
33
-
34
- <p class="tml-submit-wrap">
35
- <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Reset Password', 'theme-my-login' ); ?>" />
36
- <input type="hidden" id="user_login" value="<?php echo esc_attr( $GLOBALS['rp_login'] ); ?>" autocomplete="off" />
37
- <input type="hidden" name="rp_key" value="<?php echo esc_attr( $GLOBALS['rp_key'] ); ?>" />
38
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
39
- <input type="hidden" name="action" value="resetpass" />
40
- </p>
41
- </form>
42
- <?php $template->the_action_links( array(
43
- 'login' => false,
44
- 'register' => false,
45
- 'lostpassword' => false
46
- ) ); ?>
47
- </div>
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="tml tml-resetpass" id="theme-my-login<?php $template->the_instance(); ?>">
8
+ <?php $template->the_action_template_message( 'resetpass' ); ?>
9
+ <?php $template->the_errors(); ?>
10
+ <form name="resetpassform" id="resetpassform<?php $template->the_instance(); ?>" action="<?php $template->the_action_url( 'resetpass', 'login_post' ); ?>" method="post" autocomplete="off">
11
+
12
+ <div class="user-pass1-wrap">
13
+ <p>
14
+ <label for="pass1"><?php _e( 'New password', 'theme-my-login' ); ?></label>
15
+ </p>
16
+
17
+ <div class="wp-pwd">
18
+ <span class="password-input-wrapper">
19
+ <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" aria-describedby="pass-strength-result" />
20
+ </span>
21
+ <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator', 'theme-my-login' ); ?></div>
22
+ </div>
23
+ </div>
24
+
25
+ <p class="user-pass2-wrap">
26
+ <label for="pass2"><?php _e( 'Confirm new password', 'theme-my-login' ); ?></label>
27
+ <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
28
+ </p>
29
+
30
+ <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
31
+
32
+ <?php do_action( 'resetpassword_form' ); ?>
33
+
34
+ <p class="tml-submit-wrap">
35
+ <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Reset Password', 'theme-my-login' ); ?>" />
36
+ <input type="hidden" id="user_login" value="<?php echo esc_attr( $GLOBALS['rp_login'] ); ?>" autocomplete="off" />
37
+ <input type="hidden" name="rp_key" value="<?php echo esc_attr( $GLOBALS['rp_key'] ); ?>" />
38
+ <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
39
+ <input type="hidden" name="action" value="resetpass" />
40
+ </p>
41
+ </form>
42
+ <?php $template->the_action_links( array(
43
+ 'login' => false,
44
+ 'register' => false,
45
+ 'lostpassword' => false
46
+ ) ); ?>
47
+ </div>
templates/user-panel.php CHANGED
@@ -1,15 +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="tml tml-user-panel" 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 $template->the_user_links(); ?>
13
-
14
- <?php do_action( 'tml_user_panel' ); ?>
15
- </div>
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="tml tml-user-panel" 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 $template->the_user_links(); ?>
13
+
14
+ <?php do_action( 'tml_user_panel' ); ?>
15
+ </div>
theme-my-login.css CHANGED
@@ -1,200 +1,200 @@
1
- .tml {
2
- max-width: 320px;
3
- }
4
-
5
- .tml * {
6
- -webkit-box-sizing: border-box;
7
- -moz-box-sizing: border-box;
8
- box-sizing: border-box;
9
- }
10
-
11
- .tml .error,
12
- .tml .message {
13
- color: #333;
14
- padding: 0.5em;
15
- }
16
-
17
- .tml .error {
18
- border: 1px solid #c00;
19
- background-color: #ffebe8;
20
- }
21
-
22
- .tml .message {
23
- border: 1px solid #e6db55;
24
- background-color: #ffffe0;
25
- }
26
-
27
- .tml p {
28
- margin: 0 0 1.5em 0;
29
- padding: 0;
30
- }
31
-
32
- .tml label {
33
- display: block;
34
- text-align: left;
35
- }
36
-
37
- .tml .tml-rememberme-wrap label {
38
- display: inline;
39
- }
40
-
41
- .tml input,
42
- .tml textarea,
43
- .tml select {
44
- margin: 0.5em 0;
45
- width: 100%;
46
- }
47
-
48
- .tml input[type="checkbox"],
49
- .tml input[type="radio"],
50
- .tml .tml-rememberme-wrap input {
51
- vertical-align: middle;
52
- width: auto;
53
- }
54
-
55
- .tml .tml-action-links {
56
- display: inline-block;
57
- list-style: none;
58
- margin: 0.5em auto;
59
- padding: 0;
60
- text-align: center;
61
- }
62
-
63
- .tml .tml-action-links li {
64
- border: none;
65
- border-right: 1px solid rgba(0, 0, 0, 0.1);
66
- float: left;
67
- line-height: 1;
68
- list-style: none;
69
- margin: 0 0.5em 0 0;
70
- padding: 0 0.5em 0 0;
71
- }
72
-
73
- .tml .tml-action-links li:last-child {
74
- border-right: none;
75
- margin-right: 0;
76
- padding-right: 0;
77
- }
78
-
79
- .tml .tml-action-links a {
80
- border: none;
81
- display: block;
82
- padding: 0;
83
- text-decoration: none;
84
- }
85
-
86
- .tml .tml-rememberme-submit-wrap:before,
87
- .tml .tml-rememberme-submit-wrap:after,
88
- .tml .tml-action-links:before,
89
- .tml .tml-action-links:after {
90
- content: "";
91
- display: table;
92
- }
93
-
94
- .tml .tml-rememberme-submit-wrap:after,
95
- .tml .tml-action-links:after {
96
- clear: both;
97
- }
98
-
99
- .tml .tml-user-avatar {
100
- text-align: left;
101
- }
102
-
103
- .mu_register .hint {
104
- font-size: 12px;
105
- margin-bottom: 10px;
106
- display: block;
107
- }
108
-
109
- .mu_register label.checkbox {
110
- display: inline;
111
- }
112
-
113
- #pass-strength-result {
114
- background-color: #eee;
115
- border: 1px solid #ddd;
116
- color: #23282d;
117
- font-weight: 600;
118
- margin: 0;
119
- padding: 3px 5px;
120
- text-align: center;
121
- width: 100%;
122
- opacity: 0;
123
- }
124
-
125
- #pass-strength-result.short {
126
- background-color: #f1adad;
127
- border-color: #e35b5b;
128
- opacity: 1;
129
- }
130
-
131
- #pass-strength-result.bad {
132
- background-color: #fbc5a9;
133
- border-color: #f78b53;
134
- opacity: 1;
135
- }
136
-
137
- #pass-strength-result.good {
138
- background-color: #ffe399;
139
- border-color: #ffc733;
140
- opacity: 1;
141
- }
142
-
143
- #pass-strength-result.strong {
144
- background-color: #c1e1b9;
145
- border-color: #83c373;
146
- opacity: 1;
147
- }
148
-
149
- .pw-weak {
150
- display:none;
151
- }
152
-
153
- .indicator-hint {
154
- padding-top: 8px;
155
- }
156
-
157
- #pass1,
158
- #pass1-text {
159
- width: 100%;
160
- }
161
-
162
- #pass1-text,
163
- .show-password #pass1 {
164
- display: none;
165
- }
166
-
167
- .show-password #pass1-text
168
- {
169
- display: inline-block;
170
- }
171
-
172
- @media screen and (min-width: 768px) {
173
- .tml .tml-submit-wrap input {
174
- width: auto;
175
- }
176
-
177
- .tml-login .tml-rememberme-submit-wrap {
178
- display: table;
179
- margin-bottom: 1.5em;
180
- width: 100%;
181
- }
182
-
183
- .tml-login .tml-rememberme-wrap {
184
- display: table-cell;
185
- }
186
-
187
- .tml-login .tml-rememberme-wrap input {
188
- margin: 0;
189
- }
190
-
191
- .tml-login .tml-submit-wrap {
192
- display: table-cell;
193
- text-align: right;
194
- }
195
-
196
- .tml-login .tml-submit-wrap input {
197
- margin: 0;
198
- width: auto;
199
- }
200
- }
1
+ .tml {
2
+ max-width: 320px;
3
+ }
4
+
5
+ .tml * {
6
+ -webkit-box-sizing: border-box;
7
+ -moz-box-sizing: border-box;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ .tml .error,
12
+ .tml .message {
13
+ color: #333;
14
+ padding: 0.5em;
15
+ }
16
+
17
+ .tml .error {
18
+ border: 1px solid #c00;
19
+ background-color: #ffebe8;
20
+ }
21
+
22
+ .tml .message {
23
+ border: 1px solid #e6db55;
24
+ background-color: #ffffe0;
25
+ }
26
+
27
+ .tml p {
28
+ margin: 0 0 1.5em 0;
29
+ padding: 0;
30
+ }
31
+
32
+ .tml label {
33
+ display: block;
34
+ text-align: left;
35
+ }
36
+
37
+ .tml .tml-rememberme-wrap label {
38
+ display: inline;
39
+ }
40
+
41
+ .tml input,
42
+ .tml textarea,
43
+ .tml select {
44
+ margin: 0.5em 0;
45
+ width: 100%;
46
+ }
47
+
48
+ .tml input[type="checkbox"],
49
+ .tml input[type="radio"],
50
+ .tml .tml-rememberme-wrap input {
51
+ vertical-align: middle;
52
+ width: auto;
53
+ }
54
+
55
+ .tml .tml-action-links {
56
+ display: inline-block;
57
+ list-style: none;
58
+ margin: 0.5em auto;
59
+ padding: 0;
60
+ text-align: center;
61
+ }
62
+
63
+ .tml .tml-action-links li {
64
+ border: none;
65
+ border-right: 1px solid rgba(0, 0, 0, 0.1);
66
+ float: left;
67
+ line-height: 1;
68
+ list-style: none;
69
+ margin: 0 0.5em 0 0;
70
+ padding: 0 0.5em 0 0;
71
+ }
72
+
73
+ .tml .tml-action-links li:last-child {
74
+ border-right: none;
75
+ margin-right: 0;
76
+ padding-right: 0;
77
+ }
78
+
79
+ .tml .tml-action-links a {
80
+ border: none;
81
+ display: block;
82
+ padding: 0;
83
+ text-decoration: none;
84
+ }
85
+
86
+ .tml .tml-rememberme-submit-wrap:before,
87
+ .tml .tml-rememberme-submit-wrap:after,
88
+ .tml .tml-action-links:before,
89
+ .tml .tml-action-links:after {
90
+ content: "";
91
+ display: table;
92
+ }
93
+
94
+ .tml .tml-rememberme-submit-wrap:after,
95
+ .tml .tml-action-links:after {
96
+ clear: both;
97
+ }
98
+
99
+ .tml .tml-user-avatar {
100
+ text-align: left;
101
+ }
102
+
103
+ .mu_register .hint {
104
+ font-size: 12px;
105
+ margin-bottom: 10px;
106
+ display: block;
107
+ }
108
+
109
+ .mu_register label.checkbox {
110
+ display: inline;
111
+ }
112
+
113
+ #pass-strength-result {
114
+ background-color: #eee;
115
+ border: 1px solid #ddd;
116
+ color: #23282d;
117
+ font-weight: 600;
118
+ margin: 0;
119
+ padding: 3px 5px;
120
+ text-align: center;
121
+ width: 100%;
122
+ opacity: 0;
123
+ }
124
+
125
+ #pass-strength-result.short {
126
+ background-color: #f1adad;
127
+ border-color: #e35b5b;
128
+ opacity: 1;
129
+ }
130
+
131
+ #pass-strength-result.bad {
132
+ background-color: #fbc5a9;
133
+ border-color: #f78b53;
134
+ opacity: 1;
135
+ }
136
+
137
+ #pass-strength-result.good {
138
+ background-color: #ffe399;
139
+ border-color: #ffc733;
140
+ opacity: 1;
141
+ }
142
+
143
+ #pass-strength-result.strong {
144
+ background-color: #c1e1b9;
145
+ border-color: #83c373;
146
+ opacity: 1;
147
+ }
148
+
149
+ .pw-weak {
150
+ display:none;
151
+ }
152
+
153
+ .indicator-hint {
154
+ padding-top: 8px;
155
+ }
156
+
157
+ #pass1,
158
+ #pass1-text {
159
+ width: 100%;
160
+ }
161
+
162
+ #pass1-text,
163
+ .show-password #pass1 {
164
+ display: none;
165
+ }
166
+
167
+ .show-password #pass1-text
168
+ {
169
+ display: inline-block;
170
+ }
171
+
172
+ @media screen and (min-width: 768px) {
173
+ .tml .tml-submit-wrap input {
174
+ width: auto;
175
+ }
176
+
177
+ .tml-login .tml-rememberme-submit-wrap {
178
+ display: table;
179
+ margin-bottom: 1.5em;
180
+ width: 100%;
181
+ }
182
+
183
+ .tml-login .tml-rememberme-wrap {
184
+ display: table-cell;
185
+ }
186
+
187
+ .tml-login .tml-rememberme-wrap input {
188
+ margin: 0;
189
+ }
190
+
191
+ .tml-login .tml-submit-wrap {
192
+ display: table-cell;
193
+ text-align: right;
194
+ }
195
+
196
+ .tml-login .tml-submit-wrap input {
197
+ margin: 0;
198
+ width: auto;
199
+ }
200
+ }
theme-my-login.php CHANGED
@@ -1,59 +1,59 @@
1
- <?php
2
- /*
3
- Plugin Name: Theme My Login
4
- Plugin URI: http://www.jfarthing.com/extend/wordpress-plugins/theme-my-login/
5
- Description: Themes the WordPress login, registration and forgot password pages according to your theme.
6
- Version: 6.4.5
7
- Author: Jeff Farthing
8
- Author URI: http://www.jfarthing.com
9
- Text Domain: theme-my-login
10
- Domain Path: /languages
11
- */
12
-
13
- // Allow custom functions file
14
- if ( file_exists( WP_PLUGIN_DIR . '/theme-my-login-custom.php' ) )
15
- include_once( WP_PLUGIN_DIR . '/theme-my-login-custom.php' );
16
-
17
- if ( ! defined( 'THEME_MY_LOGIN_PATH' ) ) {
18
- define( 'THEME_MY_LOGIN_PATH', dirname( __FILE__ ) );
19
- }
20
-
21
- // Require a few needed files
22
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-common.php' );
23
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-abstract.php' );
24
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login.php' );
25
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-template.php' );
26
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-widget.php' );
27
-
28
- // Instantiate Theme_My_Login singleton
29
- Theme_My_Login::get_object();
30
-
31
- if ( is_admin() ) {
32
- require_once( THEME_MY_LOGIN_PATH . '/admin/class-theme-my-login-admin.php' );
33
-
34
- // Instantiate Theme_My_Login_Admin singleton
35
- Theme_My_Login_Admin::get_object();
36
- }
37
-
38
- if ( is_multisite() ) {
39
- require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-ms-signup.php' );
40
-
41
- // Instantiate Theme_My_Login_MS_Signup singleton
42
- Theme_My_Login_MS_Signup::get_object();
43
- }
44
-
45
- if ( ! function_exists( 'theme_my_login' ) ) :
46
- /**
47
- * Displays a TML instance
48
- *
49
- * @see Theme_My_Login::shortcode() for $args parameters
50
- * @since 6.0
51
- *
52
- * @param string|array $args Template tag arguments
53
- */
54
- function theme_my_login( $args = '' ) {
55
- echo Theme_My_Login::get_object()->shortcode( wp_parse_args( $args ) );
56
- }
57
- endif;
58
-
59
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Theme My Login
4
+ Plugin URI: http://www.jfarthing.com/extend/wordpress-plugins/theme-my-login/
5
+ Description: Themes the WordPress login, registration and forgot password pages according to your theme.
6
+ Version: 6.4.6
7
+ Author: Jeff Farthing
8
+ Author URI: http://www.jfarthing.com
9
+ Text Domain: theme-my-login
10
+ Domain Path: /languages
11
+ */
12
+
13
+ // Allow custom functions file
14
+ if ( file_exists( WP_PLUGIN_DIR . '/theme-my-login-custom.php' ) )
15
+ include_once( WP_PLUGIN_DIR . '/theme-my-login-custom.php' );
16
+
17
+ if ( ! defined( 'THEME_MY_LOGIN_PATH' ) ) {
18
+ define( 'THEME_MY_LOGIN_PATH', dirname( __FILE__ ) );
19
+ }
20
+
21
+ // Require a few needed files
22
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-common.php' );
23
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-abstract.php' );
24
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login.php' );
25
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-template.php' );
26
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-widget.php' );
27
+
28
+ // Instantiate Theme_My_Login singleton
29
+ Theme_My_Login::get_object();
30
+
31
+ if ( is_admin() ) {
32
+ require_once( THEME_MY_LOGIN_PATH . '/admin/class-theme-my-login-admin.php' );
33
+
34
+ // Instantiate Theme_My_Login_Admin singleton
35
+ Theme_My_Login_Admin::get_object();
36
+ }
37
+
38
+ if ( is_multisite() ) {
39
+ require_once( THEME_MY_LOGIN_PATH . '/includes/class-theme-my-login-ms-signup.php' );
40
+
41
+ // Instantiate Theme_My_Login_MS_Signup singleton
42
+ Theme_My_Login_MS_Signup::get_object();
43
+ }
44
+
45
+ if ( ! function_exists( 'theme_my_login' ) ) :
46
+ /**
47
+ * Displays a TML instance
48
+ *
49
+ * @see Theme_My_Login::shortcode() for $args parameters
50
+ * @since 6.0
51
+ *
52
+ * @param string|array $args Template tag arguments
53
+ */
54
+ function theme_my_login( $args = '' ) {
55
+ echo Theme_My_Login::get_object()->shortcode( wp_parse_args( $args ) );
56
+ }
57
+ endif;
58
+
59
+ ?>