Edit Author Slug - Version 1.6.0

Version Description

  • Release date: 2018-10-11
  • Minimum required WordPress version is now 4.7
  • Settings page JS no longer depends on jQuery (switched to plain js)
  • Add compatibility for iThemes Force Unique Nickname WordPress Tweak
  • Add a hash string as an author slug option
  • Minimum PHP version has been bumped to 5.3. This is a soft bump, meaning, the plugin should still run on PHP 5.2. However, PHP 5.2 is no longer, officially, supported.
Download this release

Release Info

Developer thebrandonallen
Plugin Icon 128x128 Edit Author Slug
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.2 to 1.6.0

CHANGELOG.md CHANGED
@@ -3,7 +3,19 @@ All notable changes to this project will be documented in this file.
3
 
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
5
 
6
- ## [1.5.2](https://github.com/thebrandonallen/edit-author-slug/tree/1.5.1) - 2017-06-21 ##
 
 
 
 
 
 
 
 
 
 
 
 
7
  ### Fixed
8
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. [GH-12]
9
 
3
 
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
5
 
6
+ ## [1.6.0](https://github.com/thebrandonallen/edit-author-slug/tree/1.6.0) - 2018-10-11 ##
7
+ ### Added
8
+ * Add compatibility for iThemes Force Unique Nickname WordPress Tweak
9
+ * Add a hash string as an author slug option [GH-17]
10
+
11
+ ### Changed
12
+ * Minimum required WordPress version is now 4.7
13
+ * Settings page JS no longer depends on jQuery (switched to plain js)
14
+
15
+ ### Deprecated
16
+ * Minimum PHP version has been bumped to 5.3. This is a soft bump, meaning, the plugin should still run on PHP 5.2. However, PHP 5.2 is no longer, officially, supported.
17
+
18
+ ## [1.5.2](https://github.com/thebrandonallen/edit-author-slug/tree/1.5.2) - 2017-06-21 ##
19
  ### Fixed
20
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. [GH-12]
21
 
README.md CHANGED
@@ -1,71 +1,80 @@
1
- # Edit Author Slug [![Build Status](https://travis-ci.org/thebrandonallen/edit-author-slug.svg?branch=master)](https://travis-ci.org/thebrandonallen/edit-author-slug) #
2
- **Contributors:** [thebrandonallen](https://profiles.wordpress.org/thebrandonallen)
3
- **Tags:** author, author base, author slug, user nicename, nicename, permalink, permalinks, slug, users, user, role, roles
4
- **Requires at least:** 4.4
5
- **Tested up to:** 4.8
6
- **Stable tag:** 1.5.2
7
- **License:** GPLv2 or later
8
- **License URI:** https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9
-
10
- Allows an admin (or capable user) to edit the author slug of a user, and change the author base.
11
-
12
- ## Description ##
13
-
14
- This plugin allows full control of your user permalinks, allowing you to change both the author base (the '/author/' portion of the author URLs), and the author slug (defaults to the username of the author). You can set the author base globally, or you can set it to be user-specific based on a user's role. You now have the power to craft the perfect URL structure for you Author pages.
15
-
16
- WordPress default structure *http://example.com/author/username/*.
17
-
18
- Edit Author Slug allows for *http://example.com/ninja/master-ninja/*.
19
-
20
- Using a role-based author base would allow for *http://example.com/ida/master-splinter/* (for an Administrator Role), or *http://example.com/koga/leonardo/* (for a Subscriber Role).
21
-
22
- Development of this plugin takes place on [GitHub](https://github.com/thebrandonallen/edit-author-slug/ "Edit Author Slug on Github"). Pull requests are always welcome!
23
-
24
- Translations should be submitted to [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
25
-
26
- ## Installation ##
27
-
28
- 1. Upload `edit-author-slug` folder to your WordPress plugins directory (typically 'wp-content/plugins')
29
- 2. Activate the plugin through the 'Plugins' menu in WordPress
30
- 3. Go to Users > Your Profile, or Users > All Users > (username), and edit the author slug.
31
- 4. Click "Update Profile" or "Update User"
32
- 5. Go to Settings > Edit Author Slug to edit settings
33
- 6. Click "Save Changes"
34
-
35
- ## Screenshots ##
36
-
37
- 1. Settings
38
- 2. Individual user author slug
39
-
40
- ## Frequently Asked Questions ##
41
-
42
- ### What is an author slug? ###
43
-
44
- On standard WordPress installs, it's the final part of an author permalink.
45
- e.g. - https://example.com/author/author-slug/
46
-
47
- In relation to WordPress internals, the author slug is the same as the `user_nicename` field found in a `WP_User` object, or the users table in the database.
48
-
49
- ### Will my changes persist if I deactivate or delete the Edit Author Slug plugin? ###
50
-
51
- It depends.
52
-
53
- Changing a user's author slug is permanent, as this changes the user's `user_nicename` field in the database.
54
-
55
- If you've changed the author base, deactivating or deleting the plugin will revert your author base back to `author`.
56
-
57
- ### Why can't I edit my Author Slug? ###
58
-
59
- Make sure you are an admin, or have been assigned the `edit_users` capability.
60
-
61
- ### Why isn't my new Author Slug working? ###
62
-
63
- While I've made every attempt to prevent this, I may have missed a spot or two. First things first, go to Settings > Permalinks and click "Save Changes." You don't need to actually need to make any changes for this to work. Hopefully, this should kick your new Author Slug into gear.
64
-
65
- If this doesn't work, make sure you don't have any slug conflicts from other posts/pages/plugins/permalink setting/etc. If you're still experiencing the issue, feel free to post a support request in the forums.
66
-
67
- ## Changelog ##
68
-
 
 
 
 
 
 
 
 
 
69
  ### 1.5.2 ###
70
  * Release date: 2017-06-21
71
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. Props @thatherton.
@@ -74,42 +83,42 @@ If this doesn't work, make sure you don't have any slug conflicts from other pos
74
  * Release date: 2017-06-02
75
  * Fix PHP notice when manually updating a user profile. Props @mydigitalsauce.
76
 
77
- ### 1.5.0 ###
78
- * Release date: 2017-05-30
79
- * Bumped minimum required WordPress version to 4.4.
80
- * Refactored bulk upgrading again. The original fix made things better, but not as good as it could be. This new refactoring drastically improves performance and memory usage.
81
- * This release is primarily an under-the-hood release with a number of optimizations and performance improvements.
82
-
83
- ### 1.4.1 ###
84
- * Release date: 2017-04-24
85
- * Fix failing string replacement in bulk update message.
86
-
87
- ### 1.4.0 ###
88
- * Release date: 2017-04-04
89
- * Lots of code cleanup to better adhere to WordPress Coding Standards.
90
- * Improved performance of `ba_eas_sanitize_author_base()` by preventing unnecessary processing.
91
- * Fixed an issue where the demo author permalink URL could have a double slash.
92
- * Improvements to bulk update for sites with a large user base.
93
-
94
- ### 1.3.0 ###
95
- * Release date: 2017-01-25
96
- * Fix a potential bug where a sanitized author base could end up with double forward slashes.
97
- * Introduce the `%ba_eas_author_role%` permalink structure tag. This can be used to customize role-based author bases.
98
- * Bonus: All alternative facts are now free!
99
-
100
- ### 1.2.1 ###
101
- * Release date: 2016-02-29
102
- * Fixed stupid error where the default user nicename wasn't being properly retrieved from the database. Sorry about that :(
103
- * Unfortunately, some unicorns were lost during the development of this release, but they are a resilient creature.
104
-
105
- ### 1.2.0 ###
106
- * Release date: 2016-02-01
107
- * Added the ability to use forward slashes in the author base.
108
- * Improved display on the settings page, and storing, of role slugs.
109
- * Packaged translations are now removed. Anyone interested in translating the plugin should do so at [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
110
- * EXPERIMENTAL: Added the ability to set the author slug to a user's numeric user id. While I have tested this, I can't be sure that no one's site will implode. If all goes well, the experimental tag will be removed in the next major release (or two).
111
- * Added ability to remove the front portion of author links.
112
- * Accessibility improvements to the settings page.
113
-
114
- ### Full Changelog ###
115
- * https://github.com/thebrandonallen/edit-author-slug/blob/master/CHANGELOG.md
1
+ # Edit Author Slug [![Build Status](https://travis-ci.org/thebrandonallen/edit-author-slug.svg?branch=master)](https://travis-ci.org/thebrandonallen/edit-author-slug) #
2
+ **Contributors:** [thebrandonallen](https://profiles.wordpress.org/thebrandonallen)
3
+ **Tags:** author, author base, author slug, user nicename, nicename, permalink, permalinks, slug, users, user, role, roles
4
+ **Requires at least:** 4.7
5
+ **Tested up to:** 4.9.8
6
+ **Requires PHP:** 5.3
7
+ **Stable tag:** 1.6.0
8
+ **License:** GPLv2 or later
9
+ **License URI:** https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
+
11
+ Allows an admin (or capable user) to edit the author slug of a user, and change the author base.
12
+
13
+ ## Description ##
14
+
15
+ This plugin allows full control of your user permalinks, allowing you to change both the author base (the '/author/' portion of the author URLs), and the author slug (defaults to the username of the author). You can set the author base globally, or you can set it to be user-specific based on a user's role. You now have the power to craft the perfect URL structure for you Author pages.
16
+
17
+ WordPress default structure *http://example.com/author/username/*.
18
+
19
+ Edit Author Slug allows for *http://example.com/ninja/master-ninja/*.
20
+
21
+ Using a role-based author base would allow for *http://example.com/ida/master-splinter/* (for an Administrator Role), or *http://example.com/koga/leonardo/* (for a Subscriber Role).
22
+
23
+ Development of this plugin takes place on [GitHub](https://github.com/thebrandonallen/edit-author-slug/ "Edit Author Slug on Github"). Pull requests are always welcome!
24
+
25
+ Translations should be submitted to [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
26
+
27
+ ## Installation ##
28
+
29
+ 1. Upload `edit-author-slug` folder to your WordPress plugins directory (typically 'wp-content/plugins')
30
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
31
+ 3. Go to Users > Your Profile, or Users > All Users > (username), and edit the author slug.
32
+ 4. Click "Update Profile" or "Update User"
33
+ 5. Go to Settings > Edit Author Slug to edit settings
34
+ 6. Click "Save Changes"
35
+
36
+ ## Screenshots ##
37
+
38
+ 1. Settings
39
+ 2. Individual user author slug
40
+
41
+ ## Frequently Asked Questions ##
42
+
43
+ ### What is an author slug? ###
44
+
45
+ On standard WordPress installs, it's the final part of an author permalink.
46
+ e.g. - https://example.com/author/author-slug/
47
+
48
+ In relation to WordPress internals, the author slug is the same as the `user_nicename` field found in a `WP_User` object, or the users table in the database.
49
+
50
+ ### Will my changes persist if I deactivate or delete the Edit Author Slug plugin? ###
51
+
52
+ It depends.
53
+
54
+ Changing a user's author slug is permanent, as this changes the user's `user_nicename` field in the database.
55
+
56
+ If you've changed the author base, deactivating or deleting the plugin will revert your author base back to `author`.
57
+
58
+ ### Why can't I edit my Author Slug? ###
59
+
60
+ Make sure you are an admin, or have been assigned the `edit_users` capability.
61
+
62
+ ### Why isn't my new Author Slug working? ###
63
+
64
+ While I've made every attempt to prevent this, I may have missed a spot or two. First things first, go to Settings > Permalinks and click "Save Changes." You don't need to actually need to make any changes for this to work. Hopefully, this should kick your new Author Slug into gear.
65
+
66
+ If this doesn't work, make sure you don't have any slug conflicts from other posts/pages/plugins/permalink setting/etc. If you're still experiencing the issue, feel free to post a support request in the forums.
67
+
68
+ ## Changelog ##
69
+
70
+ ### 1.6.0 ###
71
+ * Release date: 2018-10-11
72
+ * Minimum required WordPress version is now 4.7
73
+ * Settings page JS no longer depends on jQuery (switched to plain js)
74
+ * Add compatibility for iThemes Force Unique Nickname WordPress Tweak
75
+ * Add a hash string as an author slug option
76
+ * Minimum PHP version has been bumped to 5.3. This is a soft bump, meaning, the plugin should still run on PHP 5.2. However, PHP 5.2 is no longer, officially, supported.
77
+
78
  ### 1.5.2 ###
79
  * Release date: 2017-06-21
80
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. Props @thatherton.
83
  * Release date: 2017-06-02
84
  * Fix PHP notice when manually updating a user profile. Props @mydigitalsauce.
85
 
86
+ ### 1.5.0 ###
87
+ * Release date: 2017-05-30
88
+ * Bumped minimum required WordPress version to 4.4.
89
+ * Refactored bulk upgrading again. The original fix made things better, but not as good as it could be. This new refactoring drastically improves performance and memory usage.
90
+ * This release is primarily an under-the-hood release with a number of optimizations and performance improvements.
91
+
92
+ ### 1.4.1 ###
93
+ * Release date: 2017-04-24
94
+ * Fix failing string replacement in bulk update message.
95
+
96
+ ### 1.4.0 ###
97
+ * Release date: 2017-04-04
98
+ * Lots of code cleanup to better adhere to WordPress Coding Standards.
99
+ * Improved performance of `ba_eas_sanitize_author_base()` by preventing unnecessary processing.
100
+ * Fixed an issue where the demo author permalink URL could have a double slash.
101
+ * Improvements to bulk update for sites with a large user base.
102
+
103
+ ### 1.3.0 ###
104
+ * Release date: 2017-01-25
105
+ * Fix a potential bug where a sanitized author base could end up with double forward slashes.
106
+ * Introduce the `%ba_eas_author_role%` permalink structure tag. This can be used to customize role-based author bases.
107
+ * Bonus: All alternative facts are now free!
108
+
109
+ ### 1.2.1 ###
110
+ * Release date: 2016-02-29
111
+ * Fixed stupid error where the default user nicename wasn't being properly retrieved from the database. Sorry about that :(
112
+ * Unfortunately, some unicorns were lost during the development of this release, but they are a resilient creature.
113
+
114
+ ### 1.2.0 ###
115
+ * Release date: 2016-02-01
116
+ * Added the ability to use forward slashes in the author base.
117
+ * Improved display on the settings page, and storing, of role slugs.
118
+ * Packaged translations are now removed. Anyone interested in translating the plugin should do so at [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
119
+ * EXPERIMENTAL: Added the ability to set the author slug to a user's numeric user id. While I have tested this, I can't be sure that no one's site will implode. If all goes well, the experimental tag will be removed in the next major release (or two).
120
+ * Added ability to remove the front portion of author links.
121
+ * Accessibility improvements to the settings page.
122
+
123
+ ### Full Changelog ###
124
+ * https://github.com/thebrandonallen/edit-author-slug/blob/master/CHANGELOG.md
edit-author-slug.php CHANGED
@@ -7,9 +7,9 @@
7
  * Author URI: https://github.com/thebrandonallen/
8
  * Text Domain: edit-author-slug
9
  * Domain Path: /languages
10
- * Version: 1.5.2
11
  *
12
- * Copyright (C) 2009-2017 Brandon Allen (https://github.com/thebrandonallen)
13
  *
14
  * This program is free software; you can redistribute it and/or modify
15
  * it under the terms of the GNU General Public License as published by
@@ -28,14 +28,14 @@
28
  * @package Edit_Author_Slug
29
  * @subpackage Main
30
  * @author Brandon Allen
31
- * @version 1.5.2
32
  */
33
 
34
  // Exit if accessed directly.
35
  defined( 'ABSPATH' ) || exit;
36
 
37
  // Load the plugin class file.
38
- require 'includes/classes/class-edit-author-slug.php';
39
 
40
  /**
41
  * Runs on Edit Author Slug activation.
7
  * Author URI: https://github.com/thebrandonallen/
8
  * Text Domain: edit-author-slug
9
  * Domain Path: /languages
10
+ * Version: 1.6.0
11
  *
12
+ * Copyright (C) 2009-2018 Brandon Allen (https://github.com/thebrandonallen)
13
  *
14
  * This program is free software; you can redistribute it and/or modify
15
  * it under the terms of the GNU General Public License as published by
28
  * @package Edit_Author_Slug
29
  * @subpackage Main
30
  * @author Brandon Allen
31
+ * @version 1.6.0
32
  */
33
 
34
  // Exit if accessed directly.
35
  defined( 'ABSPATH' ) || exit;
36
 
37
  // Load the plugin class file.
38
+ require 'includes/classes/class-ba-edit-author-slug.php';
39
 
40
  /**
41
  * Runs on Edit Author Slug activation.
includes/admin.php CHANGED
@@ -36,14 +36,22 @@ function ba_eas_show_user_nicename( $user ) {
36
  // Setup options array.
37
  $options = array(
38
  'username' => ba_eas_get_nicename_by_structure( $user->ID, 'username' ),
 
39
  'displayname' => ba_eas_get_nicename_by_structure( $user->ID, 'displayname' ),
40
  'firstname' => ba_eas_get_nicename_by_structure( $user->ID, 'firstname' ),
41
  'lastname' => ba_eas_get_nicename_by_structure( $user->ID, 'lastname' ),
42
  'firstlast' => ba_eas_get_nicename_by_structure( $user->ID, 'firstlast' ),
43
  'lastfirst' => ba_eas_get_nicename_by_structure( $user->ID, 'lastfirst' ),
44
  'userid' => ba_eas_get_nicename_by_structure( $user->ID, 'userid' ),
 
45
  );
46
 
 
 
 
 
 
 
47
  /**
48
  * Filters the array of user nicename options.
49
  *
@@ -69,7 +77,8 @@ function ba_eas_show_user_nicename( $user ) {
69
  <th scope="row"><?php esc_html_e( 'Author Slug', 'edit-author-slug' ); ?></th>
70
  <td>
71
  <fieldset><legend class="screen-reader-text"><span><?php esc_html_e( 'Author Slug', 'edit-author-slug' ); ?></span></legend>
72
- <?php foreach ( (array) $options as $item ) :
 
73
 
74
  // Checked?
75
  $checked_text = checked( $item, $nicename, false );
@@ -78,19 +87,19 @@ function ba_eas_show_user_nicename( $user ) {
78
  if ( ! empty( $checked_text ) ) {
79
  $checked = false;
80
  }
81
- ?>
82
  <label title="<?php echo ba_eas_esc_nicename( $item ); ?>">
83
- <input type="radio" id="ba_eas_author_slug" name="ba_eas_author_slug" value="<?php echo ba_eas_esc_nicename( $item ); ?>" autocapitalize="none" autocorrect="off" maxlength="50"<?php echo $checked_text; ?>>
84
  <span><?php echo ba_eas_esc_nicename( $item ); ?></span>
85
  </label><br />
86
  <?php endforeach; ?>
87
  <label for="ba_eas_author_slug_custom_radio">
88
- <input type="radio" id="ba_eas_author_slug_custom_radio" name="ba_eas_author_slug" value="\c\u\s\t\o\m" autocapitalize="none" autocorrect="off" maxlength="50"<?php checked( $checked ); ?>>
89
  <?php esc_html_e( 'Custom:', 'edit-author-slug' ); ?>
90
  <span class="screen-reader-text"><?php esc_html_e( 'Enter a custom author slug in the following field', 'edit-author-slug' ); ?></span>
91
  </label>
92
  <label for="ba_eas_author_slug_custom" class="screen-reader-text"><?php esc_html_e( 'Custom author slug:', 'edit-author-slug' ); ?></label>
93
- <input type="text" name="ba_eas_author_slug_custom" id="ba_eas_author_slug_custom" value="<?php echo ba_eas_esc_nicename( $nicename ); ?>" class="regular-text" />
94
  </fieldset>
95
  </td>
96
  </tr></tbody>
@@ -107,9 +116,9 @@ function ba_eas_show_user_nicename( $user ) {
107
  *
108
  * @since 0.1.0
109
  *
110
- * @param WP_Errors $errors The WP_Errors object.
111
- * @param bool $update True if user is being updated.
112
- * @param object $user An stdClass with user properties.
113
  */
114
  function ba_eas_update_user_nicename( $errors, $update, $user ) {
115
 
@@ -182,13 +191,15 @@ function ba_eas_update_user_nicename( $errors, $update, $user ) {
182
  * @param bool $ascii True if the nicename contains only characters
183
  * that can be converted to allowed ASCII characters.
184
  */
185
- $user_nicename = ba_eas_sanitize_nicename( apply_filters(
186
- 'ba_eas_pre_update_user_nicename',
187
- $user_nicename,
188
- $user->ID,
189
- $raw_nicename,
190
- $ascii
191
- ) );
 
 
192
 
193
  // Reset `$ascii` if the nicename was filtered.
194
  if ( $raw_nicename_sanitized !== $user_nicename ) {
@@ -222,6 +233,23 @@ function ba_eas_update_user_nicename( $errors, $update, $user ) {
222
  return;
223
  }
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  // Bail if the nicename hasn't changed.
226
  if ( $user_nicename === $old_user_nicename ) {
227
  return;
@@ -364,8 +392,9 @@ function ba_eas_show_user_nicename_scripts( $hook_suffix = '' ) {
364
  wp_register_script(
365
  'edit-author-slug',
366
  ba_eas()->plugin_url . "js/edit-author-slug{$min}.js",
367
- array( 'jquery' ),
368
- BA_Edit_Author_Slug::VERSION
 
369
  );
370
  wp_enqueue_script( 'edit-author-slug' );
371
  }
@@ -393,7 +422,7 @@ function ba_eas_add_settings_menu() {
393
  * @since 0.9.0
394
  */
395
  function ba_eas_settings_page_html() {
396
- ?>
397
 
398
  <div class="wrap">
399
 
@@ -409,7 +438,7 @@ function ba_eas_settings_page_html() {
409
  </form>
410
  </div>
411
 
412
- <?php
413
  }
414
 
415
  /**
@@ -434,7 +463,7 @@ function ba_eas_register_admin_settings() {
434
  'edit-author-slug',
435
  'ba_eas_author_base',
436
  array(
437
- 'label_for' => '_ba_eas_author_base',
438
  )
439
  );
440
  register_setting( 'edit-author-slug', '_ba_eas_author_base', 'ba_eas_sanitize_author_base' );
@@ -446,10 +475,7 @@ function ba_eas_register_admin_settings() {
446
  __( 'Remove Front', 'edit-author-slug' ),
447
  'ba_eas_admin_setting_callback_remove_front',
448
  'edit-author-slug',
449
- 'ba_eas_author_base',
450
- array(
451
- 'label_for' => '_ba_eas_remove_front',
452
- )
453
  );
454
  register_setting( 'edit-author-slug', '_ba_eas_remove_front', 'intval' );
455
  }
@@ -460,10 +486,7 @@ function ba_eas_register_admin_settings() {
460
  __( 'Role-Based Author Base', 'edit-author-slug' ),
461
  'ba_eas_admin_setting_callback_do_role_based',
462
  'edit-author-slug',
463
- 'ba_eas_author_base',
464
- array(
465
- 'label_for' => '_ba_eas_do_role_based',
466
- )
467
  );
468
  register_setting( 'edit-author-slug', '_ba_eas_do_role_based', 'intval' );
469
 
@@ -491,10 +514,7 @@ function ba_eas_register_admin_settings() {
491
  __( 'Automatically Update', 'edit-author-slug' ),
492
  'ba_eas_admin_setting_callback_do_auto_update',
493
  'edit-author-slug',
494
- 'ba_eas_auto_update',
495
- array(
496
- 'label_for' => '_ba_eas_do_auto_update',
497
- )
498
  );
499
  register_setting( 'edit-author-slug', '_ba_eas_do_auto_update', 'intval' );
500
 
@@ -506,7 +526,7 @@ function ba_eas_register_admin_settings() {
506
  'edit-author-slug',
507
  'ba_eas_auto_update',
508
  array(
509
- 'label_for' => '_ba_eas_default_user_nicename',
510
  )
511
  );
512
  register_setting( 'edit-author-slug', '_ba_eas_default_user_nicename', 'sanitize_key' );
@@ -525,10 +545,7 @@ function ba_eas_register_admin_settings() {
525
  __( 'Bulk Update', 'edit-author-slug' ),
526
  'ba_eas_admin_setting_callback_bulk_update',
527
  'edit-author-slug',
528
- 'ba_eas_bulk_update',
529
- array(
530
- 'label_for' => '_ba_eas_bulk_update',
531
- )
532
  );
533
  register_setting( 'edit-author-slug', '_ba_eas_bulk_update', 'ba_eas_auto_update_user_nicename_bulk' );
534
 
@@ -540,7 +557,7 @@ function ba_eas_register_admin_settings() {
540
  'edit-author-slug',
541
  'ba_eas_bulk_update',
542
  array(
543
- 'label_for' => '_ba_eas_bulk_update_structure',
544
  )
545
  );
546
  register_setting( 'edit-author-slug', '_ba_eas_bulk_update_structure', '__return_false' );
@@ -552,11 +569,11 @@ function ba_eas_register_admin_settings() {
552
  * @since 0.9.0
553
  */
554
  function ba_eas_admin_setting_callback_author_base_section() {
555
- ?>
556
 
557
  <p><?php esc_html_e( 'Change your author base to something more fun!', 'edit-author-slug' ); ?></p>
558
 
559
- <?php
560
  }
561
 
562
  /**
@@ -565,11 +582,11 @@ function ba_eas_admin_setting_callback_author_base_section() {
565
  * @since 0.9.0
566
  */
567
  function ba_eas_admin_setting_callback_auto_update_section() {
568
- ?>
569
 
570
  <p><?php esc_html_e( "Allow Author Slugs to be automatically updated, and set the default Author Slug structure for users. Automatic updating will only occur when a user can't edit Author Slugs on their own.", 'edit-author-slug' ); ?> <br /><strong><em><?php esc_html_e( 'This could have SEO repercussions if users update their profiles frequently, and it will override any manual editing of the Author Slug you may have previously completed.', 'edit-author-slug' ); ?></em></strong></p>
571
 
572
- <?php
573
  }
574
 
575
  /**
@@ -586,13 +603,15 @@ function ba_eas_admin_setting_callback_author_base() {
586
  if ( ! empty( $front ) ) {
587
  $front = trailingslashit( $front );
588
  }
589
- ?>
590
 
591
- <input id="_ba_eas_author_base" name="_ba_eas_author_base" type="text" value="<?php echo esc_attr( $author_base ); ?>" class="regular-text code" />
 
592
  <em><?php esc_html_e( "Defaults to 'author'", 'edit-author-slug' ); ?></em>
593
  <br /><br />
594
  <strong>Demo:</strong>
595
- <em><?php
 
596
  echo sprintf(
597
  '%1$s%2$s%3$s%4$s',
598
  esc_url( home_url( '/' ) ),
@@ -600,9 +619,10 @@ function ba_eas_admin_setting_callback_author_base() {
600
  '<span class="eas-demo-author-base">' . esc_html( $author_base ) . '</span>',
601
  esc_html( user_trailingslashit( '/author-slug' ) )
602
  );
603
- ?></em>
 
604
 
605
- <?php
606
  }
607
 
608
  /**
@@ -613,12 +633,14 @@ function ba_eas_admin_setting_callback_author_base() {
613
  * @return void
614
  */
615
  function ba_eas_admin_setting_callback_remove_front() {
616
- ?>
617
 
618
- <input name="_ba_eas_remove_front" id="_ba_eas_remove_front" value="1"<?php checked( ba_eas()->remove_front ); ?> type="checkbox" />
619
- <?php esc_html_e( 'Remove the "front" portion of the author permalink structure.', 'edit-author-slug' ); ?>
 
 
620
 
621
- <?php
622
  }
623
 
624
  /**
@@ -627,12 +649,15 @@ function ba_eas_admin_setting_callback_remove_front() {
627
  * @since 1.0.0
628
  */
629
  function ba_eas_admin_setting_callback_do_role_based() {
630
- ?>
631
 
632
- <input class="eas-checkbox" name="_ba_eas_do_role_based" id="_ba_eas_do_role_based" value="1"<?php checked( ba_eas()->do_role_based ); ?> type="checkbox" />
633
- <?php esc_html_e( "Set user's Author Base according to their role.", 'edit-author-slug' ); ?>
 
 
634
  <br /><br />
635
- <?php echo sprintf(
 
636
  /* translators: 1: rewrite tag, 2: rewrite tag demo usage, 3: demo URL using rewrite tag */
637
  esc_html__(
638
  'Use the %1$s rewrite tag to customize the role-based author base. If you set the author base to "%2$s", the resulting author structure will be something like "%3$s".',
@@ -641,9 +666,10 @@ function ba_eas_admin_setting_callback_do_role_based() {
641
  '<code>%ba_eas_author_role%</code>',
642
  '<em>cool-people/&#37;ba_eas_author_role&#37;</em>',
643
  '<em>http://example.com/cool-people/role-slug/author-slug</em>'
644
- ); ?>
 
645
 
646
- <?php
647
  }
648
 
649
  /**
@@ -679,12 +705,12 @@ function ba_eas_admin_setting_callback_role_slugs() {
679
  if ( empty( $details['slug'] ) ) {
680
  $details['slug'] = sanitize_title( translate_user_role( $details['name'] ) );
681
  }
682
- ?>
683
 
684
- <input name="_ba_eas_role_slugs[<?php echo esc_attr( $role ); ?>][slug]" id="_ba_eas_role_slugs[<?php echo esc_attr( $role ); ?>][slug]" type="text" value="<?php echo ba_eas_esc_nicename( $details['slug'] ); ?>" class="regular-text code" />
685
- <label for="_ba_eas_role_slugs[<?php echo esc_attr( $role ); ?>][slug]"><?php echo esc_html( translate_user_role( $details['name'] ) ); ?></label><br />
686
 
687
- <?php
688
  }
689
  }
690
 
@@ -719,11 +745,9 @@ function ba_eas_admin_setting_sanitize_callback_role_slugs( $role_slugs = array(
719
  $slug = $defaults[ $role ]['slug'];
720
  }
721
 
722
- // Remove the role if we don't have a slug.
723
  if ( empty( $slug ) ) {
724
  unset( $role_slugs[ $role ] );
725
-
726
- // We made it through, so set the slug.
727
  } else {
728
  $role_slugs[ $role ]['slug'] = $slug;
729
  }
@@ -744,12 +768,14 @@ function ba_eas_admin_setting_sanitize_callback_role_slugs( $role_slugs = array(
744
  * @since 0.9.0
745
  */
746
  function ba_eas_admin_setting_callback_do_auto_update() {
747
- ?>
748
 
749
- <input class="eas-checkbox" name="_ba_eas_do_auto_update" id="_ba_eas_do_auto_update" value="1"<?php checked( ba_eas()->do_auto_update ); ?> type="checkbox" />
750
- <?php esc_html_e( 'Automatically update Author Slug when a user updates their profile.', 'edit-author-slug' ); ?>
 
 
751
 
752
- <?php
753
  }
754
 
755
  /**
@@ -767,18 +793,27 @@ function ba_eas_admin_setting_callback_default_user_nicename() {
767
  $structure = 'username';
768
  }
769
 
 
 
 
770
  // Get the default nicename options.
771
  $options = ba_eas_default_user_nicename_options_list();
772
- ?>
773
 
774
  <span class="screen-reader-text"><?php esc_html_e( 'Default author slug options', 'edit-author-slug' ); ?></span>
775
- <select id="_ba_eas_default_user_nicename" name="_ba_eas_default_user_nicename">
776
  <?php foreach ( (array) $options as $id => $item ) : ?>
777
- <option id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $id ); ?>"<?php selected( $structure, $id ); ?>><?php echo esc_html( $item ); ?></option>
778
  <?php endforeach; ?>
779
  </select>
780
 
781
- <?php
 
 
 
 
 
 
782
  }
783
 
784
  /**
@@ -789,11 +824,11 @@ function ba_eas_admin_setting_callback_default_user_nicename() {
789
  * @return void
790
  */
791
  function ba_eas_admin_setting_callback_bulk_update_section() {
792
- ?>
793
 
794
  <p><?php esc_html_e( 'Update all users at once based on the specified Author Slug structure.', 'edit-author-slug' ); ?></p>
795
 
796
- <?php
797
  }
798
 
799
  /**
@@ -804,12 +839,14 @@ function ba_eas_admin_setting_callback_bulk_update_section() {
804
  * @return void
805
  */
806
  function ba_eas_admin_setting_callback_bulk_update() {
807
- ?>
808
 
809
- <input class="eas-checkbox" name="_ba_eas_bulk_update" id="_ba_eas_bulk_update" value="1" type="checkbox" />
810
- <?php esc_html_e( 'Update all users according to the below Author Slug setting. This will only be run after clicking "Save Changes".', 'edit-author-slug' ); ?>
 
 
811
 
812
- <?php
813
  }
814
 
815
  /**
@@ -827,18 +864,27 @@ function ba_eas_admin_setting_callback_bulk_update_structure() {
827
  $structure = 'username';
828
  }
829
 
 
 
 
830
  // Get the default nicename options.
831
  $options = ba_eas_default_user_nicename_options_list();
832
- ?>
833
 
834
  <span class="screen-reader-text"><?php esc_html_e( 'Default bulk update author slug options', 'edit-author-slug' ); ?></span>
835
- <select id="_ba_eas_bulk_update_structure" name="_ba_eas_bulk_update_structure">
836
  <?php foreach ( (array) $options as $id => $item ) : ?>
837
- <option id="<?php echo esc_attr( $id ); ?>" value="<?php echo esc_attr( $id ); ?>"<?php selected( $structure, $id ); ?>><?php echo esc_html( $item ); ?></option>
838
  <?php endforeach; ?>
839
  </select>
840
 
841
- <?php
 
 
 
 
 
 
842
  }
843
 
844
  /**
@@ -886,16 +932,20 @@ function ba_eas_default_user_nicename_options_list() {
886
  *
887
  * @param array $options An array of of user nicename structure options.
888
  */
889
- $options = apply_filters( 'ba_eas_default_user_nicename_options_list', array(
890
- 'username' => __( 'username (Default)', 'edit-author-slug' ),
891
- 'nickname' => __( 'nickname', 'edit-author-slug' ),
892
- 'displayname' => __( 'displayname', 'edit-author-slug' ),
893
- 'firstname' => __( 'firstname', 'edit-author-slug' ),
894
- 'lastname' => __( 'lastname', 'edit-author-slug' ),
895
- 'firstlast' => __( 'firstname-lastname', 'edit-author-slug' ),
896
- 'lastfirst' => __( 'lastname-firstname', 'edit-author-slug' ),
897
- 'userid' => __( 'userid (Experimental)', 'edit-author-slug' ),
898
- ) );
 
 
 
 
899
 
900
  return (array) $options;
901
  }
@@ -955,13 +1005,13 @@ function ba_eas_install() {
955
  }
956
 
957
  // Add the options.
958
- add_option( '_ba_eas_author_base', $ba_eas->author_base );
959
- add_option( '_ba_eas_db_version', BA_Edit_Author_Slug::DB_VERSION );
960
- add_option( '_ba_eas_do_auto_update', (int) $ba_eas->do_auto_update );
961
  add_option( '_ba_eas_default_user_nicename', $ba_eas->default_user_nicename );
962
- add_option( '_ba_eas_do_role_based', (int) $ba_eas->do_role_based );
963
- add_option( '_ba_eas_role_slugs', $ba_eas->role_slugs );
964
- add_option( '_ba_eas_remove_front', (int) $ba_eas->remove_front );
965
  }
966
 
967
  /**
@@ -977,7 +1027,7 @@ function ba_eas_upgrade() {
977
  $ba_eas = ba_eas();
978
 
979
  // We're up-to-date, so let's move on.
980
- if ( $ba_eas->current_db_version === BA_Edit_Author_Slug::DB_VERSION ) {
981
  return;
982
  }
983
 
@@ -993,10 +1043,10 @@ function ba_eas_upgrade() {
993
 
994
  // < 1.0.0.
995
  if ( $ba_eas->current_db_version < 133 ) {
996
- add_option( '_ba_eas_do_auto_update', (int) $ba_eas->do_auto_update );
997
  add_option( '_ba_eas_default_user_nicename', $ba_eas->default_user_nicename );
998
- add_option( '_ba_eas_do_role_based', (int) $ba_eas->do_role_based );
999
- add_option( '_ba_eas_role_slugs', $ba_eas->role_slugs );
1000
  }
1001
 
1002
  // < 1.2.0.
36
  // Setup options array.
37
  $options = array(
38
  'username' => ba_eas_get_nicename_by_structure( $user->ID, 'username' ),
39
+ 'nickname' => ba_eas_get_nicename_by_structure( $user->ID, 'nickname' ),
40
  'displayname' => ba_eas_get_nicename_by_structure( $user->ID, 'displayname' ),
41
  'firstname' => ba_eas_get_nicename_by_structure( $user->ID, 'firstname' ),
42
  'lastname' => ba_eas_get_nicename_by_structure( $user->ID, 'lastname' ),
43
  'firstlast' => ba_eas_get_nicename_by_structure( $user->ID, 'firstlast' ),
44
  'lastfirst' => ba_eas_get_nicename_by_structure( $user->ID, 'lastfirst' ),
45
  'userid' => ba_eas_get_nicename_by_structure( $user->ID, 'userid' ),
46
+ 'hash' => ba_eas_get_nicename_by_structure( $user->ID, 'hash' ),
47
  );
48
 
49
+ // Remove the username as a option if the user has requested it not be
50
+ // available via iThemes force unique nicename.
51
+ if ( ba_eas()->is_itsec_force_unique_nickname() ) {
52
+ unset( $options['username'] );
53
+ }
54
+
55
  /**
56
  * Filters the array of user nicename options.
57
  *
77
  <th scope="row"><?php esc_html_e( 'Author Slug', 'edit-author-slug' ); ?></th>
78
  <td>
79
  <fieldset><legend class="screen-reader-text"><span><?php esc_html_e( 'Author Slug', 'edit-author-slug' ); ?></span></legend>
80
+ <?php
81
+ foreach ( (array) $options as $item ) :
82
 
83
  // Checked?
84
  $checked_text = checked( $item, $nicename, false );
87
  if ( ! empty( $checked_text ) ) {
88
  $checked = false;
89
  }
90
+ ?>
91
  <label title="<?php echo ba_eas_esc_nicename( $item ); ?>">
92
+ <input type="radio" class="eas-author-slug" name="ba_eas_author_slug" value="<?php echo ba_eas_esc_nicename( $item ); ?>" autocapitalize="none" autocorrect="off" maxlength="50"<?php echo $checked_text; ?>>
93
  <span><?php echo ba_eas_esc_nicename( $item ); ?></span>
94
  </label><br />
95
  <?php endforeach; ?>
96
  <label for="ba_eas_author_slug_custom_radio">
97
+ <input type="radio" class="eas-author-slug-custom-radio" name="ba_eas_author_slug" value="\c\u\s\t\o\m" autocapitalize="none" autocorrect="off" maxlength="50"<?php checked( $checked ); ?>>
98
  <?php esc_html_e( 'Custom:', 'edit-author-slug' ); ?>
99
  <span class="screen-reader-text"><?php esc_html_e( 'Enter a custom author slug in the following field', 'edit-author-slug' ); ?></span>
100
  </label>
101
  <label for="ba_eas_author_slug_custom" class="screen-reader-text"><?php esc_html_e( 'Custom author slug:', 'edit-author-slug' ); ?></label>
102
+ <input type="text" name="ba_eas_author_slug_custom" class="eas-author-slug-custom" value="<?php echo ba_eas_esc_nicename( $nicename ); ?>" class="regular-text" />
103
  </fieldset>
104
  </td>
105
  </tr></tbody>
116
  *
117
  * @since 0.1.0
118
  *
119
+ * @param WP_Error $errors The WP_Error object.
120
+ * @param bool $update True if user is being updated.
121
+ * @param object $user An stdClass with user properties.
122
  */
123
  function ba_eas_update_user_nicename( $errors, $update, $user ) {
124
 
191
  * @param bool $ascii True if the nicename contains only characters
192
  * that can be converted to allowed ASCII characters.
193
  */
194
+ $user_nicename = ba_eas_sanitize_nicename(
195
+ apply_filters(
196
+ 'ba_eas_pre_update_user_nicename',
197
+ $user_nicename,
198
+ $user->ID,
199
+ $raw_nicename,
200
+ $ascii
201
+ )
202
+ );
203
 
204
  // Reset `$ascii` if the nicename was filtered.
205
  if ( $raw_nicename_sanitized !== $user_nicename ) {
233
  return;
234
  }
235
 
236
+ // iThemes Security's Force Unique Nickname needs special handling.
237
+ if ( ba_eas()->is_itsec_force_unique_nickname() ) {
238
+ // Unless there's an error, iThemes Security will always update the
239
+ // nicename. We need to make sure it's reset back to the old nicename,
240
+ // so it's not unexpectedly changed.
241
+ $user->user_nicename = $old_user_nicename;
242
+
243
+ // Bail and throw an error if the nicename is the same as the user login.
244
+ if ( $user->user_login === $user_nicename ) {
245
+ $errors->add(
246
+ 'user_nicename_itsec_block',
247
+ __( '<strong>ERROR</strong>: Your iThemes settings prevent your author slug from being the same as your username.', 'edit-author-slug' )
248
+ );
249
+ return;
250
+ }
251
+ }
252
+
253
  // Bail if the nicename hasn't changed.
254
  if ( $user_nicename === $old_user_nicename ) {
255
  return;
392
  wp_register_script(
393
  'edit-author-slug',
394
  ba_eas()->plugin_url . "js/edit-author-slug{$min}.js",
395
+ array(),
396
+ BA_Edit_Author_Slug::VERSION,
397
+ true
398
  );
399
  wp_enqueue_script( 'edit-author-slug' );
400
  }
422
  * @since 0.9.0
423
  */
424
  function ba_eas_settings_page_html() {
425
+ ?>
426
 
427
  <div class="wrap">
428
 
438
  </form>
439
  </div>
440
 
441
+ <?php
442
  }
443
 
444
  /**
463
  'edit-author-slug',
464
  'ba_eas_author_base',
465
  array(
466
+ 'label_for' => 'eas-author-base',
467
  )
468
  );
469
  register_setting( 'edit-author-slug', '_ba_eas_author_base', 'ba_eas_sanitize_author_base' );
475
  __( 'Remove Front', 'edit-author-slug' ),
476
  'ba_eas_admin_setting_callback_remove_front',
477
  'edit-author-slug',
478
+ 'ba_eas_author_base'
 
 
 
479
  );
480
  register_setting( 'edit-author-slug', '_ba_eas_remove_front', 'intval' );
481
  }
486
  __( 'Role-Based Author Base', 'edit-author-slug' ),
487
  'ba_eas_admin_setting_callback_do_role_based',
488
  'edit-author-slug',
489
+ 'ba_eas_author_base'
 
 
 
490
  );
491
  register_setting( 'edit-author-slug', '_ba_eas_do_role_based', 'intval' );
492
 
514
  __( 'Automatically Update', 'edit-author-slug' ),
515
  'ba_eas_admin_setting_callback_do_auto_update',
516
  'edit-author-slug',
517
+ 'ba_eas_auto_update'
 
 
 
518
  );
519
  register_setting( 'edit-author-slug', '_ba_eas_do_auto_update', 'intval' );
520
 
526
  'edit-author-slug',
527
  'ba_eas_auto_update',
528
  array(
529
+ 'label_for' => 'eas-default-user-nicename',
530
  )
531
  );
532
  register_setting( 'edit-author-slug', '_ba_eas_default_user_nicename', 'sanitize_key' );
545
  __( 'Bulk Update', 'edit-author-slug' ),
546
  'ba_eas_admin_setting_callback_bulk_update',
547
  'edit-author-slug',
548
+ 'ba_eas_bulk_update'
 
 
 
549
  );
550
  register_setting( 'edit-author-slug', '_ba_eas_bulk_update', 'ba_eas_auto_update_user_nicename_bulk' );
551
 
557
  'edit-author-slug',
558
  'ba_eas_bulk_update',
559
  array(
560
+ 'label_for' => 'eas-bulk-update-structure',
561
  )
562
  );
563
  register_setting( 'edit-author-slug', '_ba_eas_bulk_update_structure', '__return_false' );
569
  * @since 0.9.0
570
  */
571
  function ba_eas_admin_setting_callback_author_base_section() {
572
+ ?>
573
 
574
  <p><?php esc_html_e( 'Change your author base to something more fun!', 'edit-author-slug' ); ?></p>
575
 
576
+ <?php
577
  }
578
 
579
  /**
582
  * @since 0.9.0
583
  */
584
  function ba_eas_admin_setting_callback_auto_update_section() {
585
+ ?>
586
 
587
  <p><?php esc_html_e( "Allow Author Slugs to be automatically updated, and set the default Author Slug structure for users. Automatic updating will only occur when a user can't edit Author Slugs on their own.", 'edit-author-slug' ); ?> <br /><strong><em><?php esc_html_e( 'This could have SEO repercussions if users update their profiles frequently, and it will override any manual editing of the Author Slug you may have previously completed.', 'edit-author-slug' ); ?></em></strong></p>
588
 
589
+ <?php
590
  }
591
 
592
  /**
603
  if ( ! empty( $front ) ) {
604
  $front = trailingslashit( $front );
605
  }
606
+ ?>
607
 
608
+ <input id="eas-author-base" name="_ba_eas_author_base" type="text" value="<?php echo esc_attr( $author_base ); ?>" class="regular-text code" />
609
+ <br />
610
  <em><?php esc_html_e( "Defaults to 'author'", 'edit-author-slug' ); ?></em>
611
  <br /><br />
612
  <strong>Demo:</strong>
613
+ <em>
614
+ <?php
615
  echo sprintf(
616
  '%1$s%2$s%3$s%4$s',
617
  esc_url( home_url( '/' ) ),
619
  '<span class="eas-demo-author-base">' . esc_html( $author_base ) . '</span>',
620
  esc_html( user_trailingslashit( '/author-slug' ) )
621
  );
622
+ ?>
623
+ </em>
624
 
625
+ <?php
626
  }
627
 
628
  /**
633
  * @return void
634
  */
635
  function ba_eas_admin_setting_callback_remove_front() {
636
+ ?>
637
 
638
+ <input name="_ba_eas_remove_front" id="eas-remove-front" value="1"<?php checked( ba_eas()->remove_front ); ?> type="checkbox" />
639
+ <label for="eas-remove-front">
640
+ <?php esc_html_e( 'Remove the "front" portion of the author permalink structure.', 'edit-author-slug' ); ?>
641
+ </label>
642
 
643
+ <?php
644
  }
645
 
646
  /**
649
  * @since 1.0.0
650
  */
651
  function ba_eas_admin_setting_callback_do_role_based() {
652
+ ?>
653
 
654
+ <input class="eas-checkbox" name="_ba_eas_do_role_based" id="eas-do-role-based" value="1"<?php checked( ba_eas()->do_role_based ); ?> type="checkbox" />
655
+ <label for="eas-do-role-based">
656
+ <?php esc_html_e( "Set user's Author Base according to their role.", 'edit-author-slug' ); ?>
657
+ </label>
658
  <br /><br />
659
+ <?php
660
+ echo sprintf(
661
  /* translators: 1: rewrite tag, 2: rewrite tag demo usage, 3: demo URL using rewrite tag */
662
  esc_html__(
663
  'Use the %1$s rewrite tag to customize the role-based author base. If you set the author base to "%2$s", the resulting author structure will be something like "%3$s".',
666
  '<code>%ba_eas_author_role%</code>',
667
  '<em>cool-people/&#37;ba_eas_author_role&#37;</em>',
668
  '<em>http://example.com/cool-people/role-slug/author-slug</em>'
669
+ );
670
+ ?>
671
 
672
+ <?php
673
  }
674
 
675
  /**
705
  if ( empty( $details['slug'] ) ) {
706
  $details['slug'] = sanitize_title( translate_user_role( $details['name'] ) );
707
  }
708
+ ?>
709
 
710
+ <input name="_ba_eas_role_slugs[<?php echo esc_attr( $role ); ?>][slug]" id="eas-role-slugs-<?php echo esc_attr( $role ); ?>-slug" type="text" value="<?php echo ba_eas_esc_nicename( $details['slug'] ); ?>" class="regular-text code" />
711
+ <label for="eas-role-slugs-<?php echo esc_attr( $role ); ?>-slug"><?php echo esc_html( translate_user_role( $details['name'] ) ); ?></label><br />
712
 
713
+ <?php
714
  }
715
  }
716
 
745
  $slug = $defaults[ $role ]['slug'];
746
  }
747
 
748
+ // Set the role slug if it exists.
749
  if ( empty( $slug ) ) {
750
  unset( $role_slugs[ $role ] );
 
 
751
  } else {
752
  $role_slugs[ $role ]['slug'] = $slug;
753
  }
768
  * @since 0.9.0
769
  */
770
  function ba_eas_admin_setting_callback_do_auto_update() {
771
+ ?>
772
 
773
+ <input class="eas-checkbox" name="_ba_eas_do_auto_update" id="eas-do-auto-update" value="1"<?php checked( ba_eas()->do_auto_update ); ?> type="checkbox" />
774
+ <label for="eas-do-auto-update">
775
+ <?php esc_html_e( 'Automatically update Author Slug when a user updates their profile.', 'edit-author-slug' ); ?>
776
+ </label>
777
 
778
+ <?php
779
  }
780
 
781
  /**
793
  $structure = 'username';
794
  }
795
 
796
+ // Set up the class for the iThemes force unique nicename username error message.
797
+ $class = 'username' === $structure ? '' : ' hidden';
798
+
799
  // Get the default nicename options.
800
  $options = ba_eas_default_user_nicename_options_list();
801
+ ?>
802
 
803
  <span class="screen-reader-text"><?php esc_html_e( 'Default author slug options', 'edit-author-slug' ); ?></span>
804
+ <select id="eas-default-user-nicename" name="_ba_eas_default_user_nicename">
805
  <?php foreach ( (array) $options as $id => $item ) : ?>
806
+ <option value="<?php echo esc_attr( $id ); ?>"<?php selected( $structure, $id ); ?>><?php echo esc_html( $item ); ?></option>
807
  <?php endforeach; ?>
808
  </select>
809
 
810
+ <?php if ( ba_eas()->is_itsec_force_unique_nickname() ) : ?>
811
+ <div class="eas-author-slug-select-error<?php echo esc_attr( $class ); ?>" style="background: #fff; border-left: 4px solid #fff; border-left-color: #dc3232; box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); margin: 10px 15px 2px 0; padding: 5px 12px 5px;">
812
+ Your iThemes settings suggest you don't want the <code>username</code> being used as an author slug. Leaving it set to <code>username</code> will still work, but you may wish to change to something different.
813
+ </div>
814
+ <?php endif; ?>
815
+
816
+ <?php
817
  }
818
 
819
  /**
824
  * @return void
825
  */
826
  function ba_eas_admin_setting_callback_bulk_update_section() {
827
+ ?>
828
 
829
  <p><?php esc_html_e( 'Update all users at once based on the specified Author Slug structure.', 'edit-author-slug' ); ?></p>
830
 
831
+ <?php
832
  }
833
 
834
  /**
839
  * @return void
840
  */
841
  function ba_eas_admin_setting_callback_bulk_update() {
842
+ ?>
843
 
844
+ <input class="eas-checkbox" name="_ba_eas_bulk_update" id="eas-bulk-update" value="1" type="checkbox" />
845
+ <label for="eas-bulk-update">
846
+ <?php esc_html_e( 'Update all users according to the below Author Slug setting. This will only be run after clicking "Save Changes".', 'edit-author-slug' ); ?>
847
+ </label>
848
 
849
+ <?php
850
  }
851
 
852
  /**
864
  $structure = 'username';
865
  }
866
 
867
+ // Set up the class for the iThemes force unique nicename username error message.
868
+ $class = 'username' === $structure ? '' : ' hidden';
869
+
870
  // Get the default nicename options.
871
  $options = ba_eas_default_user_nicename_options_list();
872
+ ?>
873
 
874
  <span class="screen-reader-text"><?php esc_html_e( 'Default bulk update author slug options', 'edit-author-slug' ); ?></span>
875
+ <select id="eas-bulk-update-structure" name="_ba_eas_bulk_update_structure">
876
  <?php foreach ( (array) $options as $id => $item ) : ?>
877
+ <option value="<?php echo esc_attr( $id ); ?>"<?php selected( $structure, $id ); ?>><?php echo esc_html( $item ); ?></option>
878
  <?php endforeach; ?>
879
  </select>
880
 
881
+ <?php if ( ba_eas()->is_itsec_force_unique_nickname() ) : ?>
882
+ <div class="eas-author-slug-select-error<?php echo esc_attr( $class ); ?>" style="background: #fff; border-left: 4px solid #fff; border-left-color: #dc3232; box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 ); margin: 10px 15px 2px 0; padding: 5px 12px 5px;">
883
+ Your iThemes settings suggest you don't want the <code>username</code> being used as an author slug. Leaving it set to <code>username</code> will still work, but you may wish to change to something different.
884
+ </div>
885
+ <?php endif; ?>
886
+
887
+ <?php
888
  }
889
 
890
  /**
932
  *
933
  * @param array $options An array of of user nicename structure options.
934
  */
935
+ $options = apply_filters(
936
+ 'ba_eas_default_user_nicename_options_list',
937
+ array(
938
+ 'username' => __( 'username (Default)', 'edit-author-slug' ),
939
+ 'nickname' => __( 'nickname', 'edit-author-slug' ),
940
+ 'displayname' => __( 'displayname', 'edit-author-slug' ),
941
+ 'firstname' => __( 'firstname', 'edit-author-slug' ),
942
+ 'lastname' => __( 'lastname', 'edit-author-slug' ),
943
+ 'firstlast' => __( 'firstname-lastname', 'edit-author-slug' ),
944
+ 'lastfirst' => __( 'lastname-firstname', 'edit-author-slug' ),
945
+ 'userid' => __( 'userid', 'edit-author-slug' ),
946
+ 'hash' => __( 'hash', 'edit-author-slug' ),
947
+ )
948
+ );
949
 
950
  return (array) $options;
951
  }
1005
  }
1006
 
1007
  // Add the options.
1008
+ add_option( '_ba_eas_author_base', $ba_eas->author_base );
1009
+ add_option( '_ba_eas_db_version', BA_Edit_Author_Slug::DB_VERSION );
1010
+ add_option( '_ba_eas_do_auto_update', (int) $ba_eas->do_auto_update );
1011
  add_option( '_ba_eas_default_user_nicename', $ba_eas->default_user_nicename );
1012
+ add_option( '_ba_eas_do_role_based', (int) $ba_eas->do_role_based );
1013
+ add_option( '_ba_eas_role_slugs', $ba_eas->role_slugs );
1014
+ add_option( '_ba_eas_remove_front', (int) $ba_eas->remove_front );
1015
  }
1016
 
1017
  /**
1027
  $ba_eas = ba_eas();
1028
 
1029
  // We're up-to-date, so let's move on.
1030
+ if ( BA_Edit_Author_Slug::DB_VERSION === $ba_eas->current_db_version ) {
1031
  return;
1032
  }
1033
 
1043
 
1044
  // < 1.0.0.
1045
  if ( $ba_eas->current_db_version < 133 ) {
1046
+ add_option( '_ba_eas_do_auto_update', (int) $ba_eas->do_auto_update );
1047
  add_option( '_ba_eas_default_user_nicename', $ba_eas->default_user_nicename );
1048
+ add_option( '_ba_eas_do_role_based', (int) $ba_eas->do_role_based );
1049
+ add_option( '_ba_eas_role_slugs', $ba_eas->role_slugs );
1050
  }
1051
 
1052
  // < 1.2.0.
includes/classes/{class-edit-author-slug.php → class-ba-edit-author-slug.php} RENAMED
@@ -160,7 +160,7 @@ if ( ! class_exists( 'BA_Edit_Author_Slug' ) ) :
160
 
161
  // Only run these methods if they haven't been ran previously.
162
  if ( null === $instance ) {
163
- $instance = new self;
164
  }
165
 
166
  // Always return the instance.
@@ -263,13 +263,13 @@ if ( ! class_exists( 'BA_Edit_Author_Slug' ) ) :
263
  private function includes() {
264
 
265
  // Load the core functions.
266
- require_once( $this->plugin_dir . 'includes/deprecated.php' );
267
- require_once( $this->plugin_dir . 'includes/functions.php' );
268
- require_once( $this->plugin_dir . 'includes/hooks.php' );
269
 
270
  // Maybe load the admin functions.
271
  if ( is_admin() ) {
272
- require_once( $this->plugin_dir . 'includes/admin.php' );
273
  }
274
  }
275
 
@@ -307,8 +307,8 @@ if ( ! class_exists( 'BA_Edit_Author_Slug' ) ) :
307
 
308
  // Author Base Actions.
309
  add_action( 'after_setup_theme', array( $this, 'set_role_slugs' ) );
310
- add_action( 'init', 'ba_eas_wp_rewrite_overrides', 4 );
311
- add_action( 'init', array( $this, 'add_rewrite_tags' ), 20 );
312
 
313
  // Localize.
314
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
@@ -405,5 +405,24 @@ if ( ! class_exists( 'BA_Edit_Author_Slug' ) ) :
405
  // Add the role-based rewrite tag, and the expected role slugs.
406
  add_rewrite_tag( '%ba_eas_author_role%', '(' . implode( '|', array_unique( $role_slugs ) ) . ')' );
407
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  }
409
  endif; // End class BA_Edit_Author_Slug.
160
 
161
  // Only run these methods if they haven't been ran previously.
162
  if ( null === $instance ) {
163
+ $instance = new self();
164
  }
165
 
166
  // Always return the instance.
263
  private function includes() {
264
 
265
  // Load the core functions.
266
+ require_once $this->plugin_dir . 'includes/deprecated.php';
267
+ require_once $this->plugin_dir . 'includes/functions.php';
268
+ require_once $this->plugin_dir . 'includes/hooks.php';
269
 
270
  // Maybe load the admin functions.
271
  if ( is_admin() ) {
272
+ require_once $this->plugin_dir . 'includes/admin.php';
273
  }
274
  }
275
 
307
 
308
  // Author Base Actions.
309
  add_action( 'after_setup_theme', array( $this, 'set_role_slugs' ) );
310
+ add_action( 'init', 'ba_eas_wp_rewrite_overrides', 4 );
311
+ add_action( 'init', array( $this, 'add_rewrite_tags' ), 20 );
312
 
313
  // Localize.
314
  add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
405
  // Add the role-based rewrite tag, and the expected role slugs.
406
  add_rewrite_tag( '%ba_eas_author_role%', '(' . implode( '|', array_unique( $role_slugs ) ) . ')' );
407
  }
408
+
409
+ /**
410
+ * Checks if iThemes Security is enabled, and if the Force Unique
411
+ * Nickname WordPress Tweak is turned on.
412
+ *
413
+ * @since 1.6.0
414
+ *
415
+ * @return bool
416
+ */
417
+ public function is_itsec_force_unique_nickname() {
418
+ $retval = false;
419
+
420
+ if ( class_exists( 'ITSEC_Modules' ) ) {
421
+ $tweaks = ITSEC_Modules::get_settings( 'wordpress-tweaks' );
422
+ $retval = $tweaks['force_unique_nicename'];
423
+ }
424
+
425
+ return (bool) $retval;
426
+ }
427
  }
428
  endif; // End class BA_Edit_Author_Slug.
includes/deprecated.php CHANGED
@@ -123,7 +123,7 @@ function ba_eas_update_nicename_cache( $user_id = 0, $old_user_data = '', $new_n
123
  if ( empty( $new_nicename ) ) {
124
 
125
  // Get the new nicename.
126
- $user = get_userdata( $user_id );
127
  $new_nicename = $user->user_nicename;
128
  }
129
 
123
  if ( empty( $new_nicename ) ) {
124
 
125
  // Get the new nicename.
126
+ $user = get_userdata( $user_id );
127
  $new_nicename = $user->user_nicename;
128
  }
129
 
includes/functions.php CHANGED
@@ -45,8 +45,8 @@ function ba_eas_do_bulk_update( $do_bulk = false ) {
45
 
46
  // Sanitize the option value.
47
  $retval = ( is_numeric( $do_bulk ) || is_bool( $do_bulk ) )
48
- ? (bool) $do_bulk
49
- : false;
50
 
51
  /**
52
  * Filters the return of the `ba_eas_do_bulk_update()`.
@@ -132,10 +132,12 @@ function ba_eas_auto_update_user_nicename( $user_id = 0, $bulk = false, $structu
132
  remove_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
133
 
134
  // Update if there's a change.
135
- $user_id = wp_update_user( array(
136
- 'ID' => $user_id,
137
- 'user_nicename' => $nicename,
138
- ) );
 
 
139
 
140
  // Add it back in case other plugins do some updating.
141
  add_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
@@ -184,9 +186,11 @@ function ba_eas_auto_update_user_nicename_bulk( $do_bulk = false ) {
184
  }
185
 
186
  // Get an array of ids of all users.
187
- $users = get_users( array(
188
- 'fields' => 'ID',
189
- ) );
 
 
190
 
191
  /**
192
  * Filters the array of user ids who will have their user nicenames updated.
@@ -241,7 +245,7 @@ function ba_eas_auto_update_user_nicename_bulk( $do_bulk = false ) {
241
  }
242
 
243
  // Run the update.
244
- $sql = "
245
  UPDATE $wpdb->users
246
  SET user_nicename = CASE ID
247
  {$when_sql}
@@ -425,32 +429,26 @@ function ba_eas_get_nicename_by_structure( $user_id = 0, $structure = '' ) {
425
  switch ( $structure ) {
426
 
427
  case 'username':
428
-
429
  $nicename = $user->user_login;
430
  break;
431
 
432
  case 'nickname':
433
-
434
  $nicename = $user->nickname;
435
  break;
436
 
437
  case 'displayname':
438
-
439
  $nicename = $user->display_name;
440
  break;
441
 
442
  case 'firstname':
443
-
444
  $nicename = $user->first_name;
445
  break;
446
 
447
  case 'lastname':
448
-
449
  $nicename = $user->last_name;
450
  break;
451
 
452
  case 'firstlast':
453
-
454
  if ( ! empty( $user->first_name ) && ! empty( $user->last_name ) ) {
455
  $nicename = $user->first_name . '-' . $user->last_name;
456
  }
@@ -458,7 +456,6 @@ function ba_eas_get_nicename_by_structure( $user_id = 0, $structure = '' ) {
458
  break;
459
 
460
  case 'lastfirst':
461
-
462
  if ( ! empty( $user->first_name ) && ! empty( $user->last_name ) ) {
463
  $nicename = $user->last_name . '-' . $user->first_name;
464
  }
@@ -466,10 +463,13 @@ function ba_eas_get_nicename_by_structure( $user_id = 0, $structure = '' ) {
466
  break;
467
 
468
  case 'userid':
469
-
470
  $nicename = $user->ID;
471
  break;
472
- } // End switch().
 
 
 
 
473
 
474
  // Sanitize and trim the new user nicename.
475
  $nicename = ba_eas_trim_nicename( ba_eas_sanitize_nicename( $nicename ) );
@@ -785,11 +785,9 @@ function ba_eas_get_user_role( $roles = array(), $user_id = 0 ) {
785
  // Set the default role to empty.
786
  $role = '';
787
 
788
- // Grab the first listed role.
789
  if ( ! empty( $roles ) && is_array( $roles ) ) {
790
  $role = array_shift( $roles );
791
-
792
- // If no roles were passed, try using the user id to get them.
793
  } elseif ( ! empty( $user_id ) ) {
794
 
795
  // Get the WP_User object.
@@ -893,9 +891,9 @@ if ( ! function_exists( 'array_replace_recursive' ) ) {
893
  $bref[ $key ] = $head[ $key ];
894
  }
895
  }
896
- } while ( count( $head_stack ) );
897
  }
898
 
899
  return $base;
900
  }
901
- } // End if().
45
 
46
  // Sanitize the option value.
47
  $retval = ( is_numeric( $do_bulk ) || is_bool( $do_bulk ) )
48
+ ? (bool) $do_bulk
49
+ : false;
50
 
51
  /**
52
  * Filters the return of the `ba_eas_do_bulk_update()`.
132
  remove_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
133
 
134
  // Update if there's a change.
135
+ $user_id = wp_update_user(
136
+ array(
137
+ 'ID' => $user_id,
138
+ 'user_nicename' => $nicename,
139
+ )
140
+ );
141
 
142
  // Add it back in case other plugins do some updating.
143
  add_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
186
  }
187
 
188
  // Get an array of ids of all users.
189
+ $users = get_users(
190
+ array(
191
+ 'fields' => 'ID',
192
+ )
193
+ );
194
 
195
  /**
196
  * Filters the array of user ids who will have their user nicenames updated.
245
  }
246
 
247
  // Run the update.
248
+ $sql = "
249
  UPDATE $wpdb->users
250
  SET user_nicename = CASE ID
251
  {$when_sql}
429
  switch ( $structure ) {
430
 
431
  case 'username':
 
432
  $nicename = $user->user_login;
433
  break;
434
 
435
  case 'nickname':
 
436
  $nicename = $user->nickname;
437
  break;
438
 
439
  case 'displayname':
 
440
  $nicename = $user->display_name;
441
  break;
442
 
443
  case 'firstname':
 
444
  $nicename = $user->first_name;
445
  break;
446
 
447
  case 'lastname':
 
448
  $nicename = $user->last_name;
449
  break;
450
 
451
  case 'firstlast':
 
452
  if ( ! empty( $user->first_name ) && ! empty( $user->last_name ) ) {
453
  $nicename = $user->first_name . '-' . $user->last_name;
454
  }
456
  break;
457
 
458
  case 'lastfirst':
 
459
  if ( ! empty( $user->first_name ) && ! empty( $user->last_name ) ) {
460
  $nicename = $user->last_name . '-' . $user->first_name;
461
  }
463
  break;
464
 
465
  case 'userid':
 
466
  $nicename = $user->ID;
467
  break;
468
+
469
+ case 'hash':
470
+ $nicename = hash( 'sha1', $user->ID . '-' . $user->user_login );
471
+ break;
472
+ } // End switch.
473
 
474
  // Sanitize and trim the new user nicename.
475
  $nicename = ba_eas_trim_nicename( ba_eas_sanitize_nicename( $nicename ) );
785
  // Set the default role to empty.
786
  $role = '';
787
 
788
+ // Attempt to get the user role. Grab the first role in the array.
789
  if ( ! empty( $roles ) && is_array( $roles ) ) {
790
  $role = array_shift( $roles );
 
 
791
  } elseif ( ! empty( $user_id ) ) {
792
 
793
  // Get the WP_User object.
891
  $bref[ $key ] = $head[ $key ];
892
  }
893
  }
894
+ } while ( count( $head_stack ) ); // phpcs:ignore Squiz.PHP.DisallowSizeFunctionsInLoops
895
  }
896
 
897
  return $base;
898
  }
899
+ } // End if.
includes/hooks.php CHANGED
@@ -25,28 +25,28 @@ if ( is_admin() ) {
25
  add_action( 'admin_init', 'ba_eas_upgrade', 999 );
26
 
27
  // Nicename Actions.
28
- add_action( 'edit_user_profile', 'ba_eas_show_user_nicename' );
29
- add_action( 'show_user_profile', 'ba_eas_show_user_nicename' );
30
- add_action( 'user_profile_update_errors', 'ba_eas_update_user_nicename', 10, 3 );
31
- add_action( 'admin_enqueue_scripts', 'ba_eas_show_user_nicename_scripts' );
32
 
33
  // Nicename column filters.
34
- add_filter( 'manage_users_columns', 'ba_eas_author_slug_column' );
35
  add_filter( 'manage_users_custom_column', 'ba_eas_author_slug_custom_column', 10, 3 );
36
 
37
  // Settings.
38
- add_action( 'admin_menu', 'ba_eas_add_settings_menu' );
39
- add_action( 'admin_init', 'ba_eas_register_admin_settings' );
40
  add_filter( 'plugin_action_links', 'ba_eas_add_settings_link', 10, 2 );
41
 
42
  // Settings updated.
43
- add_action( 'admin_action_update', 'ba_eas_settings_updated' );
44
  add_action( 'ba_eas_settings_updated', 'ba_eas_flush_rewrite_rules' );
45
  }
46
 
47
  // Nicename auto-update actions.
48
  add_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
49
- add_action( 'user_register', 'ba_eas_auto_update_user_nicename' );
50
 
51
  // Author permalink filtering for role-based author bases.
52
  add_filter( 'author_link', 'ba_eas_author_link', 20, 2 );
25
  add_action( 'admin_init', 'ba_eas_upgrade', 999 );
26
 
27
  // Nicename Actions.
28
+ add_action( 'edit_user_profile', 'ba_eas_show_user_nicename' );
29
+ add_action( 'show_user_profile', 'ba_eas_show_user_nicename' );
30
+ add_action( 'user_profile_update_errors', 'ba_eas_update_user_nicename', 20, 3 );
31
+ add_action( 'admin_enqueue_scripts', 'ba_eas_show_user_nicename_scripts' );
32
 
33
  // Nicename column filters.
34
+ add_filter( 'manage_users_columns', 'ba_eas_author_slug_column' );
35
  add_filter( 'manage_users_custom_column', 'ba_eas_author_slug_custom_column', 10, 3 );
36
 
37
  // Settings.
38
+ add_action( 'admin_menu', 'ba_eas_add_settings_menu' );
39
+ add_action( 'admin_init', 'ba_eas_register_admin_settings' );
40
  add_filter( 'plugin_action_links', 'ba_eas_add_settings_link', 10, 2 );
41
 
42
  // Settings updated.
43
+ add_action( 'admin_action_update', 'ba_eas_settings_updated' );
44
  add_action( 'ba_eas_settings_updated', 'ba_eas_flush_rewrite_rules' );
45
  }
46
 
47
  // Nicename auto-update actions.
48
  add_action( 'profile_update', 'ba_eas_auto_update_user_nicename' );
49
+ add_action( 'user_register', 'ba_eas_auto_update_user_nicename' );
50
 
51
  // Author permalink filtering for role-based author bases.
52
  add_filter( 'author_link', 'ba_eas_author_link', 20, 2 );
js/edit-author-slug.js CHANGED
@@ -1,50 +1,70 @@
1
- /* jshint devel: true */
 
2
 
3
- jQuery( document ).ready( function( $ ) {
 
 
 
4
 
5
- // Front show/hide.
6
- if ( $( 'input[name="_ba_eas_remove_front"]' ).prop( 'checked' ) ) {
7
- $( 'span[class="eas-demo-author-base-front"]' ).addClass( 'hidden' );
8
- }
 
9
 
10
- // Watch for clicks on the `_ba_eas_remove_front` checkbox.
11
- $( 'input[name="_ba_eas_remove_front"]' ).on( 'click', function() {
12
- if ( $( this ).prop( 'checked' ) ) {
13
- $( 'span[class="eas-demo-author-base-front"]' ).fadeOut( 'fast', function() {
14
- $( this ).addClass( 'hidden' );
15
- });
16
- } else {
17
- $( 'span[class="eas-demo-author-base-front hidden"]' ).fadeIn( 'slow', function() {
18
- $( this ).removeClass( 'hidden' );
19
  });
20
  }
21
- });
22
 
23
- // Make example nicenames clickable.
24
- $( 'input[name="ba_eas_author_slug"]' ).click( function() {
25
- if ( 'ba_eas_author_slug_custom_radio' !== $( this ).attr( 'id' ) ) {
26
- $( 'input[name="ba_eas_author_slug_custom"]' ).val( $( this ).val() ).text( $( this ).siblings( 'span' ).text() );
27
- }
28
- });
29
 
30
- // If focus moves to the custom author slug input, select the radio.
31
- $( 'input[name="ba_eas_author_slug_custom"]' ).focus( function() {
32
- $( '#ba_eas_author_slug_custom_radio' ).attr( 'checked', 'checked' );
33
- });
34
 
35
- // Hide the related fields if `eas-checkbox` is not checked.
36
- $( 'input[class="eas-checkbox"]' ).not( ':checked' ).parents( 'tr' ).next( 'tr' ).addClass( 'hidden' );
 
 
 
 
 
 
37
 
38
- // Watch for clicks on the `eas-checkbox` options.
39
- $( 'input[class="eas-checkbox"]' ).on( 'click', function() {
40
- if ( $( this ).prop( 'checked' ) ) {
41
- $( this ).parents( 'tr' ).next( 'tr' ).fadeIn( 'slow', function() {
42
- $( this ).removeClass( 'hidden' );
 
43
  });
44
- } else {
45
- $( this ).parents( 'tr' ).next( 'tr' ).fadeOut( 'fast', function() {
46
- $( this ).addClass( 'hidden' );
 
 
 
 
 
 
 
 
 
 
 
 
47
  });
48
- }
49
  });
50
- });
1
+ ( function() {
2
+ var toggleHidden;
3
 
4
+ // Toggle the .hidden class.
5
+ toggleHidden = function( el ) {
6
+ el.classList.toggle( 'hidden' );
7
+ };
8
 
9
+ // Run our code after the DOM is loaded.
10
+ document.addEventListener( 'DOMContentLoaded', function() {
11
+ var customInput = document.querySelector( 'input[name="ba_eas_author_slug_custom"]' ),
12
+ front = document.querySelector( '.eas-demo-author-base-front' ),
13
+ removeFront = document.querySelector( 'input[name="_ba_eas_remove_front"]' );
14
 
15
+ // Hide the permalink front if remove front is on.
16
+ if ( removeFront ) {
17
+ if ( removeFront.checked ) {
18
+ toggleHidden( front );
19
+ }
20
+
21
+ // Show/hide permalink front when remove front checkbox is toggled.
22
+ removeFront.addEventListener( 'click', function() {
23
+ toggleHidden( front );
24
  });
25
  }
 
26
 
27
+ // Toggle checkbox sibling table rows.
28
+ document.querySelectorAll( 'input[class="eas-checkbox"]' ).forEach( function( item ) {
29
+ var siblingRow = item.parentNode.parentNode.nextElementSibling;
 
 
 
30
 
31
+ // If the item isn't checked, hide it.
32
+ if ( ! item.checked ) {
33
+ toggleHidden( siblingRow );
34
+ }
35
 
36
+ // Listen for checkbox clicks, and hide the appropriate item.
37
+ item.addEventListener( 'click', function() {
38
+ toggleHidden( siblingRow );
39
+ });
40
+ });
41
+
42
+ // Add click events to the user profile author slug radios.
43
+ document.querySelectorAll( 'input[name="ba_eas_author_slug"]' ).forEach( function( item ) {
44
 
45
+ // On click, set the custom author slug input value, to the value of
46
+ // the radio item that was clicked.
47
+ item.addEventListener( 'click', function() {
48
+ if ( ! item.classList.contains( 'eas-author-slug-custom-radio' ) ) {
49
+ customInput.value = item.value;
50
+ }
51
  });
52
+ });
53
+
54
+ // When the custom author slug input is focused, set the custom radio as selected.
55
+ customInput && customInput.addEventListener( 'focus', function() {
56
+ document.querySelector( '.eas-author-slug-custom-radio' ).checked = 'checked';
57
+ });
58
+
59
+ // Watch select boxes, and add a warning if username is selected, but
60
+ // only when iThemes `force unique nicename` is turned on.
61
+ document.querySelectorAll( 'select' ).forEach( function( item ) {
62
+ item.addEventListener( 'change', function( event ) {
63
+ var errorDiv = event.target.nextElementSibling;
64
+ if ( errorDiv && errorDiv.classList.contains( 'eas-author-slug-select-error' ) ) {
65
+ toggleHidden( errorDiv );
66
+ }
67
  });
68
+ });
69
  });
70
+ }() );
js/edit-author-slug.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! edit-author-slug - v1.5.2 - 2017-06-21 5:33:46 AM UTC - https://github.com/thebrandonallen/edit-author-slug/ */
2
- jQuery(document).ready(function(s){s('input[name="_ba_eas_remove_front"]').prop("checked")&&s('span[class="eas-demo-author-base-front"]').addClass("hidden"),s('input[name="_ba_eas_remove_front"]').on("click",function(){s(this).prop("checked")?s('span[class="eas-demo-author-base-front"]').fadeOut("fast",function(){s(this).addClass("hidden")}):s('span[class="eas-demo-author-base-front hidden"]').fadeIn("slow",function(){s(this).removeClass("hidden")})}),s('input[name="ba_eas_author_slug"]').click(function(){"ba_eas_author_slug_custom_radio"!==s(this).attr("id")&&s('input[name="ba_eas_author_slug_custom"]').val(s(this).val()).text(s(this).siblings("span").text())}),s('input[name="ba_eas_author_slug_custom"]').focus(function(){s("#ba_eas_author_slug_custom_radio").attr("checked","checked")}),s('input[class="eas-checkbox"]').not(":checked").parents("tr").next("tr").addClass("hidden"),s('input[class="eas-checkbox"]').on("click",function(){s(this).prop("checked")?s(this).parents("tr").next("tr").fadeIn("slow",function(){s(this).removeClass("hidden")}):s(this).parents("tr").next("tr").fadeOut("fast",function(){s(this).addClass("hidden")})})});
1
+ /*! edit-author-slug - v1.6.0 - 2018-10-12 2:57:52 AM UTC - https://github.com/thebrandonallen/edit-author-slug/ */
2
+ !function(){var c;c=function(e){e.classList.toggle("hidden")},document.addEventListener("DOMContentLoaded",function(){var t=document.querySelector('input[name="ba_eas_author_slug_custom"]'),e=document.querySelector(".eas-demo-author-base-front"),n=document.querySelector('input[name="_ba_eas_remove_front"]');n&&(n.checked&&c(e),n.addEventListener("click",function(){c(e)})),document.querySelectorAll('input[class="eas-checkbox"]').forEach(function(e){var t=e.parentNode.parentNode.nextElementSibling;e.checked||c(t),e.addEventListener("click",function(){c(t)})}),document.querySelectorAll('input[name="ba_eas_author_slug"]').forEach(function(e){e.addEventListener("click",function(){e.classList.contains("eas-author-slug-custom-radio")||(t.value=e.value)})}),t&&t.addEventListener("focus",function(){document.querySelector(".eas-author-slug-custom-radio").checked="checked"}),document.querySelectorAll("select").forEach(function(e){e.addEventListener("change",function(e){var t=e.target.nextElementSibling;t&&t.classList.contains("eas-author-slug-select-error")&&c(t)})})})}();
languages/edit-author-slug.pot CHANGED
@@ -1,16 +1,16 @@
1
- # Copyright (C) 2009-2017 Brandon Allen
2
  # This file is distributed under the same license as the Edit Author Slug package.
3
  # Submit translations to https://translate.wordpress.org/projects/wp-plugins/edit-author-slug.
4
  msgid ""
5
  msgstr ""
6
- "Project-Id-Version: Edit Author Slug 1.5.2\n"
7
  "Report-Msgid-Bugs-To: "
8
  "https://github.com/thebrandonallen/edit-author-slug/issues\n"
9
- "POT-Creation-Date: 2017-06-21 05:33:46+00:00\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=utf-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
14
  "Last-Translator: BRANDON ALLEN <plugins@brandonallen.me>\n"
15
  "Language-Team: ENGLISH <plugins@brandonallen.me>\n"
16
  "Language: en\n"
@@ -24,132 +24,138 @@ msgstr ""
24
  "X-Poedit-SearchPath-0: .\n"
25
  "X-Poedit-Bookmarks: \n"
26
  "X-Textdomain-Support: yes\n"
27
- "X-Generator: grunt-wp-i18n1.0.0\n"
28
 
29
- #: includes/admin.php:66
30
  msgid ""
31
  "Choose an Author Slug based on the above profile information, or create "
32
  "your own."
33
  msgstr ""
34
 
35
- #: includes/admin.php:66
36
  msgid "ie. - 'user-name', 'firstname-lastname', or 'master-ninja'"
37
  msgstr ""
38
 
39
- #: includes/admin.php:69 includes/admin.php:71 includes/admin.php:300
40
  msgid "Author Slug"
41
  msgstr ""
42
 
43
- #: includes/admin.php:89
44
  msgid "Custom:"
45
  msgstr ""
46
 
47
- #: includes/admin.php:90
48
  msgid "Enter a custom author slug in the following field"
49
  msgstr ""
50
 
51
- #: includes/admin.php:92
52
  msgid "Custom author slug:"
53
  msgstr ""
54
 
55
- #: includes/admin.php:159
56
  msgid "<strong>ERROR</strong>: An author slug cannot be blank. Please try again."
57
  msgstr ""
58
 
59
- #: includes/admin.php:202
60
  msgid ""
61
  "<strong>ERROR</strong>: An author slug can only contain alphanumeric "
62
  "characters, underscores (_) and dashes (-)."
63
  msgstr ""
64
 
65
- #: includes/admin.php:211
66
  msgid ""
67
  "<strong>ERROR</strong>: That author slug appears to be invalid. Please try "
68
  "something different."
69
  msgstr ""
70
 
71
- #: includes/admin.php:220
72
  msgid "<strong>ERROR</strong>: An author slug may not be longer than 50 characters."
73
  msgstr ""
74
 
75
- #: includes/admin.php:235
 
 
 
 
 
 
76
  #. translators: 1: author slug
77
  msgid ""
78
  "<strong>ERROR</strong>: The author slug, %1$s, already exists. Please try "
79
  "something different."
80
  msgstr ""
81
 
82
- #: includes/admin.php:382 includes/admin.php:400
83
  msgid "Edit Author Slug Settings"
84
  msgstr ""
85
 
86
- #: includes/admin.php:424 includes/admin.php:432
87
  msgid "Author Base"
88
  msgstr ""
89
 
90
- #: includes/admin.php:446
91
  msgid "Remove Front"
92
  msgstr ""
93
 
94
- #: includes/admin.php:460
95
  msgid "Role-Based Author Base"
96
  msgstr ""
97
 
98
- #: includes/admin.php:473
99
  msgid "Role Slugs"
100
  msgstr ""
101
 
102
- #: includes/admin.php:483
103
  msgid "Automatic Author Slug Creation"
104
  msgstr ""
105
 
106
- #: includes/admin.php:491
107
  msgid "Automatically Update"
108
  msgstr ""
109
 
110
- #: includes/admin.php:504 includes/admin.php:538
111
  msgid "Author Slug Structure"
112
  msgstr ""
113
 
114
- #: includes/admin.php:517
115
  msgid "Bulk Update Author Slugs"
116
  msgstr ""
117
 
118
- #: includes/admin.php:525
119
  msgid "Bulk Update"
120
  msgstr ""
121
 
122
- #: includes/admin.php:557
123
  msgid "Change your author base to something more fun!"
124
  msgstr ""
125
 
126
- #: includes/admin.php:570
127
  msgid ""
128
  "Allow Author Slugs to be automatically updated, and set the default Author "
129
  "Slug structure for users. Automatic updating will only occur when a user "
130
  "can't edit Author Slugs on their own."
131
  msgstr ""
132
 
133
- #: includes/admin.php:570
134
  msgid ""
135
  "This could have SEO repercussions if users update their profiles "
136
  "frequently, and it will override any manual editing of the Author Slug you "
137
  "may have previously completed."
138
  msgstr ""
139
 
140
- #: includes/admin.php:592
141
  msgid "Defaults to 'author'"
142
  msgstr ""
143
 
144
- #: includes/admin.php:619
145
  msgid "Remove the \"front\" portion of the author permalink structure."
146
  msgstr ""
147
 
148
- #: includes/admin.php:633
149
  msgid "Set user's Author Base according to their role."
150
  msgstr ""
151
 
152
- #: includes/admin.php:637
153
  #. translators: 1: rewrite tag, 2: rewrite tag demo usage, 3: demo URL using
154
  #. rewrite tag
155
  msgid ""
@@ -158,73 +164,77 @@ msgid ""
158
  "something like \"%3$s\"."
159
  msgstr ""
160
 
161
- #: includes/admin.php:750
162
  msgid "Automatically update Author Slug when a user updates their profile."
163
  msgstr ""
164
 
165
- #: includes/admin.php:774
166
  msgid "Default author slug options"
167
  msgstr ""
168
 
169
- #: includes/admin.php:794
170
  msgid "Update all users at once based on the specified Author Slug structure."
171
  msgstr ""
172
 
173
- #: includes/admin.php:810
174
  msgid ""
175
  "Update all users according to the below Author Slug setting. This will only "
176
  "be run after clicking \"Save Changes\"."
177
  msgstr ""
178
 
179
- #: includes/admin.php:834
180
  msgid "Default bulk update author slug options"
181
  msgstr ""
182
 
183
- #: includes/admin.php:865
184
  msgid "Settings"
185
  msgstr ""
186
 
187
- #: includes/admin.php:890 tests/test-admin.php:962
188
  msgid "username (Default)"
189
  msgstr ""
190
 
191
- #: includes/admin.php:891 tests/test-admin.php:963
192
  msgid "nickname"
193
  msgstr ""
194
 
195
- #: includes/admin.php:892 tests/test-admin.php:964
196
  msgid "displayname"
197
  msgstr ""
198
 
199
- #: includes/admin.php:893 tests/test-admin.php:965
200
  msgid "firstname"
201
  msgstr ""
202
 
203
- #: includes/admin.php:894 tests/test-admin.php:966
204
  msgid "lastname"
205
  msgstr ""
206
 
207
- #: includes/admin.php:895 tests/test-admin.php:967
208
  msgid "firstname-lastname"
209
  msgstr ""
210
 
211
- #: includes/admin.php:896 tests/test-admin.php:968
212
  msgid "lastname-firstname"
213
  msgstr ""
214
 
215
- #: includes/admin.php:897 tests/test-admin.php:969
216
- msgid "userid (Experimental)"
 
 
 
 
217
  msgstr ""
218
 
219
- #: includes/classes/class-edit-author-slug.php:201
220
  msgid "Use class constant, BA_Edit_Author_Slug::VERSION, instead."
221
  msgstr ""
222
 
223
- #: includes/classes/class-edit-author-slug.php:208
224
  msgid "Use class constant, BA_Edit_Author_Slug::DB_VERSION, instead."
225
  msgstr ""
226
 
227
- #: includes/functions.php:264
228
  #. translators: Updated author slugs count.
229
  msgid "%d user author slug updated."
230
  msgid_plural "%d user author slugs updated."
1
+ # Copyright (C) 2009-2018 Brandon Allen
2
  # This file is distributed under the same license as the Edit Author Slug package.
3
  # Submit translations to https://translate.wordpress.org/projects/wp-plugins/edit-author-slug.
4
  msgid ""
5
  msgstr ""
6
+ "Project-Id-Version: Edit Author Slug 1.6.0\n"
7
  "Report-Msgid-Bugs-To: "
8
  "https://github.com/thebrandonallen/edit-author-slug/issues\n"
9
+ "POT-Creation-Date: 2018-10-12 02:57:53+00:00\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=utf-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
14
  "Last-Translator: BRANDON ALLEN <plugins@brandonallen.me>\n"
15
  "Language-Team: ENGLISH <plugins@brandonallen.me>\n"
16
  "Language: en\n"
24
  "X-Poedit-SearchPath-0: .\n"
25
  "X-Poedit-Bookmarks: \n"
26
  "X-Textdomain-Support: yes\n"
27
+ "X-Generator: grunt-wp-i18n1.0.2\n"
28
 
29
+ #: includes/admin.php:74
30
  msgid ""
31
  "Choose an Author Slug based on the above profile information, or create "
32
  "your own."
33
  msgstr ""
34
 
35
+ #: includes/admin.php:74
36
  msgid "ie. - 'user-name', 'firstname-lastname', or 'master-ninja'"
37
  msgstr ""
38
 
39
+ #: includes/admin.php:77 includes/admin.php:79 includes/admin.php:328
40
  msgid "Author Slug"
41
  msgstr ""
42
 
43
+ #: includes/admin.php:98
44
  msgid "Custom:"
45
  msgstr ""
46
 
47
+ #: includes/admin.php:99
48
  msgid "Enter a custom author slug in the following field"
49
  msgstr ""
50
 
51
+ #: includes/admin.php:101
52
  msgid "Custom author slug:"
53
  msgstr ""
54
 
55
+ #: includes/admin.php:168
56
  msgid "<strong>ERROR</strong>: An author slug cannot be blank. Please try again."
57
  msgstr ""
58
 
59
+ #: includes/admin.php:213
60
  msgid ""
61
  "<strong>ERROR</strong>: An author slug can only contain alphanumeric "
62
  "characters, underscores (_) and dashes (-)."
63
  msgstr ""
64
 
65
+ #: includes/admin.php:222
66
  msgid ""
67
  "<strong>ERROR</strong>: That author slug appears to be invalid. Please try "
68
  "something different."
69
  msgstr ""
70
 
71
+ #: includes/admin.php:231
72
  msgid "<strong>ERROR</strong>: An author slug may not be longer than 50 characters."
73
  msgstr ""
74
 
75
+ #: includes/admin.php:247
76
+ msgid ""
77
+ "<strong>ERROR</strong>: Your iThemes settings prevent your author slug from "
78
+ "being the same as your username."
79
+ msgstr ""
80
+
81
+ #: includes/admin.php:263
82
  #. translators: 1: author slug
83
  msgid ""
84
  "<strong>ERROR</strong>: The author slug, %1$s, already exists. Please try "
85
  "something different."
86
  msgstr ""
87
 
88
+ #: includes/admin.php:411 includes/admin.php:429
89
  msgid "Edit Author Slug Settings"
90
  msgstr ""
91
 
92
+ #: includes/admin.php:453 includes/admin.php:461
93
  msgid "Author Base"
94
  msgstr ""
95
 
96
+ #: includes/admin.php:475
97
  msgid "Remove Front"
98
  msgstr ""
99
 
100
+ #: includes/admin.php:486
101
  msgid "Role-Based Author Base"
102
  msgstr ""
103
 
104
+ #: includes/admin.php:496
105
  msgid "Role Slugs"
106
  msgstr ""
107
 
108
+ #: includes/admin.php:506
109
  msgid "Automatic Author Slug Creation"
110
  msgstr ""
111
 
112
+ #: includes/admin.php:514
113
  msgid "Automatically Update"
114
  msgstr ""
115
 
116
+ #: includes/admin.php:524 includes/admin.php:555
117
  msgid "Author Slug Structure"
118
  msgstr ""
119
 
120
+ #: includes/admin.php:537
121
  msgid "Bulk Update Author Slugs"
122
  msgstr ""
123
 
124
+ #: includes/admin.php:545
125
  msgid "Bulk Update"
126
  msgstr ""
127
 
128
+ #: includes/admin.php:574
129
  msgid "Change your author base to something more fun!"
130
  msgstr ""
131
 
132
+ #: includes/admin.php:587
133
  msgid ""
134
  "Allow Author Slugs to be automatically updated, and set the default Author "
135
  "Slug structure for users. Automatic updating will only occur when a user "
136
  "can't edit Author Slugs on their own."
137
  msgstr ""
138
 
139
+ #: includes/admin.php:587
140
  msgid ""
141
  "This could have SEO repercussions if users update their profiles "
142
  "frequently, and it will override any manual editing of the Author Slug you "
143
  "may have previously completed."
144
  msgstr ""
145
 
146
+ #: includes/admin.php:610
147
  msgid "Defaults to 'author'"
148
  msgstr ""
149
 
150
+ #: includes/admin.php:640
151
  msgid "Remove the \"front\" portion of the author permalink structure."
152
  msgstr ""
153
 
154
+ #: includes/admin.php:656
155
  msgid "Set user's Author Base according to their role."
156
  msgstr ""
157
 
158
+ #: includes/admin.php:662
159
  #. translators: 1: rewrite tag, 2: rewrite tag demo usage, 3: demo URL using
160
  #. rewrite tag
161
  msgid ""
164
  "something like \"%3$s\"."
165
  msgstr ""
166
 
167
+ #: includes/admin.php:775
168
  msgid "Automatically update Author Slug when a user updates their profile."
169
  msgstr ""
170
 
171
+ #: includes/admin.php:803
172
  msgid "Default author slug options"
173
  msgstr ""
174
 
175
+ #: includes/admin.php:829
176
  msgid "Update all users at once based on the specified Author Slug structure."
177
  msgstr ""
178
 
179
+ #: includes/admin.php:846
180
  msgid ""
181
  "Update all users according to the below Author Slug setting. This will only "
182
  "be run after clicking \"Save Changes\"."
183
  msgstr ""
184
 
185
+ #: includes/admin.php:874
186
  msgid "Default bulk update author slug options"
187
  msgstr ""
188
 
189
+ #: includes/admin.php:911
190
  msgid "Settings"
191
  msgstr ""
192
 
193
+ #: includes/admin.php:938 tests/test-admin.php:1112
194
  msgid "username (Default)"
195
  msgstr ""
196
 
197
+ #: includes/admin.php:939 tests/test-admin.php:1113
198
  msgid "nickname"
199
  msgstr ""
200
 
201
+ #: includes/admin.php:940 tests/test-admin.php:1114
202
  msgid "displayname"
203
  msgstr ""
204
 
205
+ #: includes/admin.php:941 tests/test-admin.php:1115
206
  msgid "firstname"
207
  msgstr ""
208
 
209
+ #: includes/admin.php:942 tests/test-admin.php:1116
210
  msgid "lastname"
211
  msgstr ""
212
 
213
+ #: includes/admin.php:943 tests/test-admin.php:1117
214
  msgid "firstname-lastname"
215
  msgstr ""
216
 
217
+ #: includes/admin.php:944 tests/test-admin.php:1118
218
  msgid "lastname-firstname"
219
  msgstr ""
220
 
221
+ #: includes/admin.php:945 tests/test-admin.php:1119
222
+ msgid "userid"
223
+ msgstr ""
224
+
225
+ #: includes/admin.php:946 tests/test-admin.php:1120
226
+ msgid "hash"
227
  msgstr ""
228
 
229
+ #: includes/classes/class-ba-edit-author-slug.php:201
230
  msgid "Use class constant, BA_Edit_Author_Slug::VERSION, instead."
231
  msgstr ""
232
 
233
+ #: includes/classes/class-ba-edit-author-slug.php:208
234
  msgid "Use class constant, BA_Edit_Author_Slug::DB_VERSION, instead."
235
  msgstr ""
236
 
237
+ #: includes/functions.php:268
238
  #. translators: Updated author slugs count.
239
  msgid "%d user author slug updated."
240
  msgid_plural "%d user author slugs updated."
readme.txt CHANGED
@@ -1,71 +1,80 @@
1
- === Edit Author Slug ===
2
- Contributors: thebrandonallen
3
- Tags: author, author base, author slug, user nicename, nicename, permalink, permalinks, slug, users, user, role, roles
4
- Requires at least: 4.4
5
- Tested up to: 4.8
6
- Stable tag: 1.5.2
7
- License: GPLv2 or later
8
- License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
9
-
10
- Allows an admin (or capable user) to edit the author slug of a user, and change the author base.
11
-
12
- == Description ==
13
-
14
- This plugin allows full control of your user permalinks, allowing you to change both the author base (the '/author/' portion of the author URLs), and the author slug (defaults to the username of the author). You can set the author base globally, or you can set it to be user-specific based on a user's role. You now have the power to craft the perfect URL structure for you Author pages.
15
-
16
- WordPress default structure *http://example.com/author/username/*.
17
-
18
- Edit Author Slug allows for *http://example.com/ninja/master-ninja/*.
19
-
20
- Using a role-based author base would allow for *http://example.com/ida/master-splinter/* (for an Administrator Role), or *http://example.com/koga/leonardo/* (for a Subscriber Role).
21
-
22
- Development of this plugin takes place on [GitHub](https://github.com/thebrandonallen/edit-author-slug/ "Edit Author Slug on Github"). Pull requests are always welcome!
23
-
24
- Translations should be submitted to [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
25
-
26
- == Installation ==
27
-
28
- 1. Upload `edit-author-slug` folder to your WordPress plugins directory (typically 'wp-content/plugins')
29
- 2. Activate the plugin through the 'Plugins' menu in WordPress
30
- 3. Go to Users > Your Profile, or Users > All Users > (username), and edit the author slug.
31
- 4. Click "Update Profile" or "Update User"
32
- 5. Go to Settings > Edit Author Slug to edit settings
33
- 6. Click "Save Changes"
34
-
35
- == Screenshots ==
36
-
37
- 1. Settings
38
- 2. Individual user author slug
39
-
40
- == Frequently Asked Questions ==
41
-
42
- = What is an author slug? =
43
-
44
- On standard WordPress installs, it's the final part of an author permalink.
45
- e.g. - https://example.com/author/author-slug/
46
-
47
- In relation to WordPress internals, the author slug is the same as the `user_nicename` field found in a `WP_User` object, or the users table in the database.
48
-
49
- = Will my changes persist if I deactivate or delete the Edit Author Slug plugin? =
50
-
51
- It depends.
52
-
53
- Changing a user's author slug is permanent, as this changes the user's `user_nicename` field in the database.
54
-
55
- If you've changed the author base, deactivating or deleting the plugin will revert your author base back to `author`.
56
-
57
- = Why can't I edit my Author Slug? =
58
-
59
- Make sure you are an admin, or have been assigned the `edit_users` capability.
60
-
61
- = Why isn't my new Author Slug working? =
62
-
63
- While I've made every attempt to prevent this, I may have missed a spot or two. First things first, go to Settings > Permalinks and click "Save Changes." You don't need to actually need to make any changes for this to work. Hopefully, this should kick your new Author Slug into gear.
64
-
65
- If this doesn't work, make sure you don't have any slug conflicts from other posts/pages/plugins/permalink setting/etc. If you're still experiencing the issue, feel free to post a support request in the forums.
66
-
67
- == Changelog ==
68
-
 
 
 
 
 
 
 
 
 
69
  = 1.5.2 =
70
  * Release date: 2017-06-21
71
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. Props @thatherton.
@@ -74,42 +83,42 @@ If this doesn't work, make sure you don't have any slug conflicts from other pos
74
  * Release date: 2017-06-02
75
  * Fix PHP notice when manually updating a user profile. Props @mydigitalsauce.
76
 
77
- = 1.5.0 =
78
- * Release date: 2017-05-30
79
- * Bumped minimum required WordPress version to 4.4.
80
- * Refactored bulk upgrading again. The original fix made things better, but not as good as it could be. This new refactoring drastically improves performance and memory usage.
81
- * This release is primarily an under-the-hood release with a number of optimizations and performance improvements.
82
-
83
- = 1.4.1 =
84
- * Release date: 2017-04-24
85
- * Fix failing string replacement in bulk update message.
86
-
87
- = 1.4.0 =
88
- * Release date: 2017-04-04
89
- * Lots of code cleanup to better adhere to WordPress Coding Standards.
90
- * Improved performance of `ba_eas_sanitize_author_base()` by preventing unnecessary processing.
91
- * Fixed an issue where the demo author permalink URL could have a double slash.
92
- * Improvements to bulk update for sites with a large user base.
93
-
94
- = 1.3.0 =
95
- * Release date: 2017-01-25
96
- * Fix a potential bug where a sanitized author base could end up with double forward slashes.
97
- * Introduce the `%ba_eas_author_role%` permalink structure tag. This can be used to customize role-based author bases.
98
- * Bonus: All alternative facts are now free!
99
-
100
- = 1.2.1 =
101
- * Release date: 2016-02-29
102
- * Fixed stupid error where the default user nicename wasn't being properly retrieved from the database. Sorry about that :(
103
- * Unfortunately, some unicorns were lost during the development of this release, but they are a resilient creature.
104
-
105
- = 1.2.0 =
106
- * Release date: 2016-02-01
107
- * Added the ability to use forward slashes in the author base.
108
- * Improved display on the settings page, and storing, of role slugs.
109
- * Packaged translations are now removed. Anyone interested in translating the plugin should do so at [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
110
- * EXPERIMENTAL: Added the ability to set the author slug to a user's numeric user id. While I have tested this, I can't be sure that no one's site will implode. If all goes well, the experimental tag will be removed in the next major release (or two).
111
- * Added ability to remove the front portion of author links.
112
- * Accessibility improvements to the settings page.
113
-
114
- = Full Changelog =
115
- * https://github.com/thebrandonallen/edit-author-slug/blob/master/CHANGELOG.md
1
+ === Edit Author Slug ===
2
+ Contributors: thebrandonallen
3
+ Tags: author, author base, author slug, user nicename, nicename, permalink, permalinks, slug, users, user, role, roles
4
+ Requires at least: 4.7
5
+ Tested up to: 4.9.8
6
+ Requires PHP: 5.3
7
+ Stable tag: 1.6.0
8
+ License: GPLv2 or later
9
+ License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
+
11
+ Allows an admin (or capable user) to edit the author slug of a user, and change the author base.
12
+
13
+ == Description ==
14
+
15
+ This plugin allows full control of your user permalinks, allowing you to change both the author base (the '/author/' portion of the author URLs), and the author slug (defaults to the username of the author). You can set the author base globally, or you can set it to be user-specific based on a user's role. You now have the power to craft the perfect URL structure for you Author pages.
16
+
17
+ WordPress default structure *http://example.com/author/username/*.
18
+
19
+ Edit Author Slug allows for *http://example.com/ninja/master-ninja/*.
20
+
21
+ Using a role-based author base would allow for *http://example.com/ida/master-splinter/* (for an Administrator Role), or *http://example.com/koga/leonardo/* (for a Subscriber Role).
22
+
23
+ Development of this plugin takes place on [GitHub](https://github.com/thebrandonallen/edit-author-slug/ "Edit Author Slug on Github"). Pull requests are always welcome!
24
+
25
+ Translations should be submitted to [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
26
+
27
+ == Installation ==
28
+
29
+ 1. Upload `edit-author-slug` folder to your WordPress plugins directory (typically 'wp-content/plugins')
30
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
31
+ 3. Go to Users > Your Profile, or Users > All Users > (username), and edit the author slug.
32
+ 4. Click "Update Profile" or "Update User"
33
+ 5. Go to Settings > Edit Author Slug to edit settings
34
+ 6. Click "Save Changes"
35
+
36
+ == Screenshots ==
37
+
38
+ 1. Settings
39
+ 2. Individual user author slug
40
+
41
+ == Frequently Asked Questions ==
42
+
43
+ = What is an author slug? =
44
+
45
+ On standard WordPress installs, it's the final part of an author permalink.
46
+ e.g. - https://example.com/author/author-slug/
47
+
48
+ In relation to WordPress internals, the author slug is the same as the `user_nicename` field found in a `WP_User` object, or the users table in the database.
49
+
50
+ = Will my changes persist if I deactivate or delete the Edit Author Slug plugin? =
51
+
52
+ It depends.
53
+
54
+ Changing a user's author slug is permanent, as this changes the user's `user_nicename` field in the database.
55
+
56
+ If you've changed the author base, deactivating or deleting the plugin will revert your author base back to `author`.
57
+
58
+ = Why can't I edit my Author Slug? =
59
+
60
+ Make sure you are an admin, or have been assigned the `edit_users` capability.
61
+
62
+ = Why isn't my new Author Slug working? =
63
+
64
+ While I've made every attempt to prevent this, I may have missed a spot or two. First things first, go to Settings > Permalinks and click "Save Changes." You don't need to actually need to make any changes for this to work. Hopefully, this should kick your new Author Slug into gear.
65
+
66
+ If this doesn't work, make sure you don't have any slug conflicts from other posts/pages/plugins/permalink setting/etc. If you're still experiencing the issue, feel free to post a support request in the forums.
67
+
68
+ == Changelog ==
69
+
70
+ = 1.6.0 =
71
+ * Release date: 2018-10-11
72
+ * Minimum required WordPress version is now 4.7
73
+ * Settings page JS no longer depends on jQuery (switched to plain js)
74
+ * Add compatibility for iThemes Force Unique Nickname WordPress Tweak
75
+ * Add a hash string as an author slug option
76
+ * Minimum PHP version has been bumped to 5.3. This is a soft bump, meaning, the plugin should still run on PHP 5.2. However, PHP 5.2 is no longer, officially, supported.
77
+
78
  = 1.5.2 =
79
  * Release date: 2017-06-21
80
  * Fixed a regression where those using the default author based couldn't remove front unless they were also using role-based author bases. Props @thatherton.
83
  * Release date: 2017-06-02
84
  * Fix PHP notice when manually updating a user profile. Props @mydigitalsauce.
85
 
86
+ = 1.5.0 =
87
+ * Release date: 2017-05-30
88
+ * Bumped minimum required WordPress version to 4.4.
89
+ * Refactored bulk upgrading again. The original fix made things better, but not as good as it could be. This new refactoring drastically improves performance and memory usage.
90
+ * This release is primarily an under-the-hood release with a number of optimizations and performance improvements.
91
+
92
+ = 1.4.1 =
93
+ * Release date: 2017-04-24
94
+ * Fix failing string replacement in bulk update message.
95
+
96
+ = 1.4.0 =
97
+ * Release date: 2017-04-04
98
+ * Lots of code cleanup to better adhere to WordPress Coding Standards.
99
+ * Improved performance of `ba_eas_sanitize_author_base()` by preventing unnecessary processing.
100
+ * Fixed an issue where the demo author permalink URL could have a double slash.
101
+ * Improvements to bulk update for sites with a large user base.
102
+
103
+ = 1.3.0 =
104
+ * Release date: 2017-01-25
105
+ * Fix a potential bug where a sanitized author base could end up with double forward slashes.
106
+ * Introduce the `%ba_eas_author_role%` permalink structure tag. This can be used to customize role-based author bases.
107
+ * Bonus: All alternative facts are now free!
108
+
109
+ = 1.2.1 =
110
+ * Release date: 2016-02-29
111
+ * Fixed stupid error where the default user nicename wasn't being properly retrieved from the database. Sorry about that :(
112
+ * Unfortunately, some unicorns were lost during the development of this release, but they are a resilient creature.
113
+
114
+ = 1.2.0 =
115
+ * Release date: 2016-02-01
116
+ * Added the ability to use forward slashes in the author base.
117
+ * Improved display on the settings page, and storing, of role slugs.
118
+ * Packaged translations are now removed. Anyone interested in translating the plugin should do so at [Translate WordPress](https://translate.wordpress.org/projects/wp-plugins/edit-author-slug).
119
+ * EXPERIMENTAL: Added the ability to set the author slug to a user's numeric user id. While I have tested this, I can't be sure that no one's site will implode. If all goes well, the experimental tag will be removed in the next major release (or two).
120
+ * Added ability to remove the front portion of author links.
121
+ * Accessibility improvements to the settings page.
122
+
123
+ = Full Changelog =
124
+ * https://github.com/thebrandonallen/edit-author-slug/blob/master/CHANGELOG.md