Username Changer - Version 3.2.0

Version Description

Download this release

Release Info

Developer evertiro
Plugin Icon 128x128 Username Changer
Version 3.2.0
Comparing to
See all releases

Code changes from version 3.1.3 to 3.2.0

Files changed (57) hide show
  1. apigen.neon +0 -4
  2. assets/banner-1544x500-rtl.png +0 -0
  3. assets/banner-1544x500.png +0 -0
  4. assets/banner-772x250-rtl.png +0 -0
  5. assets/banner-772x250.png +0 -0
  6. assets/css/admin.min.css +1 -0
  7. assets/icon-128x128.png +0 -0
  8. assets/icon-256x256.png +0 -0
  9. assets/js/admin.min.js +1 -0
  10. assets/screenshot-1.png +0 -0
  11. assets/screenshot-2.gif +0 -0
  12. class-username-changer.php +240 -0
  13. includes/admin/actions.php +112 -113
  14. includes/admin/settings/register-settings.php +306 -0
  15. includes/admin/settings/register.php +0 -298
  16. includes/{class.template-tags.php → class-username-changer-template-tags.php} +513 -505
  17. includes/libraries/s214-settings/.editorconfig +0 -29
  18. includes/libraries/s214-settings/.gitattributes +0 -2
  19. includes/libraries/s214-settings/.gitignore +0 -36
  20. includes/libraries/s214-settings/.jshintrc +0 -14
  21. includes/libraries/s214-settings/CONTRIBUTING.md +0 -34
  22. includes/libraries/s214-settings/README.md +0 -36
  23. includes/libraries/s214-settings/apigen.neon +0 -4
  24. includes/libraries/s214-settings/composer.json +0 -27
  25. includes/libraries/s214-settings/license.txt +0 -281
  26. includes/libraries/s214-settings/source/assets/css/admin.min.css +0 -1
  27. includes/libraries/s214-settings/source/assets/js/admin.min.js +0 -1
  28. includes/libraries/s214-settings/source/class.s214-settings.php +0 -1276
  29. includes/libraries/s214-settings/source/modules/licensing/S214_Plugin_Updater.php +0 -382
  30. includes/libraries/s214-settings/source/modules/licensing/class.s214-license.php +0 -385
  31. includes/libraries/s214-settings/source/modules/sysinfo/browser.php +0 -1103
  32. includes/libraries/simple-settings/CHANGELOG.md +14 -0
  33. CONTRIBUTING.md → includes/libraries/simple-settings/CONTRIBUTING.md +37 -36
  34. includes/libraries/simple-settings/Gruntfile.js +83 -0
  35. includes/libraries/simple-settings/README.md +28 -0
  36. includes/libraries/{s214-settings/source → simple-settings}/assets/css/admin.css +10 -2
  37. includes/libraries/simple-settings/assets/css/admin.min.css +1 -0
  38. includes/libraries/{s214-settings/source → simple-settings}/assets/css/jquery-ui-classic.min.css +0 -0
  39. includes/libraries/{s214-settings/source → simple-settings}/assets/css/jquery-ui-fresh.min.css +0 -0
  40. includes/libraries/{s214-settings/source → simple-settings}/assets/js/admin.js +10 -10
  41. includes/libraries/simple-settings/assets/js/admin.min.js +1 -0
  42. includes/libraries/simple-settings/class-simple-settings.php +1430 -0
  43. includes/libraries/simple-settings/composer.json +26 -0
  44. includes/libraries/simple-settings/license.txt +674 -0
  45. includes/libraries/simple-settings/modules/licensing/class-simple-settings-license.php +473 -0
  46. includes/libraries/simple-settings/modules/licensing/class-simple-settings-plugin-updater.php +460 -0
  47. includes/libraries/simple-settings/modules/sysinfo/class-browser.php +1931 -0
  48. includes/libraries/{s214-settings/source/modules/sysinfo/class.s214-sysinfo.php → simple-settings/modules/sysinfo/class-simple-settings-sysinfo.php} +139 -125
  49. includes/libraries/simple-settings/package.json +18 -0
  50. includes/{functions.php → misc-functions.php} +156 -157
  51. includes/scripts.php +52 -44
  52. languages/README.md +6 -0
  53. languages/username-changer.pot +348 -0
  54. license.txt +651 -258
  55. readme.md +0 -22
  56. readme.txt +90 -90
  57. username-changer.php +0 -165
apigen.neon DELETED
@@ -1,4 +0,0 @@
1
- source:
2
- - ./
3
-
4
- destination: codex
 
 
 
 
assets/banner-1544x500-rtl.png ADDED
Binary file
assets/banner-1544x500.png ADDED
Binary file
assets/banner-772x250-rtl.png ADDED
Binary file
assets/banner-772x250.png ADDED
Binary file
assets/css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .username-changer-get-help .dashicons{vertical-align:middle;line-height:.9em;margin-right:5px}.username-changer-settings-note{background-color:#fcecad;border:1px solid #ccc;padding:7px}.username-changer-settings-note .note-title{font-weight:700}.username-changer-template-tag-list{margin:14px 14px 0 14px}.username-changer-template-tag span{width:150px;display:inline-block}@media screen and (max-width:480px){.username-changer-template-tag{margin-bottom:12px}.username-changer-template-tag span{width:100%}}
assets/icon-128x128.png ADDED
Binary file
assets/icon-256x256.png ADDED
Binary file
assets/js/admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document.body).ready(function($){"use strict";var profileForm,mount,message,link,currentUsernameInput,newUsernameInput,submitButton,cancelButton,minimumLength;({init:function(){this.general()},general:function(){}}).init(),{init:function(){this.general()},general:function(){"profile"!==username_changer_vars.current_screen&&"user-edit"!==username_changer_vars.current_screen||"1"!==username_changer_vars.can_change_username||(currentUsernameInput=document.getElementById("user_login"),mount=document.querySelector(".user-user-login-wrap td .description"),link=this.createElement("a",{id:"username-changer-link",href:"#",onclick:this.toggle},username_changer_vars.change_button_label),newUsernameInput=this.createElement("input",{id:"username-changer-input",type:"text",name:"new_user_login",value:currentUsernameInput.value,className:"regular-text",style:{"min-height":"28px"},autocomplete:"off"}),cancelButton=this.createElement("input",{id:"username-changer-cancel",type:"button",value:username_changer_vars.cancel_button_label,className:"button",style:{"margin-left":"5px"},onclick:this.toggle}),submitButton=this.createElement("input",{id:"username-changer-submit",type:"button",value:username_changer_vars.save_button_label,className:"button",style:{"margin-left":"5px"},onclick:this.onSubmit}),profileForm=this.createElement("form",{id:"username-changer-form",method:"POST",onsubmit:this.onSubmit,style:{display:"none"}},[newUsernameInput,submitButton,cancelButton]),message=this.createElement("p",{id:"username-changer-message",style:{display:"none"}}),mount.parentNode.replaceChild(link,mount),link.parentNode.appendChild(this.createElement("div",[profileForm,message])),minimumLength=parseInt(username_changer_vars.minimum_length),$("#username-changer-input").on("input",function(){$(this).val().length<minimumLength?(message.style.color="red",message.textContent=username_changer_vars.error_short_username,message.style.display="",submitButton.disabled=!0):!0===submitButton.disabled&&(message.style.display="none",message.textContent="",submitButton.disabled=!1,cancelButton.disabled=!1)}))},createElement:function(name,attrs,children){var e=document.createElement(name);if(children||!Array.isArray(attrs)&&"string"!=typeof attrs||(children=attrs,attrs=null),attrs&&this.setAttribute(e,attrs),children)if("string"==typeof children)e.textContent=children;else for(var i=0;i<children.length;i++)e.appendChild(children[i]);return e},setAttribute:function(object,attrs){for(var key in attrs)"object"==typeof attrs[key]?this.setAttribute(object[key],attrs[key]):object[key]=attrs[key]},toggle:function(e){e.preventDefault(),"none"===profileForm.style.display?(profileForm.style.display="",link.style.display="none",currentUsernameInput.style.display="none",newUsernameInput.focus()):(profileForm.style.display="none",link.style.display="inline",currentUsernameInput.style.display="",message.style.display="none",message.textContent="",newUsernameInput.value=currentUsernameInput.value,submitButton.disabled=!1,cancelButton.disabled=!1)},onSubmit:function(e){e.preventDefault();var newUsername,currentUsername,postData,error=!0;if(newUsername=profileForm.new_user_login.value,currentUsername=currentUsernameInput.value,minimumLength=parseInt(username_changer_vars.minimum_length),newUsername!==currentUsername){if(submitButton.value=username_changer_vars.please_wait_message,submitButton.disabled=!0,cancelButton.disabled=!0,newUsername.length<minimumLength)return message.style.color="red",message.textContent=username_changer_vars.error_short_username,message.style.display="",submitButton.value=username_changer_vars.save_button_label,void(cancelButton.disabled=!1);postData={action:"change_username",old_username:currentUsername,new_username:newUsername,security:username_changer_vars.nonce},$.ajax({type:"POST",data:postData,dataType:"json",url:username_changer_vars.ajaxurl,success:function(response){if(null!==response)try{username_changer_vars.nonce=response.new_nonce,message.style.color=response.success?"green":"red",message.innerHTML=response.message,response.success&&(currentUsernameInput.value=newUsername,error=!1)}catch(e){message.style.color="red",message.textContent=username_changer_vars.error_unknown}else message.style.color="red",message.textContent=username_changer_vars.error_unknown;if(message.style.display="",cancelButton.disabled=!1,submitButton.value=username_changer_vars.save_button_label,!1===error)return currentUsernameInput.value=newUsername,$('input[name="nickname"]').val()===currentUsername&&$('input[name="nickname"]').val(newUsername),$('select[name="display_name"] option:selected').text()===currentUsername&&$('select[name="display_name"] option:selected').text(newUsername),profileForm.style.display="none",link.style.display="inline",void(currentUsernameInput.style.display="")}}).fail(function(data){window.console&&window.console.log&&console.log(data)})}else cancelButton.click()}}.init()});
assets/screenshot-1.png ADDED
Binary file
assets/screenshot-2.gif ADDED
Binary file
class-username-changer.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Username Changer
4
+ * Plugin URI: https://gitlab.com/widgitlabs/wordpress/Username-Changer
5
+ * Description: Change usernames easily
6
+ * Author: Widgit Team
7
+ * Author URI: https://widgit.io
8
+ * Version: 3.2.0
9
+ * Text Domain: username-changer
10
+ * Domain Path: languages
11
+ *
12
+ * @package UsernameChanger
13
+ * @author Daniel J Griffiths <dgriffiths@evertiro.com>
14
+ */
15
+
16
+ // Exit if accessed directly.
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
+ exit;
19
+ }
20
+
21
+
22
+ if ( ! class_exists( 'Username_Changer' ) ) {
23
+
24
+
25
+ /**
26
+ * Main Username_Changer class
27
+ *
28
+ * @access public
29
+ * @since 2.0.0
30
+ */
31
+ final class Username_Changer {
32
+
33
+
34
+ /**
35
+ * The one true Username_Changer
36
+ *
37
+ * @access private
38
+ * @since 2.0.0
39
+ * @var Username_Changer $instance The one true Username_Changer
40
+ */
41
+ private static $instance;
42
+
43
+
44
+ /**
45
+ * The settings object
46
+ *
47
+ * @access public
48
+ * @since 3.0.0
49
+ * @var object $settings The settings object
50
+ */
51
+ public $settings;
52
+
53
+
54
+ /**
55
+ * The template tags object
56
+ *
57
+ * @access public
58
+ * @since 3.0.0
59
+ * @var object $template_tags The template tags object
60
+ */
61
+ public $template_tags;
62
+
63
+
64
+ /**
65
+ * Get active instance
66
+ *
67
+ * @access public
68
+ * @since 2.0.0
69
+ * @static
70
+ * @return object self::$instance The one true Username_Changer
71
+ */
72
+ public static function instance() {
73
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Username_Changer ) ) {
74
+ self::$instance = new Username_Changer();
75
+ self::$instance->setup_constants();
76
+ self::$instance->hooks();
77
+ self::$instance->includes();
78
+ self::$instance->template_tags = new Username_Changer_Template_Tags();
79
+ }
80
+
81
+ return self::$instance;
82
+ }
83
+
84
+
85
+ /**
86
+ * Throw error on object clone
87
+ *
88
+ * The whole idea of the singleton design pattern is that there is
89
+ * a single object. Therefore, we don't want the object to be cloned.
90
+ *
91
+ * @access protected
92
+ * @since 1.0.0
93
+ * @return void
94
+ */
95
+ public function __clone() {
96
+ _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'username-changer' ), '1.0.0' );
97
+ }
98
+
99
+
100
+ /**
101
+ * Disable unserializing of the class
102
+ *
103
+ * @access protected
104
+ * @since 1.0.0
105
+ * @return void
106
+ */
107
+ public function __wakeup() {
108
+ _doing_it_wrong( __FUNCTION__, esc_attr__( 'Cheatin&#8217; huh?', 'username-changer' ), '1.0.0' );
109
+ }
110
+
111
+
112
+ /**
113
+ * Setup plugin constants
114
+ *
115
+ * @access private
116
+ * @since 2.0.0
117
+ * @return void
118
+ */
119
+ private function setup_constants() {
120
+ // Plugin version.
121
+ if ( ! defined( 'USERNAME_CHANGER_VER' ) ) {
122
+ define( 'USERNAME_CHANGER_VER', '3.2.0' );
123
+ }
124
+
125
+ // Plugin path.
126
+ if ( ! defined( 'USERNAME_CHANGER_DIR' ) ) {
127
+ define( 'USERNAME_CHANGER_DIR', plugin_dir_path( __FILE__ ) );
128
+ }
129
+
130
+ // Plugin URL.
131
+ if ( ! defined( 'USERNAME_CHANGER_URL' ) ) {
132
+ define( 'USERNAME_CHANGER_URL', plugin_dir_url( __FILE__ ) );
133
+ }
134
+
135
+ // Plugin file.
136
+ if ( ! defined( 'USERNAME_CHANGER_FILE' ) ) {
137
+ define( 'USERNAME_CHANGER_FILE', __FILE__ );
138
+ }
139
+ }
140
+
141
+
142
+ /**
143
+ * Run plugin base hooks
144
+ *
145
+ * @access private
146
+ * @since 3.2.0
147
+ * @return void
148
+ */
149
+ private function hooks() {
150
+ add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
151
+ }
152
+
153
+
154
+ /**
155
+ * Include necessary files
156
+ *
157
+ * @access private
158
+ * @since 1.0.0
159
+ * @return void
160
+ */
161
+ private function includes() {
162
+ global $username_changer_options;
163
+
164
+ // Load settings handler if necessary.
165
+ if ( ! class_exists( 'Simple_Settings' ) ) {
166
+ require_once USERNAME_CHANGER_DIR . 'includes/libraries/simple-settings/class-simple-settings.php';
167
+ }
168
+
169
+ require_once USERNAME_CHANGER_DIR . 'includes/admin/settings/register-settings.php';
170
+
171
+ self::$instance->settings = new Simple_Settings( 'username_changer', 'settings' );
172
+ $username_changer_options = self::$instance->settings->get_settings();
173
+
174
+ require_once USERNAME_CHANGER_DIR . 'includes/misc-functions.php';
175
+ require_once USERNAME_CHANGER_DIR . 'includes/scripts.php';
176
+ require_once USERNAME_CHANGER_DIR . 'includes/class-username-changer-template-tags.php';
177
+
178
+ if ( is_admin() ) {
179
+ require_once USERNAME_CHANGER_DIR . 'includes/admin/actions.php';
180
+ }
181
+ }
182
+
183
+
184
+ /**
185
+ * Load plugin language files
186
+ *
187
+ * @access public
188
+ * @since 2.0.0
189
+ * @return void
190
+ */
191
+ public function load_textdomain() {
192
+ // Set filter for language directory.
193
+ $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
194
+ $lang_dir = apply_filters( 'username_changer_languages_directory', $lang_dir );
195
+
196
+ // WordPress plugin locale filter.
197
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'username-changer' );
198
+ $mofile = sprintf( '%1$s-%2$s.mo', 'username-changer', $locale );
199
+
200
+ // Setup paths to current locale file.
201
+ $mofile_local = $lang_dir . $mofile;
202
+ $mofile_global = WP_LANG_DIR . '/username-changer/' . $mofile;
203
+ $mofile_core = WP_LANG_DIR . '/plugins/username-changer/' . $mofile;
204
+
205
+ if ( file_exists( $mofile_global ) ) {
206
+ // Look in global /wp-content/languages/username-changer folder.
207
+ load_textdomain( 'username-changer', $mofile_global );
208
+ } elseif ( file_exists( $mofile_local ) ) {
209
+ // Look in local /wp-content/plugins/username-changer/languages/ folder.
210
+ load_textdomain( 'username-changer', $mofile_local );
211
+ } elseif ( file_exists( $mofile_core ) ) {
212
+ // Look in core /wp-content/languages/plugins/username-changer/ folder.
213
+ load_textdomain( 'username-changer', $mofile_core );
214
+ } else {
215
+ // Load the default language files.
216
+ load_plugin_textdomain( 'username-changer', false, $lang_dir );
217
+ }
218
+ }
219
+ }
220
+ }
221
+
222
+
223
+ /**
224
+ * The main function responsible for returning the one true Username_Changer
225
+ * instance to functions everywhere.
226
+ *
227
+ * Use this function like you would a global variable, except without
228
+ * needing to declare the global.
229
+ *
230
+ * Example: <?php $username_changer = Username_Changer(); ?>
231
+ *
232
+ * @since 2.0.0
233
+ * @return Username_Changer The one true Username_Changer
234
+ */
235
+ function username_changer() {
236
+ return Username_Changer::instance();
237
+ }
238
+
239
+ // Get things started.
240
+ Username_Changer();
includes/admin/actions.php CHANGED
@@ -1,113 +1,112 @@
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
- // Send emails as necessary
89
- if ( username_changer()->settings->get_option( 'enable_notifications', false ) ) {
90
- $changed_user = get_user_by( 'login', $old_username );
91
- $mail_to = $changed_user->user_email;
92
- $subject = username_changer_do_tags( username_changer()->settings->get_option( 'email_subject', __( 'Username change notification - {sitename}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
93
- $message = username_changer_do_tags( username_changer()->settings->get_option( 'email_message', __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
94
-
95
- $subject = stripslashes( $subject );
96
- $message = stripslashes( $message );
97
-
98
- $from_name = get_bloginfo( 'name' );
99
- $from_email = get_bloginfo( 'admin_email' );
100
-
101
- $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
102
- $headers .= "Reply-To: ". $from_email . "\r\n";
103
-
104
- wp_mail( $mail_to, $subject, $message, $headers );
105
- }
106
- }
107
- } else {
108
- $response['message'] = __( 'An unknown error occurred.', 'username-changer' );
109
- }
110
-
111
- wp_send_json( $response );
112
- }
113
- add_action( 'wp_ajax_change_username', 'username_changer_ajax_username_change' );
1
+ <?php
2
+ /**
3
+ * Admin actions
4
+ *
5
+ * @package Username_Changer\Admin\Actions
6
+ * @since 3.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Process username change requests through AJAX
17
+ *
18
+ * @since 3.0.0
19
+ * @return void
20
+ */
21
+ function username_changer_ajax_username_change() {
22
+ $response = array(
23
+ 'success' => false,
24
+ 'new_nonce' => wp_create_nonce( 'change_username' ),
25
+ );
26
+
27
+ // Validate nonce.
28
+ check_ajax_referer( 'change_username', 'security' );
29
+
30
+ // Validate request.
31
+ if ( empty( $_POST['new_username'] ) || empty( $_POST['old_username'] ) ) {
32
+ $response['message'] = __( 'Invalid request.', 'username-changer' );
33
+ wp_send_json( $response );
34
+ }
35
+
36
+ $old_username = trim( wp_strip_all_tags( wp_unslash( $_POST['old_username'] ) ) );
37
+ $old_username_tag = esc_attr( sanitize_text_field( wp_unslash( $_POST['old_username'] ) ) );
38
+ $new_username = trim( wp_strip_all_tags( wp_unslash( $_POST['new_username'] ) ) );
39
+ $new_username_tag = esc_attr( sanitize_text_field( wp_unslash( $_POST['new_username'] ) ) );
40
+ $current_user = wp_get_current_user();
41
+ $current_username = $current_user->user_login;
42
+
43
+ // Make sure the user can change this username.
44
+ if ( ! current_user_can( 'edit_users' ) ) {
45
+ if ( $current_username !== $old_username || ! username_changer_can_change_own_username() ) {
46
+ $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 );
47
+ wp_send_json( $response );
48
+ }
49
+ }
50
+
51
+ // Validate new username.
52
+ if ( ! validate_username( $new_username ) ) {
53
+ $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 );
54
+ wp_send_json( $response );
55
+ }
56
+
57
+ // Make sure new username isn't on the illegal logins list.
58
+ $illegal_user_logins = array_map( 'strtolower', (array) apply_filters( 'illegal_user_logins', array() ) );
59
+ if ( in_array( $new_username, $illegal_user_logins, true ) ) {
60
+ $response['message'] = __( 'Sorry, that username is not allowed.', 'username-changer' );
61
+ wp_send_json( $response );
62
+ }
63
+
64
+ // Make sure the new username isn't already taken.
65
+ if ( username_exists( $new_username ) ) {
66
+ $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 );
67
+ wp_send_json( $response );
68
+ }
69
+
70
+ // Change the username.
71
+ $success = username_changer_process( $old_username, $new_username );
72
+
73
+ if ( $success ) {
74
+ $response['success'] = true;
75
+
76
+ // Append re-login link if old_username == current_username.
77
+ if ( $old_username === $current_username ) {
78
+ $response['message'] = sprintf(
79
+ '%s&nbsp;<a href="%s">%s</a>',
80
+ 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 ),
81
+ wp_login_url(),
82
+ 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 )
83
+ );
84
+ } else {
85
+ $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 );
86
+
87
+ // Send emails as necessary.
88
+ if ( username_changer()->settings->get_option( 'enable_notifications', false ) ) {
89
+ $changed_user = get_user_by( 'login', $old_username );
90
+ $mail_to = $changed_user->user_email;
91
+ $subject = username_changer_do_tags( username_changer()->settings->get_option( 'email_subject', __( 'Username change notification - {sitename}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
92
+ $message = username_changer_do_tags( username_changer()->settings->get_option( 'email_message', __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' ) ), $old_username_tag, $new_username_tag );
93
+
94
+ $subject = stripslashes( $subject );
95
+ $message = stripslashes( $message );
96
+
97
+ $from_name = get_bloginfo( 'name' );
98
+ $from_email = get_bloginfo( 'admin_email' );
99
+
100
+ $headers = 'From: ' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
101
+ $headers .= 'Reply-To: ' . $from_email . "\r\n";
102
+
103
+ wp_mail( $mail_to, $subject, $message, $headers ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_mail_wp_mail
104
+ }
105
+ }
106
+ } else {
107
+ $response['message'] = __( 'An unknown error occurred.', 'username-changer' );
108
+ }
109
+
110
+ wp_send_json( $response );
111
+ }
112
+ add_action( 'wp_ajax_change_username', 'username_changer_ajax_username_change' );
 
includes/admin/settings/register-settings.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Register settings
4
+ *
5
+ * @package UsernameChanger\Admin\Settings\Register
6
+ * @since 3.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Setup the settings menu
17
+ *
18
+ * @since 3.0.0
19
+ * @param array $menu The default menu settings.
20
+ * @return array $menu Our defined settings
21
+ */
22
+ function username_changer_add_menu( $menu ) {
23
+ $menu['type'] = 'submenu';
24
+ $menu['page_title'] = __( 'Username Changer Settings', 'username-changer' );
25
+ $menu['menu_title'] = __( 'Username Changer', 'username-changer' );
26
+
27
+ return $menu;
28
+ }
29
+ add_filter( 'username_changer_menu', 'username_changer_add_menu' );
30
+
31
+
32
+ /**
33
+ * Define our settings tabs
34
+ *
35
+ * @since 3.0.0
36
+ * @param array $tabs The default tabs.
37
+ * @return array $tabs Our defined tabs
38
+ */
39
+ function username_changer_settings_tabs( $tabs ) {
40
+ $tabs['settings'] = __( 'Settings', 'username-changer' );
41
+ $tabs['support'] = __( 'Support', 'username-changer' );
42
+
43
+ return $tabs;
44
+ }
45
+ add_filter( 'username_changer_settings_tabs', 'username_changer_settings_tabs' );
46
+
47
+
48
+ /**
49
+ * Define settings sections
50
+ *
51
+ * @since 3.0.0
52
+ * @param array $sections The default sections.
53
+ * @return array $sections Our defined sections
54
+ */
55
+ function username_changer_registered_settings_sections( $sections ) {
56
+ $sections = array(
57
+ 'settings' => apply_filters(
58
+ 'username_changer_settings_sections_settings',
59
+ array(
60
+ 'main' => __( 'General Settings', 'username-changer' ),
61
+ 'strings' => __( 'String Settings', 'username-changer' ),
62
+ )
63
+ ),
64
+ 'support' => apply_filters( 'username_changer_settings_sections_support', array() ),
65
+ );
66
+
67
+ return $sections;
68
+ }
69
+ add_filter( 'username_changer_registered_settings_sections', 'username_changer_registered_settings_sections' );
70
+
71
+
72
+ /**
73
+ * Disable save button on unsavable tabs
74
+ *
75
+ * @since 3.0.0
76
+ * @return array $tabs The updated tabs
77
+ */
78
+ function username_changer_define_unsavable_tabs() {
79
+ $tabs = array( 'support' );
80
+
81
+ return $tabs;
82
+ }
83
+ add_filter( 'username_changer_unsavable_tabs', 'username_changer_define_unsavable_tabs' );
84
+
85
+
86
+ /**
87
+ * Define our settings
88
+ *
89
+ * @since 3.0.0
90
+ * @param array $settings The default settings.
91
+ * @return array $settings Our defined settings
92
+ */
93
+ function username_changer_registered_settings( $settings ) {
94
+ $new_settings = array(
95
+ // General Settings.
96
+ 'settings' => apply_filters(
97
+ 'username_changer_settings_settings',
98
+ array(
99
+ 'main' => array(
100
+ array(
101
+ 'id' => 'settings_header',
102
+ 'name' => __( 'General Settings', 'username-changer' ),
103
+ 'desc' => '',
104
+ 'type' => 'header',
105
+ ),
106
+ array(
107
+ 'id' => 'allowed_roles',
108
+ 'name' => __( 'Allowed Roles', 'username-changer' ),
109
+ 'desc' => __( 'Select the user roles which are permitted to change their own username.', 'username-changer' ),
110
+ 'type' => 'multicheck',
111
+ 'options' => username_changer_get_user_roles(),
112
+ 'tooltip_title' => __( 'Allowed Roles', 'username-changer' ),
113
+ 'tooltip_desc' => __( 'Administrators can always change usernames, and are the only role capable of changing other users username.', 'username-changer' ),
114
+ ),
115
+ array(
116
+ 'id' => 'minimum_length',
117
+ 'name' => __( 'Minimum Length', 'username-changer' ),
118
+ 'desc' => __( 'Specify the minimum allowed username length.', 'username-changer' ),
119
+ 'type' => 'number',
120
+ 'size' => 'small-text',
121
+ 'min' => 3,
122
+ 'step' => 1,
123
+ 'std' => 3,
124
+ 'tooltip_title' => __( 'Minimum Length', 'username-changer' ),
125
+ 'tooltip_desc' => __( 'The minimum allowed length for usernames is {minlength} characters.', 'username-changer' ),
126
+ ),
127
+ array(
128
+ 'id' => 'email_header',
129
+ 'name' => __( 'Email Settings', 'username-changer' ),
130
+ 'desc' => '',
131
+ 'type' => 'header',
132
+ ),
133
+ array(
134
+ 'id' => 'enable_notifications',
135
+ 'name' => __( 'Enable Email Notifications', 'username-changer' ),
136
+ 'desc' => __( 'Enable to send notification emails when usernames are changed.', 'username-changer' ),
137
+ 'type' => 'checkbox',
138
+ 'tooltip_title' => __( 'Enable Email Notifications', 'username-changer' ),
139
+ 'tooltip_desc' => __( 'Notifications are not sent when a user changes their own username.', 'username-changer' ),
140
+ ),
141
+ array(
142
+ 'id' => 'email_subheader',
143
+ 'name' => '',
144
+ 'desc' => '',
145
+ 'type' => 'hook',
146
+ ),
147
+ array(
148
+ 'id' => 'email_subject',
149
+ 'name' => __( 'Email Subject', 'username-changer' ),
150
+ 'desc' => __( 'Specify the subject for username change notifications.', 'username-changer' ),
151
+ 'type' => 'text',
152
+ 'std' => __( 'Username change notification - {sitename}', 'username-changer' ),
153
+ ),
154
+ array(
155
+ 'id' => 'email_message',
156
+ 'name' => __( 'Email Message', 'username-changer' ),
157
+ 'desc' => __( 'Specify the message to send for username change notifications.', 'username-changer' ),
158
+ 'type' => 'editor',
159
+ 'std' => __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' ),
160
+ ),
161
+ ),
162
+ 'strings' => array(
163
+ array(
164
+ 'id' => 'button_labels_header',
165
+ 'name' => __( 'Button Labels', 'username-changer' ),
166
+ 'desc' => '',
167
+ 'type' => 'header',
168
+ ),
169
+ array(
170
+ 'id' => 'change_button_label',
171
+ 'name' => __( 'Change Button Label', 'username-changer' ),
172
+ 'desc' => __( 'Customize the text for the \'change username\' button.', 'username-changer' ),
173
+ 'type' => 'text',
174
+ 'std' => __( 'Change Username', 'username-changer' ),
175
+ ),
176
+ array(
177
+ 'id' => 'save_button_label',
178
+ 'name' => __( 'Save Button Label', 'username-changer' ),
179
+ 'desc' => __( 'Customize the text for the save button.', 'username-changer' ),
180
+ 'type' => 'text',
181
+ 'std' => __( 'Save Username', 'username-changer' ),
182
+ ),
183
+ array(
184
+ 'id' => 'cancel_button_label',
185
+ 'name' => __( 'Cancel Button Label', 'username-changer' ),
186
+ 'desc' => __( 'Customize the text for the cancel button.', 'username-changer' ),
187
+ 'type' => 'text',
188
+ 'std' => __( 'Cancel', 'username-changer' ),
189
+ ),
190
+ array(
191
+ 'id' => 'messages_header',
192
+ 'name' => __( 'Messages', 'username-changer' ),
193
+ 'desc' => 'test',
194
+ 'type' => 'header',
195
+ ),
196
+ array(
197
+ 'id' => 'messages_subheader',
198
+ 'name' => '',
199
+ 'desc' => '',
200
+ 'type' => 'hook',
201
+ ),
202
+ array(
203
+ 'id' => 'please_wait_message',
204
+ 'name' => __( 'Please Wait Message', 'username-changer' ),
205
+ 'desc' => __( 'Customize the text displayed while usernames are being checked.', 'username-changer' ),
206
+ 'type' => 'text',
207
+ 'std' => __( 'Please wait...', 'username-changer' ),
208
+ ),
209
+ array(
210
+ 'id' => 'success_message',
211
+ 'name' => __( 'Username Changed Message', 'username-changer' ),
212
+ 'desc' => __( 'Customize the message displayed when a username is changed successfully.', 'username-changer' ),
213
+ 'type' => 'text',
214
+ 'std' => __( 'Username successfully changed to {new_username}.', 'username-changer' ),
215
+ ),
216
+ array(
217
+ 'id' => 'relogin_message',
218
+ 'name' => __( 'Relogin Message', 'username-changer' ),
219
+ 'desc' => __( 'Customize the text for the relogin link shown if a user changes their own username.', 'username-changer' ),
220
+ 'type' => 'text',
221
+ 'std' => __( 'Click here to log back in.', 'username-changer' ),
222
+ ),
223
+ array(
224
+ 'id' => 'error_short_username',
225
+ 'name' => __( 'Short Username Error', 'username-changer' ),
226
+ 'desc' => __( 'Customize the error displayed when a username is too short.', 'username-changer' ),
227
+ 'type' => 'text',
228
+ 'std' => __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' ),
229
+ ),
230
+ array(
231
+ 'id' => 'error_wrong_permissions',
232
+ 'name' => __( 'Wrong Permissions Error', 'username-changer' ),
233
+ 'desc' => __( 'Customize the error displayed when a user attempts to change a username they do not have permission to change.', 'username-changer' ),
234
+ 'type' => 'text',
235
+ 'std' => __( 'You do not have the correct permissions to change this username.', 'username-changer' ),
236
+ 'tooltip_title' => __( 'Wrong Permissions Error', 'username-changer' ),
237
+ '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' ),
238
+ ),
239
+ array(
240
+ 'id' => 'error_duplicate_username',
241
+ 'name' => __( 'Duplicate Username Error', 'username-changer' ),
242
+ 'desc' => __( 'Customize the error displayed when a user attempts to change a username to something that is already in use.', 'username-changer' ),
243
+ 'type' => 'text',
244
+ 'std' => __( 'The username {new_username} is already in use. Please try again.', 'username-changer' ),
245
+ ),
246
+ ),
247
+ )
248
+ ),
249
+ 'support' => apply_filters(
250
+ 'username_changer_settings_support',
251
+ array(
252
+ array(
253
+ 'id' => 'support_header',
254
+ 'name' => __( 'Username Changer Support', 'username-changer' ),
255
+ 'desc' => '',
256
+ 'type' => 'header',
257
+ ),
258
+ array(
259
+ 'id' => 'system_info',
260
+ 'name' => __( 'System Info', 'username-changer' ),
261
+ 'desc' => '',
262
+ 'type' => 'sysinfo',
263
+ ),
264
+ )
265
+ ),
266
+ );
267
+
268
+ return array_merge( $settings, $new_settings );
269
+ }
270
+ add_filter( 'username_changer_registered_settings', 'username_changer_registered_settings' );
271
+
272
+
273
+ /**
274
+ * Display the subheader for the emails section
275
+ *
276
+ * @since 3.1.0
277
+ * @return void
278
+ */
279
+ function username_changer_display_email_subheader() {
280
+ ?>
281
+ <div class="username-changer-settings-note">
282
+ <span class="note-title"><?php esc_attr_e( 'Template Tags', 'username-changer' ); ?></span>
283
+ <p><?php esc_attr_e( 'Emails allow the use of the following template tags:', 'username-changer' ); ?></p>
284
+ <?php username_changer_tags_list( 'email' ); ?>
285
+ </div>
286
+ <?php
287
+ }
288
+ add_action( 'username_changer_email_subheader', 'username_changer_display_email_subheader' );
289
+
290
+
291
+ /**
292
+ * Display the subheader for the messages section
293
+ *
294
+ * @since 3.0.0
295
+ * @return void
296
+ */
297
+ function username_changer_display_messages_subheader() {
298
+ ?>
299
+ <div class="username-changer-settings-note">
300
+ <span class="note-title"><?php esc_attr_e( 'Template Tags', 'username-changer' ); ?></span>
301
+ <p><?php esc_attr_e( 'The message settings fields allow the use of the following template tags:', 'username-changer' ); ?></p>
302
+ <?php username_changer_tags_list( 'message' ); ?>
303
+ </div>
304
+ <?php
305
+ }
306
+ add_action( 'username_changer_messages_subheader', 'username_changer_display_messages_subheader' );
includes/admin/settings/register.php DELETED
@@ -1,298 +0,0 @@
1
- <?php
2
- /**
3
- * Register settings
4
- *
5
- * @package UsernameChanger\Admin\Settings\Register
6
- * @since 3.0.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- /**
17
- * Setup the settings menu
18
- *
19
- * @since 3.0.0
20
- * @param array $menu The default menu settings
21
- * @return array $menu Our defined settings
22
- */
23
- function username_changer_add_menu( $menu ) {
24
- $menu['type'] = 'submenu';
25
- $menu['page_title'] = __( 'Username Changer Settings', 'username-changer' );
26
- $menu['menu_title'] = __( 'Username Changer', 'username-changer' );
27
-
28
- return $menu;
29
- }
30
- add_filter( 'username_changer_menu', 'username_changer_add_menu' );
31
-
32
-
33
- /**
34
- * Define our settings tabs
35
- *
36
- * @since 3.0.0
37
- * @param array $tabs The default tabs
38
- * @return array $tabs Our defined tabs
39
- */
40
- function username_changer_settings_tabs( $tabs ) {
41
- $tabs['settings'] = __( 'Settings', 'username-changer' );
42
- $tabs['support'] = __( 'Support', 'username-changer' );
43
-
44
- return $tabs;
45
- }
46
- add_filter( 'username_changer_settings_tabs', 'username_changer_settings_tabs' );
47
-
48
-
49
- /**
50
- * Define settings sections
51
- *
52
- * @since 3.0.0
53
- * @param array $sections The default sections
54
- * @return array $sections Our defined sections
55
- */
56
- function username_changer_registered_settings_sections( $sections ) {
57
- $sections = array(
58
- 'settings' => apply_filters( 'username_changer_settings_sections_settings', array(
59
- 'main' => __( 'General Settings', 'username-changer' ),
60
- 'strings' => __( 'String Settings', 'username-changer' )
61
- ) ),
62
- 'support' => apply_filters( 'username_changer_settings_sections_support', array() )
63
- );
64
-
65
- return $sections;
66
- }
67
- add_filter( 'username_changer_registered_settings_sections', 'username_changer_registered_settings_sections' );
68
-
69
-
70
- /**
71
- * Disable save button on unsavable tabs
72
- *
73
- * @since 3.0.0
74
- * @return array $tabs The updated tabs
75
- */
76
- function username_changer_define_unsavable_tabs() {
77
- $tabs = array( 'support' );
78
-
79
- return $tabs;
80
- }
81
- add_filter( 'username_changer_unsavable_tabs', 'username_changer_define_unsavable_tabs' );
82
-
83
-
84
- /**
85
- * Define our settings
86
- *
87
- * @since 3.0.0
88
- * @param array $settings The default settings
89
- * @return array $settings Our defined settings
90
- */
91
- function username_changer_registered_settings( $settings ) {
92
- $new_settings = array(
93
- // General Settings
94
- 'settings' => apply_filters( 'username_changer_settings_settings', array(
95
- 'main' => array(
96
- array(
97
- 'id' => 'settings_header',
98
- 'name' => __( 'General Settings', 'username-changer' ),
99
- 'desc' => '',
100
- 'type' => 'header'
101
- ),
102
- array(
103
- 'id' => 'allowed_roles',
104
- 'name' => __( 'Allowed Roles', 'username-changer' ),
105
- 'desc' => __( 'Select the user roles which are permitted to change their own username.', 'username-changer' ),
106
- 'type' => 'multicheck',
107
- 'options' => username_changer_get_user_roles(),
108
- 'tooltip_title' => __( 'Allowed Roles', 'username-changer' ),
109
- 'tooltip_desc' => __( 'Administrators can always change usernames, and are the only role capable of changing other users username.', 'username-changer' )
110
- ),
111
- array(
112
- 'id' => 'minimum_length',
113
- 'name' => __( 'Minimum Length', 'username-changer' ),
114
- 'desc' => __( 'Specify the minimum allowed username length.', 'username-changer' ),
115
- 'type' => 'number',
116
- 'size' => 'small-text',
117
- 'min' => 3,
118
- 'step' => 1,
119
- 'std' => 3,
120
- 'tooltip_title' => __( 'Minimum Length', 'username-changer' ),
121
- 'tooltip_desc' => __( 'The minimum allowed length for usernames is {minlength} characters.', 'username-changer' )
122
- ),
123
- array(
124
- 'id' => 'email_header',
125
- 'name' => __( 'Email Settings', 'username-changer' ),
126
- 'desc' => '',
127
- 'type' => 'header'
128
- ),
129
- array(
130
- 'id' => 'enable_notifications',
131
- 'name' => __( 'Enable Email Notifications', 'username-changer' ),
132
- 'desc' => __( 'Enable to send notification emails when usernames are changed.', 'username-changer' ),
133
- 'type' => 'checkbox',
134
- 'tooltip_title' => __( 'Enable Email Notifications', 'username-changer' ),
135
- 'tooltip_desc' => __( 'Notifications are not sent when a user changes their own username.', 'username-changer' )
136
- ),
137
- array(
138
- 'id' => 'email_subheader',
139
- 'name' => '',
140
- 'desc' => '',
141
- 'type' => 'hook'
142
- ),
143
- array(
144
- 'id' => 'email_subject',
145
- 'name' => __( 'Email Subject', 'username-changer' ),
146
- 'desc' => __( 'Specify the subject for username change notifications.', 'username-changer' ),
147
- 'type' => 'text',
148
- 'std' => __( 'Username change notification - {sitename}', 'username-changer' ),
149
- ),
150
- array(
151
- 'id' => 'email_message',
152
- 'name' => __( 'Email Message', 'username-changer' ),
153
- 'desc' => __( 'Specify the message to send for username change notifications.', 'username-changer' ),
154
- 'type' => 'editor',
155
- 'std' => __( 'Howdy! We\'re just writing to let you know that your username for {siteurl} has been changed to {new_username}.', 'username-changer' ) . "\n\n" . __( 'Login now at {loginurl}', 'username-changer' )
156
- )
157
- ),
158
- 'strings' => array(
159
- array(
160
- 'id' => 'button_labels_header',
161
- 'name' => __( 'Button Labels', 'username-changer' ),
162
- 'desc' => '',
163
- 'type' => 'header'
164
- ),
165
- array(
166
- 'id' => 'change_button_label',
167
- 'name' => __( 'Change Button Label', 'username-changer' ),
168
- 'desc' => __( 'Customize the text for the \'change username\' button.', 'username-changer' ),
169
- 'type' => 'text',
170
- 'std' => __( 'Change Username', 'username-changer' )
171
- ),
172
- array(
173
- 'id' => 'save_button_label',
174
- 'name' => __( 'Save Button Label', 'username-changer' ),
175
- 'desc' => __( 'Customize the text for the save buttton.', 'username-changer' ),
176
- 'type' => 'text',
177
- 'std' => __( 'Save Username', 'username-changer' )
178
- ),
179
- array(
180
- 'id' => 'cancel_button_label',
181
- 'name' => __( 'Cancel Button Label', 'username-changer' ),
182
- 'desc' => __( 'Customize the text for the cancel button.', 'username-changer' ),
183
- 'type' => 'text',
184
- 'std' => __( 'Cancel', 'username-changer' )
185
- ),
186
- array(
187
- 'id' => 'messages_header',
188
- 'name' => __( 'Messages', 'username-changer' ),
189
- 'desc' => 'test',
190
- 'type' => 'header'
191
- ),
192
- array(
193
- 'id' => 'messages_subheader',
194
- 'name' => '',
195
- 'desc' => '',
196
- 'type' => 'hook'
197
- ),
198
- array(
199
- 'id' => 'please_wait_message',
200
- 'name' => __( 'Please Wait Message', 'username-changer' ),
201
- 'desc' => __( 'Customize the text displayed while usernames are being checked.', 'username-changer' ),
202
- 'type' => 'text',
203
- 'std' => __( 'Please wait...', 'username-changer' )
204
- ),
205
- array(
206
- 'id' => 'success_message',
207
- 'name' => __( 'Username Changed Message', 'username-changer' ),
208
- 'desc' => __( 'Customize the message displayed when a username is changed successfully.', 'username-changer' ),
209
- 'type' => 'text',
210
- 'std' => __( 'Username successfully changed to {new_username}.', 'username-changer' )
211
- ),
212
- array(
213
- 'id' => 'relogin_message',
214
- 'name' => __( 'Relogin Message', 'username-changer' ),
215
- 'desc' => __( 'Customize the text for the relogin link shown if a user changes their own username.', 'username-changer' ),
216
- 'type' => 'text',
217
- 'std' => __( 'Click here to log back in.', 'username-changer' )
218
- ),
219
- array(
220
- 'id' => 'error_short_username',
221
- 'name' => __( 'Short Username Error', 'username-changer' ),
222
- 'desc' => __( 'Customize the error displayed when a username is too short.', 'username-changer' ),
223
- 'type' => 'text',
224
- 'std' => __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' )
225
- ),
226
- array(
227
- 'id' => 'error_wrong_permissions',
228
- 'name' => __( 'Wrong Permissions Error', 'username-changer' ),
229
- 'desc' => __( 'Customize the error displayed when a user attempts to change a username they do not have permission to change.', 'username-changer' ),
230
- 'type' => 'text',
231
- 'std' => __( 'You do not have the correct permissions to change this username.', 'username-changer' ),
232
- 'tooltip_title' => __( 'Wrong Permissions Error', 'username-changer' ),
233
- 'tooltip_desc' => __( 'In normal circumstances, this message should never be triggered. It exists only to provide an extra layer of security against unauthorized use.', 'username-changer' )
234
- ),
235
- array(
236
- 'id' => 'error_duplicate_username',
237
- 'name' => __( 'Duplicate Username Error', 'username-changer' ),
238
- 'desc' => __( 'Customize the error displayed when a user attempts to change a username to something that is already in use.', 'username-changer' ),
239
- 'type' => 'text',
240
- 'std' => __( 'The username {new_username} is already in use. Please try again.', 'username-changer' )
241
- )
242
- )
243
- ) ),
244
- 'support' => apply_filters( 'username_changer_settings_support', array(
245
- array(
246
- 'id' => 'support_header',
247
- 'name' => __( 'Username Changer Support', 'username-changer' ),
248
- 'desc' => '',
249
- 'type' => 'header'
250
- ),
251
- array(
252
- 'id' => 'system_info',
253
- 'name' => __( 'System Info', 'username-changer' ),
254
- 'desc' => '',
255
- 'type' => 'sysinfo'
256
- )
257
- ) )
258
- );
259
-
260
- return array_merge( $settings, $new_settings );
261
- }
262
- add_filter( 'username_changer_registered_settings', 'username_changer_registered_settings' );
263
-
264
-
265
- /**
266
- * Display the subheader for the emails section
267
- *
268
- * @since 3.1.0
269
- * @return void
270
- */
271
- function username_changer_display_email_subheader() {
272
- ?>
273
- <div class="username-changer-settings-note">
274
- <span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
275
- <p><?php _e( 'Emails allow the use of the following template tags:', 'username-changer' ); ?></p>
276
- <?php echo username_changer_tags_list( 'email' ); ?>
277
- </div>
278
- <?php
279
- }
280
- add_action( 'username_changer_email_subheader', 'username_changer_display_email_subheader' );
281
-
282
-
283
- /**
284
- * Display the subheader for the messages section
285
- *
286
- * @since 3.0.0
287
- * @return void
288
- */
289
- function username_changer_display_messages_subheader() {
290
- ?>
291
- <div class="username-changer-settings-note">
292
- <span class="note-title"><?php _e( 'Template Tags', 'username-changer' ); ?></span>
293
- <p><?php _e( 'The message settings fields allow the use of the following template tags:', 'username-changer' ); ?></p>
294
- <?php echo username_changer_tags_list( 'message' ); ?>
295
- </div>
296
- <?php
297
- }
298
- add_action( 'username_changer_messages_subheader', 'username_changer_display_messages_subheader' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/{class.template-tags.php → class-username-changer-template-tags.php} RENAMED
@@ -1,505 +1,513 @@
1
- <?php
2
- /**
3
- * Template tags
4
- *
5
- * @package UsernameChanger\TemplateTags
6
- * @since 3.0.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- class Username_Changer_Template_Tags {
17
-
18
-
19
- /**
20
- * @access private
21
- * @since 3.0.0
22
- * @var array $tags Container for storing all tags
23
- */
24
- private $tags;
25
-
26
-
27
- /**
28
- * @access private
29
- * @since 3.0.0
30
- * @var string $old_username The old username of the user
31
- */
32
- private $old_username;
33
-
34
-
35
- /**
36
- * @access private
37
- * @since 3.0.0
38
- * @var string $new_username The new username of the user
39
- */
40
- private $new_username;
41
-
42
-
43
- /**
44
- * Add a template tag
45
- *
46
- * @access public
47
- * @since 3.0.0
48
- * @param string $tag Tag to be replaced
49
- * @param string $desc Description of the tag
50
- * @param array $context Context for the tag
51
- * @param string $func The hook to run when tag is found
52
- * @return void
53
- */
54
- public function add( $tag, $desc, $context, $func ) {
55
- if ( is_callable( $func ) ) {
56
- $this->tags[ $tag ] = array(
57
- 'tag' => $tag,
58
- 'desc' => $desc,
59
- 'context' => $context,
60
- 'func' => $func
61
- );
62
- }
63
- }
64
-
65
-
66
- /**
67
- * Remove a template tag
68
- *
69
- * @access public
70
- * @since 3.0.0
71
- * @param string $tag Tag to be removed
72
- * @return void
73
- */
74
- public function remove( $tag ) {
75
- unset( $this->tags[ $tag ] );
76
- }
77
-
78
-
79
- /**
80
- * Check if $tag is a registered template tag
81
- *
82
- * @access public
83
- * @since 3.0.0
84
- * @param string $tag Tag to search for
85
- * @return bool True if found, false otherwise
86
- */
87
- public function template_tag_exists( $tag ) {
88
- return array_key_exists( $tag, $this->tags );
89
- }
90
-
91
-
92
- /**
93
- * Returns a list of all tags
94
- *
95
- * @access public
96
- * @since 3.0.0
97
- * @param string $context The context to return tags for
98
- * @return array $tags The available tags
99
- */
100
- public function get_tags( $context ) {
101
- $tags = $this->tags;
102
-
103
- foreach ( $tags as $tag_id => $tag_data ) {
104
- if ( ! in_array( $context, $tag_data['context'] ) ) {
105
- unset( $tags[ $tag_id ] );
106
- }
107
- }
108
-
109
- return $tags;
110
- }
111
-
112
-
113
- /**
114
- * Search content for tags and filter through their hooks
115
- *
116
- * @access public
117
- * @since 3.0.0
118
- * @param string $content Content to search
119
- * @param string $old_username The old username of the user
120
- * @param string $new_username The new username of the user
121
- * @return string $new_content Filtered content
122
- */
123
- public function do_tags( $content, $old_username = '', $new_username = '' ) {
124
- // Ensure there is at least one tag
125
- if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
126
- return $content;
127
- }
128
-
129
- $this->old_username = $old_username;
130
- $this->new_username = $new_username;
131
-
132
- $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
133
-
134
- $this->old_username = '';
135
- $this->new_username = '';
136
-
137
- return $new_content;
138
- }
139
-
140
-
141
- /**
142
- * Do a specific tag
143
- *
144
- * @access public
145
- * @since 3.0.0
146
- * @param $m Message
147
- * @return mixed
148
- */
149
- public function do_tag( $m ) {
150
- // Get tag
151
- $tag = $m[1];
152
-
153
- // Return tag if tag not set
154
- if ( ! $this->template_tag_exists( $tag ) ) {
155
- return $m[0];
156
- }
157
-
158
- return call_user_func( $this->tags[ $tag ]['func'], $this->old_username, $this->new_username, $tag );
159
- }
160
- }
161
-
162
-
163
- /**
164
- * Add a template tag
165
- *
166
- * @since 3.0.0
167
- * @param string $tag Tag to be replaced
168
- * @param string $desc Description of the tag
169
- * @param array $context Context for the tag
170
- * @param string $func The hook to run when tag is found
171
- * @return void
172
- */
173
- function username_changer_add_template_tag( $tag, $desc, $context, $func ) {
174
- Username_Changer()->template_tags->add( $tag, $desc, $context, $func );
175
- }
176
-
177
-
178
- /**
179
- * Remove a template tag
180
- *
181
- * @since 3.0.0
182
- * @param string $tag Template tag to remove
183
- * @return void
184
- */
185
- function username_changer_remove_template_tag( $tag ) {
186
- Username_Changer()->template_tags->remove( $tag );
187
- }
188
-
189
-
190
- /**
191
- * Check if a text exists
192
- *
193
- * @since 3.0.0
194
- * @param string $tag The string to check
195
- * @return bool True if exists, false otherwise
196
- */
197
- function username_changer_tag_exists( $tag ) {
198
- return Username_Changer()->template_tags->template_tag_exists( $tag );
199
- }
200
-
201
-
202
- /**
203
- * Get all tags
204
- *
205
- * @since 3.0.0
206
- * @param string $context The context to return tags for
207
- * @return array The existing tags
208
- */
209
- function username_changer_get_template_tags( $context = 'message' ) {
210
- return Username_Changer()->template_tags->get_tags( $context );
211
- }
212
-
213
-
214
- /**
215
- * Get a formatted list of all available tags
216
- *
217
- * @since 3.0.0
218
- * @param string $context The context to display
219
- * @return string The formatted list
220
- */
221
- function username_changer_tags_list( $context = 'message' ) {
222
- // The list
223
- $list = '';
224
-
225
- // Get all tags
226
- $tags = username_changer_get_template_tags( $context );
227
-
228
- // Check
229
- if ( count( $tags ) > 0 ) {
230
- $list .= '<ul class="username-changer-template-tag-list">';
231
-
232
- foreach ( $tags as $tag ) {
233
- // Add tag to list
234
- $list .= '<li class="username-changer-template-tag"><span>{' . $tag['tag'] . '}</span>' . $tag['desc'] . '</li>';
235
- }
236
-
237
- $list .= '</ul>';
238
- }
239
-
240
- // Return the list
241
- return $list;
242
- }
243
-
244
-
245
- /**
246
- * Search content for tags and filter
247
- *
248
- * @since 3.0.0
249
- * @param string $content Content to search
250
- * @param string $old_username The old username of the user
251
- * @param string $new_username The new username of the user
252
- * @return string $content Filtered content
253
- */
254
- function username_changer_do_tags( $content, $old_username = '', $new_username = '' ) {
255
- // Replace all tags
256
- $content = apply_filters( 'username_changer_do_tags', Username_Changer()->template_tags->do_tags( $content, $old_username, $new_username ) );
257
-
258
- return $content;
259
- }
260
-
261
-
262
- /**
263
- * Load tags
264
- *
265
- * @since 3.0.0
266
- * @return void
267
- */
268
- function username_changer_load_template_tags() {
269
- do_action( 'username_changer_add_template_tags' );
270
- }
271
- add_action( 'init', 'username_changer_load_template_tags', -999 );
272
-
273
-
274
- /**
275
- * Add default tags
276
- *
277
- * @since 3.0.0
278
- * @return void
279
- */
280
- function username_changer_setup_template_tags() {
281
- // Setup default tags array
282
- $tags = array(
283
- array(
284
- 'tag' => 'old_username',
285
- 'desc' => __( 'The original username of the user', 'username-changer' ),
286
- 'context' => array( 'email', 'message' ),
287
- 'func' => 'username_changer_template_tag_old_username'
288
- ),
289
- array(
290
- 'tag' => 'new_username',
291
- 'desc' => __( 'The new username of the user', 'username-changer' ),
292
- 'context' => array( 'email', 'message' ),
293
- 'func' => 'username_changer_template_tag_new_username'
294
- ),
295
- array(
296
- 'tag' => 'email',
297
- 'desc' => __( 'The email address of the user', 'username-changer' ),
298
- 'context' => array( 'email' ),
299
- 'func' => 'username_changer_template_tag_email'
300
- ),
301
- array(
302
- 'tag' => 'sitename',
303
- 'desc' => __( 'Your site name', 'username-changer' ),
304
- 'context' => array( 'email' ),
305
- 'func' => 'username_changer_template_tag_sitename'
306
- ),
307
- array(
308
- 'tag' => 'siteurl',
309
- 'desc' => __( 'Your site URL', 'username-changer' ),
310
- 'context' => array( 'email' ),
311
- 'func' => 'username_changer_template_tag_siteurl'
312
- ),
313
- array(
314
- 'tag' => 'loginurl',
315
- 'desc' => __( 'The login URL for your site', 'username-changer' ),
316
- 'context' => array( 'email' ),
317
- 'func' => 'username_changer_template_tag_loginurl'
318
- ),
319
- array(
320
- 'tag' => 'date',
321
- 'desc' => __( 'Today\'s date', 'username-changer' ),
322
- 'context' => array( 'email' ),
323
- 'func' => 'username_changer_template_tag_date'
324
- ),
325
- array(
326
- 'tag' => 'name',
327
- 'desc' => __( 'The first name of the user', 'username-changer' ),
328
- 'context' => array( 'email' ),
329
- 'func' => 'username_changer_template_tag_name'
330
- ),
331
- array(
332
- 'tag' => 'fullname',
333
- 'desc' => __( 'The full name of the user, first and last', 'username-changer' ),
334
- 'context' => array( 'email' ),
335
- 'func' => 'username_changer_template_tag_fullname'
336
- ),
337
- array(
338
- 'tag' => 'minlength',
339
- 'desc' => __( 'The minimum allowed username length', 'username-changer' ),
340
- 'context' => array( 'message' ),
341
- 'func' => 'username_changer_template_tag_minlength'
342
- )
343
- );
344
-
345
- $tags = apply_filters( 'username_changer_template_tags', $tags );
346
-
347
- foreach ( $tags as $tag ) {
348
- username_changer_add_template_tag( $tag['tag'], $tag['desc'], $tag['context'], $tag['func'] );
349
- }
350
- }
351
- add_action( 'username_changer_add_template_tags', 'username_changer_setup_template_tags' );
352
-
353
-
354
- /**
355
- * Template tag: old_username
356
- *
357
- * @since 3.0.0
358
- * @param string $old_username The old username of the user
359
- * @param string $new_username The new username of the user
360
- * @return string $username The original username of the user
361
- */
362
- function username_changer_template_tag_old_username( $old_username, $new_username ) {
363
- $current_user = wp_get_current_user();
364
- $username = $current_user->user_login;
365
-
366
- return '<strong>' . $username . '</strong>';
367
- }
368
-
369
-
370
- /**
371
- * Template tag: new_username
372
- *
373
- * @since 3.0.0
374
- * @param string $old_username The old username of the user
375
- * @param string $new_username The new username of the user
376
- * @return string $username The new username of the user
377
- */
378
- function username_changer_template_tag_new_username( $old_username, $new_username ) {
379
- return '<strong>' . $new_username . '</strong>';
380
- }
381
-
382
-
383
- /**
384
- * Template tag: email
385
- *
386
- * @since 3.0.0
387
- * @param string $old_username The old username of the user
388
- * @param string $new_username The new username of the user
389
- * @return string $email The email address of the user
390
- */
391
- function username_changer_template_tag_email( $old_username, $new_username ) {
392
- $current_user = wp_get_current_user();
393
- $email = $current_user->user_email;
394
-
395
- return $email;
396
- }
397
-
398
-
399
- /**
400
- * Template tag: sitename
401
- *
402
- * @since 3.0.0
403
- * @param string $old_username The old username of the user
404
- * @param string $new_username The new username of the user
405
- * @return string Site name
406
- */
407
- function username_changer_template_tag_sitename( $old_username, $new_username ) {
408
- return get_bloginfo( 'name' );
409
- }
410
-
411
-
412
- /**
413
- * Template tag: siteurl
414
- *
415
- * @since 3.0.0
416
- * @param string $old_username The old username of the user
417
- * @param string $new_username The new username of the user
418
- * @return string Site URL
419
- */
420
- function username_changer_template_tag_siteurl( $old_username, $new_username ) {
421
- return get_site_url();
422
- }
423
-
424
-
425
- /**
426
- * Template tag: loginurl
427
- *
428
- * @since 3.0.0
429
- * @param string $old_username The old username of the user
430
- * @param string $new_username The new username of the user
431
- * @return string Site URL
432
- */
433
- function username_changer_template_tag_loginurl( $old_username, $new_username ) {
434
- return wp_login_url();
435
- }
436
-
437
-
438
- /**
439
- * Template tag: date
440
- *
441
- * @since 3.0.0
442
- * @param string $old_username The old username of the user
443
- * @param string $new_username The new username of the user
444
- * @return string The purchase date
445
- */
446
- function username_changer_template_tag_date( $old_username, $new_username ) {
447
- return date_i18n( get_option( 'date_format' ), strtotime( date( 'U' ) ) );
448
- }
449
-
450
-
451
- /**
452
- * Template tag: name
453
- *
454
- * @since 3.0.0
455
- * @param string $old_username The old username of the user
456
- * @param string $new_username The new username of the user
457
- * @return string $name The first name of the user
458
- */
459
- function username_changer_template_tag_name( $old_username, $new_username ) {
460
- $current_user = get_user_by( 'login', $new_username );
461
-
462
- if ( isset( $current_user->user_firstname ) ) {
463
- $name = $current_user->user_firstname;
464
- } else {
465
- $name = $current_user->user_email;
466
- }
467
-
468
- return $name;
469
- }
470
-
471
-
472
- /**
473
- * Template tag: fullname
474
- *
475
- * @since 3.0.0
476
- * @param string $old_username The old username of the user
477
- * @param string $new_username The new username of the user
478
- * @return string $name The full name of the user
479
- */
480
- function username_changer_template_tag_fullname( $old_username, $new_username ) {
481
- $current_user = get_user_by( 'login', $new_username );
482
-
483
- if ( isset( $current_user->user_firstname ) && isset( $current_user->user_lastname ) ) {
484
- $name = $current_user->user_firstname . ' ' . $current_user->user_lastname;
485
- } elseif ( isset( $current_user->user_firstname ) ) {
486
- $name = $current_user->user_firstname;
487
- } else {
488
- $name = $current_user->user_email;
489
- }
490
-
491
- return $name;
492
- }
493
-
494
-
495
- /**
496
- * Template tag: minlength
497
- *
498
- * @since 3.0.0
499
- * @param string $old_username The old username of the user
500
- * @param string $new_username The new username of the user
501
- * @return string $minlength The minimum username length
502
- */
503
- function username_changer_template_tag_minlength( $old_username, $new_username ) {
504
- return username_changer()->settings->get_option( 'minimum_length', 3 );
505
- }
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template tags
4
+ *
5
+ * @package UsernameChanger\TemplateTags
6
+ * @since 3.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Template tag class
17
+ *
18
+ * @since 3.0.0
19
+ */
20
+ class Username_Changer_Template_Tags {
21
+
22
+
23
+ /**
24
+ * Container for storing all tags
25
+ *
26
+ * @access private
27
+ * @since 3.0.0
28
+ * @var array $tags Container for storing all tags
29
+ */
30
+ private $tags;
31
+
32
+
33
+ /**
34
+ * The old username of the user
35
+ *
36
+ * @access private
37
+ * @since 3.0.0
38
+ * @var string $old_username The old username of the user
39
+ */
40
+ private $old_username;
41
+
42
+
43
+ /**
44
+ * The new username of the user
45
+ *
46
+ * @access private
47
+ * @since 3.0.0
48
+ * @var string $new_username The new username of the user
49
+ */
50
+ private $new_username;
51
+
52
+
53
+ /**
54
+ * Add a template tag
55
+ *
56
+ * @access public
57
+ * @since 3.0.0
58
+ * @param string $tag Tag to be replaced.
59
+ * @param string $desc Description of the tag.
60
+ * @param array $context Context for the tag.
61
+ * @param string $func The hook to run when tag is found.
62
+ * @return void
63
+ */
64
+ public function add( $tag, $desc, $context, $func ) {
65
+ if ( is_callable( $func ) ) {
66
+ $this->tags[ $tag ] = array(
67
+ 'tag' => $tag,
68
+ 'desc' => $desc,
69
+ 'context' => $context,
70
+ 'func' => $func,
71
+ );
72
+ }
73
+ }
74
+
75
+
76
+ /**
77
+ * Remove a template tag
78
+ *
79
+ * @access public
80
+ * @since 3.0.0
81
+ * @param string $tag Tag to be removed.
82
+ * @return void
83
+ */
84
+ public function remove( $tag ) {
85
+ unset( $this->tags[ $tag ] );
86
+ }
87
+
88
+
89
+ /**
90
+ * Check if $tag is a registered template tag
91
+ *
92
+ * @access public
93
+ * @since 3.0.0
94
+ * @param string $tag Tag to search for.
95
+ * @return bool True if found, false otherwise
96
+ */
97
+ public function template_tag_exists( $tag ) {
98
+ return array_key_exists( $tag, $this->tags );
99
+ }
100
+
101
+
102
+ /**
103
+ * Returns a list of all tags
104
+ *
105
+ * @access public
106
+ * @since 3.0.0
107
+ * @param string $context The context to return tags for.
108
+ * @return array $tags The available tags
109
+ */
110
+ public function get_tags( $context ) {
111
+ $tags = $this->tags;
112
+
113
+ foreach ( $tags as $tag_id => $tag_data ) {
114
+ if ( ! in_array( $context, $tag_data['context'], true ) ) {
115
+ unset( $tags[ $tag_id ] );
116
+ }
117
+ }
118
+
119
+ return $tags;
120
+ }
121
+
122
+
123
+ /**
124
+ * Search content for tags and filter through their hooks
125
+ *
126
+ * @access public
127
+ * @since 3.0.0
128
+ * @param string $content Content to search.
129
+ * @param string $old_username The old username of the user.
130
+ * @param string $new_username The new username of the user.
131
+ * @return string $new_content Filtered content
132
+ */
133
+ public function do_tags( $content, $old_username = '', $new_username = '' ) {
134
+ // Ensure there is at least one tag.
135
+ if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
136
+ return $content;
137
+ }
138
+
139
+ $this->old_username = $old_username;
140
+ $this->new_username = $new_username;
141
+
142
+ $new_content = preg_replace_callback( '/{([A-z0-9\-\_]+)}/s', array( $this, 'do_tag' ), $content );
143
+
144
+ $this->old_username = '';
145
+ $this->new_username = '';
146
+
147
+ return $new_content;
148
+ }
149
+
150
+
151
+ /**
152
+ * Do a specific tag
153
+ *
154
+ * @access public
155
+ * @since 3.0.0
156
+ * @param array $m Message.
157
+ * @return mixed
158
+ */
159
+ public function do_tag( $m ) {
160
+ // Get tag.
161
+ $tag = $m[1];
162
+
163
+ // Return tag if tag not set.
164
+ if ( ! $this->template_tag_exists( $tag ) ) {
165
+ return $m[0];
166
+ }
167
+
168
+ return call_user_func( $this->tags[ $tag ]['func'], $this->old_username, $this->new_username, $tag );
169
+ }
170
+ }
171
+
172
+
173
+ /**
174
+ * Add a template tag
175
+ *
176
+ * @since 3.0.0
177
+ * @param string $tag Tag to be replaced.
178
+ * @param string $desc Description of the tag.
179
+ * @param array $context Context for the tag.
180
+ * @param string $func The hook to run when tag is found.
181
+ * @return void
182
+ */
183
+ function username_changer_add_template_tag( $tag, $desc, $context, $func ) {
184
+ Username_Changer()->template_tags->add( $tag, $desc, $context, $func );
185
+ }
186
+
187
+
188
+ /**
189
+ * Remove a template tag
190
+ *
191
+ * @since 3.0.0
192
+ * @param string $tag Template tag to remove.
193
+ * @return void
194
+ */
195
+ function username_changer_remove_template_tag( $tag ) {
196
+ Username_Changer()->template_tags->remove( $tag );
197
+ }
198
+
199
+
200
+ /**
201
+ * Check if a text exists
202
+ *
203
+ * @since 3.0.0
204
+ * @param string $tag The string to check.
205
+ * @return bool True if exists, false otherwise
206
+ */
207
+ function username_changer_tag_exists( $tag ) {
208
+ return Username_Changer()->template_tags->template_tag_exists( $tag );
209
+ }
210
+
211
+
212
+ /**
213
+ * Get all tags
214
+ *
215
+ * @since 3.0.0
216
+ * @param string $context The context to return tags for.
217
+ * @return array The existing tags
218
+ */
219
+ function username_changer_get_template_tags( $context = 'message' ) {
220
+ return Username_Changer()->template_tags->get_tags( $context );
221
+ }
222
+
223
+
224
+ /**
225
+ * Get a formatted list of all available tags
226
+ *
227
+ * @since 3.0.0
228
+ * @param string $context The context to display.
229
+ * @return void
230
+ */
231
+ function username_changer_tags_list( $context = 'message' ) {
232
+ // Get all tags.
233
+ $tags = username_changer_get_template_tags( $context );
234
+
235
+ // Check.
236
+ if ( count( $tags ) > 0 ) {
237
+ ?>
238
+ <ul class="username-changer-template-tag-list">
239
+ <?php
240
+ foreach ( $tags as $tag ) {
241
+ // Add tag to list.
242
+ ?>
243
+ <li class="username-changer-template-tag"><span>{<?php echo esc_attr( $tag['tag'] ); ?>}</span><?php echo esc_attr( $tag['desc'] ); ?></li>
244
+ <?php
245
+ }
246
+ ?>
247
+ </ul>
248
+ <?php
249
+ }
250
+ }
251
+
252
+
253
+ /**
254
+ * Search content for tags and filter
255
+ *
256
+ * @since 3.0.0
257
+ * @param string $content Content to search.
258
+ * @param string $old_username The old username of the user.
259
+ * @param string $new_username The new username of the user.
260
+ * @return string $content Filtered content
261
+ */
262
+ function username_changer_do_tags( $content, $old_username = '', $new_username = '' ) {
263
+ // Replace all tags.
264
+ $content = apply_filters( 'username_changer_do_tags', Username_Changer()->template_tags->do_tags( $content, $old_username, $new_username ) );
265
+
266
+ return $content;
267
+ }
268
+
269
+
270
+ /**
271
+ * Load tags
272
+ *
273
+ * @since 3.0.0
274
+ * @return void
275
+ */
276
+ function username_changer_load_template_tags() {
277
+ do_action( 'username_changer_add_template_tags' );
278
+ }
279
+ add_action( 'init', 'username_changer_load_template_tags', -999 );
280
+
281
+
282
+ /**
283
+ * Add default tags
284
+ *
285
+ * @since 3.0.0
286
+ * @return void
287
+ */
288
+ function username_changer_setup_template_tags() {
289
+ // Setup default tags array.
290
+ $tags = array(
291
+ array(
292
+ 'tag' => 'old_username',
293
+ 'desc' => __( 'The original username of the user', 'username-changer' ),
294
+ 'context' => array( 'email', 'message' ),
295
+ 'func' => 'username_changer_template_tag_old_username',
296
+ ),
297
+ array(
298
+ 'tag' => 'new_username',
299
+ 'desc' => __( 'The new username of the user', 'username-changer' ),
300
+ 'context' => array( 'email', 'message' ),
301
+ 'func' => 'username_changer_template_tag_new_username',
302
+ ),
303
+ array(
304
+ 'tag' => 'email',
305
+ 'desc' => __( 'The email address of the user', 'username-changer' ),
306
+ 'context' => array( 'email' ),
307
+ 'func' => 'username_changer_template_tag_email',
308
+ ),
309
+ array(
310
+ 'tag' => 'sitename',
311
+ 'desc' => __( 'Your site name', 'username-changer' ),
312
+ 'context' => array( 'email' ),
313
+ 'func' => 'username_changer_template_tag_sitename',
314
+ ),
315
+ array(
316
+ 'tag' => 'siteurl',
317
+ 'desc' => __( 'Your site URL', 'username-changer' ),
318
+ 'context' => array( 'email' ),
319
+ 'func' => 'username_changer_template_tag_siteurl',
320
+ ),
321
+ array(
322
+ 'tag' => 'loginurl',
323
+ 'desc' => __( 'The login URL for your site', 'username-changer' ),
324
+ 'context' => array( 'email' ),
325
+ 'func' => 'username_changer_template_tag_loginurl',
326
+ ),
327
+ array(
328
+ 'tag' => 'date',
329
+ 'desc' => __( 'Today\'s date', 'username-changer' ),
330
+ 'context' => array( 'email' ),
331
+ 'func' => 'username_changer_template_tag_date',
332
+ ),
333
+ array(
334
+ 'tag' => 'name',
335
+ 'desc' => __( 'The first name of the user', 'username-changer' ),
336
+ 'context' => array( 'email' ),
337
+ 'func' => 'username_changer_template_tag_name',
338
+ ),
339
+ array(
340
+ 'tag' => 'fullname',
341
+ 'desc' => __( 'The full name of the user, first and last', 'username-changer' ),
342
+ 'context' => array( 'email' ),
343
+ 'func' => 'username_changer_template_tag_fullname',
344
+ ),
345
+ array(
346
+ 'tag' => 'minlength',
347
+ 'desc' => __( 'The minimum allowed username length', 'username-changer' ),
348
+ 'context' => array( 'message' ),
349
+ 'func' => 'username_changer_template_tag_minlength',
350
+ ),
351
+ );
352
+
353
+ $tags = apply_filters( 'username_changer_template_tags', $tags );
354
+
355
+ foreach ( $tags as $tag ) {
356
+ username_changer_add_template_tag( $tag['tag'], $tag['desc'], $tag['context'], $tag['func'] );
357
+ }
358
+ }
359
+ add_action( 'username_changer_add_template_tags', 'username_changer_setup_template_tags' );
360
+
361
+
362
+ /**
363
+ * Template tag: old_username
364
+ *
365
+ * @since 3.0.0
366
+ * @param string $old_username The old username of the user.
367
+ * @param string $new_username The new username of the user.
368
+ * @return string $username The original username of the user
369
+ */
370
+ function username_changer_template_tag_old_username( $old_username, $new_username ) {
371
+ $current_user = wp_get_current_user();
372
+ $username = $current_user->user_login;
373
+
374
+ return '<strong>' . $username . '</strong>';
375
+ }
376
+
377
+
378
+ /**
379
+ * Template tag: new_username
380
+ *
381
+ * @since 3.0.0
382
+ * @param string $old_username The old username of the user.
383
+ * @param string $new_username The new username of the user.
384
+ * @return string $username The new username of the user
385
+ */
386
+ function username_changer_template_tag_new_username( $old_username, $new_username ) {
387
+ return '<strong>' . $new_username . '</strong>';
388
+ }
389
+
390
+
391
+ /**
392
+ * Template tag: email
393
+ *
394
+ * @since 3.0.0
395
+ * @param string $old_username The old username of the user.
396
+ * @param string $new_username The new username of the user.
397
+ * @return string $email The email address of the user
398
+ */
399
+ function username_changer_template_tag_email( $old_username, $new_username ) {
400
+ $current_user = wp_get_current_user();
401
+ $email = $current_user->user_email;
402
+
403
+ return $email;
404
+ }
405
+
406
+
407
+ /**
408
+ * Template tag: sitename
409
+ *
410
+ * @since 3.0.0
411
+ * @param string $old_username The old username of the user.
412
+ * @param string $new_username The new username of the user.
413
+ * @return string Site name
414
+ */
415
+ function username_changer_template_tag_sitename( $old_username, $new_username ) {
416
+ return get_bloginfo( 'name' );
417
+ }
418
+
419
+
420
+ /**
421
+ * Template tag: siteurl
422
+ *
423
+ * @since 3.0.0
424
+ * @param string $old_username The old username of the user.
425
+ * @param string $new_username The new username of the user.
426
+ * @return string Site URL
427
+ */
428
+ function username_changer_template_tag_siteurl( $old_username, $new_username ) {
429
+ return get_site_url();
430
+ }
431
+
432
+
433
+ /**
434
+ * Template tag: loginurl
435
+ *
436
+ * @since 3.0.0
437
+ * @param string $old_username The old username of the user.
438
+ * @param string $new_username The new username of the user.
439
+ * @return string Site URL
440
+ */
441
+ function username_changer_template_tag_loginurl( $old_username, $new_username ) {
442
+ return wp_login_url();
443
+ }
444
+
445
+
446
+ /**
447
+ * Template tag: date
448
+ *
449
+ * @since 3.0.0
450
+ * @param string $old_username The old username of the user.
451
+ * @param string $new_username The new username of the user.
452
+ * @return string The purchase date
453
+ */
454
+ function username_changer_template_tag_date( $old_username, $new_username ) {
455
+ return date_i18n( get_option( 'date_format' ), strtotime( gmdate( 'U' ) ) );
456
+ }
457
+
458
+
459
+ /**
460
+ * Template tag: name
461
+ *
462
+ * @since 3.0.0
463
+ * @param string $old_username The old username of the user.
464
+ * @param string $new_username The new username of the user.
465
+ * @return string $name The first name of the user
466
+ */
467
+ function username_changer_template_tag_name( $old_username, $new_username ) {
468
+ $current_user = get_user_by( 'login', $new_username );
469
+
470
+ if ( isset( $current_user->user_firstname ) ) {
471
+ $name = $current_user->user_firstname;
472
+ } else {
473
+ $name = $current_user->user_email;
474
+ }
475
+
476
+ return $name;
477
+ }
478
+
479
+
480
+ /**
481
+ * Template tag: fullname
482
+ *
483
+ * @since 3.0.0
484
+ * @param string $old_username The old username of the user.
485
+ * @param string $new_username The new username of the user.
486
+ * @return string $name The full name of the user
487
+ */
488
+ function username_changer_template_tag_fullname( $old_username, $new_username ) {
489
+ $current_user = get_user_by( 'login', $new_username );
490
+
491
+ if ( isset( $current_user->user_firstname ) && isset( $current_user->user_lastname ) ) {
492
+ $name = $current_user->user_firstname . ' ' . $current_user->user_lastname;
493
+ } elseif ( isset( $current_user->user_firstname ) ) {
494
+ $name = $current_user->user_firstname;
495
+ } else {
496
+ $name = $current_user->user_email;
497
+ }
498
+
499
+ return $name;
500
+ }
501
+
502
+
503
+ /**
504
+ * Template tag: minlength
505
+ *
506
+ * @since 3.0.0
507
+ * @param string $old_username The old username of the user.
508
+ * @param string $new_username The new username of the user.
509
+ * @return string $minlength The minimum username length
510
+ */
511
+ function username_changer_template_tag_minlength( $old_username, $new_username ) {
512
+ return username_changer()->settings->get_option( 'minimum_length', 3 );
513
+ }
includes/libraries/s214-settings/.editorconfig DELETED
@@ -1,29 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- * text=auto
2
- /tests export-ignore
 
 
includes/libraries/s214-settings/.gitignore DELETED
@@ -1,36 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,34 +0,0 @@
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 DELETED
@@ -1,36 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- source:
2
- - ./
3
-
4
- destination: codex
 
 
 
 
includes/libraries/s214-settings/composer.json DELETED
@@ -1,27 +0,0 @@
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 DELETED
@@ -1,281 +0,0 @@
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.min.css DELETED
@@ -1 +0,0 @@
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/js/admin.min.js DELETED
@@ -1 +0,0 @@
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 DELETED
@@ -1,1276 +0,0 @@
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
- add_filter( "pre_update_option_{$this->func}_settings", array( $this, 'multicheck_empty_validation' ), 10, 3 );
129
- }
130
-
131
-
132
- /**
133
- * Add settings pages
134
- *
135
- * @access public
136
- * @since 1.0.0
137
- * @global string ${this->func . '_settings_page'} The settings page slug
138
- * @return void
139
- */
140
- public function add_settings_page() {
141
- global ${$this->func . '_settings_page'};
142
-
143
- $menu = apply_filters( $this->func . '_menu', array(
144
- 'type' => 'menu',
145
- 'parent' => 'options-general.php',
146
- 'page_title' => __( 'Section214 Settings', 's214' ),
147
- 'show_title' => false,
148
- 'menu_title' => __( 'Section214 Settings', 's214' ),
149
- 'capability' => 'manage_options',
150
- 'icon' => '',
151
- 'position' => null
152
- ) );
153
-
154
- $this->show_title = $menu['show_title'];
155
- $this->page_title = $menu['page_title'];
156
-
157
- if( $menu['type'] == 'submenu' ) {
158
- ${$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' ) );
159
- } else {
160
- ${$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'] );
161
- }
162
- }
163
-
164
-
165
- /**
166
- * Render settings page
167
- *
168
- * @access public
169
- * @since 1.0.0
170
- * @return void
171
- */
172
- public function render_settings_page() {
173
- $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->get_settings_tabs() ) ? $_GET['tab'] : $this->default_tab;
174
- $sections = $registered_sections = $this->get_settings_tab_sections( $active_tab );
175
- $key = 'main';
176
-
177
- if( is_array( $sections ) ) {
178
- $key = key( $sections );
179
- }
180
-
181
- $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
182
-
183
- ob_start();
184
- ?>
185
- <div class="wrap">
186
- <?php if( $this->show_title ) { ?>
187
- <h2><?php echo $this->page_title; ?></h2>
188
- <?php } ?>
189
- <h2 class="nav-tab-wrapper">
190
- <?php
191
- foreach( $this->get_settings_tabs() as $tab_id => $tab_name ) {
192
- $tab_url = add_query_arg( array(
193
- 'settings-updated' => false,
194
- 'tab' => $tab_id
195
- ) );
196
-
197
- // Remove the section from the tabs so we always end up at the main section
198
- $tab_url = remove_query_arg( 'section', $tab_url );
199
-
200
- $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
201
-
202
- echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">' . esc_html( $tab_name ) . '</a>';
203
- }
204
- ?>
205
- </h2>
206
- <?php
207
- $number_of_sections = count( $sections );
208
- $number = 0;
209
-
210
- if( $number_of_sections > 1 ) {
211
- echo '<div><ul class="subsubsub">';
212
-
213
- foreach( $sections as $section_id => $section_name ) {
214
- echo '<li>';
215
-
216
- $number++;
217
- $tab_url = add_query_arg( array(
218
- 'settings-updated' => false,
219
- 'tab' => $active_tab,
220
- 'section' => $section_id
221
- ) );
222
- $class = '';
223
-
224
- if( $section == $section_id ) {
225
- $class = 'current';
226
- }
227
-
228
- echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
229
-
230
- if( $number != $number_of_sections ) {
231
- echo ' | ';
232
- }
233
-
234
- echo '</li>';
235
- }
236
-
237
- echo '</ul></div>';
238
- }
239
- ?>
240
- <div id="tab_container">
241
- <form method="post" action="options.php">
242
- <table class="form-table">
243
- <?php
244
- settings_fields( $this->func . '_settings' );
245
-
246
- do_action( $this->func . '_settings_tab_top_' . $active_tab . '_' . $section );
247
-
248
- do_settings_sections( $this->func . '_settings_' . $active_tab . '_' . $section );
249
-
250
- do_action( $this->func . '_settings_tab_bottom_' . $active_tab . '_' . $section );
251
- ?>
252
- </table>
253
- <?php
254
- if( ! in_array( $active_tab, apply_filters( $this->func . '_unsavable_tabs', array() ) ) ) {
255
- submit_button();
256
- }
257
- ?>
258
- </form>
259
- </div>
260
- </div>
261
- <?php
262
- echo ob_get_clean();
263
- }
264
-
265
-
266
- /**
267
- * Retrieve the settings tabs
268
- *
269
- * @access private
270
- * @since 1.0.0
271
- * @return array $tabs The registered tabs for this plugin
272
- */
273
- private function get_settings_tabs() {
274
- return apply_filters( $this->func . '_settings_tabs', array() );
275
- }
276
-
277
-
278
- /**
279
- * Retrieve settings tab sections
280
- *
281
- * @access public
282
- * @since 1.0.1
283
- * @param string $tab The current tab
284
- * @return array $section The section items
285
- */
286
- public function get_settings_tab_sections( $tab = false ) {
287
- $tabs = false;
288
- $sections = $this->get_registered_settings_sections();
289
-
290
- if( $tab && ! empty( $sections[$tab] ) ) {
291
- $tabs = $sections[$tab];
292
- } elseif( $tab ) {
293
- $tabs = false;
294
- }
295
-
296
- return $tabs;
297
- }
298
-
299
-
300
- /**
301
- * Retrieve the plugin settings
302
- *
303
- * @access public
304
- * @since 1.0.0
305
- * @return array $settings The plugin settings
306
- */
307
- public function get_registered_settings() {
308
- return apply_filters( $this->func . '_registered_settings', array() );
309
- }
310
-
311
-
312
- /**
313
- * Retrieve the plugin settings sections
314
- *
315
- * @access private
316
- * @since 1.0.1
317
- * @return array $sections The registered sections
318
- */
319
- private function get_registered_settings_sections() {
320
- global ${$this->func . '_sections'};
321
-
322
- if ( !empty( ${$this->func . '_sections'} ) ) {
323
- return ${$this->func . '_sections'};
324
- }
325
-
326
- ${$this->func . '_sections'} = apply_filters( $this->func . '_registered_settings_sections', array() );
327
-
328
- return ${$this->func . '_sections'};
329
- }
330
-
331
-
332
- /**
333
- * Retrieve an option
334
- *
335
- * @access public
336
- * @since 1.0.0
337
- * @param string $key The key to retrieve
338
- * @param mixed $default The default value if key doesn't exist
339
- * @global array ${$this->func . '_options'} The options array
340
- * @return mixed $value The value to return
341
- */
342
- public function get_option( $key = '', $default = false ) {
343
- global ${$this->func . '_options'};
344
-
345
- $value = ! empty( ${$this->func . '_options'}[$key] ) ? ${$this->func . '_options'}[$key] : $default;
346
- $value = apply_filters( $this->func . '_get_option', $value, $key, $default );
347
-
348
- return apply_filters( $this->func . '_get_option_' . $key, $value, $key, $default );
349
- }
350
-
351
-
352
- /**
353
- * Update an option
354
- *
355
- * @access public
356
- * @since 1.0.0
357
- * @param string $key The key to update
358
- * @param mixed $value The value to set key to
359
- * @return bool true if updated, false otherwise
360
- */
361
- public function update_option( $key = '', $value = false ) {
362
- // Bail if no key is set
363
- if( empty( $key ) ) {
364
- return false;
365
- }
366
-
367
- if( empty( $value ) ) {
368
- $remove_option = $this->delete_option( $key );
369
- return $remove_option;
370
- }
371
-
372
- // Fetch a clean copy of the options array
373
- $options = get_option( $this->func . '_settings' );
374
-
375
- // Allow devs to modify the value
376
- $value = apply_filters( $this->func . '_update_option', $value, $key );
377
-
378
- // Try to update the option
379
- $options[$key] = $value;
380
- $did_update = update_option( $this->func . '_settings', $options );
381
-
382
- // Update the global
383
- if( $did_update ) {
384
- global ${$this->func . '_options'};
385
- ${$this->func . '_options'}[$key] = $value;
386
- }
387
-
388
- return $did_update;
389
- }
390
-
391
-
392
- /**
393
- * Delete an option
394
- *
395
- * @access public
396
- * @since 1.0.0
397
- * @param string $key The key to delete
398
- * @return bool true if deleted, false otherwise
399
- */
400
- public function delete_option( $key = '' ) {
401
- // Bail if no key is set
402
- if( empty( $key ) ) {
403
- return false;
404
- }
405
-
406
- // Fetch a clean copy of the options array
407
- $options = get_option( $this->func . '_settings' );
408
-
409
- // Try to unset the option
410
- if( isset( $options[$key] ) ) {
411
- unset( $options[$key] );
412
- }
413
-
414
- $did_update = update_option( $this->func . '_settings', $options );
415
-
416
- // Update the global
417
- if( $did_update ) {
418
- global ${$this->func . '_options'};
419
- ${$this->func . '_options'} = $options;
420
- }
421
-
422
- return $did_update;
423
- }
424
-
425
-
426
- /**
427
- * Retrieve all options
428
- *
429
- * @access public
430
- * @since 1.0.0
431
- * @return array $settings The options array
432
- */
433
- public function get_settings() {
434
- $settings = get_option( $this->func . '_settings' );
435
-
436
- if( empty( $settings ) ) {
437
- $settings = array();
438
-
439
- update_option( $this->func . '_settings', $settings );
440
- }
441
-
442
- return apply_filters( $this->func . '_get_settings', $settings );
443
- }
444
-
445
-
446
- /**
447
- * Add settings sections and fields
448
- *
449
- * @access public
450
- * @since 1.0.0
451
- * @return void
452
- */
453
- function register_settings() {
454
- if( get_option( $this->func . '_settings' ) == false ) {
455
- add_option( $this->func . '_settings' );
456
- }
457
-
458
- foreach( $this->get_registered_settings() as $tab => $sections ) {
459
- foreach( $sections as $section => $settings ) {
460
- // Check for backwards compatibility
461
- $section_tabs = $this->get_settings_tab_sections( $tab );
462
-
463
- if( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
464
- $section = 'main';
465
- $settings = $sections;
466
- }
467
-
468
- add_settings_section(
469
- $this->func . '_settings_' . $tab . '_' . $section,
470
- __return_null(),
471
- '__return_false',
472
- $this->func . '_settings_' . $tab . '_' . $section
473
- );
474
-
475
- foreach( $settings as $option ) {
476
- // For backwards compatibility
477
- if( empty( $option['id'] ) ) {
478
- continue;
479
- }
480
-
481
- $name = isset( $option['name'] ) ? $option['name'] : '';
482
-
483
- add_settings_field(
484
- $this->func . '_settings[' . $option['id'] . ']',
485
- $name,
486
- 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' ) ),
487
- $this->func . '_settings_' . $tab . '_' . $section,
488
- $this->func . '_settings_' . $tab . '_' . $section,
489
- array(
490
- 'section' => $section,
491
- 'id' => isset( $option['id'] ) ? $option['id'] : null,
492
- 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
493
- 'name' => isset( $option['name'] ) ? $option['name'] : null,
494
- 'size' => isset( $option['size'] ) ? $option['size'] : null,
495
- 'options' => isset( $option['options'] ) ? $option['options'] : '',
496
- 'std' => isset( $option['std'] ) ? $option['std'] : '',
497
- 'min' => isset( $option['min'] ) ? $option['min'] : null,
498
- 'max' => isset( $option['max'] ) ? $option['max'] : null,
499
- 'step' => isset( $option['step'] ) ? $option['step'] : null,
500
- 'select2' => isset( $option['select2'] ) ? $option['select2'] : null,
501
- 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
502
- 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : null,
503
- 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
504
- 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
505
- 'buttons' => isset( $option['buttons'] ) ? $option['buttons'] : null,
506
- 'wpautop' => isset( $option['wpautop'] ) ? $option['wpautop'] : null,
507
- 'teeny' => isset( $option['teeny'] ) ? $option['teeny'] : null,
508
- 'tab' => isset( $option['tab'] ) ? $option['tab'] : null,
509
- 'tooltip_title' => isset( $option['tooltip_title'] ) ? $option['tooltip_title'] : false,
510
- 'tooltip_desc' => isset( $option['tooltip_desc'] ) ? $option['tooltip_desc'] : false
511
- )
512
- );
513
- }
514
- }
515
- }
516
-
517
- register_setting( $this->func . '_settings', $this->func . '_settings', array( $this, 'settings_sanitize' ) );
518
- }
519
-
520
-
521
- /**
522
- * Settings sanitization
523
- *
524
- * @access public
525
- * @since 1.0.0
526
- * @param array $input The value entered in the field
527
- * @global array ${$this->func . '_options'} The options array
528
- * @return string $input The sanitized value
529
- */
530
- public function settings_sanitize( $input = array() ) {
531
- global ${$this->func . '_options'};
532
-
533
- $doing_section = false;
534
-
535
- if( ! empty( $_POST['_wp_http_referer'] ) ) {
536
- $doing_section = true;
537
- }
538
-
539
- $setting_types = $this->get_registered_settings_types();
540
- $input = $input ? $input : array();
541
-
542
- if( $doing_section ) {
543
- parse_str( $_POST['_wp_http_referer'], $referrer );
544
-
545
- $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : $this->default_tab;
546
- $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
547
- $input = apply_filters( $this->func . '_settings_' . $tab . '_sanitize', $input );
548
- $input = apply_filters( $this->func . '_settings_' . $tab . '-' . $section . '_sanitize', $input );
549
- }
550
-
551
- $output = array_merge( ${$this->func . '_options'}, $input );
552
-
553
- foreach( $setting_types as $key => $type ) {
554
- if( empty( $type ) ) {
555
- continue;
556
- }
557
-
558
- // Bypass non-setting settings
559
- $non_setting_types = apply_filters( $this->func . '_non_setting_types', array(
560
- 'header', 'descriptive_text', 'hook'
561
- ) );
562
-
563
- if( in_array( $type, $non_setting_types ) ) {
564
- continue;
565
- }
566
-
567
- if( array_key_exists( $key, $output ) ) {
568
- $output[$key] = apply_filters( $this->func . '_settings_sanitize_' . $type, $output[$key], $key );
569
- $output[$key] = apply_filters( $this->func . '_settings_sanitize', $output[$key], $key );
570
- }
571
-
572
- if( $doing_section ) {
573
- switch( $type ) {
574
- case 'checkbox':
575
- if( array_key_exists( $key, $input ) && $output[$key] === '-1' ) {
576
- unset( $output[$key] );
577
- }
578
- break;
579
- default:
580
- if( array_key_exists( $key, $input ) && empty( $input[$key] ) ) {
581
- unset( $output[$key] );
582
- }
583
- break;
584
- }
585
- } else {
586
- if( empty( $input[$key] ) ) {
587
- unset( $output[$key] );
588
- }
589
- }
590
- }
591
-
592
- if( $doing_section ) {
593
- add_settings_error( $this->slug . '-notices', '', __( 'Settings updated.', 's214-settings' ), 'updated' );
594
- }
595
-
596
- return $output;
597
- }
598
-
599
-
600
- /**
601
- * Flattens the set of registered settings and their type so we can easily sanitize all settings
602
- *
603
- * @since 1.2.0
604
- * @return array Key is the setting ID, value is the type of setting it is registered as
605
- */
606
- function get_registered_settings_types() {
607
- $settings = $this->get_registered_settings();
608
- $setting_types = array();
609
-
610
- foreach( $settings as $tab ) {
611
- foreach( $tab as $section_or_setting ) {
612
- // See if we have a setting registered at the tab level for backwards compatibility
613
- if( is_array( $section_or_setting ) && array_key_exists( 'type', $section_or_setting ) ) {
614
- $setting_types[$section_or_setting['id']] = $section_or_setting['type'];
615
- continue;
616
- }
617
-
618
- foreach( $section_or_setting as $section => $section_settings ) {
619
- $setting_types[$section_settings['id']] = $section_settings['type'];
620
- }
621
- }
622
- }
623
-
624
- return $setting_types;
625
- }
626
-
627
-
628
- /**
629
- * Sanitize text fields
630
- *
631
- * @access public
632
- * @since 1.0.0
633
- * @param array $input The value entered in the field
634
- * @return string $input The sanitized value
635
- */
636
- public function sanitize_text_field( $input ) {
637
- return trim( wp_strip_all_tags( $input, true ) );
638
- }
639
-
640
-
641
- /**
642
- * Header callback
643
- *
644
- * @access public
645
- * @since 1.0.0
646
- * @param array $args Arguments passed by the setting
647
- * @return void
648
- */
649
- public function header_callback( $args ) {
650
- echo '<hr />';
651
- }
652
-
653
-
654
- /**
655
- * Checkbox callback
656
- *
657
- * @access public
658
- * @since 1.0.0
659
- * @param array $args Arguments passed by the setting
660
- * @global array ${$this->func . '_options'} The plugin options
661
- * @return void
662
- */
663
- public function checkbox_callback( $args ) {
664
- global ${$this->func . '_options'};
665
-
666
- $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
667
- $checked = isset( ${$this->func . '_options'}[$args['id']] ) ? checked( 1, ${$this->func . '_options'}[$args['id']], false ) : '';
668
-
669
- $html = '<input type="hidden"' . $name . ' value="-1" />';
670
- $html .= '<input type="checkbox" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="1" ' . $checked . '/>&nbsp;';
671
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
672
-
673
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
674
- }
675
-
676
-
677
- /**
678
- * Color callback
679
- *
680
- * @access public
681
- * @since 1.0.0
682
- * @param array $args Arguments passed by the settings
683
- * @global array ${$this->func . '_options'} The Beacon options
684
- * @return void
685
- */
686
- public function color_callback( $args ) {
687
- global ${$this->func . '_options'};
688
-
689
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
690
- $value = ${$this->func . '_options'}[$args['id']];
691
- } else {
692
- $value = isset( $args['std'] ) ? $args['std'] : '';
693
- }
694
-
695
- $default = isset( $args['std'] ) ? $args['std'] : '';
696
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
697
-
698
- $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;';
699
- $html .= '<span class="s214-color-picker-label description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
700
-
701
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
702
- }
703
-
704
-
705
- /**
706
- * Descriptive text callback
707
- *
708
- * @access public
709
- * @since 1.0.0
710
- * @param array $args Arguments passed by the setting
711
- * @return void
712
- */
713
- public function descriptive_text_callback( $args ) {
714
- $html = wp_kses_post( $args['desc'] );
715
-
716
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
717
- }
718
-
719
-
720
- /**
721
- * Editor callback
722
- *
723
- * @access public
724
- * @since 1.0.0
725
- * @param array $args Arguments passed by the setting
726
- * @global array ${$this->func . '_options'} The Beacon options
727
- * @return void
728
- */
729
- public function editor_callback( $args ) {
730
- global ${$this->func . '_options'};
731
-
732
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
733
- $value = ${$this->func . '_options'}[$args['id']];
734
-
735
- if( empty( $args['allow_blank'] ) && empty( $value ) ) {
736
- $value = isset( $args['std'] ) ? $args['std'] : '';
737
- }
738
- } else {
739
- $value = isset( $args['std'] ) ? $args['std'] : '';
740
- }
741
-
742
- $rows = isset( $args['size'] ) ? $args['size'] : '10';
743
- $wpautop = isset( $args['wpautop'] ) ? $args['wpautop'] : true;
744
- $buttons = isset( $args['buttons'] ) ? $args['buttons'] : true;
745
- $teeny = isset( $args['teeny'] ) ? $args['teeny'] : false;
746
-
747
- wp_editor(
748
- $value,
749
- $this->func . '_settings_' . $args['id'],
750
- array(
751
- 'wpautop' => $wpautop,
752
- 'media_buttons' => $buttons,
753
- 'textarea_name' => $this->func . '_settings[' . $args['id'] . ']',
754
- 'textarea_rows' => $rows,
755
- 'teeny' => $teeny
756
- )
757
- );
758
- $html = '<br /><span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
759
-
760
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
761
- }
762
-
763
-
764
- /**
765
- * HTML callback
766
- *
767
- * @since 1.0.0
768
- * @param array $args Arguments passed by the setting
769
- * @global array ${$this->func . '_options'} The Beacon options
770
- * @return void
771
- */
772
- public function html_callback( $args ) {
773
- global ${$this->func . '_options'};
774
-
775
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
776
- $value = ${$this->func . '_options'}[$args['id']];
777
- } else {
778
- $value = isset( $args['std'] ) ? $args['std'] : '';
779
- }
780
-
781
- $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;';
782
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
783
-
784
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
785
- }
786
-
787
-
788
- /**
789
- * Multicheck callback
790
- *
791
- * @access public
792
- * @since 1.0.0
793
- * @param array $args Arguments passed by the setting
794
- * @global array ${$this->func . '_options'} The Beacon options
795
- * @return void
796
- */
797
- public function multicheck_callback( $args ) {
798
- global ${$this->func . '_options'};
799
-
800
- if( ! empty( $args['options'] ) ) {
801
- $html = '';
802
-
803
- $html .= '<input type="hidden" name="' . $this->func . '_settings[_multicheck_fields][' . $args['id'] . ']' . '" value="' . $args['id'] . '">';
804
-
805
- foreach( $args['options'] as $key => $option ) {
806
- if( isset( ${$this->func . '_options'}[$args['id']][$key] ) ) {
807
- $enabled = $option;
808
- } else {
809
- $enabled = isset( $args['std'][$key] ) ? $args['std'][$key] : NULL;
810
- }
811
-
812
- $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;';
813
- $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
814
- }
815
- $html .= '<span class="description">' . $args['desc'] . '</span>';
816
-
817
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
818
- }
819
- }
820
-
821
-
822
- /**
823
- * Number callback
824
- *
825
- * @access public
826
- * @since 1.0.0
827
- * @param array $args Arguments passed by the setting
828
- * @global array ${$this->func . '_options'} The Beacon options
829
- * @return void
830
- */
831
- public function number_callback( $args ) {
832
- global ${$this->func . '_options'};
833
-
834
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
835
- $value = ${$this->func . '_options'}[$args['id']];
836
- } else {
837
- $value = isset( $args['std'] ) ? $args['std'] : '';
838
- }
839
-
840
- $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
841
- $max = isset( $args['max'] ) ? $args['max'] : 999999;
842
- $min = isset( $args['min'] ) ? $args['min'] : 0;
843
- $step = isset( $args['step'] ) ? $args['step'] : 1;
844
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
845
- $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
846
-
847
- $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;';
848
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
849
-
850
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
851
- }
852
-
853
-
854
- /**
855
- * Password callback
856
- *
857
- * @access public
858
- * @since 1.0.0
859
- * @param array $args Arguments passed by the settings
860
- * @global array ${$this->func . '_options'} The Beacon options
861
- * @return void
862
- */
863
- public function password_callback( $args ) {
864
- global ${$this->func . '_options'};
865
-
866
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
867
- $value = ${$this->func . '_options'}[$args['id']];
868
- } else {
869
- $value = isset( $args['std'] ) ? $args['std'] : '';
870
- }
871
-
872
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
-
874
- $html = '<input type="password" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" />&nbsp;';
875
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
876
-
877
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
878
- }
879
-
880
-
881
- /**
882
- * Radio callback
883
- *
884
- * @access public
885
- * @since 1.0.0
886
- * @param array $args Arguments passed by the setting
887
- * @global array ${$this->func . '_options'} The Beacon options
888
- * @return void
889
- */
890
- public function radio_callback( $args ) {
891
- global ${$this->func . '_options'};
892
-
893
- if( ! empty( $args['options'] ) ) {
894
- $html = '';
895
-
896
- foreach( $args['options'] as $key => $option ) {
897
- $checked = false;
898
-
899
- if( isset( ${$this->func . '_options'}[$args['id']] ) && ${$this->func . '_options'}[$args['id']] == $key ) {
900
- $checked = true;
901
- } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( ${$this->func . '_options'}[$args['id']] ) ) {
902
- $checked = true;
903
- }
904
-
905
- $html .= '<input name="' . $this->func . '_settings[' . $args['id'] . ']" id="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
906
- $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
907
- }
908
-
909
- $html .= '<p class="description">' . $args['desc'] . '</p>';
910
-
911
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
912
- }
913
- }
914
-
915
-
916
- /**
917
- * Select callback
918
- *
919
- * @access public
920
- * @since 1.0.0
921
- * @param array $args Arguments passed by the setting
922
- * @global array ${$this->func . '_options'} The Beacon options
923
- * @return void
924
- */
925
- public function select_callback( $args ) {
926
- global ${$this->func . '_options'};
927
-
928
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
929
- $value = ${$this->func . '_options'}[$args['id']];
930
- } else {
931
- $value = isset( $args['std'] ) ? $args['std'] : '';
932
- }
933
-
934
- $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
935
- $select2 = isset( $args['select2'] ) ? ' class="s214-select2"' : '';
936
- $width = isset( $args['size'] ) ? ' style="width: ' . $args['size'] . '"' : '';
937
-
938
- if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
939
- $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . '][]"' . $select2 . ' data-placeholder="' . $placeholder . '" multiple="multiple"' . $width . ' />';
940
- } else {
941
- $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']"' . $select2 . ' data-placeholder="' . $placeholder . '"' . $width . ' />';
942
- }
943
-
944
- foreach( $args['options'] as $option => $name ) {
945
- if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
946
- if( is_array( $value ) ) {
947
- $selected = ( in_array( $option, $value ) ? 'selected="selected"' : '' );
948
- } else {
949
- $selected = '';
950
- }
951
- } else {
952
- if( is_string( $value ) ) {
953
- $selected = selected( $option, $value, false );
954
- } else {
955
- $selected = '';
956
- }
957
- }
958
-
959
- $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
960
- }
961
-
962
- $html .= '</select>&nbsp;';
963
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
964
-
965
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
966
- }
967
-
968
-
969
- /**
970
- * Sysinfo callback
971
- *
972
- * @since 1.1.0
973
- * @param array $args Arguements passed by the settings
974
- * @return void
975
- */
976
- public function sysinfo_callback( $args ) {
977
- global ${$this->func . '_options'};
978
-
979
- if( ! isset( ${$this->func . '_options'}[$args['tab']] ) || ( isset( ${$this->func . '_options'}[$args['tab']] ) && isset( $_GET['tab'] ) && $_GET['tab'] == ${$this->func . '_options'}[$args['tab']] ) ) {
980
- $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>';
981
- $html .= '<p class="submit">';
982
- $html .= '<input type="hidden" name="' . $this->slug . '-settings-action" value="download_system_info" />';
983
- $html .= '<a class="button button-primary" href="' . add_query_arg( $this->slug . '-settings-action', 'download_system_info' ) . '">' . __( 'Download System Info File', 's214-settings' ) . '</a>';
984
- $html .= '</p>';
985
-
986
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
987
- }
988
- }
989
-
990
-
991
- /**
992
- * Text callback
993
- *
994
- * @since 1.0.0
995
- * @param array $args Arguments passed by the setting
996
- * @global array ${$this->func . '_options'} The Beacon options
997
- * @return void
998
- */
999
- public function text_callback( $args ) {
1000
- global ${$this->func . '_options'};
1001
-
1002
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1003
- $value = ${$this->func . '_options'}[$args['id']];
1004
- } else {
1005
- $value = isset( $args['std'] ) ? $args['std'] : '';
1006
- }
1007
-
1008
- $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
1009
- $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1010
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1011
-
1012
- $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
1013
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1014
-
1015
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1016
- }
1017
-
1018
-
1019
- /**
1020
- * Textarea callback
1021
- *
1022
- * @since 1.0.0
1023
- * @param array $args Arguments passed by the setting
1024
- * @global array ${$this->func . '_options'} The Beacon options
1025
- * @return void
1026
- */
1027
- public function textarea_callback( $args ) {
1028
- global ${$this->func . '_options'};
1029
-
1030
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1031
- $value = ${$this->func . '_options'}[$args['id']];
1032
- } else {
1033
- $value = isset( $args['std'] ) ? $args['std'] : '';
1034
- }
1035
-
1036
- $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;';
1037
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1038
-
1039
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1040
- }
1041
-
1042
-
1043
- /**
1044
- * Upload callback
1045
- *
1046
- * @since 1.0.0
1047
- * @param array $args Arguments passed by the setting
1048
- * @global array ${$this->func . '_options'} The Beacon options
1049
- * @return void
1050
- */
1051
- public function upload_callback( $args ) {
1052
- global ${$this->func . '_options'};
1053
-
1054
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1055
- $value = ${$this->func . '_options'}[$args['id']];
1056
- } else {
1057
- $value = isset( $args['std'] ) ? $args['std'] : '';
1058
- }
1059
-
1060
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1061
-
1062
- $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;';
1063
- $html .= '<span><input type="button" class="' . $this->func . '_settings_upload_button button-secondary" value="' . __( 'Upload File', 's214-settings' ) . '" /></span>&nbsp;';
1064
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1065
-
1066
- if ( $value ) {
1067
- $html .= '<br /><img src="' . $value . '" class="timeapp_settings_upload_image" />';
1068
- }
1069
-
1070
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1071
- }
1072
-
1073
-
1074
- /**
1075
- * License field callback
1076
- *
1077
- * @access public
1078
- * @since 1.0.0
1079
- * @param array $args Arguments passed by the setting
1080
- * @global array ${$this->func . '_options'} The Beacon options
1081
- * @return void
1082
- */
1083
- public function license_key_callback( $args ) {
1084
- global ${$this->func . '_options'};
1085
-
1086
- if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1087
- $value = ${$this->func . '_options'}[$args['id']];
1088
- } else {
1089
- $value = isset( $args['std'] ) ? $args['std'] : '';
1090
- }
1091
-
1092
- $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1093
-
1094
- $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" />&nbsp;';
1095
-
1096
- if( get_option( $args['options']['is_valid_license_option'] ) ) {
1097
- $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 's214-settings' ) . '"/>';
1098
- }
1099
- $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label></span>';
1100
-
1101
- wp_nonce_field( $args['id'] . '-nonce', $args['id'] . '-nonce' );
1102
-
1103
- echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1104
- }
1105
-
1106
-
1107
- /**
1108
- * Hook callback
1109
- *
1110
- * @since 1.0.0
1111
- * @param array $args Arguments passed by the setting
1112
- * @return void
1113
- */
1114
- public function hook_callback( $args ) {
1115
- do_action( $this->func . '_' . $args['id'] );
1116
- }
1117
-
1118
-
1119
- /**
1120
- * Missing callback
1121
- *
1122
- * @access public
1123
- * @since 1.0.0
1124
- * @param array $args Arguments passed by the setting
1125
- * @return void
1126
- */
1127
- public function missing_callback( $args ) {
1128
- printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 's214-settings' ), $args['id'] );
1129
- }
1130
-
1131
-
1132
- /**
1133
- * Check if we should load admin scripts
1134
- *
1135
- * @access public
1136
- * @since 1.0.0
1137
- * @param string $hook The hook for the current page
1138
- * @return bool true if we should load scripts, false otherwise
1139
- */
1140
- public function load_scripts( $hook ) {
1141
- global $typenow, $pagenow, ${$this->func . '_settings_page'};
1142
-
1143
- $ret = false;
1144
- $pages = apply_filters( $this->func . '_admin_pages', array( ${$this->func . '_settings_page'} ) );
1145
-
1146
- if( in_array( $hook, $pages ) ) {
1147
- $ret = true;
1148
- }
1149
-
1150
- return (bool) apply_filters( $this->func . 'load_scripts', $ret );
1151
- }
1152
-
1153
-
1154
- /**
1155
- * Processes all actions sent via POST and GET by looking for the '$func-settings-action'
1156
- * request and running do_action() to call the function
1157
- *
1158
- * @since 1.1.0
1159
- * @return void
1160
- */
1161
- function process_actions() {
1162
- if( ! isset( $_POST['submit'] ) ) {
1163
- if( isset( $_POST[$this->slug . '-settings-action'] ) ) {
1164
- do_action( $this->func . '_settings_' . $_POST[$this->slug . '-settings-action'], $_POST );
1165
- }
1166
-
1167
- if( isset( $_GET[$this->slug . '-settings-action'] ) ) {
1168
- do_action( $this->func . '_settings_' . $_GET[$this->slug . '-settings-action'], $_GET );
1169
- }
1170
- }
1171
- }
1172
-
1173
-
1174
- /**
1175
- * Enqueue scripts
1176
- *
1177
- * @access public
1178
- * @since 1.0.0
1179
- * @param string $hook The current page hook
1180
- * @return void
1181
- */
1182
- public function enqueue_scripts( $hook ) {
1183
- if( ! apply_filters( $this->func . '_load_admin_scripts', $this->load_scripts( $hook ), $hook ) ) {
1184
- return;
1185
- }
1186
-
1187
- // Use minified libraries if SCRIPT_DEBUG is turned off
1188
- $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1189
- $ui_style = ( get_user_option( 'admin_color' ) == 'classic' ) ? 'classic' : 'fresh';
1190
- $url_path = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname( __FILE__ ) );
1191
- $select2_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/';
1192
- $cm_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.14.2/';
1193
-
1194
- wp_enqueue_style( 'wp-color-picker' );
1195
- wp_enqueue_script( 'wp-color-picker' );
1196
- wp_enqueue_script( 'jquery-ui-tooltip' );
1197
- wp_enqueue_media();
1198
- wp_enqueue_style( 'jquery-ui-css', $url_path . '/assets/css/jquery-ui-' . $ui_style . '.min.css' );
1199
- wp_enqueue_script( 'media-upload' );
1200
- wp_enqueue_style( 'thickbox' );
1201
- wp_enqueue_script( 'thickbox' );
1202
- wp_enqueue_style( 'select2', $select2_cdn . 'css/select2.min.css', array(), '4.0.2' );
1203
- wp_enqueue_script( 'select2', $select2_cdn . 'js/select2.min.js', array( 'jquery' ), '4.0.2' );
1204
-
1205
- wp_enqueue_style( $this->slug . '-cm', $cm_cdn . 'codemirror.css', array(), '5.10' );
1206
- wp_enqueue_script( $this->slug . '-cm', $cm_cdn . 'codemirror.js', array( 'jquery' ), '5.14.2' );
1207
- wp_enqueue_script( $this->slug . '-cm-html', $cm_cdn . 'mode/htmlmixed/htmlmixed.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1208
- wp_enqueue_script( $this->slug . '-cm-xml', $cm_cdn . 'mode/xml/xml.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1209
- wp_enqueue_script( $this->slug . '-cm-js', $cm_cdn . 'mode/javascript/javascript.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1210
- wp_enqueue_script( $this->slug . '-cm-css', $cm_cdn . 'mode/css/css.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1211
- wp_enqueue_script( $this->slug . '-cm-php', $cm_cdn . 'mode/php/php.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1212
- wp_enqueue_script( $this->slug . '-cm-clike', $cm_cdn . 'mode/clike/clike.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1213
-
1214
- wp_enqueue_style( $this->slug . '-s214-settings', $url_path . '/assets/css/admin' . $suffix . '.css', array(), $this->version );
1215
- wp_enqueue_script( $this->slug . '-s214-settings', $url_path . '/assets/js/admin' . $suffix . '.js', array( 'jquery' ), $this->version );
1216
- wp_localize_script( $this->slug . '-s214-settings', 's214_settings_vars', apply_filters( $this->func . 'localize_script', array(
1217
- 'func' => $this->func,
1218
- 'image_media_button' => __( 'Insert Image', 's214-settings' ),
1219
- 'image_media_title' => __( 'Select Image', 's214-settings' ),
1220
- ) ) );
1221
- }
1222
-
1223
-
1224
- /**
1225
- * Add tooltips
1226
- *
1227
- * @access public
1228
- * @since 1.2.0
1229
- * @param string $html The current field HTML
1230
- * @param array $args Arguments passed to the field
1231
- * @return string $html The updated field HTML
1232
- */
1233
- function add_setting_tooltip( $html, $args ) {
1234
- if( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1235
- $tooltip = '<span alt="f223" class="s214-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1236
- $html .= $tooltip;
1237
- }
1238
-
1239
- return $html;
1240
- }
1241
-
1242
- /**
1243
- * Hooks in on option pre-save and checks for empty multicheck groups. If no checkboxes in a group are checked,
1244
- * the info about the fields are never passed to the $_POST array, and the updates are never saved.
1245
- *
1246
- * For every multicheck group, a hidden field is added, which adds to an array called _multicheck_fields. In this
1247
- * function, we loop through all of these to check if the field group is set at all - and if it is not, we set the
1248
- * value to an empty array.
1249
- *
1250
- * @hooked pre_update_option_{$option} - 10
1251
- * @see option.php
1252
- *
1253
- * @param $value The current value of the option
1254
- * @param $old_value The previous value of the option
1255
- * @param $option The options name
1256
- *
1257
- * @return mixed The (maybe) updated option to be saved
1258
- */
1259
- public function multicheck_empty_validation( $value, $old_value, $option ) {
1260
-
1261
- if( ! isset( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] ) || empty( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] ) ) {
1262
-
1263
- return $value;
1264
- }
1265
-
1266
- foreach( $_POST[ $this->func . '_settings' ][ '_multicheck_fields' ] as $multicheck_field_name ) {
1267
-
1268
- if( ! isset( $_POST[ $this->func . '_settings' ][ $multicheck_field_name ] ) || empty( $_POST[ $this->func . '_settings' ][ $multicheck_field_name ] ) ) {
1269
-
1270
- $value[ $multicheck_field_name ] = [];
1271
- }
1272
- }
1273
-
1274
- return $value;
1275
- }
1276
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/libraries/s214-settings/source/modules/licensing/S214_Plugin_Updater.php DELETED
@@ -1,382 +0,0 @@
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 DELETED
@@ -1,385 +0,0 @@
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 DELETED
@@ -1,1103 +0,0 @@
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/simple-settings/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ ## 1.2.0 (2020-02-06)
4
+
5
+ * Updated: Bring code quality up to VIP standards
6
+
7
+ ## 1.0.1 (2019-05-14)
8
+
9
+ * Added: Filter to allow extending whitelisted settings arguments
10
+ * Fixed: Accidental regression that prevented saving text fields on multiple tabs
11
+
12
+ ## 1.0.0 (2019-05-10)
13
+
14
+ * First official release!
CONTRIBUTING.md → includes/libraries/simple-settings/CONTRIBUTING.md RENAMED
@@ -1,36 +1,37 @@
1
- # Contribute To Username Changer
2
-
3
- Community made patches, localizations, bug reports and contributions are always welcome!
4
-
5
- When contributing please ensure you follow the guidelines below so that we can keep on top of things.
6
-
7
- ## Getting Started
8
-
9
- * Submit a ticket for your issue, assuming one does not already exist.
10
- * Raise it on our [Issue Tracker](https://github.com/evertiro/username-changer/issues)
11
- * Clearly describe the issue including steps to reproduce the bug.
12
- * Make sure you fill in the earliest version that you know has the issue as well as the version of WordPress you're using.
13
-
14
- ## Making Changes
15
-
16
- * Fork the repository on GitHub
17
- * Make the changes to your forked repository
18
- * Ensure you stick to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
19
- * When committing, reference your issue (if present) and include a note about the fix
20
- * If possible, and if applicable, please also add/update unit tests for your changes
21
- * Push the changes to your fork and submit a pull request to the 'master' branch of the repository
22
-
23
- ## Code Documentation
24
-
25
- * We ensure that every function is documented well and follows the standards set by phpDoc
26
- * An example function can be found [here](https://gist.github.com/sunnyratilal/5308969)
27
- * Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
28
- * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
29
- * Finally, please use tabs and not spaces. The tab indent size should be 4 for all code.
30
-
31
- At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
32
-
33
- # Additional Resources
34
- * [General GitHub Documentation](https://help.github.com/)
35
- * [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
36
- * [PHPUnit Tests Guide](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
 
1
+ # Contribute To Simple Settings
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://gitlab.com/widgitlabs/wordpress/simple-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
+ * If possible, and if applicable, please also add/update unit tests for your changes
21
+ * Push the changes to your fork and submit a pull request to the 'master' branch of the EDD repository
22
+
23
+ ## Code Documentation
24
+
25
+ * We ensure that every function is documented well and follows the standards set by phpDoc
26
+ * An example function can be found [here](https://gist.github.com/sunnyratilal/5308969)
27
+ * Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
28
+ * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
29
+ * Finally, please use tabs and not spaces. The tab indent size should be 4 for all library code.
30
+
31
+ At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
32
+
33
+ # Additional Resources
34
+
35
+ * [General GitHub Documentation](https://help.github.com/)
36
+ * [GitHub Pull Request documentation](https://help.github.com/send-pull-requests/)
37
+ * [PHPUnit Tests Guide](https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
includes/libraries/simple-settings/Gruntfile.js ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module.exports = function(grunt) {
2
+
3
+ // Load multiple grunt tasks using globbing patterns
4
+ require('load-grunt-tasks')(grunt);
5
+
6
+ // Project configuration.
7
+ grunt.initConfig({
8
+
9
+ pkg: grunt.file.readJSON('package.json'),
10
+
11
+ cssmin: {
12
+ options: {
13
+ mergeIntoShorthands: false,
14
+ },
15
+ target: {
16
+ files: [
17
+ {
18
+ expand: true,
19
+ cwd: 'assets/css',
20
+ src: ['admin.css'],
21
+ dest: 'assets/css',
22
+ ext: '.min.css'
23
+ }
24
+ ],
25
+ }
26
+ },
27
+
28
+ uglify: {
29
+ options: {
30
+ mangle: false,
31
+ },
32
+ target: {
33
+ files: [{
34
+ expand: true,
35
+ cwd: 'assets/js',
36
+ src: [ '*.js', '!*.min.js', '!*jquery*.js' ],
37
+ dest: 'assets/js',
38
+ ext: '.min.js',
39
+ extDot: 'last',
40
+ }]
41
+ }
42
+ },
43
+
44
+ // Clean up build directory
45
+ clean: {
46
+ main: ['build/<%= pkg.name %>']
47
+ },
48
+
49
+ // Copy the plugin into the build directory
50
+ copy: {
51
+ main: {
52
+ src: [
53
+ 'assets/**',
54
+ 'includes/**',
55
+ 'languages/**',
56
+ 'templates/**',
57
+ '*.php',
58
+ '*.txt'
59
+ ],
60
+ dest: 'build/<%= pkg.name %>/'
61
+ }
62
+ },
63
+
64
+ // Compress build directory into <name>.zip and <name>-<version>.zip
65
+ compress: {
66
+ main: {
67
+ options: {
68
+ mode: 'zip',
69
+ archive: './build/<%= pkg.name %>.zip'
70
+ },
71
+ expand: true,
72
+ cwd: 'build/<%= pkg.name %>/',
73
+ src: ['**/*'],
74
+ dest: '<%= pkg.name %>/'
75
+ }
76
+ },
77
+
78
+ });
79
+
80
+ // Build task(s).
81
+ grunt.registerTask( 'build', [ 'cssmin', 'uglify', 'clean', 'copy', 'compress' ] );
82
+
83
+ };
includes/libraries/simple-settings/README.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Simple Settings Library
2
+
3
+ ## What Is This
4
+
5
+ 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). However, what if your project is somewhere in the middle? Alternatively, what if you need a control panel, but don't want the bulk that goes along with most? This need is something that I've struggled with for some time. My standard implementation has historically been a fork of the excellent system used by [Easy Digital Downloads](https://easydigitaldownloads.com). 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!
6
+
7
+ More information can be found on the [wiki](https://gitlab.com/widgitlabs/wordpress/simple-settings/wikis/home).
8
+
9
+ ## Installation
10
+
11
+ 1. You can clone the GitLab repository: `https://gitlab.com/widgitlabs/wordpress/simple-settings.git`
12
+ 2. Or download it directly as a ZIP file: `https://gitlab.com/widgitlabs/wordpress/simple-settings/-/archive/master/simple-settings-master.zip`
13
+
14
+ This will download the latest developer copy of the Simple Settings library.
15
+
16
+ ## Bugs
17
+
18
+ If you find an issue, let us know [here](https://gitlab.com/widgitlabs/wordpress/simple-settings/issues)!
19
+
20
+ ## Contributions
21
+
22
+ Anyone is welcome to contribute to the library. Please read the [guidelines for contributing](https://github.com/widgitlabs/wordpress/simple-settings/blob/master/CONTRIBUTING.md) to this repository.
23
+
24
+ There are various ways you can contribute:
25
+
26
+ 1. Raise an [Issue](https://gitlab.com/widgitlabs/wordpress/simple-settings/issues) on GitLab
27
+ 2. Send us a Pull Request with your bug fixes and/or new features
28
+ 3. Provide feedback and suggestions on [enhancements](https://gitlab.com/widgitlabs/wordpress/simple-settings/issues?label_name[]=Enhancement)
includes/libraries/{s214-settings/source → simple-settings}/assets/css/admin.css RENAMED
@@ -1,6 +1,13 @@
 
 
 
 
 
 
 
1
  /* Fix color picker label alignment
2
  -------------------------------------------------------------- */
3
- .s214-color-picker-label {
4
  position: absolute;
5
  display: inline-block;
6
  padding-top: 4px;
@@ -20,8 +27,9 @@
20
 
21
  /* Tooltips
22
  -------------------------------------------------------------- */
23
- .s214-help-tip {
24
  cursor: help;
 
25
  }
26
 
27
  .ui-tooltip {
1
+ .simple-settings-options-table .form-table label {
2
+ color: #666;
3
+ font-size: 14px;
4
+ font-style: italic;
5
+ margin: 4px 0 0;
6
+ }
7
+
8
  /* Fix color picker label alignment
9
  -------------------------------------------------------------- */
10
+ .simple-settings-color-picker-label {
11
  position: absolute;
12
  display: inline-block;
13
  padding-top: 4px;
27
 
28
  /* Tooltips
29
  -------------------------------------------------------------- */
30
+ .simple-settings-help-tip {
31
  cursor: help;
32
+ vertical-align: middle;
33
  }
34
 
35
  .ui-tooltip {
includes/libraries/simple-settings/assets/css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .simple-settings-options-table .form-table label{color:#666;font-size:14px;font-style:italic;margin:4px 0 0}.simple-settings-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}.simple-settings-help-tip{cursor:help;vertical-align:middle}.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 → simple-settings}/assets/css/jquery-ui-classic.min.css RENAMED
File without changes
includes/libraries/{s214-settings/source → simple-settings}/assets/css/jquery-ui-fresh.min.css RENAMED
File without changes
includes/libraries/{s214-settings/source → simple-settings}/assets/js/admin.js RENAMED
@@ -1,20 +1,20 @@
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',
@@ -24,7 +24,7 @@ jQuery(document).ready(function ($) {
24
  }
25
 
26
  // Setup tooltips
27
- $('.s214-help-tip').tooltip({
28
  content: function () {
29
  return $(this).prop('title');
30
  },
@@ -42,10 +42,10 @@ jQuery(document).ready(function ($) {
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);
1
+ /*global jQuery, document, window, wp, CodeMirror, simple_settings_vars*/
2
  jQuery(document).ready(function ($) {
3
  'use strict';
4
 
5
  // Setup color picker
6
+ if ($('.simple-settings-color-picker').length) {
7
+ $('.simple-settings-color-picker').wpColorPicker();
8
  }
9
 
10
  // Setup select2
11
+ if ($('.simple-settings-select2').length) {
12
+ $('.simple-settings-select2').select2();
13
  }
14
 
15
  // Setup CodeMirror
16
+ if ($('.simple-settings-html').length) {
17
+ $('.simple-settings-html').each(function (index, elem) {
18
  CodeMirror.fromTextArea(elem, {
19
  lineNumbers: true,
20
  mode: 'text/html',
24
  }
25
 
26
  // Setup tooltips
27
+ $('.simple-settings-help-tip').tooltip({
28
  content: function () {
29
  return $(this).prop('title');
30
  },
42
  });
43
 
44
  // Setup uploaders
45
+ if ($('.' + simple_settings_vars.func + '_settings_upload_button').length) {
46
  var file_frame;
47
 
48
+ $('body').on('click', '.' + simple_settings_vars.func + '_settings_upload_button', function (e) {
49
  e.preventDefault();
50
 
51
  var button = $(this);
includes/libraries/simple-settings/assets/js/admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function($){"use strict";var file_frame;($(".simple-settings-color-picker").length&&$(".simple-settings-color-picker").wpColorPicker(),$(".simple-settings-select2").length&&$(".simple-settings-select2").select2(),$(".simple-settings-html").length&&$(".simple-settings-html").each(function(index,elem){CodeMirror.fromTextArea(elem,{lineNumbers:!0,mode:"text/html",showCursorWhenSelecting:!0})}),$(".simple-settings-help-tip").tooltip({content:function(){return $(this).prop("title")},position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}}),$("."+simple_settings_vars.func+"_settings_upload_button").length)&&($("body").on("click","."+simple_settings_vars.func+"_settings_upload_button",function(e){e.preventDefault();var button=$(this);window.formfield=$(this).parent().prev(),file_frame||(wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:button.data("uploader_title"),button:{text:button.data("uploader_button_text")},multiple:!1}),(file_frame=wp.media.frames.file_frame).on("menu:render:default",function(view){view.unset("library-separator"),view.unset("gallery"),view.unset("featured-image"),view.unset("embed"),view.set({})}),file_frame.on("insert",function(){file_frame.state().get("selection").each(function(attachment){attachment=attachment.toJSON(),window.formfield.val(attachment.url)})})),file_frame.open()}),window.formfield="")});
includes/libraries/simple-settings/class-simple-settings.php ADDED
@@ -0,0 +1,1430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widgit Simple Settings Class
4
+ *
5
+ * @package Widgit\SimpleSettings
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Widgit Simple Settings handler class
17
+ *
18
+ * @access public
19
+ * @since 1.0.0
20
+ */
21
+ class Simple_Settings {
22
+
23
+
24
+ /**
25
+ * The settings class version
26
+ *
27
+ * @var string $version The settings class version
28
+ * @access private
29
+ * @since 1.0.0
30
+ */
31
+ private $version = '1.2.0';
32
+
33
+
34
+ /**
35
+ * The plugin slug
36
+ *
37
+ * @var string $slug The plugin slug
38
+ * @access private
39
+ * @since 1.0.0
40
+ */
41
+ private $slug;
42
+
43
+
44
+ /**
45
+ * The plugin slug for names
46
+ *
47
+ * @var string $func The plugin slug for names
48
+ * @access private
49
+ * @since 1.0.0
50
+ */
51
+ private $func;
52
+
53
+
54
+ /**
55
+ * The default tab to display
56
+ *
57
+ * @var string $default_tab The default tab to display
58
+ * @access private
59
+ * @since 1.0.0
60
+ */
61
+ private $default_tab;
62
+
63
+
64
+ /**
65
+ * Whether or not to display the page title
66
+ *
67
+ * @var bool $show_title Whether or not to display the page title
68
+ * @access private
69
+ * @since 1.0.0
70
+ */
71
+ private $show_title;
72
+
73
+
74
+ /**
75
+ * The page title
76
+ *
77
+ * @var bool page_title The page title
78
+ * @access private
79
+ * @since 1.0.0
80
+ */
81
+ private $page_title;
82
+
83
+
84
+ /**
85
+ * The sysinfo object
86
+ *
87
+ * @var object $sysinfo The sysinfo object
88
+ * @access private
89
+ * @since 1.0.0
90
+ */
91
+ private $sysinfo;
92
+
93
+
94
+ /**
95
+ * Get things started
96
+ *
97
+ * @access public
98
+ * @since 1.0.0
99
+ * @param string $slug The plugin slug.
100
+ * @param string $default_tab The default settings tab to display.
101
+ * @return void
102
+ */
103
+ public function __construct( $slug = false, $default_tab = 'general' ) {
104
+ // Bail if no slug is specified.
105
+ if ( ! $slug ) {
106
+ return;
107
+ }
108
+
109
+ // Setup plugin variables.
110
+ $this->slug = $slug;
111
+ $this->func = str_replace( '-', '_', $slug );
112
+ $this->default_tab = $default_tab;
113
+
114
+ // Run action and filter hooks.
115
+ $this->hooks();
116
+
117
+ // Setup the Sysinfo class.
118
+ if ( ! class_exists( 'Simple_Settings_Sysinfo' ) ) {
119
+ require_once 'modules/sysinfo/class-simple-settings-sysinfo.php';
120
+ }
121
+ $this->sysinfo = new Simple_Settings_Sysinfo( $this->slug, $this->func, $this->version );
122
+ }
123
+
124
+
125
+ /**
126
+ * Run action and filter hooks
127
+ *
128
+ * @access private
129
+ * @since 1.0.0
130
+ * @return void
131
+ */
132
+ private function hooks() {
133
+ // Add the plugin setting page.
134
+ add_action( 'admin_menu', array( $this, 'add_settings_page' ), 10 );
135
+
136
+ // Register the plugin settings.
137
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
138
+ add_filter( $this->func . '_settings_sanitize_text', array( $this, 'sanitize_text_field' ) );
139
+
140
+ // Add styles and scripts.
141
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 100 );
142
+
143
+ // Process actions.
144
+ add_action( 'admin_init', array( $this, 'process_actions' ) );
145
+
146
+ // Handle tooltips.
147
+ add_action( $this->func . '_after_setting_output', array( $this, 'add_setting_tooltip' ), 10 );
148
+ }
149
+
150
+
151
+ /**
152
+ * Add settings pages
153
+ *
154
+ * @access public
155
+ * @since 1.0.0
156
+ * @global string ${this->func . '_settings_page'} The settings page slug
157
+ * @return void
158
+ */
159
+ public function add_settings_page() {
160
+ global ${$this->func . '_settings_page'};
161
+
162
+ $menu = apply_filters(
163
+ $this->func . '_menu',
164
+ array(
165
+ 'type' => 'menu',
166
+ 'parent' => 'options-general.php',
167
+ 'page_title' => __( 'Simple Settings', 'simple-settings' ),
168
+ 'show_title' => false,
169
+ 'menu_title' => __( 'Simple Settings', 'simple-settings' ),
170
+ 'capability' => 'manage_options',
171
+ 'icon' => '',
172
+ 'position' => null,
173
+ )
174
+ );
175
+
176
+ $this->show_title = $menu['show_title'];
177
+ $this->page_title = $menu['page_title'];
178
+
179
+ if ( 'submenu' === $menu['type'] ) {
180
+ ${$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' ) );
181
+ } else {
182
+ ${$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'] );
183
+ }
184
+ }
185
+
186
+
187
+ /**
188
+ * Render settings page
189
+ *
190
+ * @access public
191
+ * @since 1.0.0
192
+ * @return void
193
+ */
194
+ public function render_settings_page() {
195
+ if ( isset( $_REQUEST[ $this->func . '_settings_nonce' ] ) ) {
196
+ check_admin_referer( $this->func . '_settings_nonce', $this->func . '_settings_nonce' );
197
+ }
198
+
199
+ $get = wp_unslash( $_GET );
200
+ $active_tab = isset( $get['tab'] ) && array_key_exists( $get['tab'], $this->get_settings_tabs() ) ? $get['tab'] : $this->default_tab;
201
+ $registered_sections = $this->get_settings_tab_sections( $active_tab );
202
+ $sections = $registered_sections;
203
+ $key = 'main';
204
+
205
+ if ( is_array( $sections ) ) {
206
+ $key = key( $sections );
207
+ }
208
+
209
+ $section = isset( $get['section'] ) && ! empty( $registered_sections ) && array_key_exists( $get['section'], $registered_sections ) ? $get['section'] : $key;
210
+ ?>
211
+ <div class="wrap">
212
+ <?php if ( $this->show_title ) { ?>
213
+ <h2><?php echo esc_html( $this->page_title ); ?></h2>
214
+ <?php } ?>
215
+ <h2 class="nav-tab-wrapper">
216
+ <?php
217
+ foreach ( $this->get_settings_tabs() as $tab_id => $tab_name ) {
218
+ $tab_url = add_query_arg(
219
+ array(
220
+ 'settings-updated' => false,
221
+ 'tab' => $tab_id,
222
+ )
223
+ );
224
+
225
+ // Remove the section from the tabs so we always end up at the main section.
226
+ $tab_url = remove_query_arg( 'section', $tab_url );
227
+
228
+ $active = $active_tab === $tab_id ? ' nav-tab-active' : '';
229
+ ?>
230
+ <a href="<?php echo esc_url( $tab_url ); ?>" title="<?php echo esc_attr( $tab_name ); ?>" class="nav-tab<?php echo esc_attr( $active ); ?>"><?php echo wp_kses_post( $tab_name ); ?></a>
231
+ <?php
232
+ }
233
+ ?>
234
+ </h2>
235
+ <?php
236
+ $number_of_sections = count( (array) $sections );
237
+ $number = 0;
238
+
239
+ if ( $number_of_sections > 1 ) {
240
+ echo '<div><ul class="subsubsub">';
241
+
242
+ foreach ( $sections as $section_id => $section_name ) {
243
+ echo '<li>';
244
+
245
+ $number++;
246
+ $class = '';
247
+ $tab_url = add_query_arg(
248
+ array(
249
+ 'settings-updated' => false,
250
+ 'tab' => $active_tab,
251
+ 'section' => $section_id,
252
+ )
253
+ );
254
+
255
+ if ( $section === $section_id ) {
256
+ $class = 'current';
257
+ }
258
+
259
+ echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>';
260
+
261
+ if ( $number !== $number_of_sections ) {
262
+ echo ' | ';
263
+ }
264
+
265
+ echo '</li>';
266
+ }
267
+
268
+ echo '</ul></div>';
269
+ }
270
+ ?>
271
+ <div id="tab_container" class="simple-settings-options-table">
272
+ <form method="post" action="options.php">
273
+ <table class="form-table">
274
+ <?php
275
+ settings_fields( $this->func . '_settings' );
276
+
277
+ do_action( $this->func . '_settings_tab_top_' . $active_tab . '_' . $section );
278
+
279
+ do_settings_sections( $this->func . '_settings_' . $active_tab . '_' . $section );
280
+
281
+ do_action( $this->func . '_settings_tab_bottom_' . $active_tab . '_' . $section );
282
+ ?>
283
+ </table>
284
+ <?php
285
+ if ( ! in_array( $active_tab, apply_filters( $this->func . '_unsavable_tabs', array() ), true ) ) {
286
+ wp_nonce_field( $this->func . '_settings_nonce', $this->func . '_settings_nonce' );
287
+ submit_button();
288
+ }
289
+ ?>
290
+ </form>
291
+ </div>
292
+ </div>
293
+ <?php
294
+ }
295
+
296
+
297
+ /**
298
+ * Retrieve the settings tabs
299
+ *
300
+ * @access private
301
+ * @since 1.0.0
302
+ * @return array $tabs The registered tabs for this plugin
303
+ */
304
+ private function get_settings_tabs() {
305
+ return apply_filters( $this->func . '_settings_tabs', array() );
306
+ }
307
+
308
+
309
+ /**
310
+ * Retrieve settings tab sections
311
+ *
312
+ * @access public
313
+ * @since 1.0.0
314
+ * @param string $tab The current tab.
315
+ * @return array $section The section items
316
+ */
317
+ public function get_settings_tab_sections( $tab = false ) {
318
+ $tabs = false;
319
+ $sections = $this->get_registered_settings_sections();
320
+
321
+ if ( $tab && ! empty( $sections[ $tab ] ) ) {
322
+ $tabs = $sections[ $tab ];
323
+ } elseif ( $tab ) {
324
+ $tabs = false;
325
+ }
326
+
327
+ return $tabs;
328
+ }
329
+
330
+
331
+ /**
332
+ * Retrieve the plugin settings
333
+ *
334
+ * @access public
335
+ * @since 1.0.0
336
+ * @return array $settings The plugin settings
337
+ */
338
+ public function get_registered_settings() {
339
+ return apply_filters( $this->func . '_registered_settings', array() );
340
+ }
341
+
342
+
343
+ /**
344
+ * Retrieve the plugin settings sections
345
+ *
346
+ * @access private
347
+ * @since 1.0.0
348
+ * @return array $sections The registered sections
349
+ */
350
+ private function get_registered_settings_sections() {
351
+ global ${$this->func . '_sections'};
352
+
353
+ if ( ! empty( ${$this->func . '_sections'} ) ) {
354
+ return ${$this->func . '_sections'};
355
+ }
356
+
357
+ ${$this->func . '_sections'} = apply_filters( $this->func . '_registered_settings_sections', array() );
358
+
359
+ return ${$this->func . '_sections'};
360
+ }
361
+
362
+
363
+ /**
364
+ * Retrieve an option
365
+ *
366
+ * @access public
367
+ * @since 1.0.0
368
+ * @param string $key The key to retrieve.
369
+ * @param mixed $default The default value if key doesn't exist.
370
+ * @global array ${$this->func . '_options'} The options array
371
+ * @return mixed $value The value to return
372
+ */
373
+ public function get_option( $key = '', $default = false ) {
374
+ global ${$this->func . '_options'};
375
+
376
+ $value = ! empty( ${$this->func . '_options'}[ $key ] ) ? ${$this->func . '_options'}[ $key ] : $default;
377
+ $value = apply_filters( $this->func . '_get_option', $value, $key, $default );
378
+
379
+ return apply_filters( $this->func . '_get_option_' . $key, $value, $key, $default );
380
+ }
381
+
382
+
383
+ /**
384
+ * Update an option
385
+ *
386
+ * @access public
387
+ * @since 1.0.0
388
+ * @param string $key The key to update.
389
+ * @param mixed $value The value to set key to.
390
+ * @return bool true if updated, false otherwise
391
+ */
392
+ public function update_option( $key = '', $value = false ) {
393
+ // Bail if no key is set.
394
+ if ( empty( $key ) ) {
395
+ return false;
396
+ }
397
+
398
+ if ( empty( $value ) ) {
399
+ $remove_option = $this->delete_option( $key );
400
+ return $remove_option;
401
+ }
402
+
403
+ // Fetch a clean copy of the options array.
404
+ $options = get_option( $this->func . '_settings' );
405
+
406
+ // Allow devs to modify the value.
407
+ $value = apply_filters( $this->func . '_update_option', $value, $key );
408
+
409
+ // Try to update the option.
410
+ $options[ $key ] = $value;
411
+ $did_update = update_option( $this->func . '_settings', $options );
412
+
413
+ // Update the global.
414
+ if ( $did_update ) {
415
+ global ${$this->func . '_options'};
416
+ ${$this->func . '_options'}[ $key ] = $value;
417
+ }
418
+
419
+ return $did_update;
420
+ }
421
+
422
+
423
+ /**
424
+ * Delete an option
425
+ *
426
+ * @access public
427
+ * @since 1.0.0
428
+ * @param string $key The key to delete.
429
+ * @return bool true if deleted, false otherwise
430
+ */
431
+ public function delete_option( $key = '' ) {
432
+ // Bail if no key is set.
433
+ if ( empty( $key ) ) {
434
+ return false;
435
+ }
436
+
437
+ // Fetch a clean copy of the options array.
438
+ $options = get_option( $this->func . '_settings' );
439
+
440
+ // Try to unset the option.
441
+ if ( isset( $options[ $key ] ) ) {
442
+ unset( $options[ $key ] );
443
+ }
444
+
445
+ $did_update = update_option( $this->func . '_settings', $options );
446
+
447
+ // Update the global.
448
+ if ( $did_update ) {
449
+ global ${$this->func . '_options'};
450
+ ${$this->func . '_options'} = $options;
451
+ }
452
+
453
+ return $did_update;
454
+ }
455
+
456
+
457
+ /**
458
+ * Retrieve all options
459
+ *
460
+ * @access public
461
+ * @since 1.0.0
462
+ * @return array $settings The options array
463
+ */
464
+ public function get_settings() {
465
+ $settings = get_option( $this->func . '_settings' );
466
+
467
+ if ( empty( $settings ) ) {
468
+ $settings = array();
469
+
470
+ update_option( $this->func . '_settings', $settings );
471
+ }
472
+
473
+ return apply_filters( $this->func . '_get_settings', $settings );
474
+ }
475
+
476
+
477
+ /**
478
+ * Add settings sections and fields
479
+ *
480
+ * @access public
481
+ * @since 1.0.0
482
+ * @return void
483
+ */
484
+ public function register_settings() {
485
+ if ( get_option( $this->func . '_settings' ) === false ) {
486
+ add_option( $this->func . '_settings' );
487
+ }
488
+
489
+ foreach ( $this->get_registered_settings() as $tab => $sections ) {
490
+ foreach ( $sections as $section => $settings ) {
491
+ // Check for backwards compatibility.
492
+ $section_tabs = $this->get_settings_tab_sections( $tab );
493
+
494
+ if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
495
+ $section = 'main';
496
+ $settings = $sections;
497
+ }
498
+
499
+ add_settings_section(
500
+ $this->func . '_settings_' . $tab . '_' . $section,
501
+ __return_null(),
502
+ '__return_false',
503
+ $this->func . '_settings_' . $tab . '_' . $section
504
+ );
505
+
506
+ foreach ( $settings as $option ) {
507
+ // For backwards compatibility.
508
+ if ( empty( $option['id'] ) ) {
509
+ continue;
510
+ }
511
+
512
+ $name = isset( $option['name'] ) ? $option['name'] : '';
513
+
514
+ add_settings_field(
515
+ $this->func . '_settings[' . $option['id'] . ']',
516
+ $name,
517
+ 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' ) ),
518
+ $this->func . '_settings_' . $tab . '_' . $section,
519
+ $this->func . '_settings_' . $tab . '_' . $section,
520
+ apply_filters(
521
+ $this->func . '_settings_allowed_args',
522
+ array(
523
+ 'section' => $section,
524
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
525
+ 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
526
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
527
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
528
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
529
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
530
+ 'min' => isset( $option['min'] ) ? $option['min'] : null,
531
+ 'max' => isset( $option['max'] ) ? $option['max'] : null,
532
+ 'step' => isset( $option['step'] ) ? $option['step'] : null,
533
+ 'select2' => isset( $option['select2'] ) ? $option['select2'] : null,
534
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
535
+ 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : null,
536
+ 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
537
+ 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
538
+ 'disabled' => isset( $option['disabled'] ) ? $option['disabled'] : false,
539
+ 'buttons' => isset( $option['buttons'] ) ? $option['buttons'] : null,
540
+ 'wpautop' => isset( $option['wpautop'] ) ? $option['wpautop'] : null,
541
+ 'teeny' => isset( $option['teeny'] ) ? $option['teeny'] : null,
542
+ 'tab' => isset( $option['tab'] ) ? $option['tab'] : null,
543
+ 'tooltip_title' => isset( $option['tooltip_title'] ) ? $option['tooltip_title'] : false,
544
+ 'tooltip_desc' => isset( $option['tooltip_desc'] ) ? $option['tooltip_desc'] : false,
545
+ 'field_class' => isset( $option['field_class'] ) ? $option['field_class'] : '',
546
+ ),
547
+ $option
548
+ )
549
+ );
550
+ }
551
+ }
552
+ }
553
+
554
+ register_setting( $this->func . '_settings', $this->func . '_settings', array( $this, 'settings_sanitize' ) );
555
+ }
556
+
557
+
558
+ /**
559
+ * Settings sanitization
560
+ *
561
+ * @access public
562
+ * @since 1.0.0
563
+ * @param array $input The value entered in the field.
564
+ * @global array ${$this->func . '_options'} The options array
565
+ * @return string $input The sanitized value
566
+ */
567
+ public function settings_sanitize( $input = array() ) {
568
+ global ${$this->func . '_options'};
569
+
570
+ if ( isset( $_REQUEST[ $this->func . '_settings_nonce' ] ) ) {
571
+ check_admin_referer( $this->func . '_settings_nonce', $this->func . '_settings_nonce' );
572
+ }
573
+
574
+ $doing_section = false;
575
+ $post = wp_unslash( $_POST );
576
+
577
+ if ( ! empty( $post['_wp_http_referer'] ) ) {
578
+ $doing_section = true;
579
+ }
580
+
581
+ $setting_types = $this->get_registered_settings_types();
582
+ $input = $input ? $input : array();
583
+
584
+ if ( $doing_section ) {
585
+ parse_str( $post['_wp_http_referer'], $referrer );
586
+
587
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : $this->default_tab;
588
+ $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
589
+
590
+ if ( ! empty( $post[ $this->func . '_section_override' ] ) ) {
591
+ $section = sanitize_text_field( $post[ $this->func . '_section_override' ] );
592
+ }
593
+
594
+ $setting_types = $this->get_registered_settings_types( $tab, $section );
595
+
596
+ $input = apply_filters( $this->func . '_settings_' . $tab . '_sanitize', $input );
597
+ $input = apply_filters( $this->func . '_settings_' . $tab . '_' . $section . '_sanitize', $input );
598
+ }
599
+
600
+ $output = array_merge( ${$this->func . '_options'}, $input );
601
+
602
+ foreach ( $setting_types as $key => $type ) {
603
+ if ( empty( $type ) ) {
604
+ continue;
605
+ }
606
+
607
+ // Bypass non-setting settings.
608
+ $non_setting_types = apply_filters(
609
+ $this->func . '_non_setting_types',
610
+ array(
611
+ 'header',
612
+ 'descriptive_text',
613
+ 'hook',
614
+ )
615
+ );
616
+
617
+ if ( in_array( $type, $non_setting_types, true ) ) {
618
+ continue;
619
+ }
620
+
621
+ if ( array_key_exists( $key, $output ) ) {
622
+ $output[ $key ] = apply_filters( $this->func . '_settings_sanitize_' . $type, $output[ $key ], $key );
623
+ $output[ $key ] = apply_filters( $this->func . '_settings_sanitize', $output[ $key ], $key );
624
+ }
625
+
626
+ if ( $doing_section ) {
627
+ switch ( $type ) {
628
+ case 'checkbox':
629
+ case 'multicheck':
630
+ if ( array_key_exists( $key, $input ) && '-1' === $output[ $key ] ) {
631
+ unset( $output[ $key ] );
632
+ }
633
+ break;
634
+ case 'text':
635
+ if ( array_key_exists( $key, $input ) && empty( $input[ $key ] ) ) {
636
+ unset( $output[ $key ] );
637
+ }
638
+ break;
639
+ default:
640
+ if ( array_key_exists( $key, $input ) && empty( $input[ $key ] ) || ( array_key_exists( $key, $output ) && ! array_key_exists( $key, $input ) ) ) {
641
+ unset( $output[ $key ] );
642
+ }
643
+ break;
644
+ }
645
+ } else {
646
+ if ( empty( $input[ $key ] ) ) {
647
+ unset( $output[ $key ] );
648
+ }
649
+ }
650
+ }
651
+
652
+ if ( $doing_section ) {
653
+ add_settings_error( $this->slug . '-notices', '', __( 'Settings updated.', 'simple-settings' ), 'updated' );
654
+ }
655
+
656
+ return $output;
657
+ }
658
+
659
+
660
+ /**
661
+ * Flattens the set of registered settings and their type so we can easily sanitize all settings
662
+ *
663
+ * @access public
664
+ * @since 1.0.0
665
+ * @param mixed $filter_tab bool|string A tab to filter by.
666
+ * @param mixed $filter_section bool|string A section to filter by.
667
+ * @return array Key is the setting ID, value is the type of setting it is registered as
668
+ */
669
+ public function get_registered_settings_types( $filter_tab = false, $filter_section = false ) {
670
+ $settings = $this->get_registered_settings();
671
+ $setting_types = array();
672
+
673
+ foreach ( $settings as $tab_id => $tab ) {
674
+ if ( false !== $filter_tab && $filter_tab !== $tab_id ) {
675
+ continue;
676
+ }
677
+
678
+ foreach ( $tab as $section_id => $section_or_setting ) {
679
+ // See if we have a setting registered at the tab level for backwards compatibility.
680
+ if ( false !== $filter_section && is_array( $section_or_setting ) && array_key_exists( 'type', $section_or_setting ) ) {
681
+ $setting_types[ $section_or_setting['id'] ] = $section_or_setting['type'];
682
+ continue;
683
+ }
684
+
685
+ if ( false !== $filter_section && $filter_section !== $section_id ) {
686
+ continue;
687
+ }
688
+
689
+ foreach ( $section_or_setting as $section => $section_settings ) {
690
+ $setting_types[ $section_settings['id'] ] = $section_settings['type'];
691
+ }
692
+ }
693
+ }
694
+
695
+ return $setting_types;
696
+ }
697
+
698
+
699
+ /**
700
+ * Sanitize text fields
701
+ *
702
+ * @access public
703
+ * @since 1.0.0
704
+ * @param array $input The value entered in the field.
705
+ * @return string $input The sanitized value
706
+ */
707
+ public function sanitize_text_field( $input ) {
708
+ $tags = array(
709
+ 'p' => array(
710
+ 'class' => array(),
711
+ 'id' => array(),
712
+ ),
713
+ 'span' => array(
714
+ 'class' => array(),
715
+ 'id' => array(),
716
+ ),
717
+ 'a' => array(
718
+ 'href' => array(),
719
+ 'target' => array(),
720
+ 'title' => array(),
721
+ 'class' => array(),
722
+ 'id' => array(),
723
+ ),
724
+ 'strong' => array(),
725
+ 'em' => array(),
726
+ 'br' => array(),
727
+ 'img' => array(
728
+ 'src' => array(),
729
+ 'title' => array(),
730
+ 'alt' => array(),
731
+ 'class' => array(),
732
+ 'id' => array(),
733
+ ),
734
+ 'div' => array(
735
+ 'class' => array(),
736
+ 'id' => array(),
737
+ ),
738
+ 'ul' => array(
739
+ 'class' => array(),
740
+ 'id' => array(),
741
+ ),
742
+ 'ol' => array(
743
+ 'class' => array(),
744
+ 'id' => array(),
745
+ ),
746
+ 'li' => array(
747
+ 'class' => array(),
748
+ 'id' => array(),
749
+ ),
750
+ );
751
+
752
+ $allowed_tags = apply_filters( $this->func . '_allowed_html_tags', $tags );
753
+
754
+ return trim( wp_kses( $input, $allowed_tags ) );
755
+ }
756
+
757
+
758
+ /**
759
+ * Sanitize HTML Class Names
760
+ *
761
+ * @access public
762
+ * @since 1.0.0
763
+ * @param string|array $class HTML Class Name(s).
764
+ * @return string $class
765
+ */
766
+ public function sanitize_html_class( $class = '' ) {
767
+ if ( is_string( $class ) ) {
768
+ $class = sanitize_html_class( $class );
769
+ } elseif ( is_array( $class ) ) {
770
+ $class = array_values( array_map( 'sanitize_html_class', $class ) );
771
+ $class = implode( ' ', array_unique( $class ) );
772
+ }
773
+
774
+ return $class;
775
+ }
776
+
777
+
778
+ /**
779
+ * Sanitizes a string key
780
+ *
781
+ * Keys are used as internal identifiers. Alphanumeric characters, dashes,
782
+ * underscores, stops, colons and slashes are allowed
783
+ *
784
+ * @access public
785
+ * @since 1.0.0
786
+ * @param string $key String key.
787
+ * @return string Sanitized key
788
+ */
789
+ public function sanitize_key( $key ) {
790
+ $raw_key = $key;
791
+ $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
792
+
793
+ return apply_filters( $this->func . '_sanitize_key', $key, $raw_key );
794
+ }
795
+
796
+
797
+ /**
798
+ * Header callback
799
+ *
800
+ * @access public
801
+ * @since 1.0.0
802
+ * @param array $args Arguments passed by the setting.
803
+ * @return void
804
+ */
805
+ public function header_callback( $args ) {
806
+ do_action( $this->func . '_after_setting_output', '', $args );
807
+ }
808
+
809
+
810
+ /**
811
+ * Checkbox callback
812
+ *
813
+ * @access public
814
+ * @since 1.0.0
815
+ * @param array $args Arguments passed by the setting.
816
+ * @global array ${$this->func . '_options'} The plugin options
817
+ * @return void
818
+ */
819
+ public function checkbox_callback( $args ) {
820
+ global ${$this->func . '_options'};
821
+
822
+ $name = ' name="' . $this->func . '_settings[' . $this->sanitize_key( $args['id'] ) . ']"';
823
+ $class = $this->sanitize_html_class( $args['field_class'] );
824
+ $checked = isset( ${$this->func . '_options'}[ $args['id'] ] ) ? checked( 1, ${$this->func . '_options'}[ $args['id'] ], false ) : '';
825
+ ?>
826
+ <input type="hidden" name="<?php echo esc_attr( $name ); ?>" value="-1" />
827
+ <input type="checkbox" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $name ); ?>" value="1" <?php echo esc_attr( $checked ); ?> class="<?php echo esc_attr( $class ); ?>"/>&nbsp;
828
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
829
+ <?php
830
+ do_action( $this->func . '_after_setting_output', $args );
831
+ }
832
+
833
+
834
+ /**
835
+ * Color callback
836
+ *
837
+ * @access public
838
+ * @since 1.0.0
839
+ * @param array $args Arguments passed by the settings.
840
+ * @global array ${$this->func . '_options'} The Beacon options
841
+ * @return void
842
+ */
843
+ public function color_callback( $args ) {
844
+ global ${$this->func . '_options'};
845
+
846
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
847
+ $value = ${$this->func . '_options'}[ $args['id'] ];
848
+ } else {
849
+ $value = isset( $args['std'] ) ? $args['std'] : '';
850
+ }
851
+
852
+ $default = isset( $args['std'] ) ? $args['std'] : '';
853
+ $class = $this->sanitize_html_class( $args['field_class'] );
854
+ ?>
855
+ <input type="text" class="simple-settings-color-picker <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $args['id'] ); ?>]" value="<?php echo esc_attr( $value ); ?>" data-default-color="<?php echo esc_attr( $default ); ?>" />&nbsp;
856
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
857
+ <?php
858
+ do_action( $this->func . '_after_setting_output', $args );
859
+ }
860
+
861
+
862
+ /**
863
+ * Descriptive text callback
864
+ *
865
+ * @access public
866
+ * @since 1.0.0
867
+ * @param array $args Arguments passed by the setting.
868
+ * @return void
869
+ */
870
+ public function descriptive_text_callback( $args ) {
871
+ do_action( $this->func . '_after_setting_output', $args );
872
+ }
873
+
874
+
875
+ /**
876
+ * Editor callback
877
+ *
878
+ * @access public
879
+ * @since 1.0.0
880
+ * @param array $args Arguments passed by the setting.
881
+ * @global array ${$this->func . '_options'} The Beacon options
882
+ * @return void
883
+ */
884
+ public function editor_callback( $args ) {
885
+ global ${$this->func . '_options'};
886
+
887
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
888
+ $value = ${$this->func . '_options'}[ $args['id'] ];
889
+
890
+ if ( empty( $args['allow_blank'] ) && empty( $value ) ) {
891
+ $value = isset( $args['std'] ) ? $args['std'] : '';
892
+ }
893
+ } else {
894
+ $value = isset( $args['std'] ) ? $args['std'] : '';
895
+ }
896
+
897
+ $rows = isset( $args['size'] ) ? $args['size'] : '20';
898
+ $wpautop = isset( $args['wpautop'] ) ? $args['wpautop'] : true;
899
+ $buttons = isset( $args['buttons'] ) ? $args['buttons'] : true;
900
+ $teeny = isset( $args['teeny'] ) ? $args['teeny'] : false;
901
+ $class = $this->sanitize_html_class( $args['field_class'] );
902
+
903
+ wp_editor(
904
+ stripslashes( $value ),
905
+ $this->func . '_settings_' . esc_attr( $args['id'] ),
906
+ array(
907
+ 'wpautop' => $wpautop,
908
+ 'media_buttons' => $buttons,
909
+ 'textarea_name' => $this->func . '_settings[' . esc_attr( $args['id'] ) . ']',
910
+ 'textarea_rows' => absint( $rows ),
911
+ 'teeny' => $teeny,
912
+ 'editor_class' => $class,
913
+ )
914
+ );
915
+ ?>
916
+ <br /><label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
917
+ <?php
918
+ do_action( $this->func . '_after_setting_output', $args );
919
+ }
920
+
921
+
922
+ /**
923
+ * HTML callback
924
+ *
925
+ * @access public
926
+ * @since 1.0.0
927
+ * @param array $args Arguments passed by the setting.
928
+ * @global array ${$this->func . '_options'} The Beacon options
929
+ * @return void
930
+ */
931
+ public function html_callback( $args ) {
932
+ global ${$this->func . '_options'};
933
+
934
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
935
+ $value = ${$this->func . '_options'}[ $args['id'] ];
936
+ } else {
937
+ $value = isset( $args['std'] ) ? $args['std'] : '';
938
+ }
939
+ ?>
940
+ <textarea class="large-text simple-settings-html" cols="50" rows="5" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo esc_textarea( stripslashes( $value ) ); ?></textarea>&nbsp;
941
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>';
942
+ <?php
943
+ do_action( $this->func . '_after_setting_output', $args );
944
+ }
945
+
946
+
947
+ /**
948
+ * Multicheck callback
949
+ *
950
+ * @access public
951
+ * @since 1.0.0
952
+ * @param array $args Arguments passed by the setting.
953
+ * @global array ${$this->func . '_options'} The Beacon options
954
+ * @return void
955
+ */
956
+ public function multicheck_callback( $args ) {
957
+ global ${$this->func . '_options'};
958
+
959
+ $class = $this->sanitize_html_class( $args['field_class'] );
960
+
961
+ if ( ! empty( $args['options'] ) ) {
962
+ ?>
963
+ <input type="hidden" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" value="-1" />
964
+ <?php
965
+ foreach ( $args['options'] as $key => $option ) {
966
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ][ $key ] ) ) {
967
+ $enabled = $option;
968
+ } else {
969
+ $enabled = isset( $args['std'][ $key ] ) ? $args['std'][ $key ] : null;
970
+ }
971
+ ?>
972
+ <input name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>][<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>]" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>][<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>]" class="<?php echo esc_attr( $class ); ?>" type="checkbox" value="<?php echo esc_attr( $option ); ?>" <?php checked( $option, $enabled ); ?> />&nbsp;
973
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>][<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>]"><?php echo wp_kses_post( $option ); ?></label><br />
974
+ <?php
975
+ }
976
+ ?>
977
+ <p class="description" style="display: inline-block"><?php echo wp_kses_post( $args['desc'] ); ?></p>
978
+ <?php
979
+ do_action( $this->func . '_after_setting_output', $args );
980
+ }
981
+ }
982
+
983
+
984
+ /**
985
+ * Number callback
986
+ *
987
+ * @access public
988
+ * @since 1.0.0
989
+ * @param array $args Arguments passed by the setting.
990
+ * @global array ${$this->func . '_options'} The Beacon options
991
+ * @return void
992
+ */
993
+ public function number_callback( $args ) {
994
+ global ${$this->func . '_options'};
995
+
996
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
997
+ $value = ${$this->func . '_options'}[ $args['id'] ];
998
+ } else {
999
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1000
+ }
1001
+
1002
+ $name = ' name="' . $this->func . '_settings[' . $this->sanitize_key( $args['id'] ) . ']"';
1003
+ $max = isset( $args['max'] ) ? $args['max'] : 999999;
1004
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
1005
+ $step = isset( $args['step'] ) ? $args['step'] : 1;
1006
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1007
+ $readonly = true === $args['readonly'] ? ' readonly="readonly"' : '';
1008
+ $class = $this->sanitize_html_class( $args['field_class'] );
1009
+ ?>
1010
+ <input type="number" step="<?php echo esc_attr( $step ); ?>" max="<?php echo esc_attr( $max ); ?>" min="<?php echo esc_attr( $min ); ?>" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $this->sanitize_html_class( $size ) ); ?>-text" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"<?php echo esc_attr( $readonly ); ?>/>&nbsp;
1011
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
1012
+ <?php
1013
+ do_action( $this->func . '_after_setting_output', $args );
1014
+ }
1015
+
1016
+
1017
+ /**
1018
+ * Password callback
1019
+ *
1020
+ * @access public
1021
+ * @since 1.0.0
1022
+ * @param array $args Arguments passed by the settings.
1023
+ * @global array ${$this->func . '_options'} The Beacon options
1024
+ * @return void
1025
+ */
1026
+ public function password_callback( $args ) {
1027
+ global ${$this->func . '_options'};
1028
+
1029
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1030
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1031
+ } else {
1032
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1033
+ }
1034
+
1035
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1036
+ $class = $this->sanitize_html_class( $args['field_class'] );
1037
+ ?>
1038
+ <input type="password" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $this->sanitize_html_class( $size ) ); ?>-text" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" value="<?php echo esc_attr( $value ); ?>" />&nbsp;
1039
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
1040
+ <?php
1041
+ do_action( $this->func . '_after_setting_output', $args );
1042
+ }
1043
+
1044
+
1045
+ /**
1046
+ * Radio callback
1047
+ *
1048
+ * @access public
1049
+ * @since 1.0.0
1050
+ * @param array $args Arguments passed by the setting.
1051
+ * @global array ${$this->func . '_options'} The Beacon options
1052
+ * @return void
1053
+ */
1054
+ public function radio_callback( $args ) {
1055
+ global ${$this->func . '_options'};
1056
+
1057
+ if ( ! empty( $args['options'] ) ) {
1058
+ $class = $this->sanitize_html_class( $args['field_class'] );
1059
+
1060
+ $html = '';
1061
+
1062
+ foreach ( $args['options'] as $key => $option ) {
1063
+ $checked = false;
1064
+
1065
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) && ${$this->func . '_options'}[ $args['id'] ] === $key ) {
1066
+ $checked = true;
1067
+ } elseif ( isset( $args['std'] ) && $args['std'] === $key && ! isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1068
+ $checked = true;
1069
+ }
1070
+ ?>
1071
+ <input name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>][<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>]" type="radio" class="<?php echo esc_attr( $class ); ?>" value="<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>" <?php echo esc_attr( checked( true, $checked, false ) ); ?>/>&nbsp;
1072
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>][<?php echo esc_attr( $this->sanitize_key( $key ) ); ?>]"><?php echo wp_kses_post( $option ); ?></label><br />
1073
+ <?php
1074
+ }
1075
+ ?>
1076
+ <p class="description"><?php do_action( $this->func . '_after_setting_output', $args ); ?></p>
1077
+ <?php
1078
+ }
1079
+ }
1080
+
1081
+
1082
+ /**
1083
+ * Select callback
1084
+ *
1085
+ * @access public
1086
+ * @since 1.0.0
1087
+ * @param array $args Arguments passed by the setting.
1088
+ * @global array ${$this->func . '_options'} The Beacon options
1089
+ * @return void
1090
+ */
1091
+ public function select_callback( $args ) {
1092
+ global ${$this->func . '_options'};
1093
+
1094
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1095
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1096
+ } else {
1097
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1098
+ }
1099
+
1100
+ $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
1101
+ $select2 = isset( $args['select2'] ) ? 'simple-settings-select2' : '';
1102
+ $width = isset( $args['size'] ) ? ' style="width: ' . $args['size'] . '"' : '';
1103
+ $class = $this->sanitize_html_class( $args['field_class'] );
1104
+
1105
+ $nonce = isset( $args['data']['nonce'] ) ? ' data-nonce="' . sanitize_text_field( $args['data']['nonce'] ) . '"' : '';
1106
+
1107
+ // If the field allows multiples, save as an array.
1108
+ $name_attr = $this->func . '_settings[' . $this->sanitize_key( $args['id'] ) . ']';
1109
+ $name_attr = ( $args['multiple'] ) ? $name_attr . '[]' : $name_attr;
1110
+ ?>
1111
+ <select <?php echo esc_attr( $nonce ); ?> id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $name_attr ); ?>" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $select2 ); ?>" data-placeholder="<?php echo esc_html( $placeholder ); ?>"<?php echo esc_attr( $width ) . ( ( $args['multiple'] ) ? ' multiple="true"' : '' ); ?> />
1112
+ <?php
1113
+ foreach ( $args['options'] as $option => $name ) {
1114
+ if ( ! $args['multiple'] ) {
1115
+ $selected = selected( $option, $value, false );
1116
+ ?>
1117
+ <option value="<?php echo esc_attr( $option ); ?>" <?php echo esc_attr( $selected ); ?>><?php echo esc_html( $name ); ?></option>
1118
+ <?php
1119
+ } else {
1120
+ ?>
1121
+ <option value="<?php echo esc_attr( $option ); ?>" <?php echo ( ( in_array( $option, $value, true ) ) ? 'selected="true"' : '' ); ?>><?php echo esc_html( $name ); ?></option>
1122
+ <?php
1123
+ }
1124
+ }
1125
+ ?>
1126
+ </select>&nbsp;
1127
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
1128
+ <?php
1129
+ do_action( $this->func . '_after_setting_output', $args );
1130
+ }
1131
+
1132
+
1133
+ /**
1134
+ * Sysinfo callback
1135
+ *
1136
+ * @since 1.1.0
1137
+ * @param array $args Arguments passed by the settings.
1138
+ * @return void
1139
+ */
1140
+ public function sysinfo_callback( $args ) {
1141
+ global ${$this->func . '_options'};
1142
+
1143
+ if ( isset( $_REQUEST[ $this->func . '_settings_nonce' ] ) ) {
1144
+ check_admin_referer( $this->func . '_settings_nonce', $this->func . '_settings_nonce' );
1145
+ }
1146
+
1147
+ if ( ! isset( ${$this->func . '_options'}[ $args['tab'] ] ) || ( isset( ${$this->func . '_options'}[ $args['tab'] ] ) && isset( $_GET['tab'] ) && ${$this->func . '_options'}[ $args['tab'] ] === $_GET['tab'] ) ) {
1148
+ ?>
1149
+ <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="<?php echo esc_attr( $this->func ); ?>-system-info" title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'simple-settings' ); ?>"><?php echo esc_attr( $this->sysinfo->get_system_info() ); ?></textarea>
1150
+ <p class="submit">
1151
+ <input type="hidden" name="<?php echo esc_attr( $this->slug ); ?>-settings-action" value="download_system_info" />
1152
+ <a class="button button-primary" href="<?php echo esc_url( add_query_arg( $this->slug . '-settings-action', 'download_system_info' ) ); ?>"><?php esc_attr_e( 'Download System Info File', 'simple-settings' ); ?></a>
1153
+ </p>
1154
+ <?php
1155
+ do_action( $this->func . '_after_setting_output', $args );
1156
+ }
1157
+ }
1158
+
1159
+
1160
+ /**
1161
+ * Text callback
1162
+ *
1163
+ * @since 1.0.0
1164
+ * @param array $args Arguments passed by the setting.
1165
+ * @global array ${$this->func . '_options'} The Beacon options
1166
+ * @return void
1167
+ */
1168
+ public function text_callback( $args ) {
1169
+ global ${$this->func . '_options'};
1170
+
1171
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1172
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1173
+ } else {
1174
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1175
+ }
1176
+
1177
+ $name = ' name="' . $this->func . '_settings[' . $this->sanitize_key( $args['id'] ) . ']"';
1178
+ $readonly = true === $args['readonly'] ? ' readonly="readonly"' : '';
1179
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1180
+ $class = $this->sanitize_html_class( $args['field_class'] );
1181
+ $disabled = ! empty( $args['disabled'] ) ? ' disabled="disabled"' : '';
1182
+ $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
1183
+ ?>
1184
+ <input type="text" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $this->sanitize_html_class( $size ) ); ?>-text" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"<?php echo esc_attr( $name ); ?> placeholder="<?php echo esc_attr( stripslashes( $placeholder ) ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"<?php echo esc_attr( $readonly ); ?> />&nbsp;
1185
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
1186
+ <?php
1187
+ do_action( $this->func . '_after_setting_output', $args );
1188
+ }
1189
+
1190
+
1191
+ /**
1192
+ * Textarea callback
1193
+ *
1194
+ * @since 1.0.0
1195
+ * @param array $args Arguments passed by the setting.
1196
+ * @global array ${$this->func . '_options'} The Beacon options
1197
+ * @return void
1198
+ */
1199
+ public function textarea_callback( $args ) {
1200
+ global ${$this->func . '_options'};
1201
+
1202
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1203
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1204
+ } else {
1205
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1206
+ }
1207
+
1208
+ $class = $this->sanitize_html_class( $args['field_class'] );
1209
+ ?>
1210
+ <textarea class="<?php echo esc_attr( $class ); ?> large-text" cols="50" rows="5" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo esc_textarea( stripslashes( $value ) ); ?></textarea>&nbsp;
1211
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses_post( $args['desc'] ); ?></label>
1212
+ <?php
1213
+ do_action( $this->func . '_after_setting_output', $args );
1214
+ }
1215
+
1216
+
1217
+ /**
1218
+ * Upload callback
1219
+ *
1220
+ * @since 1.0.0
1221
+ * @param array $args Arguments passed by the setting.
1222
+ * @global array ${$this->func . '_options'} The Beacon options
1223
+ * @return void
1224
+ */
1225
+ public function upload_callback( $args ) {
1226
+ global ${$this->func . '_options'};
1227
+
1228
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1229
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1230
+ } else {
1231
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1232
+ }
1233
+
1234
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1235
+ $class = $this->sanitize_html_class( $args['field_class'] );
1236
+ ?>
1237
+ <input type="text" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $this->sanitize_html_class( $size ) ); ?>-text" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" value="<?php echo esc_attr( stripslashes( $value ) ); ?>" />&nbsp;
1238
+ <span>&nbsp;<input type="button" class="<?php echo esc_attr( $this->func ); ?>_settings_upload_button button-secondary" value="<?php esc_attr_e( 'Upload File', 'simple-settings' ); ?>" /></span>&nbsp;
1239
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"><?php echo wp_kses( $args['desc'] ); ?></label>
1240
+ <?php
1241
+ do_action( $this->func . '_after_setting_output', $args );
1242
+ }
1243
+
1244
+
1245
+ /**
1246
+ * License field callback
1247
+ *
1248
+ * @access public
1249
+ * @since 1.0.0
1250
+ * @param array $args Arguments passed by the setting.
1251
+ * @global array ${$this->func . '_options'} The Beacon options
1252
+ * @return void
1253
+ */
1254
+ public function license_key_callback( $args ) {
1255
+ global ${$this->func . '_options'};
1256
+
1257
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
1258
+ $value = ${$this->func . '_options'}[ $args['id'] ];
1259
+ } else {
1260
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1261
+ }
1262
+
1263
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1264
+ $class = $this->sanitize_html_class( $args['field_class'] );
1265
+ ?>
1266
+ <input type="text" class="<?php echo esc_attr( $class ) . ' ' . esc_attr( $this->sanitize_html_class( $size ) ); ?>-text" id="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" name="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]" value="<?php echo esc_attr( $value ); ?>" />&nbsp;
1267
+ <?php
1268
+ if ( get_option( $args['options']['is_valid_license_option'] ) ) {
1269
+ ?>
1270
+ <input type="submit" class="button-secondary" name="<?php echo esc_attr( $args['id'] ); ?>_deactivate" value="<?php esc_attr_e( 'Deactivate License', 'simple-settings' ); ?>"/>
1271
+ <?php
1272
+ }
1273
+ ?>
1274
+ <label for="<?php echo esc_attr( $this->func ); ?>_settings[<?php echo esc_attr( $this->sanitize_key( $args['id'] ) ); ?>]"> <?php echo wp_kses_post( $args['desc'] ); ?></label>
1275
+ <?php
1276
+ wp_nonce_field( $this->sanitize_key( $args['id'] ) . '-nonce', $this->sanitize_key( $args['id'] ) . '-nonce' );
1277
+
1278
+ do_action( $this->func . '_after_setting_output', $args );
1279
+ }
1280
+
1281
+
1282
+ /**
1283
+ * Hook callback
1284
+ *
1285
+ * @since 1.0.0
1286
+ * @param array $args Arguments passed by the setting.
1287
+ * @return void
1288
+ */
1289
+ public function hook_callback( $args ) {
1290
+ do_action( $this->func . '_' . $args['id'], $args );
1291
+ }
1292
+
1293
+
1294
+ /**
1295
+ * Missing callback
1296
+ *
1297
+ * @access public
1298
+ * @since 1.0.0
1299
+ * @param array $args Arguments passed by the setting.
1300
+ * @return string The text to display when a callback is missing
1301
+ */
1302
+ public function missing_callback( $args ) {
1303
+ // Translators: The passed ID that has no corresponding callback.
1304
+ return sprintf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'simple-settings' ), $args['id'] );
1305
+ }
1306
+
1307
+
1308
+ /**
1309
+ * Check if we should load admin scripts
1310
+ *
1311
+ * @access public
1312
+ * @since 1.0.0
1313
+ * @param string $hook The hook for the current page.
1314
+ * @return bool true if we should load scripts, false otherwise
1315
+ */
1316
+ public function load_scripts( $hook ) {
1317
+ global $typenow, $pagenow, ${$this->func . '_settings_page'};
1318
+
1319
+ $ret = false;
1320
+ $pages = apply_filters( $this->func . '_admin_pages', array( ${$this->func . '_settings_page'} ) );
1321
+
1322
+ if ( in_array( $hook, $pages, true ) ) {
1323
+ $ret = true;
1324
+ }
1325
+
1326
+ return (bool) apply_filters( $this->func . 'load_scripts', $ret );
1327
+ }
1328
+
1329
+
1330
+ /**
1331
+ * Processes all actions sent via POST and GET by looking for the '$func-settings-action'
1332
+ * request and running do_action() to call the function
1333
+ *
1334
+ * @since 1.1.0
1335
+ * @return void
1336
+ */
1337
+ public function process_actions() {
1338
+ if ( isset( $_REQUEST[ $this->sanitize_key( $args['id'] ) . '-nonce' ] ) ) {
1339
+ check_admin_referer( $this->sanitize_key( $args['id'] ) . '-nonce', $this->sanitize_key( $args['id'] ) . '-nonce' );
1340
+ }
1341
+
1342
+ $post = wp_unslash( $_POST );
1343
+
1344
+ if ( ! isset( $post['submit'] ) ) {
1345
+ if ( isset( $post[ $this->slug . '-settings-action' ] ) ) {
1346
+ do_action( $this->func . '_settings_' . $post[ $this->slug . '-settings-action' ], $post );
1347
+ }
1348
+
1349
+ $get = wp_unslash( $_GET );
1350
+
1351
+ if ( isset( $get[ $this->slug . '-settings-action' ] ) ) {
1352
+ do_action( $this->func . '_settings_' . $get[ $this->slug . '-settings-action' ], $get );
1353
+ }
1354
+ }
1355
+ }
1356
+
1357
+
1358
+ /**
1359
+ * Enqueue scripts
1360
+ *
1361
+ * @access public
1362
+ * @since 1.0.0
1363
+ * @param string $hook The current page hook.
1364
+ * @return void
1365
+ */
1366
+ public function enqueue_scripts( $hook ) {
1367
+ if ( ! apply_filters( $this->func . '_load_admin_scripts', $this->load_scripts( $hook ), $hook ) ) {
1368
+ return;
1369
+ }
1370
+
1371
+ // Use minified libraries if SCRIPT_DEBUG is turned off.
1372
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1373
+ $ui_style = ( get_user_option( 'admin_color' ) === 'classic' ) ? 'classic' : 'fresh';
1374
+ $url_path = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname( __FILE__ ) );
1375
+ $select2_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/';
1376
+ $cm_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.46.0/';
1377
+
1378
+ wp_enqueue_style( 'wp-color-picker' );
1379
+ wp_enqueue_script( 'wp-color-picker' );
1380
+ wp_enqueue_script( 'jquery-ui-tooltip' );
1381
+ wp_enqueue_media();
1382
+ wp_enqueue_style( 'jquery-ui-css', $url_path . '/assets/css/jquery-ui-' . $ui_style . '.min.css', array(), '1.0.0' );
1383
+ wp_enqueue_script( 'media-upload' );
1384
+ wp_enqueue_style( 'thickbox' );
1385
+ wp_enqueue_script( 'thickbox' );
1386
+ wp_enqueue_style( 'select2', $select2_cdn . 'css/select2.min.css', array(), '4.0.7' );
1387
+ wp_enqueue_script( 'select2', $select2_cdn . 'js/select2.min.js', array( 'jquery' ), '4.0.7', true );
1388
+
1389
+ wp_enqueue_style( $this->slug . '-cm', $cm_cdn . 'codemirror.css', array(), '5.46.0' );
1390
+ wp_enqueue_script( $this->slug . '-cm', $cm_cdn . 'codemirror.js', array( 'jquery' ), '5.46.0', true );
1391
+ wp_enqueue_script( $this->slug . '-cm-html', $cm_cdn . 'mode/htmlmixed/htmlmixed.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1392
+ wp_enqueue_script( $this->slug . '-cm-xml', $cm_cdn . 'mode/xml/xml.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1393
+ wp_enqueue_script( $this->slug . '-cm-js', $cm_cdn . 'mode/javascript/javascript.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1394
+ wp_enqueue_script( $this->slug . '-cm-css', $cm_cdn . 'mode/css/css.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1395
+ wp_enqueue_script( $this->slug . '-cm-php', $cm_cdn . 'mode/php/php.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1396
+ wp_enqueue_script( $this->slug . '-cm-clike', $cm_cdn . 'mode/clike/clike.js', array( 'jquery', $this->slug . '-cm' ), '5.46.0', true );
1397
+
1398
+ wp_enqueue_style( $this->slug . '-simple-settings', $url_path . '/assets/css/admin' . $suffix . '.css', array(), $this->version );
1399
+ wp_enqueue_script( $this->slug . '-simple-settings', $url_path . '/assets/js/admin' . $suffix . '.js', array( 'jquery' ), $this->version, true );
1400
+ wp_localize_script(
1401
+ $this->slug . '-simple-settings',
1402
+ 'simple_settings_vars',
1403
+ apply_filters(
1404
+ $this->func . 'localize_script',
1405
+ array(
1406
+ 'func' => $this->func,
1407
+ 'image_media_button' => __( 'Insert Image', 'simple-settings' ),
1408
+ 'image_media_title' => __( 'Select Image', 'simple-settings' ),
1409
+ )
1410
+ )
1411
+ );
1412
+ }
1413
+
1414
+
1415
+ /**
1416
+ * Add tooltips
1417
+ *
1418
+ * @access public
1419
+ * @since 1.2.0
1420
+ * @param array $args Arguments passed to the field.
1421
+ * @return void
1422
+ */
1423
+ public function add_setting_tooltip( $args ) {
1424
+ if ( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1425
+ ?>
1426
+ <span alt="f223" class="simple-settings-help-tip dashicons dashicons-editor-help" title="<strong><?php echo esc_attr( $args['tooltip_title'] ); ?></strong>: <?php echo esc_attr( $args['tooltip_desc'] ); ?>"></span>
1427
+ <?php
1428
+ }
1429
+ }
1430
+ }
includes/libraries/simple-settings/composer.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "widgitlabs/simple-settings",
3
+ "type": "library",
4
+ "description": "A library for implementing a simple, transparent settings panel in WordPress.",
5
+ "keywords": ["settings", "options", "WordPress"],
6
+ "homepage": "https://widgit.io/",
7
+ "license": "GPL-3.0+",
8
+ "authors": [
9
+ {
10
+ "name": "Daniel J Griffiths",
11
+ "email": "dgriffiths@evertiro.com"
12
+ }
13
+ ],
14
+ "support": {
15
+ "issues": "https://gitlab.com/widgitlabs/wordpress/simple-settings/issues"
16
+ },
17
+ "require": {
18
+ "php": ">=5.3.0",
19
+ "composer/installers": "~1.0"
20
+ },
21
+ "require-dev": {
22
+ "phpunit/phpunit": "4.8.* || 5.7.*",
23
+ "phpunit/php-invoker": "1.1.3"
24
+ },
25
+ "minimum-stability": "dev"
26
+ }
includes/libraries/simple-settings/license.txt ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. 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
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
includes/libraries/simple-settings/modules/licensing/class-simple-settings-license.php ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License handler for Simple Settings
4
+ *
5
+ * @package Widgit\SimpleSettings\License
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Simple Settings license handler class
17
+ *
18
+ * @since 1.0.0
19
+ */
20
+ class Simple_Settings_License {
21
+
22
+
23
+ /**
24
+ * The licensed file
25
+ *
26
+ * @access private
27
+ * @since 1.0.0
28
+ * @var string $file The licensed file
29
+ */
30
+ private $file;
31
+
32
+
33
+ /**
34
+ * The license key
35
+ *
36
+ * @access private
37
+ * @since 1.0.0
38
+ * @var string $license The license key
39
+ */
40
+ private $license;
41
+
42
+
43
+ /**
44
+ * The name of the item
45
+ *
46
+ * @access private
47
+ * @since 1.0.0
48
+ * @var string $item_name The name of the item
49
+ */
50
+ private $item_name;
51
+
52
+
53
+ /**
54
+ * The ID of the item
55
+ *
56
+ * @access private
57
+ * @since 1.0.0
58
+ * @var int $item_id The ID of the item
59
+ */
60
+ private $item_id;
61
+
62
+
63
+ /**
64
+ * The short name of the item
65
+ *
66
+ * @access private
67
+ * @since 1.0.0
68
+ * @var string $item_shortname The short name of the item
69
+ */
70
+ private $item_shortname;
71
+
72
+
73
+ /**
74
+ * The version of the item
75
+ *
76
+ * @access private
77
+ * @since 1.0.0
78
+ * @var string $version The version of the item
79
+ */
80
+ private $version;
81
+
82
+
83
+ /**
84
+ * The author of the item
85
+ *
86
+ * @access private
87
+ * @since 1.0.0
88
+ * @var string $author The author of the item
89
+ */
90
+ private $author;
91
+
92
+
93
+ /**
94
+ * The slug of the item
95
+ *
96
+ * @access private
97
+ * @since 1.0.0
98
+ * @var string $slug The slug of the item
99
+ */
100
+ private $slug;
101
+
102
+
103
+ /**
104
+ * The API URL
105
+ *
106
+ * @access private
107
+ * @since 1.0.0
108
+ * @var string $api_url The API URL
109
+ */
110
+ private $api_url = '';
111
+
112
+
113
+ /**
114
+ * Class constructor
115
+ *
116
+ * @access public
117
+ * @since 1.0.0
118
+ * @param string $_file The item file.
119
+ * @param string $_slug The item slug.
120
+ * @param string $_item The item name.
121
+ * @param string $_version The item version.
122
+ * @param string $_author The item author.
123
+ * @param string $_api_url The API URL.
124
+ * @return void
125
+ */
126
+ public function __construct( $_file, $_slug, $_item, $_version, $_author, $_api_url = null ) {
127
+ $this->file = $_file;
128
+
129
+ if ( is_numeric( $_item ) ) {
130
+ $this->item_id = absint( $_item );
131
+ } else {
132
+ $this->item_name = $_item;
133
+ }
134
+
135
+ $this->item_shortname = preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
136
+ $this->item_slug = $_slug;
137
+
138
+ $options = get_option( $this->item_shortname . '_settings', '' );
139
+
140
+ $this->version = $_version;
141
+ $this->license = ( isset( $options['license_key'] ) ? trim( $options['license_key'] ) : '' );
142
+ $this->author = $_author;
143
+ $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url;
144
+
145
+ // Setup hooks.
146
+ $this->includes();
147
+ $this->hooks();
148
+ }
149
+
150
+
151
+ /**
152
+ * Include the updater class
153
+ *
154
+ * @access private
155
+ * @return void
156
+ */
157
+ private function includes() {
158
+ if ( ! class_exists( 'Simple_Settings_Plugin_Updater' ) ) {
159
+ require_once 'Simple_Settings_Plugin_Updater.php';
160
+ }
161
+ }
162
+
163
+
164
+ /**
165
+ * Setup hooks
166
+ *
167
+ * @access private
168
+ * @return void
169
+ */
170
+ private function hooks() {
171
+ // Register settings.
172
+ add_filter( $this->item_shortname . '_settings_tabs', array( $this, 'tabs' ) );
173
+ add_filter( $this->item_shortname . '_registered_settings', array( $this, 'settings' ) );
174
+
175
+ // Activate license key on settings save.
176
+ add_action( 'admin_init', array( $this, 'activate_license' ) );
177
+
178
+ // Deactivate license key.
179
+ add_action( 'admin_init', array( $this, 'deactivate_license' ) );
180
+
181
+ // Updater.
182
+ add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
183
+
184
+ add_action( 'admin_notices', array( $this, 'notices' ) );
185
+ }
186
+
187
+
188
+ /**
189
+ * Auto updater
190
+ *
191
+ * @access private
192
+ * @return void
193
+ */
194
+ public function auto_updater() {
195
+ if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) {
196
+ return;
197
+ }
198
+
199
+ $args = array(
200
+ 'version' => $this->version,
201
+ 'license' => $this->license,
202
+ 'author' => $this->author,
203
+ );
204
+
205
+ if ( ! empty( $this->item_id ) ) {
206
+ $args['item_id'] = $this->item_id;
207
+ } else {
208
+ $args['item_name'] = $this->item_name;
209
+ }
210
+
211
+ // Setup the updater.
212
+ $edd_updater = new Simple_Settings_Plugin_Updater(
213
+ $this->api_url,
214
+ $this->file,
215
+ $args
216
+ );
217
+ }
218
+
219
+
220
+ /**
221
+ * Add license tab to settings
222
+ *
223
+ * @access public
224
+ * @param array $tabs The setting tabs.
225
+ * @return array $tabs The updated setting tabs
226
+ */
227
+ public function tabs( $tabs ) {
228
+ $tabs['license'] = __( 'Licensing', 'simple-settings' );
229
+
230
+ return $tabs;
231
+ }
232
+
233
+
234
+ /**
235
+ * Add license field to settings
236
+ *
237
+ * @access public
238
+ * @param array $settings The existing settings.
239
+ * @return array The updated settings
240
+ */
241
+ public function settings( $settings ) {
242
+ $license_settings = array(
243
+ 'license' => array(
244
+ array(
245
+ 'id' => $this->item_shortname . '_license_key',
246
+ // Translators: The item name for this license.
247
+ 'name' => sprintf( __( '%1$s License Key', 'simple-settings' ), $this->item_name ),
248
+ 'desc' => __( 'Please enter your license key to enable automatic updates and support.', 'simple-settings' ),
249
+ 'type' => 'license_key',
250
+ 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
251
+ 'size' => 'regular',
252
+ ),
253
+ ),
254
+ );
255
+
256
+ return array_merge( $settings, $license_settings );
257
+ }
258
+
259
+
260
+ /**
261
+ * Activate the license key
262
+ *
263
+ * @access public
264
+ * @return void
265
+ */
266
+ public function activate_license() {
267
+ check_admin_referer( $this->func . '_settings_nonce', $this->func . '_settings_nonce' );
268
+
269
+ if ( ! isset( $_POST[ $this->item_shortname . '_settings' ] ) ) {
270
+ return;
271
+ }
272
+
273
+ if ( ! isset( $_POST[ $this->item_shortname . '_settings' ][ $this->item_shortname . '_license_key' ] ) ) {
274
+ return;
275
+ }
276
+
277
+ foreach ( $_POST as $key => $value ) {
278
+ if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
279
+ // Don't activate a key when deactivating a different key.
280
+ return;
281
+ }
282
+ }
283
+
284
+ $nonce = esc_url( $this->item_shortname ) . '_license_key-nonce';
285
+
286
+ if ( ! isset( $_REQUEST[ $nonce ] ) ) {
287
+ return;
288
+ }
289
+
290
+ if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST[ $nonce ] ) ), $nonce ) ) {
291
+ wp_die( esc_attr__( 'Nonce verification failed', 'simple-settings' ), esc_attr__( 'Error', 'simple-settings' ), array( 'response' => 403 ) );
292
+ }
293
+
294
+ if ( ! current_user_can( 'manage_options' ) ) {
295
+ return;
296
+ }
297
+
298
+ if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) {
299
+ return;
300
+ }
301
+
302
+ $license = sanitize_text_field( wp_unslash( $_POST[ $this->item_shortname . '_settings' ][ $this->item_shortname . '_license_key' ] ) );
303
+
304
+ if ( empty( $license ) ) {
305
+ return;
306
+ }
307
+
308
+ // Data to send to the API.
309
+ $api_params = array(
310
+ 'edd_action' => 'activate_license',
311
+ 'license' => $license,
312
+ 'item_name' => rawurlencode( $this->item_name ),
313
+ 'url' => home_url(),
314
+ );
315
+
316
+ // Call the API.
317
+ $response = wp_remote_post(
318
+ $this->api_url,
319
+ array(
320
+ 'timeout' => 3,
321
+ 'sslverify' => false,
322
+ 'body' => $api_params,
323
+ )
324
+ );
325
+
326
+ // Make sure there are no errors.
327
+ if ( is_wp_error( $response ) ) {
328
+ return;
329
+ }
330
+
331
+ // Tell WordPress to look for updates.
332
+ set_site_transient( 'update_plugins', null );
333
+
334
+ // Decode license data.
335
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
336
+
337
+ update_option( $this->item_shortname . '_license_active', $license_data->license );
338
+
339
+ if ( ! (bool) $license_data->success ) {
340
+ set_transient( $this->item_shortname . '_license_error', $license_data, 1000 );
341
+ } else {
342
+ delete_transient( $this->item_shortname . '_license_error' );
343
+ }
344
+ }
345
+
346
+
347
+ /**
348
+ * Deactivate the license key
349
+ *
350
+ * @access public
351
+ * @return void
352
+ */
353
+ public function deactivate_license() {
354
+ if ( ! isset( $_POST[ $this->item_shortname . '_settings' ] ) ) {
355
+ return;
356
+ }
357
+
358
+ if ( ! isset( $_POST[ $this->item_shortname . '_settings' ][ $this->item_shortname . '_license_key' ] ) ) {
359
+ return;
360
+ }
361
+
362
+ $nonce = $this->item_shortname . '_license_key-nonce';
363
+
364
+ if ( ! isset( $_REQUEST[ $nonce ] ) ) {
365
+ return;
366
+ }
367
+
368
+ if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST[ $nonce ] ) ), $nonce ) ) {
369
+ wp_die( esc_attr__( 'Nonce verification failed', 'simple-settings' ), esc_attr__( 'Error', 'simple-settings' ), array( 'response' => 403 ) );
370
+ }
371
+
372
+ if ( ! current_user_can( 'manage_options' ) ) {
373
+ return;
374
+ }
375
+
376
+ // Run on deactivate button press.
377
+ if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
378
+ $license = sanitize_text_field( wp_unslash( $_POST[ $this->item_shortname . '_settings' ][ $this->item_shortname . '_license_key' ] ) );
379
+
380
+ if ( empty( $license ) ) {
381
+ return;
382
+ }
383
+
384
+ // Data to send to the API.
385
+ $api_params = array(
386
+ 'edd_action' => 'deactivate_license',
387
+ 'license' => $license,
388
+ 'item_name' => rawurlencode( $this->item_name ),
389
+ 'url' => home_url(),
390
+ );
391
+
392
+ // Call the API.
393
+ $response = wp_remote_post(
394
+ $this->api_url,
395
+ array(
396
+ 'timeout' => 3,
397
+ 'sslverify' => false,
398
+ 'body' => $api_params,
399
+ )
400
+ );
401
+
402
+ // Make sure there are no errors.
403
+ if ( is_wp_error( $response ) ) {
404
+ return;
405
+ }
406
+
407
+ // Decode the license data.
408
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
409
+
410
+ delete_option( $this->item_shortname . '_license_active' );
411
+
412
+ if ( ! (bool) $license_data->success ) {
413
+ set_transient( $this->item_shortname . '_license_error', $license_data, 1000 );
414
+ } else {
415
+ delete_transient( $this->item_shortname . '_license_error' );
416
+ }
417
+ }
418
+ }
419
+
420
+
421
+ /**
422
+ * Admin notices for errors
423
+ *
424
+ * @access public
425
+ * @return void
426
+ */
427
+ public function notices() {
428
+ if ( isset( $_REQUEST[ $this->sanitize_key( $args['id'] ) . '-nonce' ] ) ) {
429
+ check_admin_referer( $this->sanitize_key( $args['id'] ) . '-nonce', $this->sanitize_key( $args['id'] ) . '-nonce' );
430
+ }
431
+
432
+ if ( ! isset( $_GET['page'] ) || $this->item_slug . '-settings' !== $_GET['page'] ) {
433
+ return;
434
+ }
435
+
436
+ if ( ! isset( $_GET['tab'] ) || 'license' !== $_GET['tab'] ) {
437
+ return;
438
+ }
439
+
440
+ $license_error = get_transient( $this->item_shortname . '_license_error' );
441
+
442
+ if ( false === $license_error ) {
443
+ return;
444
+ }
445
+
446
+ if ( ! empty( $license_error->error ) ) {
447
+
448
+ switch ( $license_error->error ) {
449
+ case 'item_name_mismatch':
450
+ $message = __( 'This license does not belong to the product you have entered it for.', 'simple-settings' );
451
+ break;
452
+ case 'no_activations_left':
453
+ $message = __( 'This license does not have any activations left', 'simple-settings' );
454
+ break;
455
+ case 'expired':
456
+ $message = __( 'This license key is expired. Please renew it.', 'simple-settings' );
457
+ break;
458
+ default:
459
+ // Translators: The details of the error code.
460
+ $message = sprintf( __( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'simple-settings' ), $license_error->error );
461
+ break;
462
+ }
463
+ }
464
+
465
+ if ( ! empty( $message ) ) {
466
+ echo '<div class="error">';
467
+ echo '<p>' . esc_html( $message ) . '</p>';
468
+ echo '</div>';
469
+ }
470
+
471
+ delete_transient( $this->item_shortname . '_license_error' );
472
+ }
473
+ }
includes/libraries/simple-settings/modules/licensing/class-simple-settings-plugin-updater.php ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Update handler for Simple Settings
4
+ *
5
+ * @package Widgit\SimpleSettings\Updater
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Uncomment this line for testing:
17
+ * set_site_transient( 'update_plugins', null );
18
+ */
19
+
20
+
21
+ /**
22
+ * Allows plugins to use their own update API.
23
+ *
24
+ * @author Pippin Williamson
25
+ * @version 1.6
26
+ */
27
+ class Simple_Settings_Plugin_Updater {
28
+
29
+
30
+ /**
31
+ * The API URL
32
+ *
33
+ * @access private
34
+ * @since 1.0.0
35
+ * @var string $api_url The API URL
36
+ */
37
+ private $api_url = '';
38
+
39
+
40
+ /**
41
+ * The API data
42
+ *
43
+ * @access private
44
+ * @since 1.0.0
45
+ * @var array $api_data The API data
46
+ */
47
+ private $api_data = array();
48
+
49
+
50
+ /**
51
+ * The item name
52
+ *
53
+ * @access private
54
+ * @since 1.0.0
55
+ * @var string $name The item name
56
+ */
57
+ private $name = '';
58
+
59
+
60
+ /**
61
+ * The item slug
62
+ *
63
+ * @access private
64
+ * @since 1.0.0
65
+ * @var string $slug The item slug
66
+ */
67
+ private $slug = '';
68
+
69
+
70
+ /**
71
+ * The item version
72
+ *
73
+ * @access private
74
+ * @since 1.0.0
75
+ * @var string $version The item version
76
+ */
77
+ private $version = '';
78
+
79
+
80
+ /**
81
+ * Class constructor.
82
+ *
83
+ * @access public
84
+ * @since 1.0.0
85
+ * @param string $_api_url The URL pointing to the custom API endpoint.
86
+ * @param string $_plugin_file Path to the plugin file.
87
+ * @param array $_api_data Optional data to send with API calls.
88
+ * @return void
89
+ */
90
+ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
91
+ global $simple_settings_plugin_data;
92
+
93
+ $this->api_url = trailingslashit( $_api_url );
94
+ $this->api_data = $_api_data;
95
+ $this->name = plugin_basename( $_plugin_file );
96
+ $this->slug = basename( $_plugin_file, '.php' );
97
+ $this->version = $_api_data['version'];
98
+
99
+ $simple_settings_plugin_data[ $this->slug ] = $this->api_data;
100
+
101
+ // Set up hooks.
102
+ $this->init();
103
+ }
104
+
105
+ /**
106
+ * Set up WordPress filters to hook into WordPress's update process.
107
+ *
108
+ * @uses add_filter()
109
+ *
110
+ * @return void
111
+ */
112
+ public function init() {
113
+
114
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
115
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
116
+
117
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
118
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
119
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
120
+ }
121
+
122
+ /**
123
+ * Check for Updates at the defined API endpoint and modify the update array.
124
+ *
125
+ * This function dives into the update API just when WordPress creates its update array,
126
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
127
+ * It is reassembled from parts of the native WordPress plugin update code.
128
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
129
+ *
130
+ * @access public
131
+ * @since 1.0.0
132
+ * @param array $_transient_data Update array build by WordPress.
133
+ * @return array Modified update array with custom plugin data.
134
+ */
135
+ public function check_update( $_transient_data ) {
136
+
137
+ global $pagenow;
138
+
139
+ if ( ! is_object( $_transient_data ) ) {
140
+ $_transient_data = new stdClass();
141
+ }
142
+
143
+ if ( 'plugins.php' === $pagenow && is_multisite() ) {
144
+ return $_transient_data;
145
+ }
146
+
147
+ if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
148
+
149
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
150
+
151
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
152
+
153
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
154
+
155
+ if ( empty( $version_info->plugin ) ) {
156
+ $version_info->plugin = $this->name;
157
+ }
158
+
159
+ $_transient_data->response[ $this->name ] = $version_info;
160
+
161
+ }
162
+
163
+ $_transient_data->last_checked = time();
164
+ $_transient_data->checked[ $this->name ] = $this->version;
165
+
166
+ }
167
+ }
168
+
169
+ return $_transient_data;
170
+ }
171
+
172
+ /**
173
+ * Show update notification row -- needed for multisite subsites, because WP won't tell you otherwise!
174
+ *
175
+ * @access public
176
+ * @since 1.0.0
177
+ * @param string $file The item file.
178
+ * @param array $plugin The plugin data.
179
+ * @return void
180
+ */
181
+ public function show_update_notification( $file, $plugin ) {
182
+
183
+ if ( ! current_user_can( 'update_plugins' ) ) {
184
+ return;
185
+ }
186
+
187
+ if ( ! is_multisite() ) {
188
+ return;
189
+ }
190
+
191
+ if ( $this->name !== $file ) {
192
+ return;
193
+ }
194
+
195
+ // Remove our filter on the site transient.
196
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
197
+
198
+ $update_cache = get_site_transient( 'update_plugins' );
199
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
200
+
201
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
202
+
203
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $this->name ) . '_version_info' );
204
+ $version_info = get_transient( $cache_key );
205
+
206
+ if ( false === $version_info ) {
207
+
208
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
209
+
210
+ set_transient( $cache_key, $version_info, 3600 );
211
+ }
212
+
213
+ if ( ! is_object( $version_info ) ) {
214
+ return;
215
+ }
216
+
217
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
218
+
219
+ $update_cache->response[ $this->name ] = $version_info;
220
+
221
+ }
222
+
223
+ $update_cache->last_checked = time();
224
+ $update_cache->checked[ $this->name ] = $this->version;
225
+
226
+ set_site_transient( 'update_plugins', $update_cache );
227
+ } else {
228
+ $version_info = $update_cache->response[ $this->name ];
229
+
230
+ }
231
+
232
+ // Restore our filter.
233
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
234
+
235
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
236
+
237
+ // build a plugin list row, with update notification.
238
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
239
+ echo '<tr class="plugin-update-tr"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
240
+
241
+ $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' );
242
+
243
+ if ( empty( $version_info->download_link ) ) {
244
+ printf(
245
+ // Translators: The name, link, and version.
246
+ esc_html__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
247
+ esc_html( $version_info->name ),
248
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
249
+ esc_html( $version_info->new_version ),
250
+ '</a>'
251
+ );
252
+ } else {
253
+ printf(
254
+ // Translators: The name, link, version, and download link.
255
+ esc_html__( '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' ),
256
+ esc_html( $version_info->name ),
257
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
258
+ esc_html( $version_info->new_version ),
259
+ '</a>',
260
+ '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">',
261
+ '</a>'
262
+ );
263
+ }
264
+
265
+ do_action( "in_plugin_update_message_{$file}", $plugin, $version_info );
266
+
267
+ echo '</div></td></tr>';
268
+ }
269
+ }
270
+
271
+
272
+ /**
273
+ * Updates information on the "View version x.x details" page with custom data.
274
+ *
275
+ * @access public
276
+ * @since 1.0.0
277
+ * @param mixed $_data The plugin data.
278
+ * @param string $_action The page action.
279
+ * @param object $_args The plugin arguments.
280
+ * @return object $_data Data for the details page.
281
+ */
282
+ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
283
+ if ( 'plugin_information' !== $_action ) {
284
+ return $_data;
285
+ }
286
+
287
+ if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->slug ) ) {
288
+ return $_data;
289
+ }
290
+
291
+ $to_send = array(
292
+ 'slug' => $this->slug,
293
+ 'is_ssl' => is_ssl(),
294
+ 'fields' => array(
295
+ 'banners' => false, // These will be supported soon hopefully.
296
+ 'reviews' => false,
297
+ ),
298
+ );
299
+
300
+ $api_response = $this->api_request( 'plugin_information', $to_send );
301
+
302
+ if ( false !== $api_response ) {
303
+ $_data = $api_response;
304
+ }
305
+
306
+ return $_data;
307
+ }
308
+
309
+
310
+ /**
311
+ * Disable SSL verification in order to prevent download update failures
312
+ *
313
+ * @access public
314
+ * @since 1.0.0
315
+ * @param array $args The HTTP request arguments.
316
+ * @param string $url The requested URL.
317
+ * @return object $array The HTTP request arguments
318
+ */
319
+ public function http_request_args( $args, $url ) {
320
+ // If it is an https request and we are performing a package download, disable ssl verification.
321
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
322
+ $args['sslverify'] = false;
323
+ }
324
+ return $args;
325
+ }
326
+
327
+ /**
328
+ * Calls the API and, if successful, returns the object delivered by the API.
329
+ *
330
+ * @access private
331
+ * @since 1.0.0
332
+ * @param string $_action The requested action.
333
+ * @param array $_data Parameters for the API action.
334
+ * @return false|object The data fetched from the API
335
+ */
336
+ private function api_request( $_action, $_data ) {
337
+
338
+ global $wp_version;
339
+
340
+ $data = array_merge( $this->api_data, $_data );
341
+
342
+ if ( $data['slug'] !== $this->slug ) {
343
+ return;
344
+ }
345
+
346
+ if ( empty( $data['license'] ) ) {
347
+ return;
348
+ }
349
+
350
+ if ( home_url() === $this->api_url ) {
351
+ return false; // Don't allow a plugin to ping itself.
352
+ }
353
+
354
+ $api_params = array(
355
+ 'edd_action' => 'get_version',
356
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
357
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
358
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
359
+ 'slug' => $data['slug'],
360
+ 'author' => $data['author'],
361
+ 'url' => home_url(),
362
+ );
363
+
364
+ $request = wp_remote_post(
365
+ $this->api_url,
366
+ array(
367
+ 'timeout' => 3,
368
+ 'sslverify' => false,
369
+ 'body' => $api_params,
370
+ )
371
+ );
372
+
373
+ if ( ! is_wp_error( $request ) ) {
374
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
375
+ }
376
+
377
+ if ( $request && isset( $request->sections ) ) {
378
+ $request->sections = maybe_unserialize( $request->sections );
379
+ } else {
380
+ $request = false;
381
+ }
382
+
383
+ return $request;
384
+ }
385
+
386
+
387
+ /**
388
+ * Show the item changelog
389
+ *
390
+ * @access public
391
+ * @since 1.0.0
392
+ * @return void
393
+ */
394
+ public function show_changelog() {
395
+ if ( isset( $_REQUEST[ $this->name . '_settings_nonce' ] ) ) {
396
+ check_admin_referer( $this->name . '_settings_nonce', $this->name . '_settings_nonce' );
397
+ }
398
+
399
+ if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) {
400
+ return;
401
+ }
402
+
403
+ if ( empty( $_REQUEST['plugin'] ) ) {
404
+ return;
405
+ }
406
+
407
+ if ( empty( $_REQUEST['slug'] ) ) {
408
+ return;
409
+ }
410
+
411
+ if ( ! current_user_can( 'update_plugins' ) ) {
412
+ wp_die( esc_html__( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
413
+ }
414
+
415
+ global $simple_settings_plugin_data;
416
+
417
+ $data = $simple_settings_plugin_data[ sanitize_text_field( wp_unslash( $_REQUEST['slug'] ) ) ];
418
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' );
419
+ $version_info = get_transient( $cache_key );
420
+
421
+ if ( false === $version_info ) {
422
+ $api_params = array(
423
+ 'edd_action' => 'get_version',
424
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
425
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
426
+ 'slug' => sanitize_text_field( wp_unslash( $_REQUEST['slug'] ) ),
427
+ 'author' => $data['author'],
428
+ 'url' => home_url(),
429
+ );
430
+
431
+ $request = wp_remote_post(
432
+ $this->api_url,
433
+ array(
434
+ 'timeout' => 3,
435
+ 'sslverify' => false,
436
+ 'body' => $api_params,
437
+ )
438
+ );
439
+
440
+ if ( ! is_wp_error( $request ) ) {
441
+ $version_info = json_decode( wp_remote_retrieve_body( $request ) );
442
+ }
443
+
444
+ if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
445
+ $version_info->sections = maybe_unserialize( $version_info->sections );
446
+ } else {
447
+ $version_info = false;
448
+ }
449
+
450
+ set_transient( $cache_key, $version_info, 3600 );
451
+ }
452
+
453
+ if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
454
+ echo '<div style="background:#fff;padding:10px;">' . esc_html( $response->sections['changelog'] ) . '</div>';
455
+ }
456
+
457
+ exit;
458
+ }
459
+
460
+ }
includes/libraries/simple-settings/modules/sysinfo/class-browser.php ADDED
@@ -0,0 +1,1931 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Browser detection library
4
+ *
5
+ * This program is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU General Public License as
7
+ * published by the Free Software Foundation; either version 2 of
8
+ * the License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details at:
14
+ * http://www.gnu.org/copyleft/gpl.html
15
+ *
16
+ * Originally by Chris Schuld (http://chrisschuld.com/)
17
+ * Modified by Chris Christoff
18
+ * Maintained by Daniel J Griffiths (https://evertiro.com/)
19
+ *
20
+ * Typical Usage:
21
+ *
22
+ * $browser = new Browser();
23
+ * if( $browser->get_browser() == Browser::browser_firefox && $browser->get_version() >= 2 ) {
24
+ * echo 'You have FireFox version 2 or greater';
25
+ * }
26
+ *
27
+ * User Agents Sampled from: http://www.useragentstring.com/
28
+ *
29
+ * This implementation is based on the original work from Gary White
30
+ * http://apptools.com/phptools/browser/
31
+ *
32
+ * @package Widgit\SimpleSettings\Browser
33
+ * @since 2.0.0
34
+ */
35
+
36
+ // Exit if accessed directly.
37
+ if ( ! defined( 'ABSPATH' ) ) {
38
+ exit;
39
+ }
40
+
41
+
42
+ /**
43
+ * Class for determining browser information
44
+ *
45
+ * @since 1.0.0
46
+ */
47
+ class Browser {
48
+
49
+
50
+ /**
51
+ * The user agent
52
+ *
53
+ * @access public
54
+ * @since 1.0.0
55
+ * @var string $agent The user agent
56
+ */
57
+ public $agent = '';
58
+
59
+
60
+ /**
61
+ * The browser name
62
+ *
63
+ * @access public
64
+ * @since 1.0.0
65
+ * @var string $browser_name The browser name
66
+ */
67
+ public $browser_name = '';
68
+
69
+
70
+ /**
71
+ * The browser version
72
+ *
73
+ * @access public
74
+ * @since 1.0.0
75
+ * @var string $version The browser version
76
+ */
77
+ public $version = '';
78
+
79
+
80
+ /**
81
+ * The users platform
82
+ *
83
+ * @access public
84
+ * @since 1.0.0
85
+ * @var string $platform The users platform
86
+ */
87
+ public $platform = '';
88
+
89
+
90
+ /**
91
+ * The users OS
92
+ *
93
+ * @access public
94
+ * @since 1.0.0
95
+ * @var string $os The users OS
96
+ */
97
+ public $os = '';
98
+
99
+
100
+ /**
101
+ * Whether or not the user is using AOL
102
+ *
103
+ * @access public
104
+ * @since 1.0.0
105
+ * @var bool $is_aol Whether or not the user is using AOL
106
+ */
107
+ public $is_aol = false;
108
+
109
+
110
+ /**
111
+ * Whether or not the user is using a mobile device
112
+ *
113
+ * @access public
114
+ * @since 1.0.0
115
+ * @var bool $is_mobile Whether or not the user is using a mobile device
116
+ */
117
+ public $is_mobile = false;
118
+
119
+
120
+ /**
121
+ * Whether or not the user is a robot
122
+ *
123
+ * @access public
124
+ * @since 1.0.0
125
+ * @var bool $is_robot Whether or not the user is a robot
126
+ */
127
+ public $is_robot = false;
128
+
129
+
130
+ /**
131
+ * The AOL version
132
+ *
133
+ * @access public
134
+ * @since 1.0.0
135
+ * @var string $aol_version The AOL version
136
+ */
137
+ public $aol_version = '';
138
+
139
+
140
+ /**
141
+ * The string for unknown browsers
142
+ *
143
+ * @access public
144
+ * @since 1.0.0
145
+ * @var string $browser_unknown The string for unknown browsers
146
+ */
147
+ public $browser_unknown = 'unknown';
148
+
149
+
150
+ /**
151
+ * The string for unknown versions
152
+ *
153
+ * @access public
154
+ * @since 1.0.0
155
+ * @var string $version_unknown The string for unknown versions
156
+ */
157
+ public $version_unknown = 'unknown';
158
+
159
+
160
+ /**
161
+ * The string for Opera browsers
162
+ *
163
+ * @access public
164
+ * @since 1.0.0
165
+ * @var string $browser_opera The string for Opera browsers
166
+ */
167
+ public $browser_opera = 'Opera';
168
+
169
+
170
+ /**
171
+ * The string for Opera mini browsers
172
+ *
173
+ * @access public
174
+ * @since 1.0.0
175
+ * @var string $browser_opera_mini The string for Opera browsers
176
+ */
177
+ public $browser_opera_mini = 'Opera Mini';
178
+
179
+
180
+ /**
181
+ * The string for WebTV browsers
182
+ *
183
+ * @access public
184
+ * @since 1.0.0
185
+ * @var string $browser_webtv The string for WebTV browsers
186
+ */
187
+ public $browser_webtv = 'WebTV';
188
+
189
+
190
+ /**
191
+ * The string for IE browsers
192
+ *
193
+ * @access public
194
+ * @since 1.0.0
195
+ * @var string $browser_ie The string for IE browsers
196
+ */
197
+ public $browser_ie = 'Internet Explorer';
198
+
199
+
200
+ /**
201
+ * The string for Pocket IE browsers
202
+ *
203
+ * @access public
204
+ * @since 1.0.0
205
+ * @var string $browser_pocket_ie The string for Pocket IE browsers
206
+ */
207
+ public $browser_pocket_ie = 'Pocket Internet Explorer';
208
+
209
+
210
+ /**
211
+ * The string for Konqueror browsers
212
+ *
213
+ * @access public
214
+ * @since 1.0.0
215
+ * @var string $browser_konqueror The string for Konqueror browsers
216
+ */
217
+ public $browser_konqueror = 'Konqueror';
218
+
219
+
220
+ /**
221
+ * The string for iCab browsers
222
+ *
223
+ * @access public
224
+ * @since 1.0.0
225
+ * @var string $browser_icab The string for iCab browsers
226
+ */
227
+ public $browser_icab = 'iCab';
228
+
229
+
230
+ /**
231
+ * The string for OmniWeb browsers
232
+ *
233
+ * @access public
234
+ * @since 1.0.0
235
+ * @var string $browser_omniweb The string for OmniWeb browsers
236
+ */
237
+ public $browser_omniweb = 'OmniWeb';
238
+
239
+
240
+ /**
241
+ * The string for Firebird browsers
242
+ *
243
+ * @access public
244
+ * @since 1.0.0
245
+ * @var string $browser_firebird The string for Firebird browsers
246
+ */
247
+ public $browser_firebird = 'Firebird';
248
+
249
+
250
+ /**
251
+ * The string for Firefox browsers
252
+ *
253
+ * @access public
254
+ * @since 1.0.0
255
+ * @var string $browser_firefox The string for Firefox browsers
256
+ */
257
+ public $browser_firefox = 'Firefox';
258
+
259
+
260
+ /**
261
+ * The string for Iceweasel browsers
262
+ *
263
+ * @access public
264
+ * @since 1.0.0
265
+ * @var string $browser_iceweasel The string for Iceweasel browsers
266
+ */
267
+ public $browser_iceweasel = 'Iceweasel';
268
+
269
+
270
+ /**
271
+ * The string for Shiretoko browsers
272
+ *
273
+ * @access public
274
+ * @since 1.0.0
275
+ * @var string $browser_shiretoko The string for Shiretoko browsers
276
+ */
277
+ public $browser_shiretoko = 'Shiretoko';
278
+
279
+
280
+ /**
281
+ * The string for Mozilla browsers
282
+ *
283
+ * @access public
284
+ * @since 1.0.0
285
+ * @var string $browser_mozilla The string for Mozilla browsers
286
+ */
287
+ public $browser_mozilla = 'Mozilla';
288
+
289
+
290
+ /**
291
+ * The string for Amaya browsers
292
+ *
293
+ * @access public
294
+ * @since 1.0.0
295
+ * @var string $browser_amaya The string for Amaya browsers
296
+ */
297
+ public $browser_amaya = 'Amaya';
298
+
299
+
300
+ /**
301
+ * The string for lynx browsers
302
+ *
303
+ * @access public
304
+ * @since 1.0.0
305
+ * @var string $browser_lynx The string for Lynx browsers
306
+ */
307
+ public $browser_lynx = 'Lynx';
308
+
309
+
310
+ /**
311
+ * The string for Safari browsers
312
+ *
313
+ * @access public
314
+ * @since 1.0.0
315
+ * @var string $browser_safari The string for Safari browsers
316
+ */
317
+ public $browser_safari = 'Safari';
318
+
319
+
320
+ /**
321
+ * The string for iPhone browsers
322
+ *
323
+ * @access public
324
+ * @since 1.0.0
325
+ * @var string $browser_iphone The string for iPhone browsers
326
+ */
327
+ public $browser_iphone = 'iPhone';
328
+
329
+
330
+ /**
331
+ * The string for iPod browsers
332
+ *
333
+ * @access public
334
+ * @since 1.0.0
335
+ * @var string $browser_ipod The string for iPod browsers
336
+ */
337
+ public $browser_ipod = 'iPod';
338
+
339
+
340
+ /**
341
+ * The string for iPad browsers
342
+ *
343
+ * @access public
344
+ * @since 1.0.0
345
+ * @var string $browser_ipad The string for iPad browsers
346
+ */
347
+ public $browser_ipad = 'iPad';
348
+
349
+
350
+ /**
351
+ * The string for Chrome browsers
352
+ *
353
+ * @access public
354
+ * @since 1.0.0
355
+ * @var string $browser_chrome The string for Chrome browsers
356
+ */
357
+ public $browser_chrome = 'Chrome';
358
+
359
+
360
+ /**
361
+ * The string for Android browsers
362
+ *
363
+ * @access public
364
+ * @since 1.0.0
365
+ * @var string $browser_android The string for Android browsers
366
+ */
367
+ public $browser_android = 'Android';
368
+
369
+
370
+ /**
371
+ * The string for GoogleBot browsers
372
+ *
373
+ * @access public
374
+ * @since 1.0.0
375
+ * @var string $browser_googlebot The string for GoogleBot browsers
376
+ */
377
+ public $browser_googlebot = 'GoogleBot';
378
+
379
+
380
+ /**
381
+ * The string for Slurp browsers
382
+ *
383
+ * @access public
384
+ * @since 1.0.0
385
+ * @var string $browser_slurp The string for Slurp browsers
386
+ */
387
+ public $browser_slurp = 'Yahoo! Slurp';
388
+
389
+
390
+ /**
391
+ * The string for W3C Validator browsers
392
+ *
393
+ * @access public
394
+ * @since 1.0.0
395
+ * @var string $browser_w3cvalidator The string for W3C Validator browsers
396
+ */
397
+ public $browser_w3cvalidator = 'W3C Validator';
398
+
399
+
400
+ /**
401
+ * The string for BlackBerry browsers
402
+ *
403
+ * @access public
404
+ * @since 1.0.0
405
+ * @var string $browser_blackberry The string for BlackBerry browsers
406
+ */
407
+ public $browser_blackberry = 'BlackBerry';
408
+
409
+
410
+ /**
411
+ * The string for IceCat browsers
412
+ *
413
+ * @access public
414
+ * @since 1.0.0
415
+ * @var string $browser_icecat The string for IceCat browsers
416
+ */
417
+ public $browser_icecat = 'IceCat';
418
+
419
+
420
+ /**
421
+ * The string for Nokia S60 browsers
422
+ *
423
+ * @access public
424
+ * @since 1.0.0
425
+ * @var string $browser_nokia_s60 The string for Nokia S60 browsers
426
+ */
427
+ public $browser_nokia_s60 = 'Nokia S60 OSS Browser';
428
+
429
+
430
+ /**
431
+ * The string for Nokia browsers
432
+ *
433
+ * @access public
434
+ * @since 1.0.0
435
+ * @var string $browser_nokia The string for Nokia browsers
436
+ */
437
+ public $browser_nokia = 'Nokia Browser';
438
+
439
+
440
+ /**
441
+ * The string for MSN browsers
442
+ *
443
+ * @access public
444
+ * @since 1.0.0
445
+ * @var string $browser_msn The string for MSN browsers
446
+ */
447
+ public $browser_msn = 'MSN Browser';
448
+
449
+
450
+ /**
451
+ * The string for MSN Bot browsers
452
+ *
453
+ * @access public
454
+ * @since 1.0.0
455
+ * @var string $browser_msnbot The string for MSN Bot browsers
456
+ */
457
+ public $browser_msnbot = 'MSN Bot';
458
+
459
+
460
+ /**
461
+ * The string for Netscape Navigator browsers
462
+ *
463
+ * @access public
464
+ * @since 1.0.0
465
+ * @var string $browser_netscape_navigator The string for Netscape Navigator browsers
466
+ */
467
+ public $browser_netscape_navigator = 'Netscape Navigator';
468
+
469
+
470
+ /**
471
+ * The string for Galeon browsers
472
+ *
473
+ * @access public
474
+ * @since 1.0.0
475
+ * @var string $browser_googlebot The string for GoogleBot browsers
476
+ */
477
+ public $browser_galeon = 'Galeon';
478
+
479
+
480
+ /**
481
+ * The string for NetPositive browsers
482
+ *
483
+ * @access public
484
+ * @since 1.0.0
485
+ * @var string $browser_netpositive The string for NetPositive browsers
486
+ */
487
+ public $browser_netpositive = 'NetPositive';
488
+
489
+
490
+ /**
491
+ * The string for Phoenix browsers
492
+ *
493
+ * @access public
494
+ * @since 1.0.0
495
+ * @var string $browser_phoenix The string for Phoenix browsers
496
+ */
497
+ public $browser_phoenix = 'Phoenix';
498
+
499
+
500
+ /**
501
+ * The string for unknown platforms
502
+ *
503
+ * @access public
504
+ * @since 1.0.0
505
+ * @var string $platform_unknown The string for unknown platforms
506
+ */
507
+ public $platform_unknown = 'unknown';
508
+
509
+
510
+ /**
511
+ * The string for Windows
512
+ *
513
+ * @access public
514
+ * @since 1.0.0
515
+ * @var string $platform_windows The string for Windows
516
+ */
517
+ public $platform_windows = 'Windows';
518
+
519
+
520
+ /**
521
+ * The string for Windows CE
522
+ *
523
+ * @access public
524
+ * @since 1.0.0
525
+ * @var string $platform_windows_ce The string for Windows CE
526
+ */
527
+ public $platform_windows_ce = 'Windows CE';
528
+
529
+
530
+ /**
531
+ * The string for Apple
532
+ *
533
+ * @access public
534
+ * @since 1.0.0
535
+ * @var string $platform_apple The string for Apple
536
+ */
537
+ public $platform_apple = 'Apple';
538
+
539
+
540
+ /**
541
+ * The string for Linux
542
+ *
543
+ * @access public
544
+ * @since 1.0.0
545
+ * @var string $platform_linux The string for Linux
546
+ */
547
+ public $platform_linux = 'Linux';
548
+
549
+
550
+ /**
551
+ * The string for OS2
552
+ *
553
+ * @access public
554
+ * @since 1.0.0
555
+ * @var string $platform_os2 The string for OS2
556
+ */
557
+ public $platform_os2 = 'OS/2';
558
+
559
+
560
+ /**
561
+ * The string for BeOS
562
+ *
563
+ * @access public
564
+ * @since 1.0.0
565
+ * @var string $platform_beos The string for BeOS
566
+ */
567
+ public $platform_beos = 'BeOS';
568
+
569
+
570
+ /**
571
+ * The string for iPhone
572
+ *
573
+ * @access public
574
+ * @since 1.0.0
575
+ * @var string $platform_iphone The string for iPhone
576
+ */
577
+ public $platform_iphone = 'iPhone';
578
+
579
+
580
+ /**
581
+ * The string for iPod
582
+ *
583
+ * @access public
584
+ * @since 1.0.0
585
+ * @var string $platform_ipod The string for iPod
586
+ */
587
+ public $platform_ipod = 'iPod';
588
+
589
+
590
+ /**
591
+ * The string for iPad
592
+ *
593
+ * @access public
594
+ * @since 1.0.0
595
+ * @var string $platform_ipad The string for iPad
596
+ */
597
+ public $platform_ipad = 'iPad';
598
+
599
+
600
+ /**
601
+ * The string for BlackBerry
602
+ *
603
+ * @access public
604
+ * @since 1.0.0
605
+ * @var string $platform_blackberry The string for BlackBerry
606
+ */
607
+ public $platform_blackberry = 'BlackBerry';
608
+
609
+
610
+ /**
611
+ * The string for Nokia
612
+ *
613
+ * @access public
614
+ * @since 1.0.0
615
+ * @var string $platform_nokia The string for Nokia
616
+ */
617
+ public $platform_nokia = 'Nokia';
618
+
619
+
620
+ /**
621
+ * The string for FreeBSD
622
+ *
623
+ * @access public
624
+ * @since 1.0.0
625
+ * @var string $platform_freebsd The string for FreeBSD
626
+ */
627
+ public $platform_freebsd = 'FreeBSD';
628
+
629
+
630
+ /**
631
+ * The string for OpenBSD
632
+ *
633
+ * @access public
634
+ * @since 1.0.0
635
+ * @var string $platform_openbsd The string for OpenBSD
636
+ */
637
+ public $platform_openbsd = 'OpenBSD';
638
+
639
+
640
+ /**
641
+ * The string for NetBSD
642
+ *
643
+ * @access public
644
+ * @since 1.0.0
645
+ * @var string $platform_netbsd The string for NetBSD
646
+ */
647
+ public $platform_netbsd = 'NetBSD';
648
+
649
+
650
+ /**
651
+ * The string for SunOS
652
+ *
653
+ * @access public
654
+ * @since 1.0.0
655
+ * @var string $platform_sunos The string for SunOS
656
+ */
657
+ public $platform_sunos = 'SunOS';
658
+
659
+
660
+ /**
661
+ * The string for OpenSolaris
662
+ *
663
+ * @access public
664
+ * @since 1.0.0
665
+ * @var string $platform_opensolaris The string for OpenSolaris
666
+ */
667
+ public $platform_opensolaris = 'OpenSolaris';
668
+
669
+
670
+ /**
671
+ * The string for Android
672
+ *
673
+ * @access public
674
+ * @since 1.0.0
675
+ * @var string $platform_android The string for Android
676
+ */
677
+ public $platform_android = 'Android';
678
+
679
+
680
+ /**
681
+ * The string for unknown operating systems
682
+ *
683
+ * @access public
684
+ * @since 1.0.0
685
+ * @var string $operating_system_unknown The string for unknown operating systems
686
+ */
687
+ public $operating_system_unknown = 'unknown';
688
+
689
+
690
+ /**
691
+ * Get things started
692
+ *
693
+ * @access public
694
+ * @since 1.0.0
695
+ * @param string $useragent The useragent to parse.
696
+ * @return void
697
+ */
698
+ public function __construct( $useragent = '' ) {
699
+ $this->reset();
700
+
701
+ if ( '' !== $useragent ) {
702
+ $this->set_user_agent( $useragent );
703
+ } else {
704
+ $this->determine();
705
+ }
706
+ }
707
+
708
+
709
+ /**
710
+ * Reset all properties
711
+ *
712
+ * @access public
713
+ * @since 1.0.0
714
+ * @return void
715
+ */
716
+ public function reset() {
717
+ $this->agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ""; // phpcs:ignore
718
+ $this->browser_name = $this->browser_unknown;
719
+ $this->version = $this->version_unknown;
720
+ $this->platform = $this->platform_unknown;
721
+ $this->os = $this->operating_system_unknown;
722
+ $this->is_aol = false;
723
+ $this->is_mobile = false;
724
+ $this->is_robot = false;
725
+ $this->aol_version = $this->version_unknown;
726
+ }
727
+
728
+
729
+ /**
730
+ * Check to see if the specific browser is valid
731
+ *
732
+ * @access public
733
+ * @since 1.0.0
734
+ * @param string $browser_name The browser name to check.
735
+ * @return bool Whether or not the browser is the specified browser
736
+ */
737
+ public function is_browser( $browser_name ) {
738
+ return 0 === strcasecmp( $this->browser_name, trim( $browser_name ) );
739
+ }
740
+
741
+
742
+ /**
743
+ * The name of the browser. All return types are from the class constants
744
+ *
745
+ * @access public
746
+ * @since 1.0.0
747
+ * @return string Name of the browser
748
+ */
749
+ public function get_browser() {
750
+ return $this->browser_name;
751
+ }
752
+
753
+
754
+ /**
755
+ * Set the name of the browser
756
+ *
757
+ * @access public
758
+ * @since 1.0.0
759
+ * @param string $browser The name of the browser.
760
+ * @return string $browser The name of the browser
761
+ */
762
+ public function set_browser( $browser ) {
763
+ $this->browser_name = $browser;
764
+
765
+ return $browser;
766
+ }
767
+
768
+
769
+ /**
770
+ * The name of the platform. All return types are from the class constants
771
+ *
772
+ * @access public
773
+ * @since 1.0.0
774
+ * @return string Name of the browser
775
+ */
776
+ public function get_platform() {
777
+ return $this->platform;
778
+ }
779
+
780
+
781
+ /**
782
+ * Set the name of the platform
783
+ *
784
+ * @access public
785
+ * @since 1.0.0
786
+ * @param string $platform The name of the platform.
787
+ * @return string $platform The name of the platform
788
+ */
789
+ public function set_platform( $platform ) {
790
+ $this->platform = $platform;
791
+
792
+ return $platform;
793
+ }
794
+
795
+
796
+ /**
797
+ * The version of the browser
798
+ *
799
+ * @access public
800
+ * @since 1.0.0
801
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
802
+ */
803
+ public function get_version() {
804
+ return $this->version;
805
+ }
806
+
807
+
808
+ /**
809
+ * Set the version of the browser
810
+ *
811
+ * @access public
812
+ * @since 1.0.0
813
+ * @param string $version The version of the browser.
814
+ * @return void
815
+ */
816
+ public function set_version( $version ) {
817
+ $this->version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version );
818
+ }
819
+
820
+
821
+ /**
822
+ * The version of AOL
823
+ *
824
+ * @access public
825
+ * @since 1.0.0
826
+ * @return string The version of AOL (will only contain alpha-numeric characters and a period)
827
+ */
828
+ public function get_aol_version() {
829
+ return $this->aol_version;
830
+ }
831
+
832
+
833
+ /**
834
+ * Set the version of AOL
835
+ *
836
+ * @access public
837
+ * @since 1.0.0
838
+ * @param string $version The version of AOL.
839
+ * @return void
840
+ */
841
+ public function set_aol_version( $version ) {
842
+ $this->aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version );
843
+ }
844
+
845
+
846
+ /**
847
+ * Is the browser from AOL?
848
+ *
849
+ * @access public
850
+ * @since 1.0.0
851
+ * @return bool Whether or not the browser is from AOL
852
+ */
853
+ public function is_aol() {
854
+ return $this->is_aol;
855
+ }
856
+
857
+
858
+ /**
859
+ * Is the browser from a mobile device?
860
+ *
861
+ * @access public
862
+ * @since 1.0.0
863
+ * @return bool Whether or not the browser is from a mobile device
864
+ */
865
+ public function is_mobile() {
866
+ return $this->is_mobile;
867
+ }
868
+
869
+
870
+ /**
871
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
872
+ *
873
+ * @access public
874
+ * @since 1.0.0
875
+ * @return bool Whether or not the browser is from a robot
876
+ */
877
+ public function is_robot() {
878
+ return $this->is_robot;
879
+ }
880
+
881
+
882
+ /**
883
+ * Set the browser to be from AOL
884
+ *
885
+ * @access public
886
+ * @since 1.0.0
887
+ * @param bool $is_aol Whether or not the browser is from AOL.
888
+ * @return void
889
+ */
890
+ public function set_aol( $is_aol ) {
891
+ $this->is_aol = $is_aol;
892
+ }
893
+
894
+
895
+ /**
896
+ * Set the browser to be mobile
897
+ *
898
+ * @access public
899
+ * @since 1.0.0
900
+ * @param bool $value Whether the browser a mobile browser or not.
901
+ * @return void
902
+ */
903
+ public function set_mobile( $value = true ) {
904
+ $this->is_mobile = $value;
905
+ }
906
+
907
+
908
+ /**
909
+ * Set the browser to be a robot
910
+ *
911
+ * @access public
912
+ * @since 1.0.0
913
+ * @param bool $value Whether the browser is a robot or not.
914
+ * @return void
915
+ */
916
+ public function set_robot( $value = true ) {
917
+ $this->is_robot = $value;
918
+ }
919
+
920
+
921
+ /**
922
+ * Get the user agent value in use to determine the browser
923
+ *
924
+ * @access public
925
+ * @since 1.0.0
926
+ * @return string The user agent from the HTTP header.
927
+ */
928
+ public function get_user_agent() {
929
+ return $this->agent;
930
+ }
931
+
932
+
933
+ /**
934
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
935
+ *
936
+ * @access public
937
+ * @since 1.0.0
938
+ * @param string $agent_string The value for the User Agent.
939
+ * @return void
940
+ */
941
+ public function set_user_agent( $agent_string ) {
942
+ $this->reset();
943
+ $this->agent = $agent_string;
944
+ $this->determine();
945
+ }
946
+
947
+
948
+ /**
949
+ * Used to determine if the browser is actually "chromeframe"
950
+ *
951
+ * @access public
952
+ * @since 1.7.0
953
+ * @return bool Whether the browser is using chromeframe
954
+ */
955
+ public function is_chrome_frame() {
956
+ return strpos( $this->agent, 'chromeframe' ) !== false;
957
+ }
958
+
959
+
960
+ /**
961
+ * Returns a formatted string with a summary of the details of the browser.
962
+ *
963
+ * @access public
964
+ * @since 1.0.0
965
+ * @return string The formatted string with a summary of the browser
966
+ */
967
+ public function __toString() {
968
+ $text1 = $this->get_user_agent(); // Grabs the UA (user agent) string.
969
+ $ua_line1 = substr( $text1, 0, 32 ); // The first line we print should only be the first 32 characters of the UA string.
970
+ $text2 = $this->get_user_agent(); // Now we grab it again and save it to a string.
971
+ $to_wrap_ua = str_replace( $ua_line1, '', $text2 ); // The rest of the print off (other than first line) is equivalent
972
+ // to the whole string minus the part we printed off. IE
973
+ // User Agent:
974
+ // The first 32 characters from ua_line1.
975
+ // The rest of it is now stored in $text2 to be printed off.
976
+ // We need to add spaces before each line that is split other than line 1.
977
+ $space = '';
978
+
979
+ for ( $i = 0; $i < 25; $i++ ) {
980
+ $space .= ' ';
981
+ }
982
+
983
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting.
984
+ $word_wrapped = chunk_split( $to_wrap_ua, 32, "\n $space" );
985
+
986
+ return "Platform: {$this->get_platform()} \n" .
987
+ "Browser Name: {$this->get_browser()} \n" .
988
+ "Browser Version: {$this->get_version()} \n" .
989
+ "User Agent String: $ua_line1 \n\t\t\t " .
990
+ "$word_wrapped";
991
+ }
992
+
993
+
994
+ /**
995
+ * Protected routine to calculate and determine what the browser is in use (including platform)
996
+ *
997
+ * @access protected
998
+ * @since 1.0.0
999
+ * @return void
1000
+ */
1001
+ protected function determine() {
1002
+ $this->check_platform();
1003
+ $this->check_browsers();
1004
+ $this->check_for_aol();
1005
+ }
1006
+
1007
+
1008
+ /**
1009
+ * Protected routine to determine the browser type
1010
+ *
1011
+ * @access protected
1012
+ * @since 1.0.0
1013
+ * @return bool Whether or not the browser was detected
1014
+ */
1015
+ protected function check_browsers() {
1016
+ return (
1017
+ // Well-known, well-used
1018
+ // Special Notes:
1019
+ // (1) Opera must be checked before FireFox due to the odd
1020
+ // user agents used in some older versions of Opera.
1021
+ // (2) WebTV is strapped onto Internet Explorer so we must
1022
+ // check for WebTV before IE.
1023
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
1024
+ // tested before Firefox is tested.
1025
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
1026
+ // before Safari.
1027
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
1028
+ // before FireFox are necessary.
1029
+ $this->check_browser_webtv() ||
1030
+ $this->check_browser_internet_explorer() ||
1031
+ $this->check_browser_opera() ||
1032
+ $this->check_browser_galeon() ||
1033
+ $this->check_browser_netscape_navigator_9plus() ||
1034
+ $this->check_browser_firefox() ||
1035
+ $this->check_browser_chrome() ||
1036
+ $this->check_browser_omniweb() ||
1037
+
1038
+ // Common mobile.
1039
+ $this->check_browser_android() ||
1040
+ $this->check_browser_ipad() ||
1041
+ $this->check_browser_ipod() ||
1042
+ $this->check_browser_iphone() ||
1043
+ $this->check_browser_blackberry() ||
1044
+ $this->check_browser_nokia() ||
1045
+
1046
+ // Common bots.
1047
+ $this->check_browser_googlebot() ||
1048
+ $this->check_browser_msnbot() ||
1049
+ $this->check_browser_slurp() ||
1050
+
1051
+ // WebKit base check (post mobile and others).
1052
+ $this->check_browser_safari() ||
1053
+
1054
+ // Everyone else.
1055
+ $this->check_browser_netpositive() ||
1056
+ $this->check_browser_firebird() ||
1057
+ $this->check_browser_konqueror() ||
1058
+ $this->check_browser_icab() ||
1059
+ $this->check_browser_phoenix() ||
1060
+ $this->check_browser_amaya() ||
1061
+ $this->check_browser_lynx() ||
1062
+
1063
+ $this->check_browser_shiretoko() ||
1064
+ $this->check_browser_icecat() ||
1065
+ $this->check_browser_w3cvalidator() ||
1066
+ $this->check_browser_mozilla() /* Mozilla is such an open standard that you must check it last */
1067
+ );
1068
+ }
1069
+
1070
+
1071
+ /**
1072
+ * Determine if the user is using a BlackBerry
1073
+ *
1074
+ * @access public
1075
+ * @since 1.0.0
1076
+ * @return bool Whether or not the browser is the BlackBerry browser
1077
+ */
1078
+ public function check_browser_blackberry() {
1079
+ if ( stripos( $this->agent, 'blackberry' ) !== false ) {
1080
+ $a_result = explode( '/', stristr( $this->agent, 'BlackBerry' ) );
1081
+ $a_version = explode( ' ', $a_result[1] );
1082
+
1083
+ $this->set_version( $a_version[0] );
1084
+ $this->browser_name = $this->browser_blackberry;
1085
+ $this->set_mobile( true );
1086
+
1087
+ return true;
1088
+ }
1089
+
1090
+ return false;
1091
+ }
1092
+
1093
+
1094
+ /**
1095
+ * Determine if the user is using an AOL User Agent
1096
+ *
1097
+ * @access public
1098
+ * @since 1.0.0
1099
+ * @return bool Whether or not the browser is from AOL
1100
+ */
1101
+ public function check_for_aol() {
1102
+ $this->set_aol( false );
1103
+ $this->set_aol_version( $this->version_unknown );
1104
+
1105
+ if ( stripos( $this->agent, 'aol' ) !== false ) {
1106
+ $a_version = explode( ' ', stristr( $this->agent, 'AOL' ) );
1107
+
1108
+ $this->set_aol( true );
1109
+ $this->set_aol_version( preg_replace( '/[^0-9\.a-z]/i', '', $a_version[1] ) );
1110
+
1111
+ return true;
1112
+ }
1113
+
1114
+ return false;
1115
+ }
1116
+
1117
+
1118
+ /**
1119
+ * Determine if the browser is the GoogleBot or not
1120
+ *
1121
+ * @access public
1122
+ * @since 1.0.0
1123
+ * @return bool Whether or not the browser is the GoogleBot
1124
+ */
1125
+ public function check_browser_googlebot() {
1126
+ if ( stripos( $this->agent, 'googlebot' ) !== false ) {
1127
+ $a_result = explode( '/', stristr( $this->agent, 'googlebot' ) );
1128
+ $a_version = explode( ' ', $a_result[1] );
1129
+
1130
+ $this->set_version( str_replace( ';', '', $a_version[0] ) );
1131
+ $this->browser_name = $this->browser_googlebot;
1132
+ $this->set_robot( true );
1133
+
1134
+ return true;
1135
+ }
1136
+
1137
+ return false;
1138
+ }
1139
+
1140
+
1141
+ /**
1142
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
1143
+ *
1144
+ * @access public
1145
+ * @since 1.0.0
1146
+ * @return bool Whether or not the browser is the MSNBot
1147
+ */
1148
+ public function check_browser_msnbot() {
1149
+ if ( stripos( $this->agent, 'msnbot' ) !== false ) {
1150
+ $a_result = explode( '/', stristr( $this->agent, 'msnbot' ) );
1151
+ $a_version = explode( ' ', $a_result[1] );
1152
+
1153
+ $this->set_version( str_replace( ';', '', $a_version[0] ) );
1154
+ $this->browser_name = $this->browser_msnbot;
1155
+ $this->set_robot( true );
1156
+
1157
+ return true;
1158
+ }
1159
+
1160
+ return false;
1161
+ }
1162
+
1163
+
1164
+ /**
1165
+ * Determine if the browser is the W3C Validator or not
1166
+ *
1167
+ * @access public
1168
+ * @since 1.0.0
1169
+ * @return bool Whether or not the browser is the W3C Validator
1170
+ */
1171
+ public function check_browser_w3cvalidator() {
1172
+ if ( stripos( $this->agent, 'W3C-checklink' ) !== false ) {
1173
+ $a_result = explode( '/', stristr( $this->agent, 'W3C-checklink' ) );
1174
+ $a_version = explode( ' ', $a_result[1] );
1175
+
1176
+ $this->set_version( $a_version[0] );
1177
+ $this->browser_name = $this->browser_w3cvalidator;
1178
+
1179
+ return true;
1180
+ } elseif ( stripos( $this->agent, 'W3C_Validator' ) !== false ) {
1181
+ // Some of the Validator versions do not delineate w/ a slash - add it back in.
1182
+ $ua = str_replace( 'W3C_Validator ', 'W3C_Validator/', $this->agent );
1183
+ $a_result = explode( '/', stristr( $ua, 'W3C_Validator' ) );
1184
+ $a_version = explode( ' ', $a_result[1] );
1185
+
1186
+ $this->set_version( $a_version[0] );
1187
+ $this->browser_name = $this->browser_w3cvalidator;
1188
+
1189
+ return true;
1190
+ }
1191
+
1192
+ return false;
1193
+ }
1194
+
1195
+
1196
+ /**
1197
+ * Determine if the browser is the Yahoo! Slurp Robot or not
1198
+ *
1199
+ * @access public
1200
+ * @since 1.0.0
1201
+ * @return bool Whether or not the browser is the Yahoo! Slurp Robot
1202
+ */
1203
+ public function check_browser_slurp() {
1204
+ if ( stripos( $this->agent, 'slurp' ) !== false ) {
1205
+ $a_result = explode( '/', stristr( $this->agent, 'Slurp' ) );
1206
+ $a_version = explode( ' ', $a_result[1] );
1207
+
1208
+ $this->set_version( $a_version[0] );
1209
+ $this->browser_name = $this->browser_slurp;
1210
+ $this->set_robot( true );
1211
+ $this->set_mobile( false );
1212
+
1213
+ return true;
1214
+ }
1215
+
1216
+ return false;
1217
+ }
1218
+
1219
+
1220
+ /**
1221
+ * Determine if the browser is Internet Explorer or not
1222
+ *
1223
+ * @access public
1224
+ * @since 1.0.0
1225
+ * @return bool Whether or not the browser is Internet Explorer
1226
+ */
1227
+ public function check_browser_internet_explorer() {
1228
+ if ( stripos( $this->agent, 'microsoft internet explorer' ) !== false ) {
1229
+ // Test for v1 - v1.5 IE.
1230
+ $this->set_browser( $this->browser_ie );
1231
+ $this->set_version( '1.0' );
1232
+
1233
+ $a_result = stristr( $this->agent, '/' );
1234
+
1235
+ if ( preg_match( '/308|425|426|474|0b1/i', $a_result ) ) {
1236
+ $this->set_version( '1.5' );
1237
+ }
1238
+
1239
+ return true;
1240
+ } elseif ( stripos( $this->agent, 'msie' ) !== false && stripos( $this->agent, 'opera' ) === false ) {
1241
+ // Test for versions > 1.5.
1242
+ // See if the browser is the odd MSN Explorer.
1243
+ if ( stripos( $this->agent, 'msnb' ) !== false ) {
1244
+ $a_result = explode( ' ', stristr( str_replace( ';', '; ', $this->agent ), 'MSN' ) );
1245
+
1246
+ $this->set_browser( $this->browser_msn );
1247
+ $this->set_version( str_replace( array( '(', ')', ';' ), '', $a_result[1] ) );
1248
+
1249
+ return true;
1250
+ }
1251
+
1252
+ $a_result = explode( ' ', stristr( str_replace( ';', '; ', $this->agent ), 'msie' ) );
1253
+
1254
+ $this->set_browser( $this->browser_ie );
1255
+ $this->set_version( str_replace( array( '(', ')', ';' ), '', $a_result[1] ) );
1256
+
1257
+ return true;
1258
+ } elseif ( stripos( $this->agent, 'mspie' ) !== false || stripos( $this->agent, 'pocket' ) !== false ) {
1259
+ // Test for Pocket IE.
1260
+ $a_result = explode( ' ', stristr( $this->agent, 'mspie' ) );
1261
+
1262
+ $this->set_platform( $this->platform_windows_ce );
1263
+ $this->set_browser( $this->browser_pocket_ie );
1264
+ $this->set_mobile( true );
1265
+
1266
+ if ( stripos( $this->agent, 'mspie' ) !== false ) {
1267
+ $this->set_version( $a_result[1] );
1268
+ } else {
1269
+ $a_version = explode( '/', $this->agent );
1270
+
1271
+ $this->set_version( $a_version[1] );
1272
+ }
1273
+
1274
+ return true;
1275
+ }
1276
+
1277
+ return false;
1278
+ }
1279
+
1280
+
1281
+ /**
1282
+ * Determine if the browser is Opera or not
1283
+ *
1284
+ * @access public
1285
+ * @since 1.0.0
1286
+ * @return bool Whether or not the browser is Opera
1287
+ */
1288
+ public function check_browser_opera() {
1289
+ if ( stripos( $this->agent, 'opera mini' ) !== false ) {
1290
+ $resultant = stristr( $this->agent, 'opera mini' );
1291
+
1292
+ if ( preg_match( '/\//', $resultant ) ) {
1293
+ $a_result = explode( '/', $resultant );
1294
+ $a_version = explode( ' ', $a_result[1] );
1295
+
1296
+ $this->set_version( $a_version[0] );
1297
+ } else {
1298
+ $a_version = explode( ' ', stristr( $resultant, 'opera mini' ) );
1299
+
1300
+ $this->set_version( $a_version[1] );
1301
+ }
1302
+
1303
+ $this->browser_name = $this->browser_opera_mini;
1304
+ $this->set_mobile( true );
1305
+
1306
+ return true;
1307
+ } elseif ( stripos( $this->agent, 'opera' ) !== false ) {
1308
+ $resultant = stristr( $this->agent, 'opera' );
1309
+
1310
+ if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
1311
+ $this->set_version( $matches[1] );
1312
+ } elseif ( preg_match( '/\//', $resultant ) ) {
1313
+ $a_result = explode( '/', str_replace( '(', ' ', $resultant ) );
1314
+ $a_version = explode( ' ', $a_result[1] );
1315
+
1316
+ $this->set_version( $a_version[0] );
1317
+ } else {
1318
+ $a_version = explode( ' ', stristr( $resultant, 'opera' ) );
1319
+
1320
+ $this->set_version( isset( $a_version[1] ) ? $a_version[1] : '' );
1321
+ }
1322
+
1323
+ $this->browser_name = $this->browser_opera;
1324
+
1325
+ return true;
1326
+ }
1327
+
1328
+ return false;
1329
+ }
1330
+
1331
+
1332
+ /**
1333
+ * Determine if the browser is Chrome or not
1334
+ *
1335
+ * @access public
1336
+ * @since 1.0.0
1337
+ * @return bool Whether or not the browser is Chrome
1338
+ */
1339
+ public function check_browser_chrome() {
1340
+ if ( stripos( $this->agent, 'Chrome' ) !== false ) {
1341
+ $a_result = explode( '/', stristr( $this->agent, 'Chrome' ) );
1342
+ $a_version = explode( ' ', $a_result[1] );
1343
+
1344
+ $this->set_version( $a_version[0] );
1345
+ $this->set_browser( $this->browser_chrome );
1346
+
1347
+ return true;
1348
+ }
1349
+
1350
+ return false;
1351
+ }
1352
+
1353
+
1354
+ /**
1355
+ * Determine if the browser is WebTv or not
1356
+ *
1357
+ * @access public
1358
+ * @since 1.0.0
1359
+ * @return bool Whether or not the browser is WebTv
1360
+ */
1361
+ public function check_browser_webtv() {
1362
+ if ( stripos( $this->agent, 'webtv' ) !== false ) {
1363
+ $a_result = explode( '/', stristr( $this->agent, 'webtv' ) );
1364
+ $a_version = explode( ' ', $a_result[1] );
1365
+
1366
+ $this->set_version( $a_version[0] );
1367
+ $this->set_browser( $this->browser_webtv );
1368
+
1369
+ return true;
1370
+ }
1371
+
1372
+ return false;
1373
+ }
1374
+
1375
+
1376
+ /**
1377
+ * Determine if the browser is NetPositive or not
1378
+ *
1379
+ * @access public
1380
+ * @since 1.0.0
1381
+ * @return bool Whether or not the browser is NetPositive
1382
+ */
1383
+ public function check_browser_netpositive() {
1384
+ if ( stripos( $this->agent, 'NetPositive' ) !== false ) {
1385
+ $a_result = explode( '/', stristr( $this->agent, 'NetPositive' ) );
1386
+ $a_version = explode( ' ', $a_result[1] );
1387
+
1388
+ $this->set_version( str_replace( array( '(', ')', ';' ), '', $a_version[0] ) );
1389
+ $this->set_browser( $this->browser_netpositive );
1390
+
1391
+ return true;
1392
+ }
1393
+
1394
+ return false;
1395
+ }
1396
+
1397
+
1398
+ /**
1399
+ * Determine if the browser is Galeon or not
1400
+ *
1401
+ * @access public
1402
+ * @since 1.0.0
1403
+ * @return bool Whether or not the browser is Galeon
1404
+ */
1405
+ public function check_browser_galeon() {
1406
+ if ( stripos( $this->agent, 'galeon' ) !== false ) {
1407
+ $a_result = explode( ' ', stristr( $this->agent, 'galeon' ) );
1408
+ $a_version = explode( '/', $a_result[0] );
1409
+
1410
+ $this->set_version( $a_version[1] );
1411
+ $this->set_browser( $this->browser_galeon );
1412
+
1413
+ return true;
1414
+ }
1415
+
1416
+ return false;
1417
+ }
1418
+
1419
+
1420
+ /**
1421
+ * Determine if the browser is Konqueror or not
1422
+ *
1423
+ * @access public
1424
+ * @since 1.0.0
1425
+ * @return bool Whether or not the browser is Konqueror
1426
+ */
1427
+ public function check_browser_konqueror() {
1428
+ if ( stripos( $this->agent, 'Konqueror' ) !== false ) {
1429
+ $a_result = explode( ' ', stristr( $this->agent, 'Konqueror' ) );
1430
+ $a_version = explode( '/', $a_result[0] );
1431
+
1432
+ $this->set_version( $a_version[1] );
1433
+ $this->set_browser( $this->browser_konqueror );
1434
+
1435
+ return true;
1436
+ }
1437
+
1438
+ return false;
1439
+ }
1440
+
1441
+
1442
+ /**
1443
+ * Determine if the browser is iCab or not
1444
+ *
1445
+ * @access public
1446
+ * @since 1.0.0
1447
+ * @return bool Whether or not the browser is iCab
1448
+ */
1449
+ public function check_browser_icab() {
1450
+ if ( stripos( $this->agent, 'icab' ) !== false ) {
1451
+ $a_version = explode( ' ', stristr( str_replace( '/', ' ', $this->agent ), 'icab' ) );
1452
+
1453
+ $this->set_version( $a_version[1] );
1454
+ $this->set_browser( $this->browser_icab );
1455
+
1456
+ return true;
1457
+ }
1458
+
1459
+ return false;
1460
+ }
1461
+
1462
+
1463
+ /**
1464
+ * Determine if the browser is OmniWeb or not
1465
+ *
1466
+ * @access public
1467
+ * @since 1.0.0
1468
+ * @return bool Whether or not the browser is OmniWeb
1469
+ */
1470
+ public function check_browser_omniweb() {
1471
+ if ( stripos( $this->agent, 'omniweb' ) !== false ) {
1472
+ $a_result = explode( '/', stristr( $this->agent, 'omniweb' ) );
1473
+ $a_version = explode( ' ', isset( $a_result[1] ) ? $a_result[1] : '' );
1474
+
1475
+ $this->set_version( $a_version[0] );
1476
+ $this->set_browser( $this->browser_omniweb );
1477
+
1478
+ return true;
1479
+ }
1480
+
1481
+ return false;
1482
+ }
1483
+
1484
+
1485
+ /**
1486
+ * Determine if the browser is Phoenix or not
1487
+ *
1488
+ * @access public
1489
+ * @since 1.0.0
1490
+ * @return bool Whether or not the browser is Phoenix
1491
+ */
1492
+ public function check_browser_phoenix() {
1493
+ if ( stripos( $this->agent, 'Phoenix' ) !== false ) {
1494
+ $a_version = explode( '/', stristr( $this->agent, 'Phoenix' ) );
1495
+
1496
+ $this->set_version( $a_version[1] );
1497
+ $this->set_browser( $this->browser_phoenix );
1498
+
1499
+ return true;
1500
+ }
1501
+
1502
+ return false;
1503
+ }
1504
+
1505
+
1506
+ /**
1507
+ * Determine if the browser is Firebird or not
1508
+ *
1509
+ * @access public
1510
+ * @since 1.0.0
1511
+ * @return bool Whether or not the browser is Firebird
1512
+ */
1513
+ public function check_browser_firebird() {
1514
+ if ( stripos( $this->agent, 'Firebird' ) !== false ) {
1515
+ $a_version = explode( '/', stristr( $this->agent, 'Firebird' ) );
1516
+
1517
+ $this->set_version( $a_version[1] );
1518
+ $this->set_browser( $this->browser_firebird );
1519
+
1520
+ return true;
1521
+ }
1522
+
1523
+ return false;
1524
+ }
1525
+
1526
+
1527
+ /**
1528
+ * Determine if the browser is Netscape Navigator 9+ or not
1529
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
1530
+ *
1531
+ * @access public
1532
+ * @since 1.0.0
1533
+ * @return bool Whether or not the browser is Netscape Navigator 9+
1534
+ */
1535
+ public function check_browser_netscape_navigator_9plus() {
1536
+ if ( stripos( $this->agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->agent, $matches ) ) {
1537
+ $this->set_version( $matches[1] );
1538
+ $this->set_browser( $this->browser_netscape_navigator );
1539
+
1540
+ return true;
1541
+ } elseif ( stripos( $this->agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->agent, $matches ) ) {
1542
+ $this->set_version( $matches[1] );
1543
+ $this->set_browser( $this->browser_netscape_navigator );
1544
+
1545
+ return true;
1546
+ }
1547
+
1548
+ return false;
1549
+ }
1550
+
1551
+
1552
+ /**
1553
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko)
1554
+ *
1555
+ * @access public
1556
+ * @since 1.0.0
1557
+ * @return bool Whether or not the browser is Shiretoko
1558
+ */
1559
+ public function check_browser_shiretoko() {
1560
+ if ( stripos( $this->agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->agent, $matches ) ) {
1561
+ $this->set_version( $matches[1] );
1562
+ $this->set_browser( $this->browser_shiretoko );
1563
+
1564
+ return true;
1565
+ }
1566
+
1567
+ return false;
1568
+ }
1569
+
1570
+
1571
+ /**
1572
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat)
1573
+ *
1574
+ * @access public
1575
+ * @since 1.0.0
1576
+ * @return bool Whether or not the browser is Ice Cat
1577
+ */
1578
+ public function check_browser_icecat() {
1579
+ if ( stripos( $this->agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->agent, $matches ) ) {
1580
+ $this->set_version( $matches[1] );
1581
+ $this->set_browser( $this->browser_icecat );
1582
+
1583
+ return true;
1584
+ }
1585
+
1586
+ return false;
1587
+ }
1588
+
1589
+
1590
+ /**
1591
+ * Determine if the browser is Nokia or not
1592
+ *
1593
+ * @access public
1594
+ * @since 1.0.0
1595
+ * @return bool Whether or not the browser is Nokia
1596
+ */
1597
+ public function check_browser_nokia() {
1598
+ if ( preg_match( '/Nokia([^\/]+)\/([^ SP]+)/i', $this->agent, $matches ) ) {
1599
+ $this->set_version( $matches[2] );
1600
+
1601
+ if ( stripos( $this->agent, 'Series60' ) !== false || strpos( $this->agent, 'S60' ) !== false ) {
1602
+ $this->set_browser( $this->browser_nokia_s60 );
1603
+ } else {
1604
+ $this->set_browser( $this->browser_nokia );
1605
+ }
1606
+
1607
+ $this->set_mobile( true );
1608
+
1609
+ return true;
1610
+ }
1611
+
1612
+ return false;
1613
+ }
1614
+
1615
+
1616
+ /**
1617
+ * Determine if the browser is Firefox or not
1618
+ *
1619
+ * @access public
1620
+ * @since 1.0.0
1621
+ * @return bool Whether or not the browser is Firefox
1622
+ */
1623
+ public function check_browser_firefox() {
1624
+ if ( stripos( $this->agent, 'safari' ) === false ) {
1625
+ if ( preg_match( '/Firefox[\/ \(]([^ ;\)]+)/i', $this->agent, $matches ) ) {
1626
+ $this->set_version( $matches[1] );
1627
+ $this->set_browser( $this->browser_firefox );
1628
+
1629
+ return true;
1630
+ } elseif ( preg_match( '/Firefox$/i', $this->agent, $matches ) ) {
1631
+ $this->set_version( '' );
1632
+ $this->set_browser( $this->browser_firefox );
1633
+
1634
+ return true;
1635
+ }
1636
+ }
1637
+
1638
+ return false;
1639
+ }
1640
+
1641
+
1642
+ /**
1643
+ * Determine if the browser is Firefox or not
1644
+ *
1645
+ * @access public
1646
+ * @since 1.0.0
1647
+ * @return bool Whether or not the browser is Firefox
1648
+ */
1649
+ public function check_browser_iceweasel() {
1650
+ if ( stripos( $this->agent, 'Iceweasel' ) !== false ) {
1651
+ $a_result = explode( '/', stristr( $this->agent, 'Iceweasel' ) );
1652
+ $a_version = explode( ' ', $a_result[1] );
1653
+
1654
+ $this->set_version( $a_version[0] );
1655
+ $this->set_browser( $this->browser_iceweasel );
1656
+
1657
+ return true;
1658
+ }
1659
+
1660
+ return false;
1661
+ }
1662
+
1663
+
1664
+ /**
1665
+ * Determine if the browser is Mozilla or not
1666
+ *
1667
+ * @access public
1668
+ * @since 1.0.0
1669
+ * @return bool Whether or not the browser is Mozilla
1670
+ */
1671
+ public function check_browser_mozilla() {
1672
+ if ( stripos( $this->agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->agent ) && stripos( $this->agent, 'netscape' ) === false ) {
1673
+ $a_version = explode( ' ', stristr( $this->agent, 'rv:' ) );
1674
+
1675
+ preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->agent, $a_version );
1676
+
1677
+ $this->set_version( str_replace( 'rv:', '', $a_version[0] ) );
1678
+ $this->set_browser( $this->browser_mozilla );
1679
+
1680
+ return true;
1681
+ } elseif ( stripos( $this->agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->agent ) && stripos( $this->agent, 'netscape' ) === false ) {
1682
+ $a_version = explode( '', stristr( $this->agent, 'rv:' ) );
1683
+
1684
+ $this->set_version( str_replace( 'rv:', '', $a_version[0] ) );
1685
+ $this->set_browser( $this->browser_mozilla );
1686
+
1687
+ return true;
1688
+ } elseif ( stripos( $this->agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->agent, $matches ) && stripos( $this->agent, 'netscape' ) === false ) {
1689
+ $this->set_version( $matches[1] );
1690
+ $this->set_browser( $this->browser_mozilla );
1691
+
1692
+ return true;
1693
+ }
1694
+
1695
+ return false;
1696
+ }
1697
+
1698
+
1699
+ /**
1700
+ * Determine if the browser is Lynx or not
1701
+ *
1702
+ * @access public
1703
+ * @since 1.0.0
1704
+ * @return bool Whether or not the browser is Lynx
1705
+ */
1706
+ public function check_browser_lynx() {
1707
+ if ( stripos( $this->agent, 'lynx' ) !== false ) {
1708
+ $a_result = explode( '/', stristr( $this->agent, 'Lynx' ) );
1709
+ $a_version = explode( ' ', ( isset( $a_result[1] ) ? $a_result[1] : '' ) );
1710
+
1711
+ $this->set_version( $a_version[0] );
1712
+ $this->set_browser( $this->browser_lynx );
1713
+
1714
+ return true;
1715
+ }
1716
+
1717
+ return false;
1718
+ }
1719
+
1720
+
1721
+ /**
1722
+ * Determine if the browser is Amaya or not
1723
+ *
1724
+ * @access public
1725
+ * @since 1.0.0
1726
+ * @return bool Whether or not the browser is Amaya
1727
+ */
1728
+ public function check_browser_amaya() {
1729
+ if ( stripos( $this->agent, 'amaya' ) !== false ) {
1730
+ $a_result = explode( '/', stristr( $this->agent, 'Amaya' ) );
1731
+ $a_version = explode( ' ', $a_result[1] );
1732
+
1733
+ $this->set_version( $a_version[0] );
1734
+ $this->set_browser( $this->browser_amaya );
1735
+
1736
+ return true;
1737
+ }
1738
+
1739
+ return false;
1740
+ }
1741
+
1742
+
1743
+ /**
1744
+ * Determine if the browser is Safari or not
1745
+ *
1746
+ * @access public
1747
+ * @since 1.0.0
1748
+ * @return bool Whether or not the browser is Safari
1749
+ */
1750
+ public function check_browser_safari() {
1751
+ if ( stripos( $this->agent, 'Safari' ) !== false && stripos( $this->agent, 'iPhone' ) === false && stripos( $this->agent, 'iPod' ) === false ) {
1752
+ $a_result = explode( '/', stristr( $this->agent, 'Version' ) );
1753
+
1754
+ if ( isset( $a_result[1] ) ) {
1755
+ $a_version = explode( ' ', $a_result[1] );
1756
+
1757
+ $this->set_version( $a_version[0] );
1758
+ } else {
1759
+ $this->set_version( $this->version_unknown );
1760
+ }
1761
+
1762
+ $this->set_browser( $this->browser_safari );
1763
+
1764
+ return true;
1765
+ }
1766
+
1767
+ return false;
1768
+ }
1769
+
1770
+
1771
+ /**
1772
+ * Determine if the browser is iPhone or not
1773
+ *
1774
+ * @access public
1775
+ * @since 1.0.0
1776
+ * @return bool Whether or not the browser is iPhone
1777
+ */
1778
+ public function check_browser_iphone() {
1779
+ if ( stripos( $this->agent, 'iPhone' ) !== false ) {
1780
+ $a_result = explode( '/', stristr( $this->agent, 'Version' ) );
1781
+
1782
+ if ( isset( $a_result[1] ) ) {
1783
+ $a_version = explode( ' ', $a_result[1] );
1784
+
1785
+ $this->set_version( $a_version[0] );
1786
+ } else {
1787
+ $this->set_version( $this->version_unknown );
1788
+ }
1789
+
1790
+ $this->set_mobile( true );
1791
+ $this->set_browser( $this->browser_iphone );
1792
+
1793
+ return true;
1794
+ }
1795
+
1796
+ return false;
1797
+ }
1798
+
1799
+
1800
+ /**
1801
+ * Determine if the browser is iPod or not
1802
+ *
1803
+ * @access public
1804
+ * @since 1.0.0
1805
+ * @return bool Whether or not the browser is iPod
1806
+ */
1807
+ public function check_browser_ipad() {
1808
+ if ( stripos( $this->agent, 'iPad' ) !== false ) {
1809
+ $a_result = explode( '/', stristr( $this->agent, 'Version' ) );
1810
+
1811
+ if ( isset( $a_result[1] ) ) {
1812
+ $a_version = explode( ' ', $a_result[1] );
1813
+
1814
+ $this->set_version( $a_version[0] );
1815
+ } else {
1816
+ $this->set_version( $this->version_unknown );
1817
+ }
1818
+
1819
+ $this->set_mobile( true );
1820
+ $this->set_browser( $this->browser_ipad );
1821
+
1822
+ return true;
1823
+ }
1824
+
1825
+ return false;
1826
+ }
1827
+
1828
+
1829
+ /**
1830
+ * Determine if the browser is iPod or not
1831
+ *
1832
+ * @access public
1833
+ * @since 1.0.0
1834
+ * @return bool Whether or not the browser is iPod
1835
+ */
1836
+ public function check_browser_ipod() {
1837
+ if ( stripos( $this->agent, 'iPod' ) !== false ) {
1838
+ $a_result = explode( '/', stristr( $this->agent, 'Version' ) );
1839
+
1840
+ if ( isset( $a_result[1] ) ) {
1841
+ $a_version = explode( ' ', $a_result[1] );
1842
+
1843
+ $this->set_version( $a_version[0] );
1844
+ } else {
1845
+ $this->set_version( $this->version_unknown );
1846
+ }
1847
+
1848
+ $this->set_mobile( true );
1849
+ $this->set_browser( $this->browser_ipod );
1850
+
1851
+ return true;
1852
+ }
1853
+
1854
+ return false;
1855
+ }
1856
+
1857
+
1858
+ /**
1859
+ * Determine if the browser is Android or not
1860
+ *
1861
+ * @access public
1862
+ * @since 1.0.0
1863
+ * @return bool Whether or not the browser is Android
1864
+ */
1865
+ public function check_browser_android() {
1866
+ if ( stripos( $this->agent, 'Android' ) !== false ) {
1867
+ $a_result = explode( ' ', stristr( $this->agent, 'Android' ) );
1868
+
1869
+ if ( isset( $a_result[1] ) ) {
1870
+ $a_version = explode( ' ', $a_result[1] );
1871
+
1872
+ $this->set_version( $a_version[0] );
1873
+ } else {
1874
+ $this->set_version( $this->version_unknown );
1875
+ }
1876
+
1877
+ $this->set_mobile( true );
1878
+ $this->set_browser( $this->browser_android );
1879
+
1880
+ return true;
1881
+ }
1882
+
1883
+ return false;
1884
+ }
1885
+
1886
+
1887
+ /**
1888
+ * Determine the user's platform
1889
+ *
1890
+ * @access public
1891
+ * @since 1.0.0
1892
+ * @return void
1893
+ */
1894
+ public function check_platform() {
1895
+ if ( stripos( $this->agent, 'windows' ) !== false ) {
1896
+ $this->platform = $this->platform_windows;
1897
+ } elseif ( stripos( $this->agent, 'iPad' ) !== false ) {
1898
+ $this->platform = $this->platform_ipad;
1899
+ } elseif ( stripos( $this->agent, 'iPod' ) !== false ) {
1900
+ $this->platform = $this->platform_ipod;
1901
+ } elseif ( stripos( $this->agent, 'iPhone' ) !== false ) {
1902
+ $this->platform = $this->platform_iphone;
1903
+ } elseif ( stripos( $this->agent, 'mac' ) !== false ) {
1904
+ $this->platform = $this->platform_apple;
1905
+ } elseif ( stripos( $this->agent, 'android' ) !== false ) {
1906
+ $this->platform = $this->platform_android;
1907
+ } elseif ( stripos( $this->agent, 'linux' ) !== false ) {
1908
+ $this->platform = $this->platform_linux;
1909
+ } elseif ( stripos( $this->agent, 'Nokia' ) !== false ) {
1910
+ $this->platform = $this->platform_nokia;
1911
+ } elseif ( stripos( $this->agent, 'BlackBerry' ) !== false ) {
1912
+ $this->platform = $this->platform_blackberry;
1913
+ } elseif ( stripos( $this->agent, 'FreeBSD' ) !== false ) {
1914
+ $this->platform = $this->platform_freebsd;
1915
+ } elseif ( stripos( $this->agent, 'OpenBSD' ) !== false ) {
1916
+ $this->platform = $this->platform_openbsd;
1917
+ } elseif ( stripos( $this->agent, 'NetBSD' ) !== false ) {
1918
+ $this->platform = $this->platform_netbsd;
1919
+ } elseif ( stripos( $this->agent, 'OpenSolaris' ) !== false ) {
1920
+ $this->platform = $this->platform_opensolaris;
1921
+ } elseif ( stripos( $this->agent, 'SunOS' ) !== false ) {
1922
+ $this->platform = $this->platform_sunos;
1923
+ } elseif ( stripos( $this->agent, 'OS\/2' ) !== false ) {
1924
+ $this->platform = $this->platform_os2;
1925
+ } elseif ( stripos( $this->agent, 'BeOS' ) !== false ) {
1926
+ $this->platform = $this->platform_beos;
1927
+ } elseif ( stripos( $this->agent, 'win' ) !== false ) {
1928
+ $this->platform = $this->platform_windows;
1929
+ }
1930
+ }
1931
+ }
includes/libraries/{s214-settings/source/modules/sysinfo/class.s214-sysinfo.php → simple-settings/modules/sysinfo/class-simple-settings-sysinfo.php} RENAMED
@@ -1,53 +1,63 @@
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 ) {
@@ -55,7 +65,7 @@ class S214_Sysinfo {
55
  $this->func = $_func;
56
  $this->version = $_version;
57
 
58
- // Run action and filter hooks
59
  $this->hooks();
60
  }
61
 
@@ -64,12 +74,12 @@ class S214_Sysinfo {
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
 
@@ -77,32 +87,32 @@ class S214_Sysinfo {
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";
@@ -110,127 +120,134 @@ class S214_Sysinfo {
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
  }
@@ -238,15 +255,15 @@ class S214_Sysinfo {
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";
@@ -256,17 +273,18 @@ class S214_Sysinfo {
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
 
@@ -277,8 +295,8 @@ class S214_Sysinfo {
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() {
@@ -287,7 +305,7 @@ class S214_Sysinfo {
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
 
@@ -296,16 +314,16 @@ class S214_Sysinfo {
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
 
@@ -317,14 +335,14 @@ class S214_Sysinfo {
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 ) ) );
@@ -334,7 +352,7 @@ class S214_Sysinfo {
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
 
@@ -352,12 +370,12 @@ class S214_Sysinfo {
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
 
@@ -369,10 +387,10 @@ class S214_Sysinfo {
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
  }
@@ -382,35 +400,35 @@ class S214_Sysinfo {
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;
@@ -421,20 +439,16 @@ class S214_Sysinfo {
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 );
1
  <?php
2
  /**
3
+ * System Info handler for Simple Settings
4
  *
5
+ * @package Widgit\SimpleSettings\Sysinfo
6
+ * @since 1.0.0
7
  */
8
 
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
 
14
 
15
  /**
16
+ * Simple Settings system info handler class
17
  *
18
+ * @since 1.0.0
19
  */
20
+ class Simple_Settings_Sysinfo {
21
 
22
 
23
  /**
24
+ * The plugin slug
25
+ *
26
+ * @access private
27
+ * @since 1.0.0
28
  * @var string $slug The plugin slug
 
29
  */
30
  private $slug;
31
 
32
 
33
  /**
34
+ * The plugin slug for names
35
+ *
36
+ * @access private
37
+ * @since 1.0.0
38
  * @var string $func The plugin slug for names
 
39
  */
40
  private $func;
41
 
42
 
43
  /**
44
+ * The library version
45
+ *
46
+ * @access private
47
+ * @since 1.0.0
48
  * @var string $ver The library version
 
49
  */
50
  private $version;
51
 
52
 
53
  /**
54
+ * Get things started
55
  *
56
  * @access public
57
+ * @since 1.0.0
58
+ * @param string $_slug The plugin slug.
59
+ * @param string $_func The plugin function.
60
+ * @param string $_version The plugin version.
61
  * @return void
62
  */
63
  public function __construct( $_slug, $_func, $_version ) {
65
  $this->func = $_func;
66
  $this->version = $_version;
67
 
68
+ // Run action and filter hooks.
69
  $this->hooks();
70
  }
71
 
74
  * Run action and filter hooks
75
  *
76
  * @access private
77
+ * @since 1.0.0
78
  * @return void
79
  */
80
  private function hooks() {
81
+ // Process sysinfo download.
82
+ add_action( $this->func . '_settings_download_system_info', array( $this, 'download_system_info' ) );
83
  }
84
 
85
 
87
  * Get system info
88
  *
89
  * @access public
90
+ * @since 1.0.0
91
  * @global object $wpdb The WordPress database object
92
  * @return string $return The system info to display
93
  */
94
  public function get_system_info() {
95
  global $wpdb;
96
 
97
+ if ( ! class_exists( 'Browser' ) ) {
98
+ require_once 'class-browser.php';
99
  }
100
 
101
  $browser = new Browser();
102
 
103
+ // Get theme info.
104
+ $theme_data = wp_get_theme();
105
+ $theme = $theme_data->Name . ' ' . $theme_data->Version; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
106
+ $parent_theme = $theme_data->Template; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
107
+ if ( ! empty( $parent_theme ) ) {
108
+ $parent_theme_data = wp_get_theme( $parent_theme );
109
+ $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
110
  }
111
 
112
+ // Try to identify the hosting provider.
113
  $host = $this->get_host();
114
 
115
+ $return = '### Begin System Info (Generated ' . gmdate( 'Y-m-d H:i:s' ) . ') ###' . "\n\n";
116
 
117
  // Start with the basics...
118
  $return .= '-- Site Info' . "\n\n";
120
  $return .= 'Home URL: ' . home_url() . "\n";
121
  $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
122
 
123
+ $return = apply_filters( $this->func . '_sysinfo_after_site_info', $return );
124
 
125
  // Can we determine the site's host?
126
+ if ( $host ) {
127
  $return .= "\n" . '-- Hosting Provider' . "\n\n";
128
  $return .= 'Host: ' . $host . "\n";
129
 
130
+ $return = apply_filters( $this->func . '_sysinfo_after_host_info', $return );
131
  }
132
 
133
+ // The local users' browser information, handled by the Browser class.
134
  $return .= "\n" . '-- User Browser' . "\n\n";
135
  $return .= $browser;
136
 
137
+ $return = apply_filters( $this->func . '_sysinfo_after_user_browser', $return );
138
+
139
+ $locale = get_locale();
140
 
141
+ // WordPress configuration.
142
  $return .= "\n" . '-- WordPress Configuration' . "\n\n";
143
  $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
144
+ $return .= 'Language: ' . ( ! empty( $locale ) ? $locale : 'en_US' ) . "\n";
145
  $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
146
  $return .= 'Active Theme: ' . $theme . "\n";
147
+ if ( $parent_theme !== $theme ) {
148
+ $return .= 'Parent Theme: ' . $parent_theme . "\n";
149
+ }
150
  $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
151
 
152
+ // Only show page specs if front page is set to 'page'.
153
+ if ( get_option( 'show_on_front' ) === 'page' ) {
154
  $front_page_id = get_option( 'page_on_front' );
155
  $blog_page_id = get_option( 'page_for_posts' );
156
 
157
+ $return .= 'Page On Front: ' . ( 0 !== $front_page_id ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
158
+ $return .= 'Page For Posts: ' . ( 0 !== $blog_page_id ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
159
  }
160
 
161
+ $return .= 'ABSPATH: ' . ABSPATH . "\n";
162
+
163
+ // Make sure wp_remote_post() is working.
164
  $request['cmd'] = '_notify-validate';
165
 
166
  $params = array(
167
  'sslverify' => false,
168
+ 'timeout' => 3,
169
+ 'user-agent' => 'Simple-Settings/' . $this->version,
170
+ 'body' => $request,
171
  );
172
 
173
  $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
174
 
175
+ if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
176
+ $WP_REMOTE_POST = 'wp_remote_post() works'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
177
  } else {
178
+ $WP_REMOTE_POST = 'wp_remote_post() does not work'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
179
  }
180
 
181
+ $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
182
+ $return .= 'Table Prefix: Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
183
  $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
184
  $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
185
+ $return .= 'Registered Post Statuses: ' . implode( ', ', get_post_statuses() ) . "\n";
186
 
187
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_config', $return );
188
 
189
+ // Get plugins that have an update.
190
  $updates = get_plugin_updates();
191
 
192
+ // Must-use plugins.
193
  // NOTE: MU plugins can't show updates!
194
+ $mu_plugins = get_mu_plugins();
195
+ if ( count( $mu_plugins ) > 0 ) {
196
  $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
197
 
198
+ foreach ( $mu_plugins as $plugin => $plugin_data ) {
199
  $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
200
  }
201
 
202
  $return = apply_filters( $this->func . '_sysinfo_after_wordpress_mu_plugins', $return );
203
  }
204
 
205
+ // WordPress active plugins.
206
  $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
207
 
208
+ $plugins = get_plugins();
209
  $active_plugins = get_option( 'active_plugins', array() );
210
 
211
+ foreach ( $plugins as $plugin_path => $plugin ) {
212
+ if ( ! in_array( $plugin_path, $active_plugins, true ) ) {
213
  continue;
214
  }
215
 
216
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
217
  $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
218
  }
219
 
220
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins', $return );
221
 
222
+ // WordPress inactive plugins.
223
  $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
224
 
225
+ foreach ( $plugins as $plugin_path => $plugin ) {
226
+ if ( in_array( $plugin_path, $active_plugins, true ) ) {
227
  continue;
228
  }
229
 
230
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
231
  $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
232
  }
233
 
234
  $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins_inactive', $return );
235
 
236
+ if ( is_multisite() ) {
237
+ // WordPress Multisite active plugins.
238
  $return .= "\n" . '-- Network Active Plugins' . "\n\n";
239
 
240
+ $plugins = wp_get_active_network_plugins();
241
  $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
242
 
243
+ foreach ( $plugins as $plugin_path ) {
244
  $plugin_base = plugin_basename( $plugin_path );
245
 
246
+ if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
247
  continue;
248
  }
249
 
250
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
251
  $plugin = get_plugin_data( $plugin_path );
252
  $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
253
  }
255
  $return = apply_filters( $this->func . '_sysinfo_after_wordpress_ms_plugins', $return );
256
  }
257
 
258
+ // Server configuration (really just versioning).
259
  $return .= "\n" . '-- Webserver Configuration' . "\n\n";
260
  $return .= 'PHP Version: ' . PHP_VERSION . "\n";
261
  $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
262
+ $return .= 'Webserver Info: ' . ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ) . "\n";
263
 
264
+ $return = apply_filters( $this->func . '_sysinfo_after_webserver_config', $return );
265
 
266
+ // PHP configs... now we're getting to the important stuff.
267
  $return .= "\n" . '-- PHP Configuration' . "\n\n";
268
  $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
269
  $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
273
  $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
274
  $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
275
  $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
276
+ $return .= 'PHP Arg Separator: ' . ini_get( 'arg_separator.output' ) . "\n";
277
 
278
+ $return = apply_filters( $this->func . '_sysinfo_after_php_config', $return );
279
 
280
+ // PHP extensions and such.
281
  $return .= "\n" . '-- PHP Extensions' . "\n\n";
282
  $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
283
  $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
284
  $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
285
  $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
286
 
287
+ $return = apply_filters( $this->func . '_sysinfo_after_php_ext', $return );
288
 
289
  $return .= "\n" . '### End System Info ###';
290
 
295
  /**
296
  * Generates a System Info download file
297
  *
298
+ * @access public
299
+ * @since 1.0.0
300
  * @return void
301
  */
302
  public function download_system_info() {
305
  header( 'Content-Type: text/plain' );
306
  header( 'Content-Disposition: attachment; filename="' . $this->slug . '-system-info.txt"' );
307
 
308
+ echo esc_attr( wp_strip_all_tags( $this->get_system_info() ) );
309
  die();
310
  }
311
 
314
  * Get AJAX URL
315
  *
316
  * @access public
317
+ * @since 1.0.0
318
  * @return string URL to the AJAX file to call during AJAX requests.
319
  */
320
+ public function get_ajax_url() {
321
  $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
322
 
323
  $current_url = $this->get_current_page_url();
324
  $ajax_url = admin_url( 'admin-ajax.php', $scheme );
325
 
326
+ if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
327
  $ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
328
  }
329
 
335
  * Get the current page URL
336
  *
337
  * @access public
338
+ * @since 1.0.0
339
+ * @param bool $nocache If we should bust cache on the returned URL.
340
  * @return string $page_url Current page URL
341
  */
342
+ public function get_current_page_url( $nocache = false ) {
343
  global $wp;
344
 
345
+ if ( get_option( 'permalink_structure' ) ) {
346
  $base = trailingslashit( home_url( $wp->request ) );
347
  } else {
348
  $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
352
  $scheme = is_ssl() ? 'https' : 'http';
353
  $uri = set_url_scheme( $base, $scheme );
354
 
355
+ if ( is_front_page() ) {
356
  $uri = home_url( '/' );
357
  }
358
 
370
  * Adds the 'nocache' parameter to the provided URL
371
  *
372
  * @access public
373
+ * @since 1.0.0
374
+ * @param string $url The URL being requested.
375
  * @return string The URL with cache busting added or not
376
  */
377
+ public function add_cache_busting( $url = '' ) {
378
+ if ( $this->is_caching_plugin_active() ) {
379
  $url = add_query_arg( 'nocache', 'true', $url );
380
  }
381
 
387
  * Checks if a caching plugin is active
388
  *
389
  * @access public
390
+ * @since 1.0.0
391
  * @return bool $caching True if caching plugin is enabled, false otherwise
392
  */
393
+ public function is_caching_plugin_active() {
394
  $caching = ( function_exists( 'wpsupercache_site_admin' ) || defined( 'W3TC' ) || function_exists( 'rocket_init' ) );
395
  return apply_filters( $this->func . '_is_caching_plugin_active', $caching );
396
  }
400
  * Get user host
401
  *
402
  * @access public
403
+ * @since 1.0.0
404
  * @return mixed string $host if detected, fallback data otherwise
405
  */
406
+ public function get_host() {
407
+ if ( defined( 'WPE_APIKEY' ) ) {
408
  $host = 'WP Engine';
409
+ } elseif ( defined( 'PAGELYBIN' ) ) {
410
  $host = 'Pagely';
411
+ } elseif ( DB_HOST === 'localhost:/tmp/mysql5.sock' ) {
412
  $host = 'ICDSoft';
413
+ } elseif ( DB_HOST === 'mysqlv5' ) {
414
  $host = 'NetworkSolutions';
415
+ } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
416
  $host = 'iPage';
417
+ } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
418
  $host = 'IPower';
419
+ } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
420
  $host = 'MediaTemple Grid';
421
+ } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
422
  $host = 'pair Networks';
423
+ } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
424
  $host = 'Rackspace Cloud';
425
+ } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
426
  $host = 'SysFix.eu Power Hosting';
427
+ } elseif ( isset( $_SERVER['SERVER_NAME'] ) ? strpos( sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ), 'Flywheel' ) !== false : '' ) {
428
  $host = 'Flywheel';
429
  } else {
430
+ // Adding a general fallback for data gathering.
431
+ $host = 'DBH: ' . DB_HOST . ', SRV: ' . ( isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ) : '' );
432
  }
433
 
434
  return $host;
439
  * Get user IP
440
  *
441
  * @access public
442
+ * @since 1.0.0
443
  * @return string $ip User's IP address
444
  */
445
+ public function get_ip() {
446
+ $ip = '127.0.0.1';
447
+ $http_client_ip = ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ) : false );
448
+
449
+ if ( $http_client_ip ) {
450
+ // Check if IP is from share internet.
451
+ $ip = $http_client_ip;
 
 
 
 
452
  }
453
 
454
  return apply_filters( $this->func . '_get_ip', $ip );
includes/libraries/simple-settings/package.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "simple-settings",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "devDependencies": {
6
+ "grunt": "^1.0.4",
7
+ "grunt-contrib-clean": "^1.1.0",
8
+ "grunt-contrib-compress": "^1.5.0",
9
+ "grunt-contrib-copy": "^1.0.0",
10
+ "grunt-contrib-cssmin": "^2.2.1",
11
+ "grunt-contrib-uglify": "^3.3.0",
12
+ "load-grunt-tasks": "^3.5.2"
13
+ },
14
+ "dependencies": {
15
+ "grunt-cli": "^1.3.2",
16
+ "npm": "^6.9.0"
17
+ }
18
+ }
includes/{functions.php → misc-functions.php} RENAMED
@@ -1,157 +1,156 @@
1
- <?php
2
- /**
3
- * Helper functions
4
- *
5
- * @package Username_Changer\Functions
6
- * @since 2.1.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- /**
17
- * Get an array of user roles
18
- *
19
- * @since 3.0.0
20
- * @return array $roles The available user roles
21
- */
22
- function username_changer_get_user_roles() {
23
- global $wp_roles;
24
-
25
- $roles = $wp_roles->get_names();
26
-
27
- // Administrator can always edit
28
- unset( $roles['administrator'] );
29
-
30
- return apply_filters( 'username_changer_user_roles', $roles );
31
- }
32
-
33
-
34
- /**
35
- * Check if a user can change a given username
36
- *
37
- * @since 3.0.0
38
- * @return bool $allowed Whether or not this user can change their username
39
- */
40
- function username_changer_can_change_own_username() {
41
- $allowed = false;
42
-
43
- if ( is_user_logged_in() ) {
44
- $allowed_roles = username_changer()->settings->get_option( 'allowed_roles', array() );
45
- $user_data = wp_get_current_user();
46
- $user_roles = $user_data->roles;
47
-
48
- if ( in_array( 'administrator', $user_roles ) ) {
49
- $allowed = true;
50
- } elseif ( is_array( $user_roles ) ) {
51
- foreach ( $user_roles as $user_role => $role_name ) {
52
- if ( in_array( $user_role, $allowed_roles ) ) {
53
- $allowed = true;
54
- }
55
- }
56
- }
57
- }
58
-
59
- return apply_filters( 'username_changer_can_change_own_username', $allowed );
60
- }
61
-
62
-
63
- /**
64
- * Process a username change
65
- *
66
- * @since 3.0.0
67
- * @param string $old_username The old (current) username
68
- * @param string $new_username The new username
69
- * @return bool $return Whether or not we completed successfully
70
- */
71
- function username_changer_process( $old_username, $new_username ) {
72
- global $wpdb;
73
-
74
- $return = false;
75
-
76
- // One last sanity check to ensure the user exists
77
- $user_id = username_exists( $old_username );
78
- if ( $user_id ) {
79
- // Update username!
80
- $q = $wpdb->prepare( "UPDATE $wpdb->users SET user_login = %s WHERE user_login = %s", $new_username, $old_username );
81
-
82
- if ( false !== $wpdb->query( $q ) ) {
83
- // Update user_nicename
84
- $qnn = $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %s WHERE user_login = %s AND user_nicename = %s", $new_username, $new_username, $old_username );
85
- $wpdb->query( $qnn );
86
-
87
- // Update display_name
88
- $qdn = $wpdb->prepare( "UPDATE $wpdb->users SET display_name = %s WHERE user_login = %s AND display_name = %s", $new_username, $new_username, $old_username );
89
- $wpdb->query( $qdn );
90
-
91
- // Update nickname
92
- $nickname = get_user_meta( $user_id, 'nickname', true );
93
- if ( $nickname == $old_username ) {
94
- update_user_meta( $user_id, 'nickname', $new_username );
95
- }
96
-
97
- // If the user is a Super Admin, update their permissions
98
- if ( is_multisite() && is_super_admin( $user_id ) ) {
99
- grant_super_admin( $user_id );
100
- }
101
-
102
- // Reassign Coauthor Attribution
103
- if ( username_changer_plugin_installed( 'co-authors-plus/co-authors-plus.php' ) ) {
104
- global $coauthors_plus;
105
-
106
- $coauthor_posts = get_posts(
107
- array(
108
- 'post_type' => get_post_types(),
109
- 'posts_per_page' => -1,
110
- 'tax_query' => array(
111
- array(
112
- 'taxonomy' => $coauthors_plus->coauthor_taxonomy,
113
- 'field' => 'name',
114
- 'terms' => $old_username
115
- )
116
- )
117
- )
118
- );
119
-
120
- $current_term = get_term_by( 'name', $old_username, $coauthors_plus->coauthor_taxonomy );
121
- wp_delete_term( $current_term->term_id, $coauthors_plus->coauthor_taxonomy );
122
-
123
- if ( ! empty( $coauthor_posts ) ) {
124
- foreach ( $coauthor_posts as $coauthor_post ) {
125
- $coauthors_plus->add_coauthors( $coauthor_post->ID, array( $new_username ), true );
126
- }
127
- }
128
- }
129
-
130
- $return = true;
131
- }
132
-
133
- return $return;
134
- }
135
- }
136
-
137
-
138
- /**
139
- * Check if a plugin is installed
140
- *
141
- * @since 1.0.0
142
- * @param string $plugin The path to the plugin to check
143
- * @return boolean true if installed and active, false otherwise
144
- */
145
- function username_changer_plugin_installed( $plugin = false ){
146
- $ret = false;
147
-
148
- if ( $plugin ) {
149
- $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
150
-
151
- if ( in_array( $plugin, $active_plugins ) ) {
152
- $ret = true;
153
- }
154
- }
155
-
156
- return $ret;
157
- }
1
+ <?php
2
+ /**
3
+ * Helper functions
4
+ *
5
+ * @package UsernameChanger\Functions
6
+ * @since 2.1.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Get an array of user roles
17
+ *
18
+ * @since 3.0.0
19
+ * @return array $roles The available user roles
20
+ */
21
+ function username_changer_get_user_roles() {
22
+ global $wp_roles;
23
+
24
+ $roles = $wp_roles->get_names();
25
+
26
+ // Administrator can always edit.
27
+ unset( $roles['administrator'] );
28
+
29
+ return apply_filters( 'username_changer_user_roles', $roles );
30
+ }
31
+
32
+
33
+ /**
34
+ * Check if a user can change a given username
35
+ *
36
+ * @since 3.0.0
37
+ * @return bool $allowed Whether or not this user can change their username
38
+ */
39
+ function username_changer_can_change_own_username() {
40
+ $allowed = false;
41
+
42
+ if ( is_user_logged_in() ) {
43
+ $allowed_roles = username_changer()->settings->get_option( 'allowed_roles', array() );
44
+ $user_data = wp_get_current_user();
45
+ $user_roles = $user_data->roles;
46
+
47
+ if ( in_array( 'administrator', $user_roles, true ) ) {
48
+ $allowed = true;
49
+ } elseif ( is_array( $user_roles ) ) {
50
+ foreach ( $user_roles as $user_role => $role_name ) {
51
+ if ( in_array( $user_role, $allowed_roles, true ) ) {
52
+ $allowed = true;
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ return apply_filters( 'username_changer_can_change_own_username', $allowed );
59
+ }
60
+
61
+
62
+ /**
63
+ * Process a username change
64
+ *
65
+ * @since 3.0.0
66
+ * @param string $old_username The old (current) username.
67
+ * @param string $new_username The new username.
68
+ * @return bool $return Whether or not we completed successfully
69
+ */
70
+ function username_changer_process( $old_username, $new_username ) {
71
+ global $wpdb;
72
+
73
+ $return = false;
74
+
75
+ // One last sanity check to ensure the user exists.
76
+ $user_id = username_exists( $old_username );
77
+ if ( $user_id ) {
78
+ // Update username!
79
+ $q = $wpdb->prepare( "UPDATE $wpdb->users SET user_login = %s WHERE user_login = %s", $new_username, $old_username ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables
80
+
81
+ if ( false !== $wpdb->query( $q ) ) { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery
82
+ // Update user_nicename.
83
+ $qnn = $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %s WHERE user_login = %s AND user_nicename = %s", $new_username, $new_username, $old_username ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables
84
+ $wpdb->query( $qnn ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery
85
+
86
+ // Update display_name.
87
+ $qdn = $wpdb->prepare( "UPDATE $wpdb->users SET display_name = %s WHERE user_login = %s AND display_name = %s", $new_username, $new_username, $old_username ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables
88
+ $wpdb->query( $qdn ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery
89
+
90
+ // Update nickname.
91
+ $nickname = get_user_meta( $user_id, 'nickname', true );
92
+ if ( $nickname === $old_username ) {
93
+ update_user_meta( $user_id, 'nickname', $new_username );
94
+ }
95
+
96
+ // If the user is a Super Admin, update their permissions.
97
+ if ( is_multisite() && is_super_admin( $user_id ) ) {
98
+ grant_super_admin( $user_id );
99
+ }
100
+
101
+ // Reassign Coauthor Attribution.
102
+ if ( username_changer_plugin_installed( 'co-authors-plus/co-authors-plus.php' ) ) {
103
+ global $coauthors_plus;
104
+
105
+ $coauthor_posts = get_posts(
106
+ array(
107
+ 'post_type' => get_post_types(),
108
+ 'posts_per_page' => -1,
109
+ 'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery
110
+ array(
111
+ 'taxonomy' => $coauthors_plus->coauthor_taxonomy,
112
+ 'field' => 'name',
113
+ 'terms' => $old_username,
114
+ ),
115
+ ),
116
+ )
117
+ );
118
+
119
+ $current_term = get_term_by( 'name', $old_username, $coauthors_plus->coauthor_taxonomy );
120
+ wp_delete_term( $current_term->term_id, $coauthors_plus->coauthor_taxonomy );
121
+
122
+ if ( ! empty( $coauthor_posts ) ) {
123
+ foreach ( $coauthor_posts as $coauthor_post ) {
124
+ $coauthors_plus->add_coauthors( $coauthor_post->ID, array( $new_username ), true );
125
+ }
126
+ }
127
+ }
128
+
129
+ $return = true;
130
+ }
131
+
132
+ return $return;
133
+ }
134
+ }
135
+
136
+
137
+ /**
138
+ * Check if a plugin is installed
139
+ *
140
+ * @since 1.0.0
141
+ * @param string $plugin The path to the plugin to check.
142
+ * @return boolean true if installed and active, false otherwise
143
+ */
144
+ function username_changer_plugin_installed( $plugin = false ) {
145
+ $ret = false;
146
+
147
+ if ( $plugin ) {
148
+ $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
149
+
150
+ if ( in_array( $plugin, $active_plugins, true ) ) {
151
+ $ret = true;
152
+ }
153
+ }
154
+
155
+ return $ret;
156
+ }
 
includes/scripts.php CHANGED
@@ -1,44 +1,52 @@
1
- <?php
2
- /**
3
- * Scripts
4
- *
5
- * @package UsernameChanger\Scripts
6
- * @since 3.0.0
7
- */
8
-
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- }
14
-
15
-
16
- /**
17
- * Load admin scripts
18
- *
19
- * @since 1.0.0
20
- * @return void
21
- */
22
- function username_changer_admin_scripts() {
23
- // Use minified libraries if SCRIPT_DEBUG is turned off
24
- $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
25
-
26
- $minimum_length = username_changer()->settings->get_option( 'minimum_length', 3 );
27
- $screen = get_current_screen();
28
-
29
- wp_enqueue_style( 'username-changer', USERNAME_CHANGER_URL . 'assets/css/admin.css', array(), USERNAME_CHANGER_VER );
30
- wp_enqueue_script( 'username-changer', USERNAME_CHANGER_URL . 'assets/js/admin.js', array( 'jquery' ), USERNAME_CHANGER_VER );
31
- wp_localize_script( 'username-changer', 'username_changer_vars', array(
32
- 'nonce' => wp_create_nonce( 'change_username' ),
33
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
34
- 'change_button_label' => username_changer()->settings->get_option( 'change_button_label', __( 'Change Username', 'username-changer' ) ),
35
- 'save_button_label' => username_changer()->settings->get_option( 'save_button_label', __( 'Save Username', 'username-changer' ) ),
36
- 'cancel_button_label' => username_changer()->settings->get_option( 'cancel_button_label', __( 'Cancel', 'username-changer' ) ),
37
- 'please_wait_message' => username_changer()->settings->get_option( 'please_wait_message', __( 'Please wait...', 'username-changer' ) ),
38
- 'error_short_username' => username_changer_do_tags( username_changer()->settings->get_option( 'error_short_username', __( 'Username is too short, the minimum length is {minlength} characters.', 'username-changer' ) ) ),
39
- 'current_screen' => $screen->id,
40
- 'can_change_username' => username_changer_can_change_own_username(),
41
- 'minimum_length' => $minimum_length
42
- ) );
43
- }
44
- add_action( 'admin_enqueue_scripts', 'username_changer_admin_scripts' );
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Scripts
4
+ *
5
+ * @package UsernameChanger\Scripts
6
+ * @since 3.0.0
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Load admin scripts
17
+ *
18
+ * @since 1.0.0
19
+ * @return void
20
+ */
21
+ function username_changer_admin_scripts() {
22
+ $js_dir = USERNAME_CHANGER_URL . 'assets/js/';
23
+ $css_dir = USERNAME_CHANGER_URL . 'assets/css/';
24
+
25
+ // Use minified libraries if SCRIPT_DEBUG is turned off.
26
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
27
+
28
+ $minimum_length = username_changer()->settings->get_option( 'minimum_length', 3 );
29
+ $screen = get_current_screen();
30
+
31
+ wp_enqueue_script( 'username-changer', $js_dir . 'admin.js', array( 'jquery' ), USERNAME_CHANGER_VER );
32
+ wp_localize_script(
33
+ 'username-changer',
34
+ 'username_changer_vars',
35
+ array(
36
+ 'nonce' => wp_create_nonce( 'change_username' ),
37
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
38
+ 'change_button_label' => username_changer()->settings->get_option( 'change_button_label', __( 'Change Username', 'username-changer' ) ),
39
+ 'save_button_label' => username_changer()->settings->get_option( 'save_button_label', __( 'Save Username', 'username-changer' ) ),
40
+ 'cancel_button_label' => username_changer()->settings->get_option( 'cancel_button_label', __( 'Cancel', 'username-changer' ) ),
41
+ 'please_wait_message' => username_changer()->settings->get_option( 'please_wait_message', __( 'Please wait...', 'username-changer' ) ),
42
+ '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' ) ) ),
43
+ 'current_screen' => $screen->id,
44
+ 'can_change_username' => username_changer_can_change_own_username(),
45
+ 'minimum_length' => $minimum_length,
46
+ )
47
+ );
48
+
49
+ wp_register_style( 'username-changer', $css_dir . 'admin.css', array(), USERNAME_CHANGER_VER );
50
+ wp_enqueue_style( 'username-changer' );
51
+ }
52
+ add_action( 'admin_enqueue_scripts', 'username_changer_admin_scripts', 100 );
languages/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ # Username Changer
2
+
3
+ This folder contains translation files for Username Changer.
4
+
5
+ Do not store custom translations in this folder, they will be deleted on updates.
6
+ Store custom translations in `wp-content/languages/username-changer`.
languages/username-changer.pot ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2020 Widgit Team
2
+ # This file is distributed under the same license as the Username Changer package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Username Changer 3.2.0\n"
6
+ "Report-Msgid-Bugs-To: https://gitlab.com/evertiro/Username-Changer/issues\n"
7
+ "POT-Creation-Date: 2020-02-07 08:34:31+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: Evertiro (https://evertiro.com/)\n"
13
+ "Language-Team: Evertiro <dgriffiths@evertiro.com>\n"
14
+ "Language: en_US\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-Country: United States\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: "
19
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
20
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
21
+ "X-Poedit-Basepath: ../\n"
22
+ "X-Poedit-SearchPath-0: .\n"
23
+ "X-Poedit-Bookmarks: \n"
24
+ "X-Textdomain-Support: yes\n"
25
+ "X-Generator: grunt-wp-i18n 1.0.3\n"
26
+
27
+ #: class-username-changer.php:96 class-username-changer.php:108
28
+ msgid "Cheatin&#8217; huh?"
29
+ msgstr ""
30
+
31
+ #: includes/admin/actions.php:32
32
+ msgid "Invalid request."
33
+ msgstr ""
34
+
35
+ #: includes/admin/actions.php:46
36
+ #: includes/admin/settings/register-settings.php:235
37
+ msgid "You do not have the correct permissions to change this username."
38
+ msgstr ""
39
+
40
+ #: includes/admin/actions.php:53
41
+ msgid ""
42
+ "The username {new_username} contains invalid characters. Please enter a "
43
+ "valid username."
44
+ msgstr ""
45
+
46
+ #: includes/admin/actions.php:60
47
+ msgid "Sorry, that username is not allowed."
48
+ msgstr ""
49
+
50
+ #: includes/admin/actions.php:66
51
+ #: includes/admin/settings/register-settings.php:244
52
+ msgid "The username {new_username} is already in use. Please try again."
53
+ msgstr ""
54
+
55
+ #: includes/admin/actions.php:80 includes/admin/actions.php:85
56
+ #: includes/admin/settings/register-settings.php:214
57
+ msgid "Username successfully changed to {new_username}."
58
+ msgstr ""
59
+
60
+ #: includes/admin/actions.php:82
61
+ #: includes/admin/settings/register-settings.php:221
62
+ msgid "Click here to log back in."
63
+ msgstr ""
64
+
65
+ #: includes/admin/actions.php:91
66
+ #: includes/admin/settings/register-settings.php:152
67
+ msgid "Username change notification - {sitename}"
68
+ msgstr ""
69
+
70
+ #: includes/admin/actions.php:92
71
+ #: includes/admin/settings/register-settings.php:159
72
+ msgid ""
73
+ "Howdy! We're just writing to let you know that your username for {siteurl} "
74
+ "has been changed to {new_username}."
75
+ msgstr ""
76
+
77
+ #: includes/admin/actions.php:92
78
+ #: includes/admin/settings/register-settings.php:159
79
+ msgid "Login now at {loginurl}"
80
+ msgstr ""
81
+
82
+ #: includes/admin/actions.php:107
83
+ msgid "An unknown error occurred."
84
+ msgstr ""
85
+
86
+ #: includes/admin/settings/register-settings.php:24
87
+ msgid "Username Changer Settings"
88
+ msgstr ""
89
+
90
+ #: includes/admin/settings/register-settings.php:40
91
+ msgid "Settings"
92
+ msgstr ""
93
+
94
+ #: includes/admin/settings/register-settings.php:41
95
+ msgid "Support"
96
+ msgstr ""
97
+
98
+ #: includes/admin/settings/register-settings.php:60
99
+ #: includes/admin/settings/register-settings.php:102
100
+ msgid "General Settings"
101
+ msgstr ""
102
+
103
+ #: includes/admin/settings/register-settings.php:61
104
+ msgid "String Settings"
105
+ msgstr ""
106
+
107
+ #: includes/admin/settings/register-settings.php:108
108
+ #: includes/admin/settings/register-settings.php:112
109
+ msgid "Allowed Roles"
110
+ msgstr ""
111
+
112
+ #: includes/admin/settings/register-settings.php:109
113
+ msgid "Select the user roles which are permitted to change their own username."
114
+ msgstr ""
115
+
116
+ #: includes/admin/settings/register-settings.php:113
117
+ msgid ""
118
+ "Administrators can always change usernames, and are the only role capable "
119
+ "of changing other users username."
120
+ msgstr ""
121
+
122
+ #: includes/admin/settings/register-settings.php:117
123
+ #: includes/admin/settings/register-settings.php:124
124
+ msgid "Minimum Length"
125
+ msgstr ""
126
+
127
+ #: includes/admin/settings/register-settings.php:118
128
+ msgid "Specify the minimum allowed username length."
129
+ msgstr ""
130
+
131
+ #: includes/admin/settings/register-settings.php:125
132
+ msgid "The minimum allowed length for usernames is {minlength} characters."
133
+ msgstr ""
134
+
135
+ #: includes/admin/settings/register-settings.php:129
136
+ msgid "Email Settings"
137
+ msgstr ""
138
+
139
+ #: includes/admin/settings/register-settings.php:135
140
+ #: includes/admin/settings/register-settings.php:138
141
+ msgid "Enable Email Notifications"
142
+ msgstr ""
143
+
144
+ #: includes/admin/settings/register-settings.php:136
145
+ msgid "Enable to send notification emails when usernames are changed."
146
+ msgstr ""
147
+
148
+ #: includes/admin/settings/register-settings.php:139
149
+ msgid "Notifications are not sent when a user changes their own username."
150
+ msgstr ""
151
+
152
+ #: includes/admin/settings/register-settings.php:149
153
+ msgid "Email Subject"
154
+ msgstr ""
155
+
156
+ #: includes/admin/settings/register-settings.php:150
157
+ msgid "Specify the subject for username change notifications."
158
+ msgstr ""
159
+
160
+ #: includes/admin/settings/register-settings.php:156
161
+ msgid "Email Message"
162
+ msgstr ""
163
+
164
+ #: includes/admin/settings/register-settings.php:157
165
+ msgid "Specify the message to send for username change notifications."
166
+ msgstr ""
167
+
168
+ #: includes/admin/settings/register-settings.php:165
169
+ msgid "Button Labels"
170
+ msgstr ""
171
+
172
+ #: includes/admin/settings/register-settings.php:171
173
+ msgid "Change Button Label"
174
+ msgstr ""
175
+
176
+ #: includes/admin/settings/register-settings.php:172
177
+ msgid "Customize the text for the 'change username' button."
178
+ msgstr ""
179
+
180
+ #: includes/admin/settings/register-settings.php:174 includes/scripts.php:38
181
+ msgid "Change Username"
182
+ msgstr ""
183
+
184
+ #: includes/admin/settings/register-settings.php:178
185
+ msgid "Save Button Label"
186
+ msgstr ""
187
+
188
+ #: includes/admin/settings/register-settings.php:179
189
+ msgid "Customize the text for the save button."
190
+ msgstr ""
191
+
192
+ #: includes/admin/settings/register-settings.php:181 includes/scripts.php:39
193
+ msgid "Save Username"
194
+ msgstr ""
195
+
196
+ #: includes/admin/settings/register-settings.php:185
197
+ msgid "Cancel Button Label"
198
+ msgstr ""
199
+
200
+ #: includes/admin/settings/register-settings.php:186
201
+ msgid "Customize the text for the cancel button."
202
+ msgstr ""
203
+
204
+ #: includes/admin/settings/register-settings.php:188 includes/scripts.php:40
205
+ msgid "Cancel"
206
+ msgstr ""
207
+
208
+ #: includes/admin/settings/register-settings.php:192
209
+ msgid "Messages"
210
+ msgstr ""
211
+
212
+ #: includes/admin/settings/register-settings.php:204
213
+ msgid "Please Wait Message"
214
+ msgstr ""
215
+
216
+ #: includes/admin/settings/register-settings.php:205
217
+ msgid "Customize the text displayed while usernames are being checked."
218
+ msgstr ""
219
+
220
+ #: includes/admin/settings/register-settings.php:207 includes/scripts.php:41
221
+ msgid "Please wait..."
222
+ msgstr ""
223
+
224
+ #: includes/admin/settings/register-settings.php:211
225
+ msgid "Username Changed Message"
226
+ msgstr ""
227
+
228
+ #: includes/admin/settings/register-settings.php:212
229
+ msgid "Customize the message displayed when a username is changed successfully."
230
+ msgstr ""
231
+
232
+ #: includes/admin/settings/register-settings.php:218
233
+ msgid "Relogin Message"
234
+ msgstr ""
235
+
236
+ #: includes/admin/settings/register-settings.php:219
237
+ msgid ""
238
+ "Customize the text for the relogin link shown if a user changes their own "
239
+ "username."
240
+ msgstr ""
241
+
242
+ #: includes/admin/settings/register-settings.php:225
243
+ msgid "Short Username Error"
244
+ msgstr ""
245
+
246
+ #: includes/admin/settings/register-settings.php:226
247
+ msgid "Customize the error displayed when a username is too short."
248
+ msgstr ""
249
+
250
+ #: includes/admin/settings/register-settings.php:228 includes/scripts.php:42
251
+ msgid "Username is too short, the minimum length is {minlength} characters."
252
+ msgstr ""
253
+
254
+ #: includes/admin/settings/register-settings.php:232
255
+ #: includes/admin/settings/register-settings.php:236
256
+ msgid "Wrong Permissions Error"
257
+ msgstr ""
258
+
259
+ #: includes/admin/settings/register-settings.php:233
260
+ msgid ""
261
+ "Customize the error displayed when a user attempts to change a username "
262
+ "they do not have permission to change."
263
+ msgstr ""
264
+
265
+ #: includes/admin/settings/register-settings.php:237
266
+ msgid ""
267
+ "In normal circumstances, this message should never be triggered. It exists "
268
+ "only to provide an extra layer of security against unauthorized use."
269
+ msgstr ""
270
+
271
+ #: includes/admin/settings/register-settings.php:241
272
+ msgid "Duplicate Username Error"
273
+ msgstr ""
274
+
275
+ #: includes/admin/settings/register-settings.php:242
276
+ msgid ""
277
+ "Customize the error displayed when a user attempts to change a username to "
278
+ "something that is already in use."
279
+ msgstr ""
280
+
281
+ #: includes/admin/settings/register-settings.php:254
282
+ msgid "Username Changer Support"
283
+ msgstr ""
284
+
285
+ #: includes/admin/settings/register-settings.php:260
286
+ msgid "System Info"
287
+ msgstr ""
288
+
289
+ #: includes/admin/settings/register-settings.php:282
290
+ #: includes/admin/settings/register-settings.php:300
291
+ msgid "Template Tags"
292
+ msgstr ""
293
+
294
+ #: includes/admin/settings/register-settings.php:283
295
+ msgid "Emails allow the use of the following template tags:"
296
+ msgstr ""
297
+
298
+ #: includes/admin/settings/register-settings.php:301
299
+ msgid "The message settings fields allow the use of the following template tags:"
300
+ msgstr ""
301
+
302
+ #: includes/class-username-changer-template-tags.php:293
303
+ msgid "The original username of the user"
304
+ msgstr ""
305
+
306
+ #: includes/class-username-changer-template-tags.php:299
307
+ msgid "The new username of the user"
308
+ msgstr ""
309
+
310
+ #: includes/class-username-changer-template-tags.php:305
311
+ msgid "The email address of the user"
312
+ msgstr ""
313
+
314
+ #: includes/class-username-changer-template-tags.php:311
315
+ msgid "Your site name"
316
+ msgstr ""
317
+
318
+ #: includes/class-username-changer-template-tags.php:317
319
+ msgid "Your site URL"
320
+ msgstr ""
321
+
322
+ #: includes/class-username-changer-template-tags.php:323
323
+ msgid "The login URL for your site"
324
+ msgstr ""
325
+
326
+ #: includes/class-username-changer-template-tags.php:329
327
+ msgid "Today's date"
328
+ msgstr ""
329
+
330
+ #: includes/class-username-changer-template-tags.php:335
331
+ msgid "The first name of the user"
332
+ msgstr ""
333
+
334
+ #: includes/class-username-changer-template-tags.php:341
335
+ msgid "The full name of the user, first and last"
336
+ msgstr ""
337
+
338
+ #: includes/class-username-changer-template-tags.php:347
339
+ msgid "The minimum allowed username length"
340
+ msgstr ""
341
+
342
+ #: tests/bootstrap.php:71
343
+ msgid "HTTP requests disabled for unit tests"
344
+ msgstr ""
345
+
346
+ #. Description of the plugin/theme
347
+ msgid "Change usernames easily"
348
+ msgstr ""
license.txt CHANGED
@@ -1,281 +1,674 @@
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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
 
 
 
3
 
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
  Everyone is permitted to copy and distribute verbatim copies
6
  of this license document, but changing it is not allowed.
7
 
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
 
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. 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
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
 
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
 
34
  For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
 
68
  The precise terms and conditions for copying, distribution and
69
  modification follow.
70
 
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
  this License.
486
 
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
  otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  be similar in spirit to the present version, but may differ in detail to
568
  address new problems or concerns.
569
 
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
readme.md DELETED
@@ -1,22 +0,0 @@
1
- # Username Changer
2
-
3
- ![Plugin Version](https://img.shields.io/wordpress/plugin/v/username-changer.svg) ![Total Downloads](https://img.shields.io/wordpress/plugin/dt/username-changer.svg) ![Plugin Rating](https://img.shields.io/wordpress/plugin/r/username-changer.svg) ![WordPress Compatibility](https://img.shields.io/wordpress/v/username-changer.svg) [![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://github.com/evertiro/username-changer/blob/master/license.txt)
4
-
5
- ### Welcome to our GitHub Repository
6
-
7
- Changing usernames _should_ be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
8
-
9
- ## Installation
10
-
11
- 1. You can clone the GitHub repository: `https://github.com/evertiro/username-changer.git`
12
- 2. Or download it directly as a ZIP file: `https://github.com/evertiro/username-changer/archive/master.zip`
13
-
14
- This will download the latest developer copy of Username Changer.
15
-
16
- ## Bugs
17
-
18
- If you find an issue, let us know [here](https://github.com/evertiro/username-changer/issues?state=open)!
19
-
20
- ## Contributions
21
-
22
- Anyone is welcome to contribute to Username Changer. Please read the [guidelines for contributing](https://github.com/evertiro/username-changer/blob/master/CONTRIBUTING.md) to this repository.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,94 +1,94 @@
1
- === Username Changer ===
2
- Contributors: evertiro
3
- Donate link: https://evertiro.com/donate/
4
- Tags: user, username, display name, login
5
- Requires at least: 3.0
6
- Tested up to: 4.7.1
7
- Stable tag: 3.1.3
8
-
9
- Change usernames easily
10
-
11
- == Description ==
12
-
13
- Changing usernames should be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
14
-
15
- == Installation ==
16
-
17
- = From your WordPress dashboard =
18
-
19
- 1. Visit 'Plugins > Add New'
20
- 2. Search for 'Username Changer'
21
- 3. Activate Username Changer from your Plugins page
22
-
23
- = From WordPress.org =
24
-
25
- 1. Download Username Changer
26
- 2. Upload the 'username-changer' folder to the '/wp-content/plugins' directory of your WordPress installation
27
- 3. Activate Username Changer from your Plugins page
28
-
29
- == Frequently Asked Questions ==
30
-
31
- = Is Username Changer compatible with <a href="https://wordpress.org/plugins/co-authors-plus/">Co-Authors Plus</a>? =
32
-
33
- Yes! Username Changer works out of the box with Co-Authors Plus.
34
-
35
- == Screenshots ==
36
-
37
- 1. **Settings Panel** - The settings panel allows you to configure username rules and message string, as well as providing a simple method for contacting our support.
38
- 2. **Changing A Username** - Since version 3.0.0, usernames are now changed through the user profile page.
39
-
40
  == Changelog ==
41
 
42
  = Version 3.1.1 =
43
  * Fixed: Issue with multicheck settings fields
44
-
45
- + Version 3.1.0 =
46
- * Added: Email notification support
47
- * Added: Nickname support
48
- * Improved: SQL performance
49
- * Improved: Dynamically update profile files
50
-
51
- = Version 3.0.1 =
52
- * Fixed: Typo in readme file
53
-
54
- = Version 3.0.0 =
55
- * Improved: Replaced the clunky interface with an inline profile field (props: Danny van Kooten)
56
- * Added: Settings panel
57
-
58
- = Version 2.1.1 =
59
- * Removed: Deprecated functions
60
-
61
- = Version 2.0.5 =
62
- * Fixed: Contributor field
63
-
64
- = Version 2.0.4 =
65
- * Updated: Plugin metalinks
66
-
67
- = Version 2.0.3 =
68
- * Fixed: User nice name support
69
-
70
- = Version 2.0.2 =
71
- * Added: multisite support
72
-
73
- = Version 2.0.1 =
74
- * Added: Proper username sanitization
75
- * Improved: Minor code cleanup
76
-
77
- = Version 2.0.0 =
78
- * Improved: Converted to class-based structure
79
-
80
- = Version 1.4 =
81
- * Added: Include author url (nicename) in update process
82
-
83
- = Version 1.3 =
84
- * Fixed: Properly escaped vars on POST (I think)
85
-
86
- = Version 1.2 =
87
- * Fixed: Minor tweak to previous release
88
-
89
- = Version 1.1 =
90
- * Added: Action on All Users page
91
- * Improved: User dropdown is now sorted alphabetically
92
-
93
- = Version 1.0 =
94
- * Initial release
1
+ === Username Changer ===
2
+ Contributors: widgitlabs, evertiro
3
+ Donate link: https://evertiro.com/donate/
4
+ Tags: user, username, display name, login
5
+ Requires at least: 3.0
6
+ Tested up to: 5.3.2
7
+ Stable tag: 3.2.0
8
+
9
+ Change usernames easily
10
+
11
+ == Description ==
12
+
13
+ Changing usernames should be a pretty straightforward feature. Unfortunately, WordPress doesn't allow it by default. Username Changer attempts to remedy that oversight.
14
+
15
+ == Installation ==
16
+
17
+ = From your WordPress dashboard =
18
+
19
+ 1. Visit 'Plugins > Add New'
20
+ 2. Search for 'Username Changer'
21
+ 3. Activate Username Changer from your Plugins page
22
+
23
+ = From WordPress.org =
24
+
25
+ 1. Download Username Changer
26
+ 2. Upload the 'username-changer' folder to the '/wp-content/plugins' directory of your WordPress installation
27
+ 3. Activate Username Changer from your Plugins page
28
+
29
+ == Frequently Asked Questions ==
30
+
31
+ = Is Username Changer compatible with <a href="https://wordpress.org/plugins/co-authors-plus/">Co-Authors Plus</a>? =
32
+
33
+ Yes! Username Changer works out of the box with Co-Authors Plus.
34
+
35
+ == Screenshots ==
36
+
37
+ 1. **Settings Panel** - The settings panel allows you to configure username rules and message string, as well as providing a simple method for contacting our support.
38
+ 2. **Changing A Username** - Since version 3.0.0, usernames are now changed through the user profile page.
39
+
40
  == Changelog ==
41
 
42
  = Version 3.1.1 =
43
  * Fixed: Issue with multicheck settings fields
44
+
45
+ + Version 3.1.0 =
46
+ * Added: Email notification support
47
+ * Added: Nickname support
48
+ * Improved: SQL performance
49
+ * Improved: Dynamically update profile files
50
+
51
+ = Version 3.0.1 =
52
+ * Fixed: Typo in readme file
53
+
54
+ = Version 3.0.0 =
55
+ * Improved: Replaced the clunky interface with an inline profile field (props: Danny van Kooten)
56
+ * Added: Settings panel
57
+
58
+ = Version 2.1.1 =
59
+ * Removed: Deprecated functions
60
+
61
+ = Version 2.0.5 =
62
+ * Fixed: Contributor field
63
+
64
+ = Version 2.0.4 =
65
+ * Updated: Plugin metalinks
66
+
67
+ = Version 2.0.3 =
68
+ * Fixed: User nice name support
69
+
70
+ = Version 2.0.2 =
71
+ * Added: multisite support
72
+
73
+ = Version 2.0.1 =
74
+ * Added: Proper username sanitization
75
+ * Improved: Minor code cleanup
76
+
77
+ = Version 2.0.0 =
78
+ * Improved: Converted to class-based structure
79
+
80
+ = Version 1.4 =
81
+ * Added: Include author url (nicename) in update process
82
+
83
+ = Version 1.3 =
84
+ * Fixed: Properly escaped vars on POST (I think)
85
+
86
+ = Version 1.2 =
87
+ * Fixed: Minor tweak to previous release
88
+
89
+ = Version 1.1 =
90
+ * Added: Action on All Users page
91
+ * Improved: User dropdown is now sorted alphabetically
92
+
93
+ = Version 1.0 =
94
+ * Initial release
username-changer.php DELETED
@@ -1,165 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: Username Changer
4
- * Description: Change usernames easily
5
- * Version: 3.1.3
6
- * Author: Daniel J Griffiths
7
- * Author URI: https://evertiro.com
8
- * Text Domain: username-changer
9
- *
10
- * @package UsernameChanger
11
- * @author Daniel J Griffiths <dgriffiths@evertiro.com>
12
- * @copyright Copyright (c) 2014, Daniel J Griffiths
13
- */
14
-
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
- *
56
- * @access public
57
- * @since 2.0.0
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;
70
- }
71
-
72
-
73
- /**
74
- * Setup plugin constants
75
- *
76
- * @access private
77
- * @since 2.0.0
78
- * @return void
79
- */
80
- private function setup_constants() {
81
- // Plugin path
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.1.3' );
89
- }
90
-
91
-
92
- /**
93
- * Include necessary files
94
- *
95
- * @access private
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
- /**
121
- * Load plugin language files
122
- *
123
- * @access public
124
- * @since 2.0.0
125
- * @return void
126
- */
127
- public function load_textdomain() {
128
- // Set filter for language directory
129
- $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
130
- $lang_dir = apply_filters( 'username_changer_lang_dir', $lang_dir );
131
-
132
- // WordPress plugin locale filter
133
- $locale = apply_filters( 'plugin_locale', get_locale(), 'username-changer' );
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 {
147
- // Load the default language files
148
- load_plugin_textdomain( 'username-changer', false, $lang_dir );
149
- }
150
- }
151
- }
152
- }
153
-
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' );