Version Description
Download this release
Release Info
Developer | evertiro |
Plugin | Username Changer |
Version | 3.1.2 |
Comparing to | |
See all releases |
Code changes from version 3.1.1 to 3.1.2
- CONTRIBUTING.md +36 -38
- assets/banner-1544x500-rtl.png +0 -0
- assets/banner-1544x500.png +0 -0
- assets/banner-772x250-rtl.png +0 -0
- assets/banner-772x250.png +0 -0
- assets/icon-128x128.png +0 -0
- assets/icon-256x256.png +0 -0
- assets/screenshot-1.png +0 -0
- assets/screenshot-2.gif +0 -0
- includes/admin/actions.php +113 -113
- includes/admin/settings/register.php +298 -316
- includes/class.template-tags.php +505 -505
- includes/functions.php +157 -161
- includes/libraries/s214-settings/source/class.s214-settings.php +39 -0
- includes/scripts.php +44 -44
- readme.md +22 -26
- readme.txt +92 -91
- username-changer.php +4 -4
CONTRIBUTING.md
CHANGED
@@ -1,38 +1,36 @@
|
|
1 |
-
# Contribute To Username Changer
|
2 |
-
|
3 |
-
Community made patches, localizations, bug reports and contributions are always welcome!
|
4 |
-
|
5 |
-
When contributing please ensure you follow the guidelines below so that we can keep on top of things.
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
*
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
*
|
20 |
-
|
21 |
-
*
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
* [
|
37 |
-
* [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
|
38 |
-
* [PHPUnit Tests Guide](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
|
1 |
+
# Contribute To Username Changer
|
2 |
+
|
3 |
+
Community made patches, localizations, bug reports and contributions are always welcome!
|
4 |
+
|
5 |
+
When contributing please ensure you follow the guidelines below so that we can keep on top of things.
|
6 |
+
|
7 |
+
## Getting Started
|
8 |
+
|
9 |
+
* Submit a ticket for your issue, assuming one does not already exist.
|
10 |
+
* Raise it on our [Issue Tracker](https://github.com/evertiro/username-changer/issues)
|
11 |
+
* Clearly describe the issue including steps to reproduce the bug.
|
12 |
+
* Make sure you fill in the earliest version that you know has the issue as well as the version of WordPress you're using.
|
13 |
+
|
14 |
+
## Making Changes
|
15 |
+
|
16 |
+
* Fork the repository on GitHub
|
17 |
+
* Make the changes to your forked repository
|
18 |
+
* Ensure you stick to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
|
19 |
+
* When committing, reference your issue (if present) and include a note about the fix
|
20 |
+
* If possible, and if applicable, please also add/update unit tests for your changes
|
21 |
+
* Push the changes to your fork and submit a pull request to the 'master' branch of the repository
|
22 |
+
|
23 |
+
## Code Documentation
|
24 |
+
|
25 |
+
* We ensure that every function is documented well and follows the standards set by phpDoc
|
26 |
+
* An example function can be found [here](https://gist.github.com/sunnyratilal/5308969)
|
27 |
+
* Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
|
28 |
+
* If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
|
29 |
+
* Finally, please use tabs and not spaces. The tab indent size should be 4 for all code.
|
30 |
+
|
31 |
+
At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
|
32 |
+
|
33 |
+
# Additional Resources
|
34 |
+
* [General GitHub Documentation](https://help.github.com/)
|
35 |
+
* [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
|
36 |
+
* [PHPUnit Tests Guide](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
|
|
|
|
assets/banner-1544x500-rtl.png
DELETED
Binary file
|
assets/banner-1544x500.png
DELETED
Binary file
|
assets/banner-772x250-rtl.png
DELETED
Binary file
|
assets/banner-772x250.png
DELETED
Binary file
|
assets/icon-128x128.png
DELETED
Binary file
|
assets/icon-256x256.png
DELETED
Binary file
|
assets/screenshot-1.png
DELETED
Binary file
|
assets/screenshot-2.gif
DELETED
Binary file
|
includes/admin/actions.php
CHANGED
@@ -1,113 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin actions
|
4 |
-
*
|
5 |
-
* @package Username_Changer\Admin\Actions
|
6 |
-
* @since 3.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Process username change requests through AJAX
|
18 |
-
*
|
19 |
-
* @since 3.0.0
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
function username_changer_ajax_username_change() {
|
23 |
-
$response = array(
|
24 |
-
'success' => false,
|
25 |
-
'new_nonce' => wp_create_nonce( 'change_username' )
|
26 |
-
);
|
27 |
-
|
28 |
-
// Validate nonce
|
29 |
-
check_ajax_referer( 'change_username', 'security' );
|
30 |
-
|
31 |
-
// Validate request
|
32 |
-
if ( empty( $_POST['new_username'] ) || empty( $_POST['old_username'] ) ) {
|
33 |
-
$response['message'] = __( 'Invalid request.', 'username-changer' );
|
34 |
-
wp_send_json( $response );
|
35 |
-
}
|
36 |
-
|
37 |
-
$old_username = trim( strip_tags( $_POST['old_username'] ) );
|
38 |
-
$old_username_tag = esc_attr( $_POST['old_username'] );
|
39 |
-
$new_username = trim( strip_tags( $_POST['new_username'] ) );
|
40 |
-
$new_username_tag = esc_attr( $_POST['new_username'] );
|
41 |
-
$current_user = wp_get_current_user();
|
42 |
-
$current_username = $current_user->user_login;
|
43 |
-
|
44 |
-
// Make sure the user can change this username
|
45 |
-
if ( ! current_user_can( 'edit_users' ) ) {
|
46 |
-
if ( $current_username != $old_username || ! username_changer_can_change_own_username() ) {
|
47 |
-
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_wrong_permissions', __( 'You do not have the correct permissions to change this username.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
48 |
-
wp_send_json( $response );
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
// Validate new username
|
53 |
-
if ( ! validate_username( $new_username ) ) {
|
54 |
-
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_invalid_chars', __( 'The username {new_username} contains invalid characters. Please enter a valid username.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
55 |
-
wp_send_json( $response );
|
56 |
-
}
|
57 |
-
|
58 |
-
// Make sure new username isn't on the illegal logins list
|
59 |
-
$illegal_user_logins = array_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
|
60 |
-
if ( in_array( $new_username, $illegal_user_logins ) ) {
|
61 |
-
$response['message'] = __( 'Sorry, that username is not allowed.', 'username-changer' );
|
62 |
-
wp_send_json( $response );
|
63 |
-
}
|
64 |
-
|
65 |
-
// Make sure the new username isn't already taken
|
66 |
-
if ( username_exists( $new_username ) ) {
|
67 |
-
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_duplicate_username', __( 'The username {new_username} is already in use. Please try again.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
68 |
-
wp_send_json( $response );
|
69 |
-
}
|
70 |
-
|
71 |
-
// Change the username
|
72 |
-
$success = username_changer_process( $old_username, $new_username );
|
73 |
-
|
74 |
-
if ( $success ) {
|
75 |
-
$response['success'] = true;
|
76 |
-
|
77 |
-
// Append relogin link if old_username == current_username
|
78 |
-
if ( $old_username == $current_username ) {
|
79 |
-
$response['message'] = sprintf(
|
80 |
-
'%s <a href="%s">%s</a>',
|
81 |
-
username_changer_do_tags( username_changer()->settings->get_option( 'success_message', __( 'Username successfully changed to {new_username}.', 'username-changer' ) ), $old_username_tag, $new_username_tag ),
|
82 |
-
wp_login_url(),
|
83 |
-
username_changer_do_tags( username_changer()->settings->get_option( 'relogin_message', __( 'Click here to log back in.', 'username-changer' ) ), $old_username_tag, $new_username_tag )
|
84 |
-
);
|
85 |
-
} else {
|
86 |
-
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'success_message', __( 'Username successfully changed to {new_username}.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
87 |
-
|
88 |
-
// Send emails as necessary
|
89 |
-
if ( username_changer()->settings->get_option( 'enable_notifications', false ) ) {
|
90 |
-
$changed_user = get_user_by( 'login', $old_username );
|
91 |
-
$mail_to = $changed_user->user_email;
|
92 |
-
$subject = username_changer_do_tags( username_changer()->settings->get_option( 'email_subject', __( 'Username change notification - {sitename}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
93 |
-
$message = username_changer_do_tags( username_changer()->settings->get_option( 'email_message', __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
94 |
-
|
95 |
-
$subject = stripslashes( $subject );
|
96 |
-
$message = stripslashes( $message );
|
97 |
-
|
98 |
-
$from_name = get_bloginfo( 'name' );
|
99 |
-
$from_email = get_bloginfo( 'admin_email' );
|
100 |
-
|
101 |
-
$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
|
102 |
-
$headers .= "Reply-To: ". $from_email . "\r\n";
|
103 |
-
|
104 |
-
wp_mail( $mail_to, $subject, $message, $headers );
|
105 |
-
}
|
106 |
-
}
|
107 |
-
} else {
|
108 |
-
$response['message'] = __( 'An unknown error occurred.', 'username-changer' );
|
109 |
-
}
|
110 |
-
|
111 |
-
wp_send_json( $response );
|
112 |
-
}
|
113 |
-
add_action( 'wp_ajax_change_username', 'username_changer_ajax_username_change' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin actions
|
4 |
+
*
|
5 |
+
* @package Username_Changer\Admin\Actions
|
6 |
+
* @since 3.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Process username change requests through AJAX
|
18 |
+
*
|
19 |
+
* @since 3.0.0
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function username_changer_ajax_username_change() {
|
23 |
+
$response = array(
|
24 |
+
'success' => false,
|
25 |
+
'new_nonce' => wp_create_nonce( 'change_username' )
|
26 |
+
);
|
27 |
+
|
28 |
+
// Validate nonce
|
29 |
+
check_ajax_referer( 'change_username', 'security' );
|
30 |
+
|
31 |
+
// Validate request
|
32 |
+
if ( empty( $_POST['new_username'] ) || empty( $_POST['old_username'] ) ) {
|
33 |
+
$response['message'] = __( 'Invalid request.', 'username-changer' );
|
34 |
+
wp_send_json( $response );
|
35 |
+
}
|
36 |
+
|
37 |
+
$old_username = trim( strip_tags( $_POST['old_username'] ) );
|
38 |
+
$old_username_tag = esc_attr( $_POST['old_username'] );
|
39 |
+
$new_username = trim( strip_tags( $_POST['new_username'] ) );
|
40 |
+
$new_username_tag = esc_attr( $_POST['new_username'] );
|
41 |
+
$current_user = wp_get_current_user();
|
42 |
+
$current_username = $current_user->user_login;
|
43 |
+
|
44 |
+
// Make sure the user can change this username
|
45 |
+
if ( ! current_user_can( 'edit_users' ) ) {
|
46 |
+
if ( $current_username != $old_username || ! username_changer_can_change_own_username() ) {
|
47 |
+
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_wrong_permissions', __( 'You do not have the correct permissions to change this username.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
48 |
+
wp_send_json( $response );
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
// Validate new username
|
53 |
+
if ( ! validate_username( $new_username ) ) {
|
54 |
+
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_invalid_chars', __( 'The username {new_username} contains invalid characters. Please enter a valid username.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
55 |
+
wp_send_json( $response );
|
56 |
+
}
|
57 |
+
|
58 |
+
// Make sure new username isn't on the illegal logins list
|
59 |
+
$illegal_user_logins = array_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
|
60 |
+
if ( in_array( $new_username, $illegal_user_logins ) ) {
|
61 |
+
$response['message'] = __( 'Sorry, that username is not allowed.', 'username-changer' );
|
62 |
+
wp_send_json( $response );
|
63 |
+
}
|
64 |
+
|
65 |
+
// Make sure the new username isn't already taken
|
66 |
+
if ( username_exists( $new_username ) ) {
|
67 |
+
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'error_duplicate_username', __( 'The username {new_username} is already in use. Please try again.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
68 |
+
wp_send_json( $response );
|
69 |
+
}
|
70 |
+
|
71 |
+
// Change the username
|
72 |
+
$success = username_changer_process( $old_username, $new_username );
|
73 |
+
|
74 |
+
if ( $success ) {
|
75 |
+
$response['success'] = true;
|
76 |
+
|
77 |
+
// Append relogin link if old_username == current_username
|
78 |
+
if ( $old_username == $current_username ) {
|
79 |
+
$response['message'] = sprintf(
|
80 |
+
'%s <a href="%s">%s</a>',
|
81 |
+
username_changer_do_tags( username_changer()->settings->get_option( 'success_message', __( 'Username successfully changed to {new_username}.', 'username-changer' ) ), $old_username_tag, $new_username_tag ),
|
82 |
+
wp_login_url(),
|
83 |
+
username_changer_do_tags( username_changer()->settings->get_option( 'relogin_message', __( 'Click here to log back in.', 'username-changer' ) ), $old_username_tag, $new_username_tag )
|
84 |
+
);
|
85 |
+
} else {
|
86 |
+
$response['message'] = username_changer_do_tags( username_changer()->settings->get_option( 'success_message', __( 'Username successfully changed to {new_username}.', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
87 |
+
|
88 |
+
// Send emails as necessary
|
89 |
+
if ( username_changer()->settings->get_option( 'enable_notifications', false ) ) {
|
90 |
+
$changed_user = get_user_by( 'login', $old_username );
|
91 |
+
$mail_to = $changed_user->user_email;
|
92 |
+
$subject = username_changer_do_tags( username_changer()->settings->get_option( 'email_subject', __( 'Username change notification - {sitename}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
93 |
+
$message = username_changer_do_tags( username_changer()->settings->get_option( 'email_message', __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
|
94 |
+
|
95 |
+
$subject = stripslashes( $subject );
|
96 |
+
$message = stripslashes( $message );
|
97 |
+
|
98 |
+
$from_name = get_bloginfo( 'name' );
|
99 |
+
$from_email = get_bloginfo( 'admin_email' );
|
100 |
+
|
101 |
+
$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
|
102 |
+
$headers .= "Reply-To: ". $from_email . "\r\n";
|
103 |
+
|
104 |
+
wp_mail( $mail_to, $subject, $message, $headers );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
$response['message'] = __( 'An unknown error occurred.', 'username-changer' );
|
109 |
+
}
|
110 |
+
|
111 |
+
wp_send_json( $response );
|
112 |
+
}
|
113 |
+
add_action( 'wp_ajax_change_username', 'username_changer_ajax_username_change' );
|
includes/admin/settings/register.php
CHANGED
@@ -1,316 +1,298 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Register settings
|
4 |
-
*
|
5 |
-
* @package UsernameChanger\Admin\Settings\Register
|
6 |
-
* @since 3.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Setup the settings menu
|
18 |
-
*
|
19 |
-
* @since 3.0.0
|
20 |
-
* @param array $menu The default menu settings
|
21 |
-
* @return array $menu Our defined settings
|
22 |
-
*/
|
23 |
-
function username_changer_add_menu( $menu ) {
|
24 |
-
$menu['type'] = 'submenu';
|
25 |
-
$menu['page_title'] = __( 'Username Changer Settings', 'username-changer' );
|
26 |
-
$menu['menu_title'] = __( 'Username Changer', 'username-changer' );
|
27 |
-
|
28 |
-
return $menu;
|
29 |
-
}
|
30 |
-
add_filter( 'username_changer_menu', 'username_changer_add_menu' );
|
31 |
-
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Define our settings tabs
|
35 |
-
*
|
36 |
-
* @since 3.0.0
|
37 |
-
* @param array $tabs The default tabs
|
38 |
-
* @return array $tabs Our defined tabs
|
39 |
-
*/
|
40 |
-
function username_changer_settings_tabs( $tabs ) {
|
41 |
-
$tabs['settings'] = __( 'Settings', 'username-changer' );
|
42 |
-
$tabs['support'] = __( 'Support', 'username-changer' );
|
43 |
-
|
44 |
-
return $tabs;
|
45 |
-
}
|
46 |
-
add_filter( 'username_changer_settings_tabs', 'username_changer_settings_tabs' );
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Define settings sections
|
51 |
-
*
|
52 |
-
* @since 3.0.0
|
53 |
-
* @param array $sections The default sections
|
54 |
-
* @return array $sections Our defined sections
|
55 |
-
*/
|
56 |
-
function username_changer_registered_settings_sections( $sections ) {
|
57 |
-
$sections = array(
|
58 |
-
'settings' => apply_filters( 'username_changer_settings_sections_settings', array(
|
59 |
-
'main' => __( 'General Settings', 'username-changer' ),
|
60 |
-
'strings' => __( 'String Settings', 'username-changer' )
|
61 |
-
) ),
|
62 |
-
'support' => apply_filters( 'username_changer_settings_sections_support', array() )
|
63 |
-
);
|
64 |
-
|
65 |
-
return $sections;
|
66 |
-
}
|
67 |
-
add_filter( 'username_changer_registered_settings_sections', 'username_changer_registered_settings_sections' );
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Disable save button on unsavable tabs
|
72 |
-
*
|
73 |
-
* @since 3.0.0
|
74 |
-
* @return array $tabs The updated tabs
|
75 |
-
*/
|
76 |
-
function username_changer_define_unsavable_tabs() {
|
77 |
-
$tabs = array( 'support' );
|
78 |
-
|
79 |
-
return $tabs;
|
80 |
-
}
|
81 |
-
add_filter( 'username_changer_unsavable_tabs', 'username_changer_define_unsavable_tabs' );
|
82 |
-
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Define our settings
|
86 |
-
*
|
87 |
-
* @since 3.0.0
|
88 |
-
* @param array $settings The default settings
|
89 |
-
* @return array $settings Our defined settings
|
90 |
-
*/
|
91 |
-
function username_changer_registered_settings( $settings ) {
|
92 |
-
$new_settings = array(
|
93 |
-
// General Settings
|
94 |
-
'settings' => apply_filters( 'username_changer_settings_settings', array(
|
95 |
-
'main' => array(
|
96 |
-
array(
|
97 |
-
'id' => 'settings_header',
|
98 |
-
'name' => __( 'General Settings', 'username-changer' ),
|
99 |
-
'desc' => '',
|
100 |
-
'type' => 'header'
|
101 |
-
),
|
102 |
-
array(
|
103 |
-
'id' => 'allowed_roles',
|
104 |
-
'name' => __( 'Allowed Roles', 'username-changer' ),
|
105 |
-
'desc' => __( 'Select the user roles which are permitted to change their own username.', 'username-changer' ),
|
106 |
-
'type' => 'multicheck',
|
107 |
-
'options' => username_changer_get_user_roles(),
|
108 |
-
'tooltip_title' => __( 'Allowed Roles', 'username-changer' ),
|
109 |
-
'tooltip_desc' => __( 'Administrators can always change usernames, and are the only role capable of changing other users username.', 'username-changer' )
|
110 |
-
),
|
111 |
-
array(
|
112 |
-
'id' => 'minimum_length',
|
113 |
-
'name' => __( 'Minimum Length', 'username-changer' ),
|
114 |
-
'desc' => __( 'Specify the minimum allowed username length.', 'username-changer' ),
|
115 |
-
'type' => 'number',
|
116 |
-
'size' => 'small-text',
|
117 |
-
'min' => 3,
|
118 |
-
'step' => 1,
|
119 |
-
'std' => 3,
|
120 |
-
'tooltip_title' => __( 'Minimum Length', 'username-changer' ),
|
121 |
-
'tooltip_desc' => __( 'The minimum allowed length for usernames is {minlength} characters.', 'username-changer' )
|
122 |
-
),
|
123 |
-
array(
|
124 |
-
'id' => 'email_header',
|
125 |
-
'name' => __( 'Email Settings', 'username-changer' ),
|
126 |
-
'desc' => '',
|
127 |
-
'type' => 'header'
|
128 |
-
),
|
129 |
-
array(
|
130 |
-
'id' => 'enable_notifications',
|
131 |
-
'name' => __( 'Enable Email Notifications', 'username-changer' ),
|
132 |
-
'desc' => __( 'Enable to send notification emails when usernames are changed.', 'username-changer' ),
|
133 |
-
'type' => 'checkbox',
|
134 |
-
'tooltip_title' => __( 'Enable Email Notifications', 'username-changer' ),
|
135 |
-
'tooltip_desc' => __( 'Notifications are not sent when a user changes their own username.', 'username-changer' )
|
136 |
-
),
|
137 |
-
array(
|
138 |
-
'id' => 'email_subheader',
|
139 |
-
'name' => '',
|
140 |
-
'desc' => '',
|
141 |
-
'type' => 'hook'
|
142 |
-
),
|
143 |
-
array(
|
144 |
-
'id' => 'email_subject',
|
145 |
-
'name' => __( 'Email Subject', 'username-changer' ),
|
146 |
-
'desc' => __( 'Specify the subject for username change notifications.', 'username-changer' ),
|
147 |
-
'type' => 'text',
|
148 |
-
'std' => __( 'Username change notification - {sitename}', 'username-changer' ),
|
149 |
-
),
|
150 |
-
array(
|
151 |
-
'id' => 'email_message',
|
152 |
-
'name' => __( 'Email Message', 'username-changer' ),
|
153 |
-
'desc' => __( 'Specify the message to send for username change notifications.', 'username-changer' ),
|
154 |
-
'type' => 'editor',
|
155 |
-
'std' => __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' )
|
156 |
-
)
|
157 |
-
),
|
158 |
-
'strings' => array(
|
159 |
-
array(
|
160 |
-
'id' => 'button_labels_header',
|
161 |
-
'name' => __( 'Button Labels', 'username-changer' ),
|
162 |
-
'desc' => '',
|
163 |
-
'type' => 'header'
|
164 |
-
),
|
165 |
-
array(
|
166 |
-
'id' => 'change_button_label',
|
167 |
-
'name' => __( 'Change Button Label', 'username-changer' ),
|
168 |
-
'desc' => __( 'Customize the text for the \'change username\' button.', 'username-changer' ),
|
169 |
-
'type' => 'text',
|
170 |
-
'std' => __( 'Change Username', 'username-changer' )
|
171 |
-
),
|
172 |
-
array(
|
173 |
-
'id' => 'save_button_label',
|
174 |
-
'name' => __( 'Save Button Label', 'username-changer' ),
|
175 |
-
'desc' => __( 'Customize the text for the save buttton.', 'username-changer' ),
|
176 |
-
'type' => 'text',
|
177 |
-
'std' => __( 'Save Username', 'username-changer' )
|
178 |
-
),
|
179 |
-
array(
|
180 |
-
'id' => 'cancel_button_label',
|
181 |
-
'name' => __( 'Cancel Button Label', 'username-changer' ),
|
182 |
-
'desc' => __( 'Customize the text for the cancel button.', 'username-changer' ),
|
183 |
-
'type' => 'text',
|
184 |
-
'std' => __( 'Cancel', 'username-changer' )
|
185 |
-
),
|
186 |
-
array(
|
187 |
-
'id' => 'messages_header',
|
188 |
-
'name' => __( 'Messages', 'username-changer' ),
|
189 |
-
'desc' => 'test',
|
190 |
-
'type' => 'header'
|
191 |
-
),
|
192 |
-
array(
|
193 |
-
'id' => 'messages_subheader',
|
194 |
-
'name' => '',
|
195 |
-
'desc' => '',
|
196 |
-
'type' => 'hook'
|
197 |
-
),
|
198 |
-
array(
|
199 |
-
'id' => 'please_wait_message',
|
200 |
-
'name' => __( 'Please Wait Message', 'username-changer' ),
|
201 |
-
'desc' => __( 'Customize the text displayed while usernames are being checked.', 'username-changer' ),
|
202 |
-
'type' => 'text',
|
203 |
-
'std' => __( 'Please wait...', 'username-changer' )
|
204 |
-
),
|
205 |
-
array(
|
206 |
-
'id' => 'success_message',
|
207 |
-
'name' => __( 'Username Changed Message', 'username-changer' ),
|
208 |
-
'desc' => __( 'Customize the message displayed when a username is changed successfully.', 'username-changer' ),
|
209 |
-
'type' => 'text',
|
210 |
-
'std' => __( 'Username successfully changed to {new_username}.', 'username-changer' )
|
211 |
-
),
|
212 |
-
array(
|
213 |
-
'id' => 'relogin_message',
|
214 |
-
'name' => __( 'Relogin Message', 'username-changer' ),
|
215 |
-
'desc' => __( 'Customize the text for the relogin link shown if a user changes their own username.', 'username-changer' ),
|
216 |
-
'type' => 'text',
|
217 |
-
'std' => __( 'Click here to log back in.', 'username-changer' )
|
218 |
-
),
|
219 |
-
array(
|
220 |
-
'id' => 'error_short_username',
|
221 |
-
'name' => __( 'Short Username Error', 'username-changer' ),
|
222 |
-
'desc' => __( 'Customize the error displayed when a username is too short.', 'username-changer' ),
|
223 |
-
'type' => 'text',
|
224 |
-
'std' => __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' )
|
225 |
-
),
|
226 |
-
array(
|
227 |
-
'id' => 'error_wrong_permissions',
|
228 |
-
'name' => __( 'Wrong Permissions Error', 'username-changer' ),
|
229 |
-
'desc' => __( 'Customize the error displayed when a user attempts to change a username they do not have permission to change.', 'username-changer' ),
|
230 |
-
'type' => 'text',
|
231 |
-
'std' => __( 'You do not have the correct permissions to change this username.', 'username-changer' ),
|
232 |
-
'tooltip_title' => __( 'Wrong Permissions Error', 'username-changer' ),
|
233 |
-
'tooltip_desc' => __( 'In normal circumstances, this message should never be triggered. It exists only to provide an extra layer of security against unauthorized use.', 'username-changer' )
|
234 |
-
),
|
235 |
-
array(
|
236 |
-
'id' => 'error_duplicate_username',
|
237 |
-
'name' => __( 'Duplicate Username Error', 'username-changer' ),
|
238 |
-
'desc' => __( 'Customize the error displayed when a user attempts to change a username to something that is already in use.', 'username-changer' ),
|
239 |
-
'type' => 'text',
|
240 |
-
'std' => __( 'The username {new_username} is already in use. Please try again.', 'username-changer' )
|
241 |
-
)
|
242 |
-
)
|
243 |
-
) ),
|
244 |
-
'support' => apply_filters( 'username_changer_settings_support', array(
|
245 |
-
array(
|
246 |
-
'id' => 'support_header',
|
247 |
-
'name' => __( 'Username Changer Support', 'username-changer' ),
|
248 |
-
'desc' => '',
|
249 |
-
'type' => 'header'
|
250 |
-
),
|
251 |
-
array(
|
252 |
-
'id' => '
|
253 |
-
'name' => __( '
|
254 |
-
'desc' => '',
|
255 |
-
'type' => '
|
256 |
-
)
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
}
|
280 |
-
add_action( '
|
281 |
-
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Display the subheader for the
|
285 |
-
*
|
286 |
-
* @since 3.
|
287 |
-
* @return void
|
288 |
-
*/
|
289 |
-
function
|
290 |
-
?>
|
291 |
-
<div class="username-changer-settings-note">
|
292 |
-
<span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
|
293 |
-
<p><?php _e( '
|
294 |
-
<?php echo username_changer_tags_list( '
|
295 |
-
</div>
|
296 |
-
<?php
|
297 |
-
}
|
298 |
-
add_action( '
|
299 |
-
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Display the subheader for the messages section
|
303 |
-
*
|
304 |
-
* @since 3.0.0
|
305 |
-
* @return void
|
306 |
-
*/
|
307 |
-
function username_changer_display_messages_subheader() {
|
308 |
-
?>
|
309 |
-
<div class="username-changer-settings-note">
|
310 |
-
<span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
|
311 |
-
<p><?php _e( 'The message settings fields allow the use of the following template tags:', 'username-changer' ); ?></p>
|
312 |
-
<?php echo username_changer_tags_list( 'message' ); ?>
|
313 |
-
</div>
|
314 |
-
<?php
|
315 |
-
}
|
316 |
-
add_action( 'username_changer_messages_subheader', 'username_changer_display_messages_subheader' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Register settings
|
4 |
+
*
|
5 |
+
* @package UsernameChanger\Admin\Settings\Register
|
6 |
+
* @since 3.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Setup the settings menu
|
18 |
+
*
|
19 |
+
* @since 3.0.0
|
20 |
+
* @param array $menu The default menu settings
|
21 |
+
* @return array $menu Our defined settings
|
22 |
+
*/
|
23 |
+
function username_changer_add_menu( $menu ) {
|
24 |
+
$menu['type'] = 'submenu';
|
25 |
+
$menu['page_title'] = __( 'Username Changer Settings', 'username-changer' );
|
26 |
+
$menu['menu_title'] = __( 'Username Changer', 'username-changer' );
|
27 |
+
|
28 |
+
return $menu;
|
29 |
+
}
|
30 |
+
add_filter( 'username_changer_menu', 'username_changer_add_menu' );
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Define our settings tabs
|
35 |
+
*
|
36 |
+
* @since 3.0.0
|
37 |
+
* @param array $tabs The default tabs
|
38 |
+
* @return array $tabs Our defined tabs
|
39 |
+
*/
|
40 |
+
function username_changer_settings_tabs( $tabs ) {
|
41 |
+
$tabs['settings'] = __( 'Settings', 'username-changer' );
|
42 |
+
$tabs['support'] = __( 'Support', 'username-changer' );
|
43 |
+
|
44 |
+
return $tabs;
|
45 |
+
}
|
46 |
+
add_filter( 'username_changer_settings_tabs', 'username_changer_settings_tabs' );
|
47 |
+
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Define settings sections
|
51 |
+
*
|
52 |
+
* @since 3.0.0
|
53 |
+
* @param array $sections The default sections
|
54 |
+
* @return array $sections Our defined sections
|
55 |
+
*/
|
56 |
+
function username_changer_registered_settings_sections( $sections ) {
|
57 |
+
$sections = array(
|
58 |
+
'settings' => apply_filters( 'username_changer_settings_sections_settings', array(
|
59 |
+
'main' => __( 'General Settings', 'username-changer' ),
|
60 |
+
'strings' => __( 'String Settings', 'username-changer' )
|
61 |
+
) ),
|
62 |
+
'support' => apply_filters( 'username_changer_settings_sections_support', array() )
|
63 |
+
);
|
64 |
+
|
65 |
+
return $sections;
|
66 |
+
}
|
67 |
+
add_filter( 'username_changer_registered_settings_sections', 'username_changer_registered_settings_sections' );
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Disable save button on unsavable tabs
|
72 |
+
*
|
73 |
+
* @since 3.0.0
|
74 |
+
* @return array $tabs The updated tabs
|
75 |
+
*/
|
76 |
+
function username_changer_define_unsavable_tabs() {
|
77 |
+
$tabs = array( 'support' );
|
78 |
+
|
79 |
+
return $tabs;
|
80 |
+
}
|
81 |
+
add_filter( 'username_changer_unsavable_tabs', 'username_changer_define_unsavable_tabs' );
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Define our settings
|
86 |
+
*
|
87 |
+
* @since 3.0.0
|
88 |
+
* @param array $settings The default settings
|
89 |
+
* @return array $settings Our defined settings
|
90 |
+
*/
|
91 |
+
function username_changer_registered_settings( $settings ) {
|
92 |
+
$new_settings = array(
|
93 |
+
// General Settings
|
94 |
+
'settings' => apply_filters( 'username_changer_settings_settings', array(
|
95 |
+
'main' => array(
|
96 |
+
array(
|
97 |
+
'id' => 'settings_header',
|
98 |
+
'name' => __( 'General Settings', 'username-changer' ),
|
99 |
+
'desc' => '',
|
100 |
+
'type' => 'header'
|
101 |
+
),
|
102 |
+
array(
|
103 |
+
'id' => 'allowed_roles',
|
104 |
+
'name' => __( 'Allowed Roles', 'username-changer' ),
|
105 |
+
'desc' => __( 'Select the user roles which are permitted to change their own username.', 'username-changer' ),
|
106 |
+
'type' => 'multicheck',
|
107 |
+
'options' => username_changer_get_user_roles(),
|
108 |
+
'tooltip_title' => __( 'Allowed Roles', 'username-changer' ),
|
109 |
+
'tooltip_desc' => __( 'Administrators can always change usernames, and are the only role capable of changing other users username.', 'username-changer' )
|
110 |
+
),
|
111 |
+
array(
|
112 |
+
'id' => 'minimum_length',
|
113 |
+
'name' => __( 'Minimum Length', 'username-changer' ),
|
114 |
+
'desc' => __( 'Specify the minimum allowed username length.', 'username-changer' ),
|
115 |
+
'type' => 'number',
|
116 |
+
'size' => 'small-text',
|
117 |
+
'min' => 3,
|
118 |
+
'step' => 1,
|
119 |
+
'std' => 3,
|
120 |
+
'tooltip_title' => __( 'Minimum Length', 'username-changer' ),
|
121 |
+
'tooltip_desc' => __( 'The minimum allowed length for usernames is {minlength} characters.', 'username-changer' )
|
122 |
+
),
|
123 |
+
array(
|
124 |
+
'id' => 'email_header',
|
125 |
+
'name' => __( 'Email Settings', 'username-changer' ),
|
126 |
+
'desc' => '',
|
127 |
+
'type' => 'header'
|
128 |
+
),
|
129 |
+
array(
|
130 |
+
'id' => 'enable_notifications',
|
131 |
+
'name' => __( 'Enable Email Notifications', 'username-changer' ),
|
132 |
+
'desc' => __( 'Enable to send notification emails when usernames are changed.', 'username-changer' ),
|
133 |
+
'type' => 'checkbox',
|
134 |
+
'tooltip_title' => __( 'Enable Email Notifications', 'username-changer' ),
|
135 |
+
'tooltip_desc' => __( 'Notifications are not sent when a user changes their own username.', 'username-changer' )
|
136 |
+
),
|
137 |
+
array(
|
138 |
+
'id' => 'email_subheader',
|
139 |
+
'name' => '',
|
140 |
+
'desc' => '',
|
141 |
+
'type' => 'hook'
|
142 |
+
),
|
143 |
+
array(
|
144 |
+
'id' => 'email_subject',
|
145 |
+
'name' => __( 'Email Subject', 'username-changer' ),
|
146 |
+
'desc' => __( 'Specify the subject for username change notifications.', 'username-changer' ),
|
147 |
+
'type' => 'text',
|
148 |
+
'std' => __( 'Username change notification - {sitename}', 'username-changer' ),
|
149 |
+
),
|
150 |
+
array(
|
151 |
+
'id' => 'email_message',
|
152 |
+
'name' => __( 'Email Message', 'username-changer' ),
|
153 |
+
'desc' => __( 'Specify the message to send for username change notifications.', 'username-changer' ),
|
154 |
+
'type' => 'editor',
|
155 |
+
'std' => __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' )
|
156 |
+
)
|
157 |
+
),
|
158 |
+
'strings' => array(
|
159 |
+
array(
|
160 |
+
'id' => 'button_labels_header',
|
161 |
+
'name' => __( 'Button Labels', 'username-changer' ),
|
162 |
+
'desc' => '',
|
163 |
+
'type' => 'header'
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'id' => 'change_button_label',
|
167 |
+
'name' => __( 'Change Button Label', 'username-changer' ),
|
168 |
+
'desc' => __( 'Customize the text for the \'change username\' button.', 'username-changer' ),
|
169 |
+
'type' => 'text',
|
170 |
+
'std' => __( 'Change Username', 'username-changer' )
|
171 |
+
),
|
172 |
+
array(
|
173 |
+
'id' => 'save_button_label',
|
174 |
+
'name' => __( 'Save Button Label', 'username-changer' ),
|
175 |
+
'desc' => __( 'Customize the text for the save buttton.', 'username-changer' ),
|
176 |
+
'type' => 'text',
|
177 |
+
'std' => __( 'Save Username', 'username-changer' )
|
178 |
+
),
|
179 |
+
array(
|
180 |
+
'id' => 'cancel_button_label',
|
181 |
+
'name' => __( 'Cancel Button Label', 'username-changer' ),
|
182 |
+
'desc' => __( 'Customize the text for the cancel button.', 'username-changer' ),
|
183 |
+
'type' => 'text',
|
184 |
+
'std' => __( 'Cancel', 'username-changer' )
|
185 |
+
),
|
186 |
+
array(
|
187 |
+
'id' => 'messages_header',
|
188 |
+
'name' => __( 'Messages', 'username-changer' ),
|
189 |
+
'desc' => 'test',
|
190 |
+
'type' => 'header'
|
191 |
+
),
|
192 |
+
array(
|
193 |
+
'id' => 'messages_subheader',
|
194 |
+
'name' => '',
|
195 |
+
'desc' => '',
|
196 |
+
'type' => 'hook'
|
197 |
+
),
|
198 |
+
array(
|
199 |
+
'id' => 'please_wait_message',
|
200 |
+
'name' => __( 'Please Wait Message', 'username-changer' ),
|
201 |
+
'desc' => __( 'Customize the text displayed while usernames are being checked.', 'username-changer' ),
|
202 |
+
'type' => 'text',
|
203 |
+
'std' => __( 'Please wait...', 'username-changer' )
|
204 |
+
),
|
205 |
+
array(
|
206 |
+
'id' => 'success_message',
|
207 |
+
'name' => __( 'Username Changed Message', 'username-changer' ),
|
208 |
+
'desc' => __( 'Customize the message displayed when a username is changed successfully.', 'username-changer' ),
|
209 |
+
'type' => 'text',
|
210 |
+
'std' => __( 'Username successfully changed to {new_username}.', 'username-changer' )
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'id' => 'relogin_message',
|
214 |
+
'name' => __( 'Relogin Message', 'username-changer' ),
|
215 |
+
'desc' => __( 'Customize the text for the relogin link shown if a user changes their own username.', 'username-changer' ),
|
216 |
+
'type' => 'text',
|
217 |
+
'std' => __( 'Click here to log back in.', 'username-changer' )
|
218 |
+
),
|
219 |
+
array(
|
220 |
+
'id' => 'error_short_username',
|
221 |
+
'name' => __( 'Short Username Error', 'username-changer' ),
|
222 |
+
'desc' => __( 'Customize the error displayed when a username is too short.', 'username-changer' ),
|
223 |
+
'type' => 'text',
|
224 |
+
'std' => __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' )
|
225 |
+
),
|
226 |
+
array(
|
227 |
+
'id' => 'error_wrong_permissions',
|
228 |
+
'name' => __( 'Wrong Permissions Error', 'username-changer' ),
|
229 |
+
'desc' => __( 'Customize the error displayed when a user attempts to change a username they do not have permission to change.', 'username-changer' ),
|
230 |
+
'type' => 'text',
|
231 |
+
'std' => __( 'You do not have the correct permissions to change this username.', 'username-changer' ),
|
232 |
+
'tooltip_title' => __( 'Wrong Permissions Error', 'username-changer' ),
|
233 |
+
'tooltip_desc' => __( 'In normal circumstances, this message should never be triggered. It exists only to provide an extra layer of security against unauthorized use.', 'username-changer' )
|
234 |
+
),
|
235 |
+
array(
|
236 |
+
'id' => 'error_duplicate_username',
|
237 |
+
'name' => __( 'Duplicate Username Error', 'username-changer' ),
|
238 |
+
'desc' => __( 'Customize the error displayed when a user attempts to change a username to something that is already in use.', 'username-changer' ),
|
239 |
+
'type' => 'text',
|
240 |
+
'std' => __( 'The username {new_username} is already in use. Please try again.', 'username-changer' )
|
241 |
+
)
|
242 |
+
)
|
243 |
+
) ),
|
244 |
+
'support' => apply_filters( 'username_changer_settings_support', array(
|
245 |
+
array(
|
246 |
+
'id' => 'support_header',
|
247 |
+
'name' => __( 'Username Changer Support', 'username-changer' ),
|
248 |
+
'desc' => '',
|
249 |
+
'type' => 'header'
|
250 |
+
),
|
251 |
+
array(
|
252 |
+
'id' => 'system_info',
|
253 |
+
'name' => __( 'System Info', 'username-changer' ),
|
254 |
+
'desc' => '',
|
255 |
+
'type' => 'sysinfo'
|
256 |
+
)
|
257 |
+
) )
|
258 |
+
);
|
259 |
+
|
260 |
+
return array_merge( $settings, $new_settings );
|
261 |
+
}
|
262 |
+
add_filter( 'username_changer_registered_settings', 'username_changer_registered_settings' );
|
263 |
+
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Display the subheader for the emails section
|
267 |
+
*
|
268 |
+
* @since 3.1.0
|
269 |
+
* @return void
|
270 |
+
*/
|
271 |
+
function username_changer_display_email_subheader() {
|
272 |
+
?>
|
273 |
+
<div class="username-changer-settings-note">
|
274 |
+
<span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
|
275 |
+
<p><?php _e( 'Emails allow the use of the following template tags:', 'username-changer' ); ?></p>
|
276 |
+
<?php echo username_changer_tags_list( 'email' ); ?>
|
277 |
+
</div>
|
278 |
+
<?php
|
279 |
+
}
|
280 |
+
add_action( 'username_changer_email_subheader', 'username_changer_display_email_subheader' );
|
281 |
+
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Display the subheader for the messages section
|
285 |
+
*
|
286 |
+
* @since 3.0.0
|
287 |
+
* @return void
|
288 |
+
*/
|
289 |
+
function username_changer_display_messages_subheader() {
|
290 |
+
?>
|
291 |
+
<div class="username-changer-settings-note">
|
292 |
+
<span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
|
293 |
+
<p><?php _e( 'The message settings fields allow the use of the following template tags:', 'username-changer' ); ?></p>
|
294 |
+
<?php echo username_changer_tags_list( 'message' ); ?>
|
295 |
+
</div>
|
296 |
+
<?php
|
297 |
+
}
|
298 |
+
add_action( 'username_changer_messages_subheader', 'username_changer_display_messages_subheader' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class.template-tags.php
CHANGED
@@ -1,505 +1,505 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template tags
|
4 |
-
*
|
5 |
-
* @package UsernameChanger\TemplateTags
|
6 |
-
* @since 3.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
|
16 |
-
class Username_Changer_Template_Tags {
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @access private
|
21 |
-
* @since 3.0.0
|
22 |
-
* @var array $tags Container for storing all tags
|
23 |
-
*/
|
24 |
-
private $tags;
|
25 |
-
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @access private
|
29 |
-
* @since 3.0.0
|
30 |
-
* @var string $old_username The old username of the user
|
31 |
-
*/
|
32 |
-
private $old_username;
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @access private
|
37 |
-
* @since 3.0.0
|
38 |
-
* @var string $new_username The new username of the user
|
39 |
-
*/
|
40 |
-
private $new_username;
|
41 |
-
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Add a template tag
|
45 |
-
*
|
46 |
-
* @access public
|
47 |
-
* @since 3.0.0
|
48 |
-
* @param string $tag Tag to be replaced
|
49 |
-
* @param string $desc Description of the tag
|
50 |
-
* @param array $context Context for the tag
|
51 |
-
* @param string $func The hook to run when tag is found
|
52 |
-
* @return void
|
53 |
-
*/
|
54 |
-
public function add( $tag, $desc, $context, $func ) {
|
55 |
-
if ( is_callable( $func ) ) {
|
56 |
-
$this->tags[ $tag ] = array(
|
57 |
-
'tag' => $tag,
|
58 |
-
'desc' => $desc,
|
59 |
-
'context' => $context,
|
60 |
-
'func' => $func
|
61 |
-
);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Remove a template tag
|
68 |
-
*
|
69 |
-
* @access public
|
70 |
-
* @since 3.0.0
|
71 |
-
* @param string $tag Tag to be removed
|
72 |
-
* @return void
|
73 |
-
*/
|
74 |
-
public function remove( $tag ) {
|
75 |
-
unset( $this->tags[ $tag ] );
|
76 |
-
}
|
77 |
-
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Check if $tag is a registered template tag
|
81 |
-
*
|
82 |
-
* @access public
|
83 |
-
* @since 3.0.0
|
84 |
-
* @param string $tag Tag to search for
|
85 |
-
* @return bool True if found, false otherwise
|
86 |
-
*/
|
87 |
-
public function template_tag_exists( $tag ) {
|
88 |
-
return array_key_exists( $tag, $this->tags );
|
89 |
-
}
|
90 |
-
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Returns a list of all tags
|
94 |
-
*
|
95 |
-
* @access public
|
96 |
-
* @since 3.0.0
|
97 |
-
* @param string $context The context to return tags for
|
98 |
-
* @return array $tags The available tags
|
99 |
-
*/
|
100 |
-
public function get_tags( $context ) {
|
101 |
-
$tags = $this->tags;
|
102 |
-
|
103 |
-
foreach ( $tags as $tag_id => $tag_data ) {
|
104 |
-
if ( ! in_array( $context, $tag_data['context'] ) ) {
|
105 |
-
unset( $tags[ $tag_id ] );
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
return $tags;
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Search content for tags and filter through their hooks
|
115 |
-
*
|
116 |
-
* @access public
|
117 |
-
* @since 3.0.0
|
118 |
-
* @param string $content Content to search
|
119 |
-
* @param string $old_username The old username of the user
|
120 |
-
* @param string $new_username The new username of the user
|
121 |
-
* @return string $new_content Filtered content
|
122 |
-
*/
|
123 |
-
public function do_tags( $content, $old_username = '', $new_username = '' ) {
|
124 |
-
// Ensure there is at least one tag
|
125 |
-
if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
|
126 |
-
return $content;
|
127 |
-
}
|
128 |
-
|
129 |
-
$this->old_username = $old_username;
|
130 |
-
$this->new_username = $new_username;
|
131 |
-
|
132 |
-
$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
|
133 |
-
|
134 |
-
$this->old_username = '';
|
135 |
-
$this->new_username = '';
|
136 |
-
|
137 |
-
return $new_content;
|
138 |
-
}
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Do a specific tag
|
143 |
-
*
|
144 |
-
* @access public
|
145 |
-
* @since 3.0.0
|
146 |
-
* @param $m Message
|
147 |
-
* @return mixed
|
148 |
-
*/
|
149 |
-
public function do_tag( $m ) {
|
150 |
-
// Get tag
|
151 |
-
$tag = $m[1];
|
152 |
-
|
153 |
-
// Return tag if tag not set
|
154 |
-
if ( ! $this->template_tag_exists( $tag ) ) {
|
155 |
-
return $m[0];
|
156 |
-
}
|
157 |
-
|
158 |
-
return call_user_func( $this->tags[ $tag ]['func'], $this->old_username, $this->new_username, $tag );
|
159 |
-
}
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Add a template tag
|
165 |
-
*
|
166 |
-
* @since 3.0.0
|
167 |
-
* @param string $tag Tag to be replaced
|
168 |
-
* @param string $desc Description of the tag
|
169 |
-
* @param array $context Context for the tag
|
170 |
-
* @param string $func The hook to run when tag is found
|
171 |
-
* @return void
|
172 |
-
*/
|
173 |
-
function username_changer_add_template_tag( $tag, $desc, $context, $func ) {
|
174 |
-
Username_Changer()->template_tags->add( $tag, $desc, $context, $func );
|
175 |
-
}
|
176 |
-
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Remove a template tag
|
180 |
-
*
|
181 |
-
* @since 3.0.0
|
182 |
-
* @param string $tag Template tag to remove
|
183 |
-
* @return void
|
184 |
-
*/
|
185 |
-
function username_changer_remove_template_tag( $tag ) {
|
186 |
-
Username_Changer()->template_tags->remove( $tag );
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Check if a text exists
|
192 |
-
*
|
193 |
-
* @since 3.0.0
|
194 |
-
* @param string $tag The string to check
|
195 |
-
* @return bool True if exists, false otherwise
|
196 |
-
*/
|
197 |
-
function username_changer_tag_exists( $tag ) {
|
198 |
-
return Username_Changer()->template_tags->template_tag_exists( $tag );
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Get all tags
|
204 |
-
*
|
205 |
-
* @since 3.0.0
|
206 |
-
* @param string $context The context to return tags for
|
207 |
-
* @return array The existing tags
|
208 |
-
*/
|
209 |
-
function username_changer_get_template_tags( $context = 'message' ) {
|
210 |
-
return Username_Changer()->template_tags->get_tags( $context );
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Get a formatted list of all available tags
|
216 |
-
*
|
217 |
-
* @since 3.0.0
|
218 |
-
* @param string $context The context to display
|
219 |
-
* @return string The formatted list
|
220 |
-
*/
|
221 |
-
function username_changer_tags_list( $context = 'message' ) {
|
222 |
-
// The list
|
223 |
-
$list = '';
|
224 |
-
|
225 |
-
// Get all tags
|
226 |
-
$tags = username_changer_get_template_tags( $context );
|
227 |
-
|
228 |
-
// Check
|
229 |
-
if ( count( $tags ) > 0 ) {
|
230 |
-
$list .= '<ul class="username-changer-template-tag-list">';
|
231 |
-
|
232 |
-
foreach ( $tags as $tag ) {
|
233 |
-
// Add tag to list
|
234 |
-
$list .= '<li class="username-changer-template-tag"><span>{' . $tag['tag'] . '}</span>' . $tag['desc'] . '</li>';
|
235 |
-
}
|
236 |
-
|
237 |
-
$list .= '</ul>';
|
238 |
-
}
|
239 |
-
|
240 |
-
// Return the list
|
241 |
-
return $list;
|
242 |
-
}
|
243 |
-
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Search content for tags and filter
|
247 |
-
*
|
248 |
-
* @since 3.0.0
|
249 |
-
* @param string $content Content to search
|
250 |
-
* @param string $old_username The old username of the user
|
251 |
-
* @param string $new_username The new username of the user
|
252 |
-
* @return string $content Filtered content
|
253 |
-
*/
|
254 |
-
function username_changer_do_tags( $content, $old_username = '', $new_username = '' ) {
|
255 |
-
// Replace all tags
|
256 |
-
$content = apply_filters( 'username_changer_do_tags', Username_Changer()->template_tags->do_tags( $content, $old_username, $new_username ) );
|
257 |
-
|
258 |
-
return $content;
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Load tags
|
264 |
-
*
|
265 |
-
* @since 3.0.0
|
266 |
-
* @return void
|
267 |
-
*/
|
268 |
-
function username_changer_load_template_tags() {
|
269 |
-
do_action( 'username_changer_add_template_tags' );
|
270 |
-
}
|
271 |
-
add_action( 'init', 'username_changer_load_template_tags', -999 );
|
272 |
-
|
273 |
-
|
274 |
-
/**
|
275 |
-
* Add default tags
|
276 |
-
*
|
277 |
-
* @since 3.0.0
|
278 |
-
* @return void
|
279 |
-
*/
|
280 |
-
function username_changer_setup_template_tags() {
|
281 |
-
// Setup default tags array
|
282 |
-
$tags = array(
|
283 |
-
array(
|
284 |
-
'tag' => 'old_username',
|
285 |
-
'desc' => __( 'The original username of the user', 'username-changer' ),
|
286 |
-
'context' => array( 'email', 'message' ),
|
287 |
-
'func' => 'username_changer_template_tag_old_username'
|
288 |
-
),
|
289 |
-
array(
|
290 |
-
'tag' => 'new_username',
|
291 |
-
'desc' => __( 'The new username of the user', 'username-changer' ),
|
292 |
-
'context' => array( 'email', 'message' ),
|
293 |
-
'func' => 'username_changer_template_tag_new_username'
|
294 |
-
),
|
295 |
-
array(
|
296 |
-
'tag' => 'email',
|
297 |
-
'desc' => __( 'The email address of the user', 'username-changer' ),
|
298 |
-
'context' => array( 'email' ),
|
299 |
-
'func' => 'username_changer_template_tag_email'
|
300 |
-
),
|
301 |
-
array(
|
302 |
-
'tag' => 'sitename',
|
303 |
-
'desc' => __( 'Your site name', 'username-changer' ),
|
304 |
-
'context' => array( 'email' ),
|
305 |
-
'func' => 'username_changer_template_tag_sitename'
|
306 |
-
),
|
307 |
-
array(
|
308 |
-
'tag' => 'siteurl',
|
309 |
-
'desc' => __( 'Your site URL', 'username-changer' ),
|
310 |
-
'context' => array( 'email' ),
|
311 |
-
'func' => 'username_changer_template_tag_siteurl'
|
312 |
-
),
|
313 |
-
array(
|
314 |
-
'tag' => 'loginurl',
|
315 |
-
'desc' => __( 'The login URL for your site', 'username-changer' ),
|
316 |
-
'context' => array( 'email' ),
|
317 |
-
'func' => 'username_changer_template_tag_loginurl'
|
318 |
-
),
|
319 |
-
array(
|
320 |
-
'tag' => 'date',
|
321 |
-
'desc' => __( 'Today\'s date', 'username-changer' ),
|
322 |
-
'context' => array( 'email' ),
|
323 |
-
'func' => 'username_changer_template_tag_date'
|
324 |
-
),
|
325 |
-
array(
|
326 |
-
'tag' => 'name',
|
327 |
-
'desc' => __( 'The first name of the user', 'username-changer' ),
|
328 |
-
'context' => array( 'email' ),
|
329 |
-
'func' => 'username_changer_template_tag_name'
|
330 |
-
),
|
331 |
-
array(
|
332 |
-
'tag' => 'fullname',
|
333 |
-
'desc' => __( 'The full name of the user, first and last', 'username-changer' ),
|
334 |
-
'context' => array( 'email' ),
|
335 |
-
'func' => 'username_changer_template_tag_fullname'
|
336 |
-
),
|
337 |
-
array(
|
338 |
-
'tag' => 'minlength',
|
339 |
-
'desc' => __( 'The minimum allowed username length', 'username-changer' ),
|
340 |
-
'context' => array( 'message' ),
|
341 |
-
'func' => 'username_changer_template_tag_minlength'
|
342 |
-
)
|
343 |
-
);
|
344 |
-
|
345 |
-
$tags = apply_filters( 'username_changer_template_tags', $tags );
|
346 |
-
|
347 |
-
foreach ( $tags as $tag ) {
|
348 |
-
username_changer_add_template_tag( $tag['tag'], $tag['desc'], $tag['context'], $tag['func'] );
|
349 |
-
}
|
350 |
-
}
|
351 |
-
add_action( 'username_changer_add_template_tags', 'username_changer_setup_template_tags' );
|
352 |
-
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Template tag: old_username
|
356 |
-
*
|
357 |
-
* @since 3.0.0
|
358 |
-
* @param string $old_username The old username of the user
|
359 |
-
* @param string $new_username The new username of the user
|
360 |
-
* @return string $username The original username of the user
|
361 |
-
*/
|
362 |
-
function username_changer_template_tag_old_username( $old_username, $new_username ) {
|
363 |
-
$current_user = wp_get_current_user();
|
364 |
-
$username = $current_user->user_login;
|
365 |
-
|
366 |
-
return '<strong>' . $username . '</strong>';
|
367 |
-
}
|
368 |
-
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Template tag: new_username
|
372 |
-
*
|
373 |
-
* @since 3.0.0
|
374 |
-
* @param string $old_username The old username of the user
|
375 |
-
* @param string $new_username The new username of the user
|
376 |
-
* @return string $username The new username of the user
|
377 |
-
*/
|
378 |
-
function username_changer_template_tag_new_username( $old_username, $new_username ) {
|
379 |
-
return '<strong>' . $new_username . '</strong>';
|
380 |
-
}
|
381 |
-
|
382 |
-
|
383 |
-
/**
|
384 |
-
* Template tag: email
|
385 |
-
*
|
386 |
-
* @since 3.0.0
|
387 |
-
* @param string $old_username The old username of the user
|
388 |
-
* @param string $new_username The new username of the user
|
389 |
-
* @return string $email The email address of the user
|
390 |
-
*/
|
391 |
-
function username_changer_template_tag_email( $old_username, $new_username ) {
|
392 |
-
$current_user = wp_get_current_user();
|
393 |
-
$email = $current_user->user_email;
|
394 |
-
|
395 |
-
return $email;
|
396 |
-
}
|
397 |
-
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Template tag: sitename
|
401 |
-
*
|
402 |
-
* @since 3.0.0
|
403 |
-
* @param string $old_username The old username of the user
|
404 |
-
* @param string $new_username The new username of the user
|
405 |
-
* @return string Site name
|
406 |
-
*/
|
407 |
-
function username_changer_template_tag_sitename( $old_username, $new_username ) {
|
408 |
-
return get_bloginfo( 'name' );
|
409 |
-
}
|
410 |
-
|
411 |
-
|
412 |
-
/**
|
413 |
-
* Template tag: siteurl
|
414 |
-
*
|
415 |
-
* @since 3.0.0
|
416 |
-
* @param string $old_username The old username of the user
|
417 |
-
* @param string $new_username The new username of the user
|
418 |
-
* @return string Site URL
|
419 |
-
*/
|
420 |
-
function username_changer_template_tag_siteurl( $old_username, $new_username ) {
|
421 |
-
return get_site_url();
|
422 |
-
}
|
423 |
-
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Template tag: loginurl
|
427 |
-
*
|
428 |
-
* @since 3.0.0
|
429 |
-
* @param string $old_username The old username of the user
|
430 |
-
* @param string $new_username The new username of the user
|
431 |
-
* @return string Site URL
|
432 |
-
*/
|
433 |
-
function username_changer_template_tag_loginurl( $old_username, $new_username ) {
|
434 |
-
return wp_login_url();
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
/**
|
439 |
-
* Template tag: date
|
440 |
-
*
|
441 |
-
* @since 3.0.0
|
442 |
-
* @param string $old_username The old username of the user
|
443 |
-
* @param string $new_username The new username of the user
|
444 |
-
* @return string The purchase date
|
445 |
-
*/
|
446 |
-
function username_changer_template_tag_date( $old_username, $new_username ) {
|
447 |
-
return date_i18n( get_option( 'date_format' ), strtotime( date( 'U' ) ) );
|
448 |
-
}
|
449 |
-
|
450 |
-
|
451 |
-
/**
|
452 |
-
* Template tag: name
|
453 |
-
*
|
454 |
-
* @since 3.0.0
|
455 |
-
* @param string $old_username The old username of the user
|
456 |
-
* @param string $new_username The new username of the user
|
457 |
-
* @return string $name The first name of the user
|
458 |
-
*/
|
459 |
-
function username_changer_template_tag_name( $old_username, $new_username ) {
|
460 |
-
$current_user = get_user_by( 'login', $new_username );
|
461 |
-
|
462 |
-
if ( isset( $current_user->user_firstname ) ) {
|
463 |
-
$name = $current_user->user_firstname;
|
464 |
-
} else {
|
465 |
-
$name = $current_user->user_email;
|
466 |
-
}
|
467 |
-
|
468 |
-
return $name;
|
469 |
-
}
|
470 |
-
|
471 |
-
|
472 |
-
/**
|
473 |
-
* Template tag: fullname
|
474 |
-
*
|
475 |
-
* @since 3.0.0
|
476 |
-
* @param string $old_username The old username of the user
|
477 |
-
* @param string $new_username The new username of the user
|
478 |
-
* @return string $name The full name of the user
|
479 |
-
*/
|
480 |
-
function username_changer_template_tag_fullname( $old_username, $new_username ) {
|
481 |
-
$current_user = get_user_by( 'login', $new_username );
|
482 |
-
|
483 |
-
if ( isset( $current_user->user_firstname ) && isset( $current_user->user_lastname ) ) {
|
484 |
-
$name = $current_user->user_firstname . ' ' . $current_user->user_lastname;
|
485 |
-
} elseif ( isset( $current_user->user_firstname ) ) {
|
486 |
-
$name = $current_user->user_firstname;
|
487 |
-
} else {
|
488 |
-
$name = $current_user->user_email;
|
489 |
-
}
|
490 |
-
|
491 |
-
return $name;
|
492 |
-
}
|
493 |
-
|
494 |
-
|
495 |
-
/**
|
496 |
-
* Template tag: minlength
|
497 |
-
*
|
498 |
-
* @since 3.0.0
|
499 |
-
* @param string $old_username The old username of the user
|
500 |
-
* @param string $new_username The new username of the user
|
501 |
-
* @return string $minlength The minimum username length
|
502 |
-
*/
|
503 |
-
function username_changer_template_tag_minlength( $old_username, $new_username ) {
|
504 |
-
return username_changer()->settings->get_option( 'minimum_length', 3 );
|
505 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template tags
|
4 |
+
*
|
5 |
+
* @package UsernameChanger\TemplateTags
|
6 |
+
* @since 3.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
class Username_Changer_Template_Tags {
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @access private
|
21 |
+
* @since 3.0.0
|
22 |
+
* @var array $tags Container for storing all tags
|
23 |
+
*/
|
24 |
+
private $tags;
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @access private
|
29 |
+
* @since 3.0.0
|
30 |
+
* @var string $old_username The old username of the user
|
31 |
+
*/
|
32 |
+
private $old_username;
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @access private
|
37 |
+
* @since 3.0.0
|
38 |
+
* @var string $new_username The new username of the user
|
39 |
+
*/
|
40 |
+
private $new_username;
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Add a template tag
|
45 |
+
*
|
46 |
+
* @access public
|
47 |
+
* @since 3.0.0
|
48 |
+
* @param string $tag Tag to be replaced
|
49 |
+
* @param string $desc Description of the tag
|
50 |
+
* @param array $context Context for the tag
|
51 |
+
* @param string $func The hook to run when tag is found
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function add( $tag, $desc, $context, $func ) {
|
55 |
+
if ( is_callable( $func ) ) {
|
56 |
+
$this->tags[ $tag ] = array(
|
57 |
+
'tag' => $tag,
|
58 |
+
'desc' => $desc,
|
59 |
+
'context' => $context,
|
60 |
+
'func' => $func
|
61 |
+
);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Remove a template tag
|
68 |
+
*
|
69 |
+
* @access public
|
70 |
+
* @since 3.0.0
|
71 |
+
* @param string $tag Tag to be removed
|
72 |
+
* @return void
|
73 |
+
*/
|
74 |
+
public function remove( $tag ) {
|
75 |
+
unset( $this->tags[ $tag ] );
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Check if $tag is a registered template tag
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @since 3.0.0
|
84 |
+
* @param string $tag Tag to search for
|
85 |
+
* @return bool True if found, false otherwise
|
86 |
+
*/
|
87 |
+
public function template_tag_exists( $tag ) {
|
88 |
+
return array_key_exists( $tag, $this->tags );
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Returns a list of all tags
|
94 |
+
*
|
95 |
+
* @access public
|
96 |
+
* @since 3.0.0
|
97 |
+
* @param string $context The context to return tags for
|
98 |
+
* @return array $tags The available tags
|
99 |
+
*/
|
100 |
+
public function get_tags( $context ) {
|
101 |
+
$tags = $this->tags;
|
102 |
+
|
103 |
+
foreach ( $tags as $tag_id => $tag_data ) {
|
104 |
+
if ( ! in_array( $context, $tag_data['context'] ) ) {
|
105 |
+
unset( $tags[ $tag_id ] );
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return $tags;
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Search content for tags and filter through their hooks
|
115 |
+
*
|
116 |
+
* @access public
|
117 |
+
* @since 3.0.0
|
118 |
+
* @param string $content Content to search
|
119 |
+
* @param string $old_username The old username of the user
|
120 |
+
* @param string $new_username The new username of the user
|
121 |
+
* @return string $new_content Filtered content
|
122 |
+
*/
|
123 |
+
public function do_tags( $content, $old_username = '', $new_username = '' ) {
|
124 |
+
// Ensure there is at least one tag
|
125 |
+
if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
|
126 |
+
return $content;
|
127 |
+
}
|
128 |
+
|
129 |
+
$this->old_username = $old_username;
|
130 |
+
$this->new_username = $new_username;
|
131 |
+
|
132 |
+
$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
|
133 |
+
|
134 |
+
$this->old_username = '';
|
135 |
+
$this->new_username = '';
|
136 |
+
|
137 |
+
return $new_content;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Do a specific tag
|
143 |
+
*
|
144 |
+
* @access public
|
145 |
+
* @since 3.0.0
|
146 |
+
* @param $m Message
|
147 |
+
* @return mixed
|
148 |
+
*/
|
149 |
+
public function do_tag( $m ) {
|
150 |
+
// Get tag
|
151 |
+
$tag = $m[1];
|
152 |
+
|
153 |
+
// Return tag if tag not set
|
154 |
+
if ( ! $this->template_tag_exists( $tag ) ) {
|
155 |
+
return $m[0];
|
156 |
+
}
|
157 |
+
|
158 |
+
return call_user_func( $this->tags[ $tag ]['func'], $this->old_username, $this->new_username, $tag );
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Add a template tag
|
165 |
+
*
|
166 |
+
* @since 3.0.0
|
167 |
+
* @param string $tag Tag to be replaced
|
168 |
+
* @param string $desc Description of the tag
|
169 |
+
* @param array $context Context for the tag
|
170 |
+
* @param string $func The hook to run when tag is found
|
171 |
+
* @return void
|
172 |
+
*/
|
173 |
+
function username_changer_add_template_tag( $tag, $desc, $context, $func ) {
|
174 |
+
Username_Changer()->template_tags->add( $tag, $desc, $context, $func );
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Remove a template tag
|
180 |
+
*
|
181 |
+
* @since 3.0.0
|
182 |
+
* @param string $tag Template tag to remove
|
183 |
+
* @return void
|
184 |
+
*/
|
185 |
+
function username_changer_remove_template_tag( $tag ) {
|
186 |
+
Username_Changer()->template_tags->remove( $tag );
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Check if a text exists
|
192 |
+
*
|
193 |
+
* @since 3.0.0
|
194 |
+
* @param string $tag The string to check
|
195 |
+
* @return bool True if exists, false otherwise
|
196 |
+
*/
|
197 |
+
function username_changer_tag_exists( $tag ) {
|
198 |
+
return Username_Changer()->template_tags->template_tag_exists( $tag );
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get all tags
|
204 |
+
*
|
205 |
+
* @since 3.0.0
|
206 |
+
* @param string $context The context to return tags for
|
207 |
+
* @return array The existing tags
|
208 |
+
*/
|
209 |
+
function username_changer_get_template_tags( $context = 'message' ) {
|
210 |
+
return Username_Changer()->template_tags->get_tags( $context );
|
211 |
+
}
|
212 |
+
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Get a formatted list of all available tags
|
216 |
+
*
|
217 |
+
* @since 3.0.0
|
218 |
+
* @param string $context The context to display
|
219 |
+
* @return string The formatted list
|
220 |
+
*/
|
221 |
+
function username_changer_tags_list( $context = 'message' ) {
|
222 |
+
// The list
|
223 |
+
$list = '';
|
224 |
+
|
225 |
+
// Get all tags
|
226 |
+
$tags = username_changer_get_template_tags( $context );
|
227 |
+
|
228 |
+
// Check
|
229 |
+
if ( count( $tags ) > 0 ) {
|
230 |
+
$list .= '<ul class="username-changer-template-tag-list">';
|
231 |
+
|
232 |
+
foreach ( $tags as $tag ) {
|
233 |
+
// Add tag to list
|
234 |
+
$list .= '<li class="username-changer-template-tag"><span>{' . $tag['tag'] . '}</span>' . $tag['desc'] . '</li>';
|
235 |
+
}
|
236 |
+
|
237 |
+
$list .= '</ul>';
|
238 |
+
}
|
239 |
+
|
240 |
+
// Return the list
|
241 |
+
return $list;
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Search content for tags and filter
|
247 |
+
*
|
248 |
+
* @since 3.0.0
|
249 |
+
* @param string $content Content to search
|
250 |
+
* @param string $old_username The old username of the user
|
251 |
+
* @param string $new_username The new username of the user
|
252 |
+
* @return string $content Filtered content
|
253 |
+
*/
|
254 |
+
function username_changer_do_tags( $content, $old_username = '', $new_username = '' ) {
|
255 |
+
// Replace all tags
|
256 |
+
$content = apply_filters( 'username_changer_do_tags', Username_Changer()->template_tags->do_tags( $content, $old_username, $new_username ) );
|
257 |
+
|
258 |
+
return $content;
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Load tags
|
264 |
+
*
|
265 |
+
* @since 3.0.0
|
266 |
+
* @return void
|
267 |
+
*/
|
268 |
+
function username_changer_load_template_tags() {
|
269 |
+
do_action( 'username_changer_add_template_tags' );
|
270 |
+
}
|
271 |
+
add_action( 'init', 'username_changer_load_template_tags', -999 );
|
272 |
+
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Add default tags
|
276 |
+
*
|
277 |
+
* @since 3.0.0
|
278 |
+
* @return void
|
279 |
+
*/
|
280 |
+
function username_changer_setup_template_tags() {
|
281 |
+
// Setup default tags array
|
282 |
+
$tags = array(
|
283 |
+
array(
|
284 |
+
'tag' => 'old_username',
|
285 |
+
'desc' => __( 'The original username of the user', 'username-changer' ),
|
286 |
+
'context' => array( 'email', 'message' ),
|
287 |
+
'func' => 'username_changer_template_tag_old_username'
|
288 |
+
),
|
289 |
+
array(
|
290 |
+
'tag' => 'new_username',
|
291 |
+
'desc' => __( 'The new username of the user', 'username-changer' ),
|
292 |
+
'context' => array( 'email', 'message' ),
|
293 |
+
'func' => 'username_changer_template_tag_new_username'
|
294 |
+
),
|
295 |
+
array(
|
296 |
+
'tag' => 'email',
|
297 |
+
'desc' => __( 'The email address of the user', 'username-changer' ),
|
298 |
+
'context' => array( 'email' ),
|
299 |
+
'func' => 'username_changer_template_tag_email'
|
300 |
+
),
|
301 |
+
array(
|
302 |
+
'tag' => 'sitename',
|
303 |
+
'desc' => __( 'Your site name', 'username-changer' ),
|
304 |
+
'context' => array( 'email' ),
|
305 |
+
'func' => 'username_changer_template_tag_sitename'
|
306 |
+
),
|
307 |
+
array(
|
308 |
+
'tag' => 'siteurl',
|
309 |
+
'desc' => __( 'Your site URL', 'username-changer' ),
|
310 |
+
'context' => array( 'email' ),
|
311 |
+
'func' => 'username_changer_template_tag_siteurl'
|
312 |
+
),
|
313 |
+
array(
|
314 |
+
'tag' => 'loginurl',
|
315 |
+
'desc' => __( 'The login URL for your site', 'username-changer' ),
|
316 |
+
'context' => array( 'email' ),
|
317 |
+
'func' => 'username_changer_template_tag_loginurl'
|
318 |
+
),
|
319 |
+
array(
|
320 |
+
'tag' => 'date',
|
321 |
+
'desc' => __( 'Today\'s date', 'username-changer' ),
|
322 |
+
'context' => array( 'email' ),
|
323 |
+
'func' => 'username_changer_template_tag_date'
|
324 |
+
),
|
325 |
+
array(
|
326 |
+
'tag' => 'name',
|
327 |
+
'desc' => __( 'The first name of the user', 'username-changer' ),
|
328 |
+
'context' => array( 'email' ),
|
329 |
+
'func' => 'username_changer_template_tag_name'
|
330 |
+
),
|
331 |
+
array(
|
332 |
+
'tag' => 'fullname',
|
333 |
+
'desc' => __( 'The full name of the user, first and last', 'username-changer' ),
|
334 |
+
'context' => array( 'email' ),
|
335 |
+
'func' => 'username_changer_template_tag_fullname'
|
336 |
+
),
|
337 |
+
array(
|
338 |
+
'tag' => 'minlength',
|
339 |
+
'desc' => __( 'The minimum allowed username length', 'username-changer' ),
|
340 |
+
'context' => array( 'message' ),
|
341 |
+
'func' => 'username_changer_template_tag_minlength'
|
342 |
+
)
|
343 |
+
);
|
344 |
+
|
345 |
+
$tags = apply_filters( 'username_changer_template_tags', $tags );
|
346 |
+
|
347 |
+
foreach ( $tags as $tag ) {
|
348 |
+
username_changer_add_template_tag( $tag['tag'], $tag['desc'], $tag['context'], $tag['func'] );
|
349 |
+
}
|
350 |
+
}
|
351 |
+
add_action( 'username_changer_add_template_tags', 'username_changer_setup_template_tags' );
|
352 |
+
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Template tag: old_username
|
356 |
+
*
|
357 |
+
* @since 3.0.0
|
358 |
+
* @param string $old_username The old username of the user
|
359 |
+
* @param string $new_username The new username of the user
|
360 |
+
* @return string $username The original username of the user
|
361 |
+
*/
|
362 |
+
function username_changer_template_tag_old_username( $old_username, $new_username ) {
|
363 |
+
$current_user = wp_get_current_user();
|
364 |
+
$username = $current_user->user_login;
|
365 |
+
|
366 |
+
return '<strong>' . $username . '</strong>';
|
367 |
+
}
|
368 |
+
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Template tag: new_username
|
372 |
+
*
|
373 |
+
* @since 3.0.0
|
374 |
+
* @param string $old_username The old username of the user
|
375 |
+
* @param string $new_username The new username of the user
|
376 |
+
* @return string $username The new username of the user
|
377 |
+
*/
|
378 |
+
function username_changer_template_tag_new_username( $old_username, $new_username ) {
|
379 |
+
return '<strong>' . $new_username . '</strong>';
|
380 |
+
}
|
381 |
+
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Template tag: email
|
385 |
+
*
|
386 |
+
* @since 3.0.0
|
387 |
+
* @param string $old_username The old username of the user
|
388 |
+
* @param string $new_username The new username of the user
|
389 |
+
* @return string $email The email address of the user
|
390 |
+
*/
|
391 |
+
function username_changer_template_tag_email( $old_username, $new_username ) {
|
392 |
+
$current_user = wp_get_current_user();
|
393 |
+
$email = $current_user->user_email;
|
394 |
+
|
395 |
+
return $email;
|
396 |
+
}
|
397 |
+
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Template tag: sitename
|
401 |
+
*
|
402 |
+
* @since 3.0.0
|
403 |
+
* @param string $old_username The old username of the user
|
404 |
+
* @param string $new_username The new username of the user
|
405 |
+
* @return string Site name
|
406 |
+
*/
|
407 |
+
function username_changer_template_tag_sitename( $old_username, $new_username ) {
|
408 |
+
return get_bloginfo( 'name' );
|
409 |
+
}
|
410 |
+
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Template tag: siteurl
|
414 |
+
*
|
415 |
+
* @since 3.0.0
|
416 |
+
* @param string $old_username The old username of the user
|
417 |
+
* @param string $new_username The new username of the user
|
418 |
+
* @return string Site URL
|
419 |
+
*/
|
420 |
+
function username_changer_template_tag_siteurl( $old_username, $new_username ) {
|
421 |
+
return get_site_url();
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Template tag: loginurl
|
427 |
+
*
|
428 |
+
* @since 3.0.0
|
429 |
+
* @param string $old_username The old username of the user
|
430 |
+
* @param string $new_username The new username of the user
|
431 |
+
* @return string Site URL
|
432 |
+
*/
|
433 |
+
function username_changer_template_tag_loginurl( $old_username, $new_username ) {
|
434 |
+
return wp_login_url();
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Template tag: date
|
440 |
+
*
|
441 |
+
* @since 3.0.0
|
442 |
+
* @param string $old_username The old username of the user
|
443 |
+
* @param string $new_username The new username of the user
|
444 |
+
* @return string The purchase date
|
445 |
+
*/
|
446 |
+
function username_changer_template_tag_date( $old_username, $new_username ) {
|
447 |
+
return date_i18n( get_option( 'date_format' ), strtotime( date( 'U' ) ) );
|
448 |
+
}
|
449 |
+
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Template tag: name
|
453 |
+
*
|
454 |
+
* @since 3.0.0
|
455 |
+
* @param string $old_username The old username of the user
|
456 |
+
* @param string $new_username The new username of the user
|
457 |
+
* @return string $name The first name of the user
|
458 |
+
*/
|
459 |
+
function username_changer_template_tag_name( $old_username, $new_username ) {
|
460 |
+
$current_user = get_user_by( 'login', $new_username );
|
461 |
+
|
462 |
+
if ( isset( $current_user->user_firstname ) ) {
|
463 |
+
$name = $current_user->user_firstname;
|
464 |
+
} else {
|
465 |
+
$name = $current_user->user_email;
|
466 |
+
}
|
467 |
+
|
468 |
+
return $name;
|
469 |
+
}
|
470 |
+
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Template tag: fullname
|
474 |
+
*
|
475 |
+
* @since 3.0.0
|
476 |
+
* @param string $old_username The old username of the user
|
477 |
+
* @param string $new_username The new username of the user
|
478 |
+
* @return string $name The full name of the user
|
479 |
+
*/
|
480 |
+
function username_changer_template_tag_fullname( $old_username, $new_username ) {
|
481 |
+
$current_user = get_user_by( 'login', $new_username );
|
482 |
+
|
483 |
+
if ( isset( $current_user->user_firstname ) && isset( $current_user->user_lastname ) ) {
|
484 |
+
$name = $current_user->user_firstname . ' ' . $current_user->user_lastname;
|
485 |
+
} elseif ( isset( $current_user->user_firstname ) ) {
|
486 |
+
$name = $current_user->user_firstname;
|
487 |
+
} else {
|
488 |
+
$name = $current_user->user_email;
|
489 |
+
}
|
490 |
+
|
491 |
+
return $name;
|
492 |
+
}
|
493 |
+
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Template tag: minlength
|
497 |
+
*
|
498 |
+
* @since 3.0.0
|
499 |
+
* @param string $old_username The old username of the user
|
500 |
+
* @param string $new_username The new username of the user
|
501 |
+
* @return string $minlength The minimum username length
|
502 |
+
*/
|
503 |
+
function username_changer_template_tag_minlength( $old_username, $new_username ) {
|
504 |
+
return username_changer()->settings->get_option( 'minimum_length', 3 );
|
505 |
+
}
|
includes/functions.php
CHANGED
@@ -1,161 +1,157 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Helper functions
|
4 |
-
*
|
5 |
-
* @package Username_Changer\Functions
|
6 |
-
* @since 2.1.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Get an array of user roles
|
18 |
-
*
|
19 |
-
* @since 3.0.0
|
20 |
-
* @return array $roles The available user roles
|
21 |
-
*/
|
22 |
-
function username_changer_get_user_roles() {
|
23 |
-
global $wp_roles;
|
24 |
-
|
25 |
-
$roles = $wp_roles->get_names();
|
26 |
-
|
27 |
-
// Administrator can always edit
|
28 |
-
unset( $roles['administrator'] );
|
29 |
-
|
30 |
-
return apply_filters( 'username_changer_user_roles', $roles );
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Check if a user can change a given username
|
36 |
-
*
|
37 |
-
* @since 3.0.0
|
38 |
-
* @return bool $allowed Whether or not this user can change their username
|
39 |
-
*/
|
40 |
-
function username_changer_can_change_own_username() {
|
41 |
-
$allowed = false;
|
42 |
-
|
43 |
-
if ( is_user_logged_in() ) {
|
44 |
-
$allowed_roles = username_changer()->settings->get_option( 'allowed_roles', array() );
|
45 |
-
$user_data = wp_get_current_user();
|
46 |
-
$user_roles = $user_data->roles;
|
47 |
-
|
48 |
-
if ( in_array( 'administrator', $user_roles ) ) {
|
49 |
-
$allowed = true;
|
50 |
-
} elseif ( is_array( $user_roles ) ) {
|
51 |
-
foreach ( $user_roles as $user_role => $role_name ) {
|
52 |
-
if ( in_array( $user_role, $allowed_roles ) ) {
|
53 |
-
$allowed = true;
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
return apply_filters( 'username_changer_can_change_own_username', $allowed );
|
60 |
-
}
|
61 |
-
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Process a username change
|
65 |
-
*
|
66 |
-
* @since 3.0.0
|
67 |
-
* @param string $old_username The old (current) username
|
68 |
-
* @param string $new_username The new username
|
69 |
-
* @return bool $return Whether or not we completed successfully
|
70 |
-
*/
|
71 |
-
function username_changer_process( $old_username, $new_username ) {
|
72 |
-
global $wpdb;
|
73 |
-
|
74 |
-
$return = false;
|
75 |
-
|
76 |
-
// One last sanity check to ensure the user exists
|
77 |
-
$user_id = username_exists( $old_username );
|
78 |
-
if ( $user_id ) {
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
'
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
);
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
*
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
return $ret;
|
161 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Helper functions
|
4 |
+
*
|
5 |
+
* @package Username_Changer\Functions
|
6 |
+
* @since 2.1.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get an array of user roles
|
18 |
+
*
|
19 |
+
* @since 3.0.0
|
20 |
+
* @return array $roles The available user roles
|
21 |
+
*/
|
22 |
+
function username_changer_get_user_roles() {
|
23 |
+
global $wp_roles;
|
24 |
+
|
25 |
+
$roles = $wp_roles->get_names();
|
26 |
+
|
27 |
+
// Administrator can always edit
|
28 |
+
unset( $roles['administrator'] );
|
29 |
+
|
30 |
+
return apply_filters( 'username_changer_user_roles', $roles );
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Check if a user can change a given username
|
36 |
+
*
|
37 |
+
* @since 3.0.0
|
38 |
+
* @return bool $allowed Whether or not this user can change their username
|
39 |
+
*/
|
40 |
+
function username_changer_can_change_own_username() {
|
41 |
+
$allowed = false;
|
42 |
+
|
43 |
+
if ( is_user_logged_in() ) {
|
44 |
+
$allowed_roles = username_changer()->settings->get_option( 'allowed_roles', array() );
|
45 |
+
$user_data = wp_get_current_user();
|
46 |
+
$user_roles = $user_data->roles;
|
47 |
+
|
48 |
+
if ( in_array( 'administrator', $user_roles ) ) {
|
49 |
+
$allowed = true;
|
50 |
+
} elseif ( is_array( $user_roles ) ) {
|
51 |
+
foreach ( $user_roles as $user_role => $role_name ) {
|
52 |
+
if ( in_array( $user_role, $allowed_roles ) ) {
|
53 |
+
$allowed = true;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
return apply_filters( 'username_changer_can_change_own_username', $allowed );
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Process a username change
|
65 |
+
*
|
66 |
+
* @since 3.0.0
|
67 |
+
* @param string $old_username The old (current) username
|
68 |
+
* @param string $new_username The new username
|
69 |
+
* @return bool $return Whether or not we completed successfully
|
70 |
+
*/
|
71 |
+
function username_changer_process( $old_username, $new_username ) {
|
72 |
+
global $wpdb;
|
73 |
+
|
74 |
+
$return = false;
|
75 |
+
|
76 |
+
// One last sanity check to ensure the user exists
|
77 |
+
$user_id = username_exists( $old_username );
|
78 |
+
if ( $user_id ) {
|
79 |
+
// Update username!
|
80 |
+
$q = $wpdb->prepare( "UPDATE $wpdb->users SET user_login = %s WHERE user_login = %s", $new_username, $old_username );
|
81 |
+
|
82 |
+
if ( false !== $wpdb->query( $q ) ) {
|
83 |
+
// Update user_nicename
|
84 |
+
$qnn = $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %s WHERE user_login = %s AND user_nicename = %s", $new_username, $new_username, $old_username );
|
85 |
+
$wpdb->query( $qnn );
|
86 |
+
|
87 |
+
// Update display_name
|
88 |
+
$qdn = $wpdb->prepare( "UPDATE $wpdb->users SET display_name = %s WHERE user_login = %s AND display_name = %s", $new_username, $new_username, $old_username );
|
89 |
+
$wpdb->query( $qdn );
|
90 |
+
|
91 |
+
// Update nickname
|
92 |
+
$nickname = get_user_meta( $user_id, 'nickname', true );
|
93 |
+
if ( $nickname == $old_username ) {
|
94 |
+
update_user_meta( $user_id, 'nickname', $new_username );
|
95 |
+
}
|
96 |
+
|
97 |
+
// If the user is a Super Admin, update their permissions
|
98 |
+
if ( is_multisite() && is_super_admin( $user_id ) ) {
|
99 |
+
grant_super_admin( $user_id );
|
100 |
+
}
|
101 |
+
|
102 |
+
// Reassign Coauthor Attribution
|
103 |
+
if ( username_changer_plugin_installed( 'co-authors-plus/co-authors-plus.php' ) ) {
|
104 |
+
global $coauthors_plus;
|
105 |
+
|
106 |
+
$coauthor_posts = get_posts(
|
107 |
+
array(
|
108 |
+
'post_type' => get_post_types(),
|
109 |
+
'posts_per_page' => -1,
|
110 |
+
'tax_query' => array(
|
111 |
+
array(
|
112 |
+
'taxonomy' => $coauthors_plus->coauthor_taxonomy,
|
113 |
+
'field' => 'name',
|
114 |
+
'terms' => $old_username
|
115 |
+
)
|
116 |
+
)
|
117 |
+
)
|
118 |
+
);
|
119 |
+
|
120 |
+
$current_term = get_term_by( 'name', $old_username, $coauthors_plus->coauthor_taxonomy );
|
121 |
+
wp_delete_term( $current_term->term_id, $coauthors_plus->coauthor_taxonomy );
|
122 |
+
|
123 |
+
if ( ! empty( $coauthor_posts ) ) {
|
124 |
+
foreach ( $coauthor_posts as $coauthor_post ) {
|
125 |
+
$coauthors_plus->add_coauthors( $coauthor_post->ID, array( $new_username ), true );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
$return = true;
|
131 |
+
}
|
132 |
+
|
133 |
+
return $return;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Check if a plugin is installed
|
140 |
+
*
|
141 |
+
* @since 1.0.0
|
142 |
+
* @param string $plugin The path to the plugin to check
|
143 |
+
* @return boolean true if installed and active, false otherwise
|
144 |
+
*/
|
145 |
+
function username_changer_plugin_installed( $plugin = false ){
|
146 |
+
$ret = false;
|
147 |
+
|
148 |
+
if ( $plugin ) {
|
149 |
+
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
|
150 |
+
|
151 |
+
if ( in_array( $plugin, $active_plugins ) ) {
|
152 |
+
$ret = true;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
return $ret;
|
157 |
+
}
|
|
|
|
|
|
|
|
includes/libraries/s214-settings/source/class.s214-settings.php
CHANGED
@@ -124,6 +124,8 @@ class S214_Settings {
|
|
124 |
|
125 |
// Handle tooltips
|
126 |
add_filter( $this->func . '_after_setting_output', array( $this, 'add_setting_tooltip' ), 10, 2 );
|
|
|
|
|
127 |
}
|
128 |
|
129 |
|
@@ -797,6 +799,8 @@ class S214_Settings {
|
|
797 |
|
798 |
if( ! empty( $args['options'] ) ) {
|
799 |
$html = '';
|
|
|
|
|
800 |
|
801 |
foreach( $args['options'] as $key => $option ) {
|
802 |
if( isset( ${$this->func . '_options'}[$args['id']][$key] ) ) {
|
@@ -1234,4 +1238,39 @@ class S214_Settings {
|
|
1234 |
|
1235 |
return $html;
|
1236 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1237 |
}
|
124 |
|
125 |
// Handle tooltips
|
126 |
add_filter( $this->func . '_after_setting_output', array( $this, 'add_setting_tooltip' ), 10, 2 );
|
127 |
+
|
128 |
+
add_filter( "pre_update_option_{$this->func}_settings", array( $this, 'multicheck_empty_validation' ), 10, 3 );
|
129 |
}
|
130 |
|
131 |
|
799 |
|
800 |
if( ! empty( $args['options'] ) ) {
|
801 |
$html = '';
|
802 |
+
|
803 |
+
$html .= '<input type="hidden" name="' . $this->func . '_settings[_multicheck_fields][' . $args['id'] . ']' . '" value="' . $args['id'] . '">';
|
804 |
|
805 |
foreach( $args['options'] as $key => $option ) {
|
806 |
if( isset( ${$this->func . '_options'}[$args['id']][$key] ) ) {
|
1238 |
|
1239 |
return $html;
|
1240 |
}
|
1241 |
+
|
1242 |
+
/**
|
1243 |
+
* Hooks in on option pre-save and checks for empty multicheck groups. If no checkboxes in a group are checked,
|
1244 |
+
* the info about the fields are never passed to the $_POST array, and the updates are never saved.
|
1245 |
+
*
|
1246 |
+
* For every multicheck group, a hidden field is added, which adds to an array called _multicheck_fields. In this
|
1247 |
+
* function, we loop through all of these to check if the field group is set at all - and if it is not, we set the
|
1248 |
+
* value to an empty array.
|
1249 |
+
*
|
1250 |
+
* @hooked pre_update_option_{$option} - 10
|
1251 |
+
* @see option.php
|
1252 |
+
*
|
1253 |
+
* @param $value The current value of the option
|
1254 |
+
* @param $old_value The previous value of the option
|
1255 |
+
* @param $option The options name
|
1256 |
+
*
|
1257 |
+
* @return mixed The (maybe) updated option to be saved
|
1258 |
+
*/
|
1259 |
+
public function multicheck_empty_validation( $value, $old_value, $option ) {
|
1260 |
+
|
1261 |
+
if( ! isset( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] ) || empty( isset( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] ) ) ) {
|
1262 |
+
|
1263 |
+
return $value;
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
foreach( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] as $multicheck_field_name ) {
|
1267 |
+
|
1268 |
+
if( ! isset( $_POST[ $this->func . '_settings' ][ $multicheck_field_name ] ) || empty( $_POST[ $this->func . '_settings' ][ $multicheck_field_name ] ) ) {
|
1269 |
+
|
1270 |
+
$value[ $multicheck_field_name ] = [];
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
return $value;
|
1275 |
+
}
|
1276 |
}
|
includes/scripts.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Scripts
|
4 |
-
*
|
5 |
-
* @package UsernameChanger\Scripts
|
6 |
-
* @since 3.0.0
|
7 |
-
*/
|
8 |
-
|
9 |
-
|
10 |
-
// Exit if accessed directly
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Load admin scripts
|
18 |
-
*
|
19 |
-
* @since 1.0.0
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
function username_changer_admin_scripts() {
|
23 |
-
// Use minified libraries if SCRIPT_DEBUG is turned off
|
24 |
-
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
25 |
-
|
26 |
-
$minimum_length = username_changer()->settings->get_option( 'minimum_length', 3 );
|
27 |
-
$screen = get_current_screen();
|
28 |
-
|
29 |
-
wp_enqueue_style( 'username-changer', USERNAME_CHANGER_URL . 'assets/css/admin.css', array(), USERNAME_CHANGER_VER );
|
30 |
-
wp_enqueue_script( 'username-changer', USERNAME_CHANGER_URL . 'assets/js/admin.js', array( 'jquery' ), USERNAME_CHANGER_VER );
|
31 |
-
wp_localize_script( 'username-changer', 'username_changer_vars', array(
|
32 |
-
'nonce' => wp_create_nonce( 'change_username' ),
|
33 |
-
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
34 |
-
'change_button_label' => username_changer()->settings->get_option( 'change_button_label', __( 'Change Username', 'username-changer' ) ),
|
35 |
-
'save_button_label' => username_changer()->settings->get_option( 'save_button_label', __( 'Save Username', 'username-changer' ) ),
|
36 |
-
'cancel_button_label' => username_changer()->settings->get_option( 'cancel_button_label', __( 'Cancel', 'username-changer' ) ),
|
37 |
-
'please_wait_message' => username_changer()->settings->get_option( 'please_wait_message', __( 'Please wait...', 'username-changer' ) ),
|
38 |
-
'error_short_username' => username_changer_do_tags( username_changer()->settings->get_option( 'error_short_username', __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' ) ) ),
|
39 |
-
'current_screen' => $screen->id,
|
40 |
-
'can_change_username' => username_changer_can_change_own_username(),
|
41 |
-
'minimum_length' => $minimum_length
|
42 |
-
) );
|
43 |
-
}
|
44 |
-
add_action( 'admin_enqueue_scripts', 'username_changer_admin_scripts' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Scripts
|
4 |
+
*
|
5 |
+
* @package UsernameChanger\Scripts
|
6 |
+
* @since 3.0.0
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
// Exit if accessed directly
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Load admin scripts
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function username_changer_admin_scripts() {
|
23 |
+
// Use minified libraries if SCRIPT_DEBUG is turned off
|
24 |
+
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
25 |
+
|
26 |
+
$minimum_length = username_changer()->settings->get_option( 'minimum_length', 3 );
|
27 |
+
$screen = get_current_screen();
|
28 |
+
|
29 |
+
wp_enqueue_style( 'username-changer', USERNAME_CHANGER_URL . 'assets/css/admin.css', array(), USERNAME_CHANGER_VER );
|
30 |
+
wp_enqueue_script( 'username-changer', USERNAME_CHANGER_URL . 'assets/js/admin.js', array( 'jquery' ), USERNAME_CHANGER_VER );
|
31 |
+
wp_localize_script( 'username-changer', 'username_changer_vars', array(
|
32 |
+
'nonce' => wp_create_nonce( 'change_username' ),
|
33 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
34 |
+
'change_button_label' => username_changer()->settings->get_option( 'change_button_label', __( 'Change Username', 'username-changer' ) ),
|
35 |
+
'save_button_label' => username_changer()->settings->get_option( 'save_button_label', __( 'Save Username', 'username-changer' ) ),
|
36 |
+
'cancel_button_label' => username_changer()->settings->get_option( 'cancel_button_label', __( 'Cancel', 'username-changer' ) ),
|
37 |
+
'please_wait_message' => username_changer()->settings->get_option( 'please_wait_message', __( 'Please wait...', 'username-changer' ) ),
|
38 |
+
'error_short_username' => username_changer_do_tags( username_changer()->settings->get_option( 'error_short_username', __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' ) ) ),
|
39 |
+
'current_screen' => $screen->id,
|
40 |
+
'can_change_username' => username_changer_can_change_own_username(),
|
41 |
+
'minimum_length' => $minimum_length
|
42 |
+
) );
|
43 |
+
}
|
44 |
+
add_action( 'admin_enqueue_scripts', 'username_changer_admin_scripts' );
|
readme.md
CHANGED
@@ -1,26 +1,22 @@
|
|
1 |
-
# Username Changer
|
2 |
-
|
3 |
-
![Plugin Version](https://img.shields.io/wordpress/plugin/v/username-changer.svg
|
4 |
-
|
5 |
-
### Welcome to our GitHub Repository
|
6 |
-
|
7 |
-
Changing usernames _should_ be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
|
8 |
-
|
9 |
-
## Installation
|
10 |
-
|
11 |
-
1. You can clone the GitHub repository: `https://github.com/
|
12 |
-
2. Or download it directly as a ZIP file: `https://github.com/
|
13 |
-
|
14 |
-
This will download the latest developer copy of Username Changer.
|
15 |
-
|
16 |
-
## Bugs
|
17 |
-
|
18 |
-
If you find an issue, let us know [here](https://github.com/
|
19 |
-
|
20 |
-
##
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
## Contributions
|
25 |
-
|
26 |
-
Anyone is welcome to contribute to Username Changer. Please read the [guidelines for contributing](https://github.com/section214/username-changer/blob/master/CONTRIBUTING.md) to this repository.
|
1 |
+
# Username Changer
|
2 |
+
|
3 |
+
![Plugin Version](https://img.shields.io/wordpress/plugin/v/username-changer.svg) ![Total Downloads](https://img.shields.io/wordpress/plugin/dt/username-changer.svg) ![Plugin Rating](https://img.shields.io/wordpress/plugin/r/username-changer.svg) ![WordPress Compatibility](https://img.shields.io/wordpress/v/username-changer.svg) [![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://github.com/evertiro/username-changer/blob/master/license.txt)
|
4 |
+
|
5 |
+
### Welcome to our GitHub Repository
|
6 |
+
|
7 |
+
Changing usernames _should_ be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
|
8 |
+
|
9 |
+
## Installation
|
10 |
+
|
11 |
+
1. You can clone the GitHub repository: `https://github.com/evertiro/username-changer.git`
|
12 |
+
2. Or download it directly as a ZIP file: `https://github.com/evertiro/username-changer/archive/master.zip`
|
13 |
+
|
14 |
+
This will download the latest developer copy of Username Changer.
|
15 |
+
|
16 |
+
## Bugs
|
17 |
+
|
18 |
+
If you find an issue, let us know [here](https://github.com/evertiro/username-changer/issues?state=open)!
|
19 |
+
|
20 |
+
## Contributions
|
21 |
+
|
22 |
+
Anyone is welcome to contribute to Username Changer. Please read the [guidelines for contributing](https://github.com/evertiro/username-changer/blob/master/CONTRIBUTING.md) to this repository.
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,93 +1,94 @@
|
|
1 |
-
=== Username Changer ===
|
2 |
-
Contributors:
|
3 |
-
Donate link: https://
|
4 |
-
Tags: user, username, display name, login
|
5 |
-
Requires at least: 3.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 3.1.
|
8 |
-
|
9 |
-
Change usernames easily
|
10 |
-
|
11 |
-
== Description ==
|
12 |
-
|
13 |
-
Changing usernames should be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
|
14 |
-
|
15 |
-
== Installation ==
|
16 |
-
|
17 |
-
= From your WordPress dashboard =
|
18 |
-
|
19 |
-
1. Visit 'Plugins > Add New'
|
20 |
-
2. Search for 'Username Changer'
|
21 |
-
3. Activate Username Changer from your Plugins page
|
22 |
-
|
23 |
-
= From WordPress.org =
|
24 |
-
|
25 |
-
1. Download Username Changer
|
26 |
-
2. Upload the 'username-changer' folder to the '/wp-content/plugins' directory of your WordPress installation
|
27 |
-
3. Activate Username Changer from your Plugins page
|
28 |
-
|
29 |
-
== Frequently Asked Questions ==
|
30 |
-
|
31 |
-
= Is Username Changer compatible with <a href="https://wordpress.org/plugins/co-authors-plus/">Co-Authors Plus</a>? =
|
32 |
-
|
33 |
-
Yes! Username Changer works out of the box with Co-Authors Plus.
|
34 |
-
|
35 |
-
== Screenshots ==
|
36 |
-
|
37 |
-
1. **Settings Panel** - The settings panel allows you to configure username rules and message string, as well as providing a simple method for contacting our support.
|
38 |
-
2. **Changing A Username** - Since version 3.0.0, usernames are now changed through the user profile page.
|
39 |
-
|
40 |
== Changelog ==
|
41 |
-
= Version 3.1.1 =
|
42 |
-
* Added: Actions before and after update processing
|
43 |
|
44 |
-
= Version 3.1.
|
45 |
-
*
|
46 |
-
|
47 |
-
|
48 |
-
*
|
49 |
-
|
50 |
-
|
51 |
-
*
|
52 |
-
|
53 |
-
= Version 3.0.
|
54 |
-
*
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
*
|
59 |
-
|
60 |
-
= Version 2.
|
61 |
-
*
|
62 |
-
|
63 |
-
= Version 2.0.
|
64 |
-
*
|
65 |
-
|
66 |
-
= Version 2.0.
|
67 |
-
*
|
68 |
-
|
69 |
-
= Version 2.0.
|
70 |
-
*
|
71 |
-
|
72 |
-
= Version 2.0.
|
73 |
-
* Added:
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
* Improved:
|
78 |
-
|
79 |
-
= Version
|
80 |
-
*
|
81 |
-
|
82 |
-
= Version 1.
|
83 |
-
*
|
84 |
-
|
85 |
-
= Version 1.
|
86 |
-
* Fixed:
|
87 |
-
|
88 |
-
= Version 1.
|
89 |
-
*
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
*
|
|
|
|
|
|
1 |
+
=== Username Changer ===
|
2 |
+
Contributors: evertiro
|
3 |
+
Donate link: https://evertiro.com/donate/
|
4 |
+
Tags: user, username, display name, login
|
5 |
+
Requires at least: 3.0
|
6 |
+
Tested up to: 4.7.1
|
7 |
+
Stable tag: 3.1.2
|
8 |
+
|
9 |
+
Change usernames easily
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Changing usernames should be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
|
14 |
+
|
15 |
+
== Installation ==
|
16 |
+
|
17 |
+
= From your WordPress dashboard =
|
18 |
+
|
19 |
+
1. Visit 'Plugins > Add New'
|
20 |
+
2. Search for 'Username Changer'
|
21 |
+
3. Activate Username Changer from your Plugins page
|
22 |
+
|
23 |
+
= From WordPress.org =
|
24 |
+
|
25 |
+
1. Download Username Changer
|
26 |
+
2. Upload the 'username-changer' folder to the '/wp-content/plugins' directory of your WordPress installation
|
27 |
+
3. Activate Username Changer from your Plugins page
|
28 |
+
|
29 |
+
== Frequently Asked Questions ==
|
30 |
+
|
31 |
+
= Is Username Changer compatible with <a href="https://wordpress.org/plugins/co-authors-plus/">Co-Authors Plus</a>? =
|
32 |
+
|
33 |
+
Yes! Username Changer works out of the box with Co-Authors Plus.
|
34 |
+
|
35 |
+
== Screenshots ==
|
36 |
+
|
37 |
+
1. **Settings Panel** - The settings panel allows you to configure username rules and message string, as well as providing a simple method for contacting our support.
|
38 |
+
2. **Changing A Username** - Since version 3.0.0, usernames are now changed through the user profile page.
|
39 |
+
|
40 |
== Changelog ==
|
|
|
|
|
41 |
|
42 |
+
= Version 3.1.1 =
|
43 |
+
* Fixed: Issue with multicheck settings fields
|
44 |
+
|
45 |
+
+ Version 3.1.0 =
|
46 |
+
* Added: Email notification support
|
47 |
+
* Added: Nickname support
|
48 |
+
* Improved: SQL performance
|
49 |
+
* Improved: Dynamically update profile files
|
50 |
+
|
51 |
+
= Version 3.0.1 =
|
52 |
+
* Fixed: Typo in readme file
|
53 |
+
|
54 |
+
= Version 3.0.0 =
|
55 |
+
* Improved: Replaced the clunky interface with an inline profile field (props: Danny van Kooten)
|
56 |
+
* Added: Settings panel
|
57 |
+
|
58 |
+
= Version 2.1.1 =
|
59 |
+
* Removed: Deprecated functions
|
60 |
+
|
61 |
+
= Version 2.0.5 =
|
62 |
+
* Fixed: Contributor field
|
63 |
+
|
64 |
+
= Version 2.0.4 =
|
65 |
+
* Updated: Plugin metalinks
|
66 |
+
|
67 |
+
= Version 2.0.3 =
|
68 |
+
* Fixed: User nice name support
|
69 |
+
|
70 |
+
= Version 2.0.2 =
|
71 |
+
* Added: multisite support
|
72 |
+
|
73 |
+
= Version 2.0.1 =
|
74 |
+
* Added: Proper username sanitization
|
75 |
+
* Improved: Minor code cleanup
|
76 |
+
|
77 |
+
= Version 2.0.0 =
|
78 |
+
* Improved: Converted to class-based structure
|
79 |
+
|
80 |
+
= Version 1.4 =
|
81 |
+
* Added: Include author url (nicename) in update process
|
82 |
+
|
83 |
+
= Version 1.3 =
|
84 |
+
* Fixed: Properly escaped vars on POST (I think)
|
85 |
+
|
86 |
+
= Version 1.2 =
|
87 |
+
* Fixed: Minor tweak to previous release
|
88 |
+
|
89 |
+
= Version 1.1 =
|
90 |
+
* Added: Action on All Users page
|
91 |
+
* Improved: User dropdown is now sorted alphabetically
|
92 |
+
|
93 |
+
= Version 1.0 =
|
94 |
+
* Initial release
|
username-changer.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Username Changer
|
4 |
* Description: Change usernames easily
|
5 |
-
* Version: 3.1.
|
6 |
* Author: Daniel J Griffiths
|
7 |
-
* Author URI:
|
8 |
* Text Domain: username-changer
|
9 |
*
|
10 |
* @package UsernameChanger
|
11 |
-
* @author Daniel J Griffiths <dgriffiths@
|
12 |
* @copyright Copyright (c) 2014, Daniel J Griffiths
|
13 |
*/
|
14 |
|
@@ -85,7 +85,7 @@ if ( ! class_exists( 'Username_Changer' ) ) {
|
|
85 |
define( 'USERNAME_CHANGER_URL', plugin_dir_url( __FILE__ ) );
|
86 |
|
87 |
// Plugin version
|
88 |
-
define( 'USERNAME_CHANGER_VER', '3.1.
|
89 |
}
|
90 |
|
91 |
|
2 |
/**
|
3 |
* Plugin Name: Username Changer
|
4 |
* Description: Change usernames easily
|
5 |
+
* Version: 3.1.2
|
6 |
* Author: Daniel J Griffiths
|
7 |
+
* Author URI: https://evertiro.com
|
8 |
* Text Domain: username-changer
|
9 |
*
|
10 |
* @package UsernameChanger
|
11 |
+
* @author Daniel J Griffiths <dgriffiths@evertiro.com>
|
12 |
* @copyright Copyright (c) 2014, Daniel J Griffiths
|
13 |
*/
|
14 |
|
85 |
define( 'USERNAME_CHANGER_URL', plugin_dir_url( __FILE__ ) );
|
86 |
|
87 |
// Plugin version
|
88 |
+
define( 'USERNAME_CHANGER_VER', '3.1.2' );
|
89 |
}
|
90 |
|
91 |
|