Username Changer - Version 3.0.0

Version Description

Download this release

Release Info

Developer section214
Plugin Icon 128x128 Username Changer
Version 3.0.0
Comparing to
See all releases

Code changes from version 2.1.1 to 3.0.0

Files changed (36) hide show
  1. CONTRIBUTING.md +38 -0
  2. apigen.neon +4 -0
  3. assets/css/admin.css +47 -0
  4. assets/js/admin.js +239 -0
  5. includes/admin/actions.php +94 -0
  6. includes/admin/pages.php +0 -215
  7. includes/admin/settings/register.php +264 -0
  8. includes/admin/users/actions.php +0 -39
  9. includes/class.template-tags.php +505 -0
  10. includes/functions.php +129 -5
  11. includes/libraries/s214-settings/.editorconfig +29 -0
  12. includes/libraries/s214-settings/.gitattributes +2 -0
  13. includes/libraries/s214-settings/.gitignore +36 -0
  14. includes/libraries/s214-settings/.jshintrc +14 -0
  15. includes/libraries/s214-settings/CONTRIBUTING.md +34 -0
  16. includes/libraries/s214-settings/README.md +36 -0
  17. includes/libraries/s214-settings/apigen.neon +4 -0
  18. includes/libraries/s214-settings/composer.json +27 -0
  19. includes/libraries/s214-settings/license.txt +281 -0
  20. includes/libraries/s214-settings/source/assets/css/admin.css +35 -0
  21. includes/libraries/s214-settings/source/assets/css/admin.min.css +1 -0
  22. includes/libraries/s214-settings/source/assets/css/jquery-ui-classic.min.css +1 -0
  23. includes/libraries/s214-settings/source/assets/css/jquery-ui-fresh.min.css +1 -0
  24. includes/libraries/s214-settings/source/assets/js/admin.js +104 -0
  25. includes/libraries/s214-settings/source/assets/js/admin.min.js +1 -0
  26. includes/libraries/s214-settings/source/class.s214-settings.php +1237 -0
  27. includes/libraries/s214-settings/source/modules/licensing/S214_Plugin_Updater.php +382 -0
  28. includes/libraries/s214-settings/source/modules/licensing/class.s214-license.php +385 -0
  29. includes/libraries/s214-settings/source/modules/sysinfo/browser.php +1103 -0
  30. includes/libraries/s214-settings/source/modules/sysinfo/class.s214-sysinfo.php +442 -0
  31. includes/scripts.php +44 -0
  32. license.txt +281 -0
  33. readme.md +26 -0
  34. readme.txt +38 -23
  35. screenshot.png +0 -0
  36. username-changer.php +65 -26
CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ __Please Note:__ GitHub is for bug reports and contributions only - if you have a support question or a request for a customization don't post here, go to our [Support page](https://section214.com/contact/?reason=product-support&product=username-changer) instead.
8
+
9
+ ## Getting Started
10
+
11
+ * Submit a ticket for your issue, assuming one does not already exist.
12
+ * Raise it on our [Issue Tracker](https://github.com/section214/username-changer/issues)
13
+ * Clearly describe the issue including steps to reproduce the bug.
14
+ * Make sure you fill in the earliest version that you know has the issue as well as the version of WordPress you're using.
15
+
16
+ ## Making Changes
17
+
18
+ * Fork the repository on GitHub
19
+ * Make the changes to your forked repository
20
+ * Ensure you stick to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
21
+ * When committing, reference your issue (if present) and include a note about the fix
22
+ * If possible, and if applicable, please also add/update unit tests for your changes
23
+ * Push the changes to your fork and submit a pull request to the 'master' branch of the repository
24
+
25
+ ## Code Documentation
26
+
27
+ * We ensure that every function is documented well and follows the standards set by phpDoc
28
+ * An example function can be found [here](https://gist.github.com/sunnyratilal/5308969)
29
+ * Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
30
+ * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
31
+ * Finally, please use tabs and not spaces. The tab indent size should be 4 for all code.
32
+
33
+ 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.
34
+
35
+ # Additional Resources
36
+ * [General GitHub Documentation](https://help.github.com/)
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)
apigen.neon ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ source:
2
+ - ./
3
+
4
+ destination: codex
assets/css/admin.css ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Username Changer Admin CSS
3
+ *
4
+ * @package UsernameChanger\Admin\CSS
5
+ * @since 3.0.0
6
+ */
7
+
8
+
9
+ /* Support
10
+ -------------------------------------------------------------- */
11
+ .username-changer-get-help .dashicons {
12
+ vertical-align: middle;
13
+ line-height: 0.9em;
14
+ margin-right: 5px;
15
+ }
16
+
17
+
18
+ /* Support
19
+ -------------------------------------------------------------- */
20
+ .username-changer-settings-note {
21
+ background-color: #fcecad;
22
+ border: 1px solid #cccccc;
23
+ padding: 7px;
24
+ }
25
+
26
+ .username-changer-settings-note .note-title {
27
+ font-weight: bold;
28
+ }
29
+
30
+ .username-changer-template-tag-list {
31
+ margin: 14px 14px 0 14px;
32
+ }
33
+
34
+ .username-changer-template-tag span {
35
+ width: 150px;
36
+ display: inline-block;
37
+ }
38
+
39
+ @media screen and ( max-width: 480px ) {
40
+ .username-changer-template-tag {
41
+ margin-bottom: 12px;
42
+ }
43
+
44
+ .username-changer-template-tag span {
45
+ width: 100%;
46
+ }
47
+ }
assets/js/admin.js ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global jQuery, document, console, username_changer_vars*/
2
+ jQuery(document.body).ready(function ($) {
3
+ 'use strict';
4
+
5
+ var Username_Changer_Settings, Username_Changer_Profile, profileForm, mount, message, link, currentUsernameInput, newUsernameInput, submitButton, cancelButton, minimumLength;
6
+
7
+ /**
8
+ * Settings
9
+ */
10
+ Username_Changer_Settings = {
11
+ init : function () {
12
+ this.general();
13
+ },
14
+
15
+ general : function () {
16
+
17
+ }
18
+ };
19
+ Username_Changer_Settings.init();
20
+
21
+
22
+ /**
23
+ * Profile page
24
+ */
25
+ Username_Changer_Profile = {
26
+ init : function () {
27
+ this.general();
28
+ },
29
+
30
+ general : function () {
31
+ if((username_changer_vars.current_screen === 'profile' || username_changer_vars.current_screen === 'user-edit') && username_changer_vars.can_change_username === '1') {
32
+ currentUsernameInput = document.getElementById('user_login');
33
+ mount = document.querySelector('.user-user-login-wrap td .description');
34
+
35
+ link = this.createElement('a', {
36
+ id: 'username-changer-link',
37
+ href: '#',
38
+ onclick: this.toggle
39
+ }, username_changer_vars.change_button_label );
40
+
41
+ newUsernameInput = this.createElement('input', {
42
+ id: 'username-changer-input',
43
+ type: 'text',
44
+ name: 'new_user_login',
45
+ value: currentUsernameInput.value,
46
+ className: 'regular-text',
47
+ style: { 'min-height': '28px' },
48
+ autocomplete: 'off'
49
+ });
50
+
51
+ cancelButton = this.createElement('input', {
52
+ id: 'username-changer-cancel',
53
+ type: 'button',
54
+ value: username_changer_vars.cancel_button_label,
55
+ className: 'button',
56
+ style: { 'margin-left': '5px' },
57
+ onclick: this.toggle
58
+ });
59
+
60
+ submitButton = this.createElement('input', {
61
+ id: 'username-changer-submit',
62
+ type: 'button',
63
+ value: username_changer_vars.save_button_label,
64
+ className: 'button',
65
+ style: { 'margin-left': '5px' },
66
+ onclick: this.onSubmit
67
+ });
68
+
69
+ profileForm = this.createElement('form', {
70
+ id: 'username-changer-form',
71
+ method: 'POST',
72
+ onsubmit: this.onSubmit,
73
+ style: { 'display': 'none' }
74
+ }, [
75
+ newUsernameInput,
76
+ submitButton,
77
+ cancelButton
78
+ ]);
79
+
80
+ message = this.createElement('p', {
81
+ id: 'username-changer-message',
82
+ style: { 'display': 'none' }
83
+ });
84
+
85
+ mount.parentNode.replaceChild(link, mount);
86
+ link.parentNode.appendChild(this.createElement('div', [profileForm, message]));
87
+
88
+ minimumLength = parseInt(username_changer_vars.minimum_length);
89
+
90
+ $('#username-changer-input').on('input', function () {
91
+ if($(this).val().length < minimumLength) {
92
+ message.style.color = 'red';
93
+ message.textContent = username_changer_vars.error_short_username;
94
+ message.style.display = '';
95
+
96
+ submitButton.disabled = true;
97
+ } else {
98
+ if(submitButton.disabled === true) {
99
+ message.style.display = 'none';
100
+ message.textContent = '';
101
+ submitButton.disabled = false;
102
+ cancelButton.disabled = false;
103
+ }
104
+ }
105
+ });
106
+ }
107
+ },
108
+
109
+ createElement : function (name, attrs, children) {
110
+ var e = document.createElement(name);
111
+
112
+ if(!children && (Array.isArray(attrs) || typeof(attrs) === 'string')) {
113
+ children = attrs;
114
+ attrs = null;
115
+ }
116
+
117
+ if(attrs) {
118
+ this.setAttribute(e, attrs);
119
+ }
120
+
121
+ if(children) {
122
+ if(typeof(children) === 'string') {
123
+ e.textContent = children;
124
+ } else {
125
+ for(var i=0; i<children.length; i++) {
126
+ e.appendChild(children[i]);
127
+ }
128
+ }
129
+ }
130
+
131
+ return e;
132
+ },
133
+
134
+ setAttribute : function(object, attrs) {
135
+ for(var key in attrs) {
136
+ if(typeof(attrs[key]) === 'object') {
137
+ this.setAttribute(object[key], attrs[key]);
138
+ } else {
139
+ object[key] = attrs[key];
140
+ }
141
+ }
142
+ },
143
+
144
+ toggle : function(e) {
145
+ e.preventDefault();
146
+
147
+ if(profileForm.style.display === 'none') {
148
+ profileForm.style.display = '';
149
+ link.style.display = 'none';
150
+ currentUsernameInput.style.display = 'none';
151
+ newUsernameInput.focus();
152
+ } else {
153
+ profileForm.style.display = 'none';
154
+ link.style.display = 'inline';
155
+ currentUsernameInput.style.display = '';
156
+ message.style.display = 'none';
157
+ message.textContent = '';
158
+ newUsernameInput.value = currentUsernameInput.value;
159
+ submitButton.disabled = false;
160
+ cancelButton.disabled = false;
161
+ }
162
+ },
163
+
164
+ onSubmit : function(e) {
165
+ e.preventDefault();
166
+
167
+ var newUsername, currentUsername, postData;
168
+
169
+ newUsername = profileForm.new_user_login.value;
170
+ currentUsername = currentUsernameInput.value;
171
+ minimumLength = parseInt(username_changer_vars.minimum_length);
172
+
173
+ if(newUsername === currentUsername) {
174
+ cancelButton.click();
175
+ return;
176
+ }
177
+
178
+ submitButton.value = username_changer_vars.please_wait_message;
179
+ submitButton.disabled = true;
180
+ cancelButton.disabled = true;
181
+
182
+ if(newUsername.length < minimumLength) {
183
+ message.style.color = 'red';
184
+ message.textContent = username_changer_vars.error_short_username;
185
+ message.style.display = '';
186
+
187
+ submitButton.value = username_changer_vars.save_button_label;
188
+ cancelButton.disabled = false;
189
+
190
+ return;
191
+ }
192
+
193
+ postData = {
194
+ action: 'change_username',
195
+ old_username: currentUsername,
196
+ new_username: newUsername,
197
+ security: username_changer_vars.nonce
198
+ };
199
+
200
+ $.ajax({
201
+ type: 'POST',
202
+ data: postData,
203
+ dataType: 'json',
204
+ url: username_changer_vars.ajaxurl,
205
+ success: function (response) {
206
+ if(response !== null) {
207
+ try {
208
+ username_changer_vars.nonce = postData.new_nonce;
209
+ message.style.color = response.success ? 'green' : 'red';
210
+ message.innerHTML = response.message;
211
+
212
+ if(response.success) {
213
+ currentUsernameInput.value = newUsername;
214
+ }
215
+
216
+ cancelButton.click();
217
+ } catch(e) {
218
+ message.style.color = 'red';
219
+ message.textContent = username_changer_vars.error_unknown;
220
+ }
221
+ } else {
222
+ message.style.color = 'red';
223
+ message.textContent = username_changer_vars.error_unknown;
224
+ }
225
+
226
+ message.style.display = '';
227
+
228
+ submitButton.value = username_changer_vars.save_button_label;
229
+ cancelButton.disabled = false;
230
+ }
231
+ }).fail(function (data) {
232
+ if(window.console && window.console.log) {
233
+ console.log(data);
234
+ }
235
+ });
236
+ }
237
+ };
238
+ Username_Changer_Profile.init();
239
+ });
includes/admin/actions.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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&nbsp;<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
+ } else {
89
+ $response['message'] = __( 'An unknown error occurred.', 'username-changer' );
90
+ }
91
+
92
+ wp_send_json( $response );
93
+ }
94
+ add_action( 'wp_ajax_change_username', 'username_changer_ajax_username_change' );
includes/admin/pages.php DELETED
@@ -1,215 +0,0 @@
1
- <?php
2
- /**
3
- * Admin Pages
4
- *
5
- * @package Username_Changer\Admin\Pages
6
- * @since 2.1.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- /**
17
- * Add menu item for Username Changer
18
- *
19
- * @since 2.1.0
20
- * @return void
21
- */
22
- function username_changer_add_admin_menu() {
23
- // Only admin-level users with the edit_users capability can change usernames
24
- add_submenu_page(
25
- 'users.php',
26
- __( 'Username Changer', 'username-changer' ),
27
- __( 'Username Changer', 'username-changer' ),
28
- 'edit_users',
29
- 'username_changer',
30
- 'username_changer_add_admin_page'
31
- );
32
- }
33
- add_action( 'admin_menu', 'username_changer_add_admin_menu' );
34
-
35
-
36
- // Add network menu item
37
- if( is_multisite() ) {
38
- add_action( 'network_admin_menu', 'username_changer_add_admin_menu' );
39
- }
40
-
41
-
42
- /**
43
- * Add Username Changer page
44
- *
45
- * @since 2.1.0
46
- * @global object $wpdb The WordPress database object
47
- * @global array $userdata The data for the current user
48
- * @global array $current_user The data for the current user
49
- * @return void
50
- */
51
- function username_changer_add_admin_page() {
52
- global $wpdb, $userdata, $current_user;
53
-
54
- // Get current user info
55
- $current_user = wp_get_current_user();
56
-
57
- // Make SURE this user can edit users
58
- if( current_user_can( 'edit_users' ) == false ) {
59
- echo '<div id="message" class="error"><p><strong>' . __( 'You do not have permission to change a username!', 'username-changer' ) . '</strong></p></div>';
60
- return;
61
- }
62
-
63
- if( isset( $_POST['action'] ) && ( $_POST['action'] == 'update' ) && !empty( $_POST['new_username'] ) && !empty( $_POST['current_username'] ) ) {
64
-
65
- // Sanitize the new username
66
- $new_username = sanitize_user( $_POST['new_username'] );
67
- $new_username = esc_sql( $new_username );
68
- $current_username = esc_sql( $_POST['current_username'] );
69
-
70
- if( username_exists( $current_username ) ) {
71
- $current_user_data = get_user_by( 'login', $current_username );
72
-
73
- if( $new_username == $current_username ) {
74
- // Make sure username exists and username != new username
75
- echo '<div id="message" class="error"><p><strong>' . sprintf( __( 'Current Username and New Username cannot both be "%1$s"!', 'username-changer' ), $new_username ) . '</strong></p></div>';
76
- } elseif( username_exists( $new_username ) ) {
77
- // Make sure new username doesn't exist
78
- echo '<div id="message" class="error"><p><strong>' . sprintf( __( '"%1$s" cannot be changed to "%2$s", "%3$s" already exists!', 'username-changer' ), $current_username, $new_username, $new_username ) . '</strong></p></div>';
79
- } elseif( is_multisite() && user_can( $current_user_data->id, 'manage_network' ) && !is_network_admin() ) {
80
- // Super Admins must be changed from Network Dashboard
81
- echo '<div id="message" class="error"><p><strong>' . __( '"Super Admin usernames must be changed from the Network Dashboard!', 'username-changer' ) . '</strong></p></div>';
82
- } elseif( $new_username != $current_username ) {
83
- // Update username!
84
- $q = $wpdb->prepare( "UPDATE $wpdb->users SET user_login = %s WHERE user_login = %s", $new_username, $current_username );
85
- $qnn = $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %s WHERE user_login = %s", $new_username, strtolower( str_replace( ' ', '-', $new_username ) ) );
86
-
87
- // Check if display name is the same as username
88
- $usersql = $wpdb->prepare( "SELECT * from $wpdb->users WHERE user_login = %s", $current_username );
89
- $userinfo = $wpdb->get_row( $usersql );
90
-
91
- // If display name is the same as username, update both
92
- if( $current_username == $userinfo->display_name ) {
93
- $qdn = $wpdb->prepare( "UPDATE $wpdb->users SET display_name = %s WHERE user_login = %s", $new_username, $new_username );
94
- }
95
-
96
- // If the user is a Super Admin, update their permissions
97
- if( is_multisite() && is_super_admin( $current_user_data->id ) ) {
98
- grant_super_admin( $current_user_data->id );
99
- }
100
-
101
- if( false !== $wpdb->query( $q ) ) {
102
- $wpdb->query( $qnn );
103
-
104
- if( isset( $qdn ) ) {
105
- $wpdb->query( $qdn );
106
- }
107
-
108
- // Reassign Coauthor Attribution
109
- if( username_changer_plugin_installed( 'co-authors-plus/co-authors-plus.php' ) ) {
110
- global $coauthors_plus;
111
- $coauthor_posts = get_posts(
112
- array(
113
- 'post_type' => get_post_types(),
114
- 'posts_per_page' => -1,
115
- 'tax_query' => array(
116
- array(
117
- 'taxonomy' => $coauthors_plus->coauthor_taxonomy,
118
- 'field' => 'name',
119
- 'terms' => $current_username
120
- )
121
- )
122
- )
123
- );
124
- $current_term = get_term_by( 'name', $current_username, $coauthors_plus->coauthor_taxonomy );
125
- wp_delete_term( $current_term->term_id, $coauthors_plus->coauthor_taxonomy );
126
- if ( !empty( $coauthor_posts ) ) {
127
- foreach ( $coauthor_posts as $coauthor_post ) {
128
- $coauthors_plus->add_coauthors( $coauthor_post->ID, array( $new_username ), true );
129
- }
130
- }
131
- }
132
-
133
- // If changing own username, display link to re-login
134
- if( $current_user->user_login == $current_username ) {
135
- echo '<div id="message" class="updated fade"><p><strong>' . sprintf( __( 'Username %1$s was changed to %2$s.&nbsp;&nbsp;Click <a href="%3$s">here</a> to log back in.', 'username-changer' ), $current_username, $new_username, wp_login_url() ) . '</strong></p></div>';
136
- } else {
137
- echo '<div id="message" class="updated fade"><p><strong>' . sprintf( __( 'Username %1$s was changed to %2$s.', 'username-changer' ), $current_username, $new_username ) . '</strong></p></div>';
138
- }
139
- } else {
140
- // If database error occurred, display it
141
- echo '<div id="message" class="error"><p><strong>' . sprintf( __( 'A database error occurred : %1$s', 'username-changer' ), $wpdb->last_error ) . '</strong></p></div>';
142
- }
143
- }
144
- } else {
145
- // Warn if user doesn't exist (this should never happen!)
146
- echo '<div id="message" class="error"><p><strong>' . sprintf( __( 'Username "%1$s" doesn\'t exist!', 'username-changer' ), $current_username ) . '</strong></p></div>';
147
- }
148
- } elseif( ( isset( $_POST['action'] ) && $_POST['action'] == 'update' ) && ( empty( $_POST['new_username'] ) || empty( $_POST['current_username'] ) ) ) {
149
- // All fields are required
150
- echo '<div id="message" class="error"><p><strong>' . __( 'Both "Current Username" and "New Username" fields are required!', 'username-changer' ) . '</strong></p></div>';
151
- } ?>
152
-
153
- <div class="wrap">
154
- <h2><?php echo __( 'Username Changer', 'username-changer' ); ?></h2>
155
-
156
- <br />
157
-
158
- <form name="username_changer" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=username_changer">
159
- <input type='hidden' name='action' value='update' />
160
- <table style="width: 759px" cellpadding="5" class="widefat post fixed">
161
- <thead>
162
- <tr>
163
- <?php
164
- if( isset( $_REQUEST['id'] ) && $_REQUEST['id'] != '' ) {
165
- $usersql = $wpdb->prepare( "SELECT * from $wpdb->users where ID = %d", $_REQUEST['id'] );
166
- $userinfo = $wpdb->get_row( $usersql );
167
- echo '<th><strong>' . __( 'Rename user to what?', 'username-changer' ) . '</strong></th>';
168
- } else {
169
- echo '<th><strong>' . __( 'Edit which user?', 'username-changer' ) . '</strong></th>';
170
- }
171
- ?>
172
- </tr>
173
- <tr>
174
- <td>
175
- <label for="current_username"></label>
176
- <strong><?php echo __( 'Current Username', 'username-changer' ); ?></strong>
177
- <?php
178
- if( isset( $_REQUEST['id'] ) && $_REQUEST['id'] != '' ) {
179
- $usersql = $wpdb->prepare( "SELECT * from $wpdb->users where ID = %d", $_REQUEST['id'] );
180
- $userinfo = $wpdb->get_row( $usersql );
181
- echo '<input name="current_username" id="current_username" type="text" value="' . esc_attr( $userinfo->user_login ) . '" size="30" readonly />';
182
- } else {
183
- echo '<select name="current_username" id="current_username">';
184
-
185
- echo '<option value=""></option>';
186
-
187
- $usersql = "SELECT * from $wpdb->users order by user_login asc";
188
- $userinfo = $wpdb->get_results( $usersql );
189
-
190
- if( $userinfo ) {
191
- foreach( $userinfo as $userinfoObj ) {
192
- if( !is_multisite() || ( is_multisite() && !is_network_admin() && !user_can( $userinfoObj->ID, 'manage_network' ) ) || ( is_multisite() && is_network_admin() ) ) {
193
- echo '<option value="' . esc_attr( $userinfoObj->user_login ) . '">' . esc_html( $userinfoObj->user_login ) . ' (' . esc_html( $userinfoObj->user_email ) . ')</option>';
194
- }
195
- }
196
- }
197
-
198
- echo '</select>';
199
- }
200
- ?>
201
- <br />
202
- <label for="new_username"></label>
203
- <strong style="padding-right: 18px;"><?php echo __( 'New Username', 'username-changer' ); ?></strong>
204
- <input name="new_username" id="new_username" type="text" value="" size="30" />
205
- <div style="float: right;">
206
- <input type="submit" name="submit" class="button-secondary action" value="<?php echo __( 'Save Changes', 'username-changer' ); ?>" />
207
- </div>
208
- </td>
209
- </tr>
210
- </thead>
211
- </table>
212
- </form>
213
- </div>
214
- <?php
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/admin/settings/register.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ),
124
+ 'strings' => array(
125
+ array(
126
+ 'id' => 'button_labels_header',
127
+ 'name' => __( 'Button Labels', 'username-changer' ),
128
+ 'desc' => '',
129
+ 'type' => 'header'
130
+ ),
131
+ array(
132
+ 'id' => 'change_button_label',
133
+ 'name' => __( 'Change Button Label', 'username-changer' ),
134
+ 'desc' => __( 'Customize the text for the \'change username\' button.', 'username-changer' ),
135
+ 'type' => 'text',
136
+ 'std' => __( 'Change Username', 'username-changer' )
137
+ ),
138
+ array(
139
+ 'id' => 'save_button_label',
140
+ 'name' => __( 'Save Button Label', 'username-changer' ),
141
+ 'desc' => __( 'Customize the text for the save buttton.', 'username-changer' ),
142
+ 'type' => 'text',
143
+ 'std' => __( 'Save Username', 'username-changer' )
144
+ ),
145
+ array(
146
+ 'id' => 'cancel_button_label',
147
+ 'name' => __( 'Cancel Button Label', 'username-changer' ),
148
+ 'desc' => __( 'Customize the text for the cancel button.', 'username-changer' ),
149
+ 'type' => 'text',
150
+ 'std' => __( 'Cancel', 'username-changer' )
151
+ ),
152
+ array(
153
+ 'id' => 'messages_header',
154
+ 'name' => __( 'Messages', 'username-changer' ),
155
+ 'desc' => 'test',
156
+ 'type' => 'header'
157
+ ),
158
+ array(
159
+ 'id' => 'messages_subheader',
160
+ 'name' => '',
161
+ 'desc' => '',
162
+ 'type' => 'hook'
163
+ ),
164
+ array(
165
+ 'id' => 'please_wait_message',
166
+ 'name' => __( 'Please Wait Message', 'username-changer' ),
167
+ 'desc' => __( 'Customize the text displayed while usernames are being checked.', 'username-changer' ),
168
+ 'type' => 'text',
169
+ 'std' => __( 'Please wait...', 'username-changer' )
170
+ ),
171
+ array(
172
+ 'id' => 'success_message',
173
+ 'name' => __( 'Username Changed Message', 'username-changer' ),
174
+ 'desc' => __( 'Customize the message displayed when a username is changed successfully.', 'username-changer' ),
175
+ 'type' => 'text',
176
+ 'std' => __( 'Username successfully changed to {new_username}.', 'username-changer' )
177
+ ),
178
+ array(
179
+ 'id' => 'relogin_message',
180
+ 'name' => __( 'Relogin Message', 'username-changer' ),
181
+ 'desc' => __( 'Customize the text for the relogin link shown if a user changes their own username.', 'username-changer' ),
182
+ 'type' => 'text',
183
+ 'std' => __( 'Click here to log back in.', 'username-changer' )
184
+ ),
185
+ array(
186
+ 'id' => 'error_short_username',
187
+ 'name' => __( 'Short Username Error', 'username-changer' ),
188
+ 'desc' => __( 'Customize the error displayed when a username is too short.', 'username-changer' ),
189
+ 'type' => 'text',
190
+ 'std' => __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' )
191
+ ),
192
+ array(
193
+ 'id' => 'error_wrong_permissions',
194
+ 'name' => __( 'Wrong Permissions Error', 'username-changer' ),
195
+ 'desc' => __( 'Customize the error displayed when a user attempts to change a username they do not have permission to change.', 'username-changer' ),
196
+ 'type' => 'text',
197
+ 'std' => __( 'You do not have the correct permissions to change this username.', 'username-changer' ),
198
+ 'tooltip_title' => __( 'Wrong Permissions Error', 'username-changer' ),
199
+ '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' )
200
+ ),
201
+ array(
202
+ 'id' => 'error_duplicate_username',
203
+ 'name' => __( 'Duplicate Username Error', 'username-changer' ),
204
+ 'desc' => __( 'Customize the error displayed when a user attempts to change a username to something that is already in use.', 'username-changer' ),
205
+ 'type' => 'text',
206
+ 'std' => __( 'The username {new_username} is already in use. Please try again.', 'username-changer' )
207
+ )
208
+ )
209
+ ) ),
210
+ 'support' => apply_filters( 'username_changer_settings_support', array(
211
+ array(
212
+ 'id' => 'support_header',
213
+ 'name' => __( 'Username Changer Support', 'username-changer' ),
214
+ 'desc' => '',
215
+ 'type' => 'header'
216
+ ),
217
+ array(
218
+ 'id' => 'get_help',
219
+ 'name' => __( 'Need Some Help?', 'username-changer' ),
220
+ 'desc' => '',
221
+ 'type' => 'hook'
222
+ ),
223
+ array(
224
+ 'id' => 'system_info',
225
+ 'name' => __( 'System Info', 'username-changer' ),
226
+ 'desc' => '',
227
+ 'type' => 'sysinfo'
228
+ )
229
+ ) )
230
+ );
231
+
232
+ return array_merge( $settings, $new_settings );
233
+ }
234
+ add_filter( 'username_changer_registered_settings', 'username_changer_registered_settings' );
235
+
236
+
237
+ /**
238
+ * Display the help link
239
+ *
240
+ * @since 3.0.0
241
+ * @return void
242
+ */
243
+ function username_changer_display_help() {
244
+ echo '<a href="https://section214.com/contact/?reason=product-support&product=username-changer&website=' . esc_url( get_site_url() ) . '" class="username-changer-get-help button button-secondary" target="_blank"><span class="dashicons dashicons-sos"></span>' . __( 'Submit a Ticket', 'username-changer' ) . '</a>';
245
+ }
246
+ add_action( 'username_changer_get_help', 'username_changer_display_help' );
247
+
248
+
249
+ /**
250
+ * Display the subheader for the messages section
251
+ *
252
+ * @since 3.0.0
253
+ * @return void
254
+ */
255
+ function username_changer_display_messages_subheader() {
256
+ ?>
257
+ <div class="username-changer-settings-note">
258
+ <span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
259
+ <p><?php _e( 'The message settings fields allow the use of the following template tags:', 'username-changer' ); ?></p>
260
+ <?php echo username_changer_tags_list( 'message' ); ?>
261
+ </div>
262
+ <?php
263
+ }
264
+ add_action( 'username_changer_messages_subheader', 'username_changer_display_messages_subheader' );
includes/admin/users/actions.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Admin Pages
4
- *
5
- * @package Username_Changer\Admin\User\Actions
6
- * @since 2.1.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- /**
17
- * Add link to user page
18
- *
19
- * @since 2.1.0
20
- * @param array $actions The current user actions
21
- * @param object $user The user we are editing
22
- * @return array $actions The modified user actions
23
- */
24
- function username_changer_action_link( $actions, $user ) {
25
- if( current_user_can( 'edit_users' ) ) {
26
- if( ! is_multisite() || ( is_multisite() && ! is_network_admin() && ! user_can( $user->ID, 'manage_network' ) ) || ( is_multisite() && is_network_admin() ) ) {
27
- $actions[] = '<a href="' . add_query_arg( array( 'page' => 'username_changer', 'id' => $user->ID ) ) . '">' . __( 'Change Username', 'username-changer' ) . '</a>';
28
- }
29
- }
30
-
31
- return $actions;
32
- }
33
- add_filter( 'user_row_actions', 'username_changer_action_link', 10, 2 );
34
-
35
-
36
- // Add link to network/users.php
37
- if( is_multisite() ) {
38
- add_filter( 'ms_user_row_actions', 'username_changer_action_link', 10, 2 );
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class.template-tags.php ADDED
@@ -0,0 +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 = wp_get_current_user();
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 = wp_get_current_user();
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
@@ -8,13 +8,137 @@
8
 
9
 
10
  // Exit if accessed directly
11
- if( ! defined( 'ABSPATH' ) ) {
12
  exit;
13
  }
14
 
15
 
16
  /**
17
- * Check if Co-Authors Plus is installed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  *
19
  * @since 1.0.0
20
  * @param string $plugin The path to the plugin to check
@@ -23,13 +147,13 @@ if( ! defined( 'ABSPATH' ) ) {
23
  function username_changer_plugin_installed( $plugin = false ){
24
  $ret = false;
25
 
26
- if( $plugin ) {
27
  $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
28
 
29
- if( in_array( $plugin, $active_plugins ) ) {
30
  $ret = true;
31
  }
32
  }
33
 
34
  return $ret;
35
- }
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
+ $qnn = $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %s WHERE user_login = %s", $new_username, strtolower( str_replace( ' ', '-', $new_username ) ) );
82
+
83
+ // Check if display name is the same as username
84
+ $usersql = $wpdb->prepare( "SELECT * from $wpdb->users WHERE user_login = %s", $old_username );
85
+ $userinfo = $wpdb->get_row( $usersql );
86
+
87
+ // If display name is the same as username, update both
88
+ if ( $old_username == $userinfo->display_name ) {
89
+ $qdn = $wpdb->prepare( "UPDATE $wpdb->users SET display_name = %s WHERE user_login = %s", $new_username, $new_username );
90
+ }
91
+
92
+ // If the user is a Super Admin, update their permissions
93
+ if ( is_multisite() && is_super_admin( $user_id ) ) {
94
+ grant_super_admin( $user_id );
95
+ }
96
+
97
+ if ( false !== $wpdb->query( $q ) ) {
98
+ $wpdb->query( $qnn );
99
+
100
+ if ( isset( $qdn ) ) {
101
+ $wpdb->query( $qdn );
102
+ }
103
+
104
+ // Reassign Coauthor Attribution
105
+ if ( username_changer_plugin_installed( 'co-authors-plus/co-authors-plus.php' ) ) {
106
+ global $coauthors_plus;
107
+
108
+ $coauthor_posts = get_posts(
109
+ array(
110
+ 'post_type' => get_post_types(),
111
+ 'posts_per_page' => -1,
112
+ 'tax_query' => array(
113
+ array(
114
+ 'taxonomy' => $coauthors_plus->coauthor_taxonomy,
115
+ 'field' => 'name',
116
+ 'terms' => $old_username
117
+ )
118
+ )
119
+ )
120
+ );
121
+
122
+ $current_term = get_term_by( 'name', $old_username, $coauthors_plus->coauthor_taxonomy );
123
+ wp_delete_term( $current_term->term_id, $coauthors_plus->coauthor_taxonomy );
124
+
125
+ if ( ! empty( $coauthor_posts ) ) {
126
+ foreach ( $coauthor_posts as $coauthor_post ) {
127
+ $coauthors_plus->add_coauthors( $coauthor_post->ID, array( $new_username ), true );
128
+ }
129
+ }
130
+ }
131
+
132
+ $return = true;
133
+ }
134
+
135
+ return $return;
136
+ }
137
+ }
138
+
139
+
140
+ /**
141
+ * Check if a plugin is installed
142
  *
143
  * @since 1.0.0
144
  * @param string $plugin The path to the plugin to check
147
  function username_changer_plugin_installed( $plugin = false ){
148
  $ret = false;
149
 
150
+ if ( $plugin ) {
151
  $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
152
 
153
+ if ( in_array( $plugin, $active_plugins ) ) {
154
  $ret = true;
155
  }
156
  }
157
 
158
  return $ret;
159
+ }
includes/libraries/s214-settings/.editorconfig ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is for unifying the coding style for different editors and IDEs
2
+ # editorconfig.org
3
+
4
+ # WordPress Coding Standards
5
+ # https://make.wordpress.org/core/handbook/coding-standards/
6
+
7
+ # Based from https://github.com/ntwb/wp.editorconfig/blob/master/.editorconfig
8
+ #
9
+ # Need an IDE plugin? http://editorconfig.org/#download
10
+
11
+ root = true
12
+
13
+ [*]
14
+ charset = utf-8
15
+ end_of_line = lf
16
+ insert_final_newline = true
17
+ trim_trailing_whitespace = true
18
+ indent_style = tab
19
+
20
+ [*.json]
21
+ indent_style = space
22
+ indent_size = 2
23
+
24
+ [*.yml]
25
+ indent_style = space
26
+ indent_size = 4
27
+
28
+ [*.txt,wp-config-sample.php]
29
+ end_of_line = crlf
includes/libraries/s214-settings/.gitattributes ADDED
@@ -0,0 +1,2 @@
 
 
1
+ * text=auto
2
+ /tests export-ignore
includes/libraries/s214-settings/.gitignore ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Windows image file caches
2
+ Thumbs.db
3
+ ehthumbs.db
4
+
5
+ # Folder config file
6
+ Desktop.ini
7
+
8
+ # Recycle Bin used on file shares
9
+ $RECYCLE.BIN/
10
+
11
+ # Mac crap
12
+ .DS_Store
13
+
14
+ # Sublime
15
+ *.sublime-project
16
+ *.sublime-workspace
17
+
18
+ # PhpStorm
19
+ .idea
20
+
21
+ # Eclipse
22
+ *.pydevproject
23
+ .project
24
+ .metadata
25
+ build/
26
+ tmp/
27
+ tests/clover.xml
28
+
29
+ # Grunt
30
+ node_modules
31
+
32
+ # Vendor
33
+ vendor
34
+
35
+ # Temporary files
36
+ *~
includes/libraries/s214-settings/.jshintrc ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boss": true,
3
+ "curly": true,
4
+ "eqeqeq": true,
5
+ "immed": true,
6
+ "noarg": true,
7
+ "quotmark": "single",
8
+ "undef": true,
9
+ "unused": true,
10
+ "browser": true,
11
+ "globals": {
12
+ "jQuery": false
13
+ }
14
+ }
includes/libraries/s214-settings/CONTRIBUTING.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contribute To The Library
2
+
3
+ Community made patches, 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/Section214/S214-Settings/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
+ * Push the changes to your fork and submit a pull request to the 'master' branch of this repository
21
+
22
+ ## Code Documentation
23
+
24
+ * We ensure that every function is documented well and follows the standards set by phpDoc
25
+ * An example function can be found [here](https://gist.github.com/sunnyratilal/5308969)
26
+ * Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
27
+ * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
28
+ * Finally, please use tabs and not spaces. The tab indent size should be 4 for all library code.
29
+
30
+ 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.
31
+
32
+ # Additional Resources
33
+ * [General GitHub Documentation](https://help.github.com/)
34
+ * [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
includes/libraries/s214-settings/README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # S214 Settings Library
2
+ [![Travis](https://img.shields.io/travis/Section214/S214-Settings-Demo.svg?maxAge=2592000)](https://travis-ci.org/Section214/S214-Settings-Demo/)
3
+ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Section214/S214-Settings-Demo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Section214/S214-Settings-Demo/?branch=master)
4
+ [![Code Coverage](https://scrutinizer-ci.com/g/Section214/S214-Settings-Demo/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Section214/S214-Settings-Demo/?branch=master)
5
+ [![License](https://img.shields.io/badge/license-GPL--2.0%2B-green.svg)](https://github.com/Section214/S214-Settings/blob/master/license.txt)
6
+
7
+ [![Packagist](https://img.shields.io/packagist/v/Section214/S214-Settings.svg?maxAge=2592000)]()
8
+ [![Packagist Pre Release](https://img.shields.io/packagist/vpre/Section214/S214-Settings.svg?maxAge=2592000)]()
9
+
10
+
11
+ ## What Is This?
12
+
13
+ Depending on the size of a project, you may be able to get away with adding settings to an existing WordPress page (or the customizer). On the other end of the spectrum, you may need (or want) to implement a full-scale control panel like [Redux](http://reduxframework.com). But what if your project is somewhere in the middle? Or what if you need a control panel, but don't want the bulk that goes along with most? This is an issue that I've struggled with for some time. My standard implementation has historically been a fork of the awesome system used by [Easy Digital Downloads](http://section214.com/go/easy-digital-downloads). However, this has its own set of issues. For each project, I had to sort through the various required files and update function and variable names to prevent conflicts, and the process of implementing it was arduous. Thus, I finally sat down and converted it into a reusable library which I am now sharing with the general public! Read on to check out the basic implementation.
14
+
15
+ More information can be found on the [wiki](https://github.com/Section214/S214-Settings/wiki).
16
+
17
+ ## Installation
18
+
19
+ 1. You can clone the GitHub repository: `https://github.com/Section214/S214-Settings.git`
20
+ 2. Or download it directly as a ZIP file: `https://github.com/Section214/S214-Settings/archive/master.zip`
21
+
22
+ This will download the latest developer copy of the S214 Settings library.
23
+
24
+ ## Bugs
25
+
26
+ If you find an issue, let us know [here](https://github.com/Section214/S214-Settings/issues?state=open)!
27
+
28
+ ## Contributions
29
+
30
+ Anyone is welcome to contribute to the library. Please read the [guidelines for contributing](https://github.com/Section214/S214-Settings/blob/master/CONTRIBUTING.md) to this repository.
31
+
32
+ There are various ways you can contribute:
33
+
34
+ 1. Raise an [Issue](https://github.com/Section214/S214-Settings/issues) on GitHub
35
+ 2. Send us a Pull Request with your bug fixes and/or new features
36
+ 3. Provide feedback and suggestions on [enhancements](https://github.com/Section214/S214-Settings/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open)
includes/libraries/s214-settings/apigen.neon ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ source:
2
+ - ./
3
+
4
+ destination: codex
includes/libraries/s214-settings/composer.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "section214/s214-settings",
3
+ "type": "library",
4
+ "description": "A PHP library for implementing a simple, transparent WordPress settings panel.",
5
+ "keywords": ["s214", "section214", "settings", "options"],
6
+ "homepage": "https://section214.com/",
7
+ "license": "GPL-2.0+",
8
+ "authors": [
9
+ {
10
+ "name": "Daniel J Griffiths",
11
+ "email": "dgriffiths@section214.com"
12
+ }
13
+ ],
14
+ "support": {
15
+ "issues": "https://github.com/Section214/S214-Settings/issues"
16
+ },
17
+ "require": {
18
+ "php": ">=5.3.0",
19
+ "composer/installers": "~1.0"
20
+ },
21
+ "require-dev": {
22
+ "satooshi/php-coveralls": "dev-master",
23
+ "phpunit/phpunit": "3.7.31",
24
+ "phpunit/php-invoker": "1.1.3"
25
+ },
26
+ "minimum-stability": "dev"
27
+ }
includes/libraries/s214-settings/license.txt ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+ Preamble
11
+
12
+ The licenses for most software are designed to take away your
13
+ freedom to share and change it. By contrast, the GNU General Public
14
+ License is intended to guarantee your freedom to share and change free
15
+ software--to make sure the software is free for all its users. This
16
+ General Public License applies to most of the Free Software
17
+ Foundation's software and to any other program whose authors commit to
18
+ using it. (Some other Free Software Foundation software is covered by
19
+ the GNU Library General Public License instead.) You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ this service if you wish), that you receive source code or can get it
26
+ if you want it, that you can change the software or use pieces of it
27
+ in new free programs; and that you know you can do these things.
28
+
29
+ To protect your rights, we need to make restrictions that forbid
30
+ anyone to deny you these rights or to ask you to surrender the rights.
31
+ These restrictions translate to certain responsibilities for you if you
32
+ distribute copies of the software, or if you modify it.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must give the recipients all the rights that
36
+ you have. You must make sure that they, too, receive or can get the
37
+ source code. And you must show them these terms so they know their
38
+ rights.
39
+
40
+ We protect your rights with two steps: (1) copyright the software, and
41
+ (2) offer you this license which gives you legal permission to copy,
42
+ distribute and/or modify the software.
43
+
44
+ Also, for each author's protection and ours, we want to make certain
45
+ that everyone understands that there is no warranty for this free
46
+ software. If the software is modified by someone else and passed on, we
47
+ want its recipients to know that what they have is not the original, so
48
+ that any problems introduced by others will not reflect on the original
49
+ authors' reputations.
50
+
51
+ Finally, any free program is threatened constantly by software
52
+ patents. We wish to avoid the danger that redistributors of a free
53
+ program will individually obtain patent licenses, in effect making the
54
+ program proprietary. To prevent this, we have made it clear that any
55
+ patent must be licensed for everyone's free use or not licensed at all.
56
+
57
+ The precise terms and conditions for copying, distribution and
58
+ modification follow.
59
+
60
+ GNU GENERAL PUBLIC LICENSE
61
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
+
63
+ 0. This License applies to any program or other work which contains
64
+ a notice placed by the copyright holder saying it may be distributed
65
+ under the terms of this General Public License. The "Program", below,
66
+ refers to any such program or work, and a "work based on the Program"
67
+ means either the Program or any derivative work under copyright law:
68
+ that is to say, a work containing the Program or a portion of it,
69
+ either verbatim or with modifications and/or translated into another
70
+ language. (Hereinafter, translation is included without limitation in
71
+ the term "modification".) Each licensee is addressed as "you".
72
+
73
+ Activities other than copying, distribution and modification are not
74
+ covered by this License; they are outside its scope. The act of
75
+ running the Program is not restricted, and the output from the Program
76
+ is covered only if its contents constitute a work based on the
77
+ Program (independent of having been made by running the Program).
78
+ Whether that is true depends on what the Program does.
79
+
80
+ 1. You may copy and distribute verbatim copies of the Program's
81
+ source code as you receive it, in any medium, provided that you
82
+ conspicuously and appropriately publish on each copy an appropriate
83
+ copyright notice and disclaimer of warranty; keep intact all the
84
+ notices that refer to this License and to the absence of any warranty;
85
+ and give any other recipients of the Program a copy of this License
86
+ along with the Program.
87
+
88
+ You may charge a fee for the physical act of transferring a copy, and
89
+ you may at your option offer warranty protection in exchange for a fee.
90
+
91
+ 2. You may modify your copy or copies of the Program or any portion
92
+ of it, thus forming a work based on the Program, and copy and
93
+ distribute such modifications or work under the terms of Section 1
94
+ above, provided that you also meet all of these conditions:
95
+
96
+ a) You must cause the modified files to carry prominent notices
97
+ stating that you changed the files and the date of any change.
98
+
99
+ b) You must cause any work that you distribute or publish, that in
100
+ whole or in part contains or is derived from the Program or any
101
+ part thereof, to be licensed as a whole at no charge to all third
102
+ parties under the terms of this License.
103
+
104
+ c) If the modified program normally reads commands interactively
105
+ when run, you must cause it, when started running for such
106
+ interactive use in the most ordinary way, to print or display an
107
+ announcement including an appropriate copyright notice and a
108
+ notice that there is no warranty (or else, saying that you provide
109
+ a warranty) and that users may redistribute the program under
110
+ these conditions, and telling the user how to view a copy of this
111
+ License. (Exception: if the Program itself is interactive but
112
+ does not normally print such an announcement, your work based on
113
+ the Program is not required to print an announcement.)
114
+
115
+ These requirements apply to the modified work as a whole. If
116
+ identifiable sections of that work are not derived from the Program,
117
+ and can be reasonably considered independent and separate works in
118
+ themselves, then this License, and its terms, do not apply to those
119
+ sections when you distribute them as separate works. But when you
120
+ distribute the same sections as part of a whole which is a work based
121
+ on the Program, the distribution of the whole must be on the terms of
122
+ this License, whose permissions for other licensees extend to the
123
+ entire whole, and thus to each and every part regardless of who wrote it.
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
includes/libraries/s214-settings/source/assets/css/admin.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Fix color picker label alignment
2
+ -------------------------------------------------------------- */
3
+ .s214-color-picker-label {
4
+ position: absolute;
5
+ display: inline-block;
6
+ padding-top: 4px;
7
+ }
8
+
9
+ /* System info styles
10
+ -------------------------------------------------------------- */
11
+ #system-info-textarea {
12
+ width: 800px;
13
+ height: 400px;
14
+ font-family: Menlo, Monaco, monospace;
15
+ background: none;
16
+ white-space: pre;
17
+ overflow: auto;
18
+ display: block;
19
+ }
20
+
21
+ /* Tooltips
22
+ -------------------------------------------------------------- */
23
+ .s214-help-tip {
24
+ cursor: help;
25
+ }
26
+
27
+ .ui-tooltip {
28
+ background: #333 !important;
29
+ border-radius: 3px !important;
30
+ box-shadow: 1px 1px 2px 1px rgba(214,214,214,0.5);
31
+ color: #dedede !important;
32
+ max-width: 300px;
33
+ padding: 7px;
34
+ text-rendering: optimizeLegibility;
35
+ }
includes/libraries/s214-settings/source/assets/css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .s214-color-picker-label{position:absolute;display:inline-block;padding-top:4px}#system-info-textarea{width:800px;height:400px;font-family:Menlo,Monaco,monospace;background:0 0;white-space:pre;overflow:auto;display:block}.s214-help-tip{cursor:help}.ui-tooltip{background:#333!important;border-radius:3px!important;box-shadow:1px 1px 2px 1px rgba(214,214,214,.5);color:#dedede!important;max-width:300px;padding:7px;text-rendering:optimizeLegibility}
includes/libraries/s214-settings/source/assets/css/jquery-ui-classic.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.ui-helper-clearfix{display:inline-block}/*\*/* html .ui-helper-clearfix{height:1%}.ui-helper-clearfix{display:block}/**/.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-widget{font-family:sans-serif;font-size:12px}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:sans-serif;font-size:1em}.ui-widget-content{border:1px solid #d1e5ee;background:#fff;color:#333}.ui-widget-header{border:1px solid #d1e5ee;background-color:#f5fafd;background-image:-ms-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-moz-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-o-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-webkit-gradient(linear,left top,left bottom,from(#f7fcfe),to(#eff8ff));background-image:-webkit-linear-gradient(top,#f7fcfe,#eff8ff);background-image:linear-gradient(top,#f7fcfe,#eff8ff);color:#333;font-weight:bold}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #d1e5ee;background-color:#f5fafd;background-image:-ms-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-moz-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-o-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-webkit-gradient(linear,left top,left bottom,from(#f7fcfe),to(#eff8ff));background-image:-webkit-linear-gradient(top,#f7fcfe,#eff8ff);background-image:linear-gradient(top,#f7fcfe,#eff8ff);font-weight:normal;color:#333}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#333;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #b8d7e5;background-color:#f7fcfe;background-image:-ms-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-moz-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-o-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-webkit-gradient(linear,left top,left bottom,from(#eff8ff),to(#f7fcfe));background-image:-webkit-linear-gradient(top,#eff8ff,#f7fcfe);background-image:linear-gradient(top,#eff8ff,#f7fcfe);font-weight:normal;color:#000}.ui-state-hover a,.ui-state-hover a:hover{color:#000;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #d1e5ee;background:#fff;font-weight:normal;color:#333}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#333;text-decoration:none}.ui-widget :active{outline:0}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #e6db55;background:#ffffe0;color:#333}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#333}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #c00;background:#ffebe8;color:#c00}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#c00}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#c00}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-icon{width:16px;height:16px;background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-header .ui-icon{background-image:url(../images/ui-icons_999999_256x240.png)}.ui-state-default .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-active .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_21759b_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(../images/ui-icons_cc0000_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-off{background-position:-96px -144px}.ui-icon-radio-on{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;-khtml-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ui-widget-overlay{background:#000;opacity:.6;filter:Alpha(Opacity=60)}.ui-widget-shadow{box-shadow:0 0 16px rgba(0,0,0,0.3)}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion{width:100%}.ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.ui-accordion .ui-accordion-li-fix{display:inline}.ui-accordion .ui-accordion-header-active{border-bottom:0!important}.ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.ui-accordion .ui-accordion-content-active{display:block}.ui-autocomplete{position:absolute;cursor:default}* html .ui-autocomplete{width:1px}.ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.ui-menu .ui-menu{margin-top:-3px}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.ui-menu .ui-menu-item a.ui-state-hover,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none!important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:absolute;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0!important;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:0}.ui-tabs .ui-tabs-hide{display:none!important}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{display:none;display:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-progressbar{height:2em;text-align:left}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-widget-header{background-color:#83b4d8;background-image:linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-o-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-moz-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-webkit-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-ms-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%)}
includes/libraries/s214-settings/source/assets/css/jquery-ui-fresh.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.ui-helper-clearfix{display:inline-block}/*\*/* html .ui-helper-clearfix{height:1%}.ui-helper-clearfix{display:block}/**/.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-widget{font-family:sans-serif;font-size:12px}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:sans-serif;font-size:1em}.ui-widget-content{border:1px solid #dfdfdf;background:#fff;color:#333}.ui-widget-header{border:1px solid #dfdfdf;color:#333;font-weight:bold;background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#ececec);background-image:-moz-linear-gradient(top,#f9f9f9,#ececec);background-image:-o-linear-gradient(top,#f9f9f9,#ececec);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));background-image:-webkit-linear-gradient(top,#f9f9f9,#ececec);background-image:linear-gradient(top,#f9f9f9,#ececec)}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #dfdfdf;background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#ececec);background-image:-moz-linear-gradient(top,#f9f9f9,#ececec);background-image:-o-linear-gradient(top,#f9f9f9,#ececec);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));background-image:-webkit-linear-gradient(top,#f9f9f9,#ececec);background-image:linear-gradient(top,#f9f9f9,#ececec);font-weight:normal;color:#333}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#333;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #ccc;background-color:#ececec;background-image:-ms-linear-gradient(top,#ececec,#f9f9f9);background-image:-moz-linear-gradient(top,#ececec,#f9f9f9);background-image:-o-linear-gradient(top,#ececec,#f9f9f9);background-image:-webkit-gradient(linear,left top,left bottom,from(#ececec),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#ececec,#f9f9f9);background-image:linear-gradient(top,#ececec,#f9f9f9);font-weight:normal;color:#000}.ui-state-hover a,.ui-state-hover a:hover{color:#000;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #dfdfdf;background:#fff;font-weight:normal;color:#333}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#333;text-decoration:none}.ui-widget :active{outline:0}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #e6db55;background:#ffffe0;color:#333}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#333}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #c00;background:#ffebe8;color:#c00}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#c00}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#c00}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-icon{width:16px;height:16px;background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-header .ui-icon{background-image:url(../images/ui-icons_999999_256x240.png)}.ui-state-default .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-active .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_21759b_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(../images/ui-icons_cc0000_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-off{background-position:-96px -144px}.ui-icon-radio-on{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ui-widget-overlay{background:#000;opacity:.6;filter:Alpha(Opacity=60)}.ui-widget-shadow{box-shadow:0 0 16px rgba(0,0,0,0.3)}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion{width:100%}.ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.ui-accordion .ui-accordion-li-fix{display:inline}.ui-accordion .ui-accordion-header-active{border-bottom:0!important}.ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.ui-accordion .ui-accordion-content-active{display:block}.ui-autocomplete{position:absolute;cursor:default}* html .ui-autocomplete{width:1px}.ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.ui-menu .ui-menu{margin-top:-3px}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.ui-menu .ui-menu-item a.ui-state-hover,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none!important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:fixed;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0!important;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:0}.ui-tabs .ui-tabs-hide{display:none!important}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{display:none;display:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-progressbar{height:2em;text-align:left}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-widget-header{background-color:#83b4d8;background-image:linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-o-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-moz-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-webkit-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-ms-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%)}
includes/libraries/s214-settings/source/assets/js/admin.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global jQuery, document, window, wp, CodeMirror, s214_settings_vars*/
2
+ jQuery(document).ready(function ($) {
3
+ 'use strict';
4
+
5
+ // Setup color picker
6
+ if ($('.s214-color-picker').length) {
7
+ $('.s214-color-picker').wpColorPicker();
8
+ }
9
+
10
+ // Setup select2
11
+ if ($('.s214-select2').length) {
12
+ $('.s214-select2').select2();
13
+ }
14
+
15
+ // Setup CodeMirror
16
+ if ($('.s214-html').length) {
17
+ $('.s214-html').each(function (index, elem) {
18
+ CodeMirror.fromTextArea(elem, {
19
+ lineNumbers: true,
20
+ mode: 'text/html',
21
+ showCursorWhenSelecting: true
22
+ });
23
+ });
24
+ }
25
+
26
+ // Setup tooltips
27
+ $('.s214-help-tip').tooltip({
28
+ content: function () {
29
+ return $(this).prop('title');
30
+ },
31
+ position: {
32
+ my: 'center top',
33
+ at: 'center bottom+10',
34
+ collision: 'flipfit'
35
+ },
36
+ hide: {
37
+ duration: 200
38
+ },
39
+ show: {
40
+ duration: 200
41
+ }
42
+ });
43
+
44
+ // Setup uploaders
45
+ if ($('.' + s214_settings_vars.func + '_settings_upload_button').length) {
46
+ var file_frame;
47
+
48
+ $('body').on('click', '.' + s214_settings_vars.func + '_settings_upload_button', function (e) {
49
+ e.preventDefault();
50
+
51
+ var button = $(this);
52
+
53
+ window.formfield = $(this).parent().prev();
54
+
55
+ // If the media frame already exists, reopen it
56
+ if (file_frame) {
57
+ file_frame.open();
58
+ return;
59
+ }
60
+
61
+ // Create the media frame
62
+ wp.media.frames.file_frame = wp.media({
63
+ frame: 'post',
64
+ state: 'insert',
65
+ title: button.data('uploader_title'),
66
+ button: {
67
+ text: button.data('uploader_button_text')
68
+ },
69
+ multiple: false
70
+ });
71
+
72
+ file_frame = wp.media.frames.file_frame;
73
+
74
+ file_frame.on('menu:render:default', function (view) {
75
+ // Store our views in an object
76
+ var views = {};
77
+
78
+ // Unset default menu items
79
+ view.unset('library-separator');
80
+ view.unset('gallery');
81
+ view.unset('featured-image');
82
+ view.unset('embed');
83
+
84
+ // Initialize the views in our object
85
+ view.set(views);
86
+ });
87
+
88
+ // Run a callback on select
89
+ file_frame.on('insert', function () {
90
+ var selection = file_frame.state().get('selection');
91
+
92
+ selection.each(function (attachment) {
93
+ attachment = attachment.toJSON();
94
+ window.formfield.val(attachment.url);
95
+ });
96
+ });
97
+
98
+ // Open the modal
99
+ file_frame.open();
100
+ });
101
+
102
+ window.formfield = '';
103
+ }
104
+ });
includes/libraries/s214-settings/source/assets/js/admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(t){"use strict";if(t(".s214-color-picker").length&&t(".s214-color-picker").wpColorPicker(),t(".s214-select2").length&&t(".s214-select2").select2(),t(".s214-html").length&&t(".s214-html").each(function(t,e){CodeMirror.fromTextArea(e,{lineNumbers:!0,mode:"text/html",showCursorWhenSelecting:!0})}),t(".s214-help-tip").tooltip({content:function(){return t(this).prop("title")},position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}}),t("."+s214_settings_vars.func+"_settings_upload_button").length){var e;t("body").on("click","."+s214_settings_vars.func+"_settings_upload_button",function(n){n.preventDefault();var o=t(this);return window.formfield=t(this).parent().prev(),e?void e.open():(wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:o.data("uploader_title"),button:{text:o.data("uploader_button_text")},multiple:!1}),e=wp.media.frames.file_frame,e.on("menu:render:default",function(t){var e={};t.unset("library-separator"),t.unset("gallery"),t.unset("featured-image"),t.unset("embed"),t.set(e)}),e.on("insert",function(){var t=e.state().get("selection");t.each(function(t){t=t.toJSON(),window.formfield.val(t.url)})}),void e.open())}),window.formfield=""}});
includes/libraries/s214-settings/source/class.s214-settings.php ADDED
@@ -0,0 +1,1237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Section214 Settings Class
4
+ *
5
+ * @package S214\Settings
6
+ * @since 1.0.0
7
+ */
8
+
9
+
10
+ // Exit if accessed directly
11
+ if( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+
16
+ /**
17
+ * Section214 settings handler class
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ class S214_Settings {
22
+
23
+
24
+ /**
25
+ * @var string $version The settings class version
26
+ * @since 1.0.0
27
+ */
28
+ private $version = '1.2.2';
29
+
30
+
31
+ /**
32
+ * @var string $slug The plugin slug
33
+ * @since 1.0.0
34
+ */
35
+ private $slug;
36
+
37
+
38
+ /**
39
+ * @var string $func The plugin slug for names
40
+ * @since 1.0.0
41
+ */
42
+ private $func;
43
+
44
+
45
+ /**
46
+ * @var string $default_tab The default tab to display
47
+ * @since 1.0.0
48
+ */
49
+ private $default_tab;
50
+
51
+
52
+ /**
53
+ * @var bool $show_title Whether or not to display the page title
54
+ * @since 1.0.3
55
+ */
56
+ private $show_title;
57
+
58
+
59
+ /**
60
+ * @var bool page_title The page title
61
+ * @since 1.2.1
62
+ */
63
+ private $page_title;
64
+
65
+
66
+ /**
67
+ * @var object $sysinfo The sysinfo object
68
+ * @since 1.1.0
69
+ */
70
+ private $sysinfo;
71
+
72
+
73
+ /**
74
+ * Get things started
75
+ *
76
+ * @access public
77
+ * @since 1.0.1
78
+ * @param string $slug The plugin slug
79
+ * @param string $default_tab The default settings tab to display
80
+ * @return void
81
+ */
82
+ public function __construct( $slug = false, $default_tab = 'general' ) {
83
+ // Bail if no slug is specified
84
+ if( ! $slug ) {
85
+ return;
86
+ }
87
+
88
+ // Setup plugin variables
89
+ $this->slug = $slug;
90
+ $this->func = str_replace( '-', '_', $slug );
91
+ $this->default_tab = $default_tab;
92
+
93
+ // Run action and filter hooks
94
+ $this->hooks();
95
+
96
+ // Setup the Sysinfo class
97
+ if( ! class_exists( 'S214_Sysinfo' ) ) {
98
+ require_once 'modules/sysinfo/class.s214-sysinfo.php';
99
+ }
100
+ $this->sysinfo = new S214_Sysinfo( $this->slug, $this->func, $this->version );
101
+ }
102
+
103
+
104
+ /**
105
+ * Run action and filter hooks
106
+ *
107
+ * @access private
108
+ * @since 1.0.0
109
+ * @return void
110
+ */
111
+ private function hooks() {
112
+ // Add the plugin setting page
113
+ add_action( 'admin_menu', array( $this, 'add_settings_page' ), 10 );
114
+
115
+ // Register the plugin settings
116
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
117
+ add_filter( $this->func . '_settings_sanitize_text', array( $this, 'sanitize_text_field' ) );
118
+
119
+ // Add styles and scripts
120
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 100 );
121
+
122
+ // Process actions
123
+ add_action( 'admin_init', array( $this, 'process_actions' ) );
124
+
125
+ // Handle tooltips
126
+ add_filter( $this->func . '_after_setting_output', array( $this, 'add_setting_tooltip' ), 10, 2 );
127
+ }
128
+
129
+
130
+ /**
131
+ * Add settings pages
132
+ *
133
+ * @access public
134
+ * @since 1.0.0
135
+ * @global string ${this->func . '_settings_page'} The settings page slug
136
+ * @return void
137
+ */
138
+ public function add_settings_page() {
139
+ global ${$this->func . '_settings_page'};
140
+
141
+ $menu = apply_filters( $this->func . '_menu', array(
142
+ 'type' => 'menu',
143
+ 'parent' => 'options-general.php',
144
+ 'page_title' => __( 'Section214 Settings', 's214' ),
145
+ 'show_title' => false,
146
+ 'menu_title' => __( 'Section214 Settings', 's214' ),
147
+ 'capability' => 'manage_options',
148
+ 'icon' => '',
149
+ 'position' => null
150
+ ) );
151
+
152
+ $this->show_title = $menu['show_title'];
153
+ $this->page_title = $menu['page_title'];
154
+
155
+ if( $menu['type'] == 'submenu' ) {
156
+ ${$this->func . '_settings_page'} = add_submenu_page( $menu['parent'], $menu['page_title'], $menu['menu_title'], $menu['capability'], $this->slug . '-settings', array( $this, 'render_settings_page' ) );
157
+ } else {
158
+ ${$this->func . '_settings_page'} = add_menu_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $this->slug . '-settings', array( $this, 'render_settings_page' ), $menu['icon'], $menu['position'] );
159
+ }
160
+ }
161
+
162
+
163
+ /**
164
+ * Render settings page
165
+ *
166
+ * @access public
167
+ * @since 1.0.0
168
+ * @return void
169
+ */
170
+ public function render_settings_page() {
171
+ $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->get_settings_tabs() ) ? $_GET['tab'] : $this->default_tab;
172
+ $sections = $registered_sections = $this->get_settings_tab_sections( $active_tab );
173
+ $key = 'main';
174
+
175
+ if( is_array( $sections ) ) {
176
+ $key = key( $sections );
177
+ }
178
+
179
+ $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
180
+
181
+ ob_start();
182
+ ?>
183
+ <div class="wrap">
184
+ <?php if( $this->show_title ) { ?>
185
+ <h2><?php echo $this->page_title; ?></h2>
186
+ <?php } ?>
187
+ <h2 class="nav-tab-wrapper">
188
+ <?php
189
+ foreach( $this->get_settings_tabs() as $tab_id => $tab_name ) {
190
+ $tab_url = add_query_arg( array(
191
+ 'settings-updated' => false,
192
+ 'tab' => $tab_id
193
+ ) );
194
+
195
+ // Remove the section from the tabs so we always end up at the main section
196
+ $tab_url = remove_query_arg( 'section', $tab_url );
197
+
198
+ $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
199
+
200
+ echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">' . esc_html( $tab_name ) . '</a>';
201
+ }
202
+ ?>
203
+ </h2>
204
+ <?php
205
+ $number_of_sections = count( $sections );
206
+ $number = 0;
207
+
208
+ if( $number_of_sections > 1 ) {
209
+ echo '<div><ul class="subsubsub">';
210
+
211
+ foreach( $sections as $section_id => $section_name ) {
212
+ echo '<li>';
213
+
214
+ $number++;
215
+ $tab_url = add_query_arg( array(
216
+ 'settings-updated' => false,
217
+ 'tab' => $active_tab,
218
+ 'section' => $section_id
219
+ ) );
220
+ $class = '';
221
+
222
+ if( $section == $section_id ) {
223
+ $class = 'current';
224
+ }
225
+
226
+ echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
227
+
228
+ if( $number != $number_of_sections ) {
229
+ echo ' | ';
230
+ }
231
+
232
+ echo '</li>';
233
+ }
234
+
235
+ echo '</ul></div>';
236
+ }
237
+ ?>
238
+ <div id="tab_container">
239
+ <form method="post" action="options.php">
240
+ <table class="form-table">
241
+ <?php
242
+ settings_fields( $this->func . '_settings' );
243
+
244
+ do_action( $this->func . '_settings_tab_top_' . $active_tab . '_' . $section );
245
+
246
+ do_settings_sections( $this->func . '_settings_' . $active_tab . '_' . $section );
247
+
248
+ do_action( $this->func . '_settings_tab_bottom_' . $active_tab . '_' . $section );
249
+ ?>
250
+ </table>
251
+ <?php
252
+ if( ! in_array( $active_tab, apply_filters( $this->func . '_unsavable_tabs', array() ) ) ) {
253
+ submit_button();
254
+ }
255
+ ?>
256
+ </form>
257
+ </div>
258
+ </div>
259
+ <?php
260
+ echo ob_get_clean();
261
+ }
262
+
263
+
264
+ /**
265
+ * Retrieve the settings tabs
266
+ *
267
+ * @access private
268
+ * @since 1.0.0
269
+ * @return array $tabs The registered tabs for this plugin
270
+ */
271
+ private function get_settings_tabs() {
272
+ return apply_filters( $this->func . '_settings_tabs', array() );
273
+ }
274
+
275
+
276
+ /**
277
+ * Retrieve settings tab sections
278
+ *
279
+ * @access public
280
+ * @since 1.0.1
281
+ * @param string $tab The current tab
282
+ * @return array $section The section items
283
+ */
284
+ public function get_settings_tab_sections( $tab = false ) {
285
+ $tabs = false;
286
+ $sections = $this->get_registered_settings_sections();
287
+
288
+ if( $tab && ! empty( $sections[$tab] ) ) {
289
+ $tabs = $sections[$tab];
290
+ } elseif( $tab ) {
291
+ $tabs = false;
292
+ }
293
+
294
+ return $tabs;
295
+ }
296
+
297
+
298
+ /**
299
+ * Retrieve the plugin settings
300
+ *
301
+ * @access public
302
+ * @since 1.0.0
303
+ * @return array $settings The plugin settings
304
+ */
305
+ public function get_registered_settings() {
306
+ return apply_filters( $this->func . '_registered_settings', array() );
307
+ }
308
+
309
+
310
+ /**
311
+ * Retrieve the plugin settings sections
312
+ *
313
+ * @access private
314
+ * @since 1.0.1
315
+ * @return array $sections The registered sections
316
+ */
317
+ private function get_registered_settings_sections() {
318
+ global ${$this->func . '_sections'};
319
+
320
+ if ( !empty( ${$this->func . '_sections'} ) ) {
321
+ return ${$this->func . '_sections'};
322
+ }
323
+
324
+ ${$this->func . '_sections'} = apply_filters( $this->func . '_registered_settings_sections', array() );
325
+
326
+ return ${$this->func . '_sections'};
327
+ }
328
+
329
+
330
+ /**
331
+ * Retrieve an option
332
+ *
333
+ * @access public
334
+ * @since 1.0.0
335
+ * @param string $key The key to retrieve
336
+ * @param mixed $default The default value if key doesn't exist
337
+ * @global array ${$this->func . '_options'} The options array
338
+ * @return mixed $value The value to return
339
+ */
340
+ public function get_option( $key = '', $default = false ) {
341
+ global ${$this->func . '_options'};
342
+
343
+ $value = ! empty( ${$this->func . '_options'}[$key] ) ? ${$this->func . '_options'}[$key] : $default;
344
+ $value = apply_filters( $this->func . '_get_option', $value, $key, $default );
345
+
346
+ return apply_filters( $this->func . '_get_option_' . $key, $value, $key, $default );
347
+ }
348
+
349
+
350
+ /**
351
+ * Update an option
352
+ *
353
+ * @access public
354
+ * @since 1.0.0
355
+ * @param string $key The key to update
356
+ * @param mixed $value The value to set key to
357
+ * @return bool true if updated, false otherwise
358
+ */
359
+ public function update_option( $key = '', $value = false ) {
360
+ // Bail if no key is set
361
+ if( empty( $key ) ) {
362
+ return false;
363
+ }
364
+
365
+ if( empty( $value ) ) {
366
+ $remove_option = $this->delete_option( $key );
367
+ return $remove_option;
368
+ }
369
+
370
+ // Fetch a clean copy of the options array
371
+ $options = get_option( $this->func . '_settings' );
372
+
373
+ // Allow devs to modify the value
374
+ $value = apply_filters( $this->func . '_update_option', $value, $key );
375
+
376
+ // Try to update the option
377
+ $options[$key] = $value;
378
+ $did_update = update_option( $this->func . '_settings', $options );
379
+
380
+ // Update the global
381
+ if( $did_update ) {
382
+ global ${$this->func . '_options'};
383
+ ${$this->func . '_options'}[$key] = $value;
384
+ }
385
+
386
+ return $did_update;
387
+ }
388
+
389
+
390
+ /**
391
+ * Delete an option
392
+ *
393
+ * @access public
394
+ * @since 1.0.0
395
+ * @param string $key The key to delete
396
+ * @return bool true if deleted, false otherwise
397
+ */
398
+ public function delete_option( $key = '' ) {
399
+ // Bail if no key is set
400
+ if( empty( $key ) ) {
401
+ return false;
402
+ }
403
+
404
+ // Fetch a clean copy of the options array
405
+ $options = get_option( $this->func . '_settings' );
406
+
407
+ // Try to unset the option
408
+ if( isset( $options[$key] ) ) {
409
+ unset( $options[$key] );
410
+ }
411
+
412
+ $did_update = update_option( $this->func . '_settings', $options );
413
+
414
+ // Update the global
415
+ if( $did_update ) {
416
+ global ${$this->func . '_options'};
417
+ ${$this->func . '_options'} = $options;
418
+ }
419
+
420
+ return $did_update;
421
+ }
422
+
423
+
424
+ /**
425
+ * Retrieve all options
426
+ *
427
+ * @access public
428
+ * @since 1.0.0
429
+ * @return array $settings The options array
430
+ */
431
+ public function get_settings() {
432
+ $settings = get_option( $this->func . '_settings' );
433
+
434
+ if( empty( $settings ) ) {
435
+ $settings = array();
436
+
437
+ update_option( $this->func . '_settings', $settings );
438
+ }
439
+
440
+ return apply_filters( $this->func . '_get_settings', $settings );
441
+ }
442
+
443
+
444
+ /**
445
+ * Add settings sections and fields
446
+ *
447
+ * @access public
448
+ * @since 1.0.0
449
+ * @return void
450
+ */
451
+ function register_settings() {
452
+ if( get_option( $this->func . '_settings' ) == false ) {
453
+ add_option( $this->func . '_settings' );
454
+ }
455
+
456
+ foreach( $this->get_registered_settings() as $tab => $sections ) {
457
+ foreach( $sections as $section => $settings ) {
458
+ // Check for backwards compatibility
459
+ $section_tabs = $this->get_settings_tab_sections( $tab );
460
+
461
+ if( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
462
+ $section = 'main';
463
+ $settings = $sections;
464
+ }
465
+
466
+ add_settings_section(
467
+ $this->func . '_settings_' . $tab . '_' . $section,
468
+ __return_null(),
469
+ '__return_false',
470
+ $this->func . '_settings_' . $tab . '_' . $section
471
+ );
472
+
473
+ foreach( $settings as $option ) {
474
+ // For backwards compatibility
475
+ if( empty( $option['id'] ) ) {
476
+ continue;
477
+ }
478
+
479
+ $name = isset( $option['name'] ) ? $option['name'] : '';
480
+
481
+ add_settings_field(
482
+ $this->func . '_settings[' . $option['id'] . ']',
483
+ $name,
484
+ function_exists( $this->func . '_' . $option['type'] . '_callback' ) ? $this->func . '_' . $option['type'] . '_callback' : ( method_exists( $this, $option['type'] . '_callback' ) ? array( $this, $option['type'] . '_callback' ) : array( $this, 'missing_callback' ) ),
485
+ $this->func . '_settings_' . $tab . '_' . $section,
486
+ $this->func . '_settings_' . $tab . '_' . $section,
487
+ array(
488
+ 'section' => $section,
489
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
490
+ 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
491
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
492
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
493
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
494
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
495
+ 'min' => isset( $option['min'] ) ? $option['min'] : null,
496
+ 'max' => isset( $option['max'] ) ? $option['max'] : null,
497
+ 'step' => isset( $option['step'] ) ? $option['step'] : null,
498
+ 'select2' => isset( $option['select2'] ) ? $option['select2'] : null,
499
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
500
+ 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : null,
501
+ 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
502
+ 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
503
+ 'buttons' => isset( $option['buttons'] ) ? $option['buttons'] : null,
504
+ 'wpautop' => isset( $option['wpautop'] ) ? $option['wpautop'] : null,
505
+ 'teeny' => isset( $option['teeny'] ) ? $option['teeny'] : null,
506
+ 'tab' => isset( $option['tab'] ) ? $option['tab'] : null,
507
+ 'tooltip_title' => isset( $option['tooltip_title'] ) ? $option['tooltip_title'] : false,
508
+ 'tooltip_desc' => isset( $option['tooltip_desc'] ) ? $option['tooltip_desc'] : false
509
+ )
510
+ );
511
+ }
512
+ }
513
+ }
514
+
515
+ register_setting( $this->func . '_settings', $this->func . '_settings', array( $this, 'settings_sanitize' ) );
516
+ }
517
+
518
+
519
+ /**
520
+ * Settings sanitization
521
+ *
522
+ * @access public
523
+ * @since 1.0.0
524
+ * @param array $input The value entered in the field
525
+ * @global array ${$this->func . '_options'} The options array
526
+ * @return string $input The sanitized value
527
+ */
528
+ public function settings_sanitize( $input = array() ) {
529
+ global ${$this->func . '_options'};
530
+
531
+ $doing_section = false;
532
+
533
+ if( ! empty( $_POST['_wp_http_referer'] ) ) {
534
+ $doing_section = true;
535
+ }
536
+
537
+ $setting_types = $this->get_registered_settings_types();
538
+ $input = $input ? $input : array();
539
+
540
+ if( $doing_section ) {
541
+ parse_str( $_POST['_wp_http_referer'], $referrer );
542
+
543
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : $this->default_tab;
544
+ $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
545
+ $input = apply_filters( $this->func . '_settings_' . $tab . '_sanitize', $input );
546
+ $input = apply_filters( $this->func . '_settings_' . $tab . '-' . $section . '_sanitize', $input );
547
+ }
548
+
549
+ $output = array_merge( ${$this->func . '_options'}, $input );
550
+
551
+ foreach( $setting_types as $key => $type ) {
552
+ if( empty( $type ) ) {
553
+ continue;
554
+ }
555
+
556
+ // Bypass non-setting settings
557
+ $non_setting_types = apply_filters( $this->func . '_non_setting_types', array(
558
+ 'header', 'descriptive_text', 'hook'
559
+ ) );
560
+
561
+ if( in_array( $type, $non_setting_types ) ) {
562
+ continue;
563
+ }
564
+
565
+ if( array_key_exists( $key, $output ) ) {
566
+ $output[$key] = apply_filters( $this->func . '_settings_sanitize_' . $type, $output[$key], $key );
567
+ $output[$key] = apply_filters( $this->func . '_settings_sanitize', $output[$key], $key );
568
+ }
569
+
570
+ if( $doing_section ) {
571
+ switch( $type ) {
572
+ case 'checkbox':
573
+ if( array_key_exists( $key, $input ) && $output[$key] === '-1' ) {
574
+ unset( $output[$key] );
575
+ }
576
+ break;
577
+ default:
578
+ if( array_key_exists( $key, $input ) && empty( $input[$key] ) ) {
579
+ unset( $output[$key] );
580
+ }
581
+ break;
582
+ }
583
+ } else {
584
+ if( empty( $input[$key] ) ) {
585
+ unset( $output[$key] );
586
+ }
587
+ }
588
+ }
589
+
590
+ if( $doing_section ) {
591
+ add_settings_error( $this->slug . '-notices', '', __( 'Settings updated.', 's214-settings' ), 'updated' );
592
+ }
593
+
594
+ return $output;
595
+ }
596
+
597
+
598
+ /**
599
+ * Flattens the set of registered settings and their type so we can easily sanitize all settings
600
+ *
601
+ * @since 1.2.0
602
+ * @return array Key is the setting ID, value is the type of setting it is registered as
603
+ */
604
+ function get_registered_settings_types() {
605
+ $settings = $this->get_registered_settings();
606
+ $setting_types = array();
607
+
608
+ foreach( $settings as $tab ) {
609
+ foreach( $tab as $section_or_setting ) {
610
+ // See if we have a setting registered at the tab level for backwards compatibility
611
+ if( is_array( $section_or_setting ) && array_key_exists( 'type', $section_or_setting ) ) {
612
+ $setting_types[$section_or_setting['id']] = $section_or_setting['type'];
613
+ continue;
614
+ }
615
+
616
+ foreach( $section_or_setting as $section => $section_settings ) {
617
+ $setting_types[$section_settings['id']] = $section_settings['type'];
618
+ }
619
+ }
620
+ }
621
+
622
+ return $setting_types;
623
+ }
624
+
625
+
626
+ /**
627
+ * Sanitize text fields
628
+ *
629
+ * @access public
630
+ * @since 1.0.0
631
+ * @param array $input The value entered in the field
632
+ * @return string $input The sanitized value
633
+ */
634
+ public function sanitize_text_field( $input ) {
635
+ return trim( wp_strip_all_tags( $input, true ) );
636
+ }
637
+
638
+
639
+ /**
640
+ * Header callback
641
+ *
642
+ * @access public
643
+ * @since 1.0.0
644
+ * @param array $args Arguments passed by the setting
645
+ * @return void
646
+ */
647
+ public function header_callback( $args ) {
648
+ echo '<hr />';
649
+ }
650
+
651
+
652
+ /**
653
+ * Checkbox callback
654
+ *
655
+ * @access public
656
+ * @since 1.0.0
657
+ * @param array $args Arguments passed by the setting
658
+ * @global array ${$this->func . '_options'} The plugin options
659
+ * @return void
660
+ */
661
+ public function checkbox_callback( $args ) {
662
+ global ${$this->func . '_options'};
663
+
664
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
665
+ $checked = isset( ${$this->func . '_options'}[$args['id']] ) ? checked( 1, ${$this->func . '_options'}[$args['id']], false ) : '';
666
+
667
+ $html = '<input type="hidden"' . $name . ' value="-1" />';
668
+ $html .= '<input type="checkbox" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="1" ' . $checked . '/>&nbsp;';
669
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
670
+
671
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
672
+ }
673
+
674
+
675
+ /**
676
+ * Color callback
677
+ *
678
+ * @access public
679
+ * @since 1.0.0
680
+ * @param array $args Arguments passed by the settings
681
+ * @global array ${$this->func . '_options'} The Beacon options
682
+ * @return void
683
+ */
684
+ public function color_callback( $args ) {
685
+ global ${$this->func . '_options'};
686
+
687
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
688
+ $value = ${$this->func . '_options'}[$args['id']];
689
+ } else {
690
+ $value = isset( $args['std'] ) ? $args['std'] : '';
691
+ }
692
+
693
+ $default = isset( $args['std'] ) ? $args['std'] : '';
694
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
695
+
696
+ $html = '<input type="text" class="s214-color-picker" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />&nbsp;';
697
+ $html .= '<span class="s214-color-picker-label description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
698
+
699
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
700
+ }
701
+
702
+
703
+ /**
704
+ * Descriptive text callback
705
+ *
706
+ * @access public
707
+ * @since 1.0.0
708
+ * @param array $args Arguments passed by the setting
709
+ * @return void
710
+ */
711
+ public function descriptive_text_callback( $args ) {
712
+ $html = wp_kses_post( $args['desc'] );
713
+
714
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
715
+ }
716
+
717
+
718
+ /**
719
+ * Editor callback
720
+ *
721
+ * @access public
722
+ * @since 1.0.0
723
+ * @param array $args Arguments passed by the setting
724
+ * @global array ${$this->func . '_options'} The Beacon options
725
+ * @return void
726
+ */
727
+ public function editor_callback( $args ) {
728
+ global ${$this->func . '_options'};
729
+
730
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
731
+ $value = ${$this->func . '_options'}[$args['id']];
732
+
733
+ if( empty( $args['allow_blank'] ) && empty( $value ) ) {
734
+ $value = isset( $args['std'] ) ? $args['std'] : '';
735
+ }
736
+ } else {
737
+ $value = isset( $args['std'] ) ? $args['std'] : '';
738
+ }
739
+
740
+ $rows = isset( $args['size'] ) ? $args['size'] : '10';
741
+ $wpautop = isset( $args['wpautop'] ) ? $args['wpautop'] : true;
742
+ $buttons = isset( $args['buttons'] ) ? $args['buttons'] : true;
743
+ $teeny = isset( $args['teeny'] ) ? $args['teeny'] : false;
744
+
745
+ wp_editor(
746
+ $value,
747
+ $this->func . '_settings_' . $args['id'],
748
+ array(
749
+ 'wpautop' => $wpautop,
750
+ 'media_buttons' => $buttons,
751
+ 'textarea_name' => $this->func . '_settings[' . $args['id'] . ']',
752
+ 'textarea_rows' => $rows,
753
+ 'teeny' => $teeny
754
+ )
755
+ );
756
+ $html = '<br /><span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
757
+
758
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
759
+ }
760
+
761
+
762
+ /**
763
+ * HTML callback
764
+ *
765
+ * @since 1.0.0
766
+ * @param array $args Arguments passed by the setting
767
+ * @global array ${$this->func . '_options'} The Beacon options
768
+ * @return void
769
+ */
770
+ public function html_callback( $args ) {
771
+ global ${$this->func . '_options'};
772
+
773
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
774
+ $value = ${$this->func . '_options'}[$args['id']];
775
+ } else {
776
+ $value = isset( $args['std'] ) ? $args['std'] : '';
777
+ }
778
+
779
+ $html = '<textarea class="large-text s214-html" cols="50" rows="5" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>&nbsp;';
780
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
781
+
782
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
783
+ }
784
+
785
+
786
+ /**
787
+ * Multicheck callback
788
+ *
789
+ * @access public
790
+ * @since 1.0.0
791
+ * @param array $args Arguments passed by the setting
792
+ * @global array ${$this->func . '_options'} The Beacon options
793
+ * @return void
794
+ */
795
+ public function multicheck_callback( $args ) {
796
+ global ${$this->func . '_options'};
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] ) ) {
803
+ $enabled = $option;
804
+ } else {
805
+ $enabled = isset( $args['std'][$key] ) ? $args['std'][$key] : NULL;
806
+ }
807
+
808
+ $html .= '<input name="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" id="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . ' />&nbsp;';
809
+ $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
810
+ }
811
+ $html .= '<span class="description">' . $args['desc'] . '</span>';
812
+
813
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
814
+ }
815
+ }
816
+
817
+
818
+ /**
819
+ * Number callback
820
+ *
821
+ * @access public
822
+ * @since 1.0.0
823
+ * @param array $args Arguments passed by the setting
824
+ * @global array ${$this->func . '_options'} The Beacon options
825
+ * @return void
826
+ */
827
+ public function number_callback( $args ) {
828
+ global ${$this->func . '_options'};
829
+
830
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
831
+ $value = ${$this->func . '_options'}[$args['id']];
832
+ } else {
833
+ $value = isset( $args['std'] ) ? $args['std'] : '';
834
+ }
835
+
836
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
837
+ $max = isset( $args['max'] ) ? $args['max'] : 999999;
838
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
839
+ $step = isset( $args['step'] ) ? $args['step'] : 1;
840
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
841
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
842
+
843
+ $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
844
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
845
+
846
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
847
+ }
848
+
849
+
850
+ /**
851
+ * Password callback
852
+ *
853
+ * @access public
854
+ * @since 1.0.0
855
+ * @param array $args Arguments passed by the settings
856
+ * @global array ${$this->func . '_options'} The Beacon options
857
+ * @return void
858
+ */
859
+ public function password_callback( $args ) {
860
+ global ${$this->func . '_options'};
861
+
862
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
863
+ $value = ${$this->func . '_options'}[$args['id']];
864
+ } else {
865
+ $value = isset( $args['std'] ) ? $args['std'] : '';
866
+ }
867
+
868
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
869
+
870
+ $html = '<input type="password" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" />&nbsp;';
871
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
872
+
873
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
874
+ }
875
+
876
+
877
+ /**
878
+ * Radio callback
879
+ *
880
+ * @access public
881
+ * @since 1.0.0
882
+ * @param array $args Arguments passed by the setting
883
+ * @global array ${$this->func . '_options'} The Beacon options
884
+ * @return void
885
+ */
886
+ public function radio_callback( $args ) {
887
+ global ${$this->func . '_options'};
888
+
889
+ if( ! empty( $args['options'] ) ) {
890
+ $html = '';
891
+
892
+ foreach( $args['options'] as $key => $option ) {
893
+ $checked = false;
894
+
895
+ if( isset( ${$this->func . '_options'}[$args['id']] ) && ${$this->func . '_options'}[$args['id']] == $key ) {
896
+ $checked = true;
897
+ } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( ${$this->func . '_options'}[$args['id']] ) ) {
898
+ $checked = true;
899
+ }
900
+
901
+ $html .= '<input name="' . $this->func . '_settings[' . $args['id'] . ']" id="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
902
+ $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
903
+ }
904
+
905
+ $html .= '<p class="description">' . $args['desc'] . '</p>';
906
+
907
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
908
+ }
909
+ }
910
+
911
+
912
+ /**
913
+ * Select callback
914
+ *
915
+ * @access public
916
+ * @since 1.0.0
917
+ * @param array $args Arguments passed by the setting
918
+ * @global array ${$this->func . '_options'} The Beacon options
919
+ * @return void
920
+ */
921
+ public function select_callback( $args ) {
922
+ global ${$this->func . '_options'};
923
+
924
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
925
+ $value = ${$this->func . '_options'}[$args['id']];
926
+ } else {
927
+ $value = isset( $args['std'] ) ? $args['std'] : '';
928
+ }
929
+
930
+ $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
931
+ $select2 = isset( $args['select2'] ) ? ' class="s214-select2"' : '';
932
+ $width = isset( $args['size'] ) ? ' style="width: ' . $args['size'] . '"' : '';
933
+
934
+ if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
935
+ $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . '][]"' . $select2 . ' data-placeholder="' . $placeholder . '" multiple="multiple"' . $width . ' />';
936
+ } else {
937
+ $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']"' . $select2 . ' data-placeholder="' . $placeholder . '"' . $width . ' />';
938
+ }
939
+
940
+ foreach( $args['options'] as $option => $name ) {
941
+ if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
942
+ if( is_array( $value ) ) {
943
+ $selected = ( in_array( $option, $value ) ? 'selected="selected"' : '' );
944
+ } else {
945
+ $selected = '';
946
+ }
947
+ } else {
948
+ if( is_string( $value ) ) {
949
+ $selected = selected( $option, $value, false );
950
+ } else {
951
+ $selected = '';
952
+ }
953
+ }
954
+
955
+ $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
956
+ }
957
+
958
+ $html .= '</select>&nbsp;';
959
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
960
+
961
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
962
+ }
963
+
964
+
965
+ /**
966
+ * Sysinfo callback
967
+ *
968
+ * @since 1.1.0
969
+ * @param array $args Arguements passed by the settings
970
+ * @return void
971
+ */
972
+ public function sysinfo_callback( $args ) {
973
+ global ${$this->func . '_options'};
974
+
975
+ if( ! isset( ${$this->func . '_options'}[$args['tab']] ) || ( isset( ${$this->func . '_options'}[$args['tab']] ) && isset( $_GET['tab'] ) && $_GET['tab'] == ${$this->func . '_options'}[$args['tab']] ) ) {
976
+ $html = '<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="' . $this->func . '-system-info" title="' . __( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 's214-settings' ) . '">' . $this->sysinfo->get_system_info() . '</textarea>';
977
+ $html .= '<p class="submit">';
978
+ $html .= '<input type="hidden" name="' . $this->slug . '-settings-action" value="download_system_info" />';
979
+ $html .= '<a class="button button-primary" href="' . add_query_arg( $this->slug . '-settings-action', 'download_system_info' ) . '">' . __( 'Download System Info File', 's214-settings' ) . '</a>';
980
+ $html .= '</p>';
981
+
982
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
983
+ }
984
+ }
985
+
986
+
987
+ /**
988
+ * Text callback
989
+ *
990
+ * @since 1.0.0
991
+ * @param array $args Arguments passed by the setting
992
+ * @global array ${$this->func . '_options'} The Beacon options
993
+ * @return void
994
+ */
995
+ public function text_callback( $args ) {
996
+ global ${$this->func . '_options'};
997
+
998
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
999
+ $value = ${$this->func . '_options'}[$args['id']];
1000
+ } else {
1001
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1002
+ }
1003
+
1004
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
1005
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1006
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1007
+
1008
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
1009
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1010
+
1011
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1012
+ }
1013
+
1014
+
1015
+ /**
1016
+ * Textarea callback
1017
+ *
1018
+ * @since 1.0.0
1019
+ * @param array $args Arguments passed by the setting
1020
+ * @global array ${$this->func . '_options'} The Beacon options
1021
+ * @return void
1022
+ */
1023
+ public function textarea_callback( $args ) {
1024
+ global ${$this->func . '_options'};
1025
+
1026
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1027
+ $value = ${$this->func . '_options'}[$args['id']];
1028
+ } else {
1029
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1030
+ }
1031
+
1032
+ $html = '<textarea class="large-text" cols="50" rows="5" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>&nbsp;';
1033
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1034
+
1035
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1036
+ }
1037
+
1038
+
1039
+ /**
1040
+ * Upload callback
1041
+ *
1042
+ * @since 1.0.0
1043
+ * @param array $args Arguments passed by the setting
1044
+ * @global array ${$this->func . '_options'} The Beacon options
1045
+ * @return void
1046
+ */
1047
+ public function upload_callback( $args ) {
1048
+ global ${$this->func . '_options'};
1049
+
1050
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1051
+ $value = ${$this->func . '_options'}[$args['id']];
1052
+ } else {
1053
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1054
+ }
1055
+
1056
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1057
+
1058
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />&nbsp;';
1059
+ $html .= '<span><input type="button" class="' . $this->func . '_settings_upload_button button-secondary" value="' . __( 'Upload File', 's214-settings' ) . '" /></span>&nbsp;';
1060
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1061
+
1062
+ if ( $value ) {
1063
+ $html .= '<br /><img src="' . $value . '" class="timeapp_settings_upload_image" />';
1064
+ }
1065
+
1066
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1067
+ }
1068
+
1069
+
1070
+ /**
1071
+ * License field callback
1072
+ *
1073
+ * @access public
1074
+ * @since 1.0.0
1075
+ * @param array $args Arguments passed by the setting
1076
+ * @global array ${$this->func . '_options'} The Beacon options
1077
+ * @return void
1078
+ */
1079
+ public function license_key_callback( $args ) {
1080
+ global ${$this->func . '_options'};
1081
+
1082
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1083
+ $value = ${$this->func . '_options'}[$args['id']];
1084
+ } else {
1085
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1086
+ }
1087
+
1088
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1089
+
1090
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" />&nbsp;';
1091
+
1092
+ if( get_option( $args['options']['is_valid_license_option'] ) ) {
1093
+ $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 's214-settings' ) . '"/>';
1094
+ }
1095
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label></span>';
1096
+
1097
+ wp_nonce_field( $args['id'] . '-nonce', $args['id'] . '-nonce' );
1098
+
1099
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1100
+ }
1101
+
1102
+
1103
+ /**
1104
+ * Hook callback
1105
+ *
1106
+ * @since 1.0.0
1107
+ * @param array $args Arguments passed by the setting
1108
+ * @return void
1109
+ */
1110
+ public function hook_callback( $args ) {
1111
+ do_action( $this->func . '_' . $args['id'] );
1112
+ }
1113
+
1114
+
1115
+ /**
1116
+ * Missing callback
1117
+ *
1118
+ * @access public
1119
+ * @since 1.0.0
1120
+ * @param array $args Arguments passed by the setting
1121
+ * @return void
1122
+ */
1123
+ public function missing_callback( $args ) {
1124
+ printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 's214-settings' ), $args['id'] );
1125
+ }
1126
+
1127
+
1128
+ /**
1129
+ * Check if we should load admin scripts
1130
+ *
1131
+ * @access public
1132
+ * @since 1.0.0
1133
+ * @param string $hook The hook for the current page
1134
+ * @return bool true if we should load scripts, false otherwise
1135
+ */
1136
+ public function load_scripts( $hook ) {
1137
+ global $typenow, $pagenow, ${$this->func . '_settings_page'};
1138
+
1139
+ $ret = false;
1140
+ $pages = apply_filters( $this->func . '_admin_pages', array( ${$this->func . '_settings_page'} ) );
1141
+
1142
+ if( in_array( $hook, $pages ) ) {
1143
+ $ret = true;
1144
+ }
1145
+
1146
+ return (bool) apply_filters( $this->func . 'load_scripts', $ret );
1147
+ }
1148
+
1149
+
1150
+ /**
1151
+ * Processes all actions sent via POST and GET by looking for the '$func-settings-action'
1152
+ * request and running do_action() to call the function
1153
+ *
1154
+ * @since 1.1.0
1155
+ * @return void
1156
+ */
1157
+ function process_actions() {
1158
+ if( ! isset( $_POST['submit'] ) ) {
1159
+ if( isset( $_POST[$this->slug . '-settings-action'] ) ) {
1160
+ do_action( $this->func . '_settings_' . $_POST[$this->slug . '-settings-action'], $_POST );
1161
+ }
1162
+
1163
+ if( isset( $_GET[$this->slug . '-settings-action'] ) ) {
1164
+ do_action( $this->func . '_settings_' . $_GET[$this->slug . '-settings-action'], $_GET );
1165
+ }
1166
+ }
1167
+ }
1168
+
1169
+
1170
+ /**
1171
+ * Enqueue scripts
1172
+ *
1173
+ * @access public
1174
+ * @since 1.0.0
1175
+ * @param string $hook The current page hook
1176
+ * @return void
1177
+ */
1178
+ public function enqueue_scripts( $hook ) {
1179
+ if( ! apply_filters( $this->func . '_load_admin_scripts', $this->load_scripts( $hook ), $hook ) ) {
1180
+ return;
1181
+ }
1182
+
1183
+ // Use minified libraries if SCRIPT_DEBUG is turned off
1184
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1185
+ $ui_style = ( get_user_option( 'admin_color' ) == 'classic' ) ? 'classic' : 'fresh';
1186
+ $url_path = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname( __FILE__ ) );
1187
+ $select2_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/';
1188
+ $cm_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.14.2/';
1189
+
1190
+ wp_enqueue_style( 'wp-color-picker' );
1191
+ wp_enqueue_script( 'wp-color-picker' );
1192
+ wp_enqueue_script( 'jquery-ui-tooltip' );
1193
+ wp_enqueue_media();
1194
+ wp_enqueue_style( 'jquery-ui-css', $url_path . '/assets/css/jquery-ui-' . $ui_style . '.min.css' );
1195
+ wp_enqueue_script( 'media-upload' );
1196
+ wp_enqueue_style( 'thickbox' );
1197
+ wp_enqueue_script( 'thickbox' );
1198
+ wp_enqueue_style( 'select2', $select2_cdn . 'css/select2.min.css', array(), '4.0.2' );
1199
+ wp_enqueue_script( 'select2', $select2_cdn . 'js/select2.min.js', array( 'jquery' ), '4.0.2' );
1200
+
1201
+ wp_enqueue_style( $this->slug . '-cm', $cm_cdn . 'codemirror.css', array(), '5.10' );
1202
+ wp_enqueue_script( $this->slug . '-cm', $cm_cdn . 'codemirror.js', array( 'jquery' ), '5.14.2' );
1203
+ wp_enqueue_script( $this->slug . '-cm-html', $cm_cdn . 'mode/htmlmixed/htmlmixed.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1204
+ wp_enqueue_script( $this->slug . '-cm-xml', $cm_cdn . 'mode/xml/xml.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1205
+ wp_enqueue_script( $this->slug . '-cm-js', $cm_cdn . 'mode/javascript/javascript.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1206
+ wp_enqueue_script( $this->slug . '-cm-css', $cm_cdn . 'mode/css/css.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1207
+ wp_enqueue_script( $this->slug . '-cm-php', $cm_cdn . 'mode/php/php.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1208
+ wp_enqueue_script( $this->slug . '-cm-clike', $cm_cdn . 'mode/clike/clike.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1209
+
1210
+ wp_enqueue_style( $this->slug . '-s214-settings', $url_path . '/assets/css/admin' . $suffix . '.css', array(), $this->version );
1211
+ wp_enqueue_script( $this->slug . '-s214-settings', $url_path . '/assets/js/admin' . $suffix . '.js', array( 'jquery' ), $this->version );
1212
+ wp_localize_script( $this->slug . '-s214-settings', 's214_settings_vars', apply_filters( $this->func . 'localize_script', array(
1213
+ 'func' => $this->func,
1214
+ 'image_media_button' => __( 'Insert Image', 's214-settings' ),
1215
+ 'image_media_title' => __( 'Select Image', 's214-settings' ),
1216
+ ) ) );
1217
+ }
1218
+
1219
+
1220
+ /**
1221
+ * Add tooltips
1222
+ *
1223
+ * @access public
1224
+ * @since 1.2.0
1225
+ * @param string $html The current field HTML
1226
+ * @param array $args Arguments passed to the field
1227
+ * @return string $html The updated field HTML
1228
+ */
1229
+ function add_setting_tooltip( $html, $args ) {
1230
+ if( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1231
+ $tooltip = '<span alt="f223" class="s214-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1232
+ $html .= $tooltip;
1233
+ }
1234
+
1235
+ return $html;
1236
+ }
1237
+ }
includes/libraries/s214-settings/source/modules/licensing/S214_Plugin_Updater.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // uncomment this line for testing
4
+ //set_site_transient( 'update_plugins', null );
5
+
6
+ // Exit if accessed directly
7
+ if ( ! defined( 'ABSPATH' ) ) exit;
8
+
9
+ /**
10
+ * Allows plugins to use their own update API.
11
+ *
12
+ * @author Pippin Williamson
13
+ * @version 1.6
14
+ */
15
+ class S214_Plugin_Updater {
16
+ private $api_url = '';
17
+ private $api_data = array();
18
+ private $name = '';
19
+ private $slug = '';
20
+ private $version = '';
21
+
22
+ /**
23
+ * Class constructor.
24
+ *
25
+ * @uses plugin_basename()
26
+ * @uses hook()
27
+ *
28
+ * @param string $_api_url The URL pointing to the custom API endpoint.
29
+ * @param string $_plugin_file Path to the plugin file.
30
+ * @param array $_api_data Optional data to send with API calls.
31
+ */
32
+ function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+ global $s214_plugin_data;
34
+
35
+ $this->api_url = trailingslashit( $_api_url );
36
+ $this->api_data = $_api_data;
37
+ $this->name = plugin_basename( $_plugin_file );
38
+ $this->slug = basename( $_plugin_file, '.php' );
39
+ $this->version = $_api_data['version'];
40
+
41
+ $s214_plugin_data[$this->slug] = $this->api_data;
42
+
43
+ // Set up hooks.
44
+ $this->init();
45
+ }
46
+
47
+ /**
48
+ * Set up WordPress filters to hook into WP's update process.
49
+ *
50
+ * @uses add_filter()
51
+ *
52
+ * @return void
53
+ */
54
+ public function init() {
55
+
56
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
57
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
58
+
59
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
60
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
61
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
62
+ }
63
+
64
+ /**
65
+ * Check for Updates at the defined API endpoint and modify the update array.
66
+ *
67
+ * This function dives into the update API just when WordPress creates its update array,
68
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
69
+ * It is reassembled from parts of the native WordPress plugin update code.
70
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
71
+ *
72
+ * @uses api_request()
73
+ *
74
+ * @param array $_transient_data Update array build by WordPress.
75
+ * @return array Modified update array with custom plugin data.
76
+ */
77
+ function check_update( $_transient_data ) {
78
+
79
+ global $pagenow;
80
+
81
+ if( ! is_object( $_transient_data ) ) {
82
+ $_transient_data = new stdClass;
83
+ }
84
+
85
+ if( 'plugins.php' == $pagenow && is_multisite() ) {
86
+ return $_transient_data;
87
+ }
88
+
89
+ if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
90
+
91
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
92
+
93
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
94
+
95
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
96
+
97
+ if ( empty( $version_info->plugin ) ) {
98
+ $version_info->plugin = $this->name;
99
+ }
100
+
101
+ $_transient_data->response[ $this->name ] = $version_info;
102
+
103
+ }
104
+
105
+ $_transient_data->last_checked = time();
106
+ $_transient_data->checked[ $this->name ] = $this->version;
107
+
108
+ }
109
+
110
+ }
111
+
112
+ return $_transient_data;
113
+ }
114
+
115
+ /**
116
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
117
+ *
118
+ * @param string $file
119
+ * @param array $plugin
120
+ */
121
+ public function show_update_notification( $file, $plugin ) {
122
+
123
+ if( ! current_user_can( 'update_plugins' ) ) {
124
+ return;
125
+ }
126
+
127
+ if( ! is_multisite() ) {
128
+ return;
129
+ }
130
+
131
+ if ( $this->name != $file ) {
132
+ return;
133
+ }
134
+
135
+ // Remove our filter on the site transient
136
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
137
+
138
+ $update_cache = get_site_transient( 'update_plugins' );
139
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
140
+
141
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[$this->name] ) ) {
142
+
143
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $this->name ) . '_version_info' );
144
+ $version_info = get_transient( $cache_key );
145
+
146
+ if( false === $version_info ) {
147
+
148
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
149
+
150
+ set_transient( $cache_key, $version_info, 3600 );
151
+ }
152
+
153
+
154
+ if( ! is_object( $version_info ) ) {
155
+ return;
156
+ }
157
+
158
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
159
+
160
+ $update_cache->response[ $this->name ] = $version_info;
161
+
162
+ }
163
+
164
+ $update_cache->last_checked = time();
165
+ $update_cache->checked[ $this->name ] = $this->version;
166
+
167
+ set_site_transient( 'update_plugins', $update_cache );
168
+
169
+ } else {
170
+
171
+ $version_info = $update_cache->response[ $this->name ];
172
+
173
+ }
174
+
175
+ // Restore our filter
176
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
177
+
178
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
179
+
180
+ // build a plugin list row, with update notification
181
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
182
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
183
+
184
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
185
+
186
+ if ( empty( $version_info->download_link ) ) {
187
+ printf(
188
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
189
+ esc_html( $version_info->name ),
190
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
191
+ esc_html( $version_info->new_version ),
192
+ '</a>'
193
+ );
194
+ } else {
195
+ printf(
196
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
197
+ esc_html( $version_info->name ),
198
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
199
+ esc_html( $version_info->new_version ),
200
+ '</a>',
201
+ '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">',
202
+ '</a>'
203
+ );
204
+ }
205
+
206
+ do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
207
+
208
+ echo '</div></td></tr>';
209
+ }
210
+ }
211
+
212
+
213
+ /**
214
+ * Updates information on the "View version x.x details" page with custom data.
215
+ *
216
+ * @uses api_request()
217
+ *
218
+ * @param mixed $_data
219
+ * @param string $_action
220
+ * @param object $_args
221
+ * @return object $_data
222
+ */
223
+ function plugins_api_filter( $_data, $_action = '', $_args = null ) {
224
+
225
+
226
+ if ( $_action != 'plugin_information' ) {
227
+
228
+ return $_data;
229
+
230
+ }
231
+
232
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
233
+
234
+ return $_data;
235
+
236
+ }
237
+
238
+ $to_send = array(
239
+ 'slug' => $this->slug,
240
+ 'is_ssl' => is_ssl(),
241
+ 'fields' => array(
242
+ 'banners' => false, // These will be supported soon hopefully
243
+ 'reviews' => false
244
+ )
245
+ );
246
+
247
+ $api_response = $this->api_request( 'plugin_information', $to_send );
248
+
249
+ if ( false !== $api_response ) {
250
+ $_data = $api_response;
251
+ }
252
+
253
+ return $_data;
254
+ }
255
+
256
+
257
+ /**
258
+ * Disable SSL verification in order to prevent download update failures
259
+ *
260
+ * @param array $args
261
+ * @param string $url
262
+ * @return object $array
263
+ */
264
+ function http_request_args( $args, $url ) {
265
+ // If it is an https request and we are performing a package download, disable ssl verification
266
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
267
+ $args['sslverify'] = false;
268
+ }
269
+ return $args;
270
+ }
271
+
272
+ /**
273
+ * Calls the API and, if successfull, returns the object delivered by the API.
274
+ *
275
+ * @uses get_bloginfo()
276
+ * @uses wp_remote_post()
277
+ * @uses is_wp_error()
278
+ *
279
+ * @param string $_action The requested action.
280
+ * @param array $_data Parameters for the API action.
281
+ * @return false|object
282
+ */
283
+ private function api_request( $_action, $_data ) {
284
+
285
+ global $wp_version;
286
+
287
+ $data = array_merge( $this->api_data, $_data );
288
+
289
+ if ( $data['slug'] != $this->slug )
290
+ return;
291
+
292
+ if ( empty( $data['license'] ) )
293
+ return;
294
+
295
+ if( $this->api_url == home_url() ) {
296
+ return false; // Don't allow a plugin to ping itself
297
+ }
298
+
299
+ $api_params = array(
300
+ 'edd_action' => 'get_version',
301
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
302
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
303
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
304
+ 'slug' => $data['slug'],
305
+ 'author' => $data['author'],
306
+ 'url' => home_url()
307
+ );
308
+
309
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
310
+
311
+ if ( ! is_wp_error( $request ) ) {
312
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
313
+ }
314
+
315
+ if ( $request && isset( $request->sections ) ) {
316
+ $request->sections = maybe_unserialize( $request->sections );
317
+ } else {
318
+ $request = false;
319
+ }
320
+
321
+ return $request;
322
+ }
323
+
324
+ public function show_changelog() {
325
+
326
+
327
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
328
+ return;
329
+ }
330
+
331
+ if( empty( $_REQUEST['plugin'] ) ) {
332
+ return;
333
+ }
334
+
335
+ if( empty( $_REQUEST['slug'] ) ) {
336
+ return;
337
+ }
338
+
339
+ if( ! current_user_can( 'update_plugins' ) ) {
340
+ wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
341
+ }
342
+
343
+ global $s214_plugin_data;
344
+
345
+ $data = $s214_plugin_data[$_REQUEST['slug']];
346
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
347
+ $version_info = get_transient( $cache_key );
348
+
349
+ if( false === $version_info ) {
350
+ $api_params = array(
351
+ 'edd_action' => 'get_version',
352
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
353
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
354
+ 'slug' => $_REQUEST['slug'],
355
+ 'author' => $data['author'],
356
+ 'url' => home_url()
357
+ );
358
+
359
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
360
+
361
+ if( ! is_wp_error( $request ) ) {
362
+ $version_info = json_decode( wp_remote_retrieve_body( $request ) );
363
+ }
364
+
365
+ if( ! empty( $version_info ) && isset( $version_info->sections ) ) {
366
+ $version_info->sections = maybe_unserialize( $version_info->sections );
367
+ } else {
368
+ $version_info = false;
369
+ }
370
+
371
+ set_transient( $cache_key, $version_info, 3600 );
372
+ }
373
+
374
+ if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
375
+ echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
376
+ }
377
+
378
+
379
+ exit;
380
+ }
381
+
382
+ }
includes/libraries/s214-settings/source/modules/licensing/class.s214-license.php ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License handler for Section214
4
+ *
5
+ * @package S214\License
6
+ * @since 1.0.2
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Section214 license handler class
17
+ *
18
+ * @since 1.0.2
19
+ */
20
+ class S214_License {
21
+ private $file;
22
+ private $license;
23
+ private $item_name;
24
+ private $item_id;
25
+ private $item_shortname;
26
+ private $version;
27
+ private $author;
28
+ private $slug;
29
+ private $api_url = '';
30
+
31
+ /**
32
+ * Class constructor
33
+ *
34
+ * @param string $_file
35
+ * @param string $_slug
36
+ * @param string $_item_name
37
+ * @param string $_version
38
+ * @param string $_author
39
+ * @param string $_api_url
40
+ */
41
+ function __construct( $_file, $_slug, $_item, $_version, $_author, $_api_url = null ) {
42
+
43
+ $this->file = $_file;
44
+
45
+ if( is_numeric( $_item ) ) {
46
+ $this->item_id = absint( $_item );
47
+ } else {
48
+ $this->item_name = $_item;
49
+ }
50
+
51
+ $this->item_shortname = preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
52
+ $this->item_slug = $_slug;
53
+
54
+ $options = get_option( $this->item_shortname . '_settings', '' );
55
+
56
+ $this->version = $_version;
57
+ $this->license = ( isset( $options['license_key'] ) ? trim( $options['license_key'] ) : '' );
58
+ $this->author = $_author;
59
+ $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url;
60
+
61
+ // Setup hooks
62
+ $this->includes();
63
+ $this->hooks();
64
+ //$this->auto_updater();
65
+ }
66
+
67
+ /**
68
+ * Include the updater class
69
+ *
70
+ * @access private
71
+ * @return void
72
+ */
73
+ private function includes() {
74
+ if ( ! class_exists( 'S214_Plugin_Updater' ) ) require_once 'S214_Plugin_Updater.php';
75
+ }
76
+
77
+ /**
78
+ * Setup hooks
79
+ *
80
+ * @access private
81
+ * @return void
82
+ */
83
+ private function hooks() {
84
+
85
+ // Register settings
86
+ add_filter( $this->item_shortname . '_settings_tabs', array( $this, 'tabs' ) );
87
+ add_filter( $this->item_shortname . '_registered_settings', array( $this, 'settings' ) );
88
+
89
+ // Activate license key on settings save
90
+ add_action( 'admin_init', array( $this, 'activate_license' ) );
91
+
92
+ // Deactivate license key
93
+ add_action( 'admin_init', array( $this, 'deactivate_license' ) );
94
+
95
+ // Updater
96
+ add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
97
+
98
+ add_action( 'admin_notices', array( $this, 'notices' ) );
99
+ }
100
+
101
+ /**
102
+ * Auto updater
103
+ *
104
+ * @access private
105
+ * @return void
106
+ */
107
+ public function auto_updater() {
108
+
109
+ if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) )
110
+ return;
111
+
112
+ $args = array(
113
+ 'version' => $this->version,
114
+ 'license' => $this->license,
115
+ 'author' => $this->author
116
+ );
117
+
118
+ if( ! empty( $this->item_id ) ) {
119
+ $args['item_id'] = $this->item_id;
120
+ } else {
121
+ $args['item_name'] = $this->item_name;
122
+ }
123
+
124
+ // Setup the updater
125
+ $edd_updater = new S214_Plugin_Updater(
126
+ $this->api_url,
127
+ $this->file,
128
+ $args
129
+ );
130
+ }
131
+
132
+
133
+ /**
134
+ * Add license tab to settings
135
+ *
136
+ * @access public
137
+ * @param array $tabs
138
+ * @return array $tabs
139
+ */
140
+ public function tabs( $tabs ) {
141
+ $tabs['license'] = __( 'Licensing', 's214-settings' );
142
+
143
+ return $tabs;
144
+ }
145
+
146
+
147
+ /**
148
+ * Add license field to settings
149
+ *
150
+ * @access public
151
+ * @param array $settings
152
+ * @return array
153
+ */
154
+ public function settings( $settings ) {
155
+ $license_settings = array(
156
+ 'license' => array(
157
+ array(
158
+ 'id' => $this->item_shortname . '_license_key',
159
+ 'name' => sprintf( __( '%1$s License Key', 's214-settings' ), $this->item_name ),
160
+ 'desc' => __( 'Please enter your license key to enable automatic updates and support.', 's214-settings' ),
161
+ 'type' => 'license_key',
162
+ 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
163
+ 'size' => 'regular'
164
+ )
165
+ )
166
+ );
167
+
168
+ return array_merge( $settings, $license_settings );
169
+ }
170
+
171
+
172
+ /**
173
+ * Activate the license key
174
+ *
175
+ * @access public
176
+ * @return void
177
+ */
178
+ public function activate_license() {
179
+
180
+ if ( ! isset( $_POST[$this->item_shortname . '_settings'] ) ) {
181
+ return;
182
+ }
183
+
184
+ if ( ! isset( $_POST[$this->item_shortname . '_settings'][ $this->item_shortname . '_license_key'] ) ) {
185
+ return;
186
+ }
187
+
188
+ foreach( $_POST as $key => $value ) {
189
+ if( false !== strpos( $key, 'license_key_deactivate' ) ) {
190
+ // Don't activate a key when deactivating a different key
191
+ return;
192
+ }
193
+ }
194
+
195
+ if( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
196
+
197
+ wp_die( __( 'Nonce verification failed', 's214-settings' ), __( 'Error', 's214-settings' ), array( 'response' => 403 ) );
198
+
199
+ }
200
+
201
+ if( ! current_user_can( 'manage_options' ) ) {
202
+ return;
203
+ }
204
+
205
+ if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) {
206
+ return;
207
+ }
208
+
209
+ $license = sanitize_text_field( $_POST[$this->item_shortname . '_settings'][ $this->item_shortname . '_license_key'] );
210
+
211
+ if( empty( $license ) ) {
212
+ return;
213
+ }
214
+
215
+ // Data to send to the API
216
+ $api_params = array(
217
+ 'edd_action' => 'activate_license',
218
+ 'license' => $license,
219
+ 'item_name' => urlencode( $this->item_name ),
220
+ 'url' => home_url()
221
+ );
222
+
223
+ // Call the API
224
+ $response = wp_remote_post(
225
+ $this->api_url,
226
+ array(
227
+ 'timeout' => 15,
228
+ 'sslverify' => false,
229
+ 'body' => $api_params
230
+ )
231
+ );
232
+
233
+ // Make sure there are no errors
234
+ if ( is_wp_error( $response ) ) {
235
+ return;
236
+ }
237
+
238
+ // Tell WordPress to look for updates
239
+ set_site_transient( 'update_plugins', null );
240
+
241
+ // Decode license data
242
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
243
+
244
+ update_option( $this->item_shortname . '_license_active', $license_data->license );
245
+
246
+ if( ! (bool) $license_data->success ) {
247
+ set_transient( $this->item_shortname . '_license_error', $license_data, 1000 );
248
+ } else {
249
+ delete_transient( $this->item_shortname . '_license_error' );
250
+ }
251
+ }
252
+
253
+
254
+ /**
255
+ * Deactivate the license key
256
+ *
257
+ * @access public
258
+ * @return void
259
+ */
260
+ public function deactivate_license() {
261
+
262
+ if ( ! isset( $_POST[$this->item_shortname . '_settings'] ) )
263
+ return;
264
+
265
+ if ( ! isset( $_POST[$this->item_shortname . '_settings'][ $this->item_shortname . '_license_key'] ) )
266
+ return;
267
+
268
+ if( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
269
+
270
+ wp_die( __( 'Nonce verification failed', 's214-settings' ), __( 'Error', 's214-settings' ), array( 'response' => 403 ) );
271
+
272
+ }
273
+
274
+ if( ! current_user_can( 'manage_options' ) ) {
275
+ return;
276
+ }
277
+
278
+ // Run on deactivate button press
279
+ if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate'] ) ) {
280
+
281
+ $license = sanitize_text_field( $_POST[$this->item_shortname . '_settings'][ $this->item_shortname . '_license_key'] );
282
+
283
+ if( empty( $license ) ) {
284
+ return;
285
+ }
286
+
287
+ // Data to send to the API
288
+ $api_params = array(
289
+ 'edd_action' => 'deactivate_license',
290
+ 'license' => $license,
291
+ 'item_name' => urlencode( $this->item_name ),
292
+ 'url' => home_url()
293
+ );
294
+
295
+ // Call the API
296
+ $response = wp_remote_post(
297
+ $this->api_url,
298
+ array(
299
+ 'timeout' => 15,
300
+ 'sslverify' => false,
301
+ 'body' => $api_params
302
+ )
303
+ );
304
+
305
+ // Make sure there are no errors
306
+ if ( is_wp_error( $response ) ) {
307
+ return;
308
+ }
309
+
310
+ // Decode the license data
311
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
312
+
313
+ delete_option( $this->item_shortname . '_license_active' );
314
+
315
+ if( ! (bool) $license_data->success ) {
316
+ set_transient( $this->item_shortname . '_license_error', $license_data, 1000 );
317
+ } else {
318
+ delete_transient( $this->item_shortname . '_license_error' );
319
+ }
320
+ }
321
+ }
322
+
323
+
324
+ /**
325
+ * Admin notices for errors
326
+ *
327
+ * @access public
328
+ * @return void
329
+ */
330
+ public function notices() {
331
+
332
+ if( ! isset( $_GET['page'] ) || $this->item_slug . '-settings' !== $_GET['page'] ) {
333
+ return;
334
+ }
335
+
336
+ if( ! isset( $_GET['tab'] ) || 'license' !== $_GET['tab'] ) {
337
+ return;
338
+ }
339
+
340
+ $license_error = get_transient( $this->item_shortname . '_license_error' );
341
+
342
+ if( false === $license_error ) {
343
+ return;
344
+ }
345
+
346
+ if( ! empty( $license_error->error ) ) {
347
+
348
+ switch( $license_error->error ) {
349
+
350
+ case 'item_name_mismatch' :
351
+
352
+ $message = __( 'This license does not belong to the product you have entered it for.', 's214-settings' );
353
+ break;
354
+
355
+ case 'no_activations_left' :
356
+
357
+ $message = __( 'This license does not have any activations left', 's214-settings' );
358
+ break;
359
+
360
+ case 'expired' :
361
+
362
+ $message = __( 'This license key is expired. Please renew it.', 's214-settings' );
363
+ break;
364
+
365
+ default :
366
+
367
+ $message = sprintf( __( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 's214-settings' ), $license_error->error );
368
+ break;
369
+
370
+ }
371
+
372
+ }
373
+
374
+ if( ! empty( $message ) ) {
375
+
376
+ echo '<div class="error">';
377
+ echo '<p>' . $message . '</p>';
378
+ echo '</div>';
379
+
380
+ }
381
+
382
+ delete_transient( $this->item_shortname . '_license_error' );
383
+
384
+ }
385
+ }
includes/libraries/s214-settings/source/modules/sysinfo/browser.php ADDED
@@ -0,0 +1,1103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Modified to remove var
8
+ * Chris Christoff on 12/26/2012
9
+ * Changes: Changes vars to publics
10
+ *
11
+ * Modified to work for EDD by
12
+ * Chris Christoff on 12/23/2012
13
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
14
+ *
15
+ * Modified to add formatted User Agent string for EDD System Info by
16
+ * Chris Christoff on 12/23/2012
17
+ * Changes: Split user string and add formatting so we can print a nicely
18
+ * formatted user agent string on the EDD System Info
19
+ *
20
+ * File: Browser.php
21
+ * Author: Chris Schuld (http://chrisschuld.com/)
22
+ * Last Modified: August 20th, 2010
23
+ *
24
+ * @version 1.9
25
+ * @package PegasusPHP
26
+ *
27
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
28
+ *
29
+ * This program is free software; you can redistribute it and/or
30
+ * modify it under the terms of the GNU General Public License as
31
+ * published by the Free Software Foundation; either version 2 of
32
+ * the License, or (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+ * GNU General Public License for more details at:
38
+ * http://www.gnu.org/copyleft/gpl.html
39
+ *
40
+ *
41
+ * Typical Usage:
42
+ *
43
+ * $browser = new Browser();
44
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
45
+ * echo 'You have FireFox version 2 or greater';
46
+ * }
47
+ *
48
+ * User Agents Sampled from: http://www.useragentstring.com/
49
+ *
50
+ * This implementation is based on the original work from Gary White
51
+ * http://apptools.com/phptools/browser/
52
+ *
53
+ * UPDATES:
54
+ *
55
+ * 2010-08-20 (v1.9):
56
+ * + Added MSN Explorer Browser (legacy)
57
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
58
+ * + Added the Android Platform (PLATFORM_ANDROID)
59
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
60
+ *
61
+ * 2010-04-27 (v1.8):
62
+ * + Added iPad Support
63
+ *
64
+ * 2010-03-07 (v1.7):
65
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
66
+ * + Almost allof Gary's original code has been replaced
67
+ * + Large PHPUNIT testing environment created to validate new releases and additions
68
+ * + Added FreeBSD Platform
69
+ * + Added OpenBSD Platform
70
+ * + Added NetBSD Platform
71
+ * + Added SunOS Platform
72
+ * + Added OpenSolaris Platform
73
+ * + Added support of the Iceweazel Browser
74
+ * + Added isChromeFrame() call to check if chromeframe is in use
75
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
76
+ * + Added the __toString() method (Thanks Deano)
77
+ *
78
+ * 2009-11-15:
79
+ * + Updated the checkes for Firefox
80
+ * + Added the NOKIA platform
81
+ * + Added Checks for the NOKIA brower(s)
82
+ *
83
+ * 2009-11-08:
84
+ * + PHP 5.3 Support
85
+ * + Added support for BlackBerry OS and BlackBerry browser
86
+ * + Added support for the Opera Mini browser
87
+ * + Added additional documenation
88
+ * + Added support for isRobot() and isMobile()
89
+ * + Added support for Opera version 10
90
+ * + Added support for deprecated Netscape Navigator version 9
91
+ * + Added support for IceCat
92
+ * + Added support for Shiretoko
93
+ *
94
+ * 2010-04-27 (v1.8):
95
+ * + Added iPad Support
96
+ *
97
+ * 2009-08-18:
98
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
99
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
100
+ *
101
+ * 2009-04-27:
102
+ * + Updated the IE check to remove a typo and bug (thanks John)
103
+ *
104
+ * 2009-04-22:
105
+ * + Added detection for GoogleBot
106
+ * + Added detection for the W3C Validator.
107
+ * + Added detection for Yahoo! Slurp
108
+ *
109
+ * 2009-03-14:
110
+ * + Added detection for iPods.
111
+ * + Added Platform detection for iPhones
112
+ * + Added Platform detection for iPods
113
+ *
114
+ * 2009-02-16: (Rick Hale)
115
+ * + Added version detection for Android phones.
116
+ *
117
+ * 2008-12-09:
118
+ * + Removed unused constant
119
+ *
120
+ * 2008-11-07:
121
+ * + Added Google's Chrome to the detection list
122
+ * + Added isBrowser(string) to the list of functions special thanks to
123
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
124
+ *
125
+ *
126
+ * Gary White noted: "Since browser detection is so unreliable, I am
127
+ * no longer maintaining this script. You are free to use and or
128
+ * modify/update it as you want, however the author assumes no
129
+ * responsibility for the accuracy of the detected values."
130
+ *
131
+ * Anyone experienced with Gary's script might be interested in these notes:
132
+ *
133
+ * Added class constants
134
+ * Added detection and version detection for Google's Chrome
135
+ * Updated the version detection for Amaya
136
+ * Updated the version detection for Firefox
137
+ * Updated the version detection for Lynx
138
+ * Updated the version detection for WebTV
139
+ * Updated the version detection for NetPositive
140
+ * Updated the version detection for IE
141
+ * Updated the version detection for OmniWeb
142
+ * Updated the version detection for iCab
143
+ * Updated the version detection for Safari
144
+ * Updated Safari to remove mobile devices (iPhone)
145
+ * Added detection for iPhone
146
+ * Added detection for robots
147
+ * Added detection for mobile devices
148
+ * Added detection for BlackBerry
149
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
150
+ *
151
+ */
152
+
153
+ class Browser {
154
+ public $_agent = '';
155
+ public $_browser_name = '';
156
+ public $_version = '';
157
+ public $_platform = '';
158
+ public $_os = '';
159
+ public $_is_aol = false;
160
+ public $_is_mobile = false;
161
+ public $_is_robot = false;
162
+ public $_aol_version = '';
163
+
164
+ public $BROWSER_UNKNOWN = 'unknown';
165
+ public $VERSION_UNKNOWN = 'unknown';
166
+
167
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
168
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
169
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
170
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
171
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
172
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
173
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
174
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
175
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
176
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
177
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
178
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
179
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
180
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
181
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
182
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
183
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
184
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
185
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
186
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
187
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
188
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
189
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
190
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
191
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
192
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
193
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
194
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
195
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
196
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
197
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
198
+
199
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
200
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
201
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
202
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
203
+
204
+ public $PLATFORM_UNKNOWN = 'unknown';
205
+ public $PLATFORM_WINDOWS = 'Windows';
206
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
207
+ public $PLATFORM_APPLE = 'Apple';
208
+ public $PLATFORM_LINUX = 'Linux';
209
+ public $PLATFORM_OS2 = 'OS/2';
210
+ public $PLATFORM_BEOS = 'BeOS';
211
+ public $PLATFORM_IPHONE = 'iPhone';
212
+ public $PLATFORM_IPOD = 'iPod';
213
+ public $PLATFORM_IPAD = 'iPad';
214
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
215
+ public $PLATFORM_NOKIA = 'Nokia';
216
+ public $PLATFORM_FREEBSD = 'FreeBSD';
217
+ public $PLATFORM_OPENBSD = 'OpenBSD';
218
+ public $PLATFORM_NETBSD = 'NetBSD';
219
+ public $PLATFORM_SUNOS = 'SunOS';
220
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
221
+ public $PLATFORM_ANDROID = 'Android';
222
+
223
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
224
+
225
+ function __construct( $useragent="" ) {
226
+ $this->reset();
227
+ if ( $useragent != "" ) {
228
+ $this->setUserAgent( $useragent );
229
+ } else {
230
+ $this->determine();
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Reset all properties
236
+ */
237
+ function reset() {
238
+ $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "";
239
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
240
+ $this->_version = $this->VERSION_UNKNOWN;
241
+ $this->_platform = $this->PLATFORM_UNKNOWN;
242
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
243
+ $this->_is_aol = false;
244
+ $this->_is_mobile = false;
245
+ $this->_is_robot = false;
246
+ $this->_aol_version = $this->VERSION_UNKNOWN;
247
+ }
248
+
249
+ /**
250
+ * Check to see if the specific browser is valid
251
+ *
252
+ * @param string $browserName
253
+ * @return True if the browser is the specified browser
254
+ */
255
+ function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
256
+
257
+ /**
258
+ * The name of the browser. All return types are from the class contants
259
+ *
260
+ * @return string Name of the browser
261
+ */
262
+ function getBrowser() { return $this->_browser_name; }
263
+ /**
264
+ * Set the name of the browser
265
+ *
266
+ * @param unknown $browser The name of the Browser
267
+ */
268
+ function setBrowser( $browser ) { return $this->_browser_name = $browser; }
269
+ /**
270
+ * The name of the platform. All return types are from the class contants
271
+ *
272
+ * @return string Name of the browser
273
+ */
274
+ function getPlatform() { return $this->_platform; }
275
+ /**
276
+ * Set the name of the platform
277
+ *
278
+ * @param unknown $platform The name of the Platform
279
+ */
280
+ function setPlatform( $platform ) { return $this->_platform = $platform; }
281
+ /**
282
+ * The version of the browser.
283
+ *
284
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
285
+ */
286
+ function getVersion() { return $this->_version; }
287
+ /**
288
+ * Set the version of the browser
289
+ *
290
+ * @param unknown $version The version of the Browser
291
+ */
292
+ function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
293
+ /**
294
+ * The version of AOL.
295
+ *
296
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
297
+ */
298
+ function getAolVersion() { return $this->_aol_version; }
299
+ /**
300
+ * Set the version of AOL
301
+ *
302
+ * @param unknown $version The version of AOL
303
+ */
304
+ function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
305
+ /**
306
+ * Is the browser from AOL?
307
+ *
308
+ * @return boolean True if the browser is from AOL otherwise false
309
+ */
310
+ function isAol() { return $this->_is_aol; }
311
+ /**
312
+ * Is the browser from a mobile device?
313
+ *
314
+ * @return boolean True if the browser is from a mobile device otherwise false
315
+ */
316
+ function isMobile() { return $this->_is_mobile; }
317
+ /**
318
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
319
+ *
320
+ * @return boolean True if the browser is from a robot otherwise false
321
+ */
322
+ function isRobot() { return $this->_is_robot; }
323
+ /**
324
+ * Set the browser to be from AOL
325
+ *
326
+ * @param unknown $isAol
327
+ */
328
+ function setAol( $isAol ) { $this->_is_aol = $isAol; }
329
+ /**
330
+ * Set the Browser to be mobile
331
+ *
332
+ * @param boolean $value is the browser a mobile brower or not
333
+ */
334
+ function setMobile( $value=true ) { $this->_is_mobile = $value; }
335
+ /**
336
+ * Set the Browser to be a robot
337
+ *
338
+ * @param boolean $value is the browser a robot or not
339
+ */
340
+ function setRobot( $value=true ) { $this->_is_robot = $value; }
341
+ /**
342
+ * Get the user agent value in use to determine the browser
343
+ *
344
+ * @return string The user agent from the HTTP header
345
+ */
346
+ function getUserAgent() { return $this->_agent; }
347
+ /**
348
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
349
+ *
350
+ * @param unknown $agent_string The value for the User Agent
351
+ */
352
+ function setUserAgent( $agent_string ) {
353
+ $this->reset();
354
+ $this->_agent = $agent_string;
355
+ $this->determine();
356
+ }
357
+ /**
358
+ * Used to determine if the browser is actually "chromeframe"
359
+ *
360
+ * @since 1.7
361
+ * @return boolean True if the browser is using chromeframe
362
+ */
363
+ function isChromeFrame() {
364
+ return strpos( $this->_agent, "chromeframe" ) !== false;
365
+ }
366
+ /**
367
+ * Returns a formatted string with a summary of the details of the browser.
368
+ *
369
+ * @return string formatted string with a summary of the browser
370
+ */
371
+ function __toString() {
372
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
373
+ $UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string
374
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
375
+ $towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent
376
+ // To the whole string minus the part we printed off. IE
377
+ // User Agent: thefirst32charactersfromUAline1
378
+ // the rest of it is now stored in
379
+ // $text2 to be printed off
380
+ // But we need to add spaces before each line that is split other than line 1
381
+ $space = '';
382
+ for ( $i = 0; $i < 25; $i++ ) {
383
+ $space .= ' ';
384
+ }
385
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
386
+ $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
387
+ return "Platform: {$this->getPlatform()} \n".
388
+ "Browser Name: {$this->getBrowser()} \n" .
389
+ "Browser Version: {$this->getVersion()} \n" .
390
+ "User Agent String: $UAline1 \n\t\t\t " .
391
+ "$wordwrapped";
392
+ }
393
+ /**
394
+ * Protected routine to calculate and determine what the browser is in use (including platform)
395
+ */
396
+ function determine() {
397
+ $this->checkPlatform();
398
+ $this->checkBrowsers();
399
+ $this->checkForAol();
400
+ }
401
+ /**
402
+ * Protected routine to determine the browser type
403
+ *
404
+ * @return boolean True if the browser was detected otherwise false
405
+ */
406
+ function checkBrowsers() {
407
+ return (
408
+ // Well-known, well-used
409
+ // Special Notes:
410
+ // (1) Opera must be checked before FireFox due to the odd
411
+ // user agents used in some older versions of Opera
412
+ // (2) WebTV is strapped onto Internet Explorer so we must
413
+ // check for WebTV before IE
414
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
415
+ // tested before Firefox is tested
416
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
417
+ // before Safari
418
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
419
+ // before FireFox are necessary
420
+ $this->checkBrowserWebTv() ||
421
+ $this->checkBrowserInternetExplorer() ||
422
+ $this->checkBrowserOpera() ||
423
+ $this->checkBrowserGaleon() ||
424
+ $this->checkBrowserNetscapeNavigator9Plus() ||
425
+ $this->checkBrowserFirefox() ||
426
+ $this->checkBrowserChrome() ||
427
+ $this->checkBrowserOmniWeb() ||
428
+
429
+ // Common mobile
430
+ $this->checkBrowserAndroid() ||
431
+ $this->checkBrowseriPad() ||
432
+ $this->checkBrowseriPod() ||
433
+ $this->checkBrowseriPhone() ||
434
+ $this->checkBrowserBlackBerry() ||
435
+ $this->checkBrowserNokia() ||
436
+
437
+ // Common bots
438
+ $this->checkBrowserGoogleBot() ||
439
+ $this->checkBrowserMSNBot() ||
440
+ $this->checkBrowserSlurp() ||
441
+
442
+ // WebKit base check (post mobile and others)
443
+ $this->checkBrowserSafari() ||
444
+
445
+ // Everyone else
446
+ $this->checkBrowserNetPositive() ||
447
+ $this->checkBrowserFirebird() ||
448
+ $this->checkBrowserKonqueror() ||
449
+ $this->checkBrowserIcab() ||
450
+ $this->checkBrowserPhoenix() ||
451
+ $this->checkBrowserAmaya() ||
452
+ $this->checkBrowserLynx() ||
453
+
454
+ $this->checkBrowserShiretoko() ||
455
+ $this->checkBrowserIceCat() ||
456
+ $this->checkBrowserW3CValidator() ||
457
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
458
+ );
459
+ }
460
+
461
+ /**
462
+ * Determine if the user is using a BlackBerry (last updated 1.7)
463
+ *
464
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
465
+ */
466
+ function checkBrowserBlackBerry() {
467
+ if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
468
+ $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) );
469
+ $aversion = explode( ' ', $aresult[1] );
470
+ $this->setVersion( $aversion[0] );
471
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
472
+ $this->setMobile( true );
473
+ return true;
474
+ }
475
+ return false;
476
+ }
477
+
478
+ /**
479
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
480
+ *
481
+ * @return boolean True if the browser is from AOL otherwise false
482
+ */
483
+ function checkForAol() {
484
+ $this->setAol( false );
485
+ $this->setAolVersion( $this->VERSION_UNKNOWN );
486
+
487
+ if ( stripos( $this->_agent, 'aol' ) !== false ) {
488
+ $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
489
+ $this->setAol( true );
490
+ $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
491
+ return true;
492
+ }
493
+ return false;
494
+ }
495
+
496
+ /**
497
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
498
+ *
499
+ * @return boolean True if the browser is the GoogletBot otherwise false
500
+ */
501
+ function checkBrowserGoogleBot() {
502
+ if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
503
+ $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
504
+ $aversion = explode( ' ', $aresult[1] );
505
+ $this->setVersion( str_replace( ';', '', $aversion[0] ) );
506
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
507
+ $this->setRobot( true );
508
+ return true;
509
+ }
510
+ return false;
511
+ }
512
+
513
+ /**
514
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
515
+ *
516
+ * @return boolean True if the browser is the MSNBot otherwise false
517
+ */
518
+ function checkBrowserMSNBot() {
519
+ if ( stripos( $this->_agent, "msnbot" ) !== false ) {
520
+ $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) );
521
+ $aversion = explode( " ", $aresult[1] );
522
+ $this->setVersion( str_replace( ";", "", $aversion[0] ) );
523
+ $this->_browser_name = $this->BROWSER_MSNBOT;
524
+ $this->setRobot( true );
525
+ return true;
526
+ }
527
+ return false;
528
+ }
529
+
530
+ /**
531
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
532
+ *
533
+ * @return boolean True if the browser is the W3C Validator otherwise false
534
+ */
535
+ function checkBrowserW3CValidator() {
536
+ if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
537
+ $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
538
+ $aversion = explode( ' ', $aresult[1] );
539
+ $this->setVersion( $aversion[0] );
540
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
541
+ return true;
542
+ } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
543
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
544
+ $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent );
545
+ $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
546
+ $aversion = explode( ' ', $aresult[1] );
547
+ $this->setVersion( $aversion[0] );
548
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
549
+ return true;
550
+ }
551
+ return false;
552
+ }
553
+
554
+ /**
555
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
556
+ *
557
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
558
+ */
559
+ function checkBrowserSlurp() {
560
+ if ( stripos( $this->_agent, 'slurp' ) !== false ) {
561
+ $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
562
+ $aversion = explode( ' ', $aresult[1] );
563
+ $this->setVersion( $aversion[0] );
564
+ $this->_browser_name = $this->BROWSER_SLURP;
565
+ $this->setRobot( true );
566
+ $this->setMobile( false );
567
+ return true;
568
+ }
569
+ return false;
570
+ }
571
+
572
+ /**
573
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
574
+ *
575
+ * @return boolean True if the browser is Internet Explorer otherwise false
576
+ */
577
+ function checkBrowserInternetExplorer() {
578
+
579
+ // Test for v1 - v1.5 IE
580
+ if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
581
+ $this->setBrowser( $this->BROWSER_IE );
582
+ $this->setVersion( '1.0' );
583
+ $aresult = stristr( $this->_agent, '/' );
584
+ if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
585
+ $this->setVersion( '1.5' );
586
+ }
587
+ return true;
588
+ }
589
+ // Test for versions > 1.5
590
+ else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
591
+ // See if the browser is the odd MSN Explorer
592
+ if ( stripos( $this->_agent, 'msnb' ) !== false ) {
593
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
594
+ $this->setBrowser( $this->BROWSER_MSN );
595
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
596
+ return true;
597
+ }
598
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
599
+ $this->setBrowser( $this->BROWSER_IE );
600
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
601
+ return true;
602
+ }
603
+ // Test for Pocket IE
604
+ else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
605
+ $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
606
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
607
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
608
+ $this->setMobile( true );
609
+
610
+ if ( stripos( $this->_agent, 'mspie' ) !== false ) {
611
+ $this->setVersion( $aresult[1] );
612
+ } else {
613
+ $aversion = explode( '/', $this->_agent );
614
+ $this->setVersion( $aversion[1] );
615
+ }
616
+ return true;
617
+ }
618
+ return false;
619
+ }
620
+
621
+ /**
622
+ * Determine if the browser is Opera or not (last updated 1.7)
623
+ *
624
+ * @return boolean True if the browser is Opera otherwise false
625
+ */
626
+ function checkBrowserOpera() {
627
+ if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
628
+ $resultant = stristr( $this->_agent, 'opera mini' );
629
+ if ( preg_match( '/\//', $resultant ) ) {
630
+ $aresult = explode( '/', $resultant );
631
+ $aversion = explode( ' ', $aresult[1] );
632
+ $this->setVersion( $aversion[0] );
633
+ } else {
634
+ $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
635
+ $this->setVersion( $aversion[1] );
636
+ }
637
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
638
+ $this->setMobile( true );
639
+ return true;
640
+ } else if ( stripos( $this->_agent, 'opera' ) !== false ) {
641
+ $resultant = stristr( $this->_agent, 'opera' );
642
+ if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
643
+ $this->setVersion( $matches[1] );
644
+ } else if ( preg_match( '/\//', $resultant ) ) {
645
+ $aresult = explode( '/', str_replace( "(", " ", $resultant ) );
646
+ $aversion = explode( ' ', $aresult[1] );
647
+ $this->setVersion( $aversion[0] );
648
+ } else {
649
+ $aversion = explode( ' ', stristr( $resultant, 'opera' ) );
650
+ $this->setVersion( isset( $aversion[1] )?$aversion[1]:"" );
651
+ }
652
+ $this->_browser_name = $this->BROWSER_OPERA;
653
+ return true;
654
+ }
655
+ return false;
656
+ }
657
+
658
+ /**
659
+ * Determine if the browser is Chrome or not (last updated 1.7)
660
+ *
661
+ * @return boolean True if the browser is Chrome otherwise false
662
+ */
663
+ function checkBrowserChrome() {
664
+ if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
665
+ $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
666
+ $aversion = explode( ' ', $aresult[1] );
667
+ $this->setVersion( $aversion[0] );
668
+ $this->setBrowser( $this->BROWSER_CHROME );
669
+ return true;
670
+ }
671
+ return false;
672
+ }
673
+
674
+
675
+ /**
676
+ * Determine if the browser is WebTv or not (last updated 1.7)
677
+ *
678
+ * @return boolean True if the browser is WebTv otherwise false
679
+ */
680
+ function checkBrowserWebTv() {
681
+ if ( stripos( $this->_agent, 'webtv' ) !== false ) {
682
+ $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
683
+ $aversion = explode( ' ', $aresult[1] );
684
+ $this->setVersion( $aversion[0] );
685
+ $this->setBrowser( $this->BROWSER_WEBTV );
686
+ return true;
687
+ }
688
+ return false;
689
+ }
690
+
691
+ /**
692
+ * Determine if the browser is NetPositive or not (last updated 1.7)
693
+ *
694
+ * @return boolean True if the browser is NetPositive otherwise false
695
+ */
696
+ function checkBrowserNetPositive() {
697
+ if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
698
+ $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
699
+ $aversion = explode( ' ', $aresult[1] );
700
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
701
+ $this->setBrowser( $this->BROWSER_NETPOSITIVE );
702
+ return true;
703
+ }
704
+ return false;
705
+ }
706
+
707
+ /**
708
+ * Determine if the browser is Galeon or not (last updated 1.7)
709
+ *
710
+ * @return boolean True if the browser is Galeon otherwise false
711
+ */
712
+ function checkBrowserGaleon() {
713
+ if ( stripos( $this->_agent, 'galeon' ) !== false ) {
714
+ $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
715
+ $aversion = explode( '/', $aresult[0] );
716
+ $this->setVersion( $aversion[1] );
717
+ $this->setBrowser( $this->BROWSER_GALEON );
718
+ return true;
719
+ }
720
+ return false;
721
+ }
722
+
723
+ /**
724
+ * Determine if the browser is Konqueror or not (last updated 1.7)
725
+ *
726
+ * @return boolean True if the browser is Konqueror otherwise false
727
+ */
728
+ function checkBrowserKonqueror() {
729
+ if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
730
+ $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
731
+ $aversion = explode( '/', $aresult[0] );
732
+ $this->setVersion( $aversion[1] );
733
+ $this->setBrowser( $this->BROWSER_KONQUEROR );
734
+ return true;
735
+ }
736
+ return false;
737
+ }
738
+
739
+ /**
740
+ * Determine if the browser is iCab or not (last updated 1.7)
741
+ *
742
+ * @return boolean True if the browser is iCab otherwise false
743
+ */
744
+ function checkBrowserIcab() {
745
+ if ( stripos( $this->_agent, 'icab' ) !== false ) {
746
+ $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
747
+ $this->setVersion( $aversion[1] );
748
+ $this->setBrowser( $this->BROWSER_ICAB );
749
+ return true;
750
+ }
751
+ return false;
752
+ }
753
+
754
+ /**
755
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
756
+ *
757
+ * @return boolean True if the browser is OmniWeb otherwise false
758
+ */
759
+ function checkBrowserOmniWeb() {
760
+ if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
761
+ $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
762
+ $aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" );
763
+ $this->setVersion( $aversion[0] );
764
+ $this->setBrowser( $this->BROWSER_OMNIWEB );
765
+ return true;
766
+ }
767
+ return false;
768
+ }
769
+
770
+ /**
771
+ * Determine if the browser is Phoenix or not (last updated 1.7)
772
+ *
773
+ * @return boolean True if the browser is Phoenix otherwise false
774
+ */
775
+ function checkBrowserPhoenix() {
776
+ if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
777
+ $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
778
+ $this->setVersion( $aversion[1] );
779
+ $this->setBrowser( $this->BROWSER_PHOENIX );
780
+ return true;
781
+ }
782
+ return false;
783
+ }
784
+
785
+ /**
786
+ * Determine if the browser is Firebird or not (last updated 1.7)
787
+ *
788
+ * @return boolean True if the browser is Firebird otherwise false
789
+ */
790
+ function checkBrowserFirebird() {
791
+ if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
792
+ $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
793
+ $this->setVersion( $aversion[1] );
794
+ $this->setBrowser( $this->BROWSER_FIREBIRD );
795
+ return true;
796
+ }
797
+ return false;
798
+ }
799
+
800
+ /**
801
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
802
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
803
+ *
804
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
805
+ */
806
+ function checkBrowserNetscapeNavigator9Plus() {
807
+ if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
808
+ $this->setVersion( $matches[1] );
809
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
810
+ return true;
811
+ } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
812
+ $this->setVersion( $matches[1] );
813
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
814
+ return true;
815
+ }
816
+ return false;
817
+ }
818
+
819
+ /**
820
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
821
+ *
822
+ * @return boolean True if the browser is Shiretoko otherwise false
823
+ */
824
+ function checkBrowserShiretoko() {
825
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
826
+ $this->setVersion( $matches[1] );
827
+ $this->setBrowser( $this->BROWSER_SHIRETOKO );
828
+ return true;
829
+ }
830
+ return false;
831
+ }
832
+
833
+ /**
834
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
835
+ *
836
+ * @return boolean True if the browser is Ice Cat otherwise false
837
+ */
838
+ function checkBrowserIceCat() {
839
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
840
+ $this->setVersion( $matches[1] );
841
+ $this->setBrowser( $this->BROWSER_ICECAT );
842
+ return true;
843
+ }
844
+ return false;
845
+ }
846
+
847
+ /**
848
+ * Determine if the browser is Nokia or not (last updated 1.7)
849
+ *
850
+ * @return boolean True if the browser is Nokia otherwise false
851
+ */
852
+ function checkBrowserNokia() {
853
+ if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) {
854
+ $this->setVersion( $matches[2] );
855
+ if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
856
+ $this->setBrowser( $this->BROWSER_NOKIA_S60 );
857
+ } else {
858
+ $this->setBrowser( $this->BROWSER_NOKIA );
859
+ }
860
+ $this->setMobile( true );
861
+ return true;
862
+ }
863
+ return false;
864
+ }
865
+
866
+ /**
867
+ * Determine if the browser is Firefox or not (last updated 1.7)
868
+ *
869
+ * @return boolean True if the browser is Firefox otherwise false
870
+ */
871
+ function checkBrowserFirefox() {
872
+ if ( stripos( $this->_agent, 'safari' ) === false ) {
873
+ if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) {
874
+ $this->setVersion( $matches[1] );
875
+ $this->setBrowser( $this->BROWSER_FIREFOX );
876
+ return true;
877
+ } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) {
878
+ $this->setVersion( "" );
879
+ $this->setBrowser( $this->BROWSER_FIREFOX );
880
+ return true;
881
+ }
882
+ }
883
+ return false;
884
+ }
885
+
886
+ /**
887
+ * Determine if the browser is Firefox or not (last updated 1.7)
888
+ *
889
+ * @return boolean True if the browser is Firefox otherwise false
890
+ */
891
+ function checkBrowserIceweasel() {
892
+ if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
893
+ $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
894
+ $aversion = explode( ' ', $aresult[1] );
895
+ $this->setVersion( $aversion[0] );
896
+ $this->setBrowser( $this->BROWSER_ICEWEASEL );
897
+ return true;
898
+ }
899
+ return false;
900
+ }
901
+ /**
902
+ * Determine if the browser is Mozilla or not (last updated 1.7)
903
+ *
904
+ * @return boolean True if the browser is Mozilla otherwise false
905
+ */
906
+ function checkBrowserMozilla() {
907
+ if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
908
+ $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
909
+ preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
910
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
911
+ $this->setBrowser( $this->BROWSER_MOZILLA );
912
+ return true;
913
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
914
+ $aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
915
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
916
+ $this->setBrowser( $this->BROWSER_MOZILLA );
917
+ return true;
918
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
919
+ $this->setVersion( $matches[1] );
920
+ $this->setBrowser( $this->BROWSER_MOZILLA );
921
+ return true;
922
+ }
923
+ return false;
924
+ }
925
+
926
+ /**
927
+ * Determine if the browser is Lynx or not (last updated 1.7)
928
+ *
929
+ * @return boolean True if the browser is Lynx otherwise false
930
+ */
931
+ function checkBrowserLynx() {
932
+ if ( stripos( $this->_agent, 'lynx' ) !== false ) {
933
+ $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
934
+ $aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) );
935
+ $this->setVersion( $aversion[0] );
936
+ $this->setBrowser( $this->BROWSER_LYNX );
937
+ return true;
938
+ }
939
+ return false;
940
+ }
941
+
942
+ /**
943
+ * Determine if the browser is Amaya or not (last updated 1.7)
944
+ *
945
+ * @return boolean True if the browser is Amaya otherwise false
946
+ */
947
+ function checkBrowserAmaya() {
948
+ if ( stripos( $this->_agent, 'amaya' ) !== false ) {
949
+ $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
950
+ $aversion = explode( ' ', $aresult[1] );
951
+ $this->setVersion( $aversion[0] );
952
+ $this->setBrowser( $this->BROWSER_AMAYA );
953
+ return true;
954
+ }
955
+ return false;
956
+ }
957
+
958
+ /**
959
+ * Determine if the browser is Safari or not (last updated 1.7)
960
+ *
961
+ * @return boolean True if the browser is Safari otherwise false
962
+ */
963
+ function checkBrowserSafari() {
964
+ if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
965
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
966
+ if ( isset( $aresult[1] ) ) {
967
+ $aversion = explode( ' ', $aresult[1] );
968
+ $this->setVersion( $aversion[0] );
969
+ } else {
970
+ $this->setVersion( $this->VERSION_UNKNOWN );
971
+ }
972
+ $this->setBrowser( $this->BROWSER_SAFARI );
973
+ return true;
974
+ }
975
+ return false;
976
+ }
977
+
978
+ /**
979
+ * Determine if the browser is iPhone or not (last updated 1.7)
980
+ *
981
+ * @return boolean True if the browser is iPhone otherwise false
982
+ */
983
+ function checkBrowseriPhone() {
984
+ if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
985
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
986
+ if ( isset( $aresult[1] ) ) {
987
+ $aversion = explode( ' ', $aresult[1] );
988
+ $this->setVersion( $aversion[0] );
989
+ } else {
990
+ $this->setVersion( $this->VERSION_UNKNOWN );
991
+ }
992
+ $this->setMobile( true );
993
+ $this->setBrowser( $this->BROWSER_IPHONE );
994
+ return true;
995
+ }
996
+ return false;
997
+ }
998
+
999
+ /**
1000
+ * Determine if the browser is iPod or not (last updated 1.7)
1001
+ *
1002
+ * @return boolean True if the browser is iPod otherwise false
1003
+ */
1004
+ function checkBrowseriPad() {
1005
+ if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1006
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1007
+ if ( isset( $aresult[1] ) ) {
1008
+ $aversion = explode( ' ', $aresult[1] );
1009
+ $this->setVersion( $aversion[0] );
1010
+ } else {
1011
+ $this->setVersion( $this->VERSION_UNKNOWN );
1012
+ }
1013
+ $this->setMobile( true );
1014
+ $this->setBrowser( $this->BROWSER_IPAD );
1015
+ return true;
1016
+ }
1017
+ return false;
1018
+ }
1019
+
1020
+ /**
1021
+ * Determine if the browser is iPod or not (last updated 1.7)
1022
+ *
1023
+ * @return boolean True if the browser is iPod otherwise false
1024
+ */
1025
+ function checkBrowseriPod() {
1026
+ if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1027
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1028
+ if ( isset( $aresult[1] ) ) {
1029
+ $aversion = explode( ' ', $aresult[1] );
1030
+ $this->setVersion( $aversion[0] );
1031
+ } else {
1032
+ $this->setVersion( $this->VERSION_UNKNOWN );
1033
+ }
1034
+ $this->setMobile( true );
1035
+ $this->setBrowser( $this->BROWSER_IPOD );
1036
+ return true;
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ /**
1042
+ * Determine if the browser is Android or not (last updated 1.7)
1043
+ *
1044
+ * @return boolean True if the browser is Android otherwise false
1045
+ */
1046
+ function checkBrowserAndroid() {
1047
+ if ( stripos( $this->_agent, 'Android' ) !== false ) {
1048
+ $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
1049
+ if ( isset( $aresult[1] ) ) {
1050
+ $aversion = explode( ' ', $aresult[1] );
1051
+ $this->setVersion( $aversion[0] );
1052
+ } else {
1053
+ $this->setVersion( $this->VERSION_UNKNOWN );
1054
+ }
1055
+ $this->setMobile( true );
1056
+ $this->setBrowser( $this->BROWSER_ANDROID );
1057
+ return true;
1058
+ }
1059
+ return false;
1060
+ }
1061
+
1062
+ /**
1063
+ * Determine the user's platform (last updated 1.7)
1064
+ */
1065
+ function checkPlatform() {
1066
+ if ( stripos( $this->_agent, 'windows' ) !== false ) {
1067
+ $this->_platform = $this->PLATFORM_WINDOWS;
1068
+ } else if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1069
+ $this->_platform = $this->PLATFORM_IPAD;
1070
+ } else if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1071
+ $this->_platform = $this->PLATFORM_IPOD;
1072
+ } else if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1073
+ $this->_platform = $this->PLATFORM_IPHONE;
1074
+ } elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
1075
+ $this->_platform = $this->PLATFORM_APPLE;
1076
+ } elseif ( stripos( $this->_agent, 'android' ) !== false ) {
1077
+ $this->_platform = $this->PLATFORM_ANDROID;
1078
+ } elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
1079
+ $this->_platform = $this->PLATFORM_LINUX;
1080
+ } else if ( stripos( $this->_agent, 'Nokia' ) !== false ) {
1081
+ $this->_platform = $this->PLATFORM_NOKIA;
1082
+ } else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
1083
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1084
+ } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
1085
+ $this->_platform = $this->PLATFORM_FREEBSD;
1086
+ } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
1087
+ $this->_platform = $this->PLATFORM_OPENBSD;
1088
+ } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
1089
+ $this->_platform = $this->PLATFORM_NETBSD;
1090
+ } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
1091
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1092
+ } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
1093
+ $this->_platform = $this->PLATFORM_SUNOS;
1094
+ } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
1095
+ $this->_platform = $this->PLATFORM_OS2;
1096
+ } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
1097
+ $this->_platform = $this->PLATFORM_BEOS;
1098
+ } elseif ( stripos( $this->_agent, 'win' ) !== false ) {
1099
+ $this->_platform = $this->PLATFORM_WINDOWS;
1100
+ }
1101
+
1102
+ }
1103
+ }
includes/libraries/s214-settings/source/modules/sysinfo/class.s214-sysinfo.php ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System Info handler for Section214
4
+ *
5
+ * @package S214\Sysinfo
6
+ * @since 1.1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Section214 system info handler class
17
+ *
18
+ * @since 1.1.0
19
+ */
20
+ class S214_Sysinfo {
21
+
22
+
23
+ /**
24
+ * @var string $slug The plugin slug
25
+ * @since 1.1.0
26
+ */
27
+ private $slug;
28
+
29
+
30
+ /**
31
+ * @var string $func The plugin slug for names
32
+ * @since 1.1.0
33
+ */
34
+ private $func;
35
+
36
+
37
+ /**
38
+ * @var string $ver The library version
39
+ * @since 1.1.0
40
+ */
41
+ private $version;
42
+
43
+
44
+ /**
45
+ * Class constructor
46
+ *
47
+ * @access public
48
+ * @since 1.1.0
49
+ * @param string $_slug
50
+ * @param string $_func
51
+ * @return void
52
+ */
53
+ public function __construct( $_slug, $_func, $_version ) {
54
+ $this->slug = $_slug;
55
+ $this->func = $_func;
56
+ $this->version = $_version;
57
+
58
+ // Run action and filter hooks
59
+ $this->hooks();
60
+ }
61
+
62
+
63
+ /**
64
+ * Run action and filter hooks
65
+ *
66
+ * @access private
67
+ * @since 1.1.0
68
+ * @return void
69
+ */
70
+ private function hooks() {
71
+ // Process sysinfo download
72
+ add_action( $this->func . '_settings_download_system_info', array( $this, 'download_system_info' ) );
73
+ }
74
+
75
+
76
+ /**
77
+ * Get system info
78
+ *
79
+ * @access public
80
+ * @since 1.1.0
81
+ * @global object $wpdb The WordPress database object
82
+ * @return string $return The system info to display
83
+ */
84
+ public function get_system_info() {
85
+ global $wpdb;
86
+
87
+ if( ! class_exists( 'Browser' ) ) {
88
+ require_once 'browser.php';
89
+ }
90
+
91
+ $browser = new Browser();
92
+
93
+ // Get theme info
94
+ if( get_bloginfo( 'version' ) < '3.4' ) {
95
+ $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
96
+ $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
97
+ } else {
98
+ $theme_data = wp_get_theme();
99
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
100
+ }
101
+
102
+ // Try to identify the hosting provider
103
+ $host = $this->get_host();
104
+
105
+ $return = '### Begin System Info ###' . "\n\n";
106
+
107
+ // Start with the basics...
108
+ $return .= '-- Site Info' . "\n\n";
109
+ $return .= 'Site URL: ' . site_url() . "\n";
110
+ $return .= 'Home URL: ' . home_url() . "\n";
111
+ $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
112
+
113
+ $return = apply_filters( $this->func . '_sysinfo_after_site_info', $return );
114
+
115
+ // Can we determine the site's host?
116
+ if( $host ) {
117
+ $return .= "\n" . '-- Hosting Provider' . "\n\n";
118
+ $return .= 'Host: ' . $host . "\n";
119
+
120
+ $return = apply_filters( $this->func . '_sysinfo_after_host_info', $return );
121
+ }
122
+
123
+ // The local users' browser information, handled by the Browser class
124
+ $return .= "\n" . '-- User Browser' . "\n\n";
125
+ $return .= $browser;
126
+
127
+ $return = apply_filters( $this->func . '_sysinfo_after_user_browser', $return );
128
+
129
+ // WordPress configuration
130
+ $return .= "\n" . '-- WordPress Configuration' . "\n\n";
131
+ $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
132
+ $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
133
+ $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
134
+ $return .= 'Active Theme: ' . $theme . "\n";
135
+ $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
136
+
137
+ // Only show page specs if frontpage is set to 'page'
138
+ if( get_option( 'show_on_front' ) == 'page' ) {
139
+ $front_page_id = get_option( 'page_on_front' );
140
+ $blog_page_id = get_option( 'page_for_posts' );
141
+
142
+ $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
143
+ $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
144
+ }
145
+
146
+ // Make sure wp_remote_post() is working
147
+ $request['cmd'] = '_notify-validate';
148
+
149
+ $params = array(
150
+ 'sslverify' => false,
151
+ 'timeout' => 60,
152
+ 'user-agent' => 'S214-Settings/' . $this->version,
153
+ 'body' => $request
154
+ );
155
+
156
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
157
+
158
+ if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
159
+ $WP_REMOTE_POST = 'wp_remote_post() works';
160
+ } else {
161
+ $WP_REMOTE_POST = 'wp_remote_post() does not work';
162
+ }
163
+
164
+ $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
165
+ $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
166
+ $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
167
+ $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
168
+ $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
169
+
170
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_config', $return );
171
+
172
+ // Get plugins that have an update
173
+ $updates = get_plugin_updates();
174
+
175
+ // Must-use plugins
176
+ // NOTE: MU plugins can't show updates!
177
+ $muplugins = get_mu_plugins();
178
+ if( count( $muplugins > 0 ) ) {
179
+ $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
180
+
181
+ foreach( $muplugins as $plugin => $plugin_data ) {
182
+ $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
183
+ }
184
+
185
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_mu_plugins', $return );
186
+ }
187
+
188
+ // WordPress active plugins
189
+ $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
190
+
191
+ $plugins = get_plugins();
192
+ $active_plugins = get_option( 'active_plugins', array() );
193
+
194
+ foreach( $plugins as $plugin_path => $plugin ) {
195
+ if( ! in_array( $plugin_path, $active_plugins ) ) {
196
+ continue;
197
+ }
198
+
199
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
200
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
201
+ }
202
+
203
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins', $return );
204
+
205
+ // WordPress inactive plugins
206
+ $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
207
+
208
+ foreach( $plugins as $plugin_path => $plugin ) {
209
+ if( in_array( $plugin_path, $active_plugins ) ) {
210
+ continue;
211
+ }
212
+
213
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
214
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
215
+ }
216
+
217
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins_inactive', $return );
218
+
219
+ if( is_multisite() ) {
220
+ // WordPress Multisite active plugins
221
+ $return .= "\n" . '-- Network Active Plugins' . "\n\n";
222
+
223
+ $plugins = wp_get_active_network_plugins();
224
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
225
+
226
+ foreach( $plugins as $plugin_path ) {
227
+ $plugin_base = plugin_basename( $plugin_path );
228
+
229
+ if( ! array_key_exists( $plugin_base, $active_plugins ) ) {
230
+ continue;
231
+ }
232
+
233
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
234
+ $plugin = get_plugin_data( $plugin_path );
235
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
236
+ }
237
+
238
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_ms_plugins', $return );
239
+ }
240
+
241
+ // Server configuration (really just versioning)
242
+ $return .= "\n" . '-- Webserver Configuration' . "\n\n";
243
+ $return .= 'PHP Version: ' . PHP_VERSION . "\n";
244
+ $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
245
+ $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
246
+
247
+ $return = apply_filters( $this->func . '_sysinfo_after_webserver_config', $return );
248
+
249
+ // PHP configs... now we're getting to the important stuff
250
+ $return .= "\n" . '-- PHP Configuration' . "\n\n";
251
+ $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
252
+ $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
253
+ $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
254
+ $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
255
+ $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
256
+ $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
257
+ $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
258
+ $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
259
+
260
+ $return = apply_filters( $this->func . '_sysinfo_after_php_config', $return );
261
+
262
+ // PHP extensions and such
263
+ $return .= "\n" . '-- PHP Extensions' . "\n\n";
264
+ $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
265
+ $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
266
+ $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
267
+ $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
268
+
269
+ $return = apply_filters( $this->func . '_sysinfo_after_php_ext', $return );
270
+
271
+ $return .= "\n" . '### End System Info ###';
272
+
273
+ return $return;
274
+ }
275
+
276
+
277
+ /**
278
+ * Generates a System Info download file
279
+ *
280
+ * @param public
281
+ * @since 1.1.0
282
+ * @return void
283
+ */
284
+ public function download_system_info() {
285
+ nocache_headers();
286
+
287
+ header( 'Content-Type: text/plain' );
288
+ header( 'Content-Disposition: attachment; filename="' . $this->slug . '-system-info.txt"' );
289
+
290
+ echo wp_strip_all_tags( $this->get_system_info() );
291
+ die();
292
+ }
293
+
294
+
295
+ /**
296
+ * Get AJAX URL
297
+ *
298
+ * @access public
299
+ * @since 1.1.0
300
+ * @return string URL to the AJAX file to call during AJAX requests.
301
+ */
302
+ function get_ajax_url() {
303
+ $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
304
+
305
+ $current_url = $this->get_current_page_url();
306
+ $ajax_url = admin_url( 'admin-ajax.php', $scheme );
307
+
308
+ if( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
309
+ $ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
310
+ }
311
+
312
+ return apply_filters( $this->func . '_ajax_url', $ajax_url );
313
+ }
314
+
315
+
316
+ /**
317
+ * Get the current page URL
318
+ *
319
+ * @access public
320
+ * @since 1.1.0
321
+ * @param bool $nocache If we should bust cache on the returned URL
322
+ * @return string $page_url Current page URL
323
+ */
324
+ function get_current_page_url( $nocache = false ) {
325
+ global $wp;
326
+
327
+ if( get_option( 'permalink_structure' ) ) {
328
+ $base = trailingslashit( home_url( $wp->request ) );
329
+ } else {
330
+ $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
331
+ $base = remove_query_arg( array( 'post_type', 'name' ), $base );
332
+ }
333
+
334
+ $scheme = is_ssl() ? 'https' : 'http';
335
+ $uri = set_url_scheme( $base, $scheme );
336
+
337
+ if( is_front_page() ) {
338
+ $uri = home_url( '/' );
339
+ }
340
+
341
+ $uri = apply_filters( $this->func . '_get_current_page_url', $uri );
342
+
343
+ if ( $nocache ) {
344
+ $uri = $this->add_cache_busting( $uri );
345
+ }
346
+
347
+ return $uri;
348
+ }
349
+
350
+
351
+ /**
352
+ * Adds the 'nocache' parameter to the provided URL
353
+ *
354
+ * @access public
355
+ * @since 1.1.0
356
+ * @param string $url The URL being requested
357
+ * @return string The URL with cache busting added or not
358
+ */
359
+ function add_cache_busting( $url = '' ) {
360
+ if( $this->is_caching_plugin_active() ) {
361
+ $url = add_query_arg( 'nocache', 'true', $url );
362
+ }
363
+
364
+ return $url;
365
+ }
366
+
367
+
368
+ /**
369
+ * Checks if a caching plugin is active
370
+ *
371
+ * @access public
372
+ * @since 1.1.0
373
+ * @return bool $caching True if caching plugin is enabled, false otherwise
374
+ */
375
+ function is_caching_plugin_active() {
376
+ $caching = ( function_exists( 'wpsupercache_site_admin' ) || defined( 'W3TC' ) || function_exists( 'rocket_init' ) );
377
+ return apply_filters( $this->func . '_is_caching_plugin_active', $caching );
378
+ }
379
+
380
+
381
+ /**
382
+ * Get user host
383
+ *
384
+ * @access public
385
+ * @since 1.1.0
386
+ * @return mixed string $host if detected, fallback data otherwise
387
+ */
388
+ function get_host() {
389
+ if( defined( 'WPE_APIKEY' ) ) {
390
+ $host = 'WP Engine';
391
+ } elseif( defined( 'PAGELYBIN' ) ) {
392
+ $host = 'Pagely';
393
+ } elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
394
+ $host = 'ICDSoft';
395
+ } elseif( DB_HOST == 'mysqlv5' ) {
396
+ $host = 'NetworkSolutions';
397
+ } elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
398
+ $host = 'iPage';
399
+ } elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
400
+ $host = 'IPower';
401
+ } elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
402
+ $host = 'MediaTemple Grid';
403
+ } elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
404
+ $host = 'pair Networks';
405
+ } elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
406
+ $host = 'Rackspace Cloud';
407
+ } elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
408
+ $host = 'SysFix.eu Power Hosting';
409
+ } elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
410
+ $host = 'Flywheel';
411
+ } else {
412
+ // Adding a general fallback for data gathering
413
+ $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
414
+ }
415
+
416
+ return $host;
417
+ }
418
+
419
+
420
+ /**
421
+ * Get user IP
422
+ *
423
+ * @access public
424
+ * @since 1.1.0
425
+ * @return string $ip User's IP address
426
+ */
427
+ function get_ip() {
428
+ $ip = '127.0.0.1';
429
+
430
+ if( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
431
+ // Check if IP is from share internet
432
+ $ip = $_SERVER['HTTP_CLIENT_IP'];
433
+ } elseif( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
434
+ // Check if IP is passed from proxy
435
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
436
+ } elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
437
+ $ip = $_SERVER['REMOTE_ADDR'];
438
+ }
439
+
440
+ return apply_filters( $this->func . '_get_ip', $ip );
441
+ }
442
+ }
includes/scripts.php ADDED
@@ -0,0 +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' );
license.txt ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+ Preamble
11
+
12
+ The licenses for most software are designed to take away your
13
+ freedom to share and change it. By contrast, the GNU General Public
14
+ License is intended to guarantee your freedom to share and change free
15
+ software--to make sure the software is free for all its users. This
16
+ General Public License applies to most of the Free Software
17
+ Foundation's software and to any other program whose authors commit to
18
+ using it. (Some other Free Software Foundation software is covered by
19
+ the GNU Library General Public License instead.) You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ this service if you wish), that you receive source code or can get it
26
+ if you want it, that you can change the software or use pieces of it
27
+ in new free programs; and that you know you can do these things.
28
+
29
+ To protect your rights, we need to make restrictions that forbid
30
+ anyone to deny you these rights or to ask you to surrender the rights.
31
+ These restrictions translate to certain responsibilities for you if you
32
+ distribute copies of the software, or if you modify it.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must give the recipients all the rights that
36
+ you have. You must make sure that they, too, receive or can get the
37
+ source code. And you must show them these terms so they know their
38
+ rights.
39
+
40
+ We protect your rights with two steps: (1) copyright the software, and
41
+ (2) offer you this license which gives you legal permission to copy,
42
+ distribute and/or modify the software.
43
+
44
+ Also, for each author's protection and ours, we want to make certain
45
+ that everyone understands that there is no warranty for this free
46
+ software. If the software is modified by someone else and passed on, we
47
+ want its recipients to know that what they have is not the original, so
48
+ that any problems introduced by others will not reflect on the original
49
+ authors' reputations.
50
+
51
+ Finally, any free program is threatened constantly by software
52
+ patents. We wish to avoid the danger that redistributors of a free
53
+ program will individually obtain patent licenses, in effect making the
54
+ program proprietary. To prevent this, we have made it clear that any
55
+ patent must be licensed for everyone's free use or not licensed at all.
56
+
57
+ The precise terms and conditions for copying, distribution and
58
+ modification follow.
59
+
60
+ GNU GENERAL PUBLIC LICENSE
61
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
+
63
+ 0. This License applies to any program or other work which contains
64
+ a notice placed by the copyright holder saying it may be distributed
65
+ under the terms of this General Public License. The "Program", below,
66
+ refers to any such program or work, and a "work based on the Program"
67
+ means either the Program or any derivative work under copyright law:
68
+ that is to say, a work containing the Program or a portion of it,
69
+ either verbatim or with modifications and/or translated into another
70
+ language. (Hereinafter, translation is included without limitation in
71
+ the term "modification".) Each licensee is addressed as "you".
72
+
73
+ Activities other than copying, distribution and modification are not
74
+ covered by this License; they are outside its scope. The act of
75
+ running the Program is not restricted, and the output from the Program
76
+ is covered only if its contents constitute a work based on the
77
+ Program (independent of having been made by running the Program).
78
+ Whether that is true depends on what the Program does.
79
+
80
+ 1. You may copy and distribute verbatim copies of the Program's
81
+ source code as you receive it, in any medium, provided that you
82
+ conspicuously and appropriately publish on each copy an appropriate
83
+ copyright notice and disclaimer of warranty; keep intact all the
84
+ notices that refer to this License and to the absence of any warranty;
85
+ and give any other recipients of the Program a copy of this License
86
+ along with the Program.
87
+
88
+ You may charge a fee for the physical act of transferring a copy, and
89
+ you may at your option offer warranty protection in exchange for a fee.
90
+
91
+ 2. You may modify your copy or copies of the Program or any portion
92
+ of it, thus forming a work based on the Program, and copy and
93
+ distribute such modifications or work under the terms of Section 1
94
+ above, provided that you also meet all of these conditions:
95
+
96
+ a) You must cause the modified files to carry prominent notices
97
+ stating that you changed the files and the date of any change.
98
+
99
+ b) You must cause any work that you distribute or publish, that in
100
+ whole or in part contains or is derived from the Program or any
101
+ part thereof, to be licensed as a whole at no charge to all third
102
+ parties under the terms of this License.
103
+
104
+ c) If the modified program normally reads commands interactively
105
+ when run, you must cause it, when started running for such
106
+ interactive use in the most ordinary way, to print or display an
107
+ announcement including an appropriate copyright notice and a
108
+ notice that there is no warranty (or else, saying that you provide
109
+ a warranty) and that users may redistribute the program under
110
+ these conditions, and telling the user how to view a copy of this
111
+ License. (Exception: if the Program itself is interactive but
112
+ does not normally print such an announcement, your work based on
113
+ the Program is not required to print an announcement.)
114
+
115
+ These requirements apply to the modified work as a whole. If
116
+ identifiable sections of that work are not derived from the Program,
117
+ and can be reasonably considered independent and separate works in
118
+ themselves, then this License, and its terms, do not apply to those
119
+ sections when you distribute them as separate works. But when you
120
+ distribute the same sections as part of a whole which is a work based
121
+ on the Program, the distribution of the whole must be on the terms of
122
+ this License, whose permissions for other licensees extend to the
123
+ entire whole, and thus to each and every part regardless of who wrote it.
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
readme.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Username Changer
2
+
3
+ ![Plugin Version](https://img.shields.io/wordpress/plugin/v/username-changer.svg?maxAge=2592000) ![Total Downloads](https://img.shields.io/wordpress/plugin/dt/username-changer.svg?maxAge=2592000) ![Plugin Rating](https://img.shields.io/wordpress/plugin/r/username-changer.svg?maxAge=2592000) ![WordPress Compatibility](https://img.shields.io/wordpress/v/username-changer.svg?maxAge=2592000) [![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://github.com/section214/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/section214/username-changer.git`
12
+ 2. Or download it directly as a ZIP file: `https://github.com/section214/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/section214/username-changer/issues?state=open)!
19
+
20
+ ## Support
21
+
22
+ This is a developer's portal for Username Changer and should _not_ be used for support. Please visit the [support page](https://section214.com/contact/?reason=product-support&product=username-changer) if you need to submit a support request.
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.
readme.txt CHANGED
@@ -1,66 +1,81 @@
1
  === Username Changer ===
2
  Contributors: section214
3
- Donate link: http://pledgie.com/campaigns/17372
4
- Tags: user, username, display name, changer
5
  Requires at least: 3.0
6
- Tested up to: 3.4.1
7
- Stable tag: 2.1.1
8
 
9
- A simple plugin to change registered usernames.
10
 
11
  == Description ==
12
 
13
- Username Changer is a simple plugin which allows administrators to change usernames of users on their sites. Additionally, if the user display name matches the username, it is updated as well.
14
 
15
  == Installation ==
16
 
17
- 1. Unzip the downloaded 'username-changer.zip' file
18
- 2. Upload the 'username-changer' folder to '/wp-content/plugins' directory of your WordPress installation
19
- 3. Activate the plugin via the WordPress Plugins page
 
 
 
 
 
 
 
 
20
 
21
  == Frequently Asked Questions ==
22
 
23
- None yet
 
 
24
 
25
  == Screenshots ==
26
 
27
- 1. The main interface
 
28
 
29
  == Changelog ==
 
 
 
 
30
  = Version 2.1.1 =
31
  * Removed: Deprecated functions
32
 
33
  = Version 2.0.5 =
34
- * Fix contributor
35
 
36
  = Version 2.0.4 =
37
- * Update metalinks
38
 
39
  = Version 2.0.3 =
40
- * Fixed user nice name
41
 
42
  = Version 2.0.2 =
43
- * Added multisite support
44
 
45
  = Version 2.0.1 =
46
- * Added username sanitization
47
- * Minor code cleanup
48
 
49
  = Version 2.0.0 =
50
- * Converted to class-based structure
51
 
52
  = Version 1.4 =
53
- * Include author url (nicename) in update process
54
 
55
  = Version 1.3 =
56
- * Properly escaped vars on POST (I think)
57
 
58
  = Version 1.2 =
59
- * Minor tweak to previous release
60
 
61
  = Version 1.1 =
62
- * Added action on All Users page
63
- * User dropdown is now sorted alphabetically
64
 
65
  = Version 1.0 =
66
  * Initial release
1
  === Username Changer ===
2
  Contributors: section214
3
+ Donate link: https://section214.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.0.0
8
 
9
+ Change usernames easily
10
 
11
  == Description ==
12
 
13
+ hanging 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.0.0 =
42
+ * Improved: Replaced the clunky interface with an inline profile field (props: Danny van Kooten)
43
+ * Added: Settings panel
44
+
45
  = Version 2.1.1 =
46
  * Removed: Deprecated functions
47
 
48
  = Version 2.0.5 =
49
+ * Fixed: Contributor field
50
 
51
  = Version 2.0.4 =
52
+ * Updated: Plugin metalinks
53
 
54
  = Version 2.0.3 =
55
+ * Fixed: User nice name support
56
 
57
  = Version 2.0.2 =
58
+ * Added: multisite support
59
 
60
  = Version 2.0.1 =
61
+ * Added: Proper username sanitization
62
+ * Improved: Minor code cleanup
63
 
64
  = Version 2.0.0 =
65
+ * Improved: Converted to class-based structure
66
 
67
  = Version 1.4 =
68
+ * Added: Include author url (nicename) in update process
69
 
70
  = Version 1.3 =
71
+ * Fixed: Properly escaped vars on POST (I think)
72
 
73
  = Version 1.2 =
74
+ * Fixed: Minor tweak to previous release
75
 
76
  = Version 1.1 =
77
+ * Added: Action on All Users page
78
+ * Improved: User dropdown is now sorted alphabetically
79
 
80
  = Version 1.0 =
81
  * Initial release
screenshot.png DELETED
Binary file
username-changer.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  /**
3
  * Plugin Name: Username Changer
4
- * Description: Lets you change usernames.
5
- * Version: 2.1.1
6
  * Author: Daniel J Griffiths
7
  * Author URI: http://section214.com
8
  * Text Domain: username-changer
@@ -14,19 +14,42 @@
14
 
15
 
16
  // Exit if accessed directly
17
- if( ! defined( 'ABSPATH' ) ) exit;
18
-
19
-
20
- if( ! class_exists( 'Username_Changer' ) ) {
 
 
 
 
 
 
 
21
 
22
  class Username_Changer {
23
-
 
24
  /**
25
  * @var Username_Changer $instance The one true Username_Changer
26
  * @since 2.0.0
27
  */
28
- private static $instance;
29
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  /**
31
  * Get active instance
32
  *
@@ -35,11 +58,12 @@ if( ! class_exists( 'Username_Changer' ) ) {
35
  * @return object self::$instance The one true Username_Changer
36
  */
37
  public static function instance() {
38
- if( ! self::$instance ) {
39
  self::$instance = new Username_Changer();
40
  self::$instance->setup_constants();
41
  self::$instance->includes();
42
- self::$instance->load_textdomain();
 
43
  }
44
 
45
  return self::$instance;
@@ -58,7 +82,10 @@ if( ! class_exists( 'Username_Changer' ) ) {
58
  define( 'USERNAME_CHANGER_DIR', plugin_dir_path( __FILE__ ) );
59
 
60
  // Plugin URL
61
- define( 'USERNAME_CHANGER_URL', plugin_dir_url( __FILE__ ) );
 
 
 
62
  }
63
 
64
 
@@ -69,13 +96,25 @@ if( ! class_exists( 'Username_Changer' ) ) {
69
  * @since 1.0.0
70
  * @return void
71
  */
72
- private function includes() {
73
- if( is_admin() ) {
74
- require_once USERNAME_CHANGER_DIR . 'includes/functions.php';
75
- require_once USERNAME_CHANGER_DIR . 'includes/admin/pages.php';
76
- require_once USERNAME_CHANGER_DIR . 'includes/admin/users/actions.php';
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
  /**
@@ -95,13 +134,13 @@ if( ! class_exists( 'Username_Changer' ) ) {
95
  $mofile = sprintf( '%1$s-%2$s.mo', 'username-changer', $locale );
96
 
97
  // Setup paths to current locale file
98
- $mofile_local = $lang_dir . $mofile;
99
- $mofile_global = WP_LANG_DIR . '/username-changer/' . $mofile;
100
 
101
- if( file_exists( $mofile_global ) ) {
102
  // Look in global /wp-content/languages/username-changer folder
103
  load_textdomain( 'username-changer', $mofile_global );
104
- } elseif( file_exists( $mofile_local ) ) {
105
  // Look in local /wp-content/plugins/username-changer/languages/ filder
106
  load_textdomain( 'username-changer', $mofile_local );
107
  } else {
@@ -115,12 +154,12 @@ if( ! class_exists( 'Username_Changer' ) ) {
115
 
116
  /**
117
  * The main function responsible for returning the one true Username_Changer
118
- * instance to functions everywhere
119
  *
120
  * @since 2.0.0
121
  * @return Username_Changer The one true Username_Changer
122
  */
123
- function Username_Changer_load() {
124
  return Username_Changer::instance();
125
  }
126
- add_action( 'plugins_loaded', 'Username_Changer_load' );
1
  <?php
2
  /**
3
  * Plugin Name: Username Changer
4
+ * Description: Change usernames easily
5
+ * Version: 3.0.0
6
  * Author: Daniel J Griffiths
7
  * Author URI: http://section214.com
8
  * Text Domain: username-changer
14
 
15
 
16
  // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
+ exit;
19
+ }
20
+
21
+
22
+ /**
23
+ * Main Username_Changer class
24
+ *
25
+ * @since 2.0.0
26
+ */
27
+ if ( ! class_exists( 'Username_Changer' ) ) {
28
 
29
  class Username_Changer {
30
+
31
+
32
  /**
33
  * @var Username_Changer $instance The one true Username_Changer
34
  * @since 2.0.0
35
  */
36
+ private static $instance;
37
+
38
+
39
+ /**
40
+ * @var object $settings The settings object
41
+ * @since 3.0.0
42
+ */
43
+ public $settings;
44
+
45
+
46
+ /**
47
+ * @var object $template_tags The template tags object
48
+ * @since 3.0.0
49
+ */
50
+ public $template_tags;
51
+
52
+
53
  /**
54
  * Get active instance
55
  *
58
  * @return object self::$instance The one true Username_Changer
59
  */
60
  public static function instance() {
61
+ if ( ! self::$instance ) {
62
  self::$instance = new Username_Changer();
63
  self::$instance->setup_constants();
64
  self::$instance->includes();
65
+ self::$instance->load_textdomain();
66
+ self::$instance->template_tags = new Username_Changer_Template_Tags();
67
  }
68
 
69
  return self::$instance;
82
  define( 'USERNAME_CHANGER_DIR', plugin_dir_path( __FILE__ ) );
83
 
84
  // Plugin URL
85
+ define( 'USERNAME_CHANGER_URL', plugin_dir_url( __FILE__ ) );
86
+
87
+ // Plugin version
88
+ define( 'USERNAME_CHANGER_VER', '3.0.0' );
89
  }
90
 
91
 
96
  * @since 1.0.0
97
  * @return void
98
  */
99
+ private function includes() {
100
+ global $username_changer_options;
101
+
102
+ // Setup the plugin settings
103
+ require_once USERNAME_CHANGER_DIR . 'includes/admin/settings/register.php';
104
+ if ( ! class_exists( 'S214_Settings' ) ) {
105
+ require_once USERNAME_CHANGER_DIR . 'includes/libraries/s214-settings/source/class.s214-settings.php';
106
+ }
107
+ $this->settings = new S214_Settings( 'username_changer', 'settings' );
108
+ $username_changer_options = $this->settings->get_settings();
109
+
110
+ require_once USERNAME_CHANGER_DIR . 'includes/functions.php';
111
+ require_once USERNAME_CHANGER_DIR . 'includes/scripts.php';
112
+ require_once USERNAME_CHANGER_DIR . 'includes/class.template-tags.php';
113
+
114
+ if ( is_admin() ) {
115
+ require_once USERNAME_CHANGER_DIR . 'includes/admin/actions.php';
116
+ }
117
+ }
118
 
119
 
120
  /**
134
  $mofile = sprintf( '%1$s-%2$s.mo', 'username-changer', $locale );
135
 
136
  // Setup paths to current locale file
137
+ $mofile_local = $lang_dir . $mofile;
138
+ $mofile_global = WP_LANG_DIR . '/username-changer/' . $mofile;
139
 
140
+ if ( file_exists( $mofile_global ) ) {
141
  // Look in global /wp-content/languages/username-changer folder
142
  load_textdomain( 'username-changer', $mofile_global );
143
+ } elseif ( file_exists( $mofile_local ) ) {
144
  // Look in local /wp-content/plugins/username-changer/languages/ filder
145
  load_textdomain( 'username-changer', $mofile_local );
146
  } else {
154
 
155
  /**
156
  * The main function responsible for returning the one true Username_Changer
157
+ * instance to functions everywhere.
158
  *
159
  * @since 2.0.0
160
  * @return Username_Changer The one true Username_Changer
161
  */
162
+ function username_changer() {
163
  return Username_Changer::instance();
164
  }
165
+ add_action( 'plugins_loaded', 'username_changer' );