Theme My Login - Version 7.0.3

Version Description

  • Fix an error on PHP versions less than 5.3
  • Allow for description in settings API functions
  • Fix compatibility with legacy shortcode
  • Rewrite certain admin login links
  • Remove undesired actions and filters from TML pages
  • Introduce new tml_action_{$action} hook and use it for handlers
Download this release

Release Info

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

Code changes from version 6.4.17 to 7.0.3

Files changed (72) hide show
  1. admin/assets/images/logo.svg +1 -0
  2. admin/assets/scripts/theme-my-login-admin.js +26 -0
  3. admin/assets/scripts/theme-my-login-admin.min.js +1 -0
  4. admin/assets/styles/theme-my-login-admin.css +0 -0
  5. admin/assets/styles/theme-my-login-admin.min.css +0 -0
  6. admin/class-theme-my-login-admin.php +92 -652
  7. admin/class-theme-my-login-walker-nav-menu-edit.php +54 -0
  8. admin/extensions.php +243 -0
  9. admin/functions.php +279 -0
  10. admin/hooks.php +33 -0
  11. admin/js/theme-my-login-admin.js +0 -20
  12. admin/settings.php +544 -0
  13. assets/scripts/theme-my-login.js +86 -0
  14. assets/scripts/theme-my-login.min.js +1 -0
  15. assets/styles/theme-my-login.css +94 -0
  16. assets/styles/theme-my-login.min.css +1 -0
  17. composer.json +12 -0
  18. includes/actions.php +648 -0
  19. includes/class-theme-my-login-abstract.php +0 -256
  20. includes/class-theme-my-login-action.php +266 -0
  21. includes/class-theme-my-login-common.php +0 -152
  22. includes/class-theme-my-login-extension.php +375 -0
  23. includes/class-theme-my-login-form-field.php +624 -0
  24. includes/class-theme-my-login-form.php +586 -0
  25. includes/class-theme-my-login-ms-signup.php +0 -567
  26. includes/class-theme-my-login-template.php +0 -600
  27. includes/class-theme-my-login-widget.php +90 -99
  28. includes/class-theme-my-login.php +212 -1149
  29. includes/compat.php +126 -0
  30. includes/extensions.php +308 -0
  31. includes/forms.php +424 -0
  32. includes/functions.php +845 -0
  33. includes/hooks.php +90 -0
  34. includes/ms-functions.php +1147 -0
  35. includes/ms-hooks.php +36 -0
  36. includes/options.php +196 -0
  37. includes/shortcodes.php +77 -0
  38. languages/theme-my-login.pot +97 -1354
  39. modules/custom-email/admin/custom-email-admin.php +0 -613
  40. modules/custom-email/admin/js/custom-email-admin.js +0 -3
  41. modules/custom-email/custom-email.php +0 -938
  42. modules/custom-passwords/custom-passwords.php +0 -313
  43. modules/custom-redirection/admin/custom-redirection-admin.php +0 -201
  44. modules/custom-redirection/admin/js/custom-redirection-admin.js +0 -3
  45. modules/custom-redirection/custom-redirection.php +0 -236
  46. modules/custom-user-links/admin/css/custom-user-links-admin.css +0 -30
  47. modules/custom-user-links/admin/custom-user-links-admin.php +0 -412
  48. modules/custom-user-links/admin/js/custom-user-links-admin.js +0 -42
  49. modules/custom-user-links/custom-user-links.php +0 -130
  50. modules/recaptcha/admin/recaptcha-admin.php +0 -210
  51. modules/recaptcha/recaptcha.php +0 -200
  52. modules/security/admin/js/security-admin.js +0 -3
  53. modules/security/admin/security-admin.php +0 -313
  54. modules/security/security.php +0 -623
  55. modules/themed-profiles/admin/themed-profiles-admin.php +0 -215
  56. modules/themed-profiles/themed-profiles.css +0 -51
  57. modules/themed-profiles/themed-profiles.js +0 -5
  58. modules/themed-profiles/themed-profiles.php +0 -409
  59. modules/user-moderation/admin/user-moderation-admin.php +0 -443
  60. modules/user-moderation/user-moderation.php +0 -480
  61. readme.txt +82 -33
  62. templates/login-form.php +0 -46
  63. templates/lostpassword-form.php +0 -31
  64. templates/ms-signup-another-blog-form.php +0 -84
  65. templates/ms-signup-blog-form.php +0 -66
  66. templates/ms-signup-user-form.php +0 -51
  67. templates/profile-form.php +0 -198
  68. templates/register-form.php +0 -35
  69. templates/resetpass-form.php +0 -56
  70. templates/user-panel.php +0 -15
  71. theme-my-login.css +0 -259
  72. theme-my-login.php +80 -37
admin/assets/images/logo.svg ADDED
@@ -0,0 +1 @@
 
1
+ <svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><style>.st1{fill:#fff}</style><path d="M726 325c0-170.6-138.3-308.9-308.9-308.9v165.6c-93.7-2.2-184.3 32.4-249 95.2C105.9 337.3 72 419.5 72 508.4v.2c0 149.9 113.3 270.8 258.2 275.2 115.4 3.5 211.9-87.4 215.7-202.7-.4-8.6-.7-17.1-1.1-25.6-9.7-79.1-76-141.7-158.1-144.2-34.1-1-66.6 11.3-91.5 34.7-24.9 23.4-39.1 55.1-40.1 89.2-.8 26.3 8.7 51.4 26.8 70.6 18.1 19.2 42.5 30.2 68.8 31 41.5 1.3 76.3-31.5 77.6-73 .5-15-5-29.5-15.4-40.6-10.4-11-24.4-17.3-39.5-17.8-11.1-.3-21.7 3.7-29.9 11.3-8.1 7.6-12.8 18-13.1 29.1-.3 9.9-8.6 17.7-18.5 17.4-9.9-.3-17.7-8.5-17.4-18.5.6-20.7 9.3-40 24.4-54.2 15.1-14.2 34.8-21.7 55.6-21.1 24.7.7 47.7 11.1 64.6 29.1 17 18 25.9 41.6 25.1 66.3-1.8 61.3-53.2 109.7-114.6 107.8-35.9-1.1-69.3-16.1-93.9-42.3-24.6-26.2-37.6-60.4-36.5-96.3 1.3-43.7 19.6-84.3 51.4-114.3 31.8-30 73.5-45.7 117.2-44.4 61.1 1.8 115.2 31.1 150.6 75.5l.1.6L598 445v-.1c-3.6-33.3-32.5-57.5-64.9-54.6-2.7-23.1-5.9-44.8-9.7-64.8H726v-.5zM546 203.3c-30.7 0-55.5-24.9-55.5-55.5 0-30.7 24.9-55.5 55.5-55.5s55.5 24.9 55.5 55.5-24.9 55.5-55.5 55.5z" fill="#85c44a"/><path class="st1" d="M546 92.3c-30.7 0-55.5 24.9-55.5 55.5 0 30.7 24.9 55.5 55.5 55.5s55.5-24.9 55.5-55.5c0-30.7-24.9-55.5-55.5-55.5zm0 88.2c-18.1 0-32.7-14.7-32.7-32.7 0-18.1 14.7-32.7 32.7-32.7s32.7 14.7 32.7 32.7c0 18-14.7 32.7-32.7 32.7z"/><path d="M546 115c-18.1 0-32.7 14.7-32.7 32.7 0 18.1 14.7 32.7 32.7 32.7s32.7-14.7 32.7-32.7c0-18-14.7-32.7-32.7-32.7zm-20 37c-2.4 0-4.3-1.9-4.3-4.3s1.9-4.3 4.3-4.3 4.3 1.9 4.3 4.3-1.9 4.3-4.3 4.3zm11.4-8.5c-3.9 0-7.1-3.2-7.1-7.1s3.2-7.1 7.1-7.1 7.1 3.2 7.1 7.1-3.1 7.1-7.1 7.1z"/><circle class="st1" cx="537.4" cy="136.4" r="7.1"/><circle class="st1" cx="526" cy="147.8" r="4.3"/></svg>
admin/assets/scripts/theme-my-login-admin.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ $( initMetaBoxes );
3
+
4
+ function initMetaBoxes() {
5
+ var metaboxes = $( '.postbox' );
6
+
7
+ if ( metaboxes.length ) {
8
+ // Make metaboxes toggleable
9
+ postboxes.add_postbox_toggles( pagenow );
10
+
11
+ // Close all metaboxes by default
12
+ $( '.postbox' ).addClass( 'closed' );
13
+
14
+ // Find each metabox holder
15
+ $( '.metabox-holder' ).each( function() {
16
+ var holder = $( this );
17
+
18
+ // Maybe disable sorting
19
+ if ( holder.data( 'sortable' ) == 'off' ) {
20
+ holder.find( '.meta-box-sortables' ).sortable( 'destroy' );
21
+ holder.find( '.postbox .hndle' ).css( 'cursor', 'default' );
22
+ }
23
+ } );
24
+ }
25
+ }
26
+ } )( jQuery );
admin/assets/scripts/theme-my-login-admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(s){s(function(){s(".postbox").length&&(postboxes.add_postbox_toggles(pagenow),s(".postbox").addClass("closed"),s(".metabox-holder").each(function(){var o=s(this);"off"==o.data("sortable")&&(o.find(".meta-box-sortables").sortable("destroy"),o.find(".postbox .hndle").css("cursor","default"))}))})}(jQuery);
admin/assets/styles/theme-my-login-admin.css ADDED
File without changes
admin/assets/styles/theme-my-login-admin.min.css ADDED
File without changes
admin/class-theme-my-login-admin.php CHANGED
@@ -1,718 +1,158 @@
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
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
58
- add_action( 'wp_ajax_tml-dismiss-notice', array( $this, 'ajax_dismiss_notice' ) );
59
-
60
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
61
- add_action( 'save_post', array( $this, 'save_action_meta_box' ) );
62
-
63
- if ( ! $this->get_option( 'allow_update' ) ) {
64
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'pre_set_site_transient_update_plugins' ) );
65
- }
66
- add_action( 'upgrader_pre_install', array( $this, 'upgrader_pre_install' ), 0, 2 );
67
-
68
- register_uninstall_hook( THEME_MY_LOGIN_PATH . '/theme-my-login.php', array( 'Theme_My_Login_Admin', 'uninstall' ) );
69
- }
70
-
71
- /**
72
- * Builds plugin admin menu and pages
73
  *
74
- * @since 6.0
75
- * @access public
76
  */
77
- public function admin_menu() {
78
- add_menu_page(
79
- __( 'Theme My Login Settings', 'theme-my-login' ),
80
- __( 'TML', 'theme-my-login' ),
81
- 'manage_options',
82
- 'theme_my_login',
83
- array( 'Theme_My_Login_Admin', 'settings_page' )
84
- );
85
-
86
- add_submenu_page(
87
- 'theme_my_login',
88
- __( 'General', 'theme-my-login' ),
89
- __( 'General', 'theme-my-login' ),
90
- 'manage_options',
91
- 'theme_my_login',
92
- array( 'Theme_My_Login_Admin', 'settings_page' )
93
- );
94
  }
95
 
96
  /**
97
- * Registers TML settings
98
  *
99
- * This is used because register_setting() isn't available until the "admin_init" hook.
100
  *
101
- * @since 6.0
102
- * @access public
103
- */
104
- public function admin_init() {
105
-
106
- // Register setting
107
- register_setting( 'theme_my_login', 'theme_my_login', array( $this, 'save_settings' ) );
108
-
109
- // Install/Upgrade
110
- if ( version_compare( $this->get_option( 'version', 0 ), Theme_My_Login::VERSION, '<' ) )
111
- $this->install();
112
-
113
- // Add sections
114
- add_settings_section( 'general', __( 'General', 'theme-my-login' ), '__return_false', $this->options_key );
115
- add_settings_section( 'modules', __( 'Modules', 'theme-my-login' ), '__return_false', $this->options_key );
116
- add_settings_section( 'update', __( 'Update', 'theme-my-login' ), array( $this, 'settings_section_update' ), $this->options_key );
117
-
118
- // Add fields
119
- add_settings_field( 'enable_css', __( 'Stylesheet', 'theme-my-login' ), array( $this, 'settings_field_enable_css' ), $this->options_key, 'general' );
120
- add_settings_field( 'login_type', __( 'Login Type', 'theme-my-login' ), array( $this, 'settings_field_login_type' ), $this->options_key, 'general' );
121
- add_settings_field( 'modules', __( 'Modules', 'theme-my-login' ), array( $this, 'settings_field_modules' ), $this->options_key, 'modules' );
122
- add_settings_field( 'update', __( 'Update', 'theme-my-login' ), array( $this, 'settings_field_update' ), $this->options_key, 'update' );
123
- }
124
-
125
- /**
126
- * Enqueues TML scripts
127
  *
128
- * @since 6.3.11
129
- * @access public
 
 
 
 
 
 
 
130
  */
131
- public function admin_enqueue_scripts() {
132
- wp_enqueue_script( 'theme-my-login-admin', plugins_url( 'js/theme-my-login-admin.js', __FILE__ ), array( 'jquery' ), Theme_My_Login::VERSION, true );
133
- wp_localize_script( 'theme-my-login-admin', 'tmlAdmin', array(
134
- 'interim_login_url' => site_url( 'wp-login.php?interim-login=1', 'login' )
 
 
 
 
135
  ) );
136
- }
137
 
138
- /**
139
- * Print admin notices.
140
- *
141
- * @since 6.4.5
142
- *
143
- * @return [type] [description]
144
- */
145
- public function admin_notices() {
146
- $dismissed_notices = $this->get_option( 'dismissed_notices', array() );
147
-
148
- if ( ! current_user_can( 'manage_options' ) ) {
149
  return;
150
  }
151
 
152
- if ( ! in_array( '7', $dismissed_notices ) ) {
153
- ?>
154
-
155
- <div class="notice notice-info tml-notice is-dismissible" data-notice="7">
156
- <p>
157
- <?php _e( '<strong>Heads up!</strong> Theme My Login 7 is right around the corner and some major changes are coming!', 'theme-my-login' ); ?>
158
- <br /><br />
159
- <?php _e( 'Most notably, all of the previously included modules (with the exception of Custom Passwords, which has been merged into the core plugin) have been removed.', 'theme-my-login' ); ?>
160
- <?php _e( 'Instead, all of the legacy modules (now called "Extensions"), with many more to come, can now be purchased at our <a href="https://thememylogin.com/extensions">extensions store</a>.', 'theme-my-login' ); ?>
161
- <br /><br />
162
- <?php _e( "It's not all bad news though! As a legacy user, we're offering you a discount for a limited time. Use discount code <strong>SAVINGFACE</strong> at checkout in order to receive <strong>20% off</strong> of your purchase!", 'theme-my-login' ); ?>
163
- <br /><br />
164
- <a class="button button-primary" href="https://thememylogin.com/extensions" target="_blank"><?php _e( 'Take Me To The Store', 'theme-my-login' ); ?></a>
165
- </p>
166
- </div>
167
-
168
- <?php
169
- }
170
- }
171
-
172
- /**
173
- * Handle saving of notice dismissals.
174
- *
175
- * @since 6.4.15
176
- */
177
- public function ajax_dismiss_notice() {
178
- if ( empty( $_POST['notice'] ) ) {
179
- return;
180
  }
181
 
182
- $dismissed_notices = $this->get_option( 'dismissed_notices', array() );
183
- $dismissed_notices[] = sanitize_key( $_POST['notice'] );
184
-
185
- $this->set_option( 'dismissed_notices', $dismissed_notices );
186
- $this->save_options();
187
-
188
- wp_send_json_success();
189
- }
190
 
191
- /**
192
- * Adds the TML Action meta box.
193
- *
194
- * @since 6.4.13
195
- */
196
- public function add_meta_boxes() {
197
- add_meta_box(
198
- 'tml_action',
199
- __( 'Theme My Login Action', 'theme-my-login' ),
200
- array( $this, 'action_meta_box' ),
201
- 'page',
202
- 'side'
203
- );
204
  }
205
 
206
  /**
207
- * Renders the TML Action meta box.
208
  *
209
- * @since 6.4.13
210
  *
211
- * @param WP_Post $post The post object.
 
212
  */
213
- public function action_meta_box( $post ) {
214
- $page_action = get_post_meta( $post->ID, '_tml_action', true );
215
- ?>
216
-
217
- <select name="tml_action" id="tml_action">
218
- <option value=""></option>
219
- <?php foreach ( Theme_My_Login::default_pages() as $action => $label ) : ?>
220
- <option value="<?php echo esc_attr( $action ); ?>"<?php selected( $action, $page_action ); ?>><?php echo esc_html( $label ); ?></option>
221
- <?php endforeach; ?>
222
- </select>
223
-
224
- <?php
225
  }
226
 
227
  /**
228
- * Saves the TML Action meta box.
229
  *
230
- * @since 6.4.13
231
  *
232
- * @param int $post_id The post ID.
 
233
  */
234
- public function save_action_meta_box( $post_id ) {
235
- if ( 'page' != get_post_type( $post_id ) ) {
236
- return;
237
- }
238
-
239
- if ( isset( $_POST['tml_action'] ) ) {
240
- $tml_action = sanitize_key( $_POST['tml_action'] );
241
- if ( ! empty( $_POST['tml_action'] ) ) {
242
- update_post_meta( $post_id, '_tml_action', $tml_action );
243
- } else {
244
- if ( false !== get_post_meta( $post_id, '_tml_action', true ) ) {
245
- delete_post_meta( $post_id, '_tml_action' );
246
- }
247
- }
248
  }
249
  }
250
 
251
- /**
252
- * Renders the settings page
253
- *
254
- * @since 6.0
255
- * @access public
256
- */
257
- public static function settings_page( $args = '' ) {
258
- extract( wp_parse_args( $args, array(
259
- 'title' => __( 'Theme My Login Settings', 'theme-my-login' ),
260
- 'options_key' => 'theme_my_login'
261
- ) ) );
262
- ?>
263
- <div id="<?php echo $options_key; ?>" class="wrap">
264
- <h2><?php echo esc_html( $title ); ?></h2>
265
- <?php settings_errors(); ?>
266
-
267
- <form method="post" action="options.php">
268
- <?php
269
- settings_fields( $options_key );
270
- do_settings_sections( $options_key );
271
- submit_button();
272
- ?>
273
- </form>
274
- </div>
275
- <?php
276
- }
277
 
278
  /**
279
- * Renders Stylesheet settings field
280
  *
281
- * @since 6.3
282
- * @access public
283
  */
284
- public function settings_field_enable_css() {
285
- ?>
286
- <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' ) ); ?> />
287
- <label for="theme_my_login_enable_css"><?php _e( 'Enable "theme-my-login.css"', 'theme-my-login' ); ?></label>
288
- <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>
289
- <?php
 
 
 
290
  }
291
 
292
  /**
293
- * Renders Login Type settings field
294
  *
295
- * @since 6.3
296
- * @access public
297
  */
298
- public function settings_field_login_type() {
299
- ?>
300
-
301
- <ul>
302
-
303
- <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' ) ); ?> />
304
- <label for="theme_my_login_login_type_default"><?php _e( 'Username or E-mail', 'theme-my-login' ); ?></label></li>
305
-
306
- <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' ) ); ?> />
307
- <label for="theme_my_login_login_type_username"><?php _e( 'Username only', 'theme-my-login' ); ?></label></li>
308
-
309
- <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' ) ); ?> />
310
- <label for="theme_my_login_login_type_email"><?php _e( 'E-mail only', 'theme-my-login' ); ?></label></li>
311
-
312
- </ul>
313
-
314
- <p class="description"><?php _e( 'Allow users to login using their username and/or e-mail address.', 'theme-my-login' ); ?></p>
315
-
316
- <?php
317
- }
318
-
319
- /**
320
- * Renders Modules settings field
321
- *
322
- * @since 6.3
323
- * @access public
324
- */
325
- public function settings_field_modules() {
326
- foreach ( get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) ) as $path => $data ) {
327
- $id = sanitize_key( $data['Name'] );
328
- ?>
329
- <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' ) ) ); ?> />
330
- <label for="theme_my_login_active_modules_<?php echo $id; ?>"><?php printf( __( 'Enable %s', 'theme-my-login' ), $data['Name'] ); ?></label><br />
331
- <?php if ( $data['Description'] ) : ?>
332
- <p class="description"><?php echo $data['Description']; ?></p>
333
- <?php endif;
334
- }
335
- }
336
 
337
  /**
338
- * Renders Update settings section.
339
  *
340
- * @since 6.4.16
341
  */
342
- public function settings_section_update() {
343
- ?>
344
-
345
- <p><?php echo implode( ' ', array(
346
- __( 'Please read the following carefully!', 'theme-my-login' ),
347
- __( 'Theme My Login version 7.0+ contains major changes that can possibly break some sites. In order to protect your site from potentially breaking, we are requiring you to opt-in to receive the update.', 'theme-my-login' ),
348
- __( 'So that we may help you understand some of these changes, we will go over them below.', 'theme-my-login' ),
349
- ) ); ?>
350
-
351
- <h3><?php _e( 'Modules will no longer be included with the plugin', 'theme-my-login' ); ?></h3>
352
-
353
- <p><?php echo implode( ' ', array(
354
- __( 'With the exception of Custom Passwords (merged into the core plugin) and Custom User Links (discontinued), all of the modules listed above are now available in <a href="https://thememylogin.com/extensions">our store</a>.', 'theme-my-login' ),
355
- __( 'If you update, you will need to purchase a license to use the new extensions.', 'theme-my-login' ),
356
- __( 'Most of these extensions have been completely rewritten and contain additional features not found in the 6.4.x modules.', 'theme-my-login' ),
357
- '<strong>' . __( 'If you are not using any of the above modules, this change will not affect you.', 'theme-my-login' ) . '</strong>',
358
- ) ); ?></p>
359
-
360
- <h3><?php _e( 'Templates will no longer be utilized by the plugin', 'theme-my-login' ); ?></h3>
361
-
362
- <p><?php echo implode( ' ', array(
363
- __( 'In order to simplify the way the plugin generates forms, templates are no longer used. Instead, the forms are generated procedurally in PHP code. This makes it much easier to add, edit and rearrange form fields and leads to less complexity.', 'theme-my-login' ),
364
- '<strong>' . __( 'If you are not using custom templates for any actions, this change will not affect you.', 'theme-my-login' ) . '</strong>',
365
- ) ); ?></p>
366
-
367
- <h3><?php _e( 'The plugin will no longer use WordPress pages to represent actions', 'theme-my-login' ); ?></h3>
368
-
369
- <p><?php echo implode( ' ', array(
370
- __( 'Instead of using "real" pages, they are generated "on-the-fly", that is, as needed, when the corresponding action is requested. This eliminates clutter and avoids the accidental deletion of pages that represent actions.', 'theme-my-login' ),
371
- '<strong>' . __( 'If you have not added anything to the pages that the plugin created, this change will not affect you.', 'theme-my-login' ) . '</strong>',
372
- ) ); ?></p>
373
-
374
- <?php
375
- }
376
-
377
- /**
378
- * Renders Update settings field.
379
- *
380
- * @since 6.4.16
381
- */
382
- public function settings_field_update() {
383
- ?>
384
-
385
- <p>
386
- <input name="theme_my_login[allow_update]" type="radio" id="theme_my_login_allow_update_on" value="1"<?php checked( (bool) $this->get_option( 'allow_update' ) ); ?> />
387
- <label for="theme_my_login_allow_update_on"><?php _e( 'I understand the possible consequences, but I want the latest features and wish to allow the update', 'theme-my-login' ); ?></label>
388
- </p>
389
-
390
- <p>
391
- <input name="theme_my_login[allow_update]" type="radio" id="theme_my_login_allow_update_off" value="0"<?php checked( ! $this->get_option( 'allow_update' ) ); ?> />
392
- <label for="theme_my_login_allow_update_off"><?php _e( 'I understand that I will no longer receive any new features but I would like to stay on the 6.4 branch anyway', 'theme-my-login' ); ?></label>
393
- </p>
394
-
395
- <?php
396
- }
397
-
398
- /**
399
- * Sanitizes TML settings
400
- *
401
- * This is the callback for register_setting()
402
- *
403
- * @since 6.0
404
- * @access public
405
- *
406
- * @param string|array $settings Settings passed in from filter
407
- * @return string|array Sanitized settings
408
- */
409
- public function save_settings( $settings ) {
410
- $settings['enable_css'] = ! empty( $settings['enable_css'] );
411
- $settings['login_type'] = in_array( $settings['login_type'], array( 'default', 'username', 'email' ) ) ? $settings['login_type'] : 'default';
412
- $settings['active_modules'] = isset( $settings['active_modules'] ) ? (array) $settings['active_modules'] : array();
413
- $settings['allow_update'] = ! empty( $settings['allow_update'] );
414
-
415
- // If we have modules to activate
416
- if ( $activate = array_diff( $settings['active_modules'], $this->get_option( 'active_modules', array() ) ) ) {
417
- foreach ( $activate as $module ) {
418
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
419
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
420
- do_action( 'tml_activate_' . $module );
421
- }
422
- }
423
-
424
- // If we have modules to deactivate
425
- if ( $deactivate = array_diff( $this->get_option( 'active_modules', array() ), $settings['active_modules'] ) ) {
426
- foreach ( $deactivate as $module ) {
427
- do_action( 'tml_deactivate_' . $module );
428
- }
429
- }
430
-
431
- $settings = wp_parse_args( $settings, $this->get_options() );
432
-
433
- return $settings;
434
- }
435
-
436
- /**
437
- * Give those who opt to stay on the 6.4 branch updates.
438
- *
439
- * @since 6.4.17
440
- *
441
- * @param object $transient The transient data.
442
- * @return object The transient data.
443
- */
444
- public function pre_set_site_transient_update_plugins( $transient = '' ) {
445
- $basename = 'theme-my-login/theme-my-login.php';
446
-
447
- if ( ! is_object( $transient ) ) {
448
- $transient = new stdClass;
449
- }
450
-
451
- if ( ! isset( $transient->response ) || ! isset( $transient->no_update ) ) {
452
- return $transient;
453
- }
454
-
455
- if ( is_array( $transient->response ) && isset( $transient->response[ $basename ] ) ) {
456
- $plugin_data = $transient->response[ $basename ];
457
- unset( $transient->response[ $basename ] );
458
- } elseif ( is_array( $transient->no_update ) && isset( $transient->no_update[ $basename ] ) ) {
459
- $plugin_data = $transient->no_update[ $basename ];
460
- unset( $transient->no_update[ $basename ] );
461
- } else {
462
- return $transient;
463
- }
464
-
465
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
466
-
467
- $plugin_info = plugins_api( 'plugin_information', array( 'slug' => 'theme-my-login' ) );
468
- if ( is_wp_error( $plugin_info ) ) {
469
- return $transient;
470
- }
471
-
472
- uksort( $plugin_info->versions, 'version_compare' );
473
-
474
- // Find the latest 6.4 version
475
- foreach ( array_reverse( $plugin_info->versions ) as $version => $file ) {
476
- if ( strpos( $version, '6.4' ) === 0 ) {
477
- $plugin_data->new_version = $version;
478
- $plugin_data->package = $file;
479
- break;
480
- }
481
- }
482
-
483
- // This is an update
484
- if ( version_compare( Theme_My_Login::VERSION, $plugin_data->new_version, '<' ) ) {
485
- $transient->response[ $basename ] = $plugin_data;
486
-
487
- // This is just fetching the plugin information
488
- } else {
489
- $transient->no_update[ $basename ] = $plugin_data;
490
- }
491
-
492
- $transient->last_checked = time();
493
-
494
- return $transient;
495
- }
496
-
497
- /**
498
- * Disable upgrading to 7.0+ unless explicitly allowed.
499
- *
500
- * @since 6.4.16
501
- *
502
- * @param bool|WP_Error $response Whether to allow the install or not.
503
- * @param array $args Extra arguments passed to the hook.
504
- * @return bool|WP_Error
505
- */
506
- public function upgrader_pre_install( $response, $args ) {
507
- // Bail if we're not upgrading a plugin
508
- if ( empty( $args['plugin'] ) ) {
509
- return $response;
510
- }
511
-
512
- $basename = plugin_basename( THEME_MY_LOGIN_PATH . '/theme-my-login.php' );
513
-
514
- // Bal if we're not upgrading TML
515
- if ( $basename != $args['plugin'] ) {
516
- return $response;
517
- }
518
-
519
- $plugins = get_site_transient( 'update_plugins' );
520
-
521
- // Bail if we're not upgrading to 7.0+
522
- if ( version_compare( $plugins->response[ $basename ]->new_version, '7.0', '<' ) ) {
523
- return $response;
524
- }
525
-
526
- // Bail if the update has been allowed
527
- if ( $this->get_option( 'allow_update' ) ) {
528
- return $response;
529
- }
530
-
531
- return new WP_Error( 'update_denied', sprintf(
532
- __( 'Theme My Login has not been updated because you have not allowed the update on the <a href="%s" target="_top">settings page</a>.', 'theme-my-login' ),
533
- admin_url( 'admin.php?page=theme_my_login' )
534
- ) );
535
- }
536
-
537
- /**
538
- * Installs TML
539
- *
540
- * @since 6.0
541
- * @access public
542
- */
543
- public function install() {
544
- global $wpdb;
545
-
546
- // Current version
547
- $version = $this->get_option( 'version', Theme_My_Login::VERSION );
548
-
549
- // Check if legacy page exists
550
- if ( $page_id = $this->get_option( 'page_id' ) ) {
551
- $page = get_post( $page_id );
552
- } else {
553
- $page = get_page_by_title( 'Login' );
554
- }
555
-
556
- // 4.4 upgrade
557
- if ( version_compare( $version, '4.4', '<' ) ) {
558
- remove_role( 'denied' );
559
- }
560
-
561
- // 6.0 upgrade
562
- if ( version_compare( $version, '6.0', '<' ) ) {
563
- // Replace shortcode
564
- if ( $page ) {
565
- $page->post_content = str_replace( '[theme-my-login-page]', '[theme-my-login]', $page->post_content );
566
- wp_update_post( $page );
567
- }
568
- }
569
-
570
- // 6.3 upgrade
571
- if ( version_compare( $version, '6.3.3', '<' ) ) {
572
- // Delete obsolete options
573
- $this->delete_option( 'page_id' );
574
- $this->delete_option( 'show_page' );
575
- $this->delete_option( 'initial_nag' );
576
- $this->delete_option( 'permalinks' );
577
- $this->delete_option( 'flush_rules' );
578
-
579
- // Move options to their own rows
580
- foreach ( $this->get_options() as $key => $value ) {
581
- if ( in_array( $key, array( 'active_modules' ) ) )
582
- continue;
583
-
584
- if ( ! is_array( $value ) )
585
- continue;
586
-
587
- update_option( "theme_my_login_{$key}", $value );
588
-
589
- $this->delete_option( $key );
590
- }
591
-
592
- // Maybe create login page?
593
- if ( $page ) {
594
- // Make sure the page is not in the trash
595
- if ( 'trash' == $page->post_status )
596
- wp_untrash_post( $page->ID );
597
-
598
- update_post_meta( $page->ID, '_tml_action', 'login' );
599
- }
600
- }
601
-
602
- // 6.3.7 upgrade
603
- if ( version_compare( $version, '6.3.7', '<' ) ) {
604
- // Convert TML pages to regular pages
605
- $wpdb->update( $wpdb->posts, array( 'post_type' => 'page' ), array( 'post_type' => 'tml_page' ) );
606
-
607
- // Get rid of stale rewrite rules
608
- flush_rewrite_rules( false );
609
- }
610
-
611
- // 6.4 upgrade
612
- if ( version_compare( $version, '6.4', '<' ) ) {
613
- // Convert e-mail login option
614
- if ( $this->get_option( 'email_login' ) )
615
- $this->set_option( 'login_type', 'both' );
616
- $this->delete_option( 'email_login' );
617
- }
618
-
619
- // 6.4.5 upgrade
620
- if ( version_compare( $version, '6.4.5', '<' ) ) {
621
- // Convert login type option
622
- $login_type = $this->get_option( 'login_type' );
623
- if ( 'both' == $login_type ) {
624
- $this->set_option( 'login_type', 'default' );
625
- } elseif ( 'default' == $login_type ) {
626
- $this->set_option( 'login_type', 'username' );
627
- }
628
- }
629
-
630
- // Setup default pages
631
- foreach ( Theme_My_Login::default_pages() as $action => $title ) {
632
- if ( ! $page_id = Theme_My_Login::get_page_id( $action ) ) {
633
- $page_id = wp_insert_post( array(
634
- 'post_title' => $title,
635
- 'post_name' => $action,
636
- 'post_status' => 'publish',
637
- 'post_type' => 'page',
638
- 'post_content' => '[theme-my-login]',
639
- 'comment_status' => 'closed',
640
- 'ping_status' => 'closed'
641
- ) );
642
- update_post_meta( $page_id, '_tml_action', $action );
643
- }
644
- }
645
-
646
- // Activate modules
647
- foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
648
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
649
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
650
- do_action( 'tml_activate_' . $module );
651
- }
652
-
653
- $this->set_option( 'version', Theme_My_Login::VERSION );
654
- $this->save_options();
655
- }
656
-
657
- /**
658
- * Wrapper for multisite uninstallation
659
- *
660
- * @since 6.1
661
- * @access public
662
- */
663
- public static function uninstall() {
664
- global $wpdb;
665
-
666
- if ( is_multisite() ) {
667
- if ( isset( $_GET['networkwide'] ) && ( $_GET['networkwide'] == 1 ) ) {
668
- $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
669
- foreach ( $blogids as $blog_id ) {
670
- switch_to_blog( $blog_id );
671
- self::_uninstall();
672
- }
673
- restore_current_blog();
674
- return;
675
- }
676
- }
677
- self::_uninstall();
678
- }
679
-
680
- /**
681
- * Uninstalls TML
682
- *
683
- * @since 6.0
684
- * @access protected
685
- */
686
- protected static function _uninstall() {
687
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
688
-
689
- // Run module uninstall hooks
690
- $modules = get_plugins( sprintf( '/%s/modules', plugin_basename( THEME_MY_LOGIN_PATH ) ) );
691
- foreach ( array_keys( $modules ) as $module ) {
692
- $module = plugin_basename( trim( $module ) );
693
-
694
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
695
- @include ( THEME_MY_LOGIN_PATH . '/modules/' . $module );
696
-
697
- do_action( 'tml_uninstall_' . $module );
698
- }
699
-
700
- // Get pages
701
- $pages = get_posts( array(
702
- 'post_type' => 'page',
703
- 'post_status' => 'any',
704
- 'meta_key' => '_tml_action',
705
- 'posts_per_page' => -1
706
- ) );
707
-
708
- // Delete pages
709
- foreach ( $pages as $page ) {
710
- wp_delete_post( $page->ID, true );
711
- }
712
-
713
- // Delete options
714
- delete_option( 'theme_my_login' );
715
- delete_option( 'widget_theme-my-login' );
716
- }
717
  }
718
- endif; // Class exists
1
  <?php
2
+
3
  /**
4
+ * Theme My Login Admin Class
5
  *
6
  * @package Theme_My_Login
7
+ * @subpackage Administration
8
  */
9
 
 
10
  /**
11
+ * Class used to implement the admin object.
12
  *
13
+ * @since 7.0
14
  */
15
+ final class Theme_My_Login_Admin {
 
 
 
 
 
 
 
 
16
 
17
  /**
18
+ * The admin instance.
19
  *
20
+ * @var Theme_My_Login
 
 
21
  */
22
+ private static $instance;
 
 
23
 
24
  /**
25
+ * The admin pages.
26
  *
27
+ * @var array
 
28
  */
29
+ protected $pages = array();
 
 
30
 
31
  /**
32
+ * Get the instance.
33
  *
34
+ * @since 7.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  *
36
+ * @return Theme_My_Login_Admin
 
37
  */
38
+ public static function get_instance() {
39
+ if ( null === self::$instance ) {
40
+ self::$instance = new self();
41
+ }
42
+ return self::$instance;
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  /**
46
+ * Add an admin page.
47
  *
48
+ * @since 7.0
49
  *
50
+ * @param array|Theme_My_Login_Extension $args {
51
+ * Optional. An array of arguments for adding an admin page.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  *
53
+ * @param string $page_title Required. The page title.
54
+ * @param string $menu_title Required. The menu title.
55
+ * @param string $menu_slug Required. The menu slug.
56
+ * @param string $capability The required capability.
57
+ * @param callable $function The function to be called.
58
+ * @param string $parent_slug The parent slug.
59
+ * }
60
+ * @return string The resulting page's hook_suffix or false if the user does
61
+ * not have the capability required.
62
  */
63
+ public function add_menu_item( $args = array() ) {
64
+ $args = wp_parse_args( $args, array(
65
+ 'page_title' => '',
66
+ 'menu_title' => '',
67
+ 'menu_slug' => '',
68
+ 'parent_slug' => 'theme-my-login',
69
+ 'capability' => 'manage_options',
70
+ 'function' => 'tml_admin_settings_page',
71
  ) );
 
72
 
73
+ if ( empty( $args['page_title'] ) || empty( $args['menu_title'] ) || empty( $args['menu_slug'] ) ) {
 
 
 
 
 
 
 
 
 
 
74
  return;
75
  }
76
 
77
+ if ( empty( $args['parent_slug'] ) ) {
78
+ $hook = add_menu_page(
79
+ $args['page_title'],
80
+ $args['menu_title'],
81
+ $args['capability'],
82
+ $args['menu_slug'],
83
+ $args['function'],
84
+ isset( $args['menu_icon'] ) ? $args['menu_icon'] : ''
85
+ );
86
+ } else {
87
+ $hook = add_submenu_page(
88
+ $args['parent_slug'],
89
+ $args['page_title'],
90
+ $args['menu_title'],
91
+ $args['capability'],
92
+ $args['menu_slug'],
93
+ $args['function']
94
+ );
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
+ $this->pages[ $args['menu_slug'] ] = $hook;
 
 
 
 
 
 
 
98
 
99
+ return $hook;
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
102
  /**
103
+ * Determine if a speficic plugin page is a TML page.
104
  *
105
+ * @since 7.0
106
  *
107
+ * @param string $page The page slug.
108
+ * @return bool True if the page is a TML admin page, false if not.
109
  */
110
+ public function has_page( $page ) {
111
+ return ! empty( $this->pages[ $page ] );
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  /**
115
+ * Get a page hook.
116
  *
117
+ * @since 7.0
118
  *
119
+ * @param string $page The plugin page.
120
+ * @return string The page hook.
121
  */
122
+ public function get_page_hook( $page = 'theme-my-login' ) {
123
+ if ( $this->has_page( $page ) ) {
124
+ return $this->pages[ $page ];
 
 
 
 
 
 
 
 
 
 
 
125
  }
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
  /**
130
+ * Construct the instance.
131
  *
132
+ * @since 7.0
 
133
  */
134
+ protected function __construct() {
135
+ /**
136
+ * Fires when TML Admin has been initialized.
137
+ *
138
+ * @since 7.0
139
+ *
140
+ * @param Theme_My_Login_Admin The TML Admin object.
141
+ */
142
+ do_action( 'tml_admin_init', $this );
143
  }
144
 
145
  /**
146
+ * Don't allow cloning.
147
  *
148
+ * @since 7.0
 
149
  */
150
+ private function __clone() {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
  /**
153
+ * Don't allow unserialization.
154
  *
155
+ * @since 7.0
156
  */
157
+ private function __wakeup() {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
 
admin/class-theme-my-login-walker-nav-menu-edit.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * TML Restrictions Nav Menu Edit Walker
5
+ *
6
+ * @package Theme_My_Login_Restrictions
7
+ * @subpackage Walker
8
+ */
9
+
10
+ class Theme_My_Login_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
11
+
12
+ /**
13
+ * Start the element output
14
+ *
15
+ * @since 7.0
16
+ *
17
+ * @param string $output The current output of the walker.
18
+ * @param object $item The menu item.
19
+ * @param int $depth The current walker depth.
20
+ * @param array $args An array of arguments for walking the tree.
21
+ * @param int $id The nav menu ID.
22
+ */
23
+ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
24
+ $item_output = '';
25
+
26
+ // Get the item content from the parent class
27
+ parent::start_el( $item_output, $item, $depth, $args, $id );
28
+
29
+ // Start an output buffer
30
+ ob_start();
31
+
32
+ /**
33
+ * Fires just before the move field of a nav menu item in the menu editor.
34
+ *
35
+ * @since unknown
36
+ *
37
+ * @param int $item_id The item ID.
38
+ * @param object $item The nav menu item.
39
+ * @param int $depth The current walker depth.
40
+ * @param array $args An array of arguments for walking the tree.
41
+ */
42
+ do_action( 'wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args );
43
+
44
+ // Get the contents of the output buffer
45
+ $custom_fields = ob_get_clean();
46
+
47
+ // Append the contents of the output buffer to the nav menu item and
48
+ // append that to the walker output
49
+ $output .= preg_replace( '/(?=<(fieldset|p)[^>]+class="[^"]*field-move)/',
50
+ $custom_fields,
51
+ $item_output
52
+ );
53
+ }
54
+ }
admin/extensions.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme MY Login Extensions Admin
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Administration
8
+ */
9
+
10
+ /**
11
+ * Get the extensions feed.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @param array $args {
16
+ * Optional. An array of arguments for fetching extensions from the server.
17
+ * }
18
+ * @return array|WP_Error The extensions array or WP_Error on failure.
19
+ */
20
+ function tml_admin_get_extensions_feed( $args = array() ) {
21
+ $args = wp_parse_args( $args, array(
22
+ 'number' => 12,
23
+ ) );
24
+
25
+ $url = add_query_arg( $args, THEME_MY_LOGIN_EXTENSIONS_API_URL );
26
+
27
+ $response = wp_remote_get( $url );
28
+ if ( is_wp_error( $response ) ) {
29
+ return $response;
30
+ }
31
+
32
+ $code = wp_remote_retrieve_response_code( $response );
33
+ $message = wp_remote_retrieve_response_message( $response );
34
+
35
+ if ( '200' != $code ) {
36
+ return new WP_Error( 'http_error_' . $code, $message );
37
+ }
38
+
39
+ $response = json_decode( wp_remote_retrieve_body( $response ) );
40
+
41
+ return $response->products;
42
+ }
43
+
44
+ /**
45
+ * Render the extensions page.
46
+ *
47
+ * @since 7.0
48
+ */
49
+ function tml_admin_extensions_page() {
50
+ global $title, $plugin_page;
51
+
52
+ $extensions = tml_admin_get_extensions_feed();
53
+ ?>
54
+
55
+ <div class="wrap">
56
+ <h1><?php echo esc_html( $title ) ?></h1>
57
+ <hr class="wp-header-end">
58
+
59
+ <?php if ( is_wp_error( $extensions ) ) : ?>
60
+
61
+ <h3><?php echo esc_html_e( 'Whoops! Looks like there was an error fetching extensions from the server. Please try again.', 'theme-my-login' ); ?></h3>
62
+ <p><?php echo esc_html( sprintf( __( 'Error: %s', 'theme-my-login' ), $extensions->get_error_message() ) ); ?></p>
63
+
64
+ <?php else : ?>
65
+
66
+ <div class="tml-extensions-wrap">
67
+ <?php foreach ( $extensions as $extension ) : ?>
68
+
69
+ <div class="tml-extension">
70
+ <div class="tml-extension-header">
71
+ <?php if ( ! empty( $extension->info->thumbnail ) ) : ?>
72
+ <a href="<?php echo esc_url( $extension->info->link ); ?>">
73
+ <img class="tml-extension-image" src="<?php echo esc_url( $extension->info->thumbnail ); ?>" />
74
+ </a>
75
+ <?php endif; ?>
76
+ </div>
77
+ <div class="tml-extension-body">
78
+ <h2 class="tml-extension-title"><?php echo esc_html( $extension->info->title ); ?></h2>
79
+
80
+ <?php if ( ! empty( $extension->info->excerpt ) ) : ?>
81
+ <p><?php echo esc_html( $extension->info->excerpt ); ?></p>
82
+ <?php endif; ?>
83
+
84
+ <a class="tml-extension-button" href="<?php echo esc_url( $extension->info->link ); ?>"><?php esc_html_e( 'Get This Extension', 'theme-my-login' ); ?></a>
85
+ </div>
86
+ </div>
87
+
88
+ <?php endforeach; ?>
89
+ </div>
90
+
91
+ <?php endif; ?>
92
+
93
+ <div class="tml-view-all-extensions-wrap">
94
+ <a class="tml-view-all-extensions-link" href="<?php echo THEME_MY_LOGIN_EXTENSIONS_URL; ?>"><?php esc_html_e( 'View All Extensions', 'theme-my-login' ); ?></a>
95
+ </div>
96
+
97
+ </div>
98
+
99
+ <?php
100
+ }
101
+
102
+ /**
103
+ * Render the extensions styles.
104
+ *
105
+ * @since 7.0
106
+ */
107
+ function tml_admin_extensions_styles() {
108
+ global $plugin_page;
109
+
110
+ if ( 'theme-my-login-extensions' != $plugin_page ) {
111
+ return;
112
+ }
113
+ ?>
114
+
115
+ <style type="text/css">
116
+ .tml-extensions-wrap {
117
+ margin: 0 -15px;
118
+ }
119
+
120
+ .tml-extensions-wrap:after {
121
+ content: "";
122
+ clear: both;
123
+ display: table;
124
+ }
125
+
126
+ .tml-extensions-wrap * {
127
+ box-sizing: border-box;
128
+ }
129
+
130
+ .tml-extension {
131
+ background-color: #fff;
132
+ border: 1px solid #ccc;
133
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
134
+ float: left;
135
+ margin: 15px;
136
+ }
137
+
138
+ .tml-extension-image {
139
+ height: auto;
140
+ max-width: 100%;
141
+ }
142
+
143
+ .tml-extension-body {
144
+ padding: 15px;
145
+ }
146
+
147
+ .tml-extension-title {
148
+ margin: 0 0 15px;
149
+ padding: 0;
150
+ }
151
+
152
+ .tml-extension-button {
153
+ background-color: #8d50c3;
154
+ color: #fff;
155
+ display: block;
156
+ font-size: 1.1em;
157
+ padding: 10px;
158
+ text-align: center;
159
+ text-decoration: none;
160
+ }
161
+
162
+ .tml-extension-button:hover {
163
+ color: #fff;
164
+ background-color: #7a3cb0;
165
+ }
166
+
167
+ .tml-extension-button:active,
168
+ .tml-extension-button:focus {
169
+ box-shadow: 0 0 0 0.2em rgba(141, 80, 195, 0.5);
170
+ color: #fff;
171
+ }
172
+
173
+ .tml-view-all-extensions-wrap {
174
+ padding: 15px 0;
175
+ text-align: center;
176
+ }
177
+
178
+ .tml-view-all-extensions-link {
179
+ display: inline-block;
180
+ font-size: 1.5em;
181
+ text-decoration: none;
182
+ }
183
+
184
+ @media (min-width: 576px) {
185
+ .tml-extension {
186
+ width: 40%;
187
+ }
188
+ }
189
+
190
+ @media (min-width: 783px) {
191
+ .tml-extension {
192
+ width: 30%;
193
+ }
194
+ }
195
+ </style>
196
+
197
+ <?php
198
+ }
199
+
200
+ /**
201
+ * Handle extension license activation and deactivation.
202
+ *
203
+ * @since 7.0
204
+ */
205
+ function tml_admin_handle_extension_licenses() {
206
+
207
+ if ( ! tml_is_post_request() ) {
208
+ return;
209
+ }
210
+
211
+ // Loop through all extensions
212
+ foreach ( tml_get_extensions() as $extension ) {
213
+
214
+ // Handle license activations
215
+ if ( isset( $_POST['tml_activate_license'][ $extension->get_name() ] ) ) {
216
+ if ( $response = tml_activate_extension_license( $extension ) ) {
217
+ if ( is_wp_error( $response ) ) {
218
+ $extension->set_license_status();
219
+ add_settings_error( 'tml_activate_license',
220
+ $response->get_error_code(),
221
+ $response->get_error_message()
222
+ );
223
+ } else {
224
+ $extension->set_license_status( $response );
225
+ }
226
+ }
227
+ }
228
+
229
+ // Handle license deactivations
230
+ if ( isset( $_POST['tml_deactivate_license'][ $extension->get_name() ] ) ) {
231
+ if ( $response = tml_deactivate_extension_license( $extension ) ) {
232
+ if ( is_wp_error( $response ) ) {
233
+ add_settings_error( 'tml_deactivate_license',
234
+ $response->get_error_code(),
235
+ $response->get_error_message()
236
+ );
237
+ } else {
238
+ $extension->set_license_status();
239
+ }
240
+ }
241
+ }
242
+ }
243
+ }
admin/functions.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Admin Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Functions
8
+ */
9
+
10
+ /**
11
+ * Get the Theme My Login Admin instance.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @return Theme_My_Login_Admin
16
+ */
17
+ function theme_my_login_admin() {
18
+ return Theme_My_Login_Admin::get_instance();
19
+ }
20
+
21
+ /**
22
+ * Determine if the current page is a TML page.
23
+ *
24
+ * @since 7.0
25
+ *
26
+ * @param string $page The page name.
27
+ * @return boolean True if the current page is the specified page, false if not.
28
+ */
29
+ function tml_admin_is_plugin_page( $page = '' ) {
30
+ global $plugin_page;
31
+
32
+ if ( ! empty( $page ) ) {
33
+ return ( "theme-my-login-$page" == $plugin_page );
34
+ }
35
+
36
+ return ( strpos( $plugin_page, 'theme-my-login' ) === 0 );
37
+ }
38
+
39
+ /**
40
+ * Add an admin page.
41
+ *
42
+ * @since 7.0
43
+ *
44
+ * @see Theme_My_Login_Admin::add_menu_item()
45
+ *
46
+ * @param array|Theme_My_Login_Extension $args
47
+ */
48
+ function tml_admin_add_menu_item( $args = array() ) {
49
+ theme_my_login_admin()->add_menu_item( $args );
50
+ }
51
+
52
+ /**
53
+ * Register the admin menus.
54
+ *
55
+ * @since 7.0
56
+ */
57
+ function tml_admin_add_menu_items() {
58
+
59
+ // Bail if multisite and not in the network admin
60
+ if ( is_multisite() && ! is_network_admin() ) {
61
+ return;
62
+ }
63
+
64
+ $tml_admin = theme_my_login_admin();
65
+
66
+ // Add the main menu item
67
+ $tml_admin->add_menu_item( array(
68
+ 'page_title' => esc_html__( 'Theme My Login Settings', 'theme-my-login' ),
69
+ 'menu_title' => esc_html__( 'Theme My Login', 'theme-my-login' ),
70
+ 'menu_slug' => 'theme-my-login',
71
+ 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode(
72
+ file_get_contents( THEME_MY_LOGIN_PATH . 'admin/assets/images/logo.svg' )
73
+ ),
74
+ 'parent_slug' => false,
75
+ ) );
76
+
77
+ // Add the submenu item
78
+ $tml_admin->add_menu_item( array(
79
+ 'page_title' => esc_html__( 'Theme My Login Settings', 'theme-my-login' ),
80
+ 'menu_title' => esc_html__( 'General', 'theme-my-login' ),
81
+ 'menu_slug' => 'theme-my-login',
82
+ 'parent_slug' => 'theme-my-login',
83
+ ) );
84
+
85
+ $has_licenses = false;
86
+
87
+ // Add the extension menu items
88
+ foreach ( tml_get_extensions() as $extension ) {
89
+ $args = $extension->get_settings_page_args();
90
+ if ( ! empty( $args ) ) {
91
+ $tml_admin->add_menu_item( $args );
92
+ }
93
+ if ( $extension->get_license_key_option() ) {
94
+ $has_licenses = true;
95
+ }
96
+ }
97
+
98
+ if ( $has_licenses ) {
99
+ // Add the licenses menu item
100
+ $tml_admin->add_menu_item( array(
101
+ 'page_title' => esc_html__( 'Theme My Login Licenses', 'theme-my-login' ),
102
+ 'menu_title' => esc_html__( 'Licenses', 'theme-my-login' ),
103
+ 'menu_slug' => 'theme-my-login-licenses',
104
+ 'parent_slug' => 'theme-my-login',
105
+ ) );
106
+ add_settings_section( 'tml_settings_licenses', '', '__return_null', 'theme-my-login-licenses' );
107
+ }
108
+
109
+ // Add the extensions menu item
110
+ $tml_admin->add_menu_item( array(
111
+ 'page_title' => esc_html__( 'Theme My Login Extensions', 'theme-my-login' ),
112
+ 'menu_title' => esc_html__( 'Extensions', 'theme-my-login' ),
113
+ 'menu_slug' => 'theme-my-login-extensions',
114
+ 'parent_slug' => 'theme-my-login',
115
+ 'function' => 'tml_admin_extensions_page',
116
+ ) );
117
+ }
118
+
119
+ /**
120
+ * Enqueue admin scripts.
121
+ *
122
+ * @since 7.0
123
+ */
124
+ function tml_admin_enqueue_scripts() {
125
+ if ( ! tml_admin_is_plugin_page() ) {
126
+ return;
127
+ }
128
+
129
+ $suffix = SCRIPT_DEBUG ? '' : '.min';
130
+
131
+ wp_enqueue_script( 'theme-my-login-admin', THEME_MY_LOGIN_URL . "admin/assets/scripts/theme-my-login-admin$suffix.js", array( 'jquery', 'postbox' ), THEME_MY_LOGIN_VERSION );
132
+ }
133
+
134
+ /**
135
+ * Display admin notices.
136
+ *
137
+ * @since 7.0
138
+ */
139
+ function tml_admin_notices() {
140
+ global $plugin_page;
141
+
142
+ $is_pre_7 = ( $previous_version = tml_get_previous_version() ) && version_compare( $previous_version, '7.0', '<' );
143
+
144
+ if ( 'theme-my-login-extensions' == $plugin_page && $is_pre_7 ) {
145
+ ?>
146
+
147
+ <div class="notice notice-info">
148
+ <p><?php _e( 'As a token of our gratitude, we would like to offer your an incentive for upgrading Theme My Login to version 7.0. For a limited time, we are offering a <strong>20% discount</strong> when you use the code <strong>SAVINGFACE</strong> at checkout. Act now - this offer won\'t last!', 'theme-my-login' ); ?></p>
149
+ </div>
150
+
151
+ <?php
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Update TML.
157
+ *
158
+ * @since 7.0
159
+ */
160
+ function tml_admin_update() {
161
+ $version = tml_get_installed_version();
162
+
163
+ // Bail if no update needed
164
+ if ( version_compare( $version, THEME_MY_LOGIN_VERSION, '>=' ) ) {
165
+ return;
166
+ }
167
+
168
+ // 7.0 upgrade
169
+ if ( version_compare( $version, '7.0', '<' ) ) {
170
+ // Initial migration
171
+ $options = get_option( 'theme_my_login', array() );
172
+ if ( ! empty( $options ) ) {
173
+ if ( ! empty( $options['login_type'] ) ) {
174
+ update_site_option( 'tml_login_type', $options['login_type'] );
175
+ }
176
+ delete_option( 'theme_my_login' );
177
+ }
178
+ }
179
+
180
+ // Set the first time install date
181
+ if ( ! get_site_option( '_tml_installed_at' ) ) {
182
+ update_site_option( '_tml_installed_at', current_time( 'timestamp' ) );
183
+ }
184
+
185
+ // Set the update date
186
+ update_site_option( '_tml_updated_at', current_time( 'timestamp' ) );
187
+
188
+ // Store the previous version
189
+ if ( ! empty( $version ) ) {
190
+ update_site_option( '_tml_previous_version', $version );
191
+ }
192
+
193
+ // Bump the installed version
194
+ update_site_option( '_tml_version', THEME_MY_LOGIN_VERSION );
195
+
196
+ // Force permalinks to be regenerated
197
+ tml_flush_rewrite_rules();
198
+ }
199
+
200
+ /**
201
+ * Sanitize a slug.
202
+ *
203
+ * @since 7.0
204
+ *
205
+ * @param string $slug The slug.
206
+ * @return string The slug.
207
+ */
208
+ function tml_sanitize_slug( $slug ) {
209
+ if ( ! empty( $slug ) ) {
210
+ $slug = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $slug ) );
211
+ $slug = trim( preg_replace( '|^/index\.php/|', '', $slug ), '/' );
212
+ }
213
+ return $slug;
214
+ }
215
+
216
+ /**
217
+ * Add the nav menu meta box.
218
+ *
219
+ * @since 7.0
220
+ */
221
+ function tml_admin_add_nav_menu_meta_box() {
222
+ add_meta_box( 'tml_actions',
223
+ __( 'Theme My Login Actions', 'theme-my-login' ),
224
+ 'tml_admin_nav_menu_meta_box',
225
+ 'nav-menus',
226
+ 'side',
227
+ 'default'
228
+ );
229
+ }
230
+
231
+ /**
232
+ * Render the nav menu meta box.
233
+ *
234
+ * @since 7.0
235
+ */
236
+ function tml_admin_nav_menu_meta_box() {
237
+ global $_nav_menu_placeholder, $nav_menu_selected_id;
238
+
239
+ $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
240
+
241
+ $actions = wp_list_filter( tml_get_actions(), array(
242
+ 'show_in_nav_menus' => true
243
+ ) );
244
+ ?>
245
+
246
+ <div id="tml-action" class="posttypediv">
247
+ <div class="tabs-panel tabs-panel-active">
248
+ <ul class="categorychecklist form-no-clear">
249
+ <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $actions ), 0, (object) array(
250
+ 'walker' => new Walker_Nav_Menu_Checklist(),
251
+ ) ); ?>
252
+ </ul>
253
+ </div>
254
+ <p class="button-controls wp-clearfix">
255
+ <span class="add-to-menu">
256
+ <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-tml-action-menu-item" id="submit-tml-action" />
257
+ <span class="spinner"></span>
258
+ </span>
259
+ </p>
260
+ </div>
261
+
262
+ <?php
263
+ }
264
+
265
+ /**
266
+ * Filter the edit nav menu walker.
267
+ *
268
+ * @since 7.0
269
+ *
270
+ * @param string $walker The name of the walker class.
271
+ * @return string The name of the walker class.
272
+ */
273
+ function tml_admin_filter_edit_nav_menu_walker( $walker ) {
274
+ $walker = 'Theme_My_Login_Walker_Nav_Menu_Edit';
275
+ if ( ! class_exists( $walker ) ) {
276
+ require_once THEME_MY_LOGIN_PATH . 'admin/class-theme-my-login-walker-nav-menu-edit.php';
277
+ }
278
+ return $walker;
279
+ }
admin/hooks.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Admin Hooks
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Administration
8
+ */
9
+
10
+ // General
11
+ add_action( 'admin_enqueue_scripts', 'tml_admin_enqueue_scripts' );
12
+ add_action( 'admin_notices', 'tml_admin_notices' );
13
+
14
+ // Extensions
15
+ add_action( 'admin_init', 'tml_admin_handle_extension_licenses' );
16
+ add_action( 'admin_print_styles', 'tml_admin_extensions_styles' );
17
+
18
+ // Settings
19
+ if ( is_multisite() ) {
20
+ add_action( 'network_admin_menu', 'tml_admin_add_menu_items' );
21
+ add_action( 'admin_init', 'tml_admin_register_settings' );
22
+ add_action( 'admin_init', 'tml_admin_save_ms_settings' );
23
+ } else {
24
+ add_action( 'admin_menu', 'tml_admin_add_menu_items' );
25
+ add_action( 'admin_init', 'tml_admin_register_settings' );
26
+ }
27
+
28
+ // Update
29
+ add_action( 'admin_init', 'tml_admin_update' );
30
+
31
+ // Nav menus
32
+ add_action( 'admin_head-nav-menus.php', 'tml_admin_add_nav_menu_meta_box', 10 );
33
+ add_filter( 'wp_edit_nav_menu_walker', 'tml_admin_filter_edit_nav_menu_walker', 99 );
admin/js/theme-my-login-admin.js DELETED
@@ -1,20 +0,0 @@
1
- (function($) {
2
- var form = $('#wp-auth-check-form');
3
-
4
- if (form.length) {
5
- form.data('src', tmlAdmin.interim_login_url);
6
- }
7
-
8
- $(initNotices);
9
-
10
- function initNotices() {
11
- $('.tml-notice').on('click', '.notice-dismiss', function(e) {
12
- var notice = $(e.delegateTarget);
13
-
14
- $.post(ajaxurl, {
15
- action: 'tml-dismiss-notice',
16
- notice: notice.data('notice')
17
- });
18
- });
19
- }
20
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/settings.php ADDED
@@ -0,0 +1,544 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Admin Settings
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Administration
8
+ */
9
+
10
+ /**
11
+ * Register the settings.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ function tml_admin_register_settings() {
16
+
17
+ $settings = array(
18
+ 'theme-my-login' =>array(
19
+ 'sections' => tml_admin_get_settings_sections(),
20
+ 'fields' => tml_admin_get_settings_fields(),
21
+ ),
22
+ );
23
+
24
+ foreach ( tml_get_extensions() as $extension ) {
25
+ $settings[ $extension->get_name() ] = array(
26
+ 'sections' => (array) $extension->get_settings_sections(),
27
+ 'fields' => (array) $extension->get_settings_fields(),
28
+ );
29
+
30
+ if ( $extension->get_license_key_option() ) {
31
+ add_settings_field(
32
+ $extension->get_license_key_option(),
33
+ $extension->get_title(),
34
+ 'tml_admin_setting_callback_license_key_field',
35
+ 'theme-my-login-licenses',
36
+ 'tml_settings_licenses',
37
+ array(
38
+ 'extension' => $extension,
39
+ 'label_for' => $extension->get_license_key_option(),
40
+ )
41
+ );
42
+ register_setting(
43
+ 'theme-my-login-licenses',
44
+ $extension->get_license_key_option(),
45
+ 'sanitize_text_field'
46
+ );
47
+ }
48
+ }
49
+
50
+ // Loop through settings
51
+ foreach ( $settings as $group ) {
52
+
53
+ // Loop through sections
54
+ foreach ( $group['sections'] as $section_id => $section ) {
55
+
56
+ // Only add section and fields if section has fields
57
+ if ( empty( $group['fields'][ $section_id ] ) ) {
58
+ continue;
59
+ }
60
+
61
+ $page = ! empty( $section['page'] ) ? $section['page'] : 'theme-my-login';
62
+
63
+ // Add the section
64
+ add_settings_section( $section_id, $section['title'], $section['callback'], $page );
65
+
66
+ // Loop through fields for this section
67
+ foreach ( $group['fields'][ $section_id ] as $field_id => $field ) {
68
+
69
+ // Add the field
70
+ if ( ! empty( $field['callback'] ) && ! empty( $field['title'] ) ) {
71
+ add_settings_field( $field_id, $field['title'], $field['callback'], $page, $section_id, $field['args'] );
72
+ }
73
+
74
+ // Register the setting
75
+ register_setting( $page, $field_id, $field['sanitize_callback'] );
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Get the settings sections.
83
+ *
84
+ * @since 7.0
85
+ *
86
+ * @return array The settings sections.
87
+ */
88
+ function tml_admin_get_settings_sections() {
89
+ return (array) apply_filters( 'tml_admin_get_settings_sections', array(
90
+ 'tml_settings_login' => array(
91
+ 'title' => __( 'Log In' ),
92
+ 'callback' => '__return_null',
93
+ 'page' => 'theme-my-login',
94
+ ),
95
+ 'tml_settings_registration' => array(
96
+ 'title' => __( 'Registration', 'theme-my-login' ),
97
+ 'callback' => '__return_null',
98
+ 'page' => 'theme-my-login',
99
+ ),
100
+ 'tml_settings_slugs' => array(
101
+ 'title' => __( 'Slugs', 'theme-my-login' ),
102
+ 'callback' => '__return_null',
103
+ 'page' => 'theme-my-login',
104
+ ),
105
+ ) );
106
+ }
107
+
108
+ /**
109
+ * Get the settings fields.
110
+ *
111
+ * @since 7.0
112
+ *
113
+ * @return array The settings fields.
114
+ */
115
+ function tml_admin_get_settings_fields() {
116
+ return (array) apply_filters( 'tml_admin_get_settings_fields', array(
117
+ // Login
118
+ 'tml_settings_login' => array(
119
+ // Login type
120
+ 'tml_login_type' => array(
121
+ 'title' => __( 'Login Type', 'theme-my-login' ),
122
+ 'callback' => 'tml_admin_setting_callback_radio_group_field',
123
+ 'sanitize_callback' => 'sanitize_text_field',
124
+ 'args' => array(
125
+ 'label_for' => 'tml_login_type',
126
+ 'legend' => __( 'Login Type', 'theme-my-login' ),
127
+ 'options' => array(
128
+ 'default' => __( 'Default', 'theme-my-login' ),
129
+ 'username' => __( 'Username only', 'theme-my-login' ),
130
+ 'email' => __( 'Email only', 'theme-my-login' ),
131
+ ),
132
+ 'checked' => get_site_option( 'tml_login_type', 'default' ),
133
+ ),
134
+ ),
135
+ ),
136
+ // Registration
137
+ 'tml_settings_registration' => array(
138
+ // Registration type
139
+ 'tml_registration_type' => array(
140
+ 'title' => __( 'Registration Type', 'theme-my-login' ),
141
+ 'callback' => 'tml_admin_setting_callback_radio_group_field',
142
+ 'sanitize_callback' => 'sanitize_text_field',
143
+ 'args' => array(
144
+ 'label_for' => 'tml_registration_type',
145
+ 'legend' => __( 'Registration Type', 'theme-my-login' ),
146
+ 'options' => array(
147
+ 'default' => __( 'Default', 'theme-my-login' ),
148
+ 'email' => __( 'Email only', 'theme-my-login' ),
149
+ ),
150
+ 'checked' => get_site_option( 'tml_registration_type', 'default' ),
151
+ ),
152
+ ),
153
+ // User passwords
154
+ 'tml_user_passwords' => array(
155
+ 'title' => __( 'Passwords', 'theme-my-login' ),
156
+ 'callback' => 'tml_admin_setting_callback_checkbox_field',
157
+ 'sanitize_callback' => 'sanitize_text_field',
158
+ 'args' => array(
159
+ 'label_for' => 'tml_user_passwords',
160
+ 'label' => __( 'Allow users to set their own password', 'theme-my-login' ),
161
+ 'value' => '1',
162
+ 'checked' => get_site_option( 'tml_user_passwords' ),
163
+ ),
164
+ ),
165
+ // Auto-login
166
+ 'tml_auto_login' => array(
167
+ 'title' => __( 'Auto-Login', 'theme-my-login' ),
168
+ 'callback' => 'tml_admin_setting_callback_checkbox_field',
169
+ 'sanitize_callback' => 'sanitize_text_field',
170
+ 'args' => array(
171
+ 'label_for' => 'tml_auto_login',
172
+ 'label' => __( 'Automatically log in users after registration', 'theme-my-login' ),
173
+ 'value' => '1',
174
+ 'checked' => get_site_option( 'tml_auto_login' ),
175
+ ),
176
+ ),
177
+ ),
178
+ // Slugs
179
+ 'tml_settings_slugs' => array(
180
+ // Login
181
+ 'tml_login_slug' => array(
182
+ 'title' => __( 'Log In' ),
183
+ 'callback' => 'tml_admin_setting_callback_input_field',
184
+ 'sanitize_callback' => 'sanitize_text_field',
185
+ 'args' => array(
186
+ 'label_for' => 'tml_login_slug',
187
+ 'value' => get_site_option( 'tml_login_slug', 'login' ),
188
+ 'input_class' => 'regular-text code',
189
+ ),
190
+ ),
191
+ // Logout
192
+ 'tml_logout_slug' => array(
193
+ 'title' => __( 'Log Out' ),
194
+ 'callback' => 'tml_admin_setting_callback_input_field',
195
+ 'sanitize_callback' => 'tml_sanitize_slug',
196
+ 'args' => array(
197
+ 'label_for' => 'tml_logout_slug',
198
+ 'value' => get_site_option( 'tml_logout_slug', 'logout' ),
199
+ 'input_class' => 'regular-text code',
200
+ ),
201
+ ),
202
+ // Register
203
+ 'tml_register_slug' => array(
204
+ 'title' => __( 'Register' ),
205
+ 'callback' => 'tml_admin_setting_callback_input_field',
206
+ 'sanitize_callback' => 'tml_sanitize_slug',
207
+ 'args' => array(
208
+ 'label_for' => 'tml_register_slug',
209
+ 'value' => get_site_option( 'tml_register_slug', 'register' ),
210
+ 'input_class' => 'regular-text code',
211
+ ),
212
+ ),
213
+ // Lost password
214
+ 'tml_lostpassword_slug' => array(
215
+ 'title' => __( 'Lost Password' ),
216
+ 'callback' => 'tml_admin_setting_callback_input_field',
217
+ 'sanitize_callback' => 'tml_sanitize_slug',
218
+ 'args' => array(
219
+ 'label_for' => 'tml_lostpassword_slug',
220
+ 'value' => get_site_option( 'tml_lostpassword_slug', 'lostpassword' ),
221
+ 'input_class' => 'regular-text code',
222
+ ),
223
+ ),
224
+ // Reset password
225
+ 'tml_resetpass_slug' => array(
226
+ 'title' => __( 'Reset Password' ),
227
+ 'callback' => 'tml_admin_setting_callback_input_field',
228
+ 'sanitize_callback' => 'tml_sanitize_slug',
229
+ 'args' => array(
230
+ 'label_for' => 'tml_resetpass_slug',
231
+ 'value' => get_site_option( 'tml_resetpass_slug', 'resetpass' ),
232
+ 'input_class' => 'regular-text code',
233
+ ),
234
+ ),
235
+ ),
236
+ ) );
237
+ }
238
+
239
+ /**
240
+ * Render a text setting field.
241
+ *
242
+ * @since 7.0
243
+ */
244
+ function tml_admin_setting_callback_input_field( $args ) {
245
+ $args = wp_parse_args( $args, array(
246
+ 'label_for' => '',
247
+ 'value' => '',
248
+ 'description' => '',
249
+ 'input_type' => 'text',
250
+ 'input_class' => 'regular-text',
251
+ ) );
252
+ ?>
253
+
254
+ <input type="<?php echo esc_attr( $args['input_type'] ); ?>" name="<?php echo esc_attr( $args['label_for'] ); ?>" id="<?php echo esc_attr( $args['label_for'] ); ?>" value="<?php echo esc_attr( $args['value'] ); ?>" class="<?php echo esc_attr( $args['input_class'] ); ?>" />
255
+
256
+ <?php if ( ! empty( $args['description'] ) ) : ?>
257
+ <p class="description"><?php echo $args['description']; ?></p>
258
+ <?php endif; ?>
259
+
260
+ <?php
261
+ }
262
+
263
+ /**
264
+ * Render a checkbox setting field.
265
+ *
266
+ * @since 7.0
267
+ */
268
+ function tml_admin_setting_callback_checkbox_field( $args ) {
269
+ $args = wp_parse_args( $args, array(
270
+ 'label_for' => '',
271
+ 'label' => '',
272
+ 'value' => '1',
273
+ 'checked' => '',
274
+ 'description' => '',
275
+ ) );
276
+ ?>
277
+
278
+ <input type="checkbox" name="<?php echo esc_attr( $args['label_for'] ); ?>" id="<?php echo esc_attr( $args['label_for'] ); ?>" value="<?php echo $args['value']; ?>" <?php checked( ! empty( $args['checked'] ) ); ?> /> <label for="<?php echo esc_attr( $args['label_for'] ); ?>"><?php echo esc_html( $args['label'] ); ?></label>
279
+
280
+ <?php if ( ! empty( $args['description'] ) ) : ?>
281
+ <p class="description"><?php echo $args['description']; ?></p>
282
+ <?php endif; ?>
283
+
284
+ <?php
285
+ }
286
+
287
+ /**
288
+ * Render a radio group setting field.
289
+ *
290
+ * @since 7.0
291
+ *
292
+ * @param array $args {
293
+ * Optional. An array of arguments.
294
+ * }
295
+ */
296
+ function tml_admin_setting_callback_checkbox_group_field( $args ) {
297
+ $args = wp_parse_args( $args, array(
298
+ 'legend' => '',
299
+ 'options' => array(),
300
+ 'description' => '',
301
+ ) );
302
+
303
+ $options = array();
304
+ foreach ( (array) $args['options'] as $option_name => $option ) {
305
+ $options[] = sprintf(
306
+ '<label><input type="checkbox" name="%1$s" value="%2$s"%3$s> %4$s</label>',
307
+ esc_attr( $option_name ),
308
+ esc_attr( $option['value'] ),
309
+ checked( ! empty( $option['checked'] ), true, false ),
310
+ esc_html( $option['label'] )
311
+ );
312
+ }
313
+ ?>
314
+
315
+ <fieldset>
316
+ <legend class="screen-reader-text"><span><?php echo esc_html( $args['legend'] ); ?></span></legend>
317
+ <?php echo implode( "<br />\n", $options ); ?>
318
+ </fieldset>
319
+
320
+ <?php if ( ! empty( $args['description'] ) ) : ?>
321
+ <p class="description"><?php echo $args['description']; ?></p>
322
+ <?php endif; ?>
323
+
324
+ <?php
325
+ }
326
+
327
+ /**
328
+ * Render a dropdown setting field.
329
+ *
330
+ * @since 7.0
331
+ *
332
+ * @param array $args {
333
+ * Optional. An array of arguments.
334
+ * }
335
+ */
336
+ function tml_admin_setting_callback_dropdown_field( $args ) {
337
+ $args = wp_parse_args( $args, array(
338
+ 'label_for' => '',
339
+ 'options' => array(),
340
+ 'selected' => '',
341
+ 'description' => '',
342
+ ) );
343
+
344
+ $options = array();
345
+ foreach ( (array) $args['options'] as $value => $label ) {
346
+ $options[] = sprintf(
347
+ '<option value="%1$s"%2$s>%3$s</option>',
348
+ esc_attr( $value ),
349
+ selected( $args['selected'], $value, false ),
350
+ esc_html( $label )
351
+ );
352
+ }
353
+ ?>
354
+
355
+ <select name="<?php echo esc_attr( $args['label_for'] ); ?>" id="<?php echo esc_attr( $args['label_for'] ); ?>">
356
+ <?php echo implode( "<br />\n", $options ); ?>
357
+ </select>
358
+
359
+ <?php if ( ! empty( $args['description'] ) ) : ?>
360
+ <p class="description"><?php echo $args['description']; ?></p>
361
+ <?php endif; ?>
362
+
363
+ <?php
364
+ }
365
+
366
+ /**
367
+ * Render a radio group setting field.
368
+ *
369
+ * @since 7.0
370
+ *
371
+ * @param array $args {
372
+ * Optional. An array of arguments.
373
+ * }
374
+ */
375
+ function tml_admin_setting_callback_radio_group_field( $args ) {
376
+ $args = wp_parse_args( $args, array(
377
+ 'label_for' => '',
378
+ 'legend' => '',
379
+ 'options' => array(),
380
+ 'checked' => '',
381
+ 'description' => '',
382
+ ) );
383
+
384
+ $options = array();
385
+ foreach ( (array) $args['options'] as $value => $label ) {
386
+ $options[] = sprintf(
387
+ '<label><input type="radio" name="%1$s" value="%2$s"%3$s> %4$s</label>',
388
+ esc_html( $args['label_for'] ),
389
+ esc_attr( $value ),
390
+ checked( $args['checked'], $value, false ),
391
+ esc_html( $label )
392
+ );
393
+ }
394
+ ?>
395
+
396
+ <fieldset>
397
+ <legend class="screen-reader-text"><span><?php echo esc_html( $args['legend'] ); ?></span></legend>
398
+ <?php echo implode( "<br />\n", $options ); ?>
399
+ </fieldset>
400
+
401
+ <?php if ( ! empty( $args['description'] ) ) : ?>
402
+ <p class="description"><?php echo $args['description']; ?></p>
403
+ <?php endif; ?>
404
+
405
+ <?php
406
+ }
407
+
408
+ /**
409
+ * Render an extension license key field.
410
+ *
411
+ * @since 7.0
412
+ *
413
+ * @param array $args {
414
+ * Optional. An array of arguments.
415
+ * }
416
+ */
417
+ function tml_admin_setting_callback_license_key_field( $args ) {
418
+ $args = wp_parse_args( $args, array(
419
+ 'label_for' => '',
420
+ 'extension' => '',
421
+ ) );
422
+
423
+ if ( ! $extension = tml_get_extension( $args['extension'] ) ) {
424
+ return;
425
+ }
426
+
427
+ $license = $extension->get_license_key();
428
+ $status = $extension->get_license_status();
429
+
430
+ if ( 'valid' == $status ) {
431
+ $input_style = sprintf( 'background-color: %s; border-color: %s;', '#b5e1b9', '#46b450' );
432
+ $text_style = 'color: #46b450;';
433
+ $text = __( 'Active', 'theme-my-login' );
434
+ } elseif ( 'invalid' == $status ) {
435
+ $input_style = sprintf( 'background-color: %s; border-color: %s;', '#f1adad', '#dc3232' );
436
+ $text_style = 'color: #dc3232;';
437
+ $text = __( 'Invalid', 'theme-my-login' );
438
+ } else {
439
+ $input_style = $text_style = '';
440
+ $text = __( 'Inactive', 'theme-my-login' );
441
+ }
442
+
443
+ echo sprintf( '<input style="%1$s" type="text" name="%2$s" id="%2$s" value="%3$s" class="regular-text code" %4$s />',
444
+ esc_attr( $input_style ),
445
+ esc_attr( $args['label_for'] ),
446
+ esc_attr( $license ),
447
+ 'valid' == $status ? 'readonly="readonly"' : ''
448
+ ) . "\n";
449
+
450
+ if ( empty( $license ) ) {
451
+ return;
452
+ }
453
+
454
+ if ( 'valid' == $status ) {
455
+ submit_button( __( 'Deactivate', 'theme-my-login' ), 'secondary large', 'tml_deactivate_license[' . $extension->get_name() . ']', false );
456
+ } else {
457
+ submit_button( __( 'Activate', 'theme-my-login' ), 'secondary large', 'tml_activate_license[' . $extension->get_name() . ']', false );
458
+ }
459
+ ?>
460
+
461
+ <p style="<?php echo esc_attr( $text_style ); ?>"><?php echo esc_html( $text ); ?></p>
462
+
463
+ <?php
464
+ }
465
+
466
+ /**
467
+ * Render the settings page.
468
+ *
469
+ * @since 7.0
470
+ */
471
+ function tml_admin_settings_page() {
472
+ global $title, $plugin_page;
473
+
474
+ tml_flush_rewrite_rules();
475
+
476
+ settings_errors();
477
+ ?>
478
+
479
+ <div class="wrap">
480
+ <h1><?php echo esc_html( $title ) ?></h1>
481
+ <hr class="wp-header-end">
482
+
483
+ <form action="<?php echo is_network_admin() ? '' : 'options.php'; ?>" method="post">
484
+
485
+ <?php settings_fields( $plugin_page ); ?>
486
+
487
+ <?php do_settings_sections( $plugin_page ); ?>
488
+
489
+ <?php submit_button(); ?>
490
+ </form>
491
+ </div>
492
+
493
+ <?php
494
+ }
495
+
496
+ /**
497
+ * Handle the network settings page.
498
+ *
499
+ * @since 7.0
500
+ */
501
+ function tml_admin_save_ms_settings() {
502
+
503
+ if ( ! tml_is_post_request() ) {
504
+ return;
505
+ }
506
+
507
+ $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
508
+ $option_page = isset( $_REQUEST['option_page'] ) ? $_REQUEST['option_page'] : '';
509
+
510
+ if ( ! theme_my_login_admin()->has_page( $option_page ) ) {
511
+ return;
512
+ }
513
+
514
+ /* This filter is documented in wp-admin/options.php */
515
+ $whitelist_options = apply_filters( 'whitelist_options', array() );
516
+
517
+ if ( ! isset( $whitelist_options[ $option_page ] ) ) {
518
+ wp_die( __( '<strong>ERROR</strong>: options page not found.' ) );
519
+ }
520
+
521
+ foreach ( $whitelist_options[ $option_page ] as $option ) {
522
+ $option = trim( $option );
523
+ $value = null;
524
+ if ( isset( $_POST[ $option ] ) ) {
525
+ $value = $_POST[ $option ];
526
+ if ( ! is_array( $value ) ) {
527
+ $value = trim( $value );
528
+ }
529
+ $value = wp_unslash( $value );
530
+ }
531
+ update_site_option( $option, $value );
532
+ }
533
+
534
+ tml_flush_rewrite_rules();
535
+
536
+ if ( ! count( get_settings_errors() ) ) {
537
+ add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' );
538
+ }
539
+ set_transient( 'settings_errors', get_settings_errors(), 30 );
540
+
541
+ $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() );
542
+ wp_redirect( $goback );
543
+ exit;
544
+ }
assets/scripts/theme-my-login.js ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function ( $ ) {
2
+
3
+ $( initFocus );
4
+
5
+ function initFocus() {
6
+ var userLogin, key;
7
+
8
+ if ( ! themeMyLogin.action ) {
9
+ return;
10
+ }
11
+
12
+ userLogin = $( '#user_login' );
13
+
14
+ switch ( themeMyLogin.action ) {
15
+ case 'activate' :
16
+ key = $( '#key' );
17
+ if ( key.length ) {
18
+ key.focus();
19
+ }
20
+ break;
21
+
22
+ case 'lostpassword' :
23
+ case 'retrievepassword' :
24
+ case 'register' :
25
+ userLogin.focus();
26
+ break;
27
+
28
+ case 'resetpass' :
29
+ case 'rp' :
30
+ $( '#pass1' ).focus();
31
+ break;
32
+
33
+ case 'login' :
34
+ if ( -1 != themeMyLogin.errors.indexOf( 'invalid_username' ) ) {
35
+ userLogin.val( '' );
36
+ }
37
+
38
+ if ( userLogin.val() ) {
39
+ $( '#user_pass' ).focus();
40
+ } else {
41
+ userLogin.focus();
42
+ }
43
+ break;
44
+ }
45
+ }
46
+ } )( jQuery );
47
+
48
+ ( function( $ ) {
49
+ function checkPasswordStrength() {
50
+ var pass1 = $( '#pass1' ).val(),
51
+ result = $( '#pass-strength-result' ),
52
+ strength;
53
+
54
+ result.removeClass('short bad good strong');
55
+ if ( ! pass1 ) {
56
+ result.html( '&nbsp;' );
57
+ return;
58
+ }
59
+
60
+ strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass1 );
61
+
62
+ switch ( strength ) {
63
+ case -1:
64
+ result.addClass( 'bad' ).html( pwsL10n.unknown );
65
+ break;
66
+ case 2:
67
+ result.addClass( 'bad' ).html( pwsL10n.bad );
68
+ break;
69
+ case 3:
70
+ result.addClass( 'good' ).html( pwsL10n.good );
71
+ break;
72
+ case 4:
73
+ result.addClass( 'strong' ).html( pwsL10n.strong );
74
+ break;
75
+ case 5:
76
+ result.addClass( 'short' ).html( pwsL10n.mismatch );
77
+ break;
78
+ default:
79
+ result.addClass( 'short' ).html( pwsL10n['short'] );
80
+ }
81
+ }
82
+
83
+ $( document ).ready( function() {
84
+ $( '#pass1' ).val( '' ).on( 'keyup paste', checkPasswordStrength );
85
+ } );
86
+ } )( jQuery );
assets/scripts/theme-my-login.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){e(function(){var s,a;if(!themeMyLogin.action)return;switch(s=e("#user_login"),themeMyLogin.action){case"activate":(a=e("#key")).length&&a.focus();break;case"lostpassword":case"retrievepassword":case"register":s.focus();break;case"resetpass":case"rp":e("#pass1").focus();break;case"login":-1!=themeMyLogin.errors.indexOf("invalid_username")&&s.val(""),s.val()?e("#user_pass").focus():s.focus()}})}(jQuery),function(e){function s(){var s=e("#pass1").val(),a=e("#pass-strength-result");if(a.removeClass("short bad good strong"),s)switch(wp.passwordStrength.meter(s,wp.passwordStrength.userInputBlacklist(),s)){case-1:a.addClass("bad").html(pwsL10n.unknown);break;case 2:a.addClass("bad").html(pwsL10n.bad);break;case 3:a.addClass("good").html(pwsL10n.good);break;case 4:a.addClass("strong").html(pwsL10n.strong);break;case 5:a.addClass("short").html(pwsL10n.mismatch);break;default:a.addClass("short").html(pwsL10n.short)}else a.html("&nbsp;")}e(document).ready(function(){e("#pass1").val("").on("keyup paste",s)})}(jQuery);
assets/styles/theme-my-login.css ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .tml {
2
+ font-size: 1em;
3
+ }
4
+
5
+ .tml * {
6
+ -webkit-box-sizing: border-box;
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ .tml-field-wrap {
11
+ margin-bottom: 1em;
12
+ }
13
+
14
+ .tml-label {
15
+ display: block;
16
+ margin: 0.5em 0;
17
+ }
18
+
19
+ .tml-checkbox + .tml-label {
20
+ display: inline;
21
+ }
22
+
23
+ .tml-field {
24
+ width: 100%;
25
+ }
26
+
27
+ .tml-description {
28
+ display: block;
29
+ font-size: 0.85em;
30
+ font-style: italic;
31
+ margin: 0.5em 0;
32
+ }
33
+
34
+ .tml-errors,
35
+ .tml-messages {
36
+ list-style: none;
37
+ margin: 0;
38
+ padding: 0;
39
+ }
40
+
41
+ .tml-error,
42
+ .tml-message,
43
+ .tml-success,
44
+ .tml-action-confirmaction .success {
45
+ border-left: 4px solid #00a0d2;
46
+ -webkit-box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.1);
47
+ box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.1);
48
+ display: block;
49
+ margin: 0 0 1em;
50
+ padding: 0.75em;
51
+ }
52
+
53
+ .tml-error {
54
+ border-left-color: #dc3232;
55
+ }
56
+
57
+ .tml-success,
58
+ .tml-action-confirmaction .success {
59
+ border-left-color: #46b450;
60
+ }
61
+
62
+ #pass-strength-result {
63
+ background-color: #eee;
64
+ border: 1px solid #ddd;
65
+ color: #23282d;
66
+ font-weight: bold;
67
+ opacity: 0;
68
+ margin-bottom: 1em;
69
+ padding: 0.5em;
70
+ }
71
+
72
+ #pass-strength-result.strong {
73
+ background-color: #c1e1b9;
74
+ border-color: #83c373;
75
+ opacity: 1;
76
+ }
77
+
78
+ #pass-strength-result.good {
79
+ background-color: #ffe399;
80
+ border-color: #ffc733;
81
+ opacity: 1;
82
+ }
83
+
84
+ #pass-strength-result.bad {
85
+ background-color: #fbc5a9;
86
+ border-color: #f78b53;
87
+ opacity: 1;
88
+ }
89
+
90
+ #pass-strength-result.short {
91
+ background-color: #f1adad;
92
+ border-color: #e35b5b;
93
+ opacity: 1;
94
+ }
assets/styles/theme-my-login.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .tml{font-size:1em}.tml *{-webkit-box-sizing:border-box;box-sizing:border-box}.tml-field-wrap{margin-bottom:1em}.tml-label{display:block;margin:.5em 0}.tml-checkbox+.tml-label{display:inline}.tml-field{width:100%}.tml-description{display:block;font-size:.85em;font-style:italic;margin:.5em 0}.tml-errors,.tml-messages{list-style:none;margin:0;padding:0}.tml-action-confirmaction .success,.tml-error,.tml-message,.tml-success{border-left:4px solid #00a0d2;-webkit-box-shadow:1px 1px 2px 1px rgba(0,0,0,.1);box-shadow:1px 1px 2px 1px rgba(0,0,0,.1);display:block;margin:0 0 1em;padding:.75em}.tml-error{border-left-color:#dc3232}.tml-action-confirmaction .success,.tml-success{border-left-color:#46b450}#pass-strength-result{background-color:#eee;border:1px solid #ddd;color:#23282d;font-weight:700;opacity:0;margin-bottom:1em;padding:.5em}#pass-strength-result.strong{background-color:#c1e1b9;border-color:#83c373;opacity:1}#pass-strength-result.good{background-color:#ffe399;border-color:#ffc733;opacity:1}#pass-strength-result.bad{background-color:#fbc5a9;border-color:#f78b53;opacity:1}#pass-strength-result.short{background-color:#f1adad;border-color:#e35b5b;opacity:1}
composer.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "theme-my-login/theme-my-login",
3
+ "description": "Creates an alternate login, registration and password recovery experience within your theme.",
4
+ "keywords": ["wordpress", "plugin", "login"],
5
+ "homepage": "https://thememylogin.com",
6
+ "type": "wordpress-plugin",
7
+ "license": "GPLv2",
8
+ "require": {
9
+ "php": ">=5.2.4",
10
+ "composer/installers": "~1.0"
11
+ }
12
+ }
includes/actions.php ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Action Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Actions
8
+ */
9
+
10
+ /**
11
+ * Register default actions.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ function tml_register_default_actions() {
16
+
17
+ // Login
18
+ tml_register_action( 'login', array(
19
+ 'title' => __( 'Log In' ),
20
+ 'slug' => 'login',
21
+ 'callback' => 'tml_login_handler',
22
+ 'show_on_forms' => __( 'Log in' ),
23
+ 'show_nav_menu_item' => ! is_user_logged_in(),
24
+ ) );
25
+
26
+ // Logout
27
+ tml_register_action( 'logout', array(
28
+ 'title' => __( 'Log Out' ),
29
+ 'slug' => 'logout',
30
+ 'callback' => 'tml_logout_handler',
31
+ 'show_on_forms' => false,
32
+ 'show_in_widget' => false,
33
+ 'show_nav_menu_item' => is_user_logged_in(),
34
+ ) );
35
+
36
+ // Register
37
+ tml_register_action( 'register', array(
38
+ 'title' => __( 'Register' ),
39
+ 'slug' => 'register',
40
+ 'callback' => 'tml_registration_handler',
41
+ 'show_on_forms' => (bool) get_option( 'users_can_register' ),
42
+ 'show_nav_menu_item' => ! is_user_logged_in(),
43
+ ) );
44
+
45
+ // Lost Password
46
+ tml_register_action( 'lostpassword', array(
47
+ 'title' => __( 'Lost Password' ),
48
+ 'slug' => 'lostpassword',
49
+ 'callback' => 'tml_lost_password_handler',
50
+ 'network' => true,
51
+ 'show_on_forms' => __( 'Lost your password?' ),
52
+ 'show_in_nav_menus' => false,
53
+ ) );
54
+
55
+ // Reset Password
56
+ tml_register_action( 'resetpass', array(
57
+ 'title' => __( 'Reset Password' ),
58
+ 'slug' => 'resetpass',
59
+ 'callback' => 'tml_password_reset_handler',
60
+ 'network' => true,
61
+ 'show_on_forms' => false,
62
+ 'show_in_widget' => false,
63
+ 'show_in_nav_menus' => false,
64
+ ) );
65
+
66
+ // Confirm Action (Data Requests)
67
+ tml_register_action( 'confirmaction', array(
68
+ 'title' => __( 'Your Data Request', 'theme-my-login' ),
69
+ 'slug' => 'confirmaction',
70
+ 'callback' => 'tml_confirmaction_handler',
71
+ 'show_on_forms' => false,
72
+ 'show_in_widget' => false,
73
+ 'show_in_nav_menus' => false,
74
+ ) );
75
+ }
76
+
77
+ /**
78
+ * Register an action.
79
+ *
80
+ * @since 7.0
81
+ *
82
+ * @param string|Theme_My_Login_Action $action The action name or object.
83
+ * @param array $args {
84
+ * Optional. An array of arguments for registering an action.
85
+ * }
86
+ * @return Theme_My_Login_Action The action object.
87
+ */
88
+ function tml_register_action( $action, $args = array() ) {
89
+
90
+ if ( ! $action instanceof Theme_My_Login_Action ) {
91
+ $action = new Theme_My_Login_Action( $action, $args );
92
+ }
93
+
94
+ if ( $slug = get_site_option( 'tml_' . $action->get_name() . '_slug' ) ) {
95
+ $action->set_slug( $slug );
96
+ }
97
+
98
+ return theme_my_login()->register_action( $action );
99
+ }
100
+
101
+ /**
102
+ * Unregister an action.
103
+ *
104
+ * @since 7.0
105
+ *
106
+ * @param string|Theme_My_Login_Action $action The action name or object.
107
+ */
108
+ function tml_unregister_action( $action ) {
109
+ theme_my_login()->unregister_action( $action );
110
+ }
111
+
112
+ /**
113
+ * Get an action.
114
+ *
115
+ * @since 7.0
116
+ *
117
+ * @param string|Theme_My_Login_Action $action Optional. The action name or object.
118
+ * @return Theme_My_Login_Action|bool The action object if it exists or false otherwise.
119
+ */
120
+ function tml_get_action( $action = '' ) {
121
+
122
+ if ( $action instanceof Theme_My_Login_Action ) {
123
+ return $action;
124
+ }
125
+
126
+ if ( empty( $action ) ) {
127
+ if ( ! $action = get_query_var( 'action' ) ) {
128
+ $action = tml_get_request_value( 'action' );
129
+ }
130
+ }
131
+
132
+ return theme_my_login()->get_action( $action );
133
+ }
134
+
135
+ /**
136
+ * Get all actions.
137
+ *
138
+ * @since 7.0
139
+ *
140
+ * @return array The actions.
141
+ */
142
+ function tml_get_actions() {
143
+ return theme_my_login()->get_actions();
144
+ }
145
+
146
+ /**
147
+ * Determine if an action exists.
148
+ *
149
+ * @since 7.0
150
+ *
151
+ * @param string $action The action name.
152
+ * @return bool True if the action exists or false otherwise.
153
+ */
154
+ function tml_action_exists( $action ) {
155
+ $exists = array_key_exists( $action, tml_get_actions() );
156
+
157
+ /**
158
+ * Filter whether an action exists or not.
159
+ *
160
+ * @since 7.0
161
+ *
162
+ * @param bool $exists Whether the action exists or not.
163
+ * @param string $action The action name.
164
+ */
165
+ return apply_filters( 'tml_action_exists', $exists, $action );
166
+ }
167
+
168
+ /**
169
+ * Determine if a TML action is being requested.
170
+ *
171
+ * @since 7.0
172
+ *
173
+ * @param string $action Optional. The action to check.
174
+ * @return bool Is a TML action being requested?
175
+ */
176
+ function tml_is_action( $action = '' ) {
177
+ $is_action = false;
178
+ $current_action = tml_get_action();
179
+
180
+ if ( $current_action && array_key_exists( $current_action->get_name(), tml_get_actions() ) ) {
181
+ if ( empty( $action ) ) {
182
+ $is_action = true;
183
+ } elseif ( $action == $current_action->get_name() ) {
184
+ $is_action = true;
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Filter whether a TML action is being requested or not.
190
+ *
191
+ * @since 7.0
192
+ *
193
+ * @param bool $is_action Whether a TML action is being requested or not.
194
+ * @param string $action The action name.
195
+ */
196
+ return apply_filters( 'tml_is_action', $is_action, $action );
197
+ }
198
+
199
+ /**
200
+ * Get the action title.
201
+ *
202
+ * @since 7.0
203
+ *
204
+ * @param string|Theme_My_Login_Action $action The action name or object.
205
+ * @return string The action title.
206
+ */
207
+ function tml_get_action_title( $action = '' ) {
208
+
209
+ if ( ! $action = tml_get_action( $action ) ) {
210
+ return;
211
+ }
212
+
213
+ $title = $action->get_title();
214
+
215
+ /**
216
+ * Filter the action title.
217
+ *
218
+ * @since 7.0
219
+ *
220
+ * @param string $title The action title.
221
+ * @param string $name The action name.
222
+ */
223
+ return apply_filters( 'tml_get_action_title', $title, $action->get_name() );
224
+ }
225
+
226
+ /**
227
+ * Get the action slug.
228
+ *
229
+ * @since 7.0
230
+ *
231
+ * @param string|Theme_My_Login_Action $action The action name or object.
232
+ * @return string The action slug.
233
+ */
234
+ function tml_get_action_slug( $action = '' ) {
235
+
236
+ if ( ! $action = tml_get_action( $action ) ) {
237
+ return;
238
+ }
239
+
240
+ $slug = $action->get_slug();
241
+
242
+ /**
243
+ * Filter the action slug.
244
+ *
245
+ * @since 7.0
246
+ *
247
+ * @param string $slug The action slug.
248
+ * @param string $name The action name.
249
+ */
250
+ return apply_filters( 'tml_get_action_slug', $slug, $action->get_name() );
251
+ }
252
+
253
+ /**
254
+ * Get the action URL.
255
+ *
256
+ * @since 7.0
257
+ *
258
+ * @param string|Theme_My_Login_Action $action The action name or object.
259
+ * @param string $scheme The URL scheme.
260
+ * @param bool $network Whether to retrieve the URL for the current network or current blog.
261
+ * @return string The action URL.
262
+ */
263
+ function tml_get_action_url( $action = '', $scheme = 'login', $network = null ) {
264
+
265
+ if ( ! $action = tml_get_action( $action ) ) {
266
+ return;
267
+ }
268
+
269
+ $url = $action->get_url( $scheme, $network );
270
+
271
+ /**
272
+ * Filter the action URL.
273
+ *
274
+ * @since 7.0
275
+ *
276
+ * @param string $url The action URL.
277
+ * @param string $name The action name.
278
+ * @param string $scheme The URL scheme.
279
+ * @param bool $network Whether to retrieve the URL for the current network or current blog.
280
+ */
281
+ return apply_filters( 'tml_get_action_url', $url, $action->get_name(), $scheme, $network );
282
+ }
283
+
284
+ /**
285
+ * Determine if an action has an associated page.
286
+ *
287
+ * @since 7.0.1
288
+ *
289
+ * @param string|Theme_My_Login_Action $action The action name of object.
290
+ * @return bool|WP_Post The page object if one is found, false otherwise.
291
+ */
292
+ function tml_action_has_page( $action = '' ) {
293
+
294
+ if ( ! $action = tml_get_action( $action ) ) {
295
+ return false;
296
+ }
297
+
298
+ if ( ! $page = get_page_by_path( tml_get_action_slug( $action ) ) ) {
299
+ return false;
300
+ }
301
+
302
+ return $page;
303
+ }
304
+
305
+ /**
306
+ * Handle an action.
307
+ *
308
+ * @since 7.0
309
+ */
310
+ function tml_action_handler() {
311
+ if ( ! tml_is_action() ) {
312
+ return;
313
+ }
314
+
315
+ // Redirect to https login if forced to use SSL
316
+ if ( force_ssl_admin() && ! is_ssl() ) {
317
+ if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
318
+ wp_safe_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
319
+ exit();
320
+ } else {
321
+ wp_safe_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
322
+ exit();
323
+ }
324
+ }
325
+
326
+ nocache_headers();
327
+
328
+ /**
329
+ * Fires when a TML action is being requested.
330
+ *
331
+ * @since 7.0.3
332
+ */
333
+ do_action( 'tml_action_' . tml_get_action()->get_name() );
334
+ }
335
+
336
+ /**
337
+ * Handle the 'login' action.
338
+ *
339
+ * @since 7.0
340
+ */
341
+ function tml_login_handler() {
342
+
343
+ $errors = new WP_Error;
344
+
345
+ // Set a cookie now to see if they are supported by the browser.
346
+ $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
347
+ if ( ! isset( $_COOKIE[ TEST_COOKIE ] ) ) {
348
+ setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
349
+ if ( SITECOOKIEPATH != COOKIEPATH ) {
350
+ setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
351
+ }
352
+ }
353
+
354
+ // If the user wants ssl but the session is not ssl, force a secure cookie.
355
+ if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
356
+ $user_name = sanitize_user( $_POST['log'] );
357
+ $user = get_user_by( 'login', $user_name );
358
+
359
+ if ( ! $user && strpos( $user_name, '@' ) ) {
360
+ $user = get_user_by( 'email', $user_name );
361
+ }
362
+
363
+ if ( $user ) {
364
+ if ( get_user_option( 'use_ssl', $user->ID ) ) {
365
+ force_ssl_admin( true );
366
+ }
367
+ }
368
+ }
369
+
370
+ if ( ! empty( $_REQUEST['redirect_to'] ) ) {
371
+ $redirect_to = $_REQUEST['redirect_to'];
372
+ // Redirect to https if user wants ssl
373
+ if ( force_ssl_admin() && false !== strpos( $redirect_to, 'wp-admin' ) ) {
374
+ $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
375
+ }
376
+ } else {
377
+ $redirect_to = admin_url();
378
+ }
379
+
380
+ $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
381
+
382
+ if ( isset( $_POST['log'] ) || isset( $_GET['testcookie'] ) ) {
383
+
384
+ $user = wp_signon( array(), force_ssl_admin() );
385
+
386
+ $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
387
+
388
+ if ( ! is_wp_error( $user ) && empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
389
+ $redirect_to = add_query_arg( array(
390
+ 'testcookie' => 1,
391
+ 'redirect_to' => $redirect_to
392
+ ) );
393
+ wp_redirect( $redirect_to );
394
+ exit;
395
+ }
396
+
397
+ if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
398
+ if ( headers_sent() ) {
399
+ $user = new WP_Error( 'test_cookie', sprintf(
400
+ __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ),
401
+ __( 'https://codex.wordpress.org/Cookies' ),
402
+ __( 'https://wordpress.org/support/' )
403
+ )
404
+ );
405
+ } elseif ( isset( $_GET['testcookie'] ) ) {
406
+ // If cookies are disabled we can't log in even with a valid user+pass
407
+ $user = new WP_Error( 'test_cookie', sprintf(
408
+ __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
409
+ __( 'https://codex.wordpress.org/Cookies' )
410
+ )
411
+ );
412
+ }
413
+ } else {
414
+ $user = wp_get_current_user();
415
+ }
416
+
417
+ if ( ! is_wp_error( $user ) && ! $reauth ) {
418
+
419
+ if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
420
+
421
+ // 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.
422
+ if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) ) {
423
+ $redirect_to = user_admin_url();
424
+
425
+ } elseif ( is_multisite() && ! $user->has_cap( 'read' ) ) {
426
+ $redirect_to = get_dashboard_url( $user->ID );
427
+
428
+ } elseif ( ! $user->has_cap( 'edit_posts' ) ) {
429
+ $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
430
+ }
431
+
432
+ wp_redirect( $redirect_to );
433
+ exit;
434
+ }
435
+
436
+ wp_safe_redirect( $redirect_to );
437
+ exit;
438
+ }
439
+
440
+ $errors = $user;
441
+ }
442
+
443
+ // Clear errors if loggedout is set.
444
+ if ( ! empty( $_GET['loggedout'] ) || $reauth ) {
445
+ $errors = new WP_Error;
446
+ }
447
+
448
+ // Some parts of this script use the main login form to display a message
449
+ if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) {
450
+ $errors->add( 'loggedout', __( 'You are now logged out.' ), 'message' );
451
+
452
+ } elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) {
453
+ $errors->add( 'registerdisabled', __( 'User registration is currently not allowed.' ) );
454
+
455
+ } elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] ) {
456
+ $errors->add( 'confirm', __( 'Check your email for the confirmation link.' ), 'message' );
457
+
458
+ } elseif ( isset( $_GET['checkemail'] ) && 'newpass' == $_GET['checkemail'] ) {
459
+ $errors->add( 'newpass', __( 'Check your email for your new password.' ), 'message' );
460
+
461
+ } elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] ) {
462
+ if ( tml_allow_user_passwords() ) {
463
+ $errors->add( 'registered', __( 'Registration complete. You may now log in.', 'theme-my-login' ), 'message' );
464
+ } else {
465
+ $errors->add( 'registered', __( 'Registration complete. Please check your email.' ), 'message' );
466
+ }
467
+
468
+ } elseif ( isset( $_GET['resetpass'] ) && 'complete' == $_GET['resetpass'] ) {
469
+ $errors->add( 'password_reset', __( 'Your password has been reset.' ), 'message' );
470
+
471
+ } elseif ( strpos( $redirect_to, 'about.php?updated' ) ) {
472
+ $errors->add( 'updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.' ), 'message' );
473
+ }
474
+
475
+ $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to );
476
+
477
+ tml_set_errors( $errors );
478
+
479
+ // Clear any stale cookies.
480
+ if ( $reauth ) {
481
+ wp_clear_auth_cookie();
482
+ }
483
+ }
484
+
485
+ /**
486
+ * Handle the 'logout' action.
487
+ *
488
+ * @since 7.0
489
+ */
490
+ function tml_logout_handler() {
491
+
492
+ check_admin_referer( 'log-out' );
493
+
494
+ $user = wp_get_current_user();
495
+
496
+ wp_logout();
497
+
498
+ if ( ! empty( $_REQUEST['redirect_to'] ) ) {
499
+ $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
500
+ } else {
501
+ $redirect_to = site_url( 'wp-login.php?loggedout=true' );
502
+ $requested_redirect_to = '';
503
+ }
504
+
505
+ $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
506
+ wp_safe_redirect( $redirect_to );
507
+ exit;
508
+ }
509
+
510
+ /**
511
+ * Handle the 'register' action.
512
+ *
513
+ * @since 7.0
514
+ */
515
+ function tml_registration_handler() {
516
+
517
+ if ( is_multisite() ) {
518
+ wp_redirect( apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ) );
519
+ exit;
520
+ }
521
+
522
+ if ( ! get_option( 'users_can_register' ) ) {
523
+ wp_redirect( site_url( 'wp-login.php?registration=disabled' ) );
524
+ exit;
525
+ }
526
+
527
+ if ( tml_is_post_request() ) {
528
+ $user_login = isset( $_POST['user_login'] ) ? $_POST['user_login'] : '';
529
+ $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
530
+ $errors = register_new_user( $user_login, $user_email );
531
+ if ( ! is_wp_error( $errors ) ) {
532
+ $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : site_url( 'wp-login.php?checkemail=registered' );
533
+ wp_safe_redirect( $redirect_to );
534
+ exit;
535
+ } else {
536
+ tml_set_errors( $errors );
537
+ }
538
+ }
539
+ }
540
+
541
+ /**
542
+ * Handle the 'lostpassword' action.
543
+ *
544
+ * @since 7.0
545
+ */
546
+ function tml_lost_password_handler() {
547
+
548
+ if ( tml_is_post_request() ) {
549
+ $errors = tml_retrieve_password();
550
+ if ( ! is_wp_error( $errors ) ) {
551
+ $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url( 'wp-login.php?checkemail=confirm' );
552
+ wp_safe_redirect( $redirect_to );
553
+ exit;
554
+ } else {
555
+ tml_set_errors( $errors );
556
+ }
557
+ }
558
+
559
+ if ( isset( $_REQUEST['error'] ) ) {
560
+ if ( 'invalidkey' == $_REQUEST['error'] ) {
561
+ tml_add_error( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) );
562
+ } elseif ( 'expiredkey' == $_REQUEST['error'] ) {
563
+ tml_add_error( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) );
564
+ }
565
+ }
566
+ }
567
+
568
+ /**
569
+ * Handle the 'resetpass' action.
570
+ *
571
+ * @since 7.0
572
+ */
573
+ function tml_password_reset_handler() {
574
+
575
+ list( $rp_path ) = explode( '?', wp_unslash( $_SERVER['REQUEST_URI'] ) );
576
+ $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
577
+
578
+ if ( isset( $_GET['key'] ) ) {
579
+ $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
580
+ setcookie( $rp_cookie, $value, 0, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
581
+ wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
582
+ exit;
583
+ }
584
+
585
+ if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
586
+ list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
587
+ $user = check_password_reset_key( $rp_key, $rp_login );
588
+ if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
589
+ $user = false;
590
+ }
591
+ } else {
592
+ $user = false;
593
+ }
594
+
595
+ if ( ! $user || is_wp_error( $user ) ) {
596
+ setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
597
+ if ( $user && $user->get_error_code() === 'expired_key' ) {
598
+ wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
599
+ } else {
600
+ wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
601
+ }
602
+ exit;
603
+ }
604
+
605
+ $errors = new WP_Error;
606
+
607
+ if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] ) {
608
+ $errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
609
+ }
610
+
611
+ do_action( 'validate_password_reset', $errors, $user );
612
+
613
+ if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
614
+ reset_password( $user, $_POST['pass1'] );
615
+ setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
616
+ wp_redirect( site_url( 'wp-login.php?resetpass=complete' ) );
617
+ exit;
618
+ } else {
619
+ tml_set_errors( $errors );
620
+ }
621
+ }
622
+
623
+ /**
624
+ * Handle the 'confirmaction' action.
625
+ *
626
+ * @since 7.0
627
+ */
628
+ function tml_confirmaction_handler() {
629
+ if ( ! isset( $_GET['request_id'] ) ) {
630
+ wp_die( __( 'Invalid request.' ) );
631
+ }
632
+
633
+ $request_id = (int) $_GET['request_id'];
634
+
635
+ if ( isset( $_GET['confirm_key'] ) ) {
636
+ $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
637
+ $result = wp_validate_user_request_key( $request_id, $key );
638
+ } else {
639
+ $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) );
640
+ }
641
+
642
+ if ( is_wp_error( $result ) ) {
643
+ wp_die( $result );
644
+ }
645
+
646
+ /** This action is documented in wp-login.php */
647
+ do_action( 'user_request_action_confirmed', $request_id );
648
+ }
includes/class-theme-my-login-abstract.php DELETED
@@ -1,256 +0,0 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login Abstract class
4
- *
5
- * @package Theme_My_Login
6
- */
7
-
8
- if ( ! class_exists( 'Theme_My_Login_Abstract' ) ) :
9
- /*
10
- * Theme My Login Abstract class
11
- *
12
- * This class is the base class to be extended.
13
- *
14
- * @since 6.0
15
- */
16
- abstract class Theme_My_Login_Abstract {
17
- /**
18
- * Holds singleton objects
19
- *
20
- * @since 6.3
21
- * @access private
22
- * @var array
23
- */
24
- private static $objects = array();
25
-
26
- /**
27
- * Holds options key
28
- *
29
- * @since 6.3
30
- * @access protected
31
- * @var string
32
- */
33
- protected $options_key;
34
-
35
- /**
36
- * Holds options array
37
- *
38
- * Extending classes should explicity define options here
39
- * or create a method named default_options() which returns
40
- * an array of options.
41
- *
42
- * @since 6.3
43
- * @access protected
44
- * @var object
45
- */
46
- protected $options = array();
47
-
48
- /**
49
- * Constructor
50
- *
51
- * @since 6.3
52
- * @access protected
53
- */
54
- protected function __construct() {
55
- $this->load_options();
56
- $this->load();
57
- }
58
-
59
- /**
60
- * Clone
61
- *
62
- * @since 6.3
63
- * @access private
64
- */
65
- private function __clone() {}
66
-
67
- /**
68
- * Returns singleton instance
69
- *
70
- * @since 6.3
71
- * @access public
72
- *
73
- * @param string $class Class to instantiate
74
- * @return object Instance of $class
75
- */
76
- public static function get_object( $class = null ) {
77
- if ( ! class_exists( $class ) )
78
- return null;
79
-
80
- if ( ! isset( self::$objects[$class] ) )
81
- self::$objects[$class] = new $class;
82
-
83
- return self::$objects[$class];
84
- }
85
-
86
- /**
87
- * Called when object is constructed
88
- *
89
- * @since 6.3
90
- * @access protected
91
- */
92
- protected function load() {
93
- // This should be overridden by a child class
94
- }
95
-
96
- /**
97
- * Loads options from DB
98
- *
99
- * @since 6.3
100
- * @access public
101
- *
102
- * @param array|string
103
- */
104
- public function load_options() {
105
- if ( method_exists( $this, 'default_options' ) )
106
- $this->options = (array) $this->default_options();
107
-
108
- if ( ! $this->options_key )
109
- return;
110
-
111
- $options = get_option( $this->options_key, array() );
112
- $options = wp_parse_args( $options, $this->options );
113
-
114
- $this->options = $options;
115
- }
116
-
117
- /**
118
- * Saves options to DB
119
- *
120
- * @since 6.3
121
- * @access public
122
- */
123
- public function save_options() {
124
- if ( $this->options_key )
125
- update_option( $this->options_key, $this->options );
126
- }
127
-
128
- /**
129
- * Retrieves an option
130
- *
131
- * @since 6.3
132
- * @access public
133
- *
134
- * @param string|array $option Name of option to retrieve or an array of hierarchy for multidimensional options
135
- * @param mixed $default Default value to return if $option is not set
136
- * @return mixed Value of requested option or $default if option is not set
137
- */
138
- public function get_option( $option, $default = false ) {
139
- if ( ! is_array( $option ) )
140
- $option = array( $option );
141
- return self::_get_option( $option, $default, $this->options );
142
- }
143
-
144
- /**
145
- * Recursively retrieves a multidimensional option
146
- *
147
- * @since 6.3
148
- * @access private
149
- *
150
- * @param array $option Array of hierarchy
151
- * @param mixed $default Default value to return
152
- * @param array Options to search
153
- * @return mixed Value of requested option or $default if option is not set
154
- */
155
- private function _get_option( $option, $default, &$options ) {
156
- $key = array_shift( $option );
157
- if ( ! isset( $options[$key] ) )
158
- return $default;
159
- if ( ! empty( $option ) )
160
- return self::_get_option( $option, $default, $options[$key] );
161
- return $options[$key];
162
- }
163
-
164
- /**
165
- * Retrieves all options
166
- *
167
- * @since 6.3
168
- * @access public
169
- *
170
- * @return array Options
171
- */
172
- public function get_options() {
173
- return $this->options;
174
- }
175
-
176
- /**
177
- * Sets an option
178
- *
179
- * @since 6.3
180
- * @access public
181
- *
182
- * @param string $option Name of option to set or an array of hierarchy for multidimensional options
183
- * @param mixed $value Value of new option
184
- */
185
- public function set_option( $option, $value = '' ) {
186
- if ( ! is_array( $option ) )
187
- $option = array( $option );
188
-
189
- self::_set_option( $option, $value, $this->options );
190
- }
191
-
192
- /**
193
- * Recursively sets a multidimensional option
194
- *
195
- * @since 6.3
196
- * @access private
197
- *
198
- * @param array $option Array of hierarchy
199
- * @param mixed $value Value of new option
200
- * @param array $options Options to update
201
- */
202
- private function _set_option( $option, $value, &$options ) {
203
- $key = array_shift( $option );
204
- if ( ! empty( $option ) ) {
205
- if ( ! isset( $options[$key] ) )
206
- $options[$key] = array();
207
- return self::_set_option( $option, $value, $options[$key] );
208
- }
209
- $options[$key] = $value;
210
- }
211
-
212
- /**
213
- * Sets all options
214
- *
215
- * @since 6.3
216
- * @access public
217
- *
218
- * @param array $options Options array
219
- */
220
- public function set_options( $options ) {
221
- $this->options = (array) $options;
222
- }
223
-
224
- /**
225
- * Deletes an option
226
- *
227
- * @since 6.3
228
- * @access public
229
- *
230
- * @param string $option Name of option to delete
231
- */
232
- public function delete_option( $option ) {
233
- if ( ! is_array( $option ) )
234
- $option = array( $option );
235
-
236
- self::_delete_option( $option, $this->options );
237
- }
238
-
239
- /**
240
- * Recursively finds and deletes a multidimensional option
241
- *
242
- * @since 6.3
243
- * @access private
244
- *
245
- * @param array $option Array of hierarchy
246
- * @param array $options Options to update
247
- */
248
- private function _delete_option( $option, &$options ) {
249
- $key = array_shift( $option );
250
- if ( ! empty( $option ) )
251
- return self::_delete_option( $option, $options[$key] );
252
- unset( $options[$key] );
253
- }
254
- }
255
- endif;
256
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-theme-my-login-action.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Action Class
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Actions
8
+ */
9
+
10
+ /**
11
+ * Class used to implement the action object.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ class Theme_My_Login_Action {
16
+
17
+ /**
18
+ * The action name.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $name;
23
+
24
+ /**
25
+ * The action title.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $title;
30
+
31
+ /**
32
+ * The action slug.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $slug;
37
+
38
+ /**
39
+ * The action handler.
40
+ *
41
+ * @var callable
42
+ */
43
+ protected $callback;
44
+
45
+ /**
46
+ * Whether this action is a network action or not.
47
+ *
48
+ * @var bool
49
+ */
50
+ public $network = false;
51
+
52
+ /**
53
+ * Whether a link to the action should be shown on forms or not.
54
+ *
55
+ * @var bool
56
+ */
57
+ public $show_on_forms = true;
58
+
59
+ /**
60
+ * Whether this action should be selectable in the widget or not.
61
+ *
62
+ * @var bool
63
+ */
64
+ public $show_in_widget = true;
65
+
66
+ /**
67
+ * Whether this action should be shown for use in nav menus or not.
68
+ *
69
+ * @var bool
70
+ */
71
+ public $show_in_nav_menus = true;
72
+
73
+ /**
74
+ * Whether to show the nav menu item or not when this action is assigned to a nav menu.
75
+ *
76
+ * @var bool
77
+ */
78
+ public $show_nav_menu_item;
79
+
80
+ /**
81
+ * Construct the instance.
82
+ *
83
+ * @since 7.0
84
+ *
85
+ * @param string $name The action name.
86
+ * @param array $args {
87
+ * Optional. An array of arguments.
88
+ *
89
+ * @type string $title The action title.
90
+ * @type string $slug The action slug.
91
+ * @type callable $callback The action callback to fire when accessed.
92
+ * @type bool|string $show_on_forms Whether a link to the action should be shown on forms or not.
93
+ * @type bool $show_in_widget Whether this action should be selectable in the widget or not.
94
+ * @type bool $show_in_nav_menus Whether this action should be available for use in nav menus or not.
95
+ * @type bool $show_nav_menu_item Whether to show an assigned nav menu item or not.
96
+ * }
97
+ */
98
+ public function __construct( $name, $args = array() ) {
99
+
100
+ $this->set_name( $name );
101
+
102
+ $args = wp_parse_args( $args, array(
103
+ 'title' => '',
104
+ 'slug' => '',
105
+ 'callback' => '',
106
+ 'network' => false,
107
+ 'show_on_forms' => true,
108
+ 'show_in_widget' => true,
109
+ 'show_in_nav_menus' => true,
110
+ ) );
111
+
112
+ if ( ! isset( $args['show_nav_menu_item'] ) ) {
113
+ $args['show_nav_menu_item'] = $args['show_in_nav_menus'];
114
+ }
115
+
116
+ $this->set_title( $args['title'] );
117
+ $this->set_slug( $args['slug'] );
118
+ $this->set_callback( $args['callback'] );
119
+
120
+ $this->network = (bool) $args['network'];
121
+ $this->show_on_forms = $args['show_on_forms'];
122
+ $this->show_in_widget = (bool) $args['show_in_widget'];
123
+ $this->show_in_nav_menus = (bool) $args['show_in_nav_menus'];
124
+ $this->show_nav_menu_item = (bool) $args['show_nav_menu_item'];
125
+ }
126
+
127
+ /**
128
+ * Get the action name.
129
+ *
130
+ * @since 7.0
131
+ *
132
+ * @return string The action name.
133
+ */
134
+ public function get_name() {
135
+ return $this->name;
136
+ }
137
+
138
+ /**
139
+ * Set the action name.
140
+ *
141
+ * @since 7.0
142
+ *
143
+ * @param string $name The action name.
144
+ */
145
+ protected function set_name( $name ) {
146
+ $this->name = sanitize_key( $name );
147
+ }
148
+
149
+ /**
150
+ * Get the action title.
151
+ *
152
+ * @since 7.0
153
+ *
154
+ * @return string The action title.
155
+ */
156
+ public function get_title() {
157
+ return $this->title;
158
+ }
159
+
160
+ /**
161
+ * Set the action title.
162
+ *
163
+ * @since 7.0
164
+ *
165
+ * @param string $title The action title.
166
+ */
167
+ public function set_title( $title ) {
168
+ $this->title = $title;
169
+ }
170
+
171
+ /**
172
+ * Get the action callback.
173
+ *
174
+ * @since 7.0.3
175
+ *
176
+ * @return callable The action callback.
177
+ */
178
+ public function get_callback() {
179
+ return $this->callback;
180
+ }
181
+
182
+ /**
183
+ * Set the action callback.
184
+ *
185
+ * @since 7.0.3
186
+ *
187
+ * @param callable $callback The action callback.
188
+ */
189
+ public function set_callback( $callback ) {
190
+ $this->callback = $callback;
191
+ }
192
+
193
+ /**
194
+ * Adds the callback to the proper hook.
195
+ *
196
+ * @since 7.0.3
197
+ */
198
+ public function add_callback_hook() {
199
+ if ( $callback = $this->get_callback() ) {
200
+ add_action( 'tml_action_' . $this->get_name(), $callback, 15 );
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Removes the callback from the proper hook.
206
+ *
207
+ * @since 7.0.3
208
+ */
209
+ public function remove_callback_hook() {
210
+ if ( $callback = $this->get_callback() ) {
211
+ remove_action( 'tml_action_' . $this->get_name(), $callback, 15 );
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Get the action slug.
217
+ *
218
+ * @since 7.0
219
+ *
220
+ * @return string The action slug.
221
+ */
222
+ public function get_slug() {
223
+ return $this->slug;
224
+ }
225
+
226
+ /**
227
+ * Set the action slug.
228
+ *
229
+ * @since 7.0
230
+ *
231
+ * @param string $slug The action slug.
232
+ */
233
+ public function set_slug( $slug ) {
234
+ if ( empty( $slug ) ) {
235
+ $slug = $this->get_name();
236
+ }
237
+ $this->slug = $slug;
238
+ }
239
+
240
+ /**
241
+ * Get the action URL.
242
+ *
243
+ * @since 7.0
244
+ *
245
+ * @param string $scheme The URL scheme.
246
+ * @param bool $network Whether to retrieve the URL for the current network or current blog.
247
+ * @return string The action URL.
248
+ */
249
+ public function get_url( $scheme = 'login', $network = null ) {
250
+ if ( null === $network ) {
251
+ $network = $this->network;
252
+ }
253
+
254
+ $function = $network ? 'network_home_url' : 'home_url';
255
+
256
+ if ( tml_use_permalinks() ) {
257
+ $path = user_trailingslashit( $this->get_slug() );
258
+ $url = $function( $path, $scheme );
259
+ } else {
260
+ $url = $function( '', $scheme );
261
+ $url = user_trailingslashit( $url );
262
+ $url = add_query_arg( 'action', $this->name, $url );
263
+ }
264
+ return $url;
265
+ }
266
+ }
includes/class-theme-my-login-common.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
- /**
3
- * Holds the Theme My Login Common class
4
- *
5
- * @package Theme_My_Login
6
- * @since 6.3
7
- */
8
-
9
- if ( ! class_exists( 'Theme_My_Login_Common' ) ) :
10
- /*
11
- * Theme My Login Helper class
12
- *
13
- * This class holds methods common to being common.
14
- *
15
- * @since 6.3
16
- */
17
- class Theme_My_Login_Common {
18
- /**
19
- * Returns current URL
20
- *
21
- * @since 6.3
22
- * @access public
23
- *
24
- * @param string $query Optionally append query to the current URL
25
- * @return string URL with optional path appended
26
- */
27
- public static function get_current_url( $query = '' ) {
28
- $url = remove_query_arg( array( 'instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce', 'reauth', 'login', 'updated' ) );
29
-
30
- if ( ! empty( $_REQUEST['instance'] ) )
31
- $url = add_query_arg( 'instance', $_REQUEST['instance'] );
32
-
33
- if ( ! empty( $query ) ) {
34
- $r = wp_parse_args( $query );
35
- foreach ( $r as $k => $v ) {
36
- if ( strpos( $v, ' ' ) !== false )
37
- $r[$k] = rawurlencode( $v );
38
- }
39
- $url = add_query_arg( $r, $url );
40
- }
41
- return $url;
42
- }
43
-
44
- /**
45
- * Merges arrays recursively, replacing duplicate string keys
46
- *
47
- * @since 6.3
48
- * @access public
49
- */
50
- public static function array_merge_recursive() {
51
- $args = func_get_args();
52
-
53
- $result = array_shift( $args );
54
-
55
- foreach ( $args as $arg ) {
56
- foreach ( $arg as $key => $value ) {
57
- // Renumber numeric keys as array_merge() does.
58
- if ( is_numeric( $key ) ) {
59
- if ( ! in_array( $value, $result ) )
60
- $result[] = $value;
61
- }
62
- // Recurse only when both values are arrays.
63
- elseif ( array_key_exists( $key, $result ) && is_array( $result[$key] ) && is_array( $value ) ) {
64
- $result[$key] = self::array_merge_recursive( $result[$key], $value );
65
- }
66
- // Otherwise, use the latter value.
67
- else {
68
- $result[$key] = $value;
69
- }
70
- }
71
- }
72
- return $result;
73
- }
74
-
75
- /**
76
- * Replaces certain user and blog variables in $input string
77
- *
78
- * @since 6.0
79
- * @access public
80
- *
81
- * @param string $input The input string
82
- * @param int $user_id User ID to replace user specific variables
83
- * @param array $replacements Misc variables => values replacements
84
- * @return string The $input string with variables replaced
85
- */
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 );
93
-
94
- // Get user data
95
- $user = false;
96
- if ( $user_id )
97
- $user = get_user_by( 'id', $user_id );
98
-
99
- // Get all matches ($matches[0] will be '%value%'; $matches[1] will be 'value')
100
- preg_match_all( '/%([a-zA-Z0-9-_]*)%/', $input, $matches );
101
-
102
- // Iterate through matches
103
- foreach ( $matches[0] as $key => $match ) {
104
- if ( ! isset( $replacements[$match] ) ) {
105
- if ( $user && isset( $user->{$matches[1][$key]} ) ) // Replacement from WP_User object
106
- $replacements[$match] = $user->{$matches[1][$key]};
107
- else
108
- $replacements[$match] = get_bloginfo( $matches[1][$key] ); // Replacement from get_bloginfo()
109
- }
110
- }
111
-
112
- // Allow replacements to be filtered
113
- $replacements = apply_filters( 'tml_replace_vars', $replacements, $user_id );
114
-
115
- if ( empty( $replacements ) )
116
- return $input;
117
-
118
- // Get search values
119
- $search = array_keys( $replacements );
120
-
121
- // Get replacement values
122
- $replace = array_values( $replacements );
123
-
124
- return str_replace( $search, $replace, $input );
125
- }
126
-
127
- /**
128
- * Strip unwanted query arguments from a URL
129
- *
130
- * @since 6.4.1
131
- *
132
- * @param string $url The URL
133
- * @return string The URL
134
- */
135
- public static function strip_query_args( $url ) {
136
- return remove_query_arg( array(
137
- 'instance',
138
- 'action',
139
- 'checkemail',
140
- 'error',
141
- 'loggedout',
142
- 'registered',
143
- 'redirect_to',
144
- 'updated',
145
- 'key',
146
- '_wpnonce',
147
- 'reauth'
148
- ), $url );
149
- }
150
- }
151
- endif; // Class exists
152
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-theme-my-login-extension.php ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Extension Class
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Extensions
8
+ */
9
+
10
+ /**
11
+ * Class used to implement an extension object.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ abstract class Theme_My_Login_Extension {
16
+
17
+ /**
18
+ * The extension name.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $name = 'theme-my-login-extension';
23
+
24
+ /**
25
+ * The extension title.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $title;
30
+
31
+ /**
32
+ * The extension version.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $version = '1.0';
37
+
38
+ /**
39
+ * The main extension file.
40
+ *
41
+ * @var string
42
+ */
43
+ protected $file;
44
+
45
+ /**
46
+ * The extension path.
47
+ *
48
+ * @var string
49
+ */
50
+ protected $path;
51
+
52
+ /**
53
+ * The extension URL.
54
+ *
55
+ * @var string
56
+ */
57
+ protected $url;
58
+
59
+ /**
60
+ * The extension store URL.
61
+ *
62
+ * @var string
63
+ */
64
+ protected $store_url;
65
+
66
+ /**
67
+ * The extension item ID.
68
+ *
69
+ * @var int
70
+ */
71
+ protected $item_id;
72
+
73
+ /**
74
+ * The option used to store the license key.
75
+ *
76
+ * @var string.
77
+ */
78
+ protected $license_key_option;
79
+
80
+ /**
81
+ * The option key used to store the license status.
82
+ *
83
+ * @var string
84
+ */
85
+ protected $license_status_option;
86
+
87
+ /**
88
+ * Create the extension instance.
89
+ *
90
+ * @since 7.0
91
+ *
92
+ * @param string $file The path to the extension file.
93
+ */
94
+ public function __construct( $file ) {
95
+ $this->file = $file;
96
+ $this->path = plugin_dir_path( $file );
97
+ $this->url = plugin_dir_url( $file );
98
+
99
+ $this->set_properties();
100
+ $this->include_files();
101
+ $this->add_actions();
102
+ $this->add_filters();
103
+
104
+ register_activation_hook( $file, array( $this, 'activate' ) );
105
+ register_deactivation_hook( $file, array( $this, 'deactivate' ) );
106
+
107
+ if ( is_admin() ) {
108
+ $this->update();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Set class properties.
114
+ *
115
+ * @since 7.0
116
+ */
117
+ protected function set_properties() {}
118
+
119
+ /**
120
+ * Include the extension files.
121
+ *
122
+ * @since 7.0
123
+ */
124
+ protected function include_files() {}
125
+
126
+ /**
127
+ * Add the extension actions.
128
+ *
129
+ * @since 7.0
130
+ */
131
+ protected function add_actions() {}
132
+
133
+ /**
134
+ * Add the extension filters.
135
+ *
136
+ * @since 7.0
137
+ */
138
+ protected function add_filters() {}
139
+
140
+ /**
141
+ * Get the extension name.
142
+ *
143
+ * @since 7.0
144
+ *
145
+ * @return string The extension name.
146
+ */
147
+ public function get_name() {
148
+ return $this->name;
149
+ }
150
+
151
+ /**
152
+ * Get the extension slug.
153
+ *
154
+ * @since 7.0
155
+ *
156
+ * @return string The extension slug.
157
+ */
158
+ public function get_slug() {
159
+ if ( isset( $this->slug ) ) {
160
+ return $this->slug;
161
+ }
162
+ return str_replace( 'theme-my-login-', '', $this->name );
163
+ }
164
+
165
+ /**
166
+ * Get the extension title.
167
+ *
168
+ * @since 7.0
169
+ *
170
+ * @return string The extension title.
171
+ */
172
+ public function get_title() {
173
+ return $this->title;
174
+ }
175
+
176
+ /**
177
+ * Get the extension version.
178
+ *
179
+ * @since 7.0
180
+ *
181
+ * @return string The extension version.
182
+ */
183
+ public function get_version() {
184
+ return $this->version;
185
+ }
186
+
187
+ /**
188
+ * Get the extension basename.
189
+ *
190
+ * @since 7.0
191
+ *
192
+ * @return string The extension basename.
193
+ */
194
+ public function get_basename() {
195
+ return plugin_basename( $this->file );
196
+ }
197
+
198
+ /**
199
+ * Get the main extension file.
200
+ *
201
+ * @since 7.0
202
+ *
203
+ * @return string The main extension file.
204
+ */
205
+ public function get_file() {
206
+ return $this->file;
207
+ }
208
+
209
+ /**
210
+ * Get the extension path.
211
+ *
212
+ * @since 7.0
213
+ *
214
+ * @return string The extension path.
215
+ */
216
+ public function get_path() {
217
+ return $this->path;
218
+ }
219
+
220
+ /**
221
+ * Get the extension URL.
222
+ *
223
+ * @since 7.0
224
+ *
225
+ * @return string The extension URL.
226
+ */
227
+ public function get_url() {
228
+ return $this->url;
229
+ }
230
+
231
+ /**
232
+ * Get the extension's store URL.
233
+ *
234
+ * @since 7.0
235
+ *
236
+ * @return string The extension's store URL.
237
+ */
238
+ public function get_store_url() {
239
+ return $this->store_url;
240
+ }
241
+
242
+ /**
243
+ * Get the extension's item ID.
244
+ *
245
+ * @since 7.0
246
+ *
247
+ * @return int The extension's item ID.
248
+ */
249
+ public function get_item_id() {
250
+ return $this->item_id;
251
+ }
252
+
253
+ /**
254
+ * Get the name of the license key option for the extension.
255
+ *
256
+ * @since 7.0
257
+ *
258
+ * @return string The license key option name.
259
+ */
260
+ public function get_license_key_option() {
261
+ return $this->license_key_option;
262
+ }
263
+
264
+ /**
265
+ * Get the license key for the extension.
266
+ *
267
+ * @since 7.0
268
+ *
269
+ * @return string The license key for the extension.
270
+ */
271
+ public function get_license_key() {
272
+ return get_site_option( $this->license_key_option );
273
+ }
274
+
275
+ /**
276
+ * Get the name of the license status option for the extension.
277
+ *
278
+ * @since 7.0
279
+ *
280
+ * @return string The license status option name.
281
+ */
282
+ public function get_license_status_option() {
283
+ return $this->license_status_option;
284
+ }
285
+
286
+ /**
287
+ * Get the license status for the extension.
288
+ *
289
+ * @since 7.0
290
+ *
291
+ * @return string The license status for the extension.
292
+ */
293
+ public function get_license_status() {
294
+ return get_site_option( $this->license_status_option );
295
+ }
296
+
297
+ /**
298
+ * Set the license status for the extension.
299
+ *
300
+ * @since 7.0
301
+ *
302
+ * @param string $status The license status.
303
+ */
304
+ public function set_license_status( $status = '' ) {
305
+ update_site_option( $this->license_status_option, $status );
306
+ }
307
+
308
+ /**
309
+ * Get the extension settings page arguments.
310
+ *
311
+ * @since 7.0
312
+ *
313
+ * @return array The extension settings page arguments.
314
+ */
315
+ public function get_settings_page_args() {
316
+ return array();
317
+ }
318
+
319
+ /**
320
+ * Get the extension settings sections.
321
+ *
322
+ * @since 7.0
323
+ *
324
+ * @return array The extension settings sections.
325
+ */
326
+ public function get_settings_sections() {
327
+ return array();
328
+ }
329
+
330
+ /**
331
+ * Get the extension settings fields.
332
+ *
333
+ * @since 7.0
334
+ *
335
+ * @return array The extension settings fields.
336
+ */
337
+ public function get_settings_fields() {
338
+ return array();
339
+ }
340
+
341
+ /**
342
+ * Fire an action hook when the extension is activated.
343
+ *
344
+ * @since 7.0
345
+ */
346
+ public function activate() {
347
+ /**
348
+ * Fires when the extension is being activated.
349
+ *
350
+ * @since 7.0
351
+ */
352
+ do_action( 'tml_activate_' . $this->get_slug() );
353
+ }
354
+
355
+ /**
356
+ * Fire an action hook when the extension is deactivated.
357
+ *
358
+ * @since 7.0
359
+ */
360
+ public function deactivate() {
361
+ /**
362
+ * Fires when the extension is being deactivated.
363
+ *
364
+ * @since 7.0
365
+ */
366
+ do_action( 'tml_deactivate_' . $this->get_slug() );
367
+ }
368
+
369
+ /**
370
+ * Update the extension.
371
+ *
372
+ * @since 7.0
373
+ */
374
+ protected function update() {}
375
+ }
includes/class-theme-my-login-form-field.php ADDED
@@ -0,0 +1,624 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Form Field Class
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Forms
8
+ */
9
+
10
+ /**
11
+ * Class used to implement the form field object.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ class Theme_My_Login_Form_Field {
16
+
17
+ /**
18
+ * The field name.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $name;
23
+
24
+ /**
25
+ * The field type.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $type;
30
+
31
+ /**
32
+ * The field value.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $value;
37
+
38
+ /**
39
+ * The field label.
40
+ *
41
+ * @var string
42
+ */
43
+ protected $label;
44
+
45
+ /**
46
+ * The field description.
47
+ *
48
+ * @var string
49
+ */
50
+ protected $description;
51
+
52
+ /**
53
+ * The field error.
54
+ *
55
+ * @var string
56
+ */
57
+ protected $error;
58
+
59
+ /**
60
+ * The field content.
61
+ *
62
+ * @var string
63
+ */
64
+ protected $content;
65
+
66
+ /**
67
+ * The field options.
68
+ *
69
+ * @var array
70
+ */
71
+ protected $options = array();
72
+
73
+ /**
74
+ * The field attributes.
75
+ *
76
+ * @var array
77
+ */
78
+ protected $attributes = array();
79
+
80
+ /**
81
+ * The field's parent form.
82
+ *
83
+ * @var Theme_My_Login_Form
84
+ */
85
+ protected $form;
86
+
87
+ /**
88
+ * The field's priority within the form.
89
+ *
90
+ * @var int
91
+ */
92
+ protected $priority = 10;
93
+
94
+ /**
95
+ * The arguments used for rendering the field.
96
+ *
97
+ * @see Theme_My_Login_Form_Field::render()
98
+ *
99
+ * @var array
100
+ */
101
+ public $render_args = array();
102
+
103
+ /**
104
+ * Create a new instance.
105
+ *
106
+ * @since 7.0
107
+ *
108
+ * @param Theme_My_Login_Form $form The field's parent form.
109
+ * @param string $name The field name.
110
+ * @param array $args {
111
+ * Optional. An array of arguments.
112
+ *
113
+ * @type string $type The field type.
114
+ * @type string $value The field value.
115
+ * @type string $label The field label.
116
+ * @type string $description The field description.
117
+ * @type string $error The field error message.
118
+ * @type string $content The field content. Used if type is set to "custom".
119
+ * @type array $options The field options. Used if type is set to "dropdown" or "radio-group".
120
+ * @type array $attributes The field attributes.
121
+ * }
122
+ */
123
+ public function __construct( Theme_My_Login_Form $form, $name, $args = array() ) {
124
+ $this->set_form( $form );
125
+ $this->set_name( $name );
126
+
127
+ $args = wp_parse_args( $args, array(
128
+ 'type' => 'text',
129
+ 'value' => '',
130
+ 'label' => '',
131
+ 'description' => '',
132
+ 'error' => '',
133
+ 'content' => '',
134
+ 'options' => array(),
135
+ 'attributes' => array(),
136
+ ) );
137
+
138
+ $this->set_type( $args['type'] );
139
+ $this->set_value( $args['value'] );
140
+ $this->set_label( $args['label'] );
141
+ $this->set_description( $args['description'] );
142
+ $this->set_error( $args['error'] );
143
+ $this->set_content( $args['content'] );
144
+ $this->set_options( $args['options'] );
145
+
146
+ if ( ! empty( $args['id'] ) ) {
147
+ $this->add_attribute( 'id', $args['id'] );
148
+ }
149
+
150
+ if ( ! empty( $args['class'] ) ) {
151
+ $this->add_attribute( 'class', $args['class'] );
152
+ } elseif ( 'hidden' != $this->get_type() ) {
153
+ if ( in_array( $this->get_type(), array( 'button', 'submit', 'reset' ) ) ) {
154
+ $class = 'tml-button';
155
+ } elseif ( in_array( $this->get_type(), array( 'checkbox', 'radio', 'radio-group' ) ) ) {
156
+ $class = 'tml-checkbox';
157
+ } else {
158
+ $class = 'tml-field';
159
+ }
160
+ $this->add_attribute( 'class', $class );
161
+ }
162
+
163
+ foreach ( (array) $args['attributes'] as $key => $value ) {
164
+ $this->add_attribute( $key, $value );
165
+ }
166
+
167
+ if ( isset( $args['priority'] ) ) {
168
+ $this->set_priority( $args['priority'] );
169
+ }
170
+
171
+ if ( ! empty( $args['render_args'] ) ) {
172
+ $this->render_args = $args['render_args'];
173
+ }
174
+ }
175
+
176
+ /**
177
+ * Get the field name.
178
+ *
179
+ * @since 7.0
180
+ *
181
+ * @return string The field name.
182
+ */
183
+ public function get_name() {
184
+ return $this->name;
185
+ }
186
+
187
+ /**
188
+ * Set the field name.
189
+ *
190
+ * @since 7.0
191
+ *
192
+ * @param string $name The field name.
193
+ */
194
+ protected function set_name( $name ) {
195
+ $this->name = sanitize_key( $name );
196
+ }
197
+
198
+ /**
199
+ * Get the field type.
200
+ *
201
+ * @since 7.0
202
+ *
203
+ * @return string The field type.
204
+ */
205
+ public function get_type() {
206
+ return $this->type;
207
+ }
208
+
209
+ /**
210
+ * Set the field type.
211
+ *
212
+ * @since 7.0
213
+ *
214
+ * @param string $type The field type.
215
+ */
216
+ public function set_type( $type ) {
217
+ if ( empty( $type ) ) {
218
+ $type = 'text';
219
+ }
220
+ $this->type = $type;
221
+ }
222
+
223
+ /**
224
+ * Get the field value.
225
+ *
226
+ * @since 7.0
227
+ *
228
+ * @return string The field value.
229
+ */
230
+ public function get_value() {
231
+ return $this->value;
232
+ }
233
+
234
+ /**
235
+ * Set the field value.
236
+ *
237
+ * @since 7.0
238
+ *
239
+ * @param string $value The field value.
240
+ */
241
+ public function set_value( $value ) {
242
+ $this->value = $value;
243
+ }
244
+
245
+ /**
246
+ * Get the field label.
247
+ *
248
+ * @since 7.0
249
+ *
250
+ * @return string The field label.
251
+ */
252
+ public function get_label() {
253
+ /**
254
+ * Filters the form field label.
255
+ *
256
+ * @param string $label The field label.
257
+ * @param Theme_My_Login_Form_Field $field The field object.
258
+ */
259
+ return apply_filters( 'tml_get_form_field_label', $this->label, $this );
260
+ }
261
+
262
+ /**
263
+ * Set the field label.
264
+ *
265
+ * @since 7.0
266
+ *
267
+ * @param string $label The field label.
268
+ */
269
+ public function set_label( $label ) {
270
+ $this->label = $label;
271
+ }
272
+
273
+ /**
274
+ * Get the field description.
275
+ *
276
+ * @since 7.0
277
+ *
278
+ * @return string The field description.
279
+ */
280
+ public function get_description() {
281
+ /**
282
+ * Filters the form field description.
283
+ *
284
+ * @param string $description The field Description.
285
+ * @param Theme_My_Login_Form_Field $field The field object.
286
+ */
287
+ return apply_filters( 'tml_get_form_field_description', $this->description, $this );
288
+ }
289
+
290
+ /**
291
+ * Set the field description.
292
+ *
293
+ * @since 7.0
294
+ *
295
+ * @param string $description The field description.
296
+ */
297
+ public function set_description( $description ) {
298
+ $this->description = $description;
299
+ }
300
+
301
+ /**
302
+ * Get the field error message.
303
+ *
304
+ * @since 7.0
305
+ *
306
+ * @return string The field error message.
307
+ */
308
+ public function get_error() {
309
+ return $this->error;
310
+ }
311
+
312
+ /**
313
+ * Set the field error message.
314
+ *
315
+ * @since 7.0
316
+ *
317
+ * @param string $error The field error message.
318
+ */
319
+ public function set_error( $error = '' ) {
320
+ $this->error = $error;
321
+ }
322
+
323
+ /**
324
+ * Get the field content.
325
+ *
326
+ * @since 7.0
327
+ *
328
+ * @return string The field content.
329
+ */
330
+ public function get_content() {
331
+ return $this->content;
332
+ }
333
+
334
+ /**
335
+ * Set the field content.
336
+ *
337
+ * @since 7.0
338
+ *
339
+ * @param string $content The field content.
340
+ */
341
+ public function set_content( $content = '' ) {
342
+ $this->content = $content;
343
+ }
344
+
345
+ /**
346
+ * Get the wrap flag.
347
+ *
348
+ * @since 7.0
349
+ *
350
+ * @return bool The wrap flag.
351
+ */
352
+ public function get_wrap() {
353
+ return $this->wrap;
354
+ }
355
+
356
+ /**
357
+ * Set the wrap flag.
358
+ *
359
+ * @since 7.0
360
+ *
361
+ * @param bool $wrap Whether to wrap the field or not.
362
+ */
363
+ public function set_wrap( $wrap = true ) {
364
+ $this->wrap = (bool) $wrap;
365
+ }
366
+
367
+ /**
368
+ * Get the field options.
369
+ *
370
+ * @since 7.0
371
+ *
372
+ * @return array The field options.
373
+ */
374
+ public function get_options() {
375
+ /**
376
+ * Filters the form field options.
377
+ *
378
+ * @param array $options The field options.
379
+ * @param Theme_My_Login_Form_Field $this The field object.
380
+ */
381
+ return apply_filters( 'tml_get_form_field_options', $this->options, $this );
382
+ }
383
+
384
+ /**
385
+ * Set the field options.
386
+ *
387
+ * @since 7.0
388
+ *
389
+ * @param array $options The field options.
390
+ */
391
+ public function set_options( $options = array() ) {
392
+ $this->options = (array) $options;
393
+ }
394
+
395
+ /**
396
+ * Get the field's parent form.
397
+ *
398
+ * @since 7.0
399
+ *
400
+ * @return Theme_My_Login_Form The field's parent form.
401
+ */
402
+ public function get_form() {
403
+ return $this->form;
404
+ }
405
+
406
+ /**
407
+ * Set the field's parent form.
408
+ *
409
+ * @since 7.0
410
+ *
411
+ * @param Theme_My_Login_Form $form The field's parent form.
412
+ */
413
+ public function set_form( Theme_My_Login_Form $form ) {
414
+ $this->form = $form;
415
+ }
416
+
417
+ /**
418
+ * Add an attribute.
419
+ *
420
+ * @since 7.0
421
+ *
422
+ * @param string $key The attribute key.
423
+ * @param string $value The attribute value.
424
+ */
425
+ public function add_attribute( $key, $value = null ) {
426
+ $this->attributes[ $key ] = $value;
427
+ }
428
+
429
+ /**
430
+ * Remove an attribute.
431
+ *
432
+ * @since 7.0
433
+ *
434
+ * @param string $key The attribute key.
435
+ */
436
+ public function remove_attribute( $key ) {
437
+ if ( isset( $this->attributes[ $key ] ) ) {
438
+ unset( $this->attributes[ $key ] );
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Get an attribute.
444
+ *
445
+ * @since 7.0
446
+ *
447
+ * @param string $key The attribute key.
448
+ * @return string|bool The attribute value or false if it doesn't exist.
449
+ */
450
+ public function get_attribute( $key ) {
451
+ if ( isset( $this->attributes[ $key ] ) ) {
452
+ return $this->attributes[ $key ];
453
+ }
454
+ return false;
455
+ }
456
+
457
+ /**
458
+ * Get all attributes.
459
+ *
460
+ * @since 7.0
461
+ *
462
+ * @return array The field attributes.
463
+ */
464
+ public function get_attributes() {
465
+ return $this->attributes;
466
+ }
467
+
468
+ /**
469
+ * Set the priority.
470
+ *
471
+ * @since 7.0
472
+ *
473
+ * @param int $priority The field priority.
474
+ */
475
+ public function set_priority( $priority ) {
476
+ $this->priority = (int) $priority;
477
+ }
478
+
479
+ /**
480
+ * Get the priority.
481
+ *
482
+ * @since 7.0
483
+ *
484
+ * @return int The field priority.
485
+ */
486
+ public function get_priority() {
487
+ return $this->priority;
488
+ }
489
+
490
+ /**
491
+ * Render the field.
492
+ *
493
+ * @since 7.0
494
+ *
495
+ * @param array $args {
496
+ * Optional. An array of arguments for rendering a form field.
497
+ *
498
+ * @type string $before The content to render before the field.
499
+ * @type string $after The content to render after the field.
500
+ * @type string $control_before The content to render before the control.
501
+ * @type string $control_after The content to render after the control.
502
+ * }
503
+ */
504
+ public function render( $args = array() ) {
505
+ $is_hidden = ( 'hidden' == $this->get_type() );
506
+
507
+ $defaults = wp_parse_args( $this->render_args, array(
508
+ 'before' => $is_hidden ? '' : '<div class="tml-field-wrap tml-%s-wrap">',
509
+ 'after' => $is_hidden ? '' : '</div>',
510
+ 'control_before' => '',
511
+ 'control_after' => '',
512
+ ) );
513
+
514
+ $args = wp_parse_args( $args, $defaults );
515
+
516
+ $output = '';
517
+
518
+ if ( ! empty( $args['before'] ) ) {
519
+ $output .= sprintf( $args['before'], $this->get_name() ) . "\n";
520
+ }
521
+
522
+ $attributes = '';
523
+ foreach ( $this->get_attributes() as $key => $value ) {
524
+ $attributes .= ' ' . $key . '="' . esc_attr( $value ) . '"';
525
+ }
526
+
527
+ $label = '';
528
+ if ( $this->get_label() ) {
529
+ if ( $this->get_attribute( 'id' ) ) {
530
+ $label = sprintf(
531
+ '<label class="tml-label" for="%1$s">%2$s</label>',
532
+ $this->get_attribute( 'id' ),
533
+ $this->get_label()
534
+ ) . "\n";
535
+ } else {
536
+ $label = sprintf(
537
+ '<span class="tml-label">%s</span>',
538
+ $this->get_label()
539
+ ) . "\n";
540
+ }
541
+ }
542
+
543
+ $error = '';
544
+ if ( $this->get_error() ) {
545
+ $error = '<span class="tml-error">' . $this->get_error() . '</span>';
546
+ }
547
+
548
+ switch ( $this->get_type() ) {
549
+ case 'custom' :
550
+ $output .= $this->get_content();
551
+ break;
552
+
553
+ case 'checkbox' :
554
+ $output .= $args['control_before'];
555
+ $output .= '<input name="' . $this->get_name() . '" type="checkbox" value="' . esc_attr( $this->get_value() ) . '"' . $attributes . ">\n";
556
+ $output .= $args['control_after'];
557
+ $output .= $label;
558
+ break;
559
+
560
+ case 'radio-group' :
561
+ $output .= $label;
562
+ $output .= $error;
563
+ $output .= $args['control_before'];
564
+
565
+ $options = array();
566
+ foreach ( $this->get_options() as $value => $label ) {
567
+ $id = $this->get_name() . '_' . $value;
568
+
569
+ $option = '<input name="' . $this->get_name() . '" id="' . $id . '" type="radio" value="' . esc_attr( $value ) . '"' . $attributes;
570
+ if ( $this->get_value() == $value ) {
571
+ $option .= ' checked="checked"';
572
+ }
573
+ $option .= '>' . "\n";
574
+ $option .= '<label class="tml-label" for="' . $id . '">' . esc_html( $label ) . "</label>\n";
575
+
576
+ $options[] = $option;
577
+ }
578
+ $output .= implode( '<br />', $options );
579
+
580
+ $output .= $args['control_after'];
581
+ break;
582
+
583
+ case 'dropdown' :
584
+ $output .= $label;
585
+ $output .= $error;
586
+ $output .= $args['control_before'];
587
+ $output .= '<select name="' . $this->get_name() . '"' . $attributes . ">\n";
588
+ foreach ( $this->get_options() as $value => $option ) {
589
+ $output .= '<option value="' . esc_attr( $value ) . '"';
590
+ if ( $this->get_value() == $value ) {
591
+ $output .= ' selected="selected"';
592
+ }
593
+ $output .= '>' . esc_html( $option ) . "</option>\n";
594
+ }
595
+ $output .= "</select>\n";
596
+ $output .= $args['control_after'];
597
+ break;
598
+
599
+ case 'textarea' :
600
+ $output .= $label;
601
+ $output .= $args['control_before'];
602
+ $output .= '<textarea name="' . $this->get_name() . '"' . $attributes . '>' . $this->get_value() . "</textarea>\n";
603
+ $output .= $args['control_after'];
604
+ break;
605
+
606
+ default :
607
+ $output .= $label;
608
+ $output .= $error;
609
+ $output .= $args['control_before'];
610
+ $output .= '<input name="' . $this->get_name() . '" type="' . $this->get_type() . '" value="' . esc_attr( $this->get_value() ) . '"' . $attributes . ">\n";
611
+ $output .= $args['control_after'];
612
+ }
613
+
614
+ if ( $this->get_description() ) {
615
+ $output .= '<span class="tml-description">' . $this->get_description() . "</span>\n";
616
+ }
617
+
618
+ if ( ! empty( $args['after'] ) ) {
619
+ $output .= $args['after'] . "\n";
620
+ }
621
+
622
+ return $output;
623
+ }
624
+ }
includes/class-theme-my-login-form.php ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Form Class
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Forms
8
+ */
9
+
10
+ /**
11
+ * Class used to implement the form object.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ class Theme_My_Login_Form {
16
+
17
+ /**
18
+ * The form name.
19
+ *
20
+ * @var string
21
+ */
22
+ protected $name;
23
+
24
+ /**
25
+ * The form action.
26
+ *
27
+ * @var string
28
+ */
29
+ protected $action;
30
+
31
+ /**
32
+ * The form method.
33
+ *
34
+ * @var string
35
+ */
36
+ protected $method;
37
+
38
+ /**
39
+ * The form fields.
40
+ *
41
+ * @var array
42
+ */
43
+ protected $fields = array();
44
+
45
+ /**
46
+ * The form field priorities.
47
+ *
48
+ * @var array
49
+ */
50
+ protected $priorities = array();
51
+
52
+ /**
53
+ * The form attributes.
54
+ *
55
+ * @var array
56
+ */
57
+ protected $attributes = array();
58
+
59
+ /**
60
+ * The form errors.
61
+ *
62
+ * @var WP_Error
63
+ */
64
+ protected $errors;
65
+
66
+ /**
67
+ * The form links.
68
+ *
69
+ * @var array
70
+ */
71
+ protected $links = array();
72
+
73
+ /**
74
+ * The arguments used for rendering the field.
75
+ *
76
+ * @see Theme_My_Login_Form::render()
77
+ *
78
+ * @var array
79
+ */
80
+ public $render_args = array();
81
+
82
+ /**
83
+ * Create a new instance.
84
+ *
85
+ * @since 7.0
86
+ *
87
+ * @param string $name The form name.
88
+ * @param array $args {
89
+ * Optional. An array of arguments.
90
+ *
91
+ * @type string $action The form action. Default empty.
92
+ * @type string $method The form method. Default 'post'.
93
+ * }
94
+ */
95
+ public function __construct( $name, $args = array() ) {
96
+
97
+ $this->set_name( $name );
98
+
99
+ $args = wp_parse_args( $args, array(
100
+ 'action' => '',
101
+ 'method' => 'post',
102
+ ) );
103
+
104
+ $this->set_action( $args['action'] );
105
+ $this->set_method( $args['method'] );
106
+
107
+ $this->errors = new WP_Error;
108
+
109
+ // Add the default links
110
+ foreach ( tml_get_actions() as $action ) {
111
+ if ( $action->show_on_forms && $action->get_name() != $this->get_name() ) {
112
+ $this->add_link( $action->get_name(), array(
113
+ 'text' => true === $action->show_on_forms ? $action->get_title() : $action->show_on_forms,
114
+ 'url' => $action->get_url(),
115
+ ) );
116
+ }
117
+ }
118
+
119
+ if ( ! empty( $args['render_args'] ) ) {
120
+ $this->render_args = $args['render_args'];
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Get the form name.
126
+ *
127
+ * @since 7.0
128
+ *
129
+ * @return string The form name.
130
+ */
131
+ public function get_name() {
132
+ return $this->name;
133
+ }
134
+
135
+ /**
136
+ * Set the form name.
137
+ *
138
+ * @since 7.0
139
+ *
140
+ * @param string $name The form name.
141
+ */
142
+ protected function set_name( $name ) {
143
+ $this->name = sanitize_key( $name );
144
+ }
145
+
146
+ /**
147
+ * Get the form action.
148
+ *
149
+ * @since 7.0
150
+ *
151
+ * @return string The form action.
152
+ */
153
+ public function get_action() {
154
+ /**
155
+ * Filters the form action.
156
+ *
157
+ * @since 7.0
158
+ *
159
+ * @param string $action The form action.
160
+ * @param Theme_My_Login_Form $this The form object.
161
+ */
162
+ return apply_filters( 'tml_get_form_action', $this->action, $this );
163
+ }
164
+
165
+ /**
166
+ * Set the form action.
167
+ *
168
+ * @since 7.0
169
+ *
170
+ * @param string $action The form action.
171
+ */
172
+ public function set_action( $action ) {
173
+ $this->action = $action;
174
+ }
175
+
176
+ /**
177
+ * Get the form method.
178
+ *
179
+ * @since 7.0
180
+ *
181
+ * @return string The form method.
182
+ */
183
+ public function get_method() {
184
+ /**
185
+ * Filters the form method.
186
+ *
187
+ * @since 7.0
188
+ *
189
+ * @param string $method The form method.
190
+ * @param Theme_My_Login_Form $this The form object.
191
+ */
192
+ return apply_filters( 'tml_get_form_method', $this->method, $this );
193
+ }
194
+
195
+ /**
196
+ * Set the form method.
197
+ *
198
+ * @since 7.0
199
+ *
200
+ * @param string $method The form method.
201
+ */
202
+ public function set_method( $method ) {
203
+ $method = strtolower( $method );
204
+ if ( ! in_array( $method, array( 'get', 'post' ) ) ) {
205
+ $method = 'post';
206
+ }
207
+ $this->method = $method;
208
+ }
209
+
210
+ /**
211
+ * Add an attribute.
212
+ *
213
+ * @since 7.0
214
+ *
215
+ * @param string $key The attribute key.
216
+ * @param string $value The attribute value.
217
+ */
218
+ public function add_attribute( $key, $value = null ) {
219
+ $this->attributes[ $key ] = $value;
220
+ }
221
+
222
+ /**
223
+ * Remove an attribute.
224
+ *
225
+ * @since 7.0
226
+ *
227
+ * @param string $key The attribute key.
228
+ */
229
+ public function remove_attribute( $key ) {
230
+ if ( isset( $this->attributes[ $key ] ) ) {
231
+ unset( $this->attributes[ $key ] );
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Get an attribute.
237
+ *
238
+ * @since 7.0
239
+ *
240
+ * @param string $key The attribute key.
241
+ * @return string|bool The attribute value or false if it doesn't exist.
242
+ */
243
+ public function get_attribute( $key ) {
244
+ if ( isset( $this->attributes[ $key ] ) ) {
245
+ return $this->attributes[ $key ];
246
+ }
247
+ return false;
248
+ }
249
+
250
+ /**
251
+ * Get all attributes.
252
+ *
253
+ * @since 7.0
254
+ *
255
+ * @return array The form attributes.
256
+ */
257
+ public function get_attributes() {
258
+ return $this->attributes;
259
+ }
260
+
261
+ /**
262
+ * Add a field.
263
+ *
264
+ * @since 7.0
265
+ *
266
+ * @param TML_Form_Field $field The field object.
267
+ */
268
+ public function add_field( Theme_My_Login_Form_Field $field ) {
269
+ $name = $field->get_name();
270
+
271
+ $this->fields[ $name ] = $field;
272
+
273
+ $priority = $field->get_priority();
274
+ if ( ! isset( $this->priorities[ $priority ] ) ) {
275
+ $this->priorities[ $priority ] = array();
276
+ }
277
+ $this->priorities[ $priority ][] = $name;
278
+ }
279
+
280
+ /**
281
+ * Remove a field.
282
+ *
283
+ * @since 7.0
284
+ *
285
+ * @param string|Theme_My_Login_Form_Field $field The field name or object.
286
+ */
287
+ public function remove_field( $field ) {
288
+ if ( $field instanceof Theme_My_Login_Form_Field ) {
289
+ unset( $this->fields[ $field->get_name() ] );
290
+ } else {
291
+ unset( $this->fields[ $field ] );
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Get a field.
297
+ *
298
+ * @since 7.0
299
+ *
300
+ * @param string $field The field name.
301
+ * @return Theme_My_Login_Form_Field|bool The field object if it exists or false otherwise.
302
+ */
303
+ public function get_field( $field ) {
304
+ if ( isset( $this->fields[ $field ] ) ) {
305
+ return $this->fields[ $field ];
306
+ }
307
+ return false;
308
+ }
309
+
310
+ /**
311
+ * Get all fields.
312
+ *
313
+ * @since 7.0
314
+ *
315
+ * @return array The form fields.
316
+ */
317
+ public function get_fields() {
318
+ ksort( $this->priorities );
319
+
320
+ $sorted_fields = array();
321
+ foreach ( $this->priorities as $priority => $fields ) {
322
+ foreach ( $fields as $field ) {
323
+ $sorted_fields[] = $this->get_field( $field );
324
+ }
325
+ }
326
+
327
+ return $sorted_fields;
328
+ }
329
+
330
+ /**
331
+ * Add an error.
332
+ *
333
+ * @since 7.0
334
+ *
335
+ * @param string $code The error code.
336
+ * @param string $message The error message.
337
+ * @param string $severity The error severity.
338
+ */
339
+ public function add_error( $code, $message, $severity = 'error' ) {
340
+ $this->errors->add( $code, $message, $severity );
341
+ }
342
+
343
+ /**
344
+ * Get the errors.
345
+ *
346
+ * @since 7.0
347
+ *
348
+ * @return WP_Error The form errors.
349
+ */
350
+ public function get_errors() {
351
+ return $this->errors;
352
+ }
353
+
354
+ /**
355
+ * Set the errors.
356
+ *
357
+ * @since 7.0
358
+ *
359
+ * @param WP_Error $errors The errors.
360
+ */
361
+ public function set_errors( WP_Error $errors ) {
362
+ $this->errors = $errors;
363
+ }
364
+
365
+ /**
366
+ * Determine if the form has errors.
367
+ *
368
+ * @since 7.0
369
+ *
370
+ * @return bool True if the form has errors, false if not.
371
+ */
372
+ public function has_errors() {
373
+ return (bool) $this->errors->get_error_code();
374
+ }
375
+
376
+ /**
377
+ * Render the errors.
378
+ *
379
+ * @since 7.0
380
+ *
381
+ * @return string The errors markup.
382
+ */
383
+ public function render_errors() {
384
+
385
+ if ( ! $this->has_errors() ) {
386
+ return;
387
+ }
388
+
389
+ $errors = array();
390
+ $messages = array();
391
+
392
+ foreach ( $this->errors->get_error_codes() as $code ) {
393
+
394
+ $severity = $this->errors->get_error_data( $code );
395
+
396
+ foreach ( $this->errors->get_error_messages( $code ) as $error ) {
397
+ if ( 'message' == $severity ) {
398
+ $messages[] = $error;
399
+ } else {
400
+ $errors[] = $error;
401
+ }
402
+ }
403
+ }
404
+
405
+ $output = '';
406
+
407
+ if ( ! empty( $errors ) ) {
408
+ $output .= sprintf( '<ul class="tml-errors"><li class="tml-error">%s</li></ul>',
409
+ apply_filters( 'login_errors', implode( "</li>\n<li class=\"tml-error\">", $errors ) )
410
+ );
411
+ }
412
+
413
+ if ( ! empty( $messages ) ) {
414
+ $output .= sprintf( '<ul class="tml-messages"><li class="tml-message">%s</li></ul>',
415
+ apply_filters( 'login_messages', implode( "</li>\n<li class=\"tml-message\">", $messages ) )
416
+ );
417
+ }
418
+
419
+ return $output;
420
+ }
421
+
422
+ /**
423
+ * Add a link.
424
+ *
425
+ * @since 7.0
426
+ *
427
+ * @param string $link The link name.
428
+ * @param array $args {
429
+ * Optional. An array of arguments for adding a link.
430
+ *
431
+ * @type string $text The link text.
432
+ * @type string $url The link URL.
433
+ * }
434
+ */
435
+ public function add_link( $link, $args = array() ) {
436
+ $args = wp_parse_args( $args, array(
437
+ 'text' => '',
438
+ 'url' => '',
439
+ ) );
440
+
441
+ $link = sanitize_key( $link );
442
+
443
+ $this->links[ $link ] = $args;
444
+ }
445
+
446
+ /**
447
+ * Remove a link.
448
+ *
449
+ * @since 7.0
450
+ *
451
+ * @param string $link The link name.
452
+ */
453
+ public function remove_link( $link ) {
454
+ unset( $this->links[ $link ] );
455
+ }
456
+
457
+ /**
458
+ * Get a link.
459
+ *
460
+ * @since 7.0
461
+ *
462
+ * @param string $link The link name.
463
+ * @return array|bool The link data if it exists or false otherwise.
464
+ */
465
+ public function get_link( $link ) {
466
+ if ( isset( $this->links[ $link ] ) ) {
467
+ return $this->links[ $link ];
468
+ }
469
+ return false;
470
+ }
471
+
472
+ /**
473
+ * Get all links.
474
+ *
475
+ * @since 7.0
476
+ *
477
+ * @return array The form links.
478
+ */
479
+ public function get_links() {
480
+ /**
481
+ * Filter the form links.
482
+ *
483
+ * @since 7.0
484
+ *
485
+ * @param array $links The form links.
486
+ * @param Theme_My_Login_Form $this The form object.
487
+ */
488
+ return apply_filters( 'tml_get_form_links', $this->links, $this );
489
+ }
490
+
491
+ /**
492
+ * Render the links.
493
+ *
494
+ * @since 7.0
495
+ *
496
+ * @return string The links markup.
497
+ */
498
+ public function render_links() {
499
+
500
+ if ( ! $links = $this->get_links() ) {
501
+ return;
502
+ }
503
+
504
+ $output = '<ul class="tml-links">';
505
+
506
+ foreach ( $links as $name => $link ) {
507
+ $output .= sprintf( '<li class="tml-%s-link"><a href="%s">%s</a></li>',
508
+ esc_attr( $name ),
509
+ esc_url( $link['url'] ),
510
+ esc_html( $link['text'] )
511
+ );
512
+ }
513
+
514
+ $output .= '</ul>';
515
+
516
+ return $output;
517
+ }
518
+
519
+ /**
520
+ * Render the form.
521
+ *
522
+ * @since 7.0
523
+ *
524
+ * @param array $args {
525
+ * Optional. An array of arguments for rendering a form.
526
+ *
527
+ * @type string $container The form container element.
528
+ * @type string $container_class The form container class.
529
+ * @type string $container_id The form container ID.
530
+ * @type string $before The content to render before the form.
531
+ * @type string $after The content to render after the form.
532
+ * }
533
+ * @return string The form markup.
534
+ */
535
+ public function render( $args = array() ) {
536
+ $defaults = wp_parse_args( $this->render_args, array(
537
+ 'container' => 'div',
538
+ 'container_class' => 'tml tml-%s',
539
+ 'container_id' => '',
540
+ 'before' => '',
541
+ 'after' => '',
542
+ 'show_links' => true,
543
+ ) );
544
+
545
+ $args = wp_parse_args( $args, $defaults );
546
+
547
+ $output = $args['before'];
548
+
549
+ if ( ! empty( $args['container'] ) ) {
550
+ $output .= '<' . $args['container'];
551
+ if ( ! empty( $args['container_id'] ) ) {
552
+ $output .= ' id="' . esc_attr( sprintf( $args['container_id'], $this->name ) ) . '"';
553
+ }
554
+ if ( ! empty( $args['container_class'] ) ) {
555
+ $output .= ' class="' . esc_attr( sprintf( $args['container_class'], $this->name ) ) . '"';
556
+ }
557
+ $output .= ">\n";
558
+ }
559
+
560
+ $output .= $this->render_errors();
561
+
562
+ $output .= '<form name="' . esc_attr( $this->get_name() ) . '" action="' . esc_url( $this->get_action() ) . '" method="' . esc_attr( $this->get_method() ) . '"';
563
+ foreach ( $this->get_attributes() as $key => $value ) {
564
+ $output .= ' ' . $key . '="' . esc_attr( $value ) . '"';
565
+ }
566
+ $output .= ">\n";
567
+
568
+ foreach ( $this->get_fields() as $field ) {
569
+ $output .= $field->render() . "\n";
570
+ }
571
+
572
+ $output .= "</form>\n";
573
+
574
+ $output .= $args['after'];
575
+
576
+ if ( $args['show_links'] ) {
577
+ $output .= $this->render_links();
578
+ }
579
+
580
+ if ( ! empty( $args['container'] ) ) {
581
+ $output .= '</' . $args['container'] . ">\n";
582
+ }
583
+
584
+ return $output;
585
+ }
586
+ }
includes/class-theme-my-login-ms-signup.php DELETED
@@ -1,567 +0,0 @@
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( $current_site->blog_id );
547
-
548
- $url = Theme_My_Login::get_object()->site_url( $url, $path, $orig_scheme );
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 DELETED
@@ -1,600 +0,0 @@
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' => 'login',
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 'confirmaction':
119
- echo '<div class="tml">' . _wp_privacy_account_request_confirmed_message( $_GET['request_id'] ) . '</div>';
120
- break;
121
- case 'login':
122
- default :
123
- if ( $this->get_option( 'login_template' ) )
124
- $template[] = $this->get_option( 'login_template' );
125
- $template[] = 'login-form.php';
126
- }
127
- }
128
- $this->get_template( $template );
129
- }
130
- echo $this->get_option( 'after_widget' ) . "\n";
131
- $output = ob_get_contents();
132
- ob_end_clean();
133
- return apply_filters_ref_array( 'tml_display', array( $output, $action, $this ) );
134
- }
135
-
136
- /**
137
- * Returns action title
138
- *
139
- * @since 6.0
140
- * @access public
141
- *
142
- * @param string $action The action to retrieve. Defaults to current action.
143
- * @return string Title of $action
144
- */
145
- public function get_title( $action = '' ) {
146
- if ( empty( $action ) )
147
- $action = $this->get_option( 'default_action' );
148
-
149
- if ( is_admin() )
150
- return;
151
-
152
- if ( is_user_logged_in() && 'login' == $action && $action == $this->get_option( 'default_action' ) ) {
153
- $title = sprintf( __( 'Welcome, %s', 'theme-my-login' ), wp_get_current_user()->display_name );
154
- } else {
155
- if ( $page_id = Theme_My_Login::get_page_id( $action ) ) {
156
- $title = get_post_field( 'post_title', $page_id );
157
- } else {
158
- switch ( $action ) {
159
- case 'register':
160
- $title = __( 'Register', 'theme-my-login' );
161
- break;
162
- case 'lostpassword':
163
- case 'retrievepassword':
164
- case 'resetpass':
165
- case 'rp':
166
- $title = __( 'Lost Password', 'theme-my-login' );
167
- break;
168
- case 'confirmaction':
169
- $title = __( 'Your Data Request', 'theme-my-login' );
170
- break;
171
- case 'login':
172
- default:
173
- $title = __( 'Log In', 'theme-my-login' );
174
- }
175
- }
176
- }
177
- return apply_filters( 'tml_title', $title, $action );
178
- }
179
-
180
- /**
181
- * Outputs action title
182
- *
183
- * @since 6.0
184
- * @access public
185
- *
186
- * @param string $action The action to retieve. Defaults to current action.
187
- */
188
- public function the_title( $action = '' ) {
189
- echo $this->get_title( $action );
190
- }
191
-
192
- /**
193
- * Returns plugin errors
194
- *
195
- * @since 6.0
196
- * @access public
197
- */
198
- public function get_errors() {
199
- global $error;
200
-
201
- $theme_my_login = Theme_My_Login::get_object();
202
-
203
- $wp_error = $theme_my_login->errors;
204
-
205
- if ( empty( $wp_error ) )
206
- $wp_error = new WP_Error();
207
-
208
- // Incase a plugin uses $error rather than the $errors object
209
- if ( ! empty( $error ) ) {
210
- $wp_error->add('error', $error);
211
- unset($error);
212
- }
213
-
214
- $output = '';
215
- if ( $this->is_active() ) {
216
- if ( $wp_error->get_error_code() ) {
217
- $errors = '';
218
- $messages = '';
219
- foreach ( $wp_error->get_error_codes() as $code ) {
220
- $severity = $wp_error->get_error_data( $code );
221
- foreach ( $wp_error->get_error_messages( $code ) as $error ) {
222
- if ( 'message' == $severity )
223
- $messages .= ' ' . $error . "<br />\n";
224
- else
225
- $errors .= ' ' . $error . "<br />\n";
226
- }
227
- }
228
- if ( ! empty( $errors ) )
229
- $output .= '<p class="error">' . apply_filters( 'login_errors', $errors ) . "</p>\n";
230
- if ( ! empty( $messages ) )
231
- $output .= '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n";
232
- }
233
- }
234
- return $output;
235
- }
236
-
237
- /**
238
- * Prints plugin errors
239
- *
240
- * @since 6.0
241
- * @access public
242
- */
243
- public function the_errors() {
244
- echo $this->get_errors();
245
- }
246
-
247
- /**
248
- * Returns requested action URL
249
- *
250
- * @since 6.0
251
- * @access public
252
- *
253
- * @param string $action Action to retrieve
254
- * @param string $scheme Scheme to give the URL context
255
- * @return string The requested action URL
256
- */
257
- public function get_action_url( $action = '', $scheme = 'login' ) {
258
-
259
- $instance = $this->get_option( 'instance' );
260
-
261
- if ( $action == $this->get_option( 'default_action' ) ) {
262
- $args = array();
263
- if ( $instance )
264
- $args['instance'] = $instance;
265
- $url = Theme_My_Login_Common::get_current_url( $args );
266
- } else {
267
- $url = Theme_My_Login::get_page_link( $action );
268
- }
269
-
270
- $url = set_url_scheme( $url, $scheme );
271
-
272
- return apply_filters( 'tml_action_url', $url, $action, $scheme, $instance );
273
- }
274
-
275
- /**
276
- * Outputs requested action URL
277
- *
278
- * @since 6.0
279
- * @access public
280
- *
281
- * @param string $action Action to retrieve
282
- * @param string $scheme Scheme to give the URL context
283
- */
284
- public function the_action_url( $action = 'login', $scheme = 'login' ) {
285
- echo esc_url( $this->get_action_url( $action, $scheme ) );
286
- }
287
-
288
- /**
289
- * Returns the action links
290
- *
291
- * @since 6.0
292
- * @access public
293
- *
294
- * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
295
- */
296
- public function get_action_links( $args = '' ) {
297
- $args = wp_parse_args( $args, array(
298
- 'login' => true,
299
- 'register' => true,
300
- 'lostpassword' => true
301
- ) );
302
-
303
- $action_links = array();
304
- if ( $args['login'] && $this->get_option( 'show_log_link' ) ) {
305
- $action_links[] = array(
306
- 'title' => $this->get_title( 'login' ),
307
- 'url' => $this->get_action_url( 'login' )
308
- );
309
- }
310
- if ( $args['register'] && $this->get_option( 'show_reg_link' ) && get_option( 'users_can_register' ) ) {
311
- $action_links[] = array(
312
- 'title' => $this->get_title( 'register' ),
313
- 'url' => $this->get_action_url( 'register' )
314
- );
315
- }
316
- if ( $args['lostpassword'] && $this->get_option( 'show_pass_link' ) ) {
317
- $action_links[] = array(
318
- 'title' => $this->get_title( 'lostpassword' ),
319
- 'url' => $this->get_action_url( 'lostpassword' )
320
- );
321
- }
322
- return apply_filters( 'tml_action_links', $action_links, $args );
323
- }
324
-
325
- /**
326
- * Outputs the action links
327
- *
328
- * @since 6.0
329
- * @access public
330
- *
331
- * @param array $args Optionally specify which actions to include/exclude. By default, all are included.
332
- */
333
- public function the_action_links( $args = '' ) {
334
- if ( $action_links = $this->get_action_links( $args ) ) {
335
- echo '<ul class="tml-action-links">' . "\n";
336
- foreach ( (array) $action_links as $link ) {
337
- echo '<li><a href="' . esc_url( $link['url'] ) . '" rel="nofollow">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
338
- }
339
- echo '</ul>' . "\n";
340
- }
341
- }
342
-
343
- /**
344
- * Returns logged-in user links
345
- *
346
- * @since 6.0
347
- * @access public
348
- *
349
- * @return array Logged-in user links
350
- */
351
- public static function get_user_links() {
352
- $user_links = array(
353
- array(
354
- 'title' => __( 'Dashboard', 'theme-my-login' ),
355
- 'url' => admin_url() ),
356
- array(
357
- 'title' => __( 'Profile', 'theme-my-login' ),
358
- 'url' => admin_url( 'profile.php' )
359
- )
360
- );
361
- return apply_filters( 'tml_user_links', $user_links );
362
- }
363
-
364
- /**
365
- * Outputs logged-in user links
366
- *
367
- * @since 6.0
368
- * @access public
369
- */
370
- public function the_user_links() {
371
- echo '<ul class="tml-user-links">';
372
- foreach ( (array) self::get_user_links() as $link ) {
373
- echo '<li><a href="' . esc_url( $link['url'] ) . '">' . esc_html( $link['title'] ) . '</a></li>' . "\n";
374
- }
375
- echo '<li><a href="' . wp_logout_url() . '">' . self::get_title( 'logout' ) . '</a></li>' . "\n";
376
- echo '</ul>';
377
- }
378
-
379
- /**
380
- * Displays user avatar
381
- *
382
- * @since 6.0
383
- * @access public
384
- */
385
- public function the_user_avatar( $size = '' ) {
386
- if ( empty( $size ) )
387
- $size = $this->get_option( 'gravatar_size', 50 );
388
-
389
- $current_user = wp_get_current_user();
390
-
391
- echo get_avatar( $current_user->ID, $size );
392
- }
393
-
394
- /**
395
- * Returns template message for requested action
396
- *
397
- * @since 6.0
398
- * @access public
399
- *
400
- * @param string $action Action to retrieve
401
- * @return string The requested template message
402
- */
403
- public static function get_action_template_message( $action = '' ) {
404
- switch ( $action ) {
405
- case 'register':
406
- $message = __( 'Register For This Site', 'theme-my-login' );
407
- break;
408
- case 'lostpassword':
409
- $message = __( 'Please enter your username or email address. You will receive a link to create a new password via email.', 'theme-my-login' );
410
- break;
411
- case 'resetpass':
412
- $message = __( 'Enter your new password below.', 'theme-my-login' );
413
- break;
414
- default:
415
- $message = '';
416
- }
417
- $message = apply_filters( 'login_message', $message );
418
-
419
- return apply_filters( 'tml_action_template_message', $message, $action );
420
- }
421
-
422
- /**
423
- * Outputs template message for requested action
424
- *
425
- * @since 6.0
426
- * @access public
427
- *
428
- * @param string $action Action to retrieve
429
- * @param string $before_message Text/HTML to add before the message
430
- * @param string $after_message Text/HTML to add after the message
431
- */
432
- public function the_action_template_message( $action = 'login', $before_message = '<p class="message">', $after_message = '</p>' ) {
433
- if ( $message = self::get_action_template_message( $action ) )
434
- echo $before_message . $message . $after_message;
435
- }
436
-
437
- /**
438
- * Locates specified template
439
- *
440
- * @since 6.0
441
- * @access public
442
- *
443
- * @param string|array $template_names The template(s) to locate
444
- * @param bool $load If true, the template will be included if found
445
- * @param array $args Array of extra variables to make available to template
446
- * @return string|bool Template path if found, false if not
447
- */
448
- public function get_template( $template_names, $load = true, $args = array() ) {
449
-
450
- $theme_my_login = Theme_My_Login::get_object();
451
-
452
- // User friendly access to this
453
- $template = $this;
454
-
455
- // Easy access to current user
456
- $current_user = wp_get_current_user();
457
-
458
- extract( apply_filters_ref_array( 'tml_template_args', array( $args, $this ) ) );
459
-
460
- $template_paths = apply_filters( 'tml_template_paths', array(
461
- get_stylesheet_directory() . '/theme-my-login',
462
- get_stylesheet_directory(),
463
- get_template_directory() . '/theme-my-login',
464
- get_template_directory(),
465
- THEME_MY_LOGIN_PATH . '/templates'
466
- ) );
467
-
468
- $located = '';
469
- foreach ( (array) $template_names as $template_name ) {
470
-
471
- if ( ! $template_name )
472
- continue;
473
-
474
- if ( preg_match( '/\/|\\\\/', $template_name ) )
475
- continue;
476
-
477
- foreach ( $template_paths as $template_path ) {
478
- if ( file_exists( $template_path . '/' . $template_name ) ) {
479
- $located = $template_path . '/' . $template_name;
480
- break 2;
481
- }
482
- }
483
- }
484
-
485
- $located = apply_filters_ref_array( 'tml_template', array( $located, $template_names, $this ) );
486
-
487
- if ( $load && '' != $located )
488
- include( $located );
489
-
490
- return $located;
491
- }
492
-
493
- /**
494
- * Returns the proper redirect URL according to action
495
- *
496
- * @since 6.0
497
- * @access public
498
- *
499
- * @param string $action The action
500
- * @return string The redirect URL
501
- */
502
- public function get_redirect_url( $action = '' ) {
503
-
504
- $theme_my_login = Theme_My_Login::get_object();
505
-
506
- if ( empty( $action ) )
507
- $action = $this->get_option( 'default_action' );
508
-
509
- $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '';
510
-
511
- switch ( $action ) {
512
- case 'lostpassword' :
513
- case 'retrievepassword' :
514
- $url = apply_filters( 'lostpassword_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=confirm' ) );
515
- break;
516
- case 'register' :
517
- $url = apply_filters( 'registration_redirect', ! empty( $redirect_to ) ? $redirect_to : Theme_My_Login::get_page_link( 'login', 'checkemail=registered' ) );
518
- break;
519
- case 'login' :
520
- default :
521
- $url = apply_filters( 'login_redirect', ! empty( $redirect_to ) ? $redirect_to : admin_url(), $redirect_to, null );
522
- }
523
- return apply_filters( 'tml_redirect_url', $url, $action );
524
- }
525
-
526
- /**
527
- * Outputs redirect URL
528
- *
529
- * @since 6.0
530
- * @access public
531
- *
532
- * @param string $action The action
533
- */
534
- public function the_redirect_url( $action = '' ) {
535
- echo esc_attr( $this->get_redirect_url( $action ) );
536
- }
537
-
538
- /**
539
- * Outputs current template instance ID
540
- *
541
- * @since 6.0
542
- * @access public
543
- */
544
- public function the_instance() {
545
- if ( $this->get_option( 'instance' ) )
546
- echo esc_attr( $this->get_option( 'instance' ) );
547
- }
548
-
549
- /**
550
- * Returns requested $value
551
- *
552
- * @since 6.0
553
- * @access public
554
- *
555
- * @param string $value The value to retrieve
556
- * @return string|bool The value if it exists, false if not
557
- */
558
- public function get_posted_value( $value ) {
559
- if ( $this->is_active() && isset( $_REQUEST[$value] ) )
560
- return stripslashes( $_REQUEST[$value] );
561
- return false;
562
- }
563
-
564
- /**
565
- * Outputs requested value
566
- *
567
- * @since 6.0
568
- * @access public
569
- *
570
- * @param string $value The value to retrieve
571
- */
572
- public function the_posted_value( $value ) {
573
- echo esc_attr( $this->get_posted_value( $value ) );
574
- }
575
-
576
- /**
577
- * Returns active status
578
- *
579
- * @since 6.3
580
- * @access public
581
- *
582
- * @return bool True if instance is active, false if not
583
- */
584
- public function is_active() {
585
- return $this->is_active;
586
- }
587
-
588
- /**
589
- * Sets active status
590
- *
591
- * @since 6.3
592
- * @access public
593
- *
594
- * @param bool $active Active status
595
- */
596
- public function set_active( $active = true ) {
597
- $this->is_active = $active;
598
- }
599
- }
600
- endif; // Class exists
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-theme-my-login-widget.php CHANGED
@@ -1,147 +1,138 @@
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
  /**
4
+ * Theme My Login Widget
5
  *
6
  * @package Theme_My_Login
7
+ * @subpackage Widgets
8
  */
9
 
10
+ /**
11
+ * Class used to implement the TML widget.
 
12
  *
13
  * @since 6.0
14
  */
15
  class Theme_My_Login_Widget extends WP_Widget {
16
+
17
  /**
18
+ * Construct the instance.
19
  *
20
  * @since 6.0
 
21
  */
22
+ public function __construct() {
23
+ parent::__construct( 'theme-my-login', __( 'Theme My Login', 'theme-my-login' ), array(
24
  'classname' => 'widget_theme_my_login',
25
+ 'description' => __( 'A login form for your site.', 'theme-my-login' ),
26
+ ) );
 
27
  }
28
 
29
  /**
30
+ * Render the widget.
31
  *
32
  * @since 6.0
 
33
  *
34
+ * @param array $args
35
+ * @param array $instance
36
  */
37
  public function widget( $args, $instance ) {
38
+ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? tml_get_action_title( $instance['action'] ) : $instance['title'], $instance, $this->id_base );
39
 
40
+ if ( is_user_logged_in() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  return;
42
+ }
43
 
44
+ if ( tml_is_action() ) {
 
45
  return;
46
+ }
47
 
48
+ echo $args['before_widget'];
49
 
50
+ if ( $title ) {
51
+ echo $args['before_title'] . $title . $args['after_title'];
52
+ }
53
+
54
+ echo tml_shortcode( array(
55
+ 'action' => $instance['action'],
56
+ 'show_links' => $instance['show_links'],
57
+ 'redirect_to' => $_SERVER['REQUEST_URI'],
58
+ ) );
59
+
60
+ echo $args['after_widget'];
61
  }
62
 
63
  /**
64
+ * Displays the widget admin form
65
  *
66
  * @since 6.0
67
  * @access public
68
  */
69
+ public function form( $instance ) {
70
+ $instance = wp_parse_args( $instance, array(
71
+ 'title' => '',
72
+ 'action' => 'login',
73
+ 'show_links' => true,
74
+ ) );
75
+
76
+ $actions = wp_list_filter( tml_get_actions(), array(
77
+ 'show_in_widget' => true,
78
+ ) );
79
+ ?>
80
+
81
+ <p>
82
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?>
83
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
84
+ </label>
85
+ </p>
86
+
87
+ <p>
88
+ <label for="<?php echo $this->get_field_id( 'action' ); ?>"><?php _e( 'Action:' ); ?>
89
+ <select class="widefat" id="<?php echo $this->get_field_id( 'action' ); ?>" name="<?php echo $this->get_field_name( 'action' ); ?>">
90
+ <?php foreach ( $actions as $action ) : ?>
91
+ <option value="<?php echo esc_attr( $action->get_name() ); ?>"<?php selected( $action->get_name(), $instance['action'] ); ?>><?php echo esc_html( $action->get_title() ); ?></option>
92
+ <?php endforeach; ?>
93
+ </select>
94
+ </label>
95
+ </p>
96
+
97
+ <p>
98
+ <input class="checkbox" id="<?php echo $this->get_field_id( 'show_links' ); ?>" name="<?php echo $this->get_field_name( 'show_links' ); ?>" type="checkbox" value="1"<?php checked( ! empty( $instance['show_links'] ) ); ?> />
99
+ <label for="<?php echo $this->get_field_id( 'show_links' ); ?>"><?php _e( 'Show action links?', 'theme-my-login' ); ?></label>
100
+ </p>
101
+
102
+ <?php
103
  }
104
 
105
  /**
106
+ * Updates the widget.
107
  *
108
  * @since 6.0
109
+ *
110
+ * @param array $new_instance The new settings.
111
+ * @param array $old_instance The old settings.
112
+ * @return array The updated settings.
113
  */
114
+ public function update( $new_instance, $old_instance ) {
115
+ $instance = $old_instance;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
+ $new_instance = wp_parse_args( (array) $new_instance, array(
118
+ 'title' => '',
119
+ 'action' => 'login',
120
+ 'show_links' => false,
121
+ ) );
122
 
123
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );
124
+ $instance['action'] = sanitize_text_field( $new_instance['action'] );
125
+ $instance['show_links'] = (bool) $new_instance['show_links'];
126
 
127
+ return $instance;
128
+ }
129
 
130
+ /**
131
+ * Register the widget.
132
+ *
133
+ * @since 7.0
134
+ */
135
+ public static function register() {
136
+ register_widget( 'Theme_My_Login_Widget' );
137
  }
138
  }
 
 
includes/class-theme-my-login.php CHANGED
@@ -1,1328 +1,391 @@
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.17';
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 the current instance being displayed
73
  *
74
- * @since 6.4.11
75
- * @access public
76
- * @var int
77
  */
78
- public $current_instance = 0;
79
 
80
  /**
81
- * Holds loaded instances
82
  *
83
- * @since 6.3
84
- * @access protected
85
  * @var array
86
  */
87
- protected $loaded_instances = array();
88
 
89
  /**
90
- * Returns singleton instance
91
  *
92
- * @since 6.3
93
- * @access public
94
- * @return object
95
  */
96
- public static function get_object( $class = null ) {
97
- return parent::get_object( __CLASS__ );
98
- }
99
 
100
  /**
101
- * Returns default options
102
- *
103
- * @since 6.3
104
- * @access public
105
  *
106
- * @return array Default options
107
  */
108
- public static function default_options() {
109
- return apply_filters( 'tml_default_options', array(
110
- 'enable_css' => true,
111
- 'login_type' => 'default',
112
- 'active_modules' => array(),
113
- 'dismissed_notices' => array(),
114
- 'allow_update' => false,
115
- ) );
116
- }
117
 
118
  /**
119
- * Returns default pages
120
- *
121
- * @since 6.3
122
- * @access public
123
  *
124
- * @return array Default pages
125
  */
126
- public static function default_pages() {
127
- return apply_filters( 'tml_default_pages', array(
128
- 'login' => __( 'Log In' , 'theme-my-login' ),
129
- 'logout' => __( 'Log Out' , 'theme-my-login' ),
130
- 'register' => __( 'Register' , 'theme-my-login' ),
131
- 'lostpassword' => __( 'Lost Password' , 'theme-my-login' ),
132
- 'resetpass' => __( 'Reset Password', 'theme-my-login' )
133
- ) );
134
- }
135
 
136
  /**
137
- * Loads the plugin
138
  *
139
- * @since 6.0
140
- * @access public
141
- */
142
- protected function load() {
143
-
144
- $this->request_action = isset( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : '';
145
- $this->request_instance = isset( $_REQUEST['instance'] ) ? (int) $_REQUEST['instance'] : 0;
146
-
147
- $this->load_instance();
148
-
149
- add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
150
- add_action( 'init', array( $this, 'init' ) );
151
- add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
152
- add_action( 'widgets_init', array( $this, 'widgets_init' ) );
153
- add_action( 'wp', array( $this, 'wp' ) );
154
- add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
155
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
156
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
157
- add_action( 'wp_head', array( $this, 'wp_head' ) );
158
- add_action( 'wp_footer', array( $this, 'wp_footer' ) );
159
- add_action( 'wp_print_footer_scripts', array( $this, 'wp_print_footer_scripts' ) );
160
-
161
- add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
162
- add_filter( 'logout_url', array( $this, 'logout_url' ), 10, 2 );
163
- add_filter( 'single_post_title', array( $this, 'single_post_title' ) );
164
- add_filter( 'the_title', array( $this, 'the_title' ), 10, 2 );
165
- add_filter( 'document_title_parts', array( $this, 'document_title_parts' ) );
166
- add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ) );
167
- add_filter( 'wp_list_pages_excludes', array( $this, 'wp_list_pages_excludes' ) );
168
- add_filter( 'page_link', array( $this, 'page_link' ), 10, 2 );
169
- add_filter( 'authenticate', array( $this, 'authenticate' ), 20, 3 );
170
-
171
- add_shortcode( 'theme-my-login', array( $this, 'shortcode' ) );
172
-
173
- if ( 'username' == $this->get_option( 'login_type' ) ) {
174
- remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
175
- } elseif ( 'email' == $this->get_option( 'login_type' ) ) {
176
- remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );
177
- }
178
- }
179
-
180
-
181
- /************************************************************************************************************************
182
- * Actions
183
- ************************************************************************************************************************/
184
-
185
- /**
186
- * Loads active modules
187
  *
188
- * @since 6.3
189
- * @access public
190
  */
191
- public function plugins_loaded() {
192
- foreach ( $this->get_option( 'active_modules', array() ) as $module ) {
193
- if ( file_exists( THEME_MY_LOGIN_PATH . '/modules/' . $module ) )
194
- include_once( THEME_MY_LOGIN_PATH . '/modules/' . $module );
195
  }
196
- do_action_ref_array( 'tml_modules_loaded', array( &$this ) );
197
- }
198
-
199
- /**
200
- * Initializes the plugin
201
- *
202
- * @since 6.0
203
- * @access public
204
- */
205
- public function init() {
206
- global $pagenow;
207
-
208
- load_plugin_textdomain( 'theme-my-login', false, plugin_basename( THEME_MY_LOGIN_PATH ) . '/languages' );
209
-
210
- $this->errors = new WP_Error();
211
-
212
- if ( ! is_admin() && 'wp-login.php' != $pagenow && $this->get_option( 'enable_css' ) )
213
- wp_enqueue_style( 'theme-my-login', self::get_stylesheet(), array( 'dashicons' ), $this->get_option( 'version' ) );
214
- }
215
-
216
- /**
217
- * Registers the widget
218
- *
219
- * @since 6.0
220
- * @access public
221
- */
222
- public function widgets_init() {
223
- if ( class_exists( 'Theme_My_Login_Widget' ) )
224
- register_widget( 'Theme_My_Login_Widget' );
225
  }
226
 
227
  /**
228
- * Used to add/remove filters from login page
229
  *
230
- * @since 6.1.1
231
- * @access public
232
- */
233
- public function wp() {
234
- if ( self::is_tml_page() ) {
235
-
236
- // Define the page being requested
237
- $this->request_page = self::get_page_action( get_the_id() );
238
- if ( empty( $this->request_action ) ) {
239
- $this->request_action = $this->request_page;
240
- }
241
-
242
- do_action( 'login_init' );
243
-
244
- remove_action( 'wp_head', 'feed_links', 2 );
245
- remove_action( 'wp_head', 'feed_links_extra', 3 );
246
- remove_action( 'wp_head', 'rsd_link' );
247
- remove_action( 'wp_head', 'wlwmanifest_link' );
248
- remove_action( 'wp_head', 'parent_post_rel_link', 10 );
249
- remove_action( 'wp_head', 'start_post_rel_link', 10 );
250
- remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
251
- remove_action( 'wp_head', 'rel_canonical' );
252
-
253
- // Don't index any of these forms
254
- add_action( 'login_head', 'wp_no_robots' );
255
-
256
- if ( force_ssl_admin() && ! is_ssl() ) {
257
- if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
258
- wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) );
259
- exit;
260
- } else {
261
- wp_redirect( 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
262
- exit;
263
- }
264
- }
265
-
266
- nocache_headers();
267
- }
268
- }
269
-
270
- /**
271
- * Exclude TML pages from search
272
  *
273
- * @since 6.1.13
274
- * @access public
275
  */
276
- public function pre_get_posts( $query ) {
277
-
278
- // Bail if in admin area
279
- if ( is_admin() )
280
- return;
281
-
282
- // Bail if not the main query
283
- if ( ! $query->is_main_query() )
284
- return;
285
-
286
- // Bail if not a search
287
- if ( ! $query->is_search )
288
- return;
289
 
290
- // Get the requested post type
291
- $post_type = $query->get( 'post_type' );
292
 
293
- // Bail if not querying pages
294
- if ( ! empty( $post_type ) && ! in_array( 'page', (array) $post_type ) )
295
- return;
296
 
297
- // Get TML pages
298
- $pages = get_posts( array(
299
- 'post_type' => 'page',
300
- 'post_status' => 'any',
301
- 'meta_key' => '_tml_action',
302
- 'posts_per_page' => -1
303
- ) );
304
-
305
- // Get the page IDs
306
- $pages = wp_list_pluck( $pages, 'ID' );
307
-
308
- // Get any currently exclude posts
309
- $excludes = (array) $query->get( 'post__not_in' );
310
-
311
- // Merge the excludes
312
- $excludes = array_merge( $excludes, $pages );
313
 
314
- // Set the excludes
315
- $query->set( 'post__not_in', $excludes );
316
  }
317
 
318
  /**
319
- * Proccesses the request
320
  *
321
- * Callback for "template_redirect" hook in template-loader.php
322
  *
323
- * @since 6.3
324
- * @access public
325
  */
326
- public function template_redirect() {
327
-
328
- do_action_ref_array( 'tml_request', array( &$this ) );
329
 
330
- // allow plugins to override the default actions, and to add extra actions if they want
331
- do_action( 'login_form_' . $this->request_action );
332
 
333
- if ( has_action( 'tml_request_' . $this->request_action ) ) {
334
- do_action_ref_array( 'tml_request_' . $this->request_action, array( &$this ) );
335
  } else {
336
- $http_post = ( 'POST' == $_SERVER['REQUEST_METHOD'] );
337
- switch ( $this->request_action ) {
338
- case 'postpass' :
339
- if ( ! array_key_exists( 'post_password', $_POST ) ) {
340
- wp_safe_redirect( wp_get_referer() );
341
- exit();
342
- }
343
-
344
- require_once( ABSPATH . 'wp-includes/class-phpass.php' );
345
- $hasher = new PasswordHash( 8, true );
346
-
347
- $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
348
- $referer = wp_get_referer();
349
- if ( $referer ) {
350
- $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
351
- } else {
352
- $secure = false;
353
- }
354
- setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
355
-
356
- wp_safe_redirect( wp_get_referer() );
357
- exit;
358
-
359
- break;
360
- case 'logout' :
361
- check_admin_referer( 'log-out' );
362
-
363
- $user = wp_get_current_user();
364
-
365
- wp_logout();
366
-
367
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
368
- $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
369
- } else {
370
- $redirect_to = site_url( 'wp-login.php?loggedout=true' );
371
- $requested_redirect_to = '';
372
- }
373
-
374
- $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
375
- wp_safe_redirect( $redirect_to );
376
- exit;
377
- break;
378
- case 'lostpassword' :
379
- case 'retrievepassword' :
380
- if ( $http_post ) {
381
- $this->errors = self::retrieve_password();
382
- if ( ! is_wp_error( $this->errors ) ) {
383
- $redirect_to = ! empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : site_url( 'wp-login.php?checkemail=confirm' );
384
- wp_safe_redirect( $redirect_to );
385
- exit;
386
- }
387
- }
388
-
389
- if ( isset( $_REQUEST['error'] ) ) {
390
- if ( 'invalidkey' == $_REQUEST['error'] )
391
- $this->errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.', 'theme-my-login' ) );
392
- elseif ( 'expiredkey' == $_REQUEST['error'] )
393
- $this->errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.', 'theme-my-login' ) );
394
- }
395
-
396
- do_action( 'lost_password' );
397
- break;
398
- case 'resetpass' :
399
- case 'rp' :
400
- // Dirty hack for now
401
- global $rp_login, $rp_key;
402
-
403
- $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
404
- if ( isset( $_GET['key'] ) ) {
405
- $value = sprintf( '%s:%s', wp_unslash( $_GET['login'] ), wp_unslash( $_GET['key'] ) );
406
- setcookie( $rp_cookie, $value, 0, '/', COOKIE_DOMAIN, is_ssl(), true );
407
- wp_safe_redirect( remove_query_arg( array( 'key', 'login' ) ) );
408
- exit;
409
- }
410
-
411
- if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
412
- list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
413
- $user = check_password_reset_key( $rp_key, $rp_login );
414
- if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key, $_POST['rp_key'] ) ) {
415
- $user = false;
416
- }
417
- } else {
418
- $user = false;
419
- }
420
-
421
- if ( ! $user || is_wp_error( $user ) ) {
422
- setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
423
- if ( $user && $user->get_error_code() === 'expired_key' )
424
- wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
425
- else
426
- wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
427
- exit;
428
- }
429
-
430
- if ( isset( $_POST['pass1'] ) && $_POST['pass1'] != $_POST['pass2'] )
431
- $this->errors->add( 'password_reset_mismatch', __( 'The passwords do not match.', 'theme-my-login' ) );
432
-
433
- do_action( 'validate_password_reset', $this->errors, $user );
434
-
435
- if ( ( ! $this->errors->get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
436
- reset_password( $user, $_POST['pass1'] );
437
- setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, '/', COOKIE_DOMAIN, is_ssl(), true );
438
- $redirect_to = site_url( 'wp-login.php?resetpass=complete' );
439
- wp_safe_redirect( $redirect_to );
440
- exit;
441
- }
442
-
443
- wp_enqueue_script( 'utils' );
444
- wp_enqueue_script( 'user-profile' );
445
- break;
446
- case 'register' :
447
- if ( ! get_option( 'users_can_register' ) ) {
448
- $redirect_to = site_url( 'wp-login.php?registration=disabled' );
449
- wp_redirect( $redirect_to );
450
- exit;
451
- }
452
-
453
- $user_login = '';
454
- $user_email = '';
455
- if ( $http_post ) {
456
- if ( 'email' == $this->get_option( 'login_type' ) ) {
457
- $user_login = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
458
- } else {
459
- $user_login = isset( $_POST['user_login'] ) ? $_POST['user_login'] : '';
460
- }
461
- $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
462
-
463
- $this->errors = register_new_user( $user_login, $user_email );
464
- if ( ! is_wp_error( $this->errors ) ) {
465
- $redirect_to = ! empty( $_POST['redirect_to'] ) ? $_POST['redirect_to'] : site_url( 'wp-login.php?checkemail=registered' );
466
- wp_safe_redirect( $redirect_to );
467
- exit;
468
- }
469
- }
470
- break;
471
- case 'confirmaction' :
472
- if ( ! isset( $_GET['request_id'] ) ) {
473
- wp_die( __( 'Invalid request.' ) );
474
- }
475
-
476
- $request_id = (int) $_GET['request_id'];
477
-
478
- if ( isset( $_GET['confirm_key'] ) ) {
479
- $key = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
480
- $result = wp_validate_user_request_key( $request_id, $key );
481
- } else {
482
- $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) );
483
- }
484
-
485
- if ( is_wp_error( $result ) ) {
486
- wp_die( $result );
487
- }
488
-
489
- do_action( 'user_request_action_confirmed', $request_id );
490
- break;
491
- case 'login' :
492
- default:
493
- $secure_cookie = '';
494
- $interim_login = isset( $_REQUEST['interim-login'] );
495
-
496
- // If the user wants ssl but the session is not ssl, force a secure cookie.
497
- if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
498
- $user_name = sanitize_user( $_POST['log'] );
499
- if ( $user = get_user_by( 'login', $user_name ) ) {
500
- if ( get_user_option( 'use_ssl', $user->ID ) ) {
501
- $secure_cookie = true;
502
- force_ssl_admin( true );
503
- }
504
- }
505
- }
506
-
507
- if ( ! empty( $_REQUEST['redirect_to'] ) ) {
508
- $redirect_to = $_REQUEST['redirect_to'];
509
- // Redirect to https if user wants ssl
510
- if ( $secure_cookie && false !== strpos( $redirect_to, 'wp-admin' ) )
511
- $redirect_to = preg_replace( '|^http://|', 'https://', $redirect_to );
512
- } else {
513
- $redirect_to = admin_url();
514
- }
515
-
516
- $reauth = empty( $_REQUEST['reauth'] ) ? false : true;
517
-
518
- if ( isset( $_POST['log'] ) || isset( $_GET['testcookie'] ) ) {
519
-
520
- $user = wp_signon( array(), $secure_cookie );
521
-
522
- $redirect_to = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
523
-
524
- if ( ! is_wp_error( $user ) && empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
525
- $redirect_to = add_query_arg( array(
526
- 'testcookie' => 1,
527
- 'redirect_to' => $redirect_to
528
- ) );
529
- wp_redirect( $redirect_to );
530
- exit;
531
- }
532
 
533
- if ( empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
534
- if ( headers_sent() ) {
535
- /* translators: 1: Browser cookie documentation URL, 2: Support forums URL */
536
- $user = new WP_Error(
537
- 'test_cookie', sprintf(
538
- __( '<strong>ERROR</strong>: Cookies are blocked due to unexpected output. For help, please see <a href="%1$s">this documentation</a> or try the <a href="%2$s">support forums</a>.' ),
539
- __( 'https://codex.wordpress.org/Cookies' ), __( 'https://wordpress.org/support/' )
540
- )
541
- );
542
- } elseif ( isset( $_GET['testcookie'] ) ) {
543
- // If cookies are disabled we can't log in even with a valid user+pass
544
- /* translators: 1: Browser cookie documentation URL */
545
- $user = new WP_Error(
546
- 'test_cookie', sprintf(
547
- __( '<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href="%s">enable cookies</a> to use WordPress.' ),
548
- __( 'https://codex.wordpress.org/Cookies' )
549
- )
550
- );
551
- }
552
- } else {
553
- $user = wp_get_current_user();
554
- }
555
 
556
- if ( ! is_wp_error( $user ) && ! $reauth ) {
557
- if ( ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) {
558
- // 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.
559
- if ( is_multisite() && ! get_active_blog_for_user( $user->ID ) && ! is_super_admin( $user->ID ) )
560
- $redirect_to = user_admin_url();
561
- elseif ( is_multisite() && ! $user->has_cap( 'read' ) )
562
- $redirect_to = get_dashboard_url( $user->ID );
563
- elseif ( ! $user->has_cap( 'edit_posts' ) )
564
- $redirect_to = $user->has_cap( 'read' ) ? admin_url( 'profile.php' ) : home_url();
565
-
566
- wp_redirect( $redirect_to );
567
- exit;
568
- }
569
- wp_safe_redirect( $redirect_to );
570
- exit;
571
- }
572
-
573
- $this->errors = $user;
574
- }
575
-
576
- // Clear errors if loggedout is set.
577
- if ( ! empty( $_GET['loggedout'] ) || $reauth )
578
- $this->errors = new WP_Error();
579
-
580
- if ( $interim_login ) {
581
- if ( ! $errors->get_error_code() )
582
- $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.', 'theme-my-login' ), 'message' );
583
- } else {
584
- // Some parts of this script use the main login form to display a message
585
- if ( isset( $_GET['loggedout'] ) && true == $_GET['loggedout'] )
586
- $this->errors->add( 'loggedout', __( 'You are now logged out.', 'theme-my-login' ), 'message' );
587
- elseif ( isset( $_GET['registration'] ) && 'disabled' == $_GET['registration'] )
588
- $this->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'theme-my-login' ) );
589
- elseif ( isset( $_GET['checkemail'] ) && 'confirm' == $_GET['checkemail'] )
590
- $this->errors->add( 'confirm', __( 'Check your email for the confirmation link.', 'theme-my-login' ), 'message' );
591
- elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
592
- $this->errors->add( 'newpass', __( 'Check your email for your new password.', 'theme-my-login' ), 'message' );
593
- elseif ( isset( $_GET['resetpass'] ) && 'complete' == $_GET['resetpass'] )
594
- $this->errors->add( 'password_reset', __( 'Your password has been reset.', 'theme-my-login' ), 'message' );
595
- elseif ( isset( $_GET['checkemail'] ) && 'registered' == $_GET['checkemail'] )
596
- $this->errors->add( 'registered', __( 'Registration complete. Please check your email.', 'theme-my-login' ), 'message' );
597
- elseif ( strpos( $redirect_to, 'about.php?updated' ) )
598
- $this->errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new.', 'theme-my-login' ), 'message' );
599
- }
600
-
601
- // Clear any stale cookies.
602
- if ( $reauth )
603
- wp_clear_auth_cookie();
604
- break;
605
- } // end switch
606
- } // endif has_filter()
607
- }
608
-
609
- /**
610
- * Calls "login_enqueue_scripts" on login page
611
- *
612
- * Callback for "wp_enqueue_scripts" hook
613
- *
614
- * @since 6.3
615
- */
616
- public function wp_enqueue_scripts() {
617
- if ( self::is_tml_page() )
618
- do_action( 'login_enqueue_scripts' );
619
- }
620
-
621
- /**
622
- * Calls "login_head" hook on login page
623
- *
624
- * Callback for "wp_head" hook
625
- *
626
- * @since 6.0
627
- * @access public
628
- */
629
- public function wp_head() {
630
- if ( self::is_tml_page() ) {
631
- // This is already attached to "wp_head"
632
- remove_action( 'login_head', 'wp_print_head_scripts', 9 );
633
-
634
- do_action( 'login_head' );
635
  }
636
  }
637
 
638
  /**
639
- * Calls "login_footer" hook on login page
640
  *
641
- * Callback for "wp_footer" hook
642
  *
643
- * @since 6.3
 
644
  */
645
- public function wp_footer() {
646
- if ( self::is_tml_page() ) {
647
- // This is already attached to "wp_footer"
648
- remove_action( 'login_footer', 'wp_print_footer_scripts', 20 );
649
-
650
- do_action( 'login_footer' );
651
  }
 
652
  }
653
 
654
  /**
655
- * Prints javascript in the footer
 
 
656
  *
657
- * @since 6.0
658
- * @access public
659
  */
660
- public function wp_print_footer_scripts() {
661
- if ( ! self::is_tml_page() )
662
- return;
663
-
664
- switch ( $this->request_action ) {
665
- case 'lostpassword' :
666
- case 'retrievepassword' :
667
- case 'register' :
668
- ?>
669
- <script type="text/javascript">
670
- try{document.getElementById('user_login').focus();}catch(e){}
671
- if(typeof wpOnload=='function')wpOnload()
672
- </script>
673
- <?php
674
- break;
675
- case 'resetpass' :
676
- case 'rp' :
677
- ?>
678
- <script type="text/javascript">
679
- try{document.getElementById('pass1').focus();}catch(e){}
680
- if(typeof wpOnload=='function')wpOnload()
681
- </script>
682
- <?php
683
- break;
684
- case 'login' :
685
- $user_login = '';
686
- if ( isset($_POST['log']) )
687
- $user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? esc_attr( stripslashes( $_POST['log'] ) ) : '';
688
- ?>
689
- <script type="text/javascript">
690
- function wp_attempt_focus() {
691
- setTimeout( function() {
692
- try {
693
- <?php if ( $user_login ) { ?>
694
- d = document.getElementById('user_pass');
695
- d.value = '';
696
- <?php } else { ?>
697
- d = document.getElementById('user_login');
698
- <?php if ( 'invalid_username' == $this->errors->get_error_code() ) { ?>
699
- if ( d.value != '' )
700
- d.value = '';
701
- <?php
702
- }
703
- } ?>
704
- d.focus();
705
- d.select();
706
- } catch(e){}
707
- }, 200 );
708
- }
709
-
710
- wp_attempt_focus();
711
- if(typeof wpOnload=='function')wpOnload()
712
- </script>
713
- <?php
714
- break;
715
- }
716
  }
717
 
718
- /************************************************************************************************************************
719
- * Filters
720
- ************************************************************************************************************************/
721
-
722
  /**
723
- * Rewrites URL's containing wp-login.php created by site_url()
724
  *
725
- * @since 6.0
726
- * @access public
727
  *
728
- * @param string $url The URL
729
- * @param string $path The path specified
730
- * @param string $orig_scheme The current connection scheme (HTTP/HTTPS)
731
- * @return string The modified URL
732
  */
733
- public function site_url( $url, $path, $orig_scheme ) {
734
- global $pagenow;
735
-
736
- // Bail if currently viewing wp-login.php
737
- if ( 'wp-login.php' == $pagenow )
738
- return $url;
739
-
740
- // Bail if the URL isn't a login URL
741
- if ( false === strpos( $url, 'wp-login.php' ) )
742
- return $url;
743
 
744
- // Parse the query string from the URL
745
- parse_str( parse_url( $url, PHP_URL_QUERY ), $query );
746
 
747
  /**
748
- * Bail if the URL is an interim-login URL
749
  *
750
- * This only works using the javascript workaround as implemented in
751
- * admin/theme-my-login-admin.php and admin/js/theme-my-login-admin.js.
752
  *
753
- * @see http://core.trac.wordpress.org/ticket/31821
 
754
  */
755
- if ( isset( $query['interim-login'] ) )
756
- return $url;
757
 
758
- // Determine the action
759
- $action = isset( $query['action'] ) ? $query['action'] : 'login';
760
-
761
- // Get the action's page link
762
- $url = self::get_page_link( $action, $query );
763
-
764
- // Change the connection scheme to HTTPS, if needed
765
- if ( 'https' == strtolower( $orig_scheme ) )
766
- $url = preg_replace( '|^http://|', 'https://', $url );
767
-
768
- return $url;
769
  }
770
 
771
  /**
772
- * Filters logout URL to allow for logout permalink
773
  *
774
- * This is needed because WP doesn't pass the action parameter to site_url
775
  *
776
- * @since 6.3
777
- * @access public
778
- *
779
- * @param string $logout_url Logout URL
780
- * @param string $redirect Redirect URL
781
- * @return string Logout URL
782
  */
783
- public function logout_url( $logout_url, $redirect ) {
784
- $logout_url = self::get_page_link( 'logout' );
785
- if ( $redirect )
786
- $logout_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $logout_url );
787
- return $logout_url;
788
- }
789
-
790
- /**
791
- * Changes single_post_title() to reflect the current action
792
- *
793
- * Callback for "single_post_title" hook in single_post_title()
794
- *
795
- * @see single_post_title()
796
- * @since 6.0
797
- * @access public
798
- *
799
- * @param string $title The current post title
800
- * @return string The modified post title
801
- */
802
- function single_post_title( $title ) {
803
- if ( self::is_tml_page( 'login' ) && is_user_logged_in() )
804
- $title = $this->get_instance()->get_title( 'login' );
805
- return $title;
806
- }
807
-
808
- /**
809
- * Changes the_title() to reflect the current action
810
- *
811
- * Callback for "the_title" hook in the_title()
812
- *
813
- * @see the_title()
814
- * @since 6.0
815
- * @acess public
816
- *
817
- * @param string $title The current post title
818
- * @param int $post_id The current post ID
819
- * @return string The modified post title
820
- */
821
- public function the_title( $title, $post_id = 0 ) {
822
- if ( is_admin() )
823
- return $title;
824
-
825
- if ( self::is_tml_page( 'login', $post_id ) ) {
826
- if ( in_the_loop() ) {
827
- if ( is_user_logged_in() ) {
828
- $title = $this->get_instance()->get_title( 'login' );
829
- } elseif ( 'login' != $this->request_action ) {
830
- $title = $this->get_instance()->get_title( $this->request_action );
831
- }
832
- }
833
  }
834
- return $title;
835
  }
836
 
837
  /**
838
- * Changes wp_get_document_title() to reflect the current action
839
- *
840
- * Callback for "document_title_parts" hok in wp_get_document_title()
841
  *
842
- * @see wp_get_document_title()
843
- * @since 6.4.12
844
  *
845
- * @param array $parts The title parts
846
- * @return array The modified title parts
847
  */
848
- public function document_title_parts( $parts ) {
849
- if ( self::is_tml_page( 'login' ) ) {
850
- if ( is_user_logged_in() ) {
851
- $parts['title'] = $this->get_instance()->get_title( 'login' );
852
- } elseif ( 'login' != $this->request_action ) {
853
- $parts['title'] = $this->get_instance()->get_title( $this->request_action );
854
- }
855
  }
856
- return $parts;
857
  }
858
 
859
  /**
860
- * Hide Login & Register if user is logged in, hide Logout if not
861
  *
862
- * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
863
  *
864
- * @see wp_setup_nav_menu_item()
865
- * @since 6.0
866
- * @access public
867
- *
868
- * @param object $menu_item The menu item
869
- * @return object The (possibly) modified menu item
870
  */
871
- public function wp_setup_nav_menu_item( $menu_item ) {
872
- if ( is_admin() )
873
- return $menu_item;
874
-
875
- if ( 'page' != $menu_item->object )
876
- return $menu_item;
877
-
878
- // User is logged in
879
- if ( is_user_logged_in() ) {
880
-
881
- // Hide login, register and lost password
882
- if ( self::is_tml_page( array( 'login', 'register', 'lostpassword' ), $menu_item->object_id ) ) {
883
- $menu_item->_invalid = true;
884
- }
885
-
886
- // User is not logged in
887
- } else {
888
-
889
- // Hide Logout
890
- if ( self::is_tml_page( 'logout', $menu_item->object_id ) ) {
891
- $menu_item->_invalid = true;
892
- }
893
- }
894
-
895
- return $menu_item;
896
  }
897
 
898
  /**
899
- * Excludes pages from wp_list_pages
900
  *
901
- * @since 6.3.7
902
  *
903
- * @param array $exclude Page IDs to exclude
904
- * @return array Page IDs to exclude
905
  */
906
- public function wp_list_pages_excludes( $exclude ) {
907
- $pages = get_posts( array(
908
- 'post_type' => 'page',
909
- 'post_status' => 'any',
910
- 'meta_key' => '_tml_action',
911
- 'posts_per_page' => -1
912
- ) );
913
- $pages = wp_list_pluck( $pages, 'ID' );
914
-
915
- return array_merge( $exclude, $pages );
916
- }
917
 
918
- /**
919
- * Adds nonce to logout link
920
- *
921
- * @since 6.3.7
922
- *
923
- * @param string $link Page link
924
- * @param int $post_id Post ID
925
- * @return string Page link
926
- */
927
- public function page_link( $link, $post_id ) {
928
- if ( self::is_tml_page( 'logout', $post_id ) )
929
- $link = add_query_arg( '_wpnonce', wp_create_nonce( 'log-out' ), $link );
930
- return $link;
931
- }
932
 
933
- /**
934
- * Add proper message in case of e-mail login error
935
- *
936
- * @since 6.4.5
937
- *
938
- * @param null|WP_Error|WP_User $user
939
- * @param string $username
940
- * @param string $password
941
- * @return null|WP_User|WP_Error
942
- */
943
- public function authenticate( $user, $username, $password ) {
944
- if ( 'email' == $this->get_option( 'login_type' ) && null == $user ) {
945
- return new WP_Error( 'invalid_email', __( '<strong>ERROR</strong>: Invalid email address.', 'theme-my-login' ) );
946
- }
947
 
948
- return $user;
949
  }
950
 
951
-
952
- /************************************************************************************************************************
953
- * Utilities
954
- ************************************************************************************************************************/
955
-
956
  /**
957
- * Handler for "theme-my-login" shortcode
958
  *
959
- * Optional $atts contents:
960
  *
961
- * - instance - A unqiue instance ID for this instance.
962
- * - default_action - The action to display. Defaults to "login".
963
- * - login_template - The template used for the login form. Defaults to "login-form.php".
964
- * - register_template - The template used for the register form. Defaults to "register-form.php".
965
- * - lostpassword_template - The template used for the lost password form. Defaults to "lostpassword-form.php".
966
- * - resetpass_template - The template used for the reset password form. Defaults to "resetpass-form.php".
967
- * - user_template - The templated used for when a user is logged in. Defalts to "user-panel.php".
968
- * - show_title - True to display the current title, false to hide. Defaults to true.
969
- * - show_log_link - True to display the login link, false to hide. Defaults to true.
970
- * - show_reg_link - True to display the register link, false to hide. Defaults to true.
971
- * - show_pass_link - True to display the lost password link, false to hide. Defaults to true.
972
- * - logged_in_widget - True to display the widget when logged in, false to hide. Defaults to true.
973
- * - logged_out_widget - True to display the widget when logged out, false to hide. Defaults to true.
974
- * - show_gravatar - True to display the user's gravatar, false to hide. Defaults to true.
975
- * - gravatar_size - The size of the user's gravatar. Defaults to "50".
976
- *
977
- * @since 6.0
978
- * @access public
979
- *
980
- * @param string|array $atts Attributes passed from the shortcode
981
- * @return string HTML output from Theme_My_Login_Template->display()
982
  */
983
- public function shortcode( $atts = '' ) {
984
- static $did_main_instance = false;
985
-
986
- $atts = wp_parse_args( $atts );
987
-
988
- if ( self::is_tml_page() && in_the_loop() && is_main_query() && ! $did_main_instance ) {
989
- $instance = $this->get_instance();
990
-
991
- if ( ! empty( $this->request_instance ) )
992
- $instance->set_active( false );
993
-
994
- if ( 'login' != $this->request_page ) {
995
- $atts['default_action'] = $this->request_page;
996
- }
997
-
998
- if ( ! isset( $atts['show_title'] ) )
999
- $atts['show_title'] = false;
1000
-
1001
- foreach ( $atts as $option => $value ) {
1002
- if ( 'instance' == $option ) {
1003
- continue;
1004
- }
1005
- $instance->set_option( $option, $value );
1006
- }
1007
-
1008
- $did_main_instance = true;
1009
  } else {
1010
- $instance = $this->load_instance( $atts );
1011
  }
1012
-
1013
- $this->current_instance = $instance->get_option( 'instance' );
1014
-
1015
- return $instance->display();
1016
  }
1017
 
1018
  /**
1019
- * Determines if $action is for $page
1020
  *
1021
- * @since 6.3
1022
  *
1023
- * @param array|string $action An action or array of actions to check
1024
- * @param int|object Post ID or object
1025
- * @return bool True if $action is for $page, false otherwise
1026
  */
1027
- public static function is_tml_page( $action = '', $page = '' ) {
1028
- if ( ! $page = get_post( $page ) )
1029
- return false;
1030
-
1031
- if ( 'page' != $page->post_type )
1032
- return false;
1033
-
1034
- if ( ! $page_action = self::get_page_action( $page->ID ) )
1035
- return false;
1036
-
1037
- if ( empty( $action ) )
1038
- return true;
1039
-
1040
- if ( in_array( $page_action, (array) $action ) )
1041
- return true;
1042
-
1043
  return false;
1044
  }
1045
 
1046
  /**
1047
- * Returns link for a login page
1048
  *
1049
- * @since 6.3
1050
- * @access public
1051
  *
1052
- * @param string $action The action
1053
- * @param string|array $query Optional. Query arguments to add to link
1054
- * @return string Login page link with optional $query arguments appended
1055
  */
1056
- public static function get_page_link( $action, $query = '' ) {
1057
- global $wp_rewrite;
1058
-
1059
- if ( $page_id = self::get_page_id( $action ) ) {
1060
- if ( $wp_rewrite instanceof WP_Rewrite ) {
1061
- $link = get_permalink( $page_id );
1062
- } else {
1063
- $link = home_url( '?page_id=' . $page_id );
1064
- }
1065
- } elseif ( $page_id = self::get_page_id( 'login' ) ) {
1066
- if ( $wp_rewrite instanceof WP_Rewrite ) {
1067
- $link = get_permalink( $page_id );
1068
- } else {
1069
- $link = home_url( '?page_id=' . $page_id );
1070
- }
1071
- $link = add_query_arg( 'action', $action, $link );
1072
- } else {
1073
- // Remove site_url filter so we can use wp-login.php
1074
- remove_filter( 'site_url', array( self::get_object(), 'site_url' ), 10, 3 );
1075
-
1076
- $link = site_url( "wp-login.php?action=$action" );
1077
- }
1078
-
1079
- if ( ! empty( $query ) ) {
1080
- $args = wp_parse_args( $query );
1081
-
1082
- if ( isset( $args['action'] ) && $action == $args['action'] )
1083
- unset( $args['action'] );
1084
-
1085
- $link = add_query_arg( array_map( 'rawurlencode', $args ), $link );
1086
- }
1087
-
1088
- $link = set_url_scheme( $link, 'login' );
1089
-
1090
- return apply_filters( 'tml_page_link', $link, $action, $query );
1091
  }
1092
 
1093
  /**
1094
- * Retrieves a page ID for an action
1095
  *
1096
- * @since 6.3
1097
- *
1098
- * @param string $action The action
1099
- * @return int|bool The page ID if exists, false otherwise
1100
  */
1101
- public static function get_page_id( $action ) {
1102
- global $wpdb;
1103
-
1104
- if ( 'rp' == $action )
1105
- $action = 'resetpass';
1106
- elseif ( 'retrievepassword' == $action )
1107
- $action = 'lostpassword';
1108
-
1109
- if ( ! $page_id = wp_cache_get( $action, 'tml_page_ids' ) ) {
1110
- $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 ) );
1111
- if ( ! $page_id )
1112
- return null;
1113
- wp_cache_add( $action, $page_id, 'tml_page_ids' );
1114
- }
1115
- return apply_filters( 'tml_page_id', $page_id, $action );
1116
  }
1117
 
1118
  /**
1119
- * Get the action for a page
1120
  *
1121
- * @since 6.3
1122
- *
1123
- * @param int|object Post ID or object
1124
- * @return string|bool Action name if exists, false otherwise
1125
  */
1126
- public static function get_page_action( $page ) {
1127
- if ( ! $page = get_post( $page ) )
1128
- return false;
1129
-
1130
- return get_post_meta( $page->ID, '_tml_action', true );
 
 
1131
  }
1132
 
1133
  /**
1134
- * Enqueues the specified sylesheet
1135
- *
1136
- * First looks in theme/template directories for the stylesheet, falling back to plugin directory
1137
  *
1138
- * @since 6.0
1139
- * @access public
1140
  *
1141
- * @param string $file Filename of stylesheet to load
1142
- * @return string Path to stylesheet
 
1143
  */
1144
- public static function get_stylesheet( $file = 'theme-my-login.css' ) {
1145
- if ( file_exists( get_stylesheet_directory() . '/' . $file ) )
1146
- $stylesheet = get_stylesheet_directory_uri() . '/' . $file;
1147
- elseif ( file_exists( get_template_directory() . '/' . $file ) )
1148
- $stylesheet = get_template_directory_uri() . '/' . $file;
1149
- else
1150
- $stylesheet = plugins_url( $file, dirname( __FILE__ ) );
1151
- return $stylesheet;
1152
  }
1153
 
1154
  /**
1155
- * Retrieves active instance object
1156
  *
1157
- * @since 6.3
1158
- * @access public
1159
  *
1160
- * @return object Instance object
 
1161
  */
1162
- public function get_active_instance() {
1163
- return $this->get_instance( (int) $this->request_instance );
 
 
 
 
 
 
1164
  }
1165
 
1166
  /**
1167
- * Get the current instance object
1168
- *
1169
- * @since 6.4.11
1170
- * @access public
1171
  *
1172
- * @return object Instance object
1173
  */
1174
- public function get_current_instance() {
1175
- return $this->get_instance( (int) $this->current_instance );
1176
- }
 
 
 
 
 
 
1177
 
1178
- /**
1179
- * Retrieves a loaded instance object
1180
- *
1181
- * @since 6.3
1182
- * @access public
1183
- *
1184
- * @param int $id Instance ID
1185
- * @return object Instance object
1186
 
1187
- */
1188
- public function get_instance( $id = 0 ) {
1189
- if ( isset( $this->loaded_instances[$id] ) )
1190
- return $this->loaded_instances[$id];
1191
- }
1192
 
1193
- /**
1194
- * Sets an instance object
1195
- *
1196
- * @since 6.3
1197
- * @access public
1198
- *
1199
- * @param object $object Instance object
1200
- */
1201
- public function set_instance( $object ) {
1202
- $this->loaded_instances[] = $object;
1203
  }
1204
 
1205
  /**
1206
- * Instantiates an instance
1207
- *
1208
- * @since 6.3
1209
- * @access public
1210
  *
1211
- * @param array|string $args Array or query string of arguments
1212
-
1213
- * @return object Instance object
1214
  */
1215
- public function load_instance( $args = '' ) {
1216
-
1217
- $instance = new Theme_My_Login_Template( $args );
1218
- $instance->set_option( 'instance', count( $this->loaded_instances ) );
1219
-
1220
- if ( $instance->get_option( 'instance' ) === $this->request_instance ) {
1221
- $instance->set_active();
1222
- $instance->set_option( 'default_action', $this->request_action ? $this->request_action : 'login' );
1223
- }
1224
-
1225
- $this->loaded_instances[] = $instance;
1226
-
1227
- return $instance;
1228
- }
1229
 
1230
  /**
1231
- * Load a custom translation file for current language if available.
1232
  *
1233
- * Note that custom translation files inside the plugin folder
1234
- * will be removed on plugin updates. If you're creating custom
1235
- * translation files, please place them in a '/theme-my-login/'
1236
- * directory within the global language folder.
1237
- *
1238
- * @since 6.4.4
1239
- *
1240
- * @param string $domain The domain for which a language file is being loaded.
1241
- * @param string $mofile Full path to the target mofile.
1242
  */
1243
- public function load_custom_textdomain( $domain, $mofile ) {
1244
- if ( 'theme-my-login' === $domain ) {
1245
- remove_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1246
-
1247
- // Look in global /wp-content/languages/theme-my-login folder for a translation
1248
- // and load it if available.
1249
- $mofile = basename( $mofile );
1250
- if ( file_exists( WP_LANG_DIR . '/theme-my-login/' . $mofile ) ) {
1251
- load_textdomain( 'theme-my-login', WP_LANG_DIR . '/theme-my-login/' . $mofile );
1252
- }
1253
-
1254
- add_action( 'load_textdomain', array( $this, 'load_custom_textdomain' ), 10, 2 );
1255
- }
1256
- }
1257
 
1258
  /**
1259
- * Handles sending password retrieval email to user.
1260
  *
1261
- * @since 6.0
1262
- * @access public
1263
- * @uses $wpdb WordPress Database object
1264
- *
1265
- * @return bool|WP_Error True: when finish. WP_Error on error
1266
  */
1267
- public static function retrieve_password() {
1268
- global $wpdb, $wp_hasher;
1269
-
1270
- $errors = new WP_Error();
1271
-
1272
- if ( empty( $_POST['user_login'] ) ) {
1273
- $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or e-mail address.', 'theme-my-login' ) );
1274
- } else if ( strpos( $_POST['user_login'], '@' ) ) {
1275
- $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
1276
- if ( empty( $user_data ) )
1277
- $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no user registered with that email address.', 'theme-my-login' ) );
1278
- } else {
1279
- $login = trim( $_POST['user_login'] );
1280
- $user_data = get_user_by( 'login', $login );
1281
- }
1282
-
1283
- do_action( 'lostpassword_post', $errors );
1284
-
1285
- if ( $errors->get_error_code() )
1286
- return $errors;
1287
-
1288
- if ( ! $user_data ) {
1289
- $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: Invalid username or e-mail.', 'theme-my-login' ) );
1290
- return $errors;
1291
- }
1292
-
1293
- // redefining user_login ensures we return the right case in the email
1294
- $user_login = $user_data->user_login;
1295
- $user_email = $user_data->user_email;
1296
- $key = get_password_reset_key( $user_data );
1297
-
1298
- if ( is_wp_error( $key ) ) {
1299
- return $key;
1300
- }
1301
-
1302
- $message = __( 'Someone requested that the password be reset for the following account:', 'theme-my-login' ) . "\r\n\r\n";
1303
- $message .= network_home_url( '/' ) . "\r\n\r\n";
1304
- $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n\r\n";
1305
- $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.', 'theme-my-login' ) . "\r\n\r\n";
1306
- $message .= __( 'To reset your password, visit the following address:', 'theme-my-login' ) . "\r\n\r\n";
1307
- $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n";
1308
 
1309
- if ( is_multisite() ) {
1310
- $blogname = $GLOBALS['current_site']->site_name;
1311
- } else {
1312
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
1313
- // we want to reverse this for the plain text arena of emails.
1314
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1315
  }
1316
-
1317
- $title = sprintf( __( '[%s] Password Reset', 'theme-my-login' ), $blogname );
1318
-
1319
- $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
1320
- $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
1321
-
1322
- if ( $message && ! wp_mail( $user_email, $title, $message ) )
1323
- 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' ) );
1324
-
1325
- return true;
1326
  }
1327
  }
1328
- endif; // Class exists
1
  <?php
2
+
3
  /**
4
+ * Theme My Login Plugin Class
5
  *
6
  * @package Theme_My_Login
7
+ * @subpackage Main
8
  */
9
 
10
+ /**
11
+ * Class used to implement the plugin object.
 
 
 
12
  *
13
+ * @since 7.0
14
  */
15
+ final class Theme_My_Login {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  /**
18
+ * The plugin instance.
19
  *
20
+ * @var Theme_My_Login
 
 
21
  */
22
+ private static $instance;
23
 
24
  /**
25
+ * The registered actions.
26
  *
 
 
27
  * @var array
28
  */
29
+ protected $actions = array();
30
 
31
  /**
32
+ * The registered forms.
33
  *
34
+ * @var array
 
 
35
  */
36
+ protected $forms = array();
 
 
37
 
38
  /**
39
+ * The registered extensions.
 
 
 
40
  *
41
+ * @var array
42
  */
43
+ protected $extensions = array();
 
 
 
 
 
 
 
 
44
 
45
  /**
46
+ * An arbitrary data store.
 
 
 
47
  *
48
+ * @var array
49
  */
50
+ private $data = array();
 
 
 
 
 
 
 
 
51
 
52
  /**
53
+ * Get the instance.
54
  *
55
+ * @since 7.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  *
57
+ * @return Theme_My_Login
 
58
  */
59
+ public static function get_instance() {
60
+ if ( null === self::$instance ) {
61
+ self::$instance = new self();
 
62
  }
63
+ return self::$instance;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
67
+ * Register an action.
68
  *
69
+ * @since 7.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  *
71
+ * @param Theme_My_Login_Action $action The action object.
72
+ * @return Theme_My_Login_Action The action object.
73
  */
74
+ public function register_action( Theme_My_Login_Action $action ) {
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
+ $this->actions[ $action->get_name() ] = $action;
 
77
 
78
+ $action->add_callback_hook();
 
 
79
 
80
+ /**
81
+ * Fires after registering an action.
82
+ *
83
+ * @since 7.0
84
+ *
85
+ * @param string $name The action name.
86
+ * @param Theme_My_Login_Action $action The action object.
87
+ */
88
+ do_action( 'tml_registered_action', $action->get_name(), $action );
 
 
 
 
 
 
 
89
 
90
+ return $action;
 
91
  }
92
 
93
  /**
94
+ * Unregister an action.
95
  *
96
+ * @since 7.0
97
  *
98
+ * @param string|Theme_My_Login_Action $action The action name or object.
 
99
  */
100
+ public function unregister_action( $action ) {
101
+ if ( $action instanceof Theme_My_Login_Action ) {
 
102
 
103
+ $action->remove_callback_hook();
 
104
 
105
+ unset( $this->actions[ $action->get_name() ] );
 
106
  } else {
107
+ if ( $action = $this->get_action( $action ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+ $action->remove_callback_hook();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
+ unset( $this->actions[ $action ] );
112
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
  }
115
 
116
  /**
117
+ * Get an action.
118
  *
119
+ * @since 7.0
120
  *
121
+ * @param string $action The action name.
122
+ * @return Theme_My_Login_Action|bool The action object if it exists or false otherwise.
123
  */
124
+ public function get_action( $action ) {
125
+ if ( isset( $this->actions[ $action ] ) ) {
126
+ return $this->actions[ $action ];
 
 
 
127
  }
128
+ return false;
129
  }
130
 
131
  /**
132
+ * Get all actions.
133
+ *
134
+ * @since 7.0
135
  *
136
+ * @return array The actions.
 
137
  */
138
+ public function get_actions() {
139
+ return $this->actions;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
 
 
 
 
 
142
  /**
143
+ * Register a form.
144
  *
145
+ * @since 7.0
 
146
  *
147
+ * @param Theme_My_Login_Form $form The form object.
148
+ * @return Theme_My_Login_Form The form object.
 
 
149
  */
150
+ public function register_form( Theme_My_Login_Form $form ) {
 
 
 
 
 
 
 
 
 
151
 
152
+ $this->forms[ $form->get_name() ] = $form;
 
153
 
154
  /**
155
+ * Fires after registering a form.
156
  *
157
+ * @since 7.0
 
158
  *
159
+ * @param string $name The form name.
160
+ * @param Theme_My_Login_Form $form The form object.
161
  */
162
+ do_action( 'tml_registered_form', $form->get_name(), $form );
 
163
 
164
+ return $form;
 
 
 
 
 
 
 
 
 
 
165
  }
166
 
167
  /**
168
+ * Unregister a form.
169
  *
170
+ * @since 7.0
171
  *
172
+ * @param string|Theme_My_Login_Form $form The form name or object.
 
 
 
 
 
173
  */
174
+ public function unregister_form( $form ) {
175
+ if ( $form instanceof Theme_My_Login_Form ) {
176
+ unset( $this->forms[ $form->get_name() ] );
177
+ } else {
178
+ unset( $this->forms[ $form ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  }
 
180
  }
181
 
182
  /**
183
+ * Get a form.
 
 
184
  *
185
+ * @since 7.0
 
186
  *
187
+ * @param string $form The form name.
188
+ * @return Theme_My_Login_Form|bool The form object if it exists or false otherwise.
189
  */
190
+ public function get_form( $form ) {
191
+ if ( isset( $this->forms[ $form ] ) ) {
192
+ return $this->forms[ $form ];
 
 
 
 
193
  }
194
+ return false;
195
  }
196
 
197
  /**
198
+ * Get all forms.
199
  *
200
+ * @since 7.0
201
  *
202
+ * @return array The forms.
 
 
 
 
 
203
  */
204
+ public function get_forms() {
205
+ return $this->forms;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  }
207
 
208
  /**
209
+ * Register an extension.
210
  *
211
+ * @since 7.0
212
  *
213
+ * @param Theme_My_Login_Extension $extension The extension object.
214
+ * @return Theme_My_Login_Extension The extension object.
215
  */
216
+ public function register_extension( Theme_My_Login_Extension $extension ) {
 
 
 
 
 
 
 
 
 
 
217
 
218
+ $this->extensions[ $extension->get_name() ] = $extension;
 
 
 
 
 
 
 
 
 
 
 
 
 
219
 
220
+ /**
221
+ * Fires after registering an extension.
222
+ *
223
+ * @since 7.0
224
+ *
225
+ * @param string $name The extension name.
226
+ * @param Theme_My_Login_Extension $extension The extension object.
227
+ */
228
+ do_action( 'tml_registered_extension', $extension->get_name(), $extension );
 
 
 
 
 
229
 
230
+ return $extension;
231
  }
232
 
 
 
 
 
 
233
  /**
234
+ * Unregister an extension.
235
  *
236
+ * @since 7.0
237
  *
238
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  */
240
+ public function unregister_extension( $extension ) {
241
+ if ( $extension instanceof Theme_My_Login_Extension ) {
242
+ unset( $this->extensions[ $extension->get_name() ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  } else {
244
+ unset( $this->extensions[ $extension ] );
245
  }
 
 
 
 
246
  }
247
 
248
  /**
249
+ * Get an extension.
250
  *
251
+ * @since 7.0
252
  *
253
+ * @param string $extension The extension name.
254
+ * @return Theme_My_Login_Extension|bool The extension object if it exists or false otherwise.
 
255
  */
256
+ public function get_extension( $extension ) {
257
+ if ( isset( $this->extensions[ $extension ] ) ) {
258
+ return $this->extensions[ $extension ];
259
+ }
 
 
 
 
 
 
 
 
 
 
 
 
260
  return false;
261
  }
262
 
263
  /**
264
+ * Get all extensions.
265
  *
266
+ * @since 7.0
 
267
  *
268
+ * @return array The extensions.
 
 
269
  */
270
+ public function get_extensions() {
271
+ return $this->extensions;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  }
273
 
274
  /**
275
+ * Fire an action hook when the plugin is activated.
276
  *
277
+ * @since 7.0
 
 
 
278
  */
279
+ public function activate() {
280
+ /**
281
+ * Fires when the plugin is being activated.
282
+ *
283
+ * @since 7.0
284
+ */
285
+ do_action( 'tml_activate' );
 
 
 
 
 
 
 
 
286
  }
287
 
288
  /**
289
+ * Fire an action hook when the plugin is deactivated.
290
  *
291
+ * @since 7.0
 
 
 
292
  */
293
+ public function deactivate() {
294
+ /**
295
+ * Fires when the plugin is being deactivated.
296
+ *
297
+ * @since 7.0
298
+ */
299
+ do_action( 'tml_deactivate' );
300
  }
301
 
302
  /**
303
+ * Get arbitrary data.
 
 
304
  *
305
+ * @since 7.0
 
306
  *
307
+ * @param string $name The property name.
308
+ * @param mixed $default The value to return if the property is not set.
309
+ * @return mixed The property value or $default if not set.
310
  */
311
+ public function get_data( $name, $default = false ) {
312
+ if ( array_key_exists( $name, $this->data ) ) {
313
+ return $this->data[ $name ];
314
+ }
315
+ return $default;
 
 
 
316
  }
317
 
318
  /**
319
+ * Set arbitrary data.
320
  *
321
+ * @since 7.0
 
322
  *
323
+ * @param string|array $name The property name or an array of properties.
324
+ * @param mixed $value The property value.
325
  */
326
+ public function set_data( $name, $value = '' ) {
327
+ if ( is_array( $name ) ) {
328
+ foreach( $name as $k => $v ) {
329
+ $this->data[ $k ] = $v;
330
+ }
331
+ } else {
332
+ $this->data[ $name ] = $value;
333
+ }
334
  }
335
 
336
  /**
337
+ * Construct the instance.
 
 
 
338
  *
339
+ * @since 7.0
340
  */
341
+ protected function __construct() {
342
+ /**
343
+ * Fires when TML has been initialized.
344
+ *
345
+ * @since 7.0
346
+ *
347
+ * @param Theme_My_Login $tml The TML object.
348
+ */
349
+ do_action( 'tml_init', $this );
350
 
351
+ // Get the main plugin file path
352
+ $plugin_file = str_replace( array( 'src', 'build' ), '', THEME_MY_LOGIN_PATH . 'theme-my-login.php' );
 
 
 
 
 
 
353
 
354
+ // Run the activation hook
355
+ register_activation_hook( $plugin_file, array( $this, 'activate' ) );
 
 
 
356
 
357
+ // Run the deactivation hook
358
+ register_deactivation_hook( $plugin_file, array( $this, 'deactivate' ) );
 
 
 
 
 
 
 
 
359
  }
360
 
361
  /**
362
+ * Don't allow cloning.
 
 
 
363
  *
364
+ * @since 7.0
 
 
365
  */
366
+ private function __clone() {}
 
 
 
 
 
 
 
 
 
 
 
 
 
367
 
368
  /**
369
+ * Don't allow unserialization.
370
  *
371
+ * @since 7.0
 
 
 
 
 
 
 
 
372
  */
373
+ private function __wakeup() {}
 
 
 
 
 
 
 
 
 
 
 
 
 
374
 
375
  /**
376
+ * Handle some deprecated methods that other plugins use.
377
  *
378
+ * @since 7.0.1
 
 
 
 
379
  */
380
+ public static function __callStatic( $name, $args ) {
381
+ switch ( $name ) {
382
+ case 'get_object' :
383
+ return self::get_instance();
384
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
 
386
+ case 'is_tml_page' :
387
+ return tml_is_action( isset( $args[0] ) ? $args[0] : '' );
388
+ break;
 
 
 
389
  }
 
 
 
 
 
 
 
 
 
 
390
  }
391
  }
 
includes/compat.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Compatibility Functions
5
+ *
6
+ * Note I proposed a patch that, if accepted, would negate the need for this file.
7
+ * @link https://core.trac.wordpress.org/ticket/31039
8
+ *
9
+ * @package Theme_My_Login
10
+ * @subpackage Compatibility
11
+ */
12
+
13
+ /**
14
+ * Handles validating the lost password request and retrieving the password reset key.
15
+ *
16
+ * @since 7.0
17
+ *
18
+ * @return True on success, WP_Error on error.
19
+ */
20
+ function tml_retrieve_password() {
21
+ $errors = new WP_Error();
22
+
23
+ if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) {
24
+ $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) );
25
+ } elseif ( strpos( $_POST['user_login'], '@' ) ) {
26
+ $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
27
+ if ( empty( $user_data ) ) {
28
+ $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no user registered with that email address.' ) );
29
+ }
30
+ } else {
31
+ $login = trim( $_POST['user_login'] );
32
+ $user_data = get_user_by( 'login', $login );
33
+ }
34
+
35
+ /** This action is documented in wp-login.php */
36
+ do_action( 'lostpassword_post', $errors );
37
+
38
+ if ( $errors->get_error_code() ) {
39
+ return $errors;
40
+ }
41
+
42
+ if ( ! $user_data ) {
43
+ $errors->add( 'invalidcombo', __( '<strong>ERROR</strong>: Invalid username or email.' ) );
44
+ return $errors;
45
+ }
46
+
47
+ $key = get_password_reset_key( $user_data );
48
+ if ( is_wp_error( $key ) ) {
49
+ return $key;
50
+ }
51
+
52
+ /**
53
+ * Fires after a password reset key is retrieved.
54
+ *
55
+ * @since unknown
56
+ *
57
+ * @param WP_User $user_data The user object.
58
+ * @param string $key The password reset key.
59
+ */
60
+ do_action( 'retrieved_password_key', $user_data, $key );
61
+
62
+ return true;
63
+ }
64
+
65
+ /**
66
+ * Sends the retrieve password notification.
67
+ *
68
+ * @since 7.0
69
+ *
70
+ * @param WP_User $user The user object.
71
+ * @param string $key The password reset key.
72
+ */
73
+ function tml_retrieve_password_notification( $user, $key ) {
74
+ if ( is_multisite() ) {
75
+ $site_name = get_network()->site_name;
76
+ } else {
77
+ /*
78
+ * The blogname option is escaped with esc_html on the way into the database
79
+ * in sanitize_option we want to reverse this for the plain text arena of emails.
80
+ */
81
+ $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
82
+ }
83
+
84
+ $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
85
+ /* translators: %s: site name */
86
+ $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
87
+ /* translators: %s: user login */
88
+ $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
89
+ $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n";
90
+ $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n";
91
+ $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n";
92
+
93
+ /* translators: Password reset email subject. %s: Site name */
94
+ $title = sprintf( __( '[%s] Password Reset' ), $site_name );
95
+
96
+ /**
97
+ * Filters the subject of the password reset email.
98
+ *
99
+ * @since 2.8.0
100
+ * @since 4.4.0 Added the `$user_login` and `$user_data` parameters.
101
+ *
102
+ * @param string $title Default email title.
103
+ * @param string $user_login The username for the user.
104
+ * @param WP_User $user WP_User object.
105
+ */
106
+ $title = apply_filters( 'retrieve_password_title', $title, $user->user_login, $user );
107
+
108
+ /**
109
+ * Filters the message body of the password reset mail.
110
+ *
111
+ * If the filtered message is empty, the password reset email will not be sent.
112
+ *
113
+ * @since 2.8.0
114
+ * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
115
+ *
116
+ * @param string $message Default mail message.
117
+ * @param string $key The activation key.
118
+ * @param string $user_login The username for the user.
119
+ * @param WP_User $user WP_User object.
120
+ */
121
+ $message = apply_filters( 'retrieve_password_message', $message, $key, $user->user_login, $user );
122
+
123
+ if ( $message && ! wp_mail( $user->user_email, wp_specialchars_decode( $title ), $message ) ) {
124
+ wp_die( __( 'The email could not be sent.' ) . "<br />\n" . __( 'Possible reason: your host may have disabled the mail() function.' ) );
125
+ }
126
+ }
includes/extensions.php ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Extension Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Extensions
8
+ */
9
+
10
+ /**
11
+ * Register an extension.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
16
+ * @param array $args {
17
+ * Optional. An array of arguments for registering an extension.
18
+ * }
19
+ * @return Theme_My_Login_Extension The extension object.
20
+ */
21
+ function tml_register_extension( $extension, $args = array() ) {
22
+
23
+ if ( ! $extension instanceof Theme_My_Login_Extension ) {
24
+ return false;
25
+ }
26
+
27
+ return theme_my_login()->register_extension( $extension );
28
+ }
29
+
30
+ /**
31
+ * Unregister an extension.
32
+ *
33
+ * @since 7.0
34
+ *
35
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
36
+ */
37
+ function tml_unregister_extension( $extension ) {
38
+ theme_my_login()->unregister_extension( $extension );
39
+ }
40
+
41
+ /**
42
+ * Get an extension.
43
+ *
44
+ * @since 7.0
45
+ *
46
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
47
+ * @return Theme_My_Login_Extension|bool The extension object if it exists or false otherwise.
48
+ */
49
+ function tml_get_extension( $extension ) {
50
+
51
+ if ( $extension instanceof Theme_My_Login_Extension ) {
52
+ return $extension;
53
+ }
54
+
55
+ return theme_my_login()->get_extension( $extension );
56
+ }
57
+
58
+ /**
59
+ * Get all extensions.
60
+ *
61
+ * @since 7.0
62
+ *
63
+ * @return array The extensions.
64
+ */
65
+ function tml_get_extensions() {
66
+ return theme_my_login()->get_extensions();
67
+ }
68
+
69
+ /**
70
+ * Determine if an extension exists.
71
+ *
72
+ * @since 7.0
73
+ *
74
+ * @param string $extension The extension name.
75
+ * @return bool True if the extension exists or false otherwise.
76
+ */
77
+ function tml_extension_exists( $extension ) {
78
+ $exists = array_key_exists( $extension, tml_get_extensions() );
79
+
80
+ /**
81
+ * Filter whether an extension exists or not.
82
+ *
83
+ * @since 7.0
84
+ *
85
+ * @param bool $exists Whether the extension exists or not.
86
+ * @param string $extension The extension name.
87
+ */
88
+ return apply_filters( 'tml_extension_exists', $exists, $extension );
89
+ }
90
+
91
+ /**
92
+ * Add extensions hosted using EDD to the WP plugins API.
93
+ *
94
+ * @since 7.0
95
+ *
96
+ * @param false|object|array $result The result object or array.
97
+ * @param string $action The API action being requested.
98
+ * @param object $args The arguments being passed to the API.
99
+ */
100
+ function tml_add_extension_data_to_plugins_api( $result = false, $action = '', $args = array() ) {
101
+
102
+ // Bail if not a "plugin_information" call
103
+ if ( 'plugin_information' != $action ) {
104
+ return $result;
105
+ }
106
+
107
+ // Bail if the extension doesn't exist
108
+ if ( ! $extension = tml_get_extension( $args->slug ) ) {
109
+ return $result;
110
+ }
111
+
112
+ if ( $result = tml_extension_api_call( $extension->get_store_url(), array(
113
+ 'license' => $extension->get_license_key(),
114
+ 'item_id' => $extension->get_item_id(),
115
+ 'slug' => $extension->get_name(),
116
+ ) ) ) {
117
+ if ( ! empty( $result->new_version ) ) {
118
+ $result->version = $result->new_version;
119
+ }
120
+ }
121
+
122
+ return $result;
123
+ }
124
+
125
+ /**
126
+ * Add extensions hosted using EDD to the WP plugins transient.
127
+ *
128
+ * @since 7.0
129
+ *
130
+ * @param object $transient The transient data.
131
+ * @return object The transient data.
132
+ */
133
+ function tml_add_extension_data_to_plugins_transient( $transient = '' ) {
134
+ if ( ! is_object( $transient ) ) {
135
+ $transient = (object) array();
136
+ }
137
+
138
+ foreach ( tml_get_extensions() as $extension ) {
139
+ $response = tml_extension_api_call( $extension->get_store_url(), array(
140
+ 'license' => $extension->get_license_key(),
141
+ 'item_id' => $extension->get_item_id(),
142
+ 'slug' => $extension->get_name(),
143
+ ) );
144
+
145
+ if ( is_object( $response ) ) {
146
+ $basename = $extension->get_basename();
147
+
148
+ if ( empty( $response->plugin ) ) {
149
+ $response->plugin = $basename;
150
+ }
151
+
152
+ // This is a valid update
153
+ if ( ! empty( $response->new_version ) && version_compare( $extension->get_version(), $response->new_version, '<' ) ) {
154
+ $transient->response[ $basename ] = $response;
155
+
156
+ // This is just fetching the plugin information
157
+ } else {
158
+ $transient->no_update[ $basename ] = $response;
159
+ }
160
+
161
+ $transient->last_checked = time();
162
+ }
163
+ }
164
+
165
+ return $transient;
166
+ }
167
+
168
+ /**
169
+ * Activate an extension license.
170
+ *
171
+ * @since 7.0
172
+ *
173
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
174
+ * @return bool|string|WP_Error The license status on success, false if the
175
+ * extension doesn't exist or WP_Error on failure.
176
+ */
177
+ function tml_activate_extension_license( $extension ) {
178
+ if ( ! $extension = tml_get_extension( $extension ) ) {
179
+ return false;
180
+ }
181
+
182
+ $response = tml_extension_api_call( $extension->get_store_url(), array(
183
+ 'edd_action' => 'activate_license',
184
+ 'license' => $extension->get_license_key(),
185
+ 'item_id' => $extension->get_item_id(),
186
+ ) );
187
+
188
+ if ( empty( $response ) ) {
189
+ return new WP_Error( 'http_error', __( 'An error occurred, please try again.', 'theme-my-login' ) );
190
+ }
191
+
192
+ if ( false === $response->success ) {
193
+ switch ( $response->error ) {
194
+ case 'expired' :
195
+ $message = sprintf(
196
+ __( 'Your license key expired on %s.', 'theme_my_login' ),
197
+ date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
198
+ );
199
+ break;
200
+
201
+ case 'revoked' :
202
+ $message = __( 'Your license key has been disabled.', 'theme-my-login' );
203
+ break;
204
+
205
+ case 'missing' :
206
+ case 'item_name_mismatch' :
207
+ $message = __( 'Invalid license.', 'theme-my-login' );
208
+ break;
209
+
210
+ case 'invalid' :
211
+ case 'site_inactive' :
212
+ $message = __( 'Your license is not active for this URL.', 'theme-my-login' );
213
+ break;
214
+
215
+ case 'no_activations_left':
216
+ $message = __( 'Your license key has reached its activation limit.', 'theme-my-login' );
217
+ break;
218
+
219
+ default :
220
+ $message = __( 'An error occurred, please try again.', 'theme-my-login' );
221
+ break;
222
+ }
223
+ return new WP_Error( $response->error, $message );
224
+ }
225
+
226
+ return $response->license;
227
+ }
228
+
229
+ /**
230
+ * Deactivate an extension license.
231
+ *
232
+ * @since 7.0
233
+ *
234
+ * @param string|Theme_My_Login_Extension $extension The extension name or object.
235
+ * @return bool|string|WP_Error The license status on success, false if the
236
+ * extension doesn't exist or WP_Error on failure.
237
+ */
238
+ function tml_deactivate_extension_license( $extension ) {
239
+ if ( ! $extension = tml_get_extension( $extension ) ) {
240
+ return false;
241
+ }
242
+
243
+ $response = tml_extension_api_call( $extension->get_store_url(), array(
244
+ 'edd_action' => 'deactivate_license',
245
+ 'license' => $extension->get_license_key(),
246
+ 'item_id' => $extension->get_item_id(),
247
+ ) );
248
+
249
+ if ( empty( $response ) ) {
250
+ return new WP_Error( 'http_error', __( 'An error occurred, please try again.', 'theme-my-login' ) );
251
+ }
252
+
253
+ return $response->license;
254
+ }
255
+
256
+ /**
257
+ * Make an API call to an extension's store.
258
+ *
259
+ * @since 7.0
260
+ *
261
+ * @param string $url The store URL.
262
+ * @param array $args {
263
+ * Optional. An array of arguments for making an API call.
264
+ *
265
+ * @param string $edd_action The API action.
266
+ * @param string $license The extension license key.
267
+ * @param int $item_id The extension item ID.
268
+ * @param string $slug The extension slug.
269
+ * @param string $url
270
+ * @param bool $beta Whether to include beta versions or not.
271
+ * }
272
+ * @return object|false The response object or false on failure.
273
+ */
274
+ function tml_extension_api_call( $url, $args = array() ) {
275
+ $args = wp_parse_args( $args, array(
276
+ 'edd_action' => 'get_version',
277
+ 'license' => '',
278
+ 'item_id' => '',
279
+ 'slug' => '',
280
+ 'url' => '',
281
+ 'beta' => false,
282
+ ) );
283
+
284
+ $response = wp_remote_post( $url, array(
285
+ 'timeout' => 15,
286
+ 'sslverify' => true,
287
+ 'body' => $args,
288
+ ) );
289
+
290
+ if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
291
+ return false;
292
+ }
293
+
294
+ $response = json_decode( wp_remote_retrieve_body( $response ) );
295
+
296
+ if ( is_object( $response ) ) {
297
+ if ( isset( $response->sections ) ) {
298
+ $response->sections = maybe_unserialize( $response->sections );
299
+ }
300
+ if ( isset( $response->banners ) ) {
301
+ $response->banners = maybe_unserialize( $response->banners );
302
+ }
303
+ } else {
304
+ $response = false;
305
+ }
306
+
307
+ return $response;
308
+ }
includes/forms.php ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Form Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Forms
8
+ */
9
+
10
+ /**
11
+ * Register the default forms.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ function tml_register_default_forms() {
16
+ if ( is_admin() ) {
17
+ return;
18
+ }
19
+
20
+ tml_register_login_form();
21
+ tml_register_registration_form();
22
+ tml_register_lost_password_form();
23
+ tml_register_password_reset_form();
24
+ }
25
+
26
+ /**
27
+ * Register the login form.
28
+ *
29
+ * @since 7.0
30
+ */
31
+ function tml_register_login_form() {
32
+
33
+ tml_register_form( 'login', array(
34
+ 'action' => tml_get_action_url( 'login' ),
35
+ ) );
36
+
37
+ tml_add_form_field( 'login', 'log', array(
38
+ 'type' => 'text',
39
+ 'label' => tml_get_username_label( 'login' ),
40
+ 'value' => tml_get_request_value( 'log', 'post' ),
41
+ 'id' => 'user_login',
42
+ 'priority' => 10,
43
+ ) );
44
+
45
+ tml_add_form_field( 'login', 'pwd', array(
46
+ 'type' => 'password',
47
+ 'label' => __( 'Password' ),
48
+ 'value' => '',
49
+ 'id' => 'user_pass',
50
+ 'priority' => 15
51
+ ) );
52
+
53
+ tml_add_form_field( 'login', 'login_form_action', array(
54
+ 'type' => 'custom',
55
+ 'content' => tml_buffer_action_hook( 'login_form' ),
56
+ 'priority' => 20,
57
+ ) );
58
+
59
+ tml_add_form_field( 'login', 'rememberme', array(
60
+ 'type' => 'checkbox',
61
+ 'label' => __( 'Remember Me' ),
62
+ 'value' => 'forever',
63
+ 'priority' => 25,
64
+ ) );
65
+
66
+ tml_add_form_field( 'login', 'submit', array(
67
+ 'type' => 'submit',
68
+ 'value' => __( 'Log In' ),
69
+ 'priority' => 30,
70
+ ) );
71
+
72
+ tml_add_form_field( 'login', 'testcookie', array(
73
+ 'type' => 'hidden' ,
74
+ 'value' => 1,
75
+ 'priority' => 30,
76
+ ) );
77
+
78
+ $redirect_to = tml_get_request_value( 'redirect_to' );
79
+
80
+ tml_add_form_field( 'login', 'redirect_to', array(
81
+ 'type' => 'hidden',
82
+ 'value' => apply_filters( 'login_redirect',
83
+ ! empty( $redirect_to ) ? $redirect_to : admin_url(), $redirect_to, null
84
+ ),
85
+ 'priority' => 30,
86
+ ) );
87
+ }
88
+
89
+ /**
90
+ * Register the registration form.
91
+ *
92
+ * @since 7.0
93
+ */
94
+ function tml_register_registration_form() {
95
+
96
+ tml_register_form( 'register', array(
97
+ 'action' => tml_get_action_url( 'register' ),
98
+ ) );
99
+
100
+ if ( tml_is_default_registration_type() ) {
101
+ tml_add_form_field( 'register', 'user_login', array(
102
+ 'type' => 'text',
103
+ 'label' => __( 'Username' ),
104
+ 'value' => tml_get_request_value( 'user_login', 'post' ),
105
+ 'id' => 'user_login',
106
+ 'priority' => 10,
107
+ ) );
108
+ } else {
109
+ tml_add_form_field( 'register', 'user_login', array(
110
+ 'type' => 'hidden',
111
+ 'label' => '',
112
+ 'value' => 'user' . md5( microtime() ),
113
+ 'id' => 'user_login',
114
+ 'priority' => 10,
115
+ ) );
116
+ }
117
+
118
+ tml_add_form_field( 'register', 'user_email', array(
119
+ 'type' => 'email',
120
+ 'label' => __( 'Email' ),
121
+ 'value' => tml_get_request_value( 'user_email', 'post' ),
122
+ 'id' => 'user_email',
123
+ 'priority' => 15,
124
+ ) );
125
+
126
+ if ( tml_allow_user_passwords() ) {
127
+ tml_add_form_field( 'register', 'user_pass1', array(
128
+ 'type' => 'password',
129
+ 'label' => __( 'Password' ),
130
+ 'id' => 'pass1',
131
+ 'attributes' => array(
132
+ 'autocomplete' => 'off',
133
+ ),
134
+ 'priority' => 20,
135
+ ) );
136
+
137
+ tml_add_form_field( 'register', 'user_pass2', array(
138
+ 'type' => 'password',
139
+ 'label' => __( 'Confirm Password' ),
140
+ 'id' => 'pass2',
141
+ 'attributes' => array(
142
+ 'autocomplete' => 'off',
143
+ ),
144
+ 'priority' => 20,
145
+ ) );
146
+
147
+ tml_add_form_field( 'register', 'indicator', array(
148
+ 'type' => 'custom',
149
+ 'content' => '<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">' . __( 'Strength indicator' ) . '</div>',
150
+ 'priority' => 20,
151
+ ) );
152
+
153
+ tml_add_form_field( 'register', 'indicator_hint', array(
154
+ 'type' => 'custom',
155
+ 'content' => '<p class="description indicator-hint">' . wp_get_password_hint() . '</p>',
156
+ 'priority' => 20,
157
+ ) );
158
+ }
159
+
160
+ if ( ! tml_allow_user_passwords() ) {
161
+ tml_add_form_field( 'register', 'reg_passmail', array(
162
+ 'type' => 'custom',
163
+ 'content' => '<p id="reg_passmail">' . __( 'Registration confirmation will be emailed to you.' ) . '</p>',
164
+ 'priority' => 25,
165
+ ) );
166
+ }
167
+
168
+ tml_add_form_field( 'register', 'submit', array(
169
+ 'type' => 'submit',
170
+ 'value' => __( 'Register' ),
171
+ 'priority' => 30,
172
+ ) );
173
+
174
+ tml_add_form_field( 'register', 'redirect_to', array(
175
+ 'type' => 'hidden',
176
+ 'value' => apply_filters( 'registration_redirect', tml_get_request_value( 'redirect_to' ) ),
177
+ 'priority' => 30,
178
+ ) );
179
+ }
180
+
181
+ /**
182
+ * Register the lost password form.
183
+ *
184
+ * @since 7.0
185
+ */
186
+ function tml_register_lost_password_form() {
187
+
188
+ tml_register_form( 'lostpassword', array(
189
+ 'action' => tml_get_action_url( 'lostpassword' ),
190
+ ) );
191
+
192
+ tml_add_form_field( 'lostpassword', 'user_login', array(
193
+ 'type' => 'text',
194
+ 'label' => tml_get_username_label( 'lostpassword' ),
195
+ 'value' => '',
196
+ 'id' => 'user_login',
197
+ 'priority' => 10,
198
+ ) );
199
+
200
+ tml_add_form_field( 'lostpassword', 'submit', array(
201
+ 'type' => 'submit',
202
+ 'value' => __( 'Get New Password' ),
203
+ 'priority' => 30,
204
+ ) );
205
+
206
+ tml_add_form_field( 'lostpassword', 'redirect_to', array(
207
+ 'type' => 'hidden',
208
+ 'value' => apply_filters( 'lostpassword_redirect', tml_get_request_value( 'redirect_to' ) ),
209
+ 'priority' => 30,
210
+ ) );
211
+ }
212
+
213
+ /**
214
+ * Register the password reset form.
215
+ *
216
+ * @since 7.0
217
+ */
218
+ function tml_register_password_reset_form() {
219
+
220
+ tml_register_form( 'resetpass', array(
221
+ 'action' => tml_get_action_url( 'resetpass' ),
222
+ 'render_args' => array(
223
+ 'show_links' => false,
224
+ ),
225
+ ) );
226
+
227
+ tml_add_form_field( 'resetpass', 'pass1', array(
228
+ 'type' => 'password',
229
+ 'label' => __( 'New password' ),
230
+ 'id' => 'pass1',
231
+ 'priority' => 10,
232
+ ) );
233
+
234
+ tml_add_form_field( 'resetpass', 'pass2', array(
235
+ 'type' => 'password',
236
+ 'label' => __( 'Confirm new password' ),
237
+ 'id' => 'pass2',
238
+ 'priority' => 10,
239
+ ) );
240
+
241
+ tml_add_form_field( 'resetpass', 'indicator', array(
242
+ 'type' => 'custom',
243
+ 'content' => '<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">' . __( 'Strength indicator' ) . '</div>',
244
+ 'priority' => 10,
245
+ ) );
246
+
247
+ tml_add_form_field( 'resetpass', 'indicator_hint', array(
248
+ 'type' => 'custom',
249
+ 'content' => '<p class="description indicator-hint">' . wp_get_password_hint() . '</p>',
250
+ 'priority' => 10,
251
+ ) );
252
+
253
+ tml_add_form_field( 'resetpass', 'submit', array(
254
+ 'type' => 'submit',
255
+ 'value' => __( 'Reset Password' ),
256
+ 'priority' => 30,
257
+ ) );
258
+
259
+ $rp_cookie = 'wp-resetpass-' . COOKIEHASH;
260
+ if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
261
+ list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
262
+
263
+ tml_add_form_field( 'resetpass', 'rp_key', array(
264
+ 'type' => 'hidden',
265
+ 'value' => $rp_key,
266
+ 'priority' => 30,
267
+ ) );
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Register a form.
273
+ *
274
+ * @since 7.0
275
+ *
276
+ * @param string|Theme_My_Login_Form $form The form name or object.
277
+ * @param array $args {
278
+ * Optional. An array of arguments for registering a form.
279
+ *
280
+ * @type bool $show_links Whether to show links to other actions or not.
281
+ * }
282
+ * @return Theme_My_Login_Form The form object.
283
+ */
284
+ function tml_register_form( $form, $args = array() ) {
285
+
286
+ if ( ! $form instanceof Theme_My_Login_Form ) {
287
+ $form = new Theme_My_Login_Form( $form, $args );
288
+ }
289
+
290
+ return theme_my_login()->register_form( $form );
291
+ }
292
+
293
+ /**
294
+ * Unregister a form.
295
+ *
296
+ * @since 7.0
297
+ *
298
+ * @param string|Theme_My_Login_Form $form The form name or object.
299
+ */
300
+ function tml_unregister_form( $form ) {
301
+ theme_my_login()->unregister_form( $form );
302
+ }
303
+
304
+ /**
305
+ * Get a form.
306
+ *
307
+ * @since 7.0
308
+ *
309
+ * @param string|Theme_My_Login_Form $form Optional. The form name or object.
310
+ * @return Theme_My_Login_Form|bool The form object or false if it doesn't exist.
311
+ */
312
+ function tml_get_form( $form = '' ) {
313
+
314
+ if ( $form instanceof Theme_My_Login_Form ) {
315
+ return $form;
316
+ }
317
+
318
+ if ( empty( $form ) ) {
319
+ if ( $action = tml_get_action() ) {
320
+ $form = $action->get_name();
321
+ }
322
+ }
323
+
324
+ return theme_my_login()->get_form( $form );
325
+ }
326
+
327
+ /**
328
+ * Get all forms.
329
+ *
330
+ * @since 7.0
331
+ *
332
+ * @return array The forms.
333
+ */
334
+ function tml_get_forms() {
335
+ return theme_my_login()->get_forms();
336
+ }
337
+
338
+ /**
339
+ * Determine if a form exists.
340
+ *
341
+ * @since 7.0
342
+ *
343
+ * @param string $form The form name.
344
+ * @return bool True if the form exists or false otherwise.
345
+ */
346
+ function tml_form_exists( $form ) {
347
+ return apply_filters( 'tml_form_exists', array_key_exists( $form, tml_get_forms() ) );
348
+ }
349
+
350
+ /**
351
+ * Add a form field.
352
+ *
353
+ * @since 7.0
354
+ *
355
+ * @param string|Theme_My_Login_Form $form The form name or object.
356
+ * @param string|Theme_My_Login_Form_Field $field The field name or object.
357
+ * @param array {
358
+ * Optional. An array of arguments for registering a form field.
359
+ * }
360
+ */
361
+ function tml_add_form_field( $form, $field, $args = array() ) {
362
+
363
+ if ( ! $form = tml_get_form( $form ) ) {
364
+ return;
365
+ }
366
+
367
+ if ( ! $field instanceof Theme_My_Login_Form_Field ) {
368
+ $field = new Theme_My_Login_Form_Field( $form, $field, $args );
369
+ }
370
+
371
+ $form->add_field( $field );
372
+ }
373
+
374
+ /**
375
+ * Remove a form field.
376
+ *
377
+ * @since 7.0
378
+ *
379
+ * @param string|Theme_My_Login_Form $form The form name or object.
380
+ * @param string|Theme_My_Login_Form_Field $field The field name or object.
381
+ */
382
+ function tml_remove_form_field( $form, $field ) {
383
+
384
+ if ( ! $form = tml_get_form( $form ) ) {
385
+ return;
386
+ }
387
+
388
+ $form->remove_field( $field );
389
+ }
390
+
391
+ /**
392
+ * Get a form field.
393
+ *
394
+ * @since 7.0
395
+ *
396
+ * @param string|Theme_My_Login_Form $form The form name or object.
397
+ * @param string $field The field name.
398
+ * @return Theme_My_Login_Form_Field|bool The field object false if it doesn't exist.
399
+ */
400
+ function tml_get_form_field( $form, $field ) {
401
+
402
+ if ( ! $form = tml_get_form( $form ) ) {
403
+ return false;
404
+ }
405
+
406
+ return $form->get_field( $field );
407
+ }
408
+
409
+ /**
410
+ * Get all form fields.
411
+ *
412
+ * @since 7.0
413
+ *
414
+ * @param string|Theme_My_Login_Form $form The form name or object.
415
+ * @return array The form fields or false if the form doesn't exist.
416
+ */
417
+ function tml_get_form_fields( $form ) {
418
+
419
+ if ( ! $form = tml_get_form( $form ) ) {
420
+ return false;
421
+ }
422
+
423
+ return $form->get_fields();
424
+ }
includes/functions.php ADDED
@@ -0,0 +1,845 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Functions
8
+ */
9
+
10
+ /**
11
+ * Get the Theme My Login instance.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @return Theme_My_Login
16
+ */
17
+ function theme_my_login() {
18
+ return Theme_My_Login::get_instance();
19
+ }
20
+
21
+ /**
22
+ * Parse the query.
23
+ *
24
+ * @since 7.0
25
+ *
26
+ * @param $wp_query WP_Query The query object.
27
+ */
28
+ function tml_parse_query( $wp_query ) {
29
+
30
+ // Bail if not in the main loop
31
+ if ( ! $wp_query->is_main_query() ) {
32
+ return;
33
+ }
34
+
35
+ // Bail if not handling a TML action
36
+ if ( ! tml_is_action() ) {
37
+ return;
38
+ }
39
+
40
+ // Tell WordPress that this is a page
41
+ $wp_query->is_page = true;
42
+ $wp_query->is_singular = true;
43
+ $wp_query->is_single = false;
44
+ $wp_query->is_home = false;
45
+
46
+ // No need to calculate found rows
47
+ $wp_query->set( 'no_found_rows', true );
48
+
49
+ // Matter of fact, no need to query anything
50
+ $wp_query->set( 'post__in', array( 0 ) );
51
+ }
52
+
53
+ /**
54
+ * Add TML data to the query.
55
+ *
56
+ * @since 7.0
57
+ *
58
+ * @param array $posts The posts.
59
+ * @param WP_Query $wp_query The query object.
60
+ * @return array The posts.
61
+ */
62
+ function tml_the_posts( $posts, $wp_query ) {
63
+
64
+ // Bail if not in the main loop
65
+ if ( ! $wp_query->is_main_query() ) {
66
+ return $posts;
67
+ }
68
+
69
+ // Bail if not handling a TML action
70
+ if ( ! tml_is_action() ) {
71
+ return $posts;
72
+ }
73
+
74
+ if ( ! $post = tml_action_has_page() ) {
75
+ // Fake a post
76
+ $post = array(
77
+ 'ID' => 0,
78
+ 'post_type' => 'page',
79
+ 'post_content' => sprintf( '[theme-my-login action="%s"]', tml_get_action()->get_name() ),
80
+ 'post_title' => tml_get_action_title(),
81
+ 'post_name' => tml_get_action_slug(),
82
+ 'ping_status' => 'closed',
83
+ 'comment_status' => 'closed',
84
+ 'filter' => 'raw',
85
+ );
86
+ $post = new WP_Post( (object) $post );
87
+ }
88
+
89
+ return array( $post );
90
+ }
91
+
92
+ /**
93
+ * Remove undesired actions and filters on TML pages.
94
+ *
95
+ * @since 7.0
96
+ */
97
+ function tml_remove_default_actions_and_filters() {
98
+
99
+ if ( ! tml_is_action() ) {
100
+ return;
101
+ }
102
+
103
+ // Remove actions
104
+ remove_action( 'wp_head', 'feed_links', 2 );
105
+ remove_action( 'wp_head', 'feed_links_extra', 3 );
106
+ remove_action( 'wp_head', 'rsd_link', 10 );
107
+ remove_action( 'wp_head', 'wlwmanifest_link', 10 );
108
+ remove_action( 'wp_head', 'parent_post_rel_link', 10 );
109
+ remove_action( 'wp_head', 'start_post_rel_link', 10 );
110
+ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
111
+ remove_action( 'wp_head', 'rel_canonical', 10 );
112
+
113
+ // Remove filters
114
+ remove_filter( 'template_redirect', 'redirect_canonical' );
115
+ }
116
+
117
+ /**
118
+ * Get the page template for a TML action.
119
+ *
120
+ * @since 7.0
121
+ *
122
+ * @param string $template The page template path.
123
+ * @return string The page template path.
124
+ */
125
+ function tml_page_template( $template = 'page.php' ) {
126
+ if ( ! $action = tml_get_action() ) {
127
+ return $template;
128
+ }
129
+
130
+ $slug = $action->get_name();
131
+
132
+ $templates = array(
133
+ "$slug.php",
134
+ "theme-my-login-$slug.php",
135
+ "tml-$slug.php",
136
+ "page-$slug.php",
137
+ 'theme-my-login.php',
138
+ 'tml.php',
139
+ 'page.php',
140
+ );
141
+
142
+ if ( tml_action_has_page() ) {
143
+ $template = get_page_template_slug();
144
+ if ( $template && 0 === validate_file( $template ) ) {
145
+ array_unshift( $templates, $template );
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Filters the template hierarchy used for TML pages.
151
+ *
152
+ * @since 7.0
153
+ *
154
+ * @param array $templates The page template hierarchy.
155
+ */
156
+ $templates = apply_filters( 'tml_page_templates', $templates );
157
+
158
+ if ( $tml_template = locate_template( $templates ) ) {
159
+ return $tml_template;
160
+ }
161
+
162
+ return $template;
163
+ }
164
+
165
+ /**
166
+ * Add body classes to TML actions.
167
+ *
168
+ * @since 7.0
169
+ *
170
+ * @param array $classes The body classes.
171
+ * @return array The body classes.
172
+ */
173
+ function tml_body_class( $classes ) {
174
+ if ( $action = tml_get_action() ) {
175
+ $classes[] = 'tml-action';
176
+ $classes[] = 'tml-action-' . $action->get_name();
177
+ }
178
+ return $classes;
179
+ }
180
+
181
+ /**
182
+ * Enqueue TML's styles.
183
+ *
184
+ * @since 7.0
185
+ */
186
+ function tml_enqueue_styles() {
187
+ $suffix = SCRIPT_DEBUG ? '' : '.min';
188
+
189
+ wp_enqueue_style( 'theme-my-login', THEME_MY_LOGIN_URL . "assets/styles/theme-my-login$suffix.css", array(), THEME_MY_LOGIN_VERSION );
190
+ }
191
+
192
+ /**
193
+ * Enqueue TML's scripts.
194
+ *
195
+ * @since 7.0
196
+ *
197
+ */
198
+ function tml_enqueue_scripts() {
199
+ $suffix = SCRIPT_DEBUG ? '' : '.min';
200
+
201
+ wp_enqueue_script( 'theme-my-login', THEME_MY_LOGIN_URL . "assets/scripts/theme-my-login$suffix.js", array( 'jquery', 'password-strength-meter' ), THEME_MY_LOGIN_VERSION );
202
+ wp_localize_script( 'theme-my-login', 'themeMyLogin', array(
203
+ 'action' => tml_is_action() ? tml_get_action()->get_name() : '',
204
+ 'errors' => tml_get_errors()->get_error_codes(),
205
+ ) );
206
+ }
207
+
208
+ /**
209
+ * Add TML's rewrite tags.
210
+ *
211
+ * @since 7.0
212
+ */
213
+ function tml_add_rewrite_tags() {
214
+ if ( ! tml_use_permalinks() ) {
215
+ return;
216
+ }
217
+ add_rewrite_tag( '%action%', '([^/]+)' );
218
+ }
219
+
220
+ /**
221
+ * Add TML's rewrite rules.
222
+ *
223
+ * @since 7.0
224
+ */
225
+ function tml_add_rewrite_rules() {
226
+ if ( ! tml_use_permalinks() ) {
227
+ return;
228
+ }
229
+ foreach ( tml_get_actions() as $action ) {
230
+ add_rewrite_rule(
231
+ tml_get_action_slug( $action ) . '/?$',
232
+ 'index.php?action=' . $action->get_name(),
233
+ 'top'
234
+ );
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Flushes rewrite rules so that they will be rebuilt on the next page load.
240
+ *
241
+ * @since 7.0
242
+ */
243
+ function tml_flush_rewrite_rules() {
244
+ update_option( 'rewrite_rules', '' );
245
+ }
246
+
247
+ /**
248
+ * Filter the result of get_site_url().
249
+ *
250
+ * @since 7.0
251
+ *
252
+ * @param string $url The URL.
253
+ * @param string $path The path.
254
+ * @param string $scheme The URL scheme.
255
+ * @return string The filtered URL.
256
+ */
257
+ function tml_filter_site_url( $url, $path, $scheme ) {
258
+ global $pagenow;
259
+
260
+ // Bail if currently visiting wp-login.php
261
+ if ( 'wp-login.php' == $pagenow ) {
262
+ return $url;
263
+ }
264
+
265
+ // Bail if currently in /wp-admin
266
+ if ( is_admin() && did_action( 'admin_init' ) ) {
267
+ return $url;
268
+ }
269
+
270
+ // Bail if currently customizing
271
+ if ( is_customize_preview() ) {
272
+ return $url;
273
+ }
274
+
275
+ // Parse the URL
276
+ $parsed_url = parse_url( $url );
277
+
278
+ // Determine the path
279
+ $path = '';
280
+ if ( ! empty( $parsed_url['path'] ) ) {
281
+ $path = basename( trim( $parsed_url['path'], '/' ) );
282
+ }
283
+
284
+ // Parse the query
285
+ $query = array();
286
+ if ( ! empty( $parsed_url['query'] ) ) {
287
+ parse_str( htmlspecialchars_decode( $parsed_url['query'] ), $query );
288
+ }
289
+
290
+ // Determine the action
291
+ switch ( $path ) {
292
+ case 'wp-login.php' :
293
+ // Determine the action
294
+ $action = isset( $query['action'] ) ? $query['action'] : 'login';
295
+
296
+ // Fix some alias actions
297
+ if ( 'retrievepassword' == $action ) {
298
+ $action = 'lostpassword';
299
+ } elseif ( 'rp' == $action ) {
300
+ $action = 'resetpass';
301
+ }
302
+
303
+ // Unset the action
304
+ unset( $query['action'] );
305
+ break;
306
+
307
+ case 'wp-signup.php' :
308
+ $action = 'signup';
309
+ break;
310
+
311
+ case 'wp-activate.php' :
312
+ $action = 'activate';
313
+ break;
314
+
315
+ default :
316
+ return $url;
317
+ }
318
+
319
+ // Bail if not a TML action
320
+ if ( ! tml_action_exists( $action ) ) {
321
+ return $url;
322
+ }
323
+
324
+ // Get the URL
325
+ $url = tml_get_action_url( $action, $scheme, 'network_site_url' == current_filter() );
326
+
327
+ // Add the query
328
+ $url = add_query_arg( $query, $url );
329
+
330
+ return $url;
331
+ }
332
+
333
+ /**
334
+ * Filter the result of wp_logout_url().
335
+ *
336
+ * @since 7.0
337
+ *
338
+ * @param string $url The URL.
339
+ * @param string $redirect The redirect.
340
+ * @return string The logout URL.
341
+ */
342
+ function tml_filter_logout_url( $url, $redirect ) {
343
+
344
+ // Bail if not using permalinks
345
+ if ( ! tml_use_permalinks() ) {
346
+ return $url;
347
+ }
348
+
349
+ // Bail if logout action doesn't exist for some reason
350
+ if ( ! tml_action_exists( 'logout' ) ) {
351
+ return $url;
352
+ }
353
+
354
+ // Get the logout URL
355
+ $url = tml_get_action_url( 'logout' );
356
+
357
+ // Add the redirect query argument if needed
358
+ if ( ! empty( $redirect ) ) {
359
+ $url = add_query_arg( 'redirect_to', urlencode( $redirect ), $url );
360
+ }
361
+
362
+ // Add the nonce
363
+ $url = wp_nonce_url( $url, 'log-out' );
364
+
365
+ return $url;
366
+ }
367
+
368
+ /**
369
+ * Filter the result of get_edit_post_link().
370
+ *
371
+ * @since 7.0
372
+ *
373
+ * @param string $link The edit post link.
374
+ * @param int $post_id The post ID.
375
+ * @return string The edit post link.
376
+ */
377
+ function tml_filter_get_edit_post_link( $link, $post_id ) {
378
+ if ( tml_is_action() && 0 === $post_id ) {
379
+ $link = '';
380
+ }
381
+ return $link;
382
+ }
383
+
384
+ /**
385
+ * Add TML action type to the Customizer menu editor.
386
+ *
387
+ * @since 7.0
388
+ *
389
+ * @param array $item_types The available item types.
390
+ * @return array The available item types.
391
+ */
392
+ function tml_filter_customize_nav_menu_available_item_types( $item_types ) {
393
+ $item_types[] = array(
394
+ 'title' => __( 'Theme My Login Actions', 'theme-my-login' ),
395
+ 'type_label' => __( 'Theme My Login Action', 'theme-my-login' ),
396
+ 'type' => 'tml_action',
397
+ 'object' => 'tml_action',
398
+ );
399
+ return $item_types;
400
+ }
401
+
402
+ /**
403
+ * Add TML actions to the Customizer menu editor.
404
+ *
405
+ * @since 7.0
406
+ *
407
+ * @param array $items The avaialble items.
408
+ * @param string $type The item type.
409
+ * @param string $object The object.
410
+ * @param int $page The current page.
411
+ * @return array The available items.
412
+ */
413
+ function tml_filter_customize_nav_menu_available_items( $items, $type, $object, $page ) {
414
+ if ( 'tml_action' == $type && 0 == $page ) {
415
+ foreach ( tml_get_actions() as $action ) {
416
+ if ( ! $action->show_in_nav_menus ) {
417
+ continue;
418
+ }
419
+ $items[] = array(
420
+ 'id' => 'tml_action-' . $action->get_name(),
421
+ 'title' => $action->get_title(),
422
+ 'type' => 'tml_action',
423
+ 'type_label' => __( 'TML Action', 'theme-my-login' ),
424
+ 'object' => $action->get_name(),
425
+ 'object_id' => $action->get_name(),
426
+ 'url' => $action->get_url(),
427
+ );
428
+ }
429
+ }
430
+ return $items;
431
+ }
432
+
433
+ /**
434
+ * Set up TML action nav menu items.
435
+ *
436
+ * @since 7.0
437
+ *
438
+ * @param object $menu_item The menu item object.
439
+ * @return object The menu item object.
440
+ */
441
+ function tml_setup_nav_menu_item( $menu_item ) {
442
+ // Item to be added
443
+ if ( $menu_item instanceof Theme_My_Login_Action ) {
444
+ $menu_item = (object) array(
445
+ 'ID' => 0,
446
+ 'db_id' => 0,
447
+ 'menu_item_parent' => 0,
448
+ 'post_parent' => 0,
449
+ 'type' => 'tml_action',
450
+ 'type_label' => __( 'TML Action', 'theme-my-login' ),
451
+ 'object' => $menu_item->get_name(),
452
+ 'object_id' => -1, // Needed for AJAX save to work
453
+ 'title' => $menu_item->get_title(),
454
+ 'url' => $menu_item->get_url(),
455
+ 'target' => '',
456
+ 'attr_title' => '',
457
+ 'description' => '',
458
+ 'classes' => array(),
459
+ 'xfn' => '',
460
+ );
461
+
462
+ // Existing menu item
463
+ } elseif ( 'tml_action' == $menu_item->type ) {
464
+ $menu_item->object_id = $menu_item->ID;
465
+ $menu_item->type_label = __( 'TML Action', 'theme-my-login' );
466
+ if ( ! $action = tml_get_action( $menu_item->object ) ) {
467
+ $menu_item->_invalid = true;
468
+ } else {
469
+ $menu_item->url = $action->get_url();
470
+ if ( 'logout' == $menu_item->object ) {
471
+ $menu_item->url = wp_nonce_url( $menu_item->url, 'log-out' );
472
+ }
473
+ if ( ! is_admin() && ! $action->show_nav_menu_item ) {
474
+ $menu_item->_invalid = true;
475
+ }
476
+ }
477
+
478
+ // Legacy menu item
479
+ } elseif ( 'page' == $menu_item->object ) {
480
+ $slug = get_post_field( 'post_name', $menu_item->object_id );
481
+ if ( $action = tml_get_action( $slug ) ) {
482
+ if ( 'logout' == $action->get_name() ) {
483
+ $menu_item->url = wp_nonce_url( $action->get_url(), 'log-out' );
484
+ }
485
+ if ( ! is_admin() && ! $action->show_nav_menu_item ) {
486
+ $menu_item->_invalid = true;
487
+ }
488
+ }
489
+ }
490
+
491
+ return $menu_item;
492
+ }
493
+
494
+ /**
495
+ * Add classes to TML action nav menu items.
496
+ *
497
+ * @since 7.0
498
+ *
499
+ * @param array $classes The nav menu item classes.
500
+ * @param WP_Post $item The nav menu item.
501
+ * @return array The nav menu item classes.
502
+ */
503
+ function tml_nav_menu_css_class( $classes, $item ) {
504
+ if ( 'tml_action' == $item->type ) {
505
+ if ( tml_is_action( $item->object ) ) {
506
+ $classes[] = 'current-menu-item';
507
+ $classes[] = 'current_page_item';
508
+ }
509
+ }
510
+ return $classes;
511
+ }
512
+
513
+ /**
514
+ * Validate a new user's password.
515
+ *
516
+ * @since 7.0
517
+ *
518
+ * @param WP_Error $errors The registration errors.
519
+ * @return WP_Error The registration errors.
520
+ */
521
+ function tml_validate_new_user_password( $errors = null ) {
522
+ if ( empty( $errors ) ) {
523
+ $errors = new WP_Error();
524
+ }
525
+ if ( tml_allow_user_passwords() ) {
526
+ if ( empty( $_POST['user_pass1'] ) || empty( $_POST['user_pass2'] ) ) {
527
+ $errors->add( 'empty_password', __( '<strong>ERROR</strong>: Please enter a password.' ) );
528
+
529
+ } elseif ( false !== strpos( stripslashes( $_POST['user_pass1'] ), "\\" ) ) {
530
+ $errors->add( 'password_backslash', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ) );
531
+
532
+ } elseif ( $_POST['user_pass1'] !== $_POST['user_pass2'] ) {
533
+ $errors->add( 'password_mismatch', __( '<strong>ERROR</strong>: Please enter the same password in both password fields.' ) );
534
+ }
535
+ }
536
+ return $errors;
537
+ }
538
+
539
+ /**
540
+ * Filter the new user notification email.
541
+ *
542
+ * @since 7.0
543
+ *
544
+ * @param array $email The new user notification email parameters.
545
+ * @return array The new user notification email parameters.
546
+ */
547
+ function tml_add_password_notice_to_new_user_notification_email( $email ) {
548
+ if ( tml_allow_user_passwords() ) {
549
+ $email['message'] .= "\r\n" . __( 'If you have already set your own password, you may disregard this email and use the password you have already set.', 'theme-my-login' );
550
+ }
551
+ return $email;
552
+ }
553
+
554
+ /**
555
+ * Filter the user login before saving.
556
+ *
557
+ * @since 7.0
558
+ *
559
+ * @param string $sanitized_user_login The sanitized user login.
560
+ * @return string The sanitized user login.
561
+ */
562
+ function tml_set_user_login( $sanitized_user_login ) {
563
+ if ( tml_is_email_registration_type() && tml_is_post_request() ) {
564
+ if ( isset( $_POST['user_login'] ) && sanitize_user( $_POST['user_login'] ) == $sanitized_user_login && isset( $_POST['user_email'] ) ) {
565
+ $sanitized_user_login = sanitize_user( $_POST['user_email'] );
566
+ }
567
+ }
568
+ return $sanitized_user_login;
569
+ }
570
+
571
+ /**
572
+ * Filter the registration redirect when auto-login is enabled.
573
+ *
574
+ * @since 7.0.1
575
+ *
576
+ * @param string $url The registration redirect URL.
577
+ * @return string The registration redirect URL.
578
+ */
579
+ function tml_registration_redirect( $url ) {
580
+ if ( tml_allow_auto_login() ) {
581
+ $url = home_url();
582
+ }
583
+ return $url;
584
+ }
585
+
586
+ /**
587
+ * Buffer an action hook call so that it's content can be returned.
588
+ *
589
+ * @since 7.0
590
+ *
591
+ * @return string The result of the action call.
592
+ */
593
+ function tml_buffer_action_hook() {
594
+ $args = func_get_args();
595
+ if ( ! is_string( $args[0] ) ) {
596
+ return;
597
+ }
598
+ ob_start();
599
+ call_user_func_array( 'do_action', $args );
600
+ return ob_get_clean();
601
+ }
602
+
603
+ /**
604
+ * Get the username label.
605
+ *
606
+ * @since 7.0
607
+ *
608
+ * @param string $action Optional. The action.
609
+ * @return string The username label.
610
+ */
611
+ function tml_get_username_label( $action = '' ) {
612
+
613
+ if ( empty( $action ) ) {
614
+ $action = tml_get_action();
615
+ }
616
+
617
+ switch ( $action ) {
618
+ case 'register':
619
+ $label = __( 'Username' );
620
+ break;
621
+
622
+ case 'lostpassword':
623
+ case 'login':
624
+ default:
625
+ if ( tml_is_username_login_type() ) {
626
+ $label = __( 'Username' );
627
+ } elseif ( tml_is_email_login_type() ) {
628
+ $label = __( 'Email' );
629
+ } else {
630
+ $label = __( 'Username or Email Address' );
631
+ }
632
+ }
633
+
634
+ return apply_filters( 'tml_get_username_label', $label, $action );
635
+ }
636
+
637
+ /**
638
+ * Enforce the login type.
639
+ *
640
+ * @since 7.0
641
+ *
642
+ * @param null|WP_Error|WP_User $user
643
+ * @param string $username
644
+ * @param string $password
645
+ * @return null|WP_User|WP_Error
646
+ */
647
+ function tml_enforce_login_type( $user, $username, $password ) {
648
+ if ( tml_is_email_login_type() && null == $user ) {
649
+ return new WP_Error( 'invalid_email', __( '<strong>ERROR</strong>: Invalid email address.' ) );
650
+ }
651
+ return $user;
652
+ }
653
+
654
+ /**
655
+ * Set the new user password.
656
+ *
657
+ * @since 7.0
658
+ *
659
+ * @param int $user_id The user ID.
660
+ */
661
+ function tml_set_new_user_password( $user_id ) {
662
+ if ( ! tml_allow_user_passwords() ) {
663
+ return;
664
+ }
665
+
666
+ if ( ! $password = tml_get_request_value( 'user_pass1', 'post' ) ) {
667
+ return;
668
+ }
669
+
670
+ wp_set_password( $password, $user_id );
671
+ update_user_option( $user_id, 'default_password_nag', false, true );
672
+ }
673
+
674
+ /**
675
+ * Handle auto-login after registration.
676
+ *
677
+ * @since 7.0
678
+ *
679
+ * @param int $user_id The user ID.
680
+ */
681
+ function tml_handle_auto_login( $user_id ) {
682
+ if ( ! tml_allow_auto_login() ) {
683
+ return;
684
+ }
685
+
686
+ if ( 'wpmu_activate_blog' == current_filter() ) {
687
+ $user_id = func_get_arg( 1 );
688
+ }
689
+
690
+ wp_set_auth_cookie( $user_id );
691
+ }
692
+
693
+ /**
694
+ * Add an error.
695
+ *
696
+ * @since 7.0
697
+ *
698
+ * @param string $code The error code.
699
+ * @param string $message The error message.
700
+ * @param string $severity The error severity.
701
+ */
702
+ function tml_add_error( $code, $message, $data = '' ) {
703
+ if ( ! $form = tml_get_form() ) {
704
+ return;
705
+ }
706
+ $form->add_error( $code, $message, $data );
707
+ }
708
+
709
+ /**
710
+ * Get the errors.
711
+ *
712
+ * @since 7.0
713
+ *
714
+ * @return WP_Error
715
+ */
716
+ function tml_get_errors() {
717
+ if ( ! $form = tml_get_form() ) {
718
+ return new WP_Error;
719
+ }
720
+ return $form->get_errors();
721
+ }
722
+
723
+ /**
724
+ * Set the errors.
725
+ *
726
+ * @since 7.0
727
+ *
728
+ * @param WP_Error $errors The errors.
729
+ */
730
+ function tml_set_errors( WP_Error $errors ) {
731
+ if ( ! $form = tml_get_form() ) {
732
+ return;
733
+ }
734
+ $form->set_errors( $errors );
735
+ }
736
+
737
+ /**
738
+ * Determine if there are errors.
739
+ *
740
+ * @since 7.0
741
+ *
742
+ * @return bool
743
+ */
744
+ function tml_has_errors() {
745
+ if ( ! $form = tml_get_form() ) {
746
+ return false;
747
+ }
748
+
749
+ return $form->has_errors();
750
+ }
751
+
752
+ /**
753
+ * Get arbitrary data.
754
+ *
755
+ * @since 7.0
756
+ *
757
+ * @param string $name The property name.
758
+ * @param mixed $default The value to return if the property is not set.
759
+ * @return mixed The property value or $default if not set.
760
+ */
761
+ function tml_get_data( $name, $default = false ) {
762
+ return theme_my_login()->get_data( $name, $default );
763
+ }
764
+
765
+ /**
766
+ * Set arbitrary data.
767
+ *
768
+ * @since 7.0
769
+ *
770
+ * @param string|array $name The property name or an array of properties.
771
+ * @param mixed $value The property value.
772
+ */
773
+ function tml_set_data( $name, $value = '' ) {
774
+ theme_my_login()->set_data( $name, $value );
775
+ }
776
+
777
+ /**
778
+ * Get a value from the request.
779
+ *
780
+ * @since 7.0
781
+ *
782
+ * @param string $key The key of the value to retrieve.
783
+ * @param string $type Optional. The request type. Can be either 'get',
784
+ * 'post' or 'any'. Default 'any'.
785
+ * @return mixed The requested value.
786
+ */
787
+ function tml_get_request_value( $key, $type = 'any' ) {
788
+
789
+ $value = '';
790
+ $type = strtoupper( $type );
791
+
792
+ $types = array( 'POST', 'GET', 'REQUEST' );
793
+ if ( in_array( $type, $types ) ) {
794
+ $types = array( $type );
795
+ }
796
+
797
+ foreach ( $types as $type ) {
798
+ $type = '_' . $type;
799
+ if ( ! empty( $GLOBALS[ $type ] ) && array_key_exists( $key, $GLOBALS[ $type ] ) ) {
800
+ $value = $GLOBALS[ $type ][ $key ];
801
+ break;
802
+ }
803
+ }
804
+
805
+ if ( is_string( $value ) ) {
806
+ $value = wp_unslash( $value );
807
+ }
808
+
809
+ return $value;
810
+ }
811
+
812
+ /**
813
+ * Determine if the current request is a wp-login.php request.
814
+ *
815
+ * @since 7.0
816
+ *
817
+ * @return bool
818
+ */
819
+ function tml_is_wp_login() {
820
+ global $pagenow;
821
+
822
+ return ( 'wp-login.php' == $pagenow );
823
+ }
824
+
825
+ /**
826
+ * Determine if the current request is a GET request.
827
+ *
828
+ * @since 7.0
829
+ *
830
+ * @return bool
831
+ */
832
+ function tml_is_get_request() {
833
+ return 'GET' === strtoupper( $_SERVER['REQUEST_METHOD'] );
834
+ }
835
+
836
+ /**
837
+ * Determine if the current request is a POST request.
838
+ *
839
+ * @since 7.0
840
+ *
841
+ * @return bool
842
+ */
843
+ function tml_is_post_request() {
844
+ return 'POST' === strtoupper( $_SERVER['REQUEST_METHOD'] );
845
+ }
includes/hooks.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Hooks
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Core
8
+ */
9
+
10
+ /**
11
+ * Add Actions
12
+ */
13
+
14
+ // Actions and Forms
15
+ add_action( 'init', 'tml_register_default_actions', 0 );
16
+ add_action( 'init', 'tml_register_default_forms', 0 );
17
+
18
+ // Rewrite
19
+ add_action( 'init', 'tml_add_rewrite_tags' );
20
+ add_action( 'init', 'tml_add_rewrite_rules' );
21
+
22
+ // Widgets
23
+ add_action( 'widgets_init', 'Theme_My_Login_Widget::register' );
24
+
25
+ // Query
26
+ add_action( 'parse_query', 'tml_parse_query' );
27
+
28
+ // Pages
29
+ add_action( 'wp', 'tml_remove_default_actions_and_filters' );
30
+
31
+ // Template
32
+ add_action( 'template_redirect', 'tml_action_handler', 0 );
33
+ add_action( 'wp_enqueue_scripts', 'tml_enqueue_styles', 10 );
34
+ add_action( 'wp_enqueue_scripts', 'tml_enqueue_scripts', 10 );
35
+
36
+ // Registration
37
+ add_action( 'register_new_user', 'tml_set_new_user_password' );
38
+ add_action( 'register_new_user', 'tml_handle_auto_login' );
39
+
40
+ // Passwords
41
+ add_action( 'retrieved_password_key', 'tml_retrieve_password_notification', 10, 2 );
42
+
43
+ // Activation
44
+ add_action( 'tml_activate', 'tml_flush_rewrite_rules' );
45
+
46
+ // Deactivation
47
+ add_action( 'tml_deactivate', 'tml_flush_rewrite_rules' );
48
+
49
+ /**
50
+ * Add Filters
51
+ */
52
+
53
+ // Pages
54
+ add_filter( 'the_posts', 'tml_the_posts', 10, 2 );
55
+ add_filter( 'page_template', 'tml_page_template', 10, 3 );
56
+ add_filter( 'body_class', 'tml_body_class', 10, 2 );
57
+ add_filter( 'get_edit_post_link', 'tml_filter_get_edit_post_link', 10, 2 );
58
+
59
+ // URLs
60
+ add_filter( 'site_url', 'tml_filter_site_url', 10, 3 );
61
+ add_filter( 'network_site_url', 'tml_filter_site_url', 10, 3 );
62
+ add_filter( 'logout_url', 'tml_filter_logout_url', 10, 2 );
63
+
64
+ // Authentication
65
+ add_filter( 'authenticate', 'tml_enforce_login_type', 20, 3 );
66
+ if ( tml_is_username_login_type() ) {
67
+ remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
68
+ } elseif ( tml_is_email_login_type() ) {
69
+ remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );
70
+ }
71
+
72
+ // Registration
73
+ add_filter( 'registration_errors', 'tml_validate_new_user_password' );
74
+ add_action( 'pre_user_login', 'tml_set_user_login' );
75
+ add_filter( 'registration_redirect', 'tml_registration_redirect' );
76
+
77
+ // Notifications
78
+ add_filter( 'wp_new_user_notification_email', 'tml_add_password_notice_to_new_user_notification_email' );
79
+
80
+ // Customizer
81
+ add_filter( 'customize_nav_menu_available_item_types', 'tml_filter_customize_nav_menu_available_item_types', 10, 1 );
82
+ add_filter( 'customize_nav_menu_available_items', 'tml_filter_customize_nav_menu_available_items', 10, 4 );
83
+
84
+ // Nav menus
85
+ add_filter( 'wp_setup_nav_menu_item', 'tml_setup_nav_menu_item' );
86
+ add_filter( 'nav_menu_css_class', 'tml_nav_menu_css_class', 10, 2 );
87
+
88
+ // Extensions
89
+ add_filter( 'plugins_api', 'tml_add_extension_data_to_plugins_api', 10, 3 );
90
+ add_filter( 'pre_set_site_transient_update_plugins', 'tml_add_extension_data_to_plugins_transient', 10, 1 );
includes/ms-functions.php ADDED
@@ -0,0 +1,1147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Multisite Functions
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Multisite
8
+ */
9
+
10
+ /**
11
+ * Register the default multisite actions.
12
+ *
13
+ * @since 7.0
14
+ */
15
+ function tml_ms_register_default_actions() {
16
+ tml_register_action( 'signup', array(
17
+ 'title' => '',
18
+ 'slug' => 'signup',
19
+ 'handler' => 'tml_ms_signup_handler',
20
+ 'network' => true,
21
+ 'show_on_forms' => false,
22
+ 'show_in_widget' => false,
23
+ 'show_in_nav_menus' => false,
24
+ ) );
25
+
26
+ tml_register_action( 'activate', array(
27
+ 'title' => '',
28
+ 'slug' => 'activate',
29
+ 'handler' => 'tml_ms_activation_handler',
30
+ 'network' => true,
31
+ 'show_on_forms' => false,
32
+ 'show_in_widget' => false,
33
+ 'show_in_nav_menus' => false,
34
+ ) );
35
+ }
36
+
37
+ /**
38
+ * Register the default multisite forms.
39
+ *
40
+ * @since 7.0
41
+ */
42
+ function tml_ms_register_default_forms() {
43
+ tml_ms_register_user_signup_form();
44
+ tml_ms_register_blog_signup_form();
45
+ tml_ms_register_another_blog_signup_form();
46
+ tml_ms_register_activation_form();
47
+ }
48
+
49
+ /**
50
+ * Register the user signup form.
51
+ *
52
+ * @since 7.0
53
+ */
54
+ function tml_ms_register_user_signup_form() {
55
+
56
+ tml_register_form( 'user_signup', array(
57
+ 'action' => tml_get_action_url( 'signup' ),
58
+ 'attributes' => array(
59
+ 'id' => 'setupform',
60
+ 'novalidate' => 'novalidate',
61
+ ),
62
+ 'render_args' => array(
63
+ 'show_links' => false,
64
+ ),
65
+ ) );
66
+
67
+ tml_add_form_field( 'user_signup', 'stage', array(
68
+ 'type' => 'hidden',
69
+ 'value' => 'validate-user-signup',
70
+ 'priority' => 5,
71
+ ) );
72
+
73
+ if ( tml_is_default_registration_type() ) {
74
+ tml_add_form_field( 'user_signup', 'user_name', array(
75
+ 'type' => 'text',
76
+ 'label' => __( 'Username:' ),
77
+ 'description' => __( '(Must be at least 4 characters, letters and numbers only.)' ),
78
+ 'value' => '',
79
+ 'id' => 'user_name',
80
+ 'attributes' => array(
81
+ 'autocapitalize' => 'none',
82
+ 'autocorrect' => 'off',
83
+ 'maxlength' => 60,
84
+ ),
85
+ 'priority' => 10,
86
+ ) );
87
+ } else {
88
+ tml_add_form_field( 'user_signup', 'user_name', array(
89
+ 'type' => 'hidden',
90
+ 'label' => '',
91
+ 'value' => 'user' . md5( microtime() ),
92
+ 'id' => 'user_name',
93
+ 'priority' => 10,
94
+ ) );
95
+ }
96
+
97
+ tml_add_form_field( 'user_signup', 'user_email', array(
98
+ 'type' => 'email',
99
+ 'label' => __( 'Email&nbsp;Address:' ),
100
+ 'description' => __( 'We send your registration email to this address. (Double-check your email address before continuing.)' ),
101
+ 'value' => '',
102
+ 'id' => 'user_email',
103
+ 'attributes' => array(
104
+ 'maxlength' => 200,
105
+ ),
106
+ 'priority' => 15,
107
+ ) );
108
+
109
+ $active_signup = tml_ms_signup_get_active_signup();
110
+
111
+ if ( 'blog' == $active_signup ) {
112
+ tml_add_form_field( 'user_signup', 'signup_for', array(
113
+ 'type' => 'hidden',
114
+ 'value' => 'blog',
115
+ 'id' => 'signupblog',
116
+ 'priority' => 20,
117
+ ) );
118
+ } elseif ( 'user' == $active_signup ) {
119
+ tml_add_form_field( 'user_signup', 'signup_for', array(
120
+ 'type' => 'hidden',
121
+ 'value' => 'user',
122
+ 'id' => 'signupuser',
123
+ 'priority' => 20,
124
+ ) );
125
+ } else {
126
+ tml_add_form_field( 'user_signup', 'signup_for', array(
127
+ 'type' => 'radio-group',
128
+ 'options' => array(
129
+ 'blog' => __( 'Gimme a site!' ),
130
+ 'user' => __( 'Just a username, please.' ),
131
+ ),
132
+ 'value' => isset( $_POST['signup_for'] ) ? $_POST['signup_for'] : 'blog',
133
+ 'priority' => 20,
134
+ ) );
135
+ }
136
+
137
+ tml_add_form_field( 'user_signup', 'submit', array(
138
+ 'type' => 'submit',
139
+ 'name' => 'submit',
140
+ 'value' => __( 'Next' ),
141
+ 'priority' => 25,
142
+ ) );
143
+ }
144
+
145
+ /**
146
+ * Register the blog signup form.
147
+ *
148
+ * @since 7.0
149
+ */
150
+ function tml_ms_register_blog_signup_form() {
151
+
152
+ tml_register_form( 'blog_signup', array(
153
+ 'action' => tml_get_action_url( 'signup' ),
154
+ 'attributes' => array(
155
+ 'id' => 'setupform',
156
+ ),
157
+ 'render_args' => array(
158
+ 'show_links' => false,
159
+ )
160
+ ) );
161
+
162
+ tml_add_form_field( 'blog_signup', 'stage', array(
163
+ 'type' => 'hidden',
164
+ 'value' => 'validate-blog-signup',
165
+ 'priority' => 5,
166
+ ) );
167
+ tml_add_form_field( 'blog_signup', 'user_name', array(
168
+ 'type' => 'hidden',
169
+ 'priority' => 5,
170
+ ) );
171
+ tml_add_form_field( 'blog_signup', 'user_email', array(
172
+ 'type' => 'hidden',
173
+ 'priority' => 5,
174
+ ) );
175
+
176
+ tml_ms_add_blog_signup_form_fields( 'blog_signup' );
177
+
178
+ tml_add_form_field( 'blog_signup', 'submit', array(
179
+ 'type' => 'submit',
180
+ 'value' => __( 'Signup' ),
181
+ 'priority' => 30,
182
+ ) );
183
+ }
184
+
185
+ /**
186
+ * Register another blog signup form.
187
+ *
188
+ * @since 7.0
189
+ */
190
+ function tml_ms_register_another_blog_signup_form() {
191
+
192
+ tml_register_form( 'another_blog_signup', array(
193
+ 'action' => tml_get_action_url( 'signup' ),
194
+ 'attributes' => array(
195
+ 'id' => 'setupform',
196
+ ),
197
+ 'render_args' => array(
198
+ 'show_links' => false,
199
+ )
200
+ ) );
201
+
202
+ tml_add_form_field( 'another_blog_signup', 'stage', array(
203
+ 'type' => 'hidden',
204
+ 'value' => 'gimmeanotherblog',
205
+ 'priority' => 5,
206
+ ) );
207
+
208
+ tml_ms_add_blog_signup_form_fields( 'another_blog_signup' );
209
+
210
+ tml_add_form_field( 'another_blog_signup', 'submit', array(
211
+ 'type' => 'submit',
212
+ 'value' => __( 'Create Site' ),
213
+ 'priority' => 30,
214
+ ) );
215
+ }
216
+
217
+ /**
218
+ * Add the blog signup form fields.
219
+ *
220
+ * @since 7.0
221
+ *
222
+ * @param string $form The form name.
223
+ */
224
+ function tml_ms_add_blog_signup_form_fields( $form ) {
225
+ $current_network = get_network();
226
+
227
+ if ( ! is_subdomain_install() ) {
228
+ $control_after = '<br />';
229
+ if ( ! is_user_logged_in() ) {
230
+ $control_after .= '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), $current_network->domain . $current_network->path . __( 'sitename' ) ) . '</strong>) ';
231
+ $control_after .= __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
232
+ }
233
+
234
+ tml_add_form_field( $form, 'blogname', array(
235
+ 'type' => 'text',
236
+ 'label' => __( 'Site Name: '),
237
+ 'value' => '',
238
+ 'id' => 'blogname',
239
+ 'attributes' => array(
240
+ 'maxlength' => 60,
241
+ ),
242
+ 'priority' => 10,
243
+ 'render_args' => array(
244
+ 'control_before' => '<span class="prefix_address">' . $current_network->domain . $current_network->path . '</span>',
245
+ 'control_after' => $control_after,
246
+ ),
247
+ ) );
248
+ } else {
249
+ $control_after = '<span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_network->domain ) ) . '</span><br />';
250
+ if ( ! is_user_logged_in() ) {
251
+ $control_after .= '<p>(<strong>' . sprintf( __( 'Your address will be %s.' ), __( 'domain' ) . '.' . $site_domain . $current_network->path ) . '</strong>) ';
252
+ $control_after .= __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
253
+ }
254
+
255
+ tml_add_form_field( $form, 'blogname', array(
256
+ 'type' => 'text',
257
+ 'label' => __( 'Site Domain:' ),
258
+ 'value' => '',
259
+ 'id' => 'blogname',
260
+ 'attributes' => array(
261
+ 'maxlength' => 60,
262
+ ),
263
+ 'priority' => 10,
264
+ 'render_args' => array(
265
+ 'control_after' => $control_after,
266
+ ),
267
+ ) );
268
+ }
269
+
270
+ tml_add_form_field( $form, 'blog_title', array(
271
+ 'type' => 'text',
272
+ 'label' => __( 'Site Title:' ),
273
+ 'id' => 'blog_title',
274
+ 'priority' => 15,
275
+ ) );
276
+
277
+ if ( $language_field = tml_ms_render_blog_signup_language_field() ) {
278
+ tml_add_form_field( $form, 'site_language', array(
279
+ 'type' => 'custom',
280
+ 'content' => $language_field,
281
+ 'priority' => 20,
282
+ ) );
283
+ }
284
+
285
+ tml_add_form_field( $form, 'blog_public', array(
286
+ 'type' => 'radio-group',
287
+ 'label' => __( 'Privacy:' ),
288
+ 'value' => isset( $_POST['blog_public'] ) && 0 == $_POST['blog_public'] ? 0 : 1,
289
+ 'options' => array(
290
+ '1' => __( 'Yes' ),
291
+ '0' => __( 'No' ),
292
+ ),
293
+ 'priority' => 25,
294
+ 'render_args' => array(
295
+ 'control_before' => __( 'Allow search engines to index this site.' ) . '<br style="clear:both" />',
296
+ ),
297
+ ) );
298
+ }
299
+
300
+ /**
301
+ * Register the activation form.
302
+ *
303
+ * @since 7.0
304
+ */
305
+ function tml_ms_register_activation_form() {
306
+
307
+ tml_register_form( 'activate', array(
308
+ 'action' => tml_get_action_url( 'activate' ),
309
+ 'attributes' => array(
310
+ 'id' => 'activateform',
311
+ 'novalidate' => 'novalidate',
312
+ ),
313
+ 'render_args' => array(
314
+ 'show_links' => false,
315
+ ),
316
+ ) );
317
+
318
+ $key = tml_get_request_value( 'key' );
319
+
320
+ tml_add_form_field( 'activate', 'key', array(
321
+ 'type' => tml_allow_user_passwords() && $key ? 'hidden' : 'text',
322
+ 'label' => tml_allow_user_passwords() && $key ? '' : __( 'Activation Key:' ),
323
+ 'value' => $key,
324
+ 'id' => 'key',
325
+ 'priority' => 5,
326
+ ) );
327
+
328
+ if ( tml_allow_user_passwords() && $key ) {
329
+ tml_add_form_field( 'activate', 'user_pass1', array(
330
+ 'type' => 'password',
331
+ 'label' => __( 'Password' ),
332
+ 'id' => 'pass1',
333
+ 'attributes' => array(
334
+ 'autocomplete' => 'off',
335
+ ),
336
+ 'priority' => 10,
337
+ ) );
338
+
339
+ tml_add_form_field( 'activate', 'user_pass2', array(
340
+ 'type' => 'password',
341
+ 'label' => __( 'Confirm Password' ),
342
+ 'id' => 'pass2',
343
+ 'attributes' => array(
344
+ 'autocomplete' => 'off',
345
+ ),
346
+ 'priority' => 10,
347
+ ) );
348
+
349
+ tml_add_form_field( 'activate', 'indicator', array(
350
+ 'type' => 'custom',
351
+ 'content' => '<div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">' . __( 'Strength indicator' ) . '</div>',
352
+ 'priority' => 10,
353
+ ) );
354
+
355
+ tml_add_form_field( 'activate', 'indicator_hint', array(
356
+ 'type' => 'custom',
357
+ 'content' => '<p class="description indicator-hint">' . wp_get_password_hint() . '</p>',
358
+ 'priority' => 10,
359
+ ) );
360
+ }
361
+
362
+ tml_add_form_field( 'activate', 'submit', array(
363
+ 'type' => 'submit',
364
+ 'value' => __( 'Activate' ),
365
+ 'priority' => 15,
366
+ ) );
367
+ }
368
+
369
+ /**
370
+ * Handle the signup action.
371
+ *
372
+ * @since 7.0
373
+ */
374
+ function tml_ms_signup_handler() {
375
+
376
+ if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new'], get_site_option( 'illegal_names' ) ) ) {
377
+ wp_redirect( network_home_url() );
378
+ exit;
379
+ }
380
+
381
+ if ( ! is_multisite() ) {
382
+ wp_redirect( wp_registration_url() );
383
+ exit;
384
+ }
385
+
386
+ if ( ! is_main_site() ) {
387
+ wp_redirect( network_site_url( 'wp-signup.php' ) );
388
+ exit;
389
+ }
390
+
391
+ $active_signup = tml_ms_signup_get_active_signup();
392
+
393
+ $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
394
+
395
+ $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
396
+ switch ( $stage ) {
397
+ case 'validate-user-signup':
398
+ if ( $active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user' ) {
399
+ $result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
400
+ $user_name = $result['user_name'];
401
+ $user_email = $result['user_email'];
402
+ $errors = $result['errors'];
403
+
404
+ tml_set_data( 'signup_result', $result );
405
+
406
+ if ( $errors->get_error_code() ) {
407
+ tml_set_data( 'signup_form', 'user' );
408
+ return;
409
+ }
410
+
411
+ if ( 'blog' == $_POST['signup_for'] ) {
412
+ tml_set_data( 'signup_form', 'blog' );
413
+ return;
414
+ }
415
+
416
+ /** This filter is documented in wp-signup.php */
417
+ wpmu_signup_user( $user_name, $user_email, apply_filters( 'add_signup_meta', array() ) );
418
+ }
419
+ break;
420
+
421
+ case 'validate-blog-signup':
422
+ if ( $active_signup == 'all' || $active_signup == 'blog' ) {
423
+ $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
424
+ $user_name = $user_result['user_name'];
425
+ $user_email = $user_result['user_email'];
426
+ $user_errors = $user_result['errors'];
427
+
428
+ tml_set_data( 'signup_user_result', $user_result );
429
+
430
+ if ( $user_errors->get_error_code() ) {
431
+ tml_set_data( 'signup_form'. 'user' );
432
+ return;
433
+ }
434
+
435
+ $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'] );
436
+ $domain = $result['domain'];
437
+ $path = $result['path'];
438
+ $blogname = $result['blogname'];
439
+ $blog_title = $result['blog_title'];
440
+ $errors = $result['errors'];
441
+
442
+ tml_set_data( 'signup_result', $result );
443
+
444
+ if ( $errors->get_error_code() ) {
445
+ tml_set_data( 'signup_form', 'blog' );
446
+ return;
447
+ }
448
+
449
+ $public = (int) $_POST['blog_public'];
450
+ $signup_meta = array(
451
+ 'lang_id' => 1,
452
+ 'public' => $public,
453
+ );
454
+
455
+ // Handle the language setting for the new site.
456
+ if ( ! empty( $_POST['site_language'] ) ) {
457
+ $languages = tml_ms_signup_get_available_languages();
458
+ if ( in_array( $_POST['site_language'], $languages ) ) {
459
+ $language = wp_unslash( sanitize_text_field( $_POST['site_language'] ) );
460
+ if ( $language ) {
461
+ $signup_meta['WPLANG'] = $language;
462
+ }
463
+ }
464
+ }
465
+
466
+ /** This filter is documented in wp-signup.php */
467
+ $meta = apply_filters( 'add_signup_meta', $signup_meta );
468
+
469
+ wpmu_signup_blog( $domain, $path, $blog_title, $user_name, $user_email, $meta );
470
+ }
471
+ break;
472
+
473
+ case 'gimmeanotherblog':
474
+ if ( ! is_user_logged_in() ) {
475
+ die;
476
+ }
477
+
478
+ $current_user = wp_get_current_user();
479
+
480
+ $result = wpmu_validate_blog_signup( $_POST['blogname'], $_POST['blog_title'], $current_user );
481
+ $domain = $result['domain'];
482
+ $path = $result['path'];
483
+ $blogname = $result['blogname'];
484
+ $blog_title = $result['blog_title'];
485
+ $errors = $result['errors'];
486
+
487
+ tml_set_data( 'signup_result', $result );
488
+
489
+ if ( $errors->get_error_code() ) {
490
+ tml_set_data( 'signup_form', 'another_blog' );
491
+ return;
492
+ }
493
+
494
+ $public = (int) $_POST['blog_public'];
495
+ $blog_meta_defaults = array(
496
+ 'lang_id' => 1,
497
+ 'public' => $public,
498
+ );
499
+
500
+ // Handle the language setting for the new site.
501
+ if ( ! empty( $_POST['site_language'] ) ) {
502
+
503
+ $languages = tml_ms_signup_get_available_languages();
504
+
505
+ if ( in_array( $_POST['site_language'], $languages ) ) {
506
+ $language = wp_unslash( sanitize_text_field( $_POST['site_language'] ) );
507
+
508
+ if ( $language ) {
509
+ $blog_meta_defaults['WPLANG'] = $language;
510
+ }
511
+ }
512
+ }
513
+
514
+ /** This filter is documented in wp-signup.php */
515
+ $meta_defaults = apply_filters( 'signup_create_blog_meta', $blog_meta_defaults );
516
+
517
+ /** This filter is documented in wp-signup.php */
518
+ $meta = apply_filters( 'add_signup_meta', $meta_defaults );
519
+
520
+ $blog_id = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, get_current_network_id() );
521
+
522
+ tml_set_data( 'signup_blog_id', $blog_id );
523
+ break;
524
+
525
+ case 'default':
526
+ default:
527
+ do_action( 'preprocess_signup_form' );
528
+ break;
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Render the signup action.
534
+ *
535
+ * @since 7.0
536
+ *
537
+ * @param string $content The shortcode content.
538
+ * @param string $action The shortcode action.
539
+ * @param array $atts The shortcode attributes.
540
+ * @return string The signup content if $action is 'signup' or the original content otherwise.
541
+ */
542
+ function tml_ms_filter_signup_shortcode( $content = '', $action = 'signup', $atts = array() ) {
543
+ if ( 'signup' != $action ) {
544
+ return $content;
545
+ }
546
+
547
+ $content = '';
548
+
549
+ $active_signup = tml_ms_signup_get_active_signup();
550
+
551
+ if ( current_user_can( 'manage_network' ) ) {
552
+ $content .= '<div class="tml-messages">' . __( 'Greetings Network Administrator!' ) . ' ';
553
+ switch ( $active_signup ) {
554
+ case 'none':
555
+ $content .= __( 'The network currently disallows registrations.' );
556
+ break;
557
+
558
+ case 'blog':
559
+ $content .= __( 'The network currently allows site registrations.' );
560
+ break;
561
+
562
+ case 'user':
563
+ $content .= __( 'The network currently allows user registrations.' );
564
+ break;
565
+
566
+ default:
567
+ $content .= __( 'The network currently allows both site and user registrations.' );
568
+ break;
569
+ }
570
+ $content .= ' ' . sprintf(
571
+ __( 'To change or disable registration go to your <a href="%s">Options page</a>.' ),
572
+ esc_url( network_admin_url( 'settings.php' ) )
573
+ );
574
+ $content .= '</div>';
575
+ }
576
+
577
+ $newblogname = isset( $_GET['new'] ) ? strtolower( preg_replace( '/^-|-$|[^-a-zA-Z0-9]/', '', $_GET['new'] ) ) : null;
578
+
579
+ if ( $active_signup == 'none' ) {
580
+ $content .= __( 'Registration has been disabled.' );
581
+ } elseif ( $active_signup == 'blog' && ! is_user_logged_in() ) {
582
+ $content .= sprintf(
583
+ __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ),
584
+ wp_login_url( network_site_url( 'wp-signup.php' ) )
585
+ );
586
+ } else {
587
+ $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default';
588
+ switch ( $stage ) {
589
+ case 'validate-user-signup':
590
+ if ( $active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user' ) {
591
+ $result = tml_get_data( 'signup_result' );
592
+ $form = tml_get_data( 'signup_form' );
593
+ if ( 'user' == $form ) {
594
+ $content .= tml_ms_get_user_signup_form( $result['user_name'], $result['user_email'], $result['errors'] );
595
+ } elseif ( 'blog' == $form ) {
596
+ $content .= tml_ms_get_blog_signup_form( $result['user_name'], $result['user_email'] );
597
+ } else {
598
+ $content .= '<h2>' . sprintf( __( '%s is your new username' ), tml_is_email_login_type() ? $result['user_email'] : $result['user_name'] ) . '</h2>';
599
+ $content .= '<p>' . __( 'But, before you can start using your new username, <strong>you must activate it</strong>.' ) . '</p>';
600
+ $content .= '<p>' . sprintf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $result['user_email'] . '</strong>' ) . '</p>';
601
+ $content .= '<p>' . __( 'If you do not activate your username within two days, you will have to sign up again.' ) . '</p>';
602
+ }
603
+ } else {
604
+ $content .= __( 'User registration has been disabled.' );
605
+ }
606
+ break;
607
+
608
+ case 'validate-blog-signup':
609
+ if ( $active_signup == 'all' || $active_signup == 'blog' ) {
610
+ $user_result = tml_get_data( 'signup_user_result' );
611
+ $blog_result = tml_get_data( 'signup_result' );
612
+ $form = tml_get_data( 'signup_form' );
613
+ if ( 'user' == $form ) {
614
+ $content .= tml_ms_get_user_signup_form( $user_result['user_name'], $user_result['user_email'], $user_result['errors'] );
615
+ } elseif ( 'blog' == $form ) {
616
+ $content .= tml_ms_get_blog_signup_form( $user_result['user_name'], $user_result['user_email'], $blog_result['blogname'], $blog_result['blog_title'], $blog_result['errors'] );
617
+ } else {
618
+ $content .= '<h2>' . sprintf( __( 'Congratulations! Your new site, %s, is almost ready.' ), "<a href='http://{$blog_result['domain']}{$blog_result['path']}'>{$blog_result['blog_title']}</a>" ) . '</h2>';
619
+ $content .= '<p>' . __( 'But, before you can start using your site, <strong>you must activate it</strong>.' ) . '</p>';
620
+ $content .= '<p>' . sprintf( __( 'Check your inbox at %s and click the link given.' ), '<strong>' . $user_result['user_email'] . '</strong>' ) . '</p>';
621
+ $content .= '<p>' . __( 'If you do not activate your site within two days, you will have to sign up again.' ) . '</p>';
622
+ $content .= '<h2>' . __( 'Still waiting for your email?' ) . '</h2>';
623
+ $content .= '<p>' .
624
+ __( 'If you haven&#8217;t received your email yet, there are a number of things you can do:' ) . '
625
+ <ul id="noemail-tips">
626
+ <li><p><strong>' . __( 'Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.' ) . '</strong></p></li>
627
+ <li><p>' . __( 'Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.' ) . '</p></li>
628
+ <li>' . sprintf( __( 'Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email.' ), $user_result['user_email'] ) . '</li>
629
+ </ul>
630
+ </p>';
631
+ }
632
+ } else {
633
+ $content .= __( 'Site registration has been disabled.' );
634
+ }
635
+ break;
636
+
637
+ case 'gimmeanotherblog':
638
+ $result = tml_get_data( 'signup_result' );
639
+ $form = tml_get_data( 'signup_form' );
640
+ if ( 'another_blog' == $form ) {
641
+ $content .= tml_ms_get_another_blog_signup_form( $result['blogname'], $result['blog_title'], $result['errors'] );
642
+ } else {
643
+ $blog_id = tml_get_data( 'signup_blog_id' );
644
+ if ( ! is_wp_error( $blog_id ) ) {
645
+ if ( $blog_id ) {
646
+ switch_to_blog( $blog_id );
647
+ $home_url = home_url( '/' );
648
+ $login_url = wp_login_url();
649
+ restore_current_blog();
650
+ } else {
651
+ $home_url = 'http://' . $result['domain'] . $result['path'];
652
+ $login_url = 'http://' . $result['domain'] . $result['path'] . 'wp-login.php';
653
+ }
654
+
655
+ $site = sprintf( '<a href="%1$s">%2$s</a>',
656
+ esc_url( $home_url ),
657
+ $result['blog_title']
658
+ );
659
+
660
+ $content .= '<h2>' . sprintf( __( 'The site %s is yours.' ), $site ) . '</h2>';
661
+ $content .= sprintf(
662
+ __( '%1$s is your new site. <a href="%2$s">Log in</a> as &#8220;%3$s&#8221; using your existing password.' ),
663
+ sprintf(
664
+ '<a href="%s">%s</a>',
665
+ esc_url( $home_url ),
666
+ untrailingslashit( $result['domain'] . $result['path'] )
667
+ ),
668
+ esc_url( $login_url ),
669
+ wp_get_current_user()->user_login
670
+ );
671
+ }
672
+ }
673
+ break;
674
+
675
+ case 'default':
676
+ default:
677
+ $user_email = isset( $_POST['user_email'] ) ? $_POST['user_email'] : '';
678
+
679
+ do_action( 'preprocess_signup_form' );
680
+
681
+ if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) {
682
+ $content .= tml_ms_get_another_blog_signup_form( $newblogname );
683
+ } elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) {
684
+ $content .= tml_ms_get_user_signup_form( $newblogname, $user_email );
685
+ } elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) {
686
+ $content .= __( 'Sorry, new registrations are not allowed at this time.' );
687
+ } else {
688
+ $content .= __( 'You are logged in already. No need to register again!' );
689
+ }
690
+
691
+ if ( $newblogname ) {
692
+ $newblog = get_blogaddress_by_name( $newblogname );
693
+
694
+ if ( $active_signup == 'blog' || $active_signup == 'all' ) {
695
+ $content .= sprintf(
696
+ '<p><em>' . __( 'The site you were looking for, %s, does not exist, but you can create it now!' ) . '</em></p>',
697
+ '<strong>' . $newblog . '</strong>'
698
+ );
699
+ } else {
700
+ $content .= sprintf(
701
+ '<p><em>' . __( 'The site you were looking for, %s, does not exist.' ) . '</em></p>',
702
+ '<strong>' . $newblog . '</strong>'
703
+ );
704
+ }
705
+ }
706
+ break;
707
+ }
708
+ }
709
+
710
+ return $content;
711
+ }
712
+
713
+ /**
714
+ * Get signup form for a user.
715
+ *
716
+ * @since 7.0
717
+ *
718
+ * @param string $user_name The username.
719
+ * @param string $user_email The user's email.
720
+ * @param WP_Error $errors The WP_Error object.
721
+ */
722
+ function tml_ms_get_user_signup_form( $user_name = '', $user_email = '', $errors = '' ) {
723
+ if ( ! is_wp_error( $errors ) ) {
724
+ $errors = new WP_Error();
725
+ }
726
+
727
+ $signup_for = isset( $_POST['signup_for'] ) ? esc_html( $_POST['signup_for'] ) : 'blog';
728
+
729
+ /** This filter is documented in wp-signup.php */
730
+ $filtered_results = apply_filters( 'signup_user_init', compact( 'user_name', 'user_email', 'errors' ) );
731
+ $user_name = $filtered_results['user_name'];
732
+ $user_email = $filtered_results['user_email'];
733
+ $errors = $filtered_results['errors'];
734
+
735
+ $form = tml_get_form( 'user_signup' );
736
+
737
+ $fields = compact( 'user_name', 'user_email' );
738
+ foreach ( $fields as $field => $value ) {
739
+ if ( ! $field = $form->get_field( $field ) ) {
740
+ continue;
741
+ }
742
+
743
+ if ( $error = $errors->get_error_message( $field->get_name() ) ) {
744
+ $field->set_error( $error );
745
+ } else {
746
+ if ( null !== $value ) {
747
+ $field->set_value( $value );
748
+ }
749
+ }
750
+ }
751
+
752
+ return $form->render( array(
753
+ 'before' => '<h2>' . sprintf(
754
+ __( 'Get your own %s account in seconds' ),
755
+ get_network()->site_name
756
+ ) . '</h2>',
757
+ ) );
758
+ }
759
+
760
+ /**
761
+ * Get signup form for a blog.
762
+ *
763
+ * @since 7.0
764
+ *
765
+ * @param string $user_name The username.
766
+ * @param string $user_email The user's email.
767
+ * @param string $blogname The blogname.
768
+ * @param string $blog_title The title of the site.
769
+ * @param WP_Error $errors The WP_Error object.
770
+ * @return string The blog signup form.
771
+ */
772
+ function tml_ms_get_blog_signup_form( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
773
+ if ( ! is_wp_error( $errors ) ) {
774
+ $errors = new WP_Error();
775
+ }
776
+
777
+ /** This filter is documented in wp-signup.php */
778
+ $filtered_results = apply_filters( 'signup_blog_init', compact( 'user_name', 'user_email', 'blogname', 'blog_title', 'errors' ) );
779
+ $user_name = $filtered_results['user_name'];
780
+ $user_email = $filtered_results['user_email'];
781
+ $blogname = $filtered_results['blogname'];
782
+ $blog_title = $filtered_results['blog_title'];
783
+ $errors = $filtered_results['errors'];
784
+
785
+ if ( tml_is_default_registration_type() && empty( $blogname ) ) {
786
+ $blogname = $user_name;
787
+ }
788
+
789
+ $form = tml_get_form( 'blog_signup' );
790
+
791
+ $fields = compact( 'user_name', 'user_email', 'blogname', 'blog_title' );
792
+ foreach ( $fields as $field => $value ) {
793
+ if ( ! $field = $form->get_field( $field ) ) {
794
+ continue;
795
+ }
796
+
797
+ if ( $error = $errors->get_error_message( $field->get_name() ) ) {
798
+ $field->set_error( $error );
799
+ } else {
800
+ if ( null !== $value ) {
801
+ $field->set_value( $value );
802
+ }
803
+ }
804
+ }
805
+
806
+ return $form->render();
807
+ }
808
+
809
+ /**
810
+ * Get the signup form for another blog.
811
+ *
812
+ * @since 7.0
813
+ *
814
+ * @param string $blogname The blogname.
815
+ * @param string $blog_title The title of the site.
816
+ * @param WP_Error $errors The WP_Error object.
817
+ * @return string The blog signup form.
818
+ */
819
+ function tml_ms_get_another_blog_signup_form( $blogname = '', $blog_title = '', $errors = '' ) {
820
+ $current_user = wp_get_current_user();
821
+
822
+ if ( ! is_wp_error( $errors ) ) {
823
+ $errors = new WP_Error();
824
+ }
825
+
826
+ /** This filter is documented in wp-signup.php */
827
+ $filtered_results = apply_filters( 'signup_another_blog_init', compact( 'blogname', 'blog_title', 'errors' ) );
828
+ $blogname = $filtered_results['blogname'];
829
+ $blog_title = $filtered_results['blog_title'];
830
+ $errors = $filtered_results['errors'];
831
+
832
+ $before = '<h2>' . sprintf(
833
+ __( 'Get <em>another</em> %s site in seconds' ),
834
+ get_network()->site_name
835
+ ) . '</h2>';
836
+
837
+ $before .= '<p>' . sprintf( __( '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!' ), $current_user->display_name ) . '</p>';
838
+
839
+ $blogs = get_blogs_of_user( $current_user->ID );
840
+ if ( ! empty( $blogs ) ) {
841
+ $before .= '<p>' . __( 'Sites you are already a member of:' ) . '</p><ul>';
842
+ foreach ( $blogs as $blog ) {
843
+ $home_url = get_home_url( $blog->userblog_id );
844
+ $before .= '<li><a href="' . esc_url( $home_url ) . '">' . $home_url . '</a></li>';
845
+ }
846
+ $before .= '</ul>';
847
+ }
848
+
849
+ $before .= '<p>' . __( 'If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!' ) . '</p>';
850
+
851
+ $form = tml_get_form( 'another_blog_signup' );
852
+
853
+ $fields = compact( 'blogname', 'blog_title' );
854
+ foreach ( $fields as $field => $value ) {
855
+ if ( ! $field = $form->get_field( $field ) ) {
856
+ continue;
857
+ }
858
+
859
+ if ( $error = $errors->get_error_message( $field->get_name() ) ) {
860
+ $field->set_error( $error );
861
+ } else {
862
+ if ( null !== $value ) {
863
+ $field->set_value( $value );
864
+ }
865
+ }
866
+ }
867
+
868
+ return $form->render( compact( 'before' ) );
869
+ }
870
+
871
+ /**
872
+ * Render the signup language field.
873
+ *
874
+ * @since 7.0
875
+ *
876
+ * @return string The signup language field.
877
+ */
878
+ function tml_ms_render_blog_signup_language_field() {
879
+ $markup = '';
880
+
881
+ // Site Language.
882
+ $languages = tml_ms_signup_get_available_languages();
883
+ if ( ! empty( $languages ) ) {
884
+
885
+ $lang = get_site_option( 'WPLANG' );
886
+
887
+ if ( isset( $_POST['site_language'] ) ) {
888
+ $lang = $_POST['site_language'];
889
+ }
890
+
891
+ // Use US English if the default isn't available.
892
+ if ( ! in_array( $lang, $languages ) ) {
893
+ $lang = '';
894
+ }
895
+
896
+ $markup .= wp_dropdown_languages( array(
897
+ 'echo' => false,
898
+ 'name' => 'site_language',
899
+ 'id' => 'site-language',
900
+ 'selected' => $lang,
901
+ 'languages' => $languages,
902
+ 'show_available_translations' => false,
903
+ ) );
904
+ }
905
+
906
+ return $markup;
907
+ }
908
+
909
+ /**
910
+ * Get the languages available during the site/user signup process.
911
+ *
912
+ * @since 7.0
913
+ *
914
+ * @return array The available languages.
915
+ */
916
+ function tml_ms_signup_get_available_languages() {
917
+ /** This filter is documented in wp-signup.php */
918
+ $languages = (array) apply_filters( 'signup_get_available_languages', get_available_languages() );
919
+
920
+ /*
921
+ * Strip any non-installed languages and return.
922
+ *
923
+ * Re-call get_available_languages() here in case a language pack was installed
924
+ * in a callback hooked to the 'signup_get_available_languages' filter before this point.
925
+ */
926
+ return array_intersect_assoc( $languages, get_available_languages() );
927
+ }
928
+
929
+ /**
930
+ * Get the activate signup status.
931
+ *
932
+ * @since 7.0
933
+ *
934
+ * @return string The active signup status.
935
+ */
936
+ function tml_ms_signup_get_active_signup() {
937
+ /** This filter is documented in wp-signup.php */
938
+ return apply_filters( 'wpmu_active_signup', get_site_option( 'registration', 'none' ) );
939
+ }
940
+
941
+ /**
942
+ * Handle the activate action.
943
+ *
944
+ * @since 7.0
945
+ */
946
+ function tml_ms_activation_handler() {
947
+ global $wp_object_cache;
948
+
949
+ define( 'WP_INSTALLING', true );
950
+
951
+ if ( ! is_multisite() ) {
952
+ wp_redirect( wp_registration_url() );
953
+ exit;
954
+ }
955
+
956
+ if ( is_object( $wp_object_cache ) ) {
957
+ $wp_object_cache->cache_enabled = false;
958
+ }
959
+
960
+ if ( ! empty( $_GET['key'] ) || ! empty( $_POST['key'] ) ) {
961
+ $key = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
962
+
963
+ if ( tml_allow_user_passwords() ) {
964
+ $errors = tml_validate_new_user_password();
965
+ if ( $errors->get_error_code() ) {
966
+ tml_set_data( 'activation_result', $errors );
967
+ return;
968
+ }
969
+ }
970
+
971
+ $result = wpmu_activate_signup( $key );
972
+
973
+ if ( ! is_wp_error( $result ) ) {
974
+ $activation_redirect = null;
975
+ if ( tml_allow_user_passwords() ) {
976
+ $activation_redirect = isset( $result['blog_id'] ) ? get_home_url( $result['blog_id'] ) : network_home_url();
977
+ }
978
+
979
+ /**
980
+ * Filters the URL to redirect to after activation.
981
+ *
982
+ * @since 7.0
983
+ *
984
+ * @param string $url The URL ro redirect to after activation.
985
+ * @param int $user_id The user ID.
986
+ * @param int $blog_id The blog ID.
987
+ */
988
+ $activation_redirect = apply_filters( 'tml_ms_activation_redirect', $activation_redirect, $result['user_id'], isset( $result['blog_id'] ) ? $result['blog_id'] : null );
989
+
990
+ if ( ! empty( $activation_redirect ) ) {
991
+ wp_safe_redirect( $activation_redirect );
992
+ exit;
993
+ }
994
+ }
995
+
996
+ tml_set_data( 'activation_result', $result );
997
+ }
998
+ }
999
+
1000
+ /**
1001
+ * Render the activate action.
1002
+ *
1003
+ * @since 7.0
1004
+ *
1005
+ * @param string $content The shortcode content.
1006
+ * @param string $action The shortcode action.
1007
+ * @param array $atts The shortcode attributes.
1008
+ * @return string The signup content if $action is 'signup' or the original content otherwise.
1009
+ */
1010
+ function tml_ms_filter_activation_shortcode( $content = '', $action = 'signup', $atts = array() ) {
1011
+ if ( 'activate' != $action ) {
1012
+ return $content;
1013
+ }
1014
+
1015
+ $content = '';
1016
+
1017
+ if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) {
1018
+ $content .= tml_get_form( 'activate' )->render( array(
1019
+ 'before' => '<h2>' . __( 'Activation Key Required' ) . '</h2>',
1020
+ ) );
1021
+ } else {
1022
+ $result = tml_get_data( 'activation_result' );
1023
+ if ( is_wp_error( $result ) ) {
1024
+ if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
1025
+ $signup = $result->get_error_data();
1026
+
1027
+ $content .= '<h2>' . __( 'Your account is now active!' ) . '</h2>';
1028
+ $content .= '<p class="lead-in">';
1029
+ if ( $signup->domain . $signup->path == '' ) {
1030
+ $content .= sprintf(
1031
+ __( 'Your account has been activated. You may now <a href="%1$s">log in</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>.' ),
1032
+ network_site_url( 'wp-login.php', 'login' ),
1033
+ $signup->user_login,
1034
+ $signup->user_email,
1035
+ wp_lostpassword_url()
1036
+ );
1037
+ } else {
1038
+ $content .= sprintf(
1039
+ __( 'Your site at %1$s is active. You may now log in to your 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>.' ),
1040
+ sprintf( '<a href="http://%1$s">%1$s</a>', $signup->domain ),
1041
+ $signup->user_login,
1042
+ $signup->user_email,
1043
+ wp_lostpassword_url()
1044
+ );
1045
+ }
1046
+ $content .= '</p>';
1047
+ } elseif ( tml_allow_user_passwords() && strpos( $result->get_error_code(), 'password' ) !== false ) {
1048
+ $form = tml_get_form( 'activate' );
1049
+
1050
+ if ( isset( $_POST['user_pass1'] ) && isset( $_POST['user_pass2'] ) ) {
1051
+ $form->set_errors( $result );
1052
+ }
1053
+
1054
+ $content .= $form->render( array(
1055
+ 'before' => '<h2>' . __( 'New Password' ) . '</h2>',
1056
+ ) );
1057
+ } else {
1058
+ $content .= '<h2>' . __( 'An error occurred during the activation' ) . '</h2>';
1059
+ $content .= '<p>' . $result->get_error_message() . '</p>';
1060
+ }
1061
+ } else {
1062
+ $url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
1063
+ $user = get_userdata( (int) $result['user_id'] );
1064
+
1065
+ $content .= '<h2>' . __( 'Your account is now active!' ) . '</h2>';
1066
+
1067
+ $content .= '<div id="signup-welcome">';
1068
+ $content .= '<p><span class="h3">' . __( 'Username:' ) . '</span> ' . ( tml_is_default_registration_type() ? $user->user_login : $user->user_email ) . '</p>';
1069
+ $content .= '<p><span class="h3">' . __( 'Password:' ) . '</span> ' . ( tml_allow_user_passwords() ? '****' : $result['password'] ) . '</p>';
1070
+ $content .= '</div>';
1071
+
1072
+ if ( $url && $url != network_home_url( '', 'http' ) ) {
1073
+ switch_to_blog( (int) $result['blog_id'] );
1074
+ $login_url = wp_login_url();
1075
+ restore_current_blog();
1076
+
1077
+ $content .= '<p class="view">';
1078
+ $content .= sprintf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) );
1079
+ $content .= '</p>';
1080
+ } else {
1081
+ $content .= '<p class="view">';
1082
+ $content .= sprintf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
1083
+ $content .= '</p>';
1084
+ }
1085
+ }
1086
+ }
1087
+
1088
+ return $content;
1089
+ }
1090
+
1091
+ /**
1092
+ * Filter the user data before it is inserter by wp_insert_user().
1093
+ *
1094
+ * @since 7.0
1095
+ *
1096
+ * @param array $data The user data to insert.
1097
+ * @return array The user data to insert.
1098
+ */
1099
+ function tml_ms_filter_pre_insert_user_data( $data = array() ) {
1100
+ if ( tml_allow_user_passwords() && ! empty( $_POST['user_pass1'] ) ) {
1101
+ $data['user_pass'] = wp_hash_password( $_POST['user_pass1'] );
1102
+ }
1103
+ return $data;
1104
+ }
1105
+
1106
+ /**
1107
+ * Filter the contents of the welcome email.
1108
+ *
1109
+ * @since 7.0
1110
+ *
1111
+ * @param string $message The welcome email message.
1112
+ * @param int $blog_id The blog ID.
1113
+ * @param int $user_id The user ID.
1114
+ * @param string $password The user password.
1115
+ * @return string The welcome email message.
1116
+ */
1117
+ function tml_ms_filter_welcome_email( $message, $blog_id, $user_id, $password ) {
1118
+ $user = get_userdata( $user_id );
1119
+ if ( tml_allow_user_passwords() && ! empty( $_POST['user_pass1'] ) ) {
1120
+ $message = str_replace( $password, $_POST['user_pass1'], $message );
1121
+ }
1122
+ if ( tml_is_email_login_type() ) {
1123
+ $message = str_replace( $user->user_login, $user->user_email, $message );
1124
+ }
1125
+ return $message;
1126
+ }
1127
+
1128
+ /**
1129
+ * Filter the contents of the welcome user email.
1130
+ *
1131
+ * @since 7.0
1132
+ *
1133
+ * @param string $message The welcome user message.
1134
+ * @param int $user_id The user ID.
1135
+ * @param string $password The user password.
1136
+ * @return string The welcome user message.
1137
+ */
1138
+ function tml_ms_filter_welcome_user_email( $message, $user_id, $password ) {
1139
+ $user = get_userdata( $user_id );
1140
+ if ( tml_allow_user_passwords() && ! empty( $_POST['user_pass1'] ) ) {
1141
+ $message = str_replace( 'PASSWORD', $_POST['user_pass1'], $message );
1142
+ }
1143
+ if ( tml_is_email_login_type() ) {
1144
+ $message = str_replace( 'USERNAME', $user->user_email, $message );
1145
+ }
1146
+ return $message;
1147
+ }
includes/ms-hooks.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Multisite Hooks
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Multisite
8
+ */
9
+
10
+ /**
11
+ * Add Actions
12
+ */
13
+
14
+ // Actions and Forms
15
+ add_action( 'init', 'tml_ms_register_default_actions', 0 );
16
+ add_action( 'init', 'tml_ms_register_default_forms', 0 );
17
+
18
+ // Registration
19
+ add_action( 'wpmu_activate_user', 'tml_handle_auto_login', 10, 2 );
20
+ add_action( 'wpmu_activate_blog', 'tml_handle_auto_login', 10, 2 );
21
+
22
+ /**
23
+ * Add Filters
24
+ */
25
+
26
+ // Shortcodes
27
+ add_filter( 'tml_shortcode', 'tml_ms_filter_signup_shortcode', 10, 3 );
28
+ add_filter( 'tml_shortcode', 'tml_ms_filter_activation_shortcode', 10, 3 );
29
+
30
+ // URLs
31
+ add_filter( 'network_site_url', 'tml_filter_site_url', 10, 3 );
32
+
33
+ // Passwords
34
+ add_filter( 'wp_pre_insert_user_data', 'tml_ms_filter_pre_insert_user_data', 10, 1 );
35
+ add_filter( 'update_welcome_email', 'tml_ms_filter_welcome_email', 10, 4 );
36
+ add_filter( 'update_welcome_user_email', 'tml_ms_filter_welcome_user_email', 10, 3 );
includes/options.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Options
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Core
8
+ */
9
+
10
+ /**
11
+ * Get the installed TML version.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @return string|bool The installed TML version.
16
+ */
17
+ function tml_get_installed_version() {
18
+ if ( $options = get_option( 'theme_my_login' ) ) {
19
+ if ( isset( $options['version'] ) ) {
20
+ return $options['version'];
21
+ }
22
+ }
23
+ return get_site_option( '_tml_version' );
24
+ }
25
+
26
+ /**
27
+ * Get the previous TML version.
28
+ *
29
+ * @since 7.0
30
+ *
31
+ * @return string|bool The previous TML version.
32
+ */
33
+ function tml_get_previous_version() {
34
+ return get_site_option( '_tml_previous_version' );
35
+ }
36
+
37
+ /**
38
+ * Determine whether to use permalinks or not.
39
+ *
40
+ * @since 7.0
41
+ *
42
+ * @return bool Whether to use permalinks or not.
43
+ */
44
+ function tml_use_permalinks() {
45
+ global $wp_rewrite;
46
+
47
+ if ( ! $wp_rewrite instanceof WP_Rewrite ) {
48
+ $wp_rewrite = new WP_Rewrite;
49
+ }
50
+
51
+ $use_permalinks = $wp_rewrite->using_permalinks() && get_site_option( 'tml_use_permalinks', true );
52
+
53
+ /**
54
+ * Filter whether to use permalinks or not.
55
+ *
56
+ * @since 7.0
57
+ *
58
+ * @param bool $use_permalinks Whether to use permalinks or not.
59
+ */
60
+ return (bool) apply_filters( 'tml_use_permalinks', $use_permalinks );
61
+ }
62
+
63
+ /**
64
+ * Get the login type.
65
+ *
66
+ * @since 7.0
67
+ *
68
+ * @return string The login type.
69
+ */
70
+ function tml_get_login_type() {
71
+ $login_type = get_site_option( 'tml_login_type', 'default' );
72
+
73
+ /**
74
+ * Filter the login type.
75
+ *
76
+ * @since 7.0
77
+ *
78
+ * @param string $login_type The login type.
79
+ */
80
+ return apply_filters( 'tml_get_login_type', $login_type );
81
+ }
82
+
83
+ /**
84
+ * Determine if using the default login type.
85
+ *
86
+ * @since 7.0
87
+ *
88
+ * @return bool Whether using the default login type or not.
89
+ */
90
+ function tml_is_default_login_type() {
91
+ return 'default' == tml_get_login_type();
92
+ }
93
+
94
+ /**
95
+ * Determine if using the email login type.
96
+ *
97
+ * @since 7.0
98
+ *
99
+ * @return bool Whether using the email login type or not.
100
+ */
101
+ function tml_is_email_login_type() {
102
+ return 'email' == tml_get_login_type();
103
+ }
104
+
105
+ /**
106
+ * Determine if using the username login type.
107
+ *
108
+ * @since 7.0
109
+ *
110
+ * @return bool Whether using the username login type or not.
111
+ */
112
+ function tml_is_username_login_type() {
113
+ return 'username' == tml_get_login_type();
114
+ }
115
+
116
+ /**
117
+ * Get the registration type.
118
+ *
119
+ * @since 7.0
120
+ *
121
+ * @return string The registration type.
122
+ */
123
+ function tml_get_registration_type() {
124
+ $registration_type = get_site_option( 'tml_registration_type', 'default' );
125
+
126
+ /**
127
+ * Filter the registration type.
128
+ *
129
+ * @since 7.0
130
+ *
131
+ * @param string $registration_type The registration type.
132
+ */
133
+ return apply_filters( 'tml_get_registration_type', $registration_type );
134
+ }
135
+
136
+ /**
137
+ * Determine if using the default registration type.
138
+ *
139
+ * @since 7.0
140
+ *
141
+ * @return bool Whether using the default registration type or not.
142
+ */
143
+ function tml_is_default_registration_type() {
144
+ return 'default' == tml_get_registration_type();
145
+ }
146
+
147
+ /**
148
+ * Determine if using the email registration type.
149
+ *
150
+ * @since 7.0
151
+ *
152
+ * @return bool Whether using the email registration type or not.
153
+ */
154
+ function tml_is_email_registration_type() {
155
+ return 'email' == tml_get_registration_type();
156
+ }
157
+
158
+ /**
159
+ * Determine if users can set their own password upon registration or not.
160
+ *
161
+ * @since 7.0
162
+ *
163
+ * @return bool Whether users can set their own password upon registration or not.
164
+ */
165
+ function tml_allow_user_passwords() {
166
+ $user_passwords = (bool) get_site_option( 'tml_user_passwords' );
167
+
168
+ /**
169
+ * Filter whether users can set their own password upon registration or not.
170
+ *
171
+ * @since 7.0
172
+ *
173
+ * @param bool $user_passwords Whether users can set their own password upon registration or not.
174
+ */
175
+ return (bool) apply_filters( 'tml_allow_user_passwords', $user_passwords );
176
+ }
177
+
178
+ /**
179
+ * Determine if users should be logged in after registration or not.
180
+ *
181
+ * @since 7.0
182
+ *
183
+ * @return bool Whether users should be logged in after registration or not.
184
+ */
185
+ function tml_allow_auto_login() {
186
+ $auto_login = get_site_option( 'tml_auto_login' );
187
+
188
+ /**
189
+ * Filter whether users should be logged in after registration or not.
190
+ *
191
+ * @since 7.0
192
+ *
193
+ * @param bool $auto_login Whether users should be logged in after registration or not.
194
+ */
195
+ return (bool) apply_filters( 'tml_allow_auto_login', $auto_login );
196
+ }
includes/shortcodes.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Theme My Login Shortcodes
5
+ *
6
+ * @package Theme_My_Login
7
+ * @subpackage Shortcodes
8
+ */
9
+
10
+ /**
11
+ * Render the shortcode.
12
+ *
13
+ * @since 7.0
14
+ *
15
+ * @param array $atts {
16
+ * Optional. An array of shortcode attributes.
17
+ *
18
+ * @type string $action The action to display. Default is current action.
19
+ * @type bool $show_links Whether the actions links should be shown or not.
20
+ * @type string $redirect_to The URL to redirect to after the form is submitted.
21
+ * }
22
+ * @return string The action content.
23
+ */
24
+ function tml_shortcode( $atts = array() ) {
25
+ $atts = (array) $atts;
26
+
27
+ if ( isset( $atts['default_action'] ) ) {
28
+ $atts['action'] = $atts['default_action'];
29
+ }
30
+
31
+ $atts = shortcode_atts( array(
32
+ 'action' => '',
33
+ 'show_links' => null,
34
+ 'redirect_to' => null,
35
+ ), $atts );
36
+
37
+ $content = '';
38
+
39
+ if ( empty( $atts['action'] ) ) {
40
+ $action = tml_is_action() ? tml_get_action() : tml_get_action( 'login' );
41
+ } elseif ( ! $action = tml_get_action( $atts['action'] ) ) {
42
+ return $content;
43
+ }
44
+
45
+ if ( $form = tml_get_form( $action->get_name() ) ) {
46
+
47
+ $args = array();
48
+
49
+ if ( null !== $atts['show_links'] ) {
50
+ $args['show_links'] = (bool) $atts['show_links'];
51
+ }
52
+
53
+ if ( null !== $atts['redirect_to'] ) {
54
+ if ( $redirect_to = $form->get_field( 'redirect_to' ) ) {
55
+ $redirect_to->set_value( $atts['redirect_to'] );
56
+ }
57
+ unset( $redirect_to );
58
+ }
59
+
60
+ $content = $form->render( $args );
61
+
62
+ } elseif ( 'confirmaction' == $action->get_name() && isset( $_GET['request_id'] ) ) {
63
+ $content = _wp_privacy_account_request_confirmed_message( $_GET['request_id'] );
64
+ }
65
+
66
+ /**
67
+ * Filter the shortcode content.
68
+ *
69
+ * @since 7.0
70
+ *
71
+ * @param string $content The shortcode content.
72
+ * @param string $action The action name.
73
+ * @param array $atts The shortcode attributes.
74
+ */
75
+ return apply_filters( 'tml_shortcode', $content, $action->get_name(), $atts );
76
+ }
77
+ add_shortcode( 'theme-my-login', 'tml_shortcode' );
languages/theme-my-login.pot CHANGED
@@ -2,1456 +2,199 @@
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.16\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/theme-my-login\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2018-06-03T21:02:54-04:00\n"
13
- "PO-Revision-Date: 2018-06-03T21:02:54-04:00\n"
14
  "X-Domain: theme-my-login\n"
15
 
16
- #: includes/class-theme-my-login.php:128
17
- #: includes/class-theme-my-login-template.php:173
18
- #: templates/login-form.php:38
19
- msgid "Log In"
20
  msgstr ""
21
 
22
- #: includes/class-theme-my-login.php:129
23
- msgid "Log Out"
24
- msgstr ""
25
-
26
- #: includes/class-theme-my-login.php:130
27
- #: includes/class-theme-my-login-widget.php:111
28
- #: includes/class-theme-my-login-template.php:160
29
- #: templates/register-form.php:28
30
- msgid "Register"
31
- msgstr ""
32
-
33
- #: includes/class-theme-my-login.php:131
34
- #: includes/class-theme-my-login-widget.php:112
35
- #: includes/class-theme-my-login-template.php:166
36
- msgid "Lost Password"
37
- msgstr ""
38
-
39
- #: includes/class-theme-my-login.php:132
40
- #: templates/resetpass-form.php:44
41
- #: modules/custom-email/admin/custom-email-admin.php:100
42
- msgid "Reset Password"
43
- msgstr ""
44
-
45
- #: includes/class-theme-my-login.php:391
46
- msgid "Your password reset link appears to be invalid. Please request a new link below."
47
- msgstr ""
48
-
49
- #: includes/class-theme-my-login.php:393
50
- msgid "Your password reset link has expired. Please request a new link below."
51
- msgstr ""
52
-
53
- #: includes/class-theme-my-login.php:431
54
- msgid "The passwords do not match."
55
- msgstr ""
56
-
57
- #: includes/class-theme-my-login.php:582
58
- msgid "Your session has expired. Please log in to continue where you left off."
59
- msgstr ""
60
-
61
- #: includes/class-theme-my-login.php:586
62
- msgid "You are now logged out."
63
- msgstr ""
64
-
65
- #: includes/class-theme-my-login.php:588
66
- msgid "User registration is currently not allowed."
67
- msgstr ""
68
-
69
- #: includes/class-theme-my-login.php:590
70
- msgid "Check your email for the confirmation link."
71
- msgstr ""
72
-
73
- #: includes/class-theme-my-login.php:592
74
- msgid "Check your email for your new password."
75
- msgstr ""
76
-
77
- #: includes/class-theme-my-login.php:594
78
- msgid "Your password has been reset."
79
- msgstr ""
80
-
81
- #: includes/class-theme-my-login.php:596
82
- msgid "Registration complete. Please check your email."
83
- msgstr ""
84
-
85
- #: includes/class-theme-my-login.php:598
86
- msgid "<strong>You have successfully updated WordPress!</strong> Please log back in to see what&#8217;s new."
87
- msgstr ""
88
-
89
- #: includes/class-theme-my-login.php:945
90
- msgid "<strong>ERROR</strong>: Invalid email address."
91
- msgstr ""
92
-
93
- #: includes/class-theme-my-login.php:1273
94
- msgid "<strong>ERROR</strong>: Enter a username or e-mail address."
95
- msgstr ""
96
-
97
- #: includes/class-theme-my-login.php:1277
98
- msgid "<strong>ERROR</strong>: There is no user registered with that email address."
99
- msgstr ""
100
-
101
- #: includes/class-theme-my-login.php:1289
102
- msgid "<strong>ERROR</strong>: Invalid username or e-mail."
103
- msgstr ""
104
-
105
- #: includes/class-theme-my-login.php:1302
106
- msgid "Someone requested that the password be reset for the following account:"
107
- msgstr ""
108
-
109
- #: includes/class-theme-my-login.php:1304
110
- #: modules/user-moderation/admin/user-moderation-admin.php:382
111
- #: modules/user-moderation/user-moderation.php:461
112
- #: modules/custom-email/custom-email.php:843
113
- #: modules/custom-email/custom-email.php:872
114
- msgid "Username: %s"
115
- msgstr ""
116
-
117
- #: includes/class-theme-my-login.php:1305
118
- msgid "If this was a mistake, just ignore this email and nothing will happen."
119
- msgstr ""
120
-
121
- #: includes/class-theme-my-login.php:1306
122
- msgid "To reset your password, visit the following address:"
123
  msgstr ""
124
 
125
- #: includes/class-theme-my-login.php:1317
126
- msgid "[%s] Password Reset"
 
 
127
  msgstr ""
128
 
129
- #: includes/class-theme-my-login.php:1323
130
- #: modules/user-moderation/admin/user-moderation-admin.php:252
131
- #: modules/user-moderation/admin/user-moderation-admin.php:394
132
- #: modules/user-moderation/admin/user-moderation-admin.php:436
133
- msgid "The e-mail could not be sent."
134
  msgstr ""
135
 
136
- #: includes/class-theme-my-login.php:1323
137
- #: modules/user-moderation/admin/user-moderation-admin.php:252
138
- #: modules/user-moderation/admin/user-moderation-admin.php:394
139
- #: modules/user-moderation/admin/user-moderation-admin.php:436
140
- msgid "Possible reason: your host may have disabled the mail() function..."
141
  msgstr ""
142
 
143
- #: includes/class-theme-my-login-widget.php:24
144
- msgid "A login form for your blog."
145
  msgstr ""
146
 
147
  #. Plugin Name of the plugin
148
- #: includes/class-theme-my-login-widget.php:26
 
 
149
  msgid "Theme My Login"
150
  msgstr ""
151
 
152
- #: includes/class-theme-my-login-widget.php:110
153
- msgid "Login"
154
- msgstr ""
155
-
156
- #: includes/class-theme-my-login-widget.php:115
157
- msgid "Default Action"
158
- msgstr ""
159
-
160
- #: includes/class-theme-my-login-widget.php:123
161
- msgid "Show When Logged In"
162
- msgstr ""
163
-
164
- #: includes/class-theme-my-login-widget.php:126
165
- msgid "Show When Logged Out"
166
- msgstr ""
167
-
168
- #: includes/class-theme-my-login-widget.php:129
169
- msgid "Show Title"
170
- msgstr ""
171
-
172
- #: includes/class-theme-my-login-widget.php:132
173
- msgid "Show Login Link"
174
- msgstr ""
175
-
176
- #: includes/class-theme-my-login-widget.php:135
177
- msgid "Show Register Link"
178
- msgstr ""
179
-
180
- #: includes/class-theme-my-login-widget.php:138
181
- msgid "Show Lost Password Link"
182
- msgstr ""
183
-
184
- #: includes/class-theme-my-login-widget.php:141
185
- msgid "Show Gravatar"
186
- msgstr ""
187
-
188
- #: includes/class-theme-my-login-widget.php:143
189
- msgid "Gravatar Size"
190
- msgstr ""
191
-
192
- #: includes/class-theme-my-login-ms-signup.php:110
193
- msgid "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>."
194
- msgstr ""
195
-
196
- #: includes/class-theme-my-login-ms-signup.php:116
197
- msgid "Registration has been disabled."
198
- msgstr ""
199
-
200
- #: includes/class-theme-my-login-ms-signup.php:118
201
- msgid "You must first <a href=\"%s\">log in</a>, and then you can create a new site."
202
- msgstr ""
203
-
204
- #: includes/class-theme-my-login-ms-signup.php:142
205
- msgid "%s is your new username"
206
- msgstr ""
207
-
208
- #: includes/class-theme-my-login-ms-signup.php:143
209
- msgid "But, before you can start using your new username, <strong>you must activate it</strong>."
210
- msgstr ""
211
-
212
- #: includes/class-theme-my-login-ms-signup.php:144
213
- msgid "Check your inbox at <strong>%1$s</strong> and click the link given."
214
- msgstr ""
215
-
216
- #: includes/class-theme-my-login-ms-signup.php:145
217
- msgid "If you do not activate your username within two days, you will have to sign up again."
218
- msgstr ""
219
-
220
- #: includes/class-theme-my-login-ms-signup.php:149
221
- msgid "User registration has been disabled."
222
- msgstr ""
223
-
224
- #: includes/class-theme-my-login-ms-signup.php:181
225
- msgid "Congratulations! Your new site, %s, is almost ready."
226
- msgstr ""
227
-
228
- #: includes/class-theme-my-login-ms-signup.php:183
229
- msgid "But, before you can start using your site, <strong>you must activate it</strong>."
230
- msgstr ""
231
-
232
- #: includes/class-theme-my-login-ms-signup.php:184
233
- msgid "Check your inbox at <strong>%s</strong> and click the link given."
234
- msgstr ""
235
-
236
- #: includes/class-theme-my-login-ms-signup.php:185
237
- msgid "If you do not activate your site within two days, you will have to sign up again."
238
- msgstr ""
239
-
240
- #: includes/class-theme-my-login-ms-signup.php:186
241
- msgid "Still waiting for your email?"
242
- msgstr ""
243
-
244
- #: includes/class-theme-my-login-ms-signup.php:188
245
- msgid "If you haven&#8217;t received your email yet, there are a number of things you can do:"
246
- msgstr ""
247
-
248
- #: includes/class-theme-my-login-ms-signup.php:190
249
- msgid "Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control."
250
- msgstr ""
251
-
252
- #: includes/class-theme-my-login-ms-signup.php:191
253
- msgid "Check the junk or spam folder of your email client. Sometime emails wind up there by mistake."
254
- msgstr ""
255
-
256
- #: includes/class-theme-my-login-ms-signup.php:192
257
- msgid "Have you entered your email correctly? You have entered %s, if it&#8217;s incorrect, you will not receive your email."
258
- msgstr ""
259
-
260
- #: includes/class-theme-my-login-ms-signup.php:198
261
- msgid "Site registration has been disabled."
262
- msgstr ""
263
-
264
- #: includes/class-theme-my-login-ms-signup.php:222
265
- msgid "The site %s is yours."
266
- msgstr ""
267
-
268
- #: includes/class-theme-my-login-ms-signup.php:224
269
- msgid "<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."
270
- msgstr ""
271
-
272
- #: includes/class-theme-my-login-ms-signup.php:240
273
- msgid "Sorry, new registrations are not allowed at this time."
274
- msgstr ""
275
-
276
- #: includes/class-theme-my-login-ms-signup.php:242
277
- msgid "You are logged in already. No need to register again!"
278
- msgstr ""
279
-
280
- #: includes/class-theme-my-login-ms-signup.php:248
281
- msgid "<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>"
282
- msgstr ""
283
-
284
- #: includes/class-theme-my-login-ms-signup.php:250
285
- msgid "<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>"
286
- msgstr ""
287
-
288
- #: includes/class-theme-my-login-ms-signup.php:392
289
- msgid "Activation Key Required"
290
- msgstr ""
291
-
292
- #: includes/class-theme-my-login-ms-signup.php:395
293
- msgid "Activation Key:"
294
- msgstr ""
295
-
296
- #: includes/class-theme-my-login-ms-signup.php:399
297
- #: includes/class-theme-my-login-ms-signup.php:471
298
- msgid "Activate"
299
- msgstr ""
300
-
301
- #: includes/class-theme-my-login-ms-signup.php:411
302
- #: includes/class-theme-my-login-ms-signup.php:431
303
- msgid "Your account is now active!"
304
- msgstr ""
305
-
306
- #: includes/class-theme-my-login-ms-signup.php:415
307
- msgid "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>."
308
- msgstr ""
309
-
310
- #: includes/class-theme-my-login-ms-signup.php:417
311
- msgid "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>."
312
- msgstr ""
313
-
314
- #: includes/class-theme-my-login-ms-signup.php:422
315
- msgid "An error occurred during the activation"
316
- msgstr ""
317
-
318
- #: includes/class-theme-my-login-ms-signup.php:434
319
- #: templates/ms-signup-user-form.php:14
320
- msgid "Username:"
321
- msgstr ""
322
-
323
- #: includes/class-theme-my-login-ms-signup.php:435
324
- #: modules/custom-passwords/custom-passwords.php:99
325
- msgid "Password:"
326
- msgstr ""
327
-
328
- #: includes/class-theme-my-login-ms-signup.php:439
329
- msgid "Your account is now activated. <a href=\"%1$s\">View your site</a> or <a href=\"%2$s\">Login</a>"
330
- msgstr ""
331
-
332
- #: includes/class-theme-my-login-ms-signup.php:441
333
- msgid "Your account is now activated. <a href=\"%1$s\">Login</a> or go back to the <a href=\"%2$s\">homepage</a>."
334
- msgstr ""
335
-
336
- #: includes/class-theme-my-login-template.php:153
337
- msgid "Welcome, %s"
338
  msgstr ""
339
 
340
- #: includes/class-theme-my-login-template.php:169
341
- msgid "Your Data Request"
342
  msgstr ""
343
 
344
- #: includes/class-theme-my-login-template.php:354
345
- #: modules/custom-user-links/custom-user-links.php:61
346
- msgid "Dashboard"
 
347
  msgstr ""
348
 
349
- #: includes/class-theme-my-login-template.php:357
350
- #: modules/themed-profiles/themed-profiles.php:99
351
- #: modules/custom-user-links/custom-user-links.php:65
352
- msgid "Profile"
353
  msgstr ""
354
 
355
- #: includes/class-theme-my-login-template.php:406
356
- msgid "Register For This Site"
357
  msgstr ""
358
 
359
- #: includes/class-theme-my-login-template.php:409
360
- msgid "Please enter your username or email address. You will receive a link to create a new password via email."
361
  msgstr ""
362
 
363
- #: includes/class-theme-my-login-template.php:412
364
- msgid "Enter your new password below."
365
  msgstr ""
366
 
367
- #: admin/class-theme-my-login-admin.php:76
368
- #: admin/class-theme-my-login-admin.php:256
369
  msgid "Theme My Login Settings"
370
  msgstr ""
371
 
372
- #: admin/class-theme-my-login-admin.php:77
373
- msgid "TML"
374
- msgstr ""
375
-
376
- #: admin/class-theme-my-login-admin.php:85
377
- #: admin/class-theme-my-login-admin.php:86
378
- #: admin/class-theme-my-login-admin.php:111
379
  msgid "General"
380
  msgstr ""
381
 
382
- #: admin/class-theme-my-login-admin.php:112
383
- #: admin/class-theme-my-login-admin.php:118
384
- msgid "Modules"
385
- msgstr ""
386
-
387
- #: admin/class-theme-my-login-admin.php:113
388
- #: admin/class-theme-my-login-admin.php:119
389
- #: modules/custom-user-links/admin/custom-user-links-admin.php:237
390
- msgid "Update"
391
  msgstr ""
392
 
393
- #: admin/class-theme-my-login-admin.php:116
394
- msgid "Stylesheet"
395
  msgstr ""
396
 
397
- #: admin/class-theme-my-login-admin.php:117
398
- msgid "Login Type"
399
- msgstr ""
400
-
401
- #: admin/class-theme-my-login-admin.php:154
402
- msgid "<strong>Heads up!</strong> Theme My Login 7 is right around the corner and some major changes are coming!"
403
- msgstr ""
404
-
405
- #: admin/class-theme-my-login-admin.php:156
406
- msgid "Most notably, all of the previously included modules (with the exception of Custom Passwords, which has been merged into the core plugin) have been removed."
407
- msgstr ""
408
-
409
- #: admin/class-theme-my-login-admin.php:157
410
- msgid "Instead, all of the legacy modules (now called \"Extensions\"), with many more to come, can now be purchased at our <a href=\"https://thememylogin.com/extensions\">extensions store</a>."
411
  msgstr ""
412
 
413
- #: admin/class-theme-my-login-admin.php:159
414
- msgid "It's not all bad news though! As a legacy user, we're offering you a discount for a limited time. Use discount code <strong>SAVINGFACE</strong> at checkout in order to receive <strong>20% off</strong> of your purchase!"
415
  msgstr ""
416
 
417
- #: admin/class-theme-my-login-admin.php:161
418
- msgid "Take Me To The Store"
419
  msgstr ""
420
 
421
- #: admin/class-theme-my-login-admin.php:196
422
- msgid "Theme My Login Action"
423
  msgstr ""
424
 
425
- #: admin/class-theme-my-login-admin.php:284
426
- msgid "Enable \"theme-my-login.css\""
427
  msgstr ""
428
 
429
- #: admin/class-theme-my-login-admin.php:285
430
- msgid "In order to keep changes between upgrades, you can store your customized \"theme-my-login.css\" in your current theme directory."
 
431
  msgstr ""
432
 
433
- #: admin/class-theme-my-login-admin.php:301
434
- #: templates/login-form.php:18
435
- msgid "Username or E-mail"
436
  msgstr ""
437
 
438
- #: admin/class-theme-my-login-admin.php:304
439
  msgid "Username only"
440
  msgstr ""
441
 
442
- #: admin/class-theme-my-login-admin.php:307
443
- msgid "E-mail only"
444
- msgstr ""
445
-
446
- #: admin/class-theme-my-login-admin.php:311
447
- msgid "Allow users to login using their username and/or e-mail address."
448
- msgstr ""
449
-
450
- #: admin/class-theme-my-login-admin.php:327
451
- msgid "Enable %s"
452
- msgstr ""
453
-
454
- #: admin/class-theme-my-login-admin.php:343
455
- msgid "Please read the following carefully!"
456
- msgstr ""
457
-
458
- #: admin/class-theme-my-login-admin.php:344
459
- msgid "Theme My Login version 7.0+ contains major changes that can possibly break some sites. In order to protect your site from potentially breaking, we are requiring you to opt-in to receive the update."
460
- msgstr ""
461
-
462
- #: admin/class-theme-my-login-admin.php:345
463
- msgid "So that we may help you understand some of these changes, we will go over them below."
464
- msgstr ""
465
-
466
- #: admin/class-theme-my-login-admin.php:348
467
- msgid "Modules will no longer be included with the plugin"
468
- msgstr ""
469
-
470
- #: admin/class-theme-my-login-admin.php:351
471
- msgid "With the exception of Custom Passwords (merged into the core plugin) and Custom User Links (discontinued), all of the modules listed above are now available in <a href=\"https://thememylogin.com/extensions\">our store</a>."
472
- msgstr ""
473
-
474
- #: admin/class-theme-my-login-admin.php:352
475
- msgid "If you update, you will need to purchase a license to use the new extensions."
476
- msgstr ""
477
-
478
- #: admin/class-theme-my-login-admin.php:353
479
- msgid "Most of these extensions have been completely rewritten and contain additional features not found in the 6.4.x modules."
480
- msgstr ""
481
-
482
- #: admin/class-theme-my-login-admin.php:354
483
- msgid "If you are not using any of the above modules, this change will not affect you."
484
- msgstr ""
485
-
486
- #: admin/class-theme-my-login-admin.php:357
487
- msgid "Templates will no longer be utilized by the plugin"
488
- msgstr ""
489
-
490
- #: admin/class-theme-my-login-admin.php:360
491
- msgid "In order to simplify the way the plugin generates forms, templates are no longer used. Instead, the forms are generated procedurally in PHP code. This makes it much easier to add, edit and rearrange form fields and leads to less complexity."
492
- msgstr ""
493
-
494
- #: admin/class-theme-my-login-admin.php:361
495
- msgid "If you are not using custom templates for any actions, this change will not affect you."
496
- msgstr ""
497
-
498
- #: admin/class-theme-my-login-admin.php:364
499
- msgid "The plugin will no longer use WordPress pages to represent actions"
500
- msgstr ""
501
-
502
- #: admin/class-theme-my-login-admin.php:367
503
- msgid "Instead of using \"real\" pages, they are generated \"on-the-fly\", that is, as needed, when the corresponding action is requested. This eliminates clutter and avoids the accidental deletion of pages that represent actions."
504
- msgstr ""
505
-
506
- #: admin/class-theme-my-login-admin.php:368
507
- msgid "If you have not added anything to the pages that the plugin created, this change will not affect you."
508
- msgstr ""
509
-
510
- #: admin/class-theme-my-login-admin.php:384
511
- msgid "I understand the possible consequences, but I want the latest features and wish to allow the update"
512
- msgstr ""
513
-
514
- #: admin/class-theme-my-login-admin.php:389
515
- msgid "I understand that I will no longer receive any new features but I would like to stay on the 6.4 branch anyway"
516
- msgstr ""
517
-
518
- #: admin/class-theme-my-login-admin.php:468
519
- msgid "Theme My Login has not been updated because you have not allowed the update on the <a href=\"%s\" target=\"_top\">settings page</a>."
520
  msgstr ""
521
 
522
- #: templates/resetpass-form.php:14
523
- msgid "New password"
 
524
  msgstr ""
525
 
526
- #: templates/resetpass-form.php:24
527
- msgid "Strength indicator"
528
  msgstr ""
529
 
530
- #: templates/resetpass-form.php:29
531
- #: templates/profile-form.php:181
532
- msgid "Confirm use of weak password"
533
  msgstr ""
534
 
535
- #: templates/resetpass-form.php:35
536
- msgid "Confirm new password"
537
  msgstr ""
538
 
539
- #: templates/ms-signup-blog-form.php:15
540
- #: templates/ms-signup-another-blog-form.php:34
541
- msgid "Site Name:"
542
  msgstr ""
543
 
544
- #: templates/ms-signup-blog-form.php:17
545
- #: templates/ms-signup-another-blog-form.php:36
546
- msgid "Site Domain:"
547
  msgstr ""
548
 
549
- #: templates/ms-signup-blog-form.php:34
550
- #: templates/ms-signup-another-blog-form.php:53
551
- msgid "sitename"
552
  msgstr ""
553
 
554
- #: templates/ms-signup-blog-form.php:36
555
- #: templates/ms-signup-another-blog-form.php:55
556
- msgid "domain"
557
  msgstr ""
558
 
559
- #: templates/ms-signup-blog-form.php:37
560
- #: templates/ms-signup-another-blog-form.php:56
561
- msgid "Your address will be %s."
562
  msgstr ""
563
 
564
- #: templates/ms-signup-blog-form.php:37
565
- #: templates/ms-signup-another-blog-form.php:56
566
- msgid "Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!"
567
- msgstr ""
568
-
569
- #: templates/ms-signup-blog-form.php:40
570
- #: templates/ms-signup-another-blog-form.php:59
571
- msgid "Site Title:"
572
- msgstr ""
573
-
574
- #: templates/ms-signup-blog-form.php:48
575
- #: templates/ms-signup-another-blog-form.php:67
576
- msgid "Privacy:"
577
- msgstr ""
578
-
579
- #: templates/ms-signup-blog-form.php:49
580
- #: templates/ms-signup-another-blog-form.php:68
581
- msgid "Allow search engines to index this site."
582
- msgstr ""
583
-
584
- #: templates/ms-signup-blog-form.php:53
585
- #: templates/ms-signup-another-blog-form.php:72
586
- msgid "Yes"
587
- msgstr ""
588
-
589
- #: templates/ms-signup-blog-form.php:57
590
- #: templates/ms-signup-another-blog-form.php:76
591
- msgid "No"
592
- msgstr ""
593
-
594
- #: templates/ms-signup-blog-form.php:64
595
- msgid "Signup"
596
- msgstr ""
597
-
598
- #: templates/ms-signup-user-form.php:7
599
- msgid "Get your own %s account in seconds"
600
- msgstr ""
601
-
602
- #: templates/ms-signup-user-form.php:20
603
- msgid "(Must be at least 4 characters, letters and numbers only.)"
604
- msgstr ""
605
-
606
- #: templates/ms-signup-user-form.php:22
607
- msgid "Email&nbsp;Address:"
608
- msgstr ""
609
-
610
- #: templates/ms-signup-user-form.php:28
611
- msgid "We send your registration email to this address. (Double-check your email address before continuing.)"
612
- msgstr ""
613
-
614
- #: templates/ms-signup-user-form.php:42
615
- msgid "Gimme a site!"
616
- msgstr ""
617
-
618
- #: templates/ms-signup-user-form.php:45
619
- msgid "Just a username, please."
620
- msgstr ""
621
-
622
- #: templates/ms-signup-user-form.php:49
623
- msgid "Next"
624
- msgstr ""
625
-
626
- #: templates/register-form.php:13
627
- #: templates/profile-form.php:39
628
- #: templates/login-form.php:14
629
- msgid "Username"
630
- msgstr ""
631
-
632
- #: templates/register-form.php:19
633
- #: templates/profile-form.php:99
634
- #: templates/login-form.php:16
635
- #: modules/custom-email/admin/custom-email-admin.php:91
636
- msgid "E-mail"
637
- msgstr ""
638
-
639
- #: templates/register-form.php:25
640
- msgid "Registration confirmation will be e-mailed to you."
641
- msgstr ""
642
-
643
- #: templates/profile-form.php:17
644
- msgid "Personal Options"
645
- msgstr ""
646
-
647
- #: templates/profile-form.php:22
648
- msgid "Toolbar"
649
- msgstr ""
650
-
651
- #: templates/profile-form.php:25
652
- msgid "Show Toolbar when viewing site"
653
- msgstr ""
654
-
655
- #: templates/profile-form.php:35
656
- msgid "Name"
657
- msgstr ""
658
-
659
- #: templates/profile-form.php:40
660
- msgid "Usernames cannot be changed."
661
- msgstr ""
662
-
663
- #: templates/profile-form.php:44
664
- msgid "First Name"
665
- msgstr ""
666
-
667
- #: templates/profile-form.php:49
668
- msgid "Last Name"
669
- msgstr ""
670
-
671
- #: templates/profile-form.php:54
672
- msgid "Nickname"
673
- msgstr ""
674
-
675
- #: templates/profile-form.php:54
676
- #: templates/profile-form.php:99
677
- msgid "(required)"
678
- msgstr ""
679
-
680
- #: templates/profile-form.php:59
681
- msgid "Display name publicly as"
682
- msgstr ""
683
-
684
- #: templates/profile-form.php:95
685
- msgid "Contact Info"
686
- msgstr ""
687
-
688
- #: templates/profile-form.php:107
689
- msgid "There is a pending change of your e-mail to %1$s. <a href=\"%2$s\">Cancel</a>"
690
- msgstr ""
691
-
692
- #: templates/profile-form.php:116
693
- msgid "Website"
694
- msgstr ""
695
-
696
- #: templates/profile-form.php:132
697
- msgid "About Yourself"
698
  msgstr ""
699
 
700
- #: templates/profile-form.php:136
701
- msgid "Biographical Info"
702
  msgstr ""
703
 
704
- #: templates/profile-form.php:138
705
- msgid "Share a little biographical information to fill out your profile. This may be shown publicly."
706
  msgstr ""
707
 
708
- #: templates/profile-form.php:147
709
- msgid "Account Management"
710
  msgstr ""
711
 
712
- #: templates/profile-form.php:150
713
- msgid "New Password"
714
  msgstr ""
715
 
716
- #: templates/profile-form.php:153
717
- msgid "Generate Password"
718
- msgstr ""
719
-
720
- #: templates/profile-form.php:159
721
- msgid "Hide password"
722
- msgstr ""
723
-
724
- #: templates/profile-form.php:161
725
- msgid "Hide"
726
- msgstr ""
727
-
728
- #: templates/profile-form.php:163
729
- msgid "Cancel password change"
730
- msgstr ""
731
-
732
- #: templates/profile-form.php:164
733
- msgid "Cancel"
734
- msgstr ""
735
-
736
- #: templates/profile-form.php:170
737
- msgid "Repeat New Password"
738
- msgstr ""
739
-
740
- #: templates/profile-form.php:173
741
- msgid "Type your new password again."
742
- msgstr ""
743
-
744
- #: templates/profile-form.php:177
745
- #: modules/custom-passwords/custom-passwords.php:73
746
- msgid "Confirm Password"
747
- msgstr ""
748
-
749
- #: templates/profile-form.php:195
750
- msgid "Update Profile"
751
- msgstr ""
752
-
753
- #: templates/ms-signup-another-blog-form.php:7
754
- msgid "Get <em>another</em> %s site in seconds"
755
- msgstr ""
756
-
757
- #: templates/ms-signup-another-blog-form.php:10
758
- msgid "There was a problem, please correct the form below and try again."
759
- msgstr ""
760
-
761
- #: templates/ms-signup-another-blog-form.php:13
762
- msgid "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!"
763
- msgstr ""
764
-
765
- #: templates/ms-signup-another-blog-form.php:18
766
- msgid "Sites you are already a member of:"
767
- msgstr ""
768
-
769
- #: templates/ms-signup-another-blog-form.php:27
770
- msgid "If you&#8217;re not going to use a great site domain, leave it for a new user. Now have at it!"
771
- msgstr ""
772
-
773
- #: templates/ms-signup-another-blog-form.php:83
774
- msgid "Create Site"
775
- msgstr ""
776
-
777
- #: templates/lostpassword-form.php:14
778
- msgid "E-mail:"
779
- msgstr ""
780
-
781
- #: templates/lostpassword-form.php:16
782
- msgid "Username or E-mail:"
783
- msgstr ""
784
-
785
- #: templates/lostpassword-form.php:24
786
- msgid "Get New Password"
787
- msgstr ""
788
-
789
- #: templates/login-form.php:25
790
- #: modules/custom-passwords/custom-passwords.php:69
791
- msgid "Password"
792
- msgstr ""
793
-
794
- #: templates/login-form.php:34
795
- msgid "Remember Me"
796
- msgstr ""
797
-
798
- #: modules/themed-profiles/admin/themed-profiles-admin.php:73
799
- msgid "Your Profile"
800
- msgstr ""
801
-
802
- #: modules/themed-profiles/admin/themed-profiles-admin.php:108
803
- #: modules/themed-profiles/admin/themed-profiles-admin.php:143
804
- msgid "Theme My Login Themed Profiles Settings"
805
- msgstr ""
806
-
807
- #: modules/themed-profiles/admin/themed-profiles-admin.php:109
808
- #: modules/themed-profiles/admin/themed-profiles-admin.php:117
809
- msgid "Themed Profiles"
810
- msgstr ""
811
-
812
- #: modules/themed-profiles/admin/themed-profiles-admin.php:118
813
- msgid "Restrict Admin Access"
814
- msgstr ""
815
-
816
- #: modules/themed-profiles/themed-profiles.php:271
817
- msgid "You do not have permission to edit this user."
818
- msgstr ""
819
-
820
- #: modules/themed-profiles/themed-profiles.php:308
821
- msgid "Profile updated."
822
- msgstr ""
823
-
824
- #: modules/custom-redirection/admin/custom-redirection-admin.php:86
825
- #: modules/custom-redirection/admin/custom-redirection-admin.php:133
826
- msgid "Theme My Login Custom Redirection Settings"
827
- msgstr ""
828
-
829
- #: modules/custom-redirection/admin/custom-redirection-admin.php:87
830
- msgid "Redirection"
831
- msgstr ""
832
-
833
- #: modules/custom-redirection/admin/custom-redirection-admin.php:168
834
- #: modules/custom-redirection/admin/custom-redirection-admin.php:182
835
- msgid "Default"
836
- msgstr ""
837
-
838
- #: modules/custom-redirection/admin/custom-redirection-admin.php:169
839
- msgid "Check this option to send the user to their WordPress Dashboard/Profile."
840
- msgstr ""
841
-
842
- #: modules/custom-redirection/admin/custom-redirection-admin.php:171
843
- #: modules/custom-redirection/admin/custom-redirection-admin.php:185
844
- msgid "Referer"
845
- msgstr ""
846
-
847
- #: modules/custom-redirection/admin/custom-redirection-admin.php:172
848
- msgid "Check this option to send the user back to the page they were visiting before logging in."
849
- msgstr ""
850
-
851
- #: modules/custom-redirection/admin/custom-redirection-admin.php:176
852
- #: modules/custom-redirection/admin/custom-redirection-admin.php:190
853
- msgid "Check this option to send the user to a custom location, specified by the textbox above."
854
- msgstr ""
855
-
856
- #: modules/custom-redirection/admin/custom-redirection-admin.php:183
857
- msgid "Check this option to send the user to the log in page, displaying a message that they have successfully logged out."
858
- msgstr ""
859
-
860
- #: modules/custom-redirection/admin/custom-redirection-admin.php:186
861
- msgid "Check this option to send the user back to the page they were visiting before logging out. (Note: If the previous page being visited was an admin page, this can have unexpected results.)"
862
- msgstr ""
863
-
864
- #: modules/security/admin/security-admin.php:89
865
- #: modules/security/admin/security-admin.php:121
866
- msgid "Theme My Login Security Settings"
867
- msgstr ""
868
-
869
- #: modules/security/admin/security-admin.php:90
870
- msgid "Security"
871
- msgstr ""
872
-
873
- #: modules/security/admin/security-admin.php:98
874
- msgid "Private Site"
875
- msgstr ""
876
-
877
- #: modules/security/admin/security-admin.php:99
878
- msgid "Private Login"
879
- msgstr ""
880
-
881
- #: modules/security/admin/security-admin.php:100
882
- msgid "Login Attempts"
883
- msgstr ""
884
-
885
- #: modules/security/admin/security-admin.php:135
886
- msgid "Require users to be logged in to view site"
887
- msgstr ""
888
-
889
- #: modules/security/admin/security-admin.php:148
890
- msgid "Disable <tt>wp-login.php</tt>"
891
- msgstr ""
892
-
893
- #: modules/security/admin/security-admin.php:161
894
- msgid "minute(s)"
895
- msgstr ""
896
-
897
- #: modules/security/admin/security-admin.php:162
898
- msgid "hour(s)"
899
- msgstr ""
900
-
901
- #: modules/security/admin/security-admin.php:163
902
- msgid "day(s)"
903
- msgstr ""
904
-
905
- #: modules/security/admin/security-admin.php:190
906
- msgid "After %1$s failed login attempts within %2$s %3$s, lockout the account for %4$s %5$s."
907
- msgstr ""
908
-
909
- #: modules/security/admin/security-admin.php:241
910
- #: modules/security/admin/security-admin.php:244
911
- #: modules/user-moderation/admin/user-moderation-admin.php:232
912
- #: modules/user-moderation/admin/user-moderation-admin.php:242
913
- msgid "You can&#8217;t edit that user."
914
- msgstr ""
915
-
916
- #: modules/security/admin/security-admin.php:276
917
- msgid "User locked."
918
- msgstr ""
919
-
920
- #: modules/security/admin/security-admin.php:278
921
- msgid "User unlocked."
922
- msgstr ""
923
-
924
- #: modules/security/admin/security-admin.php:301
925
- msgid "Unlock"
926
- msgstr ""
927
-
928
- #: modules/security/admin/security-admin.php:303
929
- msgid "Lock"
930
- msgstr ""
931
-
932
- #: modules/security/security.php:167
933
- msgid "Your account has been unlocked. You may now log in."
934
- msgstr ""
935
-
936
- #: modules/security/security.php:185
937
- #: modules/security/security.php:188
938
- #: modules/security/security.php:191
939
- #: modules/security/security.php:194
940
- #: modules/user-moderation/user-moderation.php:345
941
- #: modules/user-moderation/user-moderation.php:348
942
- #: modules/user-moderation/user-moderation.php:353
943
- msgid "Invalid key"
944
- msgstr ""
945
-
946
- #: modules/security/security.php:227
947
- #: modules/security/security.php:250
948
- msgid "<strong>ERROR</strong>: This account has been locked because of too many failed login attempts. You may try again in %s."
949
- msgstr ""
950
-
951
- #: modules/security/security.php:229
952
- msgid "<strong>ERROR</strong>: This account has been locked."
953
- msgstr ""
954
-
955
- #: modules/security/security.php:294
956
- msgid "Failed Login Attempts"
957
- msgstr ""
958
-
959
- #: modules/security/security.php:298
960
- msgid "IP Address"
961
- msgstr ""
962
-
963
- #: modules/security/security.php:299
964
- msgid "Date"
965
- msgstr ""
966
-
967
- #: modules/security/security.php:302
968
- #: modules/security/security.php:605
969
- msgid "Y/m/d g:i:s A"
970
- msgstr ""
971
-
972
- #: modules/security/security.php:307
973
- msgid "%s ago"
974
- msgstr ""
975
-
976
- #: modules/security/security.php:309
977
- msgid "Y/m/d"
978
- msgstr ""
979
-
980
- #: modules/security/security.php:597
981
- msgid "[%s] Account Locked"
982
- msgstr ""
983
-
984
- #: modules/security/security.php:598
985
- msgid "For your security, your account has been locked because of too many failed login attempts. To unlock your account please click the following link: "
986
- msgstr ""
987
-
988
- #: modules/security/security.php:603
989
- msgid "The following attempts resulted in the lock:"
990
- msgstr ""
991
-
992
- #: modules/custom-user-links/admin/custom-user-links-admin.php:94
993
- #: modules/custom-user-links/admin/custom-user-links-admin.php:144
994
- msgid "Theme My Login Custom User Links Settings"
995
- msgstr ""
996
-
997
- #: modules/custom-user-links/admin/custom-user-links-admin.php:95
998
- msgid "User Links"
999
- msgstr ""
1000
-
1001
- #: modules/custom-user-links/admin/custom-user-links-admin.php:181
1002
- #: modules/custom-user-links/admin/custom-user-links-admin.php:231
1003
- msgid "Title"
1004
- msgstr ""
1005
-
1006
- #: modules/custom-user-links/admin/custom-user-links-admin.php:182
1007
- #: modules/custom-user-links/admin/custom-user-links-admin.php:232
1008
- msgid "URL"
1009
- msgstr ""
1010
-
1011
- #: modules/custom-user-links/admin/custom-user-links-admin.php:205
1012
- msgid "Add Link"
1013
- msgstr ""
1014
-
1015
- #: modules/custom-user-links/admin/custom-user-links-admin.php:235
1016
- msgid "Delete"
1017
- msgstr ""
1018
-
1019
- #: modules/user-moderation/admin/user-moderation-admin.php:86
1020
- msgid "User Moderation is not currently compatible with multisite."
1021
- msgstr ""
1022
-
1023
- #: modules/user-moderation/admin/user-moderation-admin.php:136
1024
- #: modules/user-moderation/admin/user-moderation-admin.php:168
1025
- msgid "Theme My Login User Moderation Settings"
1026
- msgstr ""
1027
-
1028
- #: modules/user-moderation/admin/user-moderation-admin.php:137
1029
- msgid "Moderation"
1030
- msgstr ""
1031
-
1032
- #: modules/user-moderation/admin/user-moderation-admin.php:145
1033
- msgid "Moderation Type"
1034
- msgstr ""
1035
-
1036
- #: modules/user-moderation/admin/user-moderation-admin.php:182
1037
- msgid "None"
1038
- msgstr ""
1039
-
1040
- #: modules/user-moderation/admin/user-moderation-admin.php:183
1041
- msgid "Check this option to require no moderation."
1042
- msgstr ""
1043
-
1044
- #: modules/user-moderation/admin/user-moderation-admin.php:186
1045
- msgid "E-mail Confirmation"
1046
- msgstr ""
1047
-
1048
- #: modules/user-moderation/admin/user-moderation-admin.php:187
1049
- msgid "Check this option to require new users to confirm their e-mail address before they may log in."
1050
- msgstr ""
1051
-
1052
- #: modules/user-moderation/admin/user-moderation-admin.php:190
1053
- msgid "Admin Approval"
1054
- msgstr ""
1055
-
1056
- #: modules/user-moderation/admin/user-moderation-admin.php:191
1057
- msgid "Check this option to require new users to be approved by an administrator before they may log in."
1058
- msgstr ""
1059
-
1060
- #: modules/user-moderation/admin/user-moderation-admin.php:275
1061
- msgid "User approved."
1062
- msgstr ""
1063
-
1064
- #: modules/user-moderation/admin/user-moderation-admin.php:277
1065
- msgid "Activation sent."
1066
- msgstr ""
1067
-
1068
- #: modules/user-moderation/admin/user-moderation-admin.php:308
1069
- msgid "Resend Activation"
1070
- msgstr ""
1071
-
1072
- #: modules/user-moderation/admin/user-moderation-admin.php:318
1073
- msgid "Approve"
1074
- msgstr ""
1075
-
1076
- #: modules/user-moderation/admin/user-moderation-admin.php:381
1077
- msgid "You have been approved access to %s"
1078
- msgstr ""
1079
-
1080
- #: modules/user-moderation/admin/user-moderation-admin.php:383
1081
- #: modules/custom-email/custom-email.php:873
1082
- msgid "To set your password, visit the following address:"
1083
- msgstr ""
1084
-
1085
- #: modules/user-moderation/admin/user-moderation-admin.php:388
1086
- msgid "[%s] Registration Approved"
1087
- msgstr ""
1088
-
1089
- #: modules/user-moderation/admin/user-moderation-admin.php:429
1090
- msgid "You have been denied access to %s"
1091
- msgstr ""
1092
-
1093
- #: modules/user-moderation/admin/user-moderation-admin.php:430
1094
- msgid "[%s] Registration Denied"
1095
- msgstr ""
1096
-
1097
- #: modules/user-moderation/user-moderation.php:159
1098
- msgid "<strong>ERROR</strong>: You have not yet confirmed your e-mail address. <a href=\"%s\">Resend activation</a>?"
1099
- msgstr ""
1100
-
1101
- #: modules/user-moderation/user-moderation.php:163
1102
- msgid "<strong>ERROR</strong>: Your registration has not yet been approved."
1103
- msgstr ""
1104
-
1105
- #: modules/user-moderation/user-moderation.php:202
1106
- msgid "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."
1107
- msgstr ""
1108
-
1109
- #: modules/user-moderation/user-moderation.php:205
1110
- msgid "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."
1111
- msgstr ""
1112
-
1113
- #: modules/user-moderation/user-moderation.php:214
1114
- msgid "Your account has been activated. You may now log in."
1115
- msgstr ""
1116
-
1117
- #: modules/user-moderation/user-moderation.php:216
1118
- msgid "Your account has been activated. Please check your e-mail for your password."
1119
- msgstr ""
1120
-
1121
- #: modules/user-moderation/user-moderation.php:219
1122
- msgid "<strong>ERROR</strong>: Sorry, that key does not appear to be valid."
1123
- msgstr ""
1124
-
1125
- #: modules/user-moderation/user-moderation.php:227
1126
- msgid "<strong>ERROR</strong>: Sorry, the activation e-mail could not be sent."
1127
- msgstr ""
1128
-
1129
- #: modules/user-moderation/user-moderation.php:230
1130
- msgid "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."
1131
- msgstr ""
1132
-
1133
- #: modules/user-moderation/user-moderation.php:421
1134
- msgid "[%s] Activate Your Account"
1135
- msgstr ""
1136
-
1137
- #: modules/user-moderation/user-moderation.php:422
1138
- msgid "Thanks for registering at %s! To complete the activation of your account please click the following link: "
1139
- msgstr ""
1140
-
1141
- #: modules/user-moderation/user-moderation.php:458
1142
- msgid "[%s] New User Awaiting Approval"
1143
- msgstr ""
1144
-
1145
- #: modules/user-moderation/user-moderation.php:460
1146
- msgid "New user requires approval on your blog %s:"
1147
- msgstr ""
1148
-
1149
- #: modules/user-moderation/user-moderation.php:462
1150
- #: modules/custom-email/custom-email.php:844
1151
- msgid "E-mail: %s"
1152
- msgstr ""
1153
-
1154
- #: modules/user-moderation/user-moderation.php:463
1155
- msgid "To approve or deny this user:"
1156
- msgstr ""
1157
-
1158
- #: modules/custom-passwords/custom-passwords.php:104
1159
- msgid "(Must be at least %d characters.)"
1160
- msgstr ""
1161
-
1162
- #: modules/custom-passwords/custom-passwords.php:106
1163
- msgid "Confirm Password:"
1164
- msgstr ""
1165
-
1166
- #: modules/custom-passwords/custom-passwords.php:108
1167
- msgid "Confirm that you've typed your password correctly."
1168
- msgstr ""
1169
-
1170
- #: modules/custom-passwords/custom-passwords.php:145
1171
- msgid "<strong>ERROR</strong>: Please enter your password twice."
1172
- msgstr ""
1173
-
1174
- #: modules/custom-passwords/custom-passwords.php:149
1175
- msgid "<strong>ERROR</strong>: Passwords may not contain the character \"\\\"."
1176
- msgstr ""
1177
-
1178
- #: modules/custom-passwords/custom-passwords.php:153
1179
- msgid "<strong>ERROR</strong>: Please enter the same password in the two password fields."
1180
- msgstr ""
1181
-
1182
- #: modules/custom-passwords/custom-passwords.php:157
1183
- msgid "<strong>ERROR</strong>: Your password must be at least %d characters in length."
1184
- msgstr ""
1185
-
1186
- #: modules/custom-passwords/custom-passwords.php:286
1187
- msgid "Registration complete. You may now log in."
1188
- msgstr ""
1189
-
1190
- #: modules/recaptcha/recaptcha.php:110
1191
- msgid "<strong>ERROR</strong>: Invalid reCAPTCHA secret key."
1192
- msgstr ""
1193
-
1194
- #: modules/recaptcha/recaptcha.php:114
1195
- msgid "<strong>ERROR</strong>: Please check the box to prove that you are not a robot."
1196
- msgstr ""
1197
-
1198
- #: modules/recaptcha/recaptcha.php:118
1199
- msgid "<strong>ERROR</strong>: Unable to reach the reCAPTCHA server."
1200
- msgstr ""
1201
-
1202
- #: modules/recaptcha/admin/recaptcha-admin.php:89
1203
- #: modules/recaptcha/admin/recaptcha-admin.php:139
1204
- msgid "Theme My Login reCAPTCHA Settings"
1205
- msgstr ""
1206
-
1207
- #: modules/recaptcha/admin/recaptcha-admin.php:90
1208
- msgid "reCAPTCHA"
1209
- msgstr ""
1210
-
1211
- #: modules/recaptcha/admin/recaptcha-admin.php:98
1212
- msgid "Site Key"
1213
- msgstr ""
1214
-
1215
- #: modules/recaptcha/admin/recaptcha-admin.php:99
1216
- msgid "Secret Key"
1217
- msgstr ""
1218
-
1219
- #: modules/recaptcha/admin/recaptcha-admin.php:100
1220
- msgid "Theme"
1221
- msgstr ""
1222
-
1223
- #: modules/recaptcha/admin/recaptcha-admin.php:123
1224
- msgctxt "recaptcha theme"
1225
- msgid "Light"
1226
- msgstr ""
1227
-
1228
- #: modules/recaptcha/admin/recaptcha-admin.php:124
1229
- msgctxt "recaptcha theme"
1230
- msgid "Dark"
1231
- msgstr ""
1232
-
1233
- #: modules/custom-email/admin/custom-email-admin.php:90
1234
- #: modules/custom-email/admin/custom-email-admin.php:147
1235
- msgid "Theme My Login Custom E-mail Settings"
1236
- msgstr ""
1237
-
1238
- #: modules/custom-email/admin/custom-email-admin.php:97
1239
- msgid "New User"
1240
- msgstr ""
1241
-
1242
- #: modules/custom-email/admin/custom-email-admin.php:98
1243
- msgid "New User Admin"
1244
- msgstr ""
1245
-
1246
- #: modules/custom-email/admin/custom-email-admin.php:99
1247
- msgid "Retrieve Password"
1248
- msgstr ""
1249
-
1250
- #: modules/custom-email/admin/custom-email-admin.php:104
1251
- msgid "User Activation"
1252
- msgstr ""
1253
-
1254
- #: modules/custom-email/admin/custom-email-admin.php:105
1255
- msgid "User Approval"
1256
- msgstr ""
1257
-
1258
- #: modules/custom-email/admin/custom-email-admin.php:106
1259
- msgid "User Approval Admin"
1260
- msgstr ""
1261
-
1262
- #: modules/custom-email/admin/custom-email-admin.php:107
1263
- msgid "User Denial"
1264
- msgstr ""
1265
-
1266
- #: modules/custom-email/admin/custom-email-admin.php:176
1267
- msgid "This e-mail will be sent to a new user upon registration."
1268
- msgstr ""
1269
-
1270
- #: modules/custom-email/admin/custom-email-admin.php:177
1271
- #: modules/custom-email/admin/custom-email-admin.php:282
1272
- #: modules/custom-email/admin/custom-email-admin.php:436
1273
- msgid "Please be sure to include the variable %reseturl% or else the user will not be able to recover their password!"
1274
- msgstr ""
1275
-
1276
- #: modules/custom-email/admin/custom-email-admin.php:178
1277
- #: modules/custom-email/admin/custom-email-admin.php:225
1278
- #: modules/custom-email/admin/custom-email-admin.php:283
1279
- #: modules/custom-email/admin/custom-email-admin.php:330
1280
- #: modules/custom-email/admin/custom-email-admin.php:389
1281
- #: modules/custom-email/admin/custom-email-admin.php:437
1282
- #: modules/custom-email/admin/custom-email-admin.php:484
1283
- #: modules/custom-email/admin/custom-email-admin.php:542
1284
- msgid "If any field is left empty, the default will be used instead."
1285
- msgstr ""
1286
-
1287
- #: modules/custom-email/admin/custom-email-admin.php:182
1288
- #: modules/custom-email/admin/custom-email-admin.php:233
1289
- #: modules/custom-email/admin/custom-email-admin.php:287
1290
- #: modules/custom-email/admin/custom-email-admin.php:338
1291
- #: modules/custom-email/admin/custom-email-admin.php:393
1292
- #: modules/custom-email/admin/custom-email-admin.php:441
1293
- #: modules/custom-email/admin/custom-email-admin.php:492
1294
- #: modules/custom-email/admin/custom-email-admin.php:546
1295
- msgid "From Name"
1296
- msgstr ""
1297
-
1298
- #: modules/custom-email/admin/custom-email-admin.php:186
1299
- #: modules/custom-email/admin/custom-email-admin.php:237
1300
- #: modules/custom-email/admin/custom-email-admin.php:291
1301
- #: modules/custom-email/admin/custom-email-admin.php:342
1302
- #: modules/custom-email/admin/custom-email-admin.php:397
1303
- #: modules/custom-email/admin/custom-email-admin.php:445
1304
- #: modules/custom-email/admin/custom-email-admin.php:496
1305
- #: modules/custom-email/admin/custom-email-admin.php:550
1306
- msgid "From E-mail"
1307
- msgstr ""
1308
-
1309
- #: modules/custom-email/admin/custom-email-admin.php:190
1310
- #: modules/custom-email/admin/custom-email-admin.php:241
1311
- #: modules/custom-email/admin/custom-email-admin.php:295
1312
- #: modules/custom-email/admin/custom-email-admin.php:346
1313
- #: modules/custom-email/admin/custom-email-admin.php:401
1314
- #: modules/custom-email/admin/custom-email-admin.php:449
1315
- #: modules/custom-email/admin/custom-email-admin.php:500
1316
- #: modules/custom-email/admin/custom-email-admin.php:554
1317
- msgid "E-mail Format"
1318
- msgstr ""
1319
-
1320
- #: modules/custom-email/admin/custom-email-admin.php:193
1321
- #: modules/custom-email/admin/custom-email-admin.php:244
1322
- #: modules/custom-email/admin/custom-email-admin.php:298
1323
- #: modules/custom-email/admin/custom-email-admin.php:349
1324
- #: modules/custom-email/admin/custom-email-admin.php:404
1325
- #: modules/custom-email/admin/custom-email-admin.php:452
1326
- #: modules/custom-email/admin/custom-email-admin.php:503
1327
- #: modules/custom-email/admin/custom-email-admin.php:557
1328
- msgid "Plain Text"
1329
- msgstr ""
1330
-
1331
- #: modules/custom-email/admin/custom-email-admin.php:194
1332
- #: modules/custom-email/admin/custom-email-admin.php:245
1333
- #: modules/custom-email/admin/custom-email-admin.php:299
1334
- #: modules/custom-email/admin/custom-email-admin.php:350
1335
- #: modules/custom-email/admin/custom-email-admin.php:405
1336
- #: modules/custom-email/admin/custom-email-admin.php:453
1337
- #: modules/custom-email/admin/custom-email-admin.php:504
1338
- #: modules/custom-email/admin/custom-email-admin.php:558
1339
- msgid "HTML"
1340
- msgstr ""
1341
-
1342
- #: modules/custom-email/admin/custom-email-admin.php:199
1343
- #: modules/custom-email/admin/custom-email-admin.php:249
1344
- #: modules/custom-email/admin/custom-email-admin.php:304
1345
- #: modules/custom-email/admin/custom-email-admin.php:355
1346
- #: modules/custom-email/admin/custom-email-admin.php:410
1347
- #: modules/custom-email/admin/custom-email-admin.php:458
1348
- #: modules/custom-email/admin/custom-email-admin.php:509
1349
- #: modules/custom-email/admin/custom-email-admin.php:563
1350
- msgid "Subject"
1351
- msgstr ""
1352
-
1353
- #: modules/custom-email/admin/custom-email-admin.php:203
1354
- #: modules/custom-email/admin/custom-email-admin.php:253
1355
- #: modules/custom-email/admin/custom-email-admin.php:308
1356
- #: modules/custom-email/admin/custom-email-admin.php:359
1357
- #: modules/custom-email/admin/custom-email-admin.php:414
1358
- #: modules/custom-email/admin/custom-email-admin.php:462
1359
- #: modules/custom-email/admin/custom-email-admin.php:513
1360
- #: modules/custom-email/admin/custom-email-admin.php:567
1361
- msgid "Message"
1362
- msgstr ""
1363
-
1364
- #: modules/custom-email/admin/custom-email-admin.php:205
1365
- #: modules/custom-email/admin/custom-email-admin.php:255
1366
- #: modules/custom-email/admin/custom-email-admin.php:310
1367
- #: modules/custom-email/admin/custom-email-admin.php:361
1368
- #: modules/custom-email/admin/custom-email-admin.php:416
1369
- #: modules/custom-email/admin/custom-email-admin.php:464
1370
- #: modules/custom-email/admin/custom-email-admin.php:515
1371
- #: modules/custom-email/admin/custom-email-admin.php:569
1372
- msgid "Available Variables"
1373
- msgstr ""
1374
-
1375
- #: modules/custom-email/admin/custom-email-admin.php:224
1376
- msgid "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."
1377
- msgstr ""
1378
-
1379
- #: modules/custom-email/admin/custom-email-admin.php:229
1380
- #: modules/custom-email/admin/custom-email-admin.php:334
1381
- #: modules/custom-email/admin/custom-email-admin.php:488
1382
- msgid "To"
1383
- msgstr ""
1384
-
1385
- #: modules/custom-email/admin/custom-email-admin.php:263
1386
- #: modules/custom-email/admin/custom-email-admin.php:369
1387
- #: modules/custom-email/admin/custom-email-admin.php:523
1388
- msgid "Disable Admin Notification"
1389
- msgstr ""
1390
-
1391
- #: modules/custom-email/admin/custom-email-admin.php:281
1392
- msgid "This e-mail will be sent to a user when they attempt to recover their password."
1393
- msgstr ""
1394
-
1395
- #: modules/custom-email/admin/custom-email-admin.php:329
1396
- msgid "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."
1397
- msgstr ""
1398
-
1399
- #: modules/custom-email/admin/custom-email-admin.php:387
1400
- msgid "This e-mail will be sent to a new user upon registration when \"E-mail Confirmation\" is checked for \"User Moderation\"."
1401
- msgstr ""
1402
-
1403
- #: modules/custom-email/admin/custom-email-admin.php:388
1404
- msgid "Please be sure to include the variable %activateurl% or else the user will not be able to activate their account!"
1405
- msgstr ""
1406
-
1407
- #: modules/custom-email/admin/custom-email-admin.php:435
1408
- msgid "This e-mail will be sent to a new user upon admin approval when \"Admin Approval\" is checked for \"User Moderation\"."
1409
- msgstr ""
1410
-
1411
- #: modules/custom-email/admin/custom-email-admin.php:483
1412
- msgid "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\"."
1413
- msgstr ""
1414
-
1415
- #: modules/custom-email/admin/custom-email-admin.php:541
1416
- msgid "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\"."
1417
- msgstr ""
1418
-
1419
- #: modules/custom-email/admin/custom-email-admin.php:577
1420
- msgid "Disable Notification"
1421
- msgstr ""
1422
-
1423
- #: modules/custom-email/custom-email.php:842
1424
- msgid "New user registration on your site %s:"
1425
- msgstr ""
1426
-
1427
- #: modules/custom-email/custom-email.php:846
1428
- msgid "[%s] New User Registration"
1429
- msgstr ""
1430
-
1431
- #: modules/custom-email/custom-email.php:878
1432
- msgid "[%s] Your username and password info"
1433
- msgstr ""
1434
-
1435
- #: modules/custom-email/custom-email.php:906
1436
- msgid "[%s] Password Lost/Changed"
1437
- msgstr ""
1438
-
1439
- #: modules/custom-email/custom-email.php:907
1440
- msgid "Password Lost and Changed for user: %s"
1441
- msgstr ""
1442
-
1443
- #. Plugin URI of the plugin
1444
- msgid "http://www.jfarthing.com/extend/wordpress-plugins/theme-my-login/"
1445
  msgstr ""
1446
 
1447
  #. Description of the plugin
1448
- msgid "Themes the WordPress login, registration and forgot password pages according to your theme."
1449
- msgstr ""
1450
-
1451
- #. Author of the plugin
1452
- msgid "Jeff Farthing"
1453
- msgstr ""
1454
-
1455
- #. Author URI of the plugin
1456
- msgid "http://www.jfarthing.com"
1457
  msgstr ""
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 7.0.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/theme-my-login\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2018-06-15T20:03:50-04:00\n"
13
+ "PO-Revision-Date: 2018-06-15T20:03:50-04:00\n"
14
  "X-Domain: theme-my-login\n"
15
 
16
+ #: includes/functions.php:394
17
+ #: admin/functions.php:223
18
+ msgid "Theme My Login Actions"
 
19
  msgstr ""
20
 
21
+ #: includes/functions.php:395
22
+ msgid "Theme My Login Action"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  msgstr ""
24
 
25
+ #: includes/functions.php:423
26
+ #: includes/functions.php:450
27
+ #: includes/functions.php:465
28
+ msgid "TML Action"
29
  msgstr ""
30
 
31
+ #: includes/functions.php:549
32
+ msgid "If you have already set your own password, you may disregard this email and use the password you have already set."
 
 
 
33
  msgstr ""
34
 
35
+ #: includes/actions.php:68
36
+ msgid "Your Data Request"
 
 
 
37
  msgstr ""
38
 
39
+ #: includes/actions.php:463
40
+ msgid "Registration complete. You may now log in."
41
  msgstr ""
42
 
43
  #. Plugin Name of the plugin
44
+ #. Author of the plugin
45
+ #: includes/class-theme-my-login-widget.php:23
46
+ #: admin/functions.php:69
47
  msgid "Theme My Login"
48
  msgstr ""
49
 
50
+ #: includes/class-theme-my-login-widget.php:25
51
+ msgid "A login form for your site."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  msgstr ""
53
 
54
+ #: includes/class-theme-my-login-widget.php:99
55
+ msgid "Show action links?"
56
  msgstr ""
57
 
58
+ #: includes/extensions.php:189
59
+ #: includes/extensions.php:220
60
+ #: includes/extensions.php:250
61
+ msgid "An error occurred, please try again."
62
  msgstr ""
63
 
64
+ #: includes/extensions.php:202
65
+ msgid "Your license key has been disabled."
 
 
66
  msgstr ""
67
 
68
+ #: includes/extensions.php:207
69
+ msgid "Invalid license."
70
  msgstr ""
71
 
72
+ #: includes/extensions.php:212
73
+ msgid "Your license is not active for this URL."
74
  msgstr ""
75
 
76
+ #: includes/extensions.php:216
77
+ msgid "Your license key has reached its activation limit."
78
  msgstr ""
79
 
80
+ #: admin/functions.php:68
81
+ #: admin/functions.php:79
82
  msgid "Theme My Login Settings"
83
  msgstr ""
84
 
85
+ #: admin/functions.php:80
 
 
 
 
 
 
86
  msgid "General"
87
  msgstr ""
88
 
89
+ #: admin/functions.php:101
90
+ msgid "Theme My Login Licenses"
 
 
 
 
 
 
 
91
  msgstr ""
92
 
93
+ #: admin/functions.php:102
94
+ msgid "Licenses"
95
  msgstr ""
96
 
97
+ #: admin/functions.php:111
98
+ msgid "Theme My Login Extensions"
 
 
 
 
 
 
 
 
 
 
 
 
99
  msgstr ""
100
 
101
+ #: admin/functions.php:112
102
+ msgid "Extensions"
103
  msgstr ""
104
 
105
+ #: admin/functions.php:148
106
+ msgid "As a token of our gratitude, we would like to offer your an incentive for upgrading Theme My Login to version 7.0. For a limited time, we are offering a <strong>20% discount</strong> when you use the code <strong>SAVINGFACE</strong> at checkout. Act now - this offer won't last!"
107
  msgstr ""
108
 
109
+ #: admin/settings.php:96
110
+ msgid "Registration"
111
  msgstr ""
112
 
113
+ #: admin/settings.php:101
114
+ msgid "Slugs"
115
  msgstr ""
116
 
117
+ #: admin/settings.php:121
118
+ #: admin/settings.php:126
119
+ msgid "Login Type"
120
  msgstr ""
121
 
122
+ #: admin/settings.php:128
123
+ #: admin/settings.php:147
124
+ msgid "Default"
125
  msgstr ""
126
 
127
+ #: admin/settings.php:129
128
  msgid "Username only"
129
  msgstr ""
130
 
131
+ #: admin/settings.php:130
132
+ #: admin/settings.php:148
133
+ msgid "Email only"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  msgstr ""
135
 
136
+ #: admin/settings.php:140
137
+ #: admin/settings.php:145
138
+ msgid "Registration Type"
139
  msgstr ""
140
 
141
+ #: admin/settings.php:155
142
+ msgid "Passwords"
143
  msgstr ""
144
 
145
+ #: admin/settings.php:160
146
+ msgid "Allow users to set their own password"
 
147
  msgstr ""
148
 
149
+ #: admin/settings.php:167
150
+ msgid "Auto-Login"
151
  msgstr ""
152
 
153
+ #: admin/settings.php:172
154
+ msgid "Automatically log in users after registration"
 
155
  msgstr ""
156
 
157
+ #: admin/settings.php:433
158
+ msgid "Active"
 
159
  msgstr ""
160
 
161
+ #: admin/settings.php:437
162
+ msgid "Invalid"
 
163
  msgstr ""
164
 
165
+ #: admin/settings.php:440
166
+ msgid "Inactive"
 
167
  msgstr ""
168
 
169
+ #: admin/settings.php:455
170
+ msgid "Deactivate"
 
171
  msgstr ""
172
 
173
+ #: admin/settings.php:457
174
+ msgid "Activate"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  msgstr ""
176
 
177
+ #: admin/extensions.php:61
178
+ msgid "Whoops! Looks like there was an error fetching extensions from the server. Please try again."
179
  msgstr ""
180
 
181
+ #: admin/extensions.php:62
182
+ msgid "Error: %s"
183
  msgstr ""
184
 
185
+ #: admin/extensions.php:84
186
+ msgid "Get This Extension"
187
  msgstr ""
188
 
189
+ #: admin/extensions.php:94
190
+ msgid "View All Extensions"
191
  msgstr ""
192
 
193
+ #. Plugin URI of the plugin
194
+ #. Author URI of the plugin
195
+ msgid "https://thememylogin.com"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  msgstr ""
197
 
198
  #. Description of the plugin
199
+ msgid "Creates an alternate login, registration and password recovery experience within your theme."
 
 
 
 
 
 
 
 
200
  msgstr ""
modules/custom-email/admin/custom-email-admin.php DELETED
@@ -1,613 +0,0 @@
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/admin/js/custom-email-admin.js DELETED
@@ -1,3 +0,0 @@
1
- jQuery(document).ready( function($) {
2
- postboxes.add_postbox_toggles(pagenow);
3
- } );
 
 
 
modules/custom-email/custom-email.php DELETED
@@ -1,938 +0,0 @@
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 DELETED
@@ -1,313 +0,0 @@
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_current_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', sprintf( __( '(Must be at least %d characters.)', 'theme-my-login' ), apply_filters( 'tml_minimum_password_length', 6 ) ) ); ?></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'] ) < apply_filters( 'tml_minimum_password_length', 6 ) ) {
157
- $errors->add( 'password_length', sprintf( __( '<strong>ERROR</strong>: Your password must be at least %d characters in length.', 'theme-my-login' ), apply_filters( 'tml_minimum_password_length', 6 ) ) );
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;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-redirection/admin/custom-redirection-admin.php DELETED
@@ -1,201 +0,0 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Custom Redirection Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Custom_Redirection
7
- * @since 6.0
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Custom_Redirection_Admin' ) ) :
11
- /**
12
- * Theme My Login Custom Redirection Admin class
13
- *
14
- * @since 6.3
15
- */
16
- class Theme_My_Login_Custom_Redirection_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_redirection';
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
- * Called on Theme_My_Login_Abstract::__construct
39
- *
40
- * @since 6.3
41
- * @access protected
42
- */
43
- protected function load() {
44
- add_action( 'tml_uninstall_custom-redirection/custom-redirection.php', array( $this, 'uninstall' ) );
45
-
46
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
47
- add_action( 'admin_init', array( $this, 'admin_init' ) );
48
-
49
- add_action( 'load-tml_page_theme_my_login_redirection', array( $this, 'load_settings_page' ) );
50
- }
51
-
52
- /**
53
- * Returns default options
54
- *
55
- * @since 6.3
56
- * @access public
57
- */
58
- public static function default_options() {
59
- return Theme_My_Login_Custom_Redirection::default_options();
60
- }
61
-
62
- /**
63
- * Uninstalls the module
64
- *
65
- * Callback for "tml_uninstall_custom-email/custom-email.php" hook in method Theme_My_Login_Admin::uninstall()
66
- *
67
- * @see Theme_My_Login_Admin::uninstall()
68
- * @since 6.3
69
- * @access public
70
- */
71
- public function uninstall() {
72
- delete_option( $this->options_key );
73
- }
74
-
75
- /**
76
- * Adds "Redirection" tab to Theme My Login menu
77
- *
78
- * @since 6.0
79
- * @access public
80
- */
81
- public function admin_menu() {
82
- global $wp_roles;
83
-
84
- add_submenu_page(
85
- 'theme_my_login',
86
- __( 'Theme My Login Custom Redirection Settings', 'theme-my-login' ),
87
- __( 'Redirection', 'theme-my-login' ),
88
- 'manage_options',
89
- $this->options_key,
90
- array( $this, 'settings_page' )
91
- );
92
-
93
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
94
- if ( 'pending' != $role )
95
- add_meta_box( $role, translate_user_role( $role_name ), array( $this, 'redirection_meta_box' ), 'tml_page_' . $this->options_key, 'normal' );
96
- }
97
- }
98
-
99
- /**
100
- * Registers options group
101
- *
102
- * Callback for "admin_init" hook
103
- *
104
- * @since 6.3
105
- * @access public
106
- */
107
- public function admin_init() {
108
- register_setting( $this->options_key, $this->options_key );
109
- }
110
-
111
- /**
112
- * Loads admin styles and scripts
113
- *
114
- * Callback for "load-settings_page_theme-my-login" hook in file "wp-admin/admin.php"
115
- *
116
- * @since 6.0
117
- * @access public
118
- */
119
- public function load_settings_page() {
120
- wp_enqueue_script( 'tml-custom-redirection-admin', plugins_url( 'js/custom-redirection-admin.js', __FILE__ ), array( 'postbox' ) );
121
- }
122
-
123
- /**
124
- * Renders settings page
125
- *
126
- * @since 6.3
127
- * @access public
128
- */
129
- public function settings_page() {
130
- global $current_screen;
131
- ?>
132
- <div class="wrap">
133
- <h2><?php esc_html_e( 'Theme My Login Custom Redirection Settings', 'theme-my-login' ); ?></h2>
134
- <?php settings_errors(); ?>
135
-
136
- <form method="post" action="options.php">
137
- <?php
138
- settings_fields( $this->options_key );
139
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
140
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
141
- ?>
142
- <div id="<?php echo $this->options_key; ?>" class="metabox-holder">
143
- <?php do_meta_boxes( $current_screen->id, 'normal', null ); ?>
144
- </div>
145
- <?php submit_button(); ?>
146
- </form>
147
- </div>
148
- <?php
149
- }
150
-
151
- /**
152
- * Outputs redirection admin menu for specified role
153
- *
154
- * Callback for add_submenu_page()
155
- *
156
- * @since 6.3
157
- * @access public
158
- *
159
- * @param array $args Arguments passed in from add_submenu_page()
160
- */
161
- public function redirection_meta_box( $object, $box ) {
162
- $role = $box['id'];
163
- ?>
164
- <table class="form-table">
165
- <tr valign="top">
166
- <th scope="row"><?php _e( 'Log in' ); ?></th>
167
- <td>
168
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][login_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_type_default" value="default"<?php checked( 'default', $this->get_option( array( $role, 'login_type' ) ) ); ?> /> <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_type_default"><?php _e( 'Default', 'theme-my-login' ); ?></label>
169
- <p class="description"><?php _e( 'Check this option to send the user to their WordPress Dashboard/Profile.', 'theme-my-login' ); ?></p>
170
-
171
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][login_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_type_referer" value="referer"<?php checked( 'referer', $this->get_option( array( $role, 'login_type' ) ) ); ?> /> <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_type_referer"><?php _e( 'Referer', 'theme-my-login' ); ?></label>
172
- <p class="description"><?php _e( 'Check this option to send the user back to the page they were visiting before logging in.', 'theme-my-login' ); ?></p>
173
-
174
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][login_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_type_custom" value="custom"<?php checked( 'custom', $this->get_option( array( $role, 'login_type' ) ) ); ?> />
175
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][login_url]" type="text" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_login_url" value="<?php echo $this->get_option( array( $role, 'login_url' ) ); ?>" class="regular-text" />
176
- <p class="description"><?php _e( 'Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login' ); ?></p>
177
- </td>
178
- </tr>
179
- <tr valign="top">
180
- <th scope="row"><?php _e( 'Log out' ); ?></th>
181
- <td>
182
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][logout_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_type_default" value="default"<?php checked( 'default', $this->get_option( array( $role, 'logout_type' ) ) ); ?> /> <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_type_default"><?php _e( 'Default', 'theme-my-login' ); ?></label><br />
183
- <p class="description"><?php _e( 'Check this option to send the user to the log in page, displaying a message that they have successfully logged out.', 'theme-my-login' ); ?></p>
184
-
185
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][logout_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_type_referer" value="referer"<?php checked( 'referer', $this->get_option( array( $role, 'logout_type' ) ) ); ?> /> <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_type_referer"><?php _e( 'Referer', 'theme-my-login' ); ?></label><br />
186
- <p class="description"><?php _e( 'Check this option to send the user back to the page they were visiting before logging out. (Note: If the previous page being visited was an admin page, this can have unexpected results.)', 'theme-my-login' ); ?></p>
187
-
188
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][logout_type]" type="radio" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_type_custom" value="custom"<?php checked( 'custom', $this->get_option( array( $role, 'logout_type' ) ) ); ?> />
189
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][logout_url]" type="text" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_logout_url" value="<?php echo $this->get_option( array( $role, 'logout_url' ) ); ?>" class="regular-text" />
190
- <p class="description"><?php _e( 'Check this option to send the user to a custom location, specified by the textbox above.', 'theme-my-login' ); ?></p>
191
- </td>
192
- </tr>
193
- </table>
194
- <?php
195
- }
196
- }
197
-
198
- Theme_My_Login_Custom_Redirection_Admin::get_object();
199
-
200
- endif;
201
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/custom-redirection/admin/js/custom-redirection-admin.js DELETED
@@ -1,3 +0,0 @@
1
- jQuery(document).ready( function($) {
2
- postboxes.add_postbox_toggles(pagenow);
3
- } );
 
 
 
modules/custom-redirection/custom-redirection.php DELETED
@@ -1,236 +0,0 @@
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 DELETED
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,412 +0,0 @@
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 DELETED
@@ -1,42 +0,0 @@
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 DELETED
@@ -1,130 +0,0 @@
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/admin/recaptcha-admin.php DELETED
@@ -1,210 +0,0 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Recaptcha Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Recaptcha
7
- * @since 6.3
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Recaptcha_Admin' ) ) :
11
- /**
12
- * Theme My Login Recaptcha Admin class
13
- *
14
- * @since 6.3
15
- */
16
- class Theme_My_Login_Recaptcha_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_recaptcha';
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
- */
43
- public static function default_options() {
44
- return Theme_My_Login_Recaptcha::default_options();
45
- }
46
-
47
- /**
48
- * Loads the module
49
- *
50
- * Called by Theme_My_Login_Abstract::__construct()
51
- *
52
- * @see Theme_My_Login_Abstract::__construct()
53
- * @since 6.0
54
- * @access protected
55
- */
56
- protected function load() {
57
- add_action( 'tml_uninstall_recaptcha/recaptcha.php', array( $this, 'uninstall' ) );
58
-
59
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
60
- add_action( 'admin_init', array( $this, 'admin_init' ) );
61
- }
62
-
63
- /**
64
- * Uninstalls the module
65
- *
66
- * Callback for "tml_uninstall_recaptcha/recaptcha.php" hook in method Theme_My_Login_Admin::uninstall()
67
- *
68
- * @see Theme_My_Login_Admin::uninstall()
69
- * @since 6.3
70
- * @access public
71
- */
72
- public function uninstall() {
73
- delete_option( $this->options_key );
74
- }
75
-
76
- /**
77
- * Adds "Permalinks" to the Theme My Login menu
78
- *
79
- * Callback for "admin_menu" hook
80
- *
81
- * @since 6.3
82
- * @access public
83
- */
84
- public function admin_menu() {
85
- global $theme_my_login;
86
-
87
- add_submenu_page(
88
- 'theme_my_login',
89
- __( 'Theme My Login reCAPTCHA Settings', 'theme-my-login' ),
90
- __( 'reCAPTCHA', '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( 'public_key', __( 'Site Key', 'theme-my-login' ), array( $this, 'settings_field_public_key' ), $this->options_key, 'general' );
99
- add_settings_field( 'private_key', __( 'Secret Key', 'theme-my-login' ), array( $this, 'settings_field_private_key' ), $this->options_key, 'general' );
100
- add_settings_field( 'theme', __( 'Theme', 'theme-my-login' ), array( $this, 'settings_field_theme' ), $this->options_key, 'general' );
101
- }
102
-
103
- /**
104
- * Registers options group
105
- *
106
- * Callback for "admin_init" hook
107
- *
108
- * @since 6.3
109
- * @access public
110
- */
111
- public function admin_init() {
112
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
113
- }
114
-
115
- /**
116
- * Returns available reCAPTCHA themes
117
- *
118
- * @since 6.3
119
- * @access public
120
- */
121
- public function get_themes() {
122
- $recaptcha_themes = array(
123
- 'light' => _x( 'Light', 'recaptcha theme', 'theme-my-login' ),
124
- 'dark' => _x( 'Dark', 'recaptcha theme', 'theme-my-login' )
125
- );
126
- return apply_filters( 'theme_my_login_recaptcha_themes', $recaptcha_themes );
127
- }
128
-
129
- /**
130
- * Renders the settings page
131
- *
132
- * Callback for add_submenu_page()
133
- *
134
- * @since 6.3
135
- * @access public
136
- */
137
- public function settings_page() {
138
- Theme_My_Login_Admin::settings_page( array(
139
- 'title' => __( 'Theme My Login reCAPTCHA Settings', 'theme-my-login' ),
140
- 'options_key' => $this->options_key
141
- ) );
142
- }
143
-
144
- /**
145
- * Renders the Public Key field.
146
- *
147
- * @since 6.3
148
- * @access public
149
- */
150
- public function settings_field_public_key() {
151
- ?>
152
- <input name="theme_my_login_recaptcha[public_key]" type="text" id="theme_my_login_recaptcha_public_key" value="<?php echo esc_attr( $this->get_option( 'public_key' ) ); ?>" class="regular-text" />
153
- <?php
154
- }
155
-
156
- /**
157
- * Renders the Private Key field.
158
- *
159
- * @since 6.3
160
- * @access public
161
- */
162
- public function settings_field_private_key() {
163
- ?>
164
- <input name="theme_my_login_recaptcha[private_key]" type="text" id="theme_my_login_recaptcha_private_key" value="<?php echo esc_attr( $this->get_option( 'private_key' ) ); ?>" class="regular-text" />
165
- <?php
166
- }
167
-
168
- /**
169
- * Renders the Theme field.
170
- *
171
- * @since 6.3
172
- * @access public
173
- */
174
- public function settings_field_theme() {
175
- ?>
176
- <select name="theme_my_login_recaptcha[theme]" id="theme_my_login_recaptcha_theme">
177
- <?php foreach ( $this->get_themes() as $theme => $theme_name ) : ?>
178
- <option value="<?php echo $theme; ?>"<?php selected( $this->get_option( 'theme' ), $theme ); ?>><?php echo $theme_name; ?></option>
179
- <?php endforeach; ?>
180
- </select>
181
- <?php
182
- }
183
-
184
- /**
185
- * Sanitizes module settings
186
- *
187
- * Callback for register_setting()
188
- *
189
- * @since 6.3
190
- * @access public
191
- *
192
- * @param string|array $input Settings passed in from filter
193
- * @return string|array Sanitized settings
194
- */
195
- public function save_settings( $input ) {
196
- $output = $defaults = self::default_options();
197
-
198
- $output['public_key'] = strip_tags( $input['public_key'] );
199
- $output['private_key'] = strip_tags( $input['private_key'] );
200
- if ( in_array( $input['theme'], array_keys( $this->get_themes() ) ) )
201
- $output['theme'] = $input['theme'];
202
-
203
- return $output;
204
- }
205
- }
206
-
207
- Theme_My_Login_Recaptcha_Admin::get_object();
208
-
209
- endif;
210
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/recaptcha/recaptcha.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: reCAPTCHA
4
- * Description: Enabling this module will initialize reCAPTCHA. You will then have to configure the settings via the "reCAPTCHA" tab.
5
- *
6
- * Holds Theme My Login Recaptcha class
7
- *
8
- * @package Theme_My_Login
9
- * @subpackage Theme_My_Login_Recaptcha
10
- * @since 6.3
11
- */
12
-
13
- if ( ! class_exists( 'Theme_My_Login_Recaptcha' ) ) :
14
- /**
15
- * Theme My Login Custom Permalinks class
16
- *
17
- * Adds the ability to set permalinks for default actions.
18
- *
19
- * @since 6.3
20
- */
21
- class Theme_My_Login_Recaptcha 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_recaptcha';
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
- 'public_key' => '',
53
- 'private_key' => '',
54
- 'theme' => 'light'
55
- );
56
- }
57
-
58
- /**
59
- * Loads the module
60
- *
61
- * @since 6.3
62
- * @access protected
63
- */
64
- protected function load() {
65
- if ( ! ( $this->get_option( 'public_key' ) || $this->get_option( 'private_key' ) ) )
66
- return;
67
-
68
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
69
-
70
- add_action( 'register_form', array( $this, 'recaptcha_display' ) );
71
- add_filter( 'registration_errors', array( $this, 'registration_errors' ) );
72
-
73
- if ( is_multisite() ) {
74
- add_action( 'signup_extra_fields', array( $this, 'recaptcha_display' ) );
75
- add_filter( 'wpmu_validate_user_signup', array( $this, 'wpmu_validate_signup' ) );
76
- add_filter( 'wpmu_validate_blog_signup', array( $this, 'wpmu_validate_signup' ) );
77
- }
78
- }
79
-
80
- /**
81
- * Enqueues scripts
82
- *
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
- /**
92
- * Retrieves reCAPTCHA errors
93
- *
94
- * @since 6.3
95
- *
96
- * @param WP_Error $errors WP_Error object
97
- * @return WP_Error WP_Error object
98
- */
99
- public function registration_errors( $errors ) {
100
- $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
101
- $result = $this->recaptcha_validate( $response );
102
-
103
- if ( is_wp_error( $result ) ) {
104
-
105
- $error_code = $result->get_error_message();
106
-
107
- switch ( $error_code ) {
108
- case 'missing-input-secret' :
109
- case 'invalid-input-secret' :
110
- $errors->add( 'recaptcha', __( '<strong>ERROR</strong>: Invalid reCAPTCHA secret key.', 'theme-my-login' ), $error_code );
111
- break;
112
- case 'missing-input-response' :
113
- case 'invalid-input-response' :
114
- $errors->add( 'recaptcha', __( '<strong>ERROR</strong>: Please check the box to prove that you are not a robot.', 'theme-my-login' ), $error_code );
115
- break;
116
- case 'recaptcha-not-reachable' :
117
- default :
118
- $errors->add( 'recaptcha', __( '<strong>ERROR</strong>: Unable to reach the reCAPTCHA server.', 'theme-my-login' ), $error_code );
119
- break;
120
- }
121
- }
122
- return $errors;
123
- }
124
-
125
- /**
126
- * Retrieves reCAPTCHA errors for multisite
127
- *
128
- * @since 6.3.7
129
- *
130
- * @param array $result Signup parameters
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
- }
142
-
143
- /**
144
- * Displays reCAPTCHA
145
- *
146
- * @since 6.3
147
- * @access public
148
- */
149
- public function recaptcha_display( $errors = null ) {
150
- if ( is_multisite() ) {
151
- if ( $error = $errors->get_error_message( 'recaptcha' ) )
152
- echo '<p class="error">' . $error . '</p>';
153
- }
154
- echo '<div class="g-recaptcha" data-sitekey="' . esc_attr( $this->get_option( 'public_key' ) ) . '" data-theme="' . esc_attr( $this->get_option( 'theme' ) ) . '"></div>';
155
- }
156
-
157
- /**
158
- * Validates reCAPTCHA
159
- *
160
- * @since 6.3
161
- * @access public
162
- */
163
- public function recaptcha_validate( $response, $remote_ip = '' ) {
164
-
165
- if ( empty( $remote_ip ) )
166
- $remote_ip = $_SERVER['REMOTE_ADDR'];
167
-
168
- $response = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
169
- 'body' => array(
170
- 'secret' => $this->get_option( 'private_key' ),
171
- 'response' => $response,
172
- 'remoteip' => $remote_ip
173
- )
174
- ) );
175
-
176
- $response_code = wp_remote_retrieve_response_code( $response );
177
- $response_message = wp_remote_retrieve_response_message( $response );
178
- $response_body = wp_remote_retrieve_body( $response );
179
-
180
- if ( 200 == $response_code ) {
181
-
182
- $result = json_decode( $response_body, true );
183
-
184
- if ( $result['success'] )
185
- return true;
186
-
187
- return new WP_Error( 'recaptcha', reset( $result['error-codes'] ) );
188
- }
189
-
190
- return new WP_Error( 'recaptcha', 'recaptcha-not-reachable' );
191
- }
192
- }
193
-
194
- Theme_My_Login_Recaptcha::get_object();
195
-
196
- endif;
197
-
198
- if ( is_admin() )
199
- include_once( dirname( __FILE__ ) . '/admin/recaptcha-admin.php' );
200
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/security/admin/js/security-admin.js DELETED
@@ -1,3 +0,0 @@
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 DELETED
@@ -1,313 +0,0 @@
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 DELETED
@@ -1,623 +0,0 @@
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 ( $private_site = apply_filters( 'tml_enforce_private_site', $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
- $field = is_email( $username ) ? 'email' : 'login';
216
- if ( ! $userdata = get_user_by( $field, $username ) )
217
- return $user;
218
-
219
- // Current time
220
- $time = time();
221
-
222
- if ( self::is_user_locked( $userdata->ID ) ) {
223
- if ( $expiration = self::get_user_lock_expiration( $userdata->ID ) ) {
224
- if ( $time > $expiration )
225
- self::unlock_user( $userdata->ID );
226
- else
227
- 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 ) ) );
228
- } else {
229
- return new WP_Error( 'locked_account', __( '<strong>ERROR</strong>: This account has been locked.', 'theme-my-login' ) );
230
- }
231
- } elseif ( is_wp_error( $user ) && 'incorrect_password' == $user->get_error_code() ) {
232
- // Get the attempts
233
- $attempts = self::get_failed_login_attempts( $userdata->ID );
234
-
235
- // Get the first valid attempt
236
- $first_attempt = reset( $attempts );
237
-
238
- // Get the relative duration
239
- $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' ) ) );
240
-
241
- // If current time is less than relative duration time, we're still within the defensive zone
242
- if ( $time < $duration ) {
243
- // Log this attempt
244
- self::add_failed_login_attempt( $userdata->ID, $time );
245
- // If failed attempts reach treshold, lock the account
246
- if ( self::get_failed_login_attempt_count( $userdata->ID ) >= $this->get_option( array( 'failed_login', 'threshold' ) ) ) {
247
- // Create new expiration
248
- $expiration = $time + self::get_seconds_from_unit( $this->get_option( array( 'failed_login', 'lockout_duration' ) ), $this->get_option( array( 'failed_login', 'lockout_duration_unit' ) ) );
249
- self::lock_user( $userdata->ID, $expiration );
250
- 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 ) ) );
251
- }
252
- } else {
253
- // Clear the attempts
254
- self::reset_failed_login_attempts( $userdata->ID );
255
- // Log this attempt
256
- self::add_failed_login_attempt( $userdata->ID, $time );
257
- }
258
- }
259
- return $user;
260
- }
261
-
262
- /**
263
- * Blocks locked users from resetting their password, if locked by admin
264
- *
265
- * Callback for "allow_password_reset" in method Theme_My_Login::retrieve_password()
266
- *
267
- * @see Theme_My_Login::retrieve_password()
268
- * @since 6.0
269
- * @access public
270
- *
271
- * @param bool $allow Default setting
272
- * @param int $user_id User ID
273
- * @return bool Whether to allow password reset or not
274
- */
275
- public function allow_password_reset( $allow, $user_id ) {
276
- if ( self::is_user_locked( $user_id ) && ! self::get_user_lock_expiration( $user_id ) )
277
- $allow = false;
278
- return $allow;
279
- }
280
-
281
- /**
282
- * Displays failed login attempts on users profile for administrators
283
- *
284
- * @since 6.2
285
- * @access public
286
- *
287
- * @param object $profileuser User object
288
- */
289
- public function show_user_profile( $profileuser ) {
290
- if ( ! current_user_can( 'manage_users' ) )
291
- return;
292
-
293
- if ( $failed_login_attempts = self::get_failed_login_attempts( $profileuser->ID ) ) : ?>
294
- <h3><?php _e( 'Failed Login Attempts', 'theme-my-login' ); ?></h3>
295
-
296
- <table class="form-table">
297
- <tr>
298
- <th scope="col"><?php _e( 'IP Address', 'theme-my-login' ); ?></th>
299
- <th scope="col"><?php _e( 'Date', 'theme-my-login' ); ?></th>
300
- </tr>
301
- <?php foreach ( $failed_login_attempts as $attempt ) :
302
- $t_time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
303
-
304
- $time_diff = time() - $attempt['time'];
305
-
306
- if ( $time_diff > 0 && $time_diff < 24*60*60 )
307
- $h_time = sprintf( __( '%s ago', 'theme-my-login' ), human_time_diff( $attempt['time'] ) );
308
- else
309
- $h_time = date_i18n( __( 'Y/m/d', 'theme-my-login' ), $attempt['time'] );
310
- ?>
311
- <tr>
312
- <td><?php echo $attempt['ip']; ?></td>
313
- <td><abbr title="<?php echo $t_time; ?>"><?php echo $h_time; ?></abbr></td>
314
- </tr>
315
- <?php endforeach; ?>
316
- </table>
317
- <?php endif;
318
- }
319
-
320
- /**
321
- * Shows admin bar for wp-login.php when it is disabled
322
- *
323
- * @since 6.3
324
- * @access public
325
- *
326
- * @param bool $show True to show admin bar, false to hide
327
- * @return bool True to show admin bar, false to hide
328
- */
329
- public function show_admin_bar( $show ) {
330
- global $pagenow;
331
-
332
- if ( is_user_logged_in() && 'wp-login.php' == $pagenow && $this->get_option( 'private_login' ) )
333
- return true;
334
- return $show;
335
- }
336
-
337
- /**
338
- * Locks a user
339
- *
340
- * @since 6.0
341
- * @access public
342
- *
343
- * @param int|WP_User $user User ID ir WP_User object
344
- * @param int $expires When the lock expires, in seconds from current time
345
- */
346
- public static function lock_user( $user, $expires = 0 ) {
347
- if ( is_object( $user ) )
348
- $user = $user->ID;
349
-
350
- $user = (int) $user;
351
-
352
- do_action( 'tml_lock_user', $user );
353
-
354
- $security = self::get_security_meta( $user );
355
-
356
- $security['is_locked'] = true;
357
- $security['lock_expiration'] = absint( $expires );
358
- $security['unlock_key'] = wp_generate_password( 20, false );
359
-
360
- update_user_meta( $user, 'theme_my_login_security', $security );
361
-
362
- if ( $expires )
363
- self::user_lock_notification( $user );
364
- }
365
-
366
- /**
367
- * Unlocks a user
368
- *
369
- * @since 6.0
370
- * @access public
371
- *
372
- * @param int|WP_User $user User ID or WP_User object
373
- */
374
- public static function unlock_user( $user ) {
375
- if ( is_object( $user ) )
376
- $user = $user->ID;
377
-
378
- $user = (int) $user;
379
-
380
- do_action( 'tml_unlock_user', $user );
381
-
382
- $security = self::get_security_meta( $user );
383
-
384
- $security['is_locked'] = false;
385
- $security['lock_expiration'] = 0;
386
- $security['unlock_key'] = '';
387
- $security['failed_login_attempts'] = array();
388
-
389
- return update_user_meta( $user, 'theme_my_login_security', $security );
390
- }
391
-
392
- /**
393
- * Determine if a user is locked or not
394
- *
395
- * @since 6.0
396
- * @access public
397
- *
398
- * @param int|WP_User $user User ID or WP_User object
399
- * @return bool True if user is locked, false if not
400
- */
401
- public static function is_user_locked( $user ) {
402
- if ( is_object( $user ) )
403
- $user = $user->ID;
404
-
405
- $user = (int) $user;
406
-
407
- $security = self::get_security_meta( $user );
408
-
409
- // If "is_locked" is not set, there is no lock
410
- if ( ! $security['is_locked'] )
411
- return false;
412
-
413
- // If "lock_expires" is not set, there is a lock but no expiry
414
- if ( ! $expires = self::get_user_lock_expiration( $user ) )
415
- return true;
416
-
417
- // We have a lock with an expiry
418
- $time = time();
419
- if ( $time > $expires ) {
420
- self::unlock_user( $user );
421
- return false;
422
- }
423
-
424
- return true;
425
- }
426
-
427
- /**
428
- * Get a user's security meta
429
- *
430
- * @since 6.0
431
- * @access protected
432
- *
433
- * @param int $user_id User ID
434
- * @return array User's security meta
435
- */
436
- protected static function get_security_meta( $user_id ) {
437
- $defaults = array(
438
- 'is_locked' => false,
439
- 'lock_expiration' => 0,
440
- 'unlock_key' => '',
441
- 'failed_login_attempts' => array()
442
- );
443
- $meta = get_user_meta( $user_id, 'theme_my_login_security', true );
444
- if ( ! is_array( $meta ) )
445
- $meta = array();
446
-
447
- return array_merge( $defaults, $meta );
448
- }
449
-
450
- /**
451
- * Get a user's failed login attempts
452
- *
453
- * @since 6.0
454
- * @access public
455
- *
456
- * @param int $user_id User ID
457
- * @return array User's failed login attempts
458
- */
459
- public static function get_failed_login_attempts( $user_id ) {
460
- $security_meta = self::get_security_meta( $user_id );
461
- return $security_meta['failed_login_attempts'];
462
- }
463
-
464
- /**
465
- * Reset a user's failed login attempts
466
- *
467
- * @since 6.0
468
- * @access public
469
- *
470
- * @param int $user_id User ID
471
- */
472
- public static function reset_failed_login_attempts( $user_id ) {
473
- $security_meta = self::get_security_meta( $user_id );
474
- $security_meta['failed_login_attempts'] = array();
475
- return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
476
- }
477
-
478
- /**
479
- * Get a user's failed login attempt count
480
- *
481
- * @since 6.0
482
- * @access public
483
- *
484
- * @param int $user_id User ID
485
- * @return int Number of user's failed login attempts
486
- */
487
- public static function get_failed_login_attempt_count( $user_id ) {
488
- return count( self::get_failed_login_attempts( $user_id ) );
489
- }
490
-
491
- /**
492
- * Add a failed login attempt to a user
493
- *
494
- * @since 6.0
495
- * @access public
496
- *
497
- * @param int $user_id User ID
498
- * @param int $time Time of attempt, in seconds
499
- * @param string $ip IP address of attempt
500
- */
501
- public static function add_failed_login_attempt( $user_id, $time = '', $ip = '' ) {
502
- $security_meta = self::get_security_meta( $user_id );
503
- if ( ! is_array( $security_meta['failed_login_attempts'] ) )
504
- $security_meta['failed_login_attempts'] = array();
505
-
506
- $time = absint( $time );
507
-
508
- if ( empty( $time ) )
509
- $time = time();
510
-
511
- if ( empty( $ip ) )
512
- $ip = $_SERVER['REMOTE_ADDR'];
513
-
514
- $security_meta['failed_login_attempts'][] = array( 'time' => $time, 'ip' => $ip );
515
-
516
- return update_user_meta( $user_id, 'theme_my_login_security', $security_meta );
517
- }
518
-
519
- /**
520
- * Get user's lock expiration time
521
- *
522
- * @since 6.0
523
- * @access public
524
- *
525
- * @param int $user_id User ID
526
- * @return int User's lock expiration time
527
- */
528
- public static function get_user_lock_expiration( $user_id ) {
529
- $security_meta = self::get_security_meta( $user_id );
530
- return apply_filters( 'tml_user_lock_expiration', absint( $security_meta['lock_expiration'] ), $user_id );
531
- }
532
-
533
- /**
534
- * Get a user's unlock key
535
- *
536
- * @since 6.3
537
- *
538
- * @param int $user_id User ID
539
- * @return string User's unlock key
540
- */
541
- public static function get_user_unlock_key( $user_id ) {
542
- $security_meta = self::get_security_meta( $user_id );
543
- return apply_filters( 'tml_user_unlock_key', $security_meta['unlock_key'], $user_id );
544
- }
545
-
546
- /**
547
- * Get number of secongs from days, hours and minutes
548
- *
549
- * @since 6.0
550
- * @access public
551
- *
552
- * @param int $value Number of $unit
553
- * @param string $unit Can be either "day", "hour" or "minute"
554
- * @return int Number of seconds
555
- */
556
- public static function get_seconds_from_unit( $value, $unit = 'minute' ) {
557
- switch ( $unit ) {
558
- case 'day' :
559
- $value = $value * 24 * 60 * 60;
560
- break;
561
- case 'hour' :
562
- $value = $value * 60 * 60;
563
- break;
564
- case 'minute' :
565
- $value = $value * 60;
566
- break;
567
- }
568
- return $value;
569
- }
570
-
571
- /**
572
- * Sends a user a notification that their account has been locked
573
- *
574
- * @since 6.3
575
- *
576
- * @param int $user_id User ID
577
- */
578
- public static function user_lock_notification( $user_id ) {
579
- global $wpdb, $current_site;
580
-
581
- if ( apply_filters( 'send_user_lock_notification', true ) ) {
582
- $user = new WP_User( $user_id );
583
-
584
- $user_login = stripslashes( $user->user_login );
585
- $user_email = stripslashes( $user->user_email );
586
-
587
- if ( is_multisite() ) {
588
- $blogname = $current_site->site_name;
589
- } else {
590
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
591
- // we want to reverse this for the plain text arena of emails.
592
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
593
- }
594
-
595
- $unlock_url = add_query_arg( array( 'action' => 'unlock', 'key' => self::get_user_unlock_key( $user->ID ), 'login' => rawurlencode( $user_login ) ), wp_login_url() );
596
-
597
- $title = sprintf( __( '[%s] Account Locked', 'theme-my-login' ), $blogname );
598
- $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";
599
- $message .= $unlock_url . "\r\n";
600
-
601
- if ( $user->has_cap( 'administrator' ) ) {
602
- $message .= "\r\n";
603
- $message .= __( 'The following attempts resulted in the lock:', 'theme-my-login' ) . "\r\n\r\n";
604
- foreach ( self::get_failed_login_attempts( $user->ID ) as $attempt ) {
605
- $time = date_i18n( __( 'Y/m/d g:i:s A', 'theme-my-login' ), $attempt['time'] );
606
- $message .= $attempt['ip'] . "\t" . $time . "\r\n";
607
- }
608
- }
609
-
610
- $title = apply_filters( 'user_lock_notification_title', $title, $user_id );
611
- $message = apply_filters( 'user_lock_notification_message', $message, $unlock_url, $user_id );
612
-
613
- wp_mail( $user_email, $title, $message );
614
- }
615
- }
616
- }
617
-
618
- Theme_My_Login_Security::get_object();
619
-
620
- endif;
621
-
622
- if ( is_admin() )
623
- include_once( dirname( __FILE__ ) . '/admin/security-admin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/themed-profiles/admin/themed-profiles-admin.php DELETED
@@ -1,215 +0,0 @@
1
- <?php
2
- /**
3
- * Holds Theme My Login Themed Profiles Admin class
4
- *
5
- * @package Theme_My_Login
6
- * @subpackage Theme_My_Login_Themed_Profiles
7
- * @since 6.2
8
- */
9
-
10
- if ( ! class_exists( 'Theme_My_Login_Themed_Profiles_Admin' ) ) :
11
- /**
12
- * Theme My Login Themed Profiles Admin class
13
- *
14
- * @since 6.2
15
- */
16
- class Theme_My_Login_Themed_Profiles_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_themed_profiles';
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.2
41
- * @access protected
42
- */
43
- protected function load() {
44
- add_action( 'tml_activate_themed-profiles/themed-profiles.php', array( $this, 'activate' ) );
45
- add_action( 'tml_uninstall_themed-profiles/themed-profiles.php', array( $this, 'uninstall' ) );
46
-
47
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
48
- add_action( 'admin_init', array( $this, 'admin_init' ) );
49
- }
50
-
51
- /**
52
- * Returns default options
53
- *
54
- * @since 6.3
55
- * @access public
56
- */
57
- public static function default_options() {
58
- return Theme_My_Login_Themed_Profiles::default_options();
59
- }
60
-
61
- /**
62
- * Activates the module
63
- *
64
- * Callback for "tml_activate_themed-profiles/themed-profiles.php" hook in method Theme_My_Login_Modules_Admin::activate_module()
65
- *
66
- * @see Theme_My_Login_Modules_Admin::activate_module()
67
- * @since 6.0
68
- * @access public
69
- */
70
- public function activate() {
71
- if ( ! $page_id = Theme_My_Login::get_page_id( 'profile' ) ) {
72
- $page_id = wp_insert_post( array(
73
- 'post_title' => __( 'Your Profile', 'theme-my-login' ),
74
- 'post_status' => 'publish',
75
- 'post_type' => 'page',
76
- 'post_content' => '[theme-my-login]',
77
- 'comment_status' => 'closed',
78
- 'ping_status' => 'closed'
79
- ) );
80
- update_post_meta( $page_id, '_tml_action', 'profile' );
81
- }
82
- }
83
-
84
- /**
85
- * Uninstalls the module
86
- *
87
- * Callback for "tml_uninstall_themed-profiles/themed-profiles.php" hook in method Theme_My_Login_Admin::uninstall()
88
- *
89
- * @see Theme_My_Login_Admin::uninstall()
90
- * @since 6.3
91
- * @access public
92
- */
93
- public function uninstall() {
94
- delete_option( $this->options_key );
95
- }
96
-
97
- /**
98
- * Adds "Themed Profiles" tab to Theme My Login menu
99
- *
100
- * Callback for "admin_menu" hook
101
- *
102
- * @since 6.3
103
- * @access public
104
- */
105
- public function admin_menu() {
106
- add_submenu_page(
107
- 'theme_my_login',
108
- __( 'Theme My Login Themed Profiles Settings', 'theme-my-login' ),
109
- __( 'Themed Profiles', 'theme-my-login' ),
110
- 'manage_options',
111
- $this->options_key,
112
- array( $this, 'settings_page' )
113
- );
114
-
115
- add_settings_section( 'general', null, '__return_false', $this->options_key );
116
-
117
- add_settings_field( 'themed_profiles', __( 'Themed Profiles', 'theme-my-login' ), array( $this, 'settings_field_themed_profiles' ), $this->options_key, 'general' );
118
- add_settings_field( 'restrict_admin', __( 'Restrict Admin Access', 'theme-my-login' ), array( $this, 'settings_field_restrict_admin_access' ), $this->options_key, 'general' );
119
- }
120
-
121
- /**
122
- * Registers options group
123
- *
124
- * Callback for "admin_init" hook
125
- *
126
- * @since 6.3
127
- * @access public
128
- */
129
- public function admin_init() {
130
- register_setting( $this->options_key, $this->options_key, array( $this, 'save_settings' ) );
131
- }
132
-
133
- /**
134
- * Renders settings page
135
- *
136
- * Callback for add_submenu_page()
137
- *
138
- * @since 6.3
139
- * @access public
140
- */
141
- public function settings_page() {
142
- Theme_My_Login_Admin::settings_page( array(
143
- 'title' => __( 'Theme My Login Themed Profiles Settings', 'theme-my-login' ),
144
- 'options_key' => $this->options_key
145
- ) );
146
- }
147
-
148
- /**
149
- * Renders Themed Profiles settings field
150
- *
151
- * @since 6.3
152
- * @access public
153
- */
154
- public function settings_field_themed_profiles() {
155
- global $wp_roles;
156
-
157
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
158
- if ( 'pending' == $role )
159
- continue;
160
- ?>
161
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][theme_profile]" type="checkbox" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_theme_profile" value="1"<?php checked( $this->get_option( array( $role, 'theme_profile' ) ) ); ?> />
162
- <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_theme_profile"><?php echo $role_name; ?></label><br />
163
- <?php
164
- }
165
- }
166
-
167
- /**
168
- * Renders Restrict Admin Access settings field
169
- *
170
- * @since 6.3
171
- * @access public
172
- */
173
- public function settings_field_restrict_admin_access() {
174
- global $wp_roles;
175
-
176
- foreach ( $wp_roles->get_names() as $role => $role_name ) {
177
- if ( 'pending' == $role )
178
- continue;
179
- ?>
180
- <input name="<?php echo $this->options_key; ?>[<?php echo $role; ?>][restrict_admin]" type="checkbox" id="<?php echo $this->options_key; ?>_<?php echo $role; ?>_restrict_admin" value="1"<?php checked( $this->get_option( array( $role, 'restrict_admin' ) ) ); ?><?php if ( 'administrator' == $role ) echo ' disabled="disabled"'; ?> />
181
- <label for="<?php echo $this->options_key; ?>_<?php echo $role; ?>_restrict_admin"><?php echo $role_name; ?></label><br />
182
- <?php
183
- }
184
- }
185
-
186
- /**
187
- * Sanitizes settings
188
- *
189
- * Callback for register_setting()
190
- *
191
- * @since 6.2
192
- * @access public
193
- *
194
- * @param array $settings Settings passed in from filter
195
- * @return array Sanitized settings
196
- */
197
- public function save_settings( $settings ) {
198
- global $wp_roles;
199
-
200
- foreach( $wp_roles->get_names() as $role => $role_name ) {
201
- if ( 'pending' != $role ) {
202
- $settings[$role] = array(
203
- 'theme_profile' => ! empty( $settings[$role]['theme_profile'] ),
204
- 'restrict_admin' => ! empty( $settings[$role]['restrict_admin'] )
205
- );
206
- }
207
- }
208
- return $settings;
209
- }
210
- }
211
-
212
- Theme_My_Login_Themed_Profiles_Admin::get_object();
213
-
214
- endif;
215
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/themed-profiles/themed-profiles.css DELETED
@@ -1,51 +0,0 @@
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.js DELETED
@@ -1,5 +0,0 @@
1
- (function($){
2
- $(document).ready(function(){
3
- $('body').addClass('js').removeClass('no-js');
4
- });
5
- })(jQuery);
 
 
 
 
 
modules/themed-profiles/themed-profiles.php DELETED
@@ -1,409 +0,0 @@
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_filter( 'tml_default_pages', array( $this, 'tml_default_pages' ) );
76
- add_action( 'tml_modules_loaded', array( $this, 'modules_loaded' ) );
77
-
78
- add_action( 'init', array( $this, 'init' ) );
79
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
80
- add_filter( 'show_admin_bar', array( $this, 'show_admin_bar' ) );
81
- add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
82
- add_filter( 'body_class', array( $this, 'body_class' ) );
83
-
84
- add_action( 'tml_request_profile', array( $this, 'tml_request_profile' ) );
85
- add_action( 'tml_display_profile', array( $this, 'tml_display_profile' ) );
86
-
87
- add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ), 12 );
88
- }
89
-
90
- /**
91
- * Add the profile page to the default pages.
92
- *
93
- * @since 6.4.13
94
- *
95
- * @param array $page The default pages.
96
- * @return array The default pages with the profile page added.
97
- */
98
- public function tml_default_pages( $pages ) {
99
- $pages['profile'] = __( 'Profile', 'theme-my-login' );
100
- return $pages;
101
- }
102
-
103
- /**
104
- * Adds filters to site_url() and admin_url()
105
- *
106
- * Callback for "tml_modules_loaded" in file "theme-my-login.php"
107
- *
108
- * @since 6.0
109
- * @access public
110
- */
111
- public function modules_loaded() {
112
- add_filter( 'site_url', array( $this, 'site_url' ), 10, 3 );
113
- add_filter( 'admin_url', array( $this, 'site_url' ), 10, 2 );
114
- }
115
-
116
- /**
117
- * Redirects "profile.php" to themed profile page
118
- *
119
- * Callback for "init" hook
120
- *
121
- * @since 6.0
122
- * @access public
123
- */
124
- public function init() {
125
- global $current_user, $pagenow;
126
-
127
- if ( is_user_logged_in() && is_admin() ) {
128
- $redirect_to = Theme_My_Login::get_page_link( 'profile' );
129
-
130
- $user_role = reset( $current_user->roles );
131
- if ( is_multisite() && empty( $user_role ) )
132
- $user_role = 'subscriber';
133
-
134
- if ( 'profile.php' == $pagenow && ! isset( $_REQUEST['page'] ) ) {
135
- if ( $this->get_option( array( $user_role, 'theme_profile' ) ) ) {
136
- if ( ! empty( $_GET ) )
137
- $redirect_to = add_query_arg( (array) $_GET, $redirect_to );
138
- wp_redirect( $redirect_to );
139
- exit;
140
- }
141
- } else {
142
- if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) ) {
143
- if ( ! defined( 'DOING_AJAX' ) ) {
144
- wp_redirect( $redirect_to );
145
- exit;
146
- }
147
- }
148
- }
149
- }
150
- }
151
-
152
- /**
153
- * Redirects login page to profile if user is logged in
154
- *
155
- * Callback for "template_redirect" hook
156
- *
157
- * @since 6.0
158
- * @access public
159
- */
160
- public function template_redirect() {
161
- $theme_my_login = Theme_My_Login::get_object();
162
-
163
- if ( Theme_My_Login::is_tml_page() ) {
164
- switch ( $theme_my_login->request_action ) {
165
- case 'profile' :
166
- // Redirect to login page if not logged in
167
- if ( ! is_user_logged_in() ) {
168
- $redirect_to = Theme_My_Login::get_page_link( 'login', 'reauth=1' );
169
- wp_redirect( $redirect_to );
170
- exit;
171
- }
172
- break;
173
- case 'logout' :
174
- // Allow logout action
175
- break;
176
- case 'register' :
177
- // Allow register action if multisite
178
- if ( is_multisite() )
179
- break;
180
- default :
181
- // Redirect to profile for any other action if logged in
182
- if ( is_user_logged_in() ) {
183
- $redirect_to = Theme_My_Login::get_page_link( 'profile' );
184
- wp_redirect( $redirect_to );
185
- exit;
186
- }
187
- }
188
- }
189
- }
190
-
191
- /**
192
- * Hides admin bar is admin is restricted
193
- *
194
- * Callback for "show_admin_bar" hook
195
- *
196
- * @since 6.2
197
- * @access public
198
- */
199
- public function show_admin_bar( $show_admin_bar ) {
200
- global $current_user;
201
-
202
- $user_role = reset( $current_user->roles );
203
- if ( is_multisite() && empty( $user_role ) )
204
- $user_role = 'subscriber';
205
-
206
- if ( $this->get_option( array( $user_role, 'restrict_admin' ) ) )
207
- return false;
208
-
209
- return $show_admin_bar;
210
- }
211
-
212
- /**
213
- * Enqueue scripts
214
- *
215
- * @since 6.4
216
- * @access public
217
- */
218
- public function wp_enqueue_scripts() {
219
- wp_enqueue_script( 'tml-themed-profiles', plugins_url( 'themed-profiles.js', __FILE__ ), array( 'jquery' ) );
220
- }
221
-
222
- /**
223
- * Add a 'no-js' class to the body
224
- *
225
- * @since 6.4
226
- * @access public
227
- *
228
- * @param array $classes Body classes
229
- * @return array Body classes
230
- */
231
- public function body_class( $classes ) {
232
-
233
- if ( ! Theme_My_Login::is_tml_page( 'profile' ) )
234
- return $classes;
235
-
236
- if ( ! in_array( 'no-js', $classes ) )
237
- $classes[] = 'no-js';
238
-
239
- return $classes;
240
- }
241
-
242
- /**
243
- * Handles profile action
244
- *
245
- * Callback for "tml_request_profile" in method Theme_My_Login::the_request()
246
- *
247
- * @see Theme_My_Login::the_request()
248
- * @since 6.0
249
- * @access public
250
- */
251
- public function tml_request_profile() {
252
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
253
- require_once( ABSPATH . 'wp-admin/includes/misc.php' );
254
-
255
- define( 'IS_PROFILE_PAGE', true );
256
-
257
- load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
258
-
259
- register_admin_color_schemes();
260
-
261
- wp_enqueue_style( 'password-strength', plugins_url( 'themed-profiles.css', __FILE__ ) );
262
-
263
- wp_enqueue_script( 'user-profile' );
264
-
265
- $current_user = wp_get_current_user();
266
-
267
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
268
- check_admin_referer( 'update-user_' . $current_user->ID );
269
-
270
- if ( ! current_user_can( 'edit_user', $current_user->ID ) )
271
- wp_die( __( 'You do not have permission to edit this user.', 'theme-my-login' ) );
272
-
273
- do_action( 'personal_options_update', $current_user->ID );
274
-
275
- $errors = edit_user( $current_user->ID );
276
-
277
- if ( ! is_wp_error( $errors ) ) {
278
- $args = array( 'updated' => 'true' );
279
- if ( ! empty( $_REQUEST['instance'] ) )
280
- $args['instance'] = $_REQUEST['instance'];
281
- $redirect = add_query_arg( $args );
282
- wp_redirect( $redirect );
283
- exit;
284
- } else {
285
- Theme_My_Login::get_object()->errors = $errors;
286
- }
287
- }
288
- }
289
-
290
- /**
291
- * Outputs profile form HTML
292
- *
293
- * Callback for "tml_display_profile" hook in method Theme_My_login_Template::display()
294
- *
295
- * @see Theme_My_Login_Template::display()
296
- * @since 6.0
297
- * @access public
298
- *
299
- * @param object $template Reference to $theme_my_login_template object
300
- */
301
- public function tml_display_profile( &$template ) {
302
- global $current_user, $profileuser, $_wp_admin_css_colors, $wp_version;
303
-
304
- require_once( ABSPATH . 'wp-admin/includes/user.php' );
305
- require_once( ABSPATH . 'wp-admin/includes/misc.php' );
306
-
307
- if ( isset( $_GET['updated'] ) && 'true' == $_GET['updated'] )
308
- Theme_My_Login::get_object()->errors->add( 'profile_updated', __( 'Profile updated.', 'theme-my-login' ), 'message' );
309
-
310
- $current_user = wp_get_current_user();
311
- $profileuser = get_user_to_edit( $current_user->ID );
312
-
313
- $user_role = reset( $profileuser->roles );
314
- if ( is_multisite() && empty( $user_role ) )
315
- $user_role = 'subscriber';
316
-
317
- $_template = array();
318
-
319
- // Allow template override via shortcode or template tag args
320
- if ( ! empty( $template->options['profile_template'] ) )
321
- $_template[] = $template->options['profile_template'];
322
-
323
- // Allow role template overrid via shortcode or template tag args
324
- if ( ! empty( $template->options["profile_template_{$user_role}"] ) )
325
- $_template[] = $template->options["profile_template_{$user_role}"];
326
-
327
- // Role template
328
- $_template[] = "profile-form-{$user_role}.php";
329
-
330
- // Default template
331
- $_template[] = 'profile-form.php';
332
-
333
- // Load template
334
- $template->get_template( $_template, true, compact( 'current_user', 'profileuser', 'user_role', '_wp_admin_css_colors', 'wp_version' ) );
335
- }
336
-
337
- /**
338
- * Changes links from "profile.php" to themed profile page
339
- *
340
- * Callback for "site_url" hook
341
- *
342
- * @see site_url()
343
- * @since 6.0
344
- * @access public
345
- *
346
- * @param string $url The generated link
347
- * @param string $path The specified path
348
- * @param string $orig_scheme The original connection scheme
349
- * @return string The filtered link
350
- */
351
- public function site_url( $url, $path, $orig_scheme = '' ) {
352
- global $current_user, $pagenow;
353
-
354
- if ( 'profile.php' != $pagenow && strpos( $url, 'profile.php' ) !== false ) {
355
- $user_role = reset( $current_user->roles );
356
- if ( is_multisite() && empty( $user_role ) )
357
- $user_role = 'subscriber';
358
-
359
- if ( $user_role && ! $this->get_option( array( $user_role, 'theme_profile' ) ) )
360
- return $url;
361
-
362
- $parsed_url = parse_url( $url );
363
-
364
- $url = Theme_My_Login::get_page_link( 'profile' );
365
-
366
- if ( isset( $parsed_url['query'] ) )
367
- $url = add_query_arg( array_map( 'rawurlencode', wp_parse_args( $parsed_url['query'] ) ), $url );
368
- }
369
- return $url;
370
- }
371
-
372
- /**
373
- * Hide Profile link if user is not logged in
374
- *
375
- * Callback for "wp_setup_nav_menu_item" hook in wp_setup_nav_menu_item()
376
- *
377
- * @see wp_setup_nav_menu_item()
378
- * @since 6.4
379
- * @access public
380
- *
381
- * @param object $menu_item The menu item
382
- * @return object The (possibly) modified menu item
383
- */
384
- public function wp_setup_nav_menu_item( $menu_item ) {
385
- if ( is_admin() )
386
- return $menu_item;
387
-
388
- if ( 'page' != $menu_item->object )
389
- return $menu_item;
390
-
391
- // User is not logged in
392
- if ( ! is_user_logged_in() ) {
393
-
394
- // Hide Profile
395
- if ( Theme_My_Login::is_tml_page( 'profile', $menu_item->object_id ) ) {
396
- $menu_item->_invalid = true;
397
- }
398
- }
399
-
400
- return $menu_item;
401
- }
402
- }
403
-
404
- Theme_My_Login_Themed_Profiles::get_object();
405
-
406
- endif;
407
-
408
- if ( is_admin() )
409
- include_once( dirname( __FILE__ ) . '/admin/themed-profiles-admin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/user-moderation/admin/user-moderation-admin.php DELETED
@@ -1,443 +0,0 @@
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 DELETED
@@ -1,480 +0,0 @@
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
- $field = is_email( $login ) ? 'email' : 'login';
310
-
311
- if ( ! $user = get_user_by( $field, $login ) ) {
312
- $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'failed' ) );
313
- wp_redirect( $redirect_to );
314
- exit;
315
- }
316
-
317
- do_action( 'tml_user_activation_resend', $user->ID );
318
-
319
- if ( in_array( 'pending', (array) $user->roles ) ) {
320
- // Send activation e-mail
321
- self::new_user_activation_notification( $user->ID );
322
- // Now redirect them
323
- $redirect_to = Theme_My_Login_Common::get_current_url( array( 'sendactivation' => 'sent' ) );
324
- wp_redirect( $redirect_to );
325
- exit;
326
- }
327
- }
328
-
329
- /**
330
- * Handles activating a new user by user email confirmation
331
- *
332
- * @since 6.0
333
- * @access public
334
- *
335
- * @param string $key Hash to validate sending confirmation email
336
- * @param string $login User's username for logging in
337
- * @return bool|WP_Error True if successful, WP_Error otherwise
338
- */
339
- public static function activate_new_user( $key, $login ) {
340
- global $wpdb;
341
-
342
- $key = preg_replace( '/[^a-z0-9]/i', '', $key );
343
-
344
- if ( empty( $key ) || ! is_string( $key ) )
345
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
346
-
347
- if ( empty( $login ) || ! is_string( $login ) )
348
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
349
-
350
- // Validate activation key
351
- $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login ) );
352
- if ( empty( $user ) )
353
- return new WP_Error( 'invalid_key', __( 'Invalid key', 'theme-my-login' ) );
354
-
355
- do_action( 'tml_user_activation_post', $user->user_login, $user->user_email );
356
-
357
- // Allow plugins to short-circuit process and send errors
358
- $errors = new WP_Error();
359
- $errors = apply_filters( 'tml_user_activation_errors', $errors, $user->user_login, $user->user_email );
360
-
361
- // Return errors if there are any
362
- if ( $errors->get_error_code() )
363
- return $errors;
364
-
365
- // Clear the activation key
366
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'user_login' => $login ) );
367
-
368
- // Set user role
369
- $user_object = new WP_User( $user->ID );
370
- $user_object->set_role( get_option( 'default_role' ) );
371
-
372
- do_action( 'tml_new_user_activated', $user->ID );
373
-
374
- return true;
375
- }
376
-
377
- /**
378
- * Calls the "register_new_user" hook
379
- *
380
- * @since 6.0
381
- * @access public
382
- *
383
- * @param int $user_id The user's ID
384
- */
385
- public function new_user_activated( $user_id ) {
386
- do_action( 'register_new_user', $user_id );
387
- }
388
-
389
- /**
390
- * Notifies a pending user to activate their account
391
- *
392
- * @since 6.0
393
- * @access public
394
- *
395
- * @param int $user_id The user's ID
396
- */
397
- public static function new_user_activation_notification( $user_id ) {
398
- global $wpdb, $current_site;
399
-
400
- $user = new WP_User( $user_id );
401
-
402
- $user_login = stripslashes( $user->user_login );
403
- $user_email = stripslashes( $user->user_email );
404
-
405
- // Generate an activation key
406
- $key = wp_generate_password( 20, false );
407
-
408
- // Set the activation key for the user
409
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key ), array( 'user_login' => $user->user_login ) );
410
-
411
- if ( is_multisite() ) {
412
- $blogname = $current_site->site_name;
413
- } else {
414
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
415
- // we want to reverse this for the plain text arena of emails.
416
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
417
- }
418
-
419
- $activation_url = add_query_arg( array( 'action' => 'activate', 'key' => $key, 'login' => rawurlencode( $user_login ) ), wp_login_url() );
420
-
421
- $title = sprintf( __( '[%s] Activate Your Account', 'theme-my-login' ), $blogname );
422
- $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";
423
- $message .= $activation_url . "\r\n";
424
-
425
- $title = apply_filters( 'user_activation_notification_title', $title, $user_id );
426
- $message = apply_filters( 'user_activation_notification_message', $message, $activation_url, $user_id );
427
-
428
- return wp_mail( $user_email, $title, $message );
429
- }
430
-
431
- /**
432
- * Notifies the administrator of a pending user needing approval
433
- *
434
- * @since 6.0
435
- * @access public
436
- *
437
- * @param int $user_id The user's ID
438
- */
439
- public static function new_user_approval_admin_notification( $user_id ) {
440
- global $current_site;
441
-
442
- if ( ! apply_filters( 'send_new_user_approval_admin_notification', true ) )
443
- return;
444
-
445
- $user = new WP_User( $user_id );
446
-
447
- $user_login = stripslashes( $user->user_login );
448
- $user_email = stripslashes( $user->user_email );
449
-
450
- if ( is_multisite() ) {
451
- $blogname = $current_site->site_name;
452
- } else {
453
- // The blogname option is escaped with esc_html on the way into the database in sanitize_option
454
- // we want to reverse this for the plain text arena of emails.
455
- $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
456
- }
457
-
458
- $title = sprintf( __( '[%s] New User Awaiting Approval', 'theme-my-login' ), $blogname );
459
-
460
- $message = sprintf( __( 'New user requires approval on your blog %s:', 'theme-my-login' ), $blogname ) . "\r\n\r\n";
461
- $message .= sprintf( __( 'Username: %s', 'theme-my-login' ), $user_login ) . "\r\n";
462
- $message .= sprintf( __( 'E-mail: %s', 'theme-my-login' ), $user_email ) . "\r\n\r\n";
463
- $message .= __( 'To approve or deny this user:', 'theme-my-login' ) . "\r\n";
464
- $message .= admin_url( 'users.php?role=pending' );
465
-
466
- $title = apply_filters( 'user_approval_admin_notification_title', $title, $user_id );
467
- $message = apply_filters( 'user_approval_admin_notification_message', $message, $user_id );
468
-
469
- $to = apply_filters( 'user_approval_admin_notification_mail_to', get_option( 'admin_email' ) );
470
-
471
- @wp_mail( $to, $title, $message );
472
- }
473
- }
474
-
475
- Theme_My_Login_User_Moderation::get_object();
476
-
477
- endif;
478
-
479
- if ( is_admin() )
480
- include_once( dirname( __FILE__ ) . '/admin/user-moderation-admin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,61 +1,105 @@
1
  === Theme My Login ===
2
- Contributors: jfarthing84
3
- Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
4
- Requires at least: 4.5
5
  Tested up to: 4.9.6
6
- Stable tag: 6.4.17
7
 
8
- Themes the WordPress login pages according to your theme.
9
 
10
 
11
  == Description ==
12
 
13
- This plugin themes the WordPress login, registration and forgot password pages according to your current theme.
14
- It creates a page to use in place of wp-login.php, using a page template from your theme.
15
- Also includes a widget for sidebar login.
16
 
17
 
18
  = Features =
19
- * Your registration, log in, and password recovery pages will all match the rest of your website
20
- * Includes a customizable widget to login anywhere from your blog
21
- * Redirect users upon log in and log out based upon their role
22
- * Show gravatar to users who are logged in
23
- * Assign custom links to users who are logged in based on their role
24
- * Customize user emails for registration and/or password recovery
25
- * Send user emails in HTML format
26
- * Allow users to set their own password upon registration
27
- * Require users to be approved or confirm e-mail address upon registration
28
- * Theme user profiles
29
 
 
 
 
 
 
 
 
 
30
 
31
- == Installation ==
32
 
33
- 1. Upload the plugin to your 'wp-content/plugins' directory
34
- 1. Activate the plugin
35
 
 
36
 
37
- == Frequently Asked Questions ==
 
 
 
 
 
 
 
 
 
 
38
 
39
- = How do I change the look of forms? =
40
 
41
- 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.
42
- You can copy this to your theme's directory and add additional styling there or simply add additional styling to your theme's stylesheet.
43
 
44
- = I can't get into my site! What do I do? =
45
 
46
- Visit yoursite.com/wp-login.php.
47
 
48
- = What happened to the language folder? =
49
 
50
- As of version 6.3, Theme My Login no longer ships with translation files. Translations will be available at http://translate.wordpress.org.
51
 
52
- = How do I obtain additional assistance? =
53
 
54
- Please visit https://wordpress.org/support/plugin/theme-my-login.
55
 
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  = 6.4.17 =
60
  * Fix the version check logic in the updater
61
  * Implement path to download 6.4.x releases only
@@ -420,7 +464,7 @@ Please visit https://wordpress.org/support/plugin/theme-my-login.
420
  = 4.3.2 =
421
  * Added the option to redirect unapproved and/or denied users to a custom URL upon login attempt
422
  * Fixed a bug where custom user password is lost if user moderation is enabled
423
- * Fixed a PHP notice in the admin (Wish more plugin authors would do this; WP_DEBUG is your friend!)
424
 
425
  = 4.3.1 =
426
  * Fixed a MAJOR security hole that allowed anyone to login without a password!!
@@ -460,7 +504,6 @@ Please visit https://wordpress.org/support/plugin/theme-my-login.
460
  * Implemented custom links for logged in users based on role
461
  * Implemented custom redirection upon log in based on role
462
  * Implemented custom registration/password recovery emails
463
-
464
  * Implemented true shortcode and template tag functionality
465
  * Implemented true multi-instance functionality
466
  * Implemented an easy-to-use jQuery tabbed administration menu
@@ -578,3 +621,9 @@ Please visit https://wordpress.org/support/plugin/theme-my-login.
578
 
579
  = 1.0.0 =
580
  * Initial release version
 
 
 
 
 
 
1
  === Theme My Login ===
2
+ Contributors: thememylogin, jfarthing84
3
+ Tags: login, register, password, branding, customize, widget, wp-login, wp-login.php
4
+ Requires at least: 4.6
5
  Tested up to: 4.9.6
6
+ Stable tag: 7.0.3
7
 
8
+ The ultimate login branding solution! Theme My Login offers matchless customization of your WordPress user experience!
9
 
10
 
11
  == Description ==
12
 
13
+ Ever wished that your WordPress login page matched the rest of your site? Your wish has come true! Theme My Login allows you to bypass the default WordPress-branded login page that looks nothing like the rest of your site. Instead, your users will be presented with the login, registration and password recovery pages right within your theme. The best part? It works right out of the box, with no configuration necessary! Take back your login page, WordPress users!
 
 
14
 
15
 
16
  = Features =
 
 
 
 
 
 
 
 
 
 
17
 
18
+ * Have you users log in from the frontend of your site.
19
+ * Have your users register from the frontend of your site.
20
+ * Have your users recover their password from the frontend of your site.
21
+ * Customize the slugs used for login, registration, password recovery and other pages.
22
+ * Allow your users to register with only their email.
23
+ * Allow your users to set their own passwords upon registration.
24
+ * Allow your users to log in using either their email and password, username and password or a combination of the two.
25
+ * Allow your users to be logged in automatically after registration with auto-login.
26
 
 
27
 
28
+ = Do More With Extensions =
 
29
 
30
+ Boost your user experience even more with add-on plugins from our [extensions catalog](https://thememylogin.com/extensions). Some of our extensions include:
31
 
32
+ * [Moderation](https://thememylogin.com/extensions/moderation) allows you to moderate your users by requiring them to confirm their email or by requiring admin approval.
33
+ * [Notifications](https://thememylogin.com/extensions/notification) allows you to send customized notification for many different actions that take place within your site.
34
+ * [Profiles](https://thememylogin.com/extensions/profiles) lets your users edit their profile from the frontend of your site.
35
+ * [reCAPTCHA](https://thememylogin.com/extensions/recaptcha) enables Google reCAPTCHA support for your registration and login forms.
36
+ * [Redirection](https://thememylogin.com/extensions/redirection) allows you to redirect your users on login, logout and registration based on their role.
37
+ * [Security](https://thememylogin.com/extensions/security) empowers you to secure you website and your users by offering brute-force protection via login throttling by IP address.
38
+
39
+ == Installation ==
40
+
41
+ 1. Upload the plugin files to the `/wp-content/plugins/theme-my-login` directory, or install the plugin through the WordPress plugins screen directly.
42
+ 1. Activate the plugin through the 'Plugins' screen in WordPress
43
 
 
44
 
45
+ == Frequently Asked Questions ==
 
46
 
47
+ = Where can I find documentation? =
48
 
49
+ Documentation can be found on our [documentation site](http://docs.thememylogin.com).
50
 
51
+ = Where can I find support? =
52
 
53
+ Support can be found using our [support form](https://thememylogin.com/support).
54
 
55
+ = Where can I report a bug? =
56
 
57
+ Report bugs, suggest ideas and participate in development at [GitHub](https://github.com/theme-my-login/theme-my-login/).
58
 
59
 
60
  == Changelog ==
61
 
62
+ = 7.0.3 =
63
+ * Fix an error on PHP versions less than 5.3
64
+ * Allow for description in settings API functions
65
+ * Fix compatibility with legacy shortcode
66
+ * Rewrite certain admin login links
67
+ * Remove undesired actions and filters from TML pages
68
+ * Introduce new `tml_action_{$action}` hook and use it for handlers
69
+
70
+ = 7.0.2 =
71
+ * Fix collision with some plugins which modify the nav menu edit walker
72
+ * Fix a notice in multisite
73
+ * Fix pages not using custom templates when used as TML actions
74
+ * Fix shortcode not working in certain circumstances when no action is present
75
+
76
+ = 7.0.1 =
77
+ * Fix error where WP_Query is used before expected by other plugins
78
+ * Fix existing shortcodes from pre-7 not working due to missing action
79
+ * Fix compatibility with plugins that use some legacy methods on the plugin class
80
+ * Fix registration redirection when auto-login is enabled
81
+ * Allow actions to be represented by pages if their slugs match
82
+ * Fix legacy page menu items no longer behaving as they did pre-7
83
+
84
+ = 7.0 =
85
+ * Rewrite plugin from the ground up
86
+ * Pages are no longer used to represent actions
87
+ * Actions are now represented by a class
88
+ * Actions can be added/remove on the fly
89
+ * Forms are now represented by a class
90
+ * Forms can be added/remove on the fly
91
+ * Form fields can be added/removed/modified/rearranged on the fly
92
+ * Extensions can easily be written and integrated with the plugin
93
+ * Move Custom E-mail module to a commercial extension
94
+ * Merge Custom Passwords module into core plugin
95
+ * Move Custom Redirection module to a commercial extension
96
+ * Remove Custom User Links module
97
+ * Move reCAPTCHA module to a commercial extension
98
+ * Move Security module to a commercial extension
99
+ * Move Themed Profiles module to a commercial extension
100
+ * Move User Moderation module to a commercial extension
101
+ * Add option to allow auto-login after registration
102
+
103
  = 6.4.17 =
104
  * Fix the version check logic in the updater
105
  * Implement path to download 6.4.x releases only
464
  = 4.3.2 =
465
  * Added the option to redirect unapproved and/or denied users to a custom URL upon login attempt
466
  * Fixed a bug where custom user password is lost if user moderation is enabled
467
+ * Fixed a PHP notice in the admin
468
 
469
  = 4.3.1 =
470
  * Fixed a MAJOR security hole that allowed anyone to login without a password!!
504
  * Implemented custom links for logged in users based on role
505
  * Implemented custom redirection upon log in based on role
506
  * Implemented custom registration/password recovery emails
 
507
  * Implemented true shortcode and template tag functionality
508
  * Implemented true multi-instance functionality
509
  * Implemented an easy-to-use jQuery tabbed administration menu
621
 
622
  = 1.0.0 =
623
  * Initial release version
624
+
625
+
626
+ == Upgrade Notice ==
627
+
628
+ = 7.0 =
629
+ Modules are no longer included with the plugin. Please consider this before you upgrade!
templates/login-form.php DELETED
@@ -1,46 +0,0 @@
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 DELETED
@@ -1,31 +0,0 @@
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 DELETED
@@ -1,84 +0,0 @@
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 DELETED
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,51 +0,0 @@
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 DELETED
@@ -1,198 +0,0 @@
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
-
13
- <input type="hidden" name="from" value="profile" />
14
- <input type="hidden" name="checkuser_id" value="<?php echo $current_user->ID; ?>" />
15
-
16
- <?php if ( apply_filters( 'show_admin_bar', true ) || has_action( 'personal_options' ) ) : ?>
17
- <h3><?php _e( 'Personal Options', 'theme-my-login' ); ?></h3>
18
-
19
- <table class="tml-form-table">
20
- <?php if ( apply_filters( 'show_admin_bar', true ) ) : ?>
21
- <tr class="tml-user-admin-bar-front-wrap">
22
- <th><label for="admin_bar_front"><?php _e( 'Toolbar', 'theme-my-login' )?></label></th>
23
- <td>
24
- <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 ) ); ?> />
25
- <?php _e( 'Show Toolbar when viewing site', 'theme-my-login' ); ?></label>
26
- </td>
27
- </tr>
28
- <?php endif; ?>
29
- <?php do_action( 'personal_options', $profileuser ); ?>
30
- </table>
31
- <?php endif; ?>
32
-
33
- <?php do_action( 'profile_personal_options', $profileuser ); ?>
34
-
35
- <h3><?php _e( 'Name', 'theme-my-login' ); ?></h3>
36
-
37
- <table class="tml-form-table">
38
- <tr class="tml-user-login-wrap">
39
- <th><label for="user_login"><?php _e( 'Username', 'theme-my-login' ); ?></label></th>
40
- <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>
41
- </tr>
42
-
43
- <tr class="tml-first-name-wrap">
44
- <th><label for="first_name"><?php _e( 'First Name', 'theme-my-login' ); ?></label></th>
45
- <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td>
46
- </tr>
47
-
48
- <tr class="tml-last-name-wrap">
49
- <th><label for="last_name"><?php _e( 'Last Name', 'theme-my-login' ); ?></label></th>
50
- <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>
51
- </tr>
52
-
53
- <tr class="tml-nickname-wrap">
54
- <th><label for="nickname"><?php _e( 'Nickname', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
55
- <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td>
56
- </tr>
57
-
58
- <tr class="tml-display-name-wrap">
59
- <th><label for="display_name"><?php _e( 'Display name publicly as', 'theme-my-login' ); ?></label></th>
60
- <td>
61
- <select name="display_name" id="display_name">
62
- <?php
63
- $public_display = array();
64
- $public_display['display_nickname'] = $profileuser->nickname;
65
- $public_display['display_username'] = $profileuser->user_login;
66
-
67
- if ( ! empty( $profileuser->first_name ) )
68
- $public_display['display_firstname'] = $profileuser->first_name;
69
-
70
- if ( ! empty( $profileuser->last_name ) )
71
- $public_display['display_lastname'] = $profileuser->last_name;
72
-
73
- if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
74
- $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
75
- $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
76
- }
77
-
78
- if ( ! in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
79
- $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
80
-
81
- $public_display = array_map( 'trim', $public_display );
82
- $public_display = array_unique( $public_display );
83
-
84
- foreach ( $public_display as $id => $item ) {
85
- ?>
86
- <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
87
- <?php
88
- }
89
- ?>
90
- </select>
91
- </td>
92
- </tr>
93
- </table>
94
-
95
- <h3><?php _e( 'Contact Info', 'theme-my-login' ); ?></h3>
96
-
97
- <table class="tml-form-table">
98
- <tr class="tml-user-email-wrap">
99
- <th><label for="email"><?php _e( 'E-mail', 'theme-my-login' ); ?> <span class="description"><?php _e( '(required)', 'theme-my-login' ); ?></span></label></th>
100
- <td><input type="text" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text" /></td>
101
- <?php
102
- $new_email = get_option( $current_user->ID . '_new_email' );
103
- if ( $new_email && $new_email['newemail'] != $current_user->user_email ) : ?>
104
- <div class="updated inline">
105
- <p><?php
106
- printf(
107
- __( 'There is a pending change of your e-mail to %1$s. <a href="%2$s">Cancel</a>', 'theme-my-login' ),
108
- '<code>' . $new_email['newemail'] . '</code>',
109
- esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) )
110
- ); ?></p>
111
- </div>
112
- <?php endif; ?>
113
- </tr>
114
-
115
- <tr class="tml-user-url-wrap">
116
- <th><label for="url"><?php _e( 'Website', 'theme-my-login' ); ?></label></th>
117
- <td><input type="text" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td>
118
- </tr>
119
-
120
- <?php
121
- foreach ( wp_get_user_contact_methods() as $name => $desc ) {
122
- ?>
123
- <tr class="tml-user-contact-method-<?php echo $name; ?>-wrap">
124
- <th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
125
- <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
126
- </tr>
127
- <?php
128
- }
129
- ?>
130
- </table>
131
-
132
- <h3><?php _e( 'About Yourself', 'theme-my-login' ); ?></h3>
133
-
134
- <table class="tml-form-table">
135
- <tr class="tml-user-description-wrap">
136
- <th><label for="description"><?php _e( 'Biographical Info', 'theme-my-login' ); ?></label></th>
137
- <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html( $profileuser->description ); ?></textarea><br />
138
- <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>
139
- </tr>
140
-
141
- <?php
142
- $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
143
- if ( $show_password_fields ) :
144
- ?>
145
- </table>
146
-
147
- <h3><?php _e( 'Account Management', 'theme-my-login' ); ?></h3>
148
- <table class="tml-form-table">
149
- <tr id="password" class="user-pass1-wrap">
150
- <th><label for="pass1"><?php _e( 'New Password', 'theme-my-login' ); ?></label></th>
151
- <td>
152
- <input class="hidden" value=" " /><!-- #24364 workaround -->
153
- <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password', 'theme-my-login' ); ?></button>
154
- <div class="wp-pwd hide-if-js">
155
- <span class="password-input-wrapper">
156
- <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" />
157
- </span>
158
- <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
159
- <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' ); ?>">
160
- <span class="dashicons dashicons-hidden"></span>
161
- <span class="text"><?php _e( 'Hide', 'theme-my-login' ); ?></span>
162
- </button>
163
- <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' ); ?>">
164
- <span class="text"><?php _e( 'Cancel', 'theme-my-login' ); ?></span>
165
- </button>
166
- </div>
167
- </td>
168
- </tr>
169
- <tr class="user-pass2-wrap hide-if-js">
170
- <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password', 'theme-my-login' ); ?></label></th>
171
- <td>
172
- <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
173
- <p class="description"><?php _e( 'Type your new password again.', 'theme-my-login' ); ?></p>
174
- </td>
175
- </tr>
176
- <tr class="pw-weak">
177
- <th><?php _e( 'Confirm Password', 'theme-my-login' ); ?></th>
178
- <td>
179
- <label>
180
- <input type="checkbox" name="pw_weak" class="pw-checkbox" />
181
- <?php _e( 'Confirm use of weak password', 'theme-my-login' ); ?>
182
- </label>
183
- </td>
184
- </tr>
185
- <?php endif; ?>
186
-
187
- </table>
188
-
189
- <?php do_action( 'show_user_profile', $profileuser ); ?>
190
-
191
- <p class="tml-submit-wrap">
192
- <input type="hidden" name="action" value="profile" />
193
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
194
- <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $current_user->ID ); ?>" />
195
- <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Profile', 'theme-my-login' ); ?>" name="submit" id="submit" />
196
- </p>
197
- </form>
198
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/register-form.php DELETED
@@ -1,35 +0,0 @@
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 DELETED
@@ -1,56 +0,0 @@
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
- <div 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 password-input" value="" autocomplete="off" aria-describedby="pass-strength-result" />
20
- <span class="wp-hide-pw hide-if-no-js">
21
- <span class="dashicons dashicons-hidden"></span>
22
- </span>
23
- </div>
24
- <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator', 'theme-my-login' ); ?></div>
25
- </div>
26
- <div class="pw-weak">
27
- <label>
28
- <input type="checkbox" name="pw_weak" class="pw-checkbox" />
29
- <?php _e( 'Confirm use of weak password', 'theme-my-login' ); ?>
30
- </label>
31
- </div>
32
- </div>
33
-
34
- <p class="user-pass2-wrap">
35
- <label for="pass2"><?php _e( 'Confirm new password', 'theme-my-login' ); ?></label>
36
- <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
37
- </p>
38
-
39
- <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
40
-
41
- <?php do_action( 'resetpassword_form' ); ?>
42
-
43
- <p class="tml-submit-wrap">
44
- <input type="submit" name="wp-submit" id="wp-submit<?php $template->the_instance(); ?>" value="<?php esc_attr_e( 'Reset Password', 'theme-my-login' ); ?>" />
45
- <input type="hidden" id="user_login" value="<?php echo esc_attr( $GLOBALS['rp_login'] ); ?>" autocomplete="off" />
46
- <input type="hidden" name="rp_key" value="<?php echo esc_attr( $GLOBALS['rp_key'] ); ?>" />
47
- <input type="hidden" name="instance" value="<?php $template->the_instance(); ?>" />
48
- <input type="hidden" name="action" value="resetpass" />
49
- </p>
50
- </form>
51
- <?php $template->the_action_links( array(
52
- 'login' => false,
53
- 'register' => false,
54
- 'lostpassword' => false
55
- ) ); ?>
56
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/user-panel.php DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,259 +0,0 @@
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
- .tml .success {
14
- padding: 1em;
15
- }
16
-
17
- .tml .error {
18
- border: 1px solid #ebccd1;
19
- background-color: #f2dede;
20
- color: #a94442;
21
- }
22
-
23
- .tml .error a {
24
- color: #843534;
25
- }
26
-
27
- .tml .message {
28
- border: 1px solid #faebcc;
29
- background-color: #fcf8e3;
30
- color: #8a6d3b;
31
- }
32
-
33
- .tml .message a {
34
- color: #66512c;
35
- }
36
-
37
- .tml .success {
38
- border: 1px solid #d6e9c6;
39
- background-color: #dff0d8;
40
- color: #3c763d;
41
- }
42
-
43
- .tml .success a {
44
- color: #2b542c;
45
- }
46
-
47
- .tml p {
48
- margin: 0 0 1.5em 0;
49
- padding: 0;
50
- }
51
-
52
- .tml label {
53
- display: block;
54
- text-align: left;
55
- }
56
-
57
- .tml .tml-rememberme-wrap label {
58
- display: inline;
59
- font-size: 90%;
60
- }
61
-
62
- .tml input,
63
- .tml textarea,
64
- .tml select {
65
- margin: 0.5em 0;
66
- width: 100%;
67
- }
68
-
69
- .tml input[type="checkbox"],
70
- .tml input[type="radio"],
71
- .tml .tml-rememberme-wrap input {
72
- margin: 0 0.5em 0 0;
73
- vertical-align: middle;
74
- width: auto;
75
- }
76
-
77
- .tml .tml-action-links {
78
- display: inline-block;
79
- list-style: none;
80
- margin: 0.5em auto;
81
- padding: 0;
82
- text-align: center;
83
- }
84
-
85
- .tml .tml-action-links li {
86
- border: none;
87
- border-right: 1px solid rgba(0, 0, 0, 0.1);
88
- float: left;
89
- line-height: 1;
90
- list-style: none;
91
- margin: 0 0.5em 0 0;
92
- padding: 0 0.5em 0 0;
93
- }
94
-
95
- .tml .tml-action-links li:last-child {
96
- border-right: none;
97
- margin-right: 0;
98
- padding-right: 0;
99
- }
100
-
101
- .tml .tml-action-links a {
102
- border: none;
103
- display: block;
104
- padding: 0;
105
- text-decoration: none;
106
- }
107
-
108
- .tml .tml-rememberme-submit-wrap:before,
109
- .tml .tml-rememberme-submit-wrap:after,
110
- .tml .tml-action-links:before,
111
- .tml .tml-action-links:after {
112
- content: "";
113
- display: table;
114
- }
115
-
116
- .tml .tml-rememberme-submit-wrap:after,
117
- .tml .tml-action-links:after {
118
- clear: both;
119
- }
120
-
121
- .tml .tml-user-avatar {
122
- text-align: left;
123
- }
124
-
125
- .mu_register .hint {
126
- font-size: 12px;
127
- margin-bottom: 10px;
128
- display: block;
129
- }
130
-
131
- .mu_register label.checkbox {
132
- display: inline;
133
- }
134
-
135
- #pass-strength-result {
136
- background-color: #eee;
137
- border: 1px solid #ddd;
138
- color: #23282d;
139
- font-weight: 600;
140
- margin: -1px 0 1.5em;
141
- padding: 3px 5px;
142
- text-align: center;
143
- width: 100%;
144
- opacity: 0;
145
- }
146
-
147
- #pass-strength-result.short {
148
- background-color: #f1adad;
149
- border-color: #e35b5b;
150
- opacity: 1;
151
- }
152
-
153
- #pass1.short,
154
- #pass1-text.short {
155
- border-color: #e35b5b;
156
- }
157
-
158
- #pass-strength-result.bad {
159
- background-color: #fbc5a9;
160
- border-color: #f78b53;
161
- opacity: 1;
162
- }
163
-
164
- #pass1.bad,
165
- #pass1-text.bad {
166
- border-color: #f78b53;
167
- }
168
-
169
- #pass-strength-result.good {
170
- background-color: #ffe399;
171
- border-color: #ffc733;
172
- opacity: 1;
173
- }
174
-
175
- #pass1.good,
176
- #pass1-text.good {
177
- border-color: #ffc733;
178
- }
179
-
180
- #pass-strength-result.strong {
181
- background-color: #c1e1b9;
182
- border-color: #83c373;
183
- opacity: 1;
184
- }
185
-
186
- #pass1.strong,
187
- #pass1-text.strong {
188
- border-color: #83c373;
189
- }
190
-
191
- .tml .password-input-wrapper {
192
- display: table;
193
- width: 100%;
194
- }
195
-
196
- .tml .input.password-input {
197
- display: table-cell;
198
- margin: 0;
199
- }
200
-
201
- .tml .pw-weak {
202
- display: none;
203
- margin-bottom: 1.5em;
204
- }
205
-
206
- .tml .wp-hide-pw {
207
- cursor: pointer;
208
- display: table-cell;
209
- margin: 0;
210
- padding: 0 0.5em;
211
- text-align: center;
212
- vertical-align: middle;
213
- white-space: nowrap;
214
- }
215
-
216
- #pass1,
217
- #pass1-text {
218
- width: 100%;
219
- }
220
-
221
- #pass1-text,
222
- .show-password #pass1 {
223
- display: none;
224
- }
225
-
226
- .show-password #pass1-text
227
- {
228
- display: inline-block;
229
- }
230
-
231
- @media screen and (min-width: 768px) {
232
- .tml {
233
- max-width: 500px;
234
- }
235
-
236
- .tml .tml-submit-wrap input {
237
- width: auto;
238
- }
239
-
240
- .tml-login .tml-rememberme-submit-wrap {
241
- display: table;
242
- margin-bottom: 1.5em;
243
- width: 100%;
244
- }
245
-
246
- .tml-login .tml-rememberme-wrap {
247
- display: table-cell;
248
- }
249
-
250
- .tml-login .tml-submit-wrap {
251
- display: table-cell;
252
- text-align: right;
253
- }
254
-
255
- .tml-login .tml-submit-wrap input {
256
- margin: 0;
257
- width: auto;
258
- }
259
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
theme-my-login.php CHANGED
@@ -1,59 +1,102 @@
1
  <?php
 
 
 
 
 
 
 
2
  /*
3
  Plugin Name: Theme My Login
4
  Plugin URI: https://thememylogin.com
5
- Description: Themes the WordPress login, registration and forgot password pages according to your theme.
6
- Version: 6.4.17
7
  Author: Theme My Login
8
  Author URI: https://thememylogin.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
+ /**
4
+ * The Theme My Login Plugin
5
+ *
6
+ * @package Theme_My_Login
7
+ */
8
+
9
  /*
10
  Plugin Name: Theme My Login
11
  Plugin URI: https://thememylogin.com
12
+ Description: Creates an alternate login, registration and password recovery experience within your theme.
13
+ Version: 7.0.3
14
  Author: Theme My Login
15
  Author URI: https://thememylogin.com
16
+ License: GPLv2
17
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
18
  Text Domain: theme-my-login
19
+ Network: true
20
  */
21
 
22
+ /**
23
+ * Stores the version of TML.
24
+ *
25
+ * @since 7.0
26
+ */
27
+ define( 'THEME_MY_LOGIN_VERSION', '7.0.3' );
28
 
29
+ /**
30
+ * Stores the path to TML.
31
+ *
32
+ * @since 6.4.4
33
+ */
34
+ define( 'THEME_MY_LOGIN_PATH', plugin_dir_path( __FILE__ ) );
35
 
36
+ /**
37
+ * Stores the URL to TML.
38
+ *
39
+ * @since 7.0
40
+ */
41
+ define( 'THEME_MY_LOGIN_URL', plugin_dir_url( __FILE__ ) );
42
 
43
+ /**
44
+ * Stores the URL to TML's extensions directory.
45
+ *
46
+ * @since 7.0
47
+ */
48
+ define( 'THEME_MY_LOGIN_EXTENSIONS_URL', 'https://thememylogin.com/extensions' );
49
 
50
+ /**
51
+ * Stores the URL to TML's extensions API.
52
+ *
53
+ * @since 7.0
54
+ */
55
+ define( 'THEME_MY_LOGIN_EXTENSIONS_API_URL', 'https://thememylogin.com/edd-api/products' );
56
 
57
+ /**
58
+ * Require files.
59
+ */
60
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login.php';
61
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login-action.php';
62
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login-form.php';
63
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login-form-field.php';
64
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login-extension.php';
65
+ require THEME_MY_LOGIN_PATH . 'includes/class-theme-my-login-widget.php';
66
+ require THEME_MY_LOGIN_PATH . 'includes/actions.php';
67
+ require THEME_MY_LOGIN_PATH . 'includes/forms.php';
68
+ require THEME_MY_LOGIN_PATH . 'includes/extensions.php';
69
+ require THEME_MY_LOGIN_PATH . 'includes/compat.php';
70
+ require THEME_MY_LOGIN_PATH . 'includes/functions.php';
71
+ require THEME_MY_LOGIN_PATH . 'includes/options.php';
72
+ require THEME_MY_LOGIN_PATH . 'includes/shortcodes.php';
73
+ require THEME_MY_LOGIN_PATH . 'includes/hooks.php';
74
 
75
  if ( is_multisite() ) {
76
+ require THEME_MY_LOGIN_PATH . 'includes/ms-functions.php';
77
+ require THEME_MY_LOGIN_PATH . 'includes/ms-hooks.php';
 
 
78
  }
79
 
 
80
  /**
81
+ * Load custom functions file.
 
 
 
 
 
82
  */
83
+ if ( file_exists( WP_PLUGIN_DIR . '/theme-my-login-custom.php' ) ) {
84
+ include WP_PLUGIN_DIR . '/theme-my-login-custom.php';
85
  }
 
86
 
87
+ // Prepare for something amazing!
88
+ theme_my_login();
89
+
90
+ /**
91
+ * Require admin files.
92
+ */
93
+ if ( is_admin() ) {
94
+ require THEME_MY_LOGIN_PATH . 'admin/class-theme-my-login-admin.php';
95
+ require THEME_MY_LOGIN_PATH . 'admin/functions.php';
96
+ require THEME_MY_LOGIN_PATH . 'admin/settings.php';
97
+ require THEME_MY_LOGIN_PATH . 'admin/extensions.php';
98
+ require THEME_MY_LOGIN_PATH . 'admin/hooks.php';
99
+
100
+ // Prepare for something somewhat amazing!
101
+ theme_my_login_admin();
102
+ }