├── .editorconfig ├── .gitignore ├── .travis.yml ├── Gruntfile.js ├── LICENSE.txt ├── README.md ├── assets ├── banner-1544x500.png ├── banner-772x250.png ├── icon.svg ├── screenshot-1.png └── screenshot-2.png ├── bin └── install-wp-tests.sh ├── classes └── Controller.php ├── composer.json ├── composer.lock ├── css └── src │ └── simple-user-adding.scss ├── grunt ├── aliases.yaml ├── checktextdomain.js ├── clean.js ├── compress.js ├── concat.js ├── copy.js ├── jshint.js ├── phpunit.js ├── postcss.js ├── replace.js ├── sass.js ├── test.js ├── uglify.js ├── watch.js └── wp_deploy.js ├── init.php ├── js └── src │ └── simple-user-adding.js ├── lib ├── requirements-check.php └── wp-stack-plugin.php ├── package.json ├── phpunit.xml ├── simple-user-adding.php ├── tests ├── bootstrap.php └── test-tests.php └── views └── simple-user-adding-form.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | # WordPress Coding Standards 5 | # http://make.wordpress.org/core/handbook/coding-standards/ 6 | 7 | root = true 8 | 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | indent_style = tab 15 | 16 | [{.jshintrc,*.json,*.yml}] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [{*.txt,wp-config-sample.php}] 21 | end_of_line = crlf 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | .DS_Store 3 | 4 | # npm 5 | /node_modules 6 | 7 | # Release task 8 | /release 9 | 10 | # Build files 11 | /js/*.js 12 | /js/*.map 13 | /css/*.css 14 | /css/*.map 15 | 16 | # Sass 17 | .sass-cache 18 | 19 | # Vendor (e.g. Composer) 20 | vendor/* 21 | !vendor/.gitkeep 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.2 5 | - 5.3 6 | - 5.4 7 | - 5.5 8 | - 5.6 9 | 10 | env: 11 | - WP_VERSION=latest WP_MULTISITE=0 12 | - WP_VERSION=latest WP_MULTISITE=1 13 | - WP_VERSION=4.1.1 WP_MULTISITE=0 14 | - WP_VERSION=4.1.1 WP_MULTISITE=1 15 | - WP_VERSION=4.0.1 WP_MULTISITE=0 16 | - WP_VERSION=4.0.1 WP_MULTISITE=1 17 | - WP_VERSION=3.9.3 WP_MULTISITE=0 18 | - WP_VERSION=3.9.3 WP_MULTISITE=1 19 | 20 | before_script: 21 | - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 22 | 23 | script: phpunit 24 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 3 | // measures the time each task takes 4 | require('time-grunt')(grunt); 5 | 6 | // load grunt config 7 | require('load-grunt-config')(grunt); 8 | 9 | }; 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 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 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple User Adding # 2 | Contributors: wearerequired, swissspidy 3 | Tags: admin, email, users, form, registration 4 | Requires at least: 3.1 5 | Tested up to: 4.6 6 | Requires PHP: 5.3 7 | Stable tag: 1.1.1 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | This plugin makes adding users to your WordPress site easier than ever before. 12 | 13 | ## Description ## 14 | 15 | Simple User Adding declutters the form used to add new users to your site and strips it down to a minimum. 16 | 17 | Highlights: 18 | 19 | * You no longer have to enter a custom password. It is automatically created for you. 20 | * The plugin tries to detect the new user’s name from the email address you entered. 21 | * Also: A “Show More” link reveals the first and last name fields, plus a new field to enter a custom welcome message for the new user. 22 | 23 | ## Installation ## 24 | 25 | ### Manual Installation ### 26 | 27 | 1. Upload the entire `/simple-user-adding` directory to the `/wp-content/plugins/` directory. 28 | 2. Activate Simple User Adding through the 'Plugins' menu in WordPress. 29 | 3. Add new users through Users -> Add New 30 | 31 | ## Frequently Asked Questions ## 32 | 33 | ### Why can’t I enter a custom welcome message? ### 34 | 35 | If the message field is missing, another plugin is already defining the `wp_new_user_notification` function. This means we can’t define our own mail function and therefore you can’t enter a custom message. 36 | 37 | ### I want more control! Where can I add more info? ### 38 | 39 | Well, edit the user’s profile afterwards or just go to the original form to add new users. You can find a link to it in the admin footer. 40 | 41 | ### Is Multisite supported? ### 42 | 43 | Not 100% yet, but we’re working on it! 44 | 45 | ## Screenshots ## 46 | 47 | 1. This plugin makes adding new users to your WordPress site simpler than ever. 48 | 2. You can even enter a custom message that is shown in the confirmation email the user receives. 49 | 50 | ## Contribute ## 51 | 52 | If you would like to contribute to this plugin, report an isse or anything like that, please note that we develop this plugin on [GitHub](https://github.com/wearerequired/simple-user-adding). 53 | 54 | Developed by [required](https://required.com/ "Team of experienced web professionals from Switzerland & Germany") 55 | 56 | ## Changelog ## 57 | 58 | ### 1.1.1 ### 59 | * Enhancement: Small improvements to the user adding form. 60 | 61 | ### 1.1.0 ### 62 | * Enhancement: Now supports the Digest Notifications plugin. 63 | * Enhancement: Improved name guessing from email address. 64 | * Fixed: The plugin now works with WordPress 4.3. 65 | 66 | ### 1.0.0 ### 67 | * First release 68 | 69 | ## Upgrade Notice ## 70 | 71 | ### 1.1.1 ### 72 | Being 100% compatible with WordPress 4.4, this update includes some smaller enhancements. 73 | 74 | ### 1.1.0 ### 75 | Being 100% compatible with WordPress 4.3, this update includes some smaller enhancements. 76 | 77 | ### 1.0.0 ### 78 | First release 79 | -------------------------------------------------------------------------------- /assets/banner-1544x500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wearerequired/simple-user-adding/f38d82f9eff77ddac15dea24483ede7ade8b040e/assets/banner-1544x500.png -------------------------------------------------------------------------------- /assets/banner-772x250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wearerequired/simple-user-adding/f38d82f9eff77ddac15dea24483ede7ade8b040e/assets/banner-772x250.png -------------------------------------------------------------------------------- /assets/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /assets/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wearerequired/simple-user-adding/f38d82f9eff77ddac15dea24483ede7ade8b040e/assets/screenshot-1.png -------------------------------------------------------------------------------- /assets/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wearerequired/simple-user-adding/f38d82f9eff77ddac15dea24483ede7ade8b040e/assets/screenshot-2.png -------------------------------------------------------------------------------- /bin/install-wp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: $0 [db-host] [wp-version]" 5 | exit 1 6 | fi 7 | 8 | DB_NAME=$1 9 | DB_USER=$2 10 | DB_PASS=$3 11 | DB_HOST=${4-localhost} 12 | WP_VERSION=${5-latest} 13 | 14 | WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} 15 | WP_CORE_DIR=/tmp/wordpress/ 16 | 17 | set -ex 18 | 19 | install_wp() { 20 | mkdir -p $WP_CORE_DIR 21 | 22 | if [ $WP_VERSION == 'latest' ]; then 23 | local ARCHIVE_URL='https://github.com/WordPress/WordPress/archive/master.tar.gz' 24 | else 25 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 26 | local ARCHIVE_URL="http://wordpress.org/${ARCHIVE_NAME}.tar.gz" 27 | fi 28 | 29 | wget -nv -O /tmp/wordpress.tar.gz $ARCHIVE_URL 30 | tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR 31 | 32 | wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php 33 | } 34 | 35 | install_test_suite() { 36 | # portable in-place argument for both GNU sed and Mac OSX sed 37 | if [[ $(uname -s) == 'Darwin' ]]; then 38 | local ioption='-i .bak' 39 | else 40 | local ioption='-i' 41 | fi 42 | 43 | # set up testing suite 44 | mkdir -p $WP_TESTS_DIR 45 | cd $WP_TESTS_DIR 46 | svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/ 47 | 48 | wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php 49 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php 50 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php 51 | sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php 52 | sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php 53 | sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php 54 | } 55 | 56 | install_db() { 57 | # parse DB_HOST for port or socket references 58 | local PARTS=(${DB_HOST//\:/ }) 59 | local DB_HOSTNAME=${PARTS[0]}; 60 | local DB_SOCK_OR_PORT=${PARTS[1]}; 61 | local EXTRA="" 62 | 63 | if ! [ -z $DB_HOSTNAME ] ; then 64 | if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then 65 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" 66 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then 67 | EXTRA=" --socket=$DB_SOCK_OR_PORT" 68 | elif ! [ -z $DB_HOSTNAME ] ; then 69 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" 70 | fi 71 | fi 72 | 73 | # create database 74 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA 75 | } 76 | 77 | install_wp 78 | install_test_suite 79 | install_db 80 | -------------------------------------------------------------------------------- /classes/Controller.php: -------------------------------------------------------------------------------- 1 | file = $file; 47 | } 48 | 49 | /** 50 | * Adds hooks. 51 | */ 52 | public function add_hooks() { 53 | add_action( 'init', array( $this, 'load_textdomain' ) ); 54 | 55 | // Add the options page with the custom admin footer text. 56 | add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 57 | add_action( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); 58 | 59 | // Add help tab. 60 | add_action( 'load-users_page_simple-user-adding', array( $this, 'admin_help_tab' ) ); 61 | 62 | // Load admin style sheet and JavaScript. 63 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); 64 | 65 | // Handle form submissions. 66 | add_action( 'admin_post_simple_user_adding', array( $this, 'create_user' ) ); 67 | } 68 | 69 | /** 70 | * Returns the URL to the plugin directory (with trailing slash). 71 | * 72 | * @return string The URL to the plugin directory. 73 | */ 74 | public function get_url() { 75 | return plugin_dir_url( $this->file ); 76 | } 77 | 78 | /** 79 | * Returns the absolute path to the plugin directory (with trailing slash). 80 | * 81 | * @return string The absolute path to the plugin directory. 82 | */ 83 | public function get_path() { 84 | return plugin_dir_path( $this->file ); 85 | } 86 | 87 | /** 88 | * Returns the basename of the plugin. 89 | * 90 | * @return string The name of the plugin. 91 | */ 92 | public function get_basename() { 93 | return plugin_basename( $this->file ); 94 | } 95 | 96 | /** 97 | * Initializes the plugin, registers textdomain, etc. 98 | * 99 | * @return bool True if the textdomain was loaded successfully, false otherwise. 100 | */ 101 | public function load_textdomain() { 102 | return load_plugin_textdomain( 'simple-user-adding', false, $this->get_path() . 'languages' ); 103 | } 104 | 105 | /** 106 | * Whether the plugin can modify the emails being sent or not. 107 | * 108 | * @param bool $possible Optional. The value to set. Default null. 109 | * @return bool Whether the plugin can modify the emails being sent or not. 110 | */ 111 | public function can_modify_email( $possible = null ) { 112 | if ( null !== $possible ) { 113 | $this->can_modify_email = (bool) $possible; 114 | } 115 | 116 | return $this->can_modify_email; 117 | } 118 | 119 | /** 120 | * Add a new admin menu item. 121 | */ 122 | public function admin_menu() { 123 | add_users_page( 124 | __( 'Add New User', 'simple-user-adding' ), 125 | __( 'Add New', 'simple-user-adding' ), 126 | 'create_users', 127 | 'simple-user-adding', 128 | array( $this, 'display_admin_page' ) 129 | ); 130 | remove_submenu_page( 'users.php', 'user-new.php' ); 131 | } 132 | 133 | /** 134 | * Output the content for the new admin page. 135 | */ 136 | public function display_admin_page() { 137 | include $this->get_path() . 'views/simple-user-adding-form.php'; 138 | } 139 | 140 | /** 141 | * Add some text in the footer of our admin page. 142 | * 143 | * @return string 144 | */ 145 | public function admin_footer_text() { 146 | $screen = get_current_screen(); 147 | if ( 'users_page_simple-user-adding' !== $screen->id ) { 148 | return ''; 149 | } 150 | $text = sprintf( __( '%s is brought to you by %s. We ♥ WordPress.', 'simple-user-adding' ), 'Simple User Adding', 'required+' ); 151 | $text .= ' ' . __( 'Looking for the original Add User form?', 'simple-user-adding' ) . ''; 152 | 153 | return $text; 154 | } 155 | 156 | /** 157 | * Add help text to our admin page. 158 | */ 159 | public function admin_help_tab() { 160 | $screen = get_current_screen(); 161 | if ( 'users_page_simple-user-adding' !== $screen->id ) { 162 | return; 163 | } 164 | 165 | $help = '

' . __( 'To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.', 'simple-user-adding' ) . '

'; 166 | 167 | if ( is_multisite() ) { 168 | $help .= '

' . __( 'Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.', 'simple-user-adding' ) . '

'; 169 | } 170 | 171 | $help .= '

' . __( 'New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their automatically generated password.', 'simple-user-adding' ) . '

'; 172 | $help .= '

' . __( 'Remember to click the Add New User button at the bottom of this screen when you are finished.', 'simple-user-adding' ) . '

'; 173 | 174 | $screen->add_help_tab( array( 175 | 'id' => 'overview', 176 | 'title' => __( 'Overview', 'simple-user-adding' ), 177 | 'content' => $help, 178 | ) ); 179 | 180 | $screen->add_help_tab( array( 181 | 'id' => 'user-roles', 182 | 'title' => __( 'User Roles', 'simple-user-adding' ), 183 | 'content' => '

' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:', 'simple-user-adding' ) . '

' . 184 | '
    ' . 185 | '
  • ' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.', 'simple-user-adding' ) . '
  • ' . 186 | '
  • ' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.', 'simple-user-adding' ) . '
  • ' . 187 | '
  • ' . __( 'Authors can publish and manage their own posts, and are able to upload files.', 'simple-user-adding' ) . '
  • ' . 188 | '
  • ' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.', 'simple-user-adding' ) . '
  • ' . 189 | '
  • ' . __( 'Administrators have access to all the administration features.', 'simple-user-adding' ) . '
  • ' . 190 | '
', 191 | ) ); 192 | 193 | $screen->set_help_sidebar( 194 | '

' . __( 'For more information:', 'simple-user-adding' ) . '

' . 195 | '

' . __( 'Documentation on Adding New Users', 'simple-user-adding' ) . '

' . 196 | '

' . __( 'Support Forums', 'simple-user-adding' ) . '

' 197 | ); 198 | } 199 | 200 | /** 201 | * Enqueue scripts and styles on our admin page. 202 | */ 203 | public function admin_enqueue_scripts() { 204 | $screen = get_current_screen(); 205 | 206 | if ( 'users_page_simple-user-adding' !== $screen->id ) { 207 | return; 208 | } 209 | 210 | $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 211 | 212 | wp_enqueue_style( 'sua-admin-styles', $this->get_url() . 'css/simple-user-adding' . $suffix . '.css', array(), self::VERSION ); 213 | 214 | $dependencies = array( 'jquery' ); 215 | 216 | if ( is_multisite() ) { 217 | $dependencies[] = 'user-suggest'; 218 | } 219 | 220 | wp_enqueue_script( 'sua-admin-script', $this->get_url() . 'js/simple-user-adding' . $suffix . '.js', $dependencies, self::VERSION ); 221 | } 222 | 223 | /** 224 | * Handle form submissions. 225 | */ 226 | public function create_user() { 227 | /** 228 | * This checks for the correct referrer and the nonce. 229 | * On failure, the function dies after calling the wp_nonce_ays() function. 230 | */ 231 | check_admin_referer( 'simple-user-adding', 'simple_user_adding_nonce' ); 232 | 233 | if ( ! current_user_can( 'create_users' ) ) { 234 | wp_die( __( 'Cheatin’ uh?', 'simple-user-adding' ), 403 ); 235 | } 236 | 237 | // Check required fields. 238 | if ( ! isset( $_POST['user_login'] ) || empty( $_POST['user_login'] ) 239 | || ! isset( $_POST['email'] ) || empty( $_POST['email'] ) 240 | ) { 241 | wp_redirect( add_query_arg( 242 | array( 'message' => 'required_fields_missing' ), 243 | admin_url( 'users.php?page=simple-user-adding' ) 244 | ) ); 245 | die(); 246 | } 247 | 248 | // Check if the email address is valid. 249 | $user_email = wp_unslash( $_POST['email'] ); 250 | if ( ! is_email( $user_email ) ) { 251 | wp_redirect( add_query_arg( 252 | array( 'message' => 'enter_email' ), 253 | admin_url( 'users.php?page=simple-user-adding' ) 254 | ) ); 255 | die(); 256 | } 257 | 258 | // Check if a user with this email address already exists. 259 | if ( get_user_by( 'email', $user_email ) ) { 260 | wp_redirect( add_query_arg( 261 | array( 'message' => 'user_email_exists' ), 262 | admin_url( 'users.php?page=simple-user-adding' ) 263 | ) ); 264 | die(); 265 | } 266 | 267 | // Check if a user with this login already exists. 268 | if ( get_user_by( 'login', wp_unslash( $_POST['user_login'] ) ) ) { 269 | wp_redirect( add_query_arg( 270 | array( 'message' => 'user_name_exists' ), 271 | admin_url( 'users.php?page=simple-user-adding' ) 272 | ) ); 273 | die(); 274 | } 275 | 276 | // Set passwords for use in edit_user(). 277 | $_POST['pass2'] = $_POST['pass1'] = wp_generate_password( 24 ); 278 | 279 | // Set the flag to send a notification mail to the user. 280 | $_POST['send_password'] = true; 281 | 282 | // Filter the user notification when there's a custom message. 283 | if ( $this->can_modify_email && isset( $_POST['notification_msg'] ) && ! empty( $_POST['notification_msg'] ) ) { 284 | $this->notification_message = wp_kses( $_POST['notification_msg'], array() ); 285 | 286 | add_filter( 'sua_notification_message', array( $this, 'modify_notification_message' ) ); 287 | } 288 | 289 | // This creates (or updates) a user. 290 | $user_id = edit_user(); 291 | if ( is_wp_error( $user_id ) ) { 292 | wp_redirect( add_query_arg( 293 | array( 'message' => 'failure' ), 294 | admin_url( 'users.php?page=simple-user-adding' ) 295 | ) ); 296 | die(); 297 | } 298 | 299 | wp_redirect( add_query_arg( 300 | array( 'message' => 'success' ), 301 | admin_url( 'users.php?page=simple-user-adding' ) 302 | ) ); 303 | die(); 304 | } 305 | 306 | /** 307 | * Filter the new user notification message. 308 | * 309 | * @param string $message The notification message. 310 | * 311 | * @return string 312 | */ 313 | public function modify_notification_message( $message ) { 314 | if ( ! empty( $this->notification_message ) ) { 315 | $message = $this->notification_message . "\r\n\r\n" . $message; 316 | } 317 | 318 | return $message; 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wearerequired/simple-user-adding", 3 | "description": "This plugin makes adding users to your WordPress site easier than ever before.", 4 | "version": "1.0.0", 5 | "type": "wordpress-plugin", 6 | "license": "GPL-2.0+", 7 | "authors": [ 8 | { 9 | "name": "required+", 10 | "email": "support@required.ch", 11 | "homepage": "https://required.ch", 12 | "role": "Developer" 13 | } 14 | ], 15 | "repositories": [ 16 | { 17 | "type": "vcs", 18 | "url": "https://github.com/wearerequired/wp-requirements-check" 19 | } 20 | ], 21 | "require": { 22 | "php": ">=5.4", 23 | "wearerequired/wp-requirements-check": "dev-master" 24 | }, 25 | "require-dev": { 26 | "phpmd/phpmd": "~2.4.0", 27 | "wp-coding-standards/wpcs": "~0.10.0" 28 | }, 29 | "scripts": { 30 | "post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs", 31 | "post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Required\\Simple_User_Adding\\": "classes" 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "4e6317fb802ac17c5344f7b9cc72a83c", 8 | "content-hash": "dd99e848e864952632b30f18beab83cd", 9 | "packages": [ 10 | { 11 | "name": "wearerequired/wp-requirements-check", 12 | "version": "dev-master", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/wearerequired/wp-requirements-check.git", 16 | "reference": "0d9f602ed83def11f97c07ee76ad204cc1ba247f" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/wearerequired/wp-requirements-check/zipball/0d9f602ed83def11f97c07ee76ad204cc1ba247f", 21 | "reference": "0d9f602ed83def11f97c07ee76ad204cc1ba247f", 22 | "shasum": "" 23 | }, 24 | "type": "library", 25 | "autoload": { 26 | "classmap": [ 27 | "WP_Requirements_Check.php" 28 | ] 29 | }, 30 | "license": [ 31 | "GPL-2.0+" 32 | ], 33 | "authors": [ 34 | { 35 | "name": "required", 36 | "email": "support@required.ch", 37 | "homepage": "http://required.ch", 38 | "role": "Developer" 39 | } 40 | ], 41 | "description": "Simple requirements checking class", 42 | "support": { 43 | "source": "https://github.com/wearerequired/wp-requirements-check/tree/master", 44 | "issues": "https://github.com/wearerequired/wp-requirements-check/issues" 45 | }, 46 | "time": "2016-06-06 18:20:15" 47 | } 48 | ], 49 | "packages-dev": [ 50 | { 51 | "name": "pdepend/pdepend", 52 | "version": "2.2.4", 53 | "source": { 54 | "type": "git", 55 | "url": "https://github.com/pdepend/pdepend.git", 56 | "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06" 57 | }, 58 | "dist": { 59 | "type": "zip", 60 | "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b086687f3a01dc6bb92d633aef071d2c5dd0db06", 61 | "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06", 62 | "shasum": "" 63 | }, 64 | "require": { 65 | "php": ">=5.3.7", 66 | "symfony/config": "^2.3.0|^3", 67 | "symfony/dependency-injection": "^2.3.0|^3", 68 | "symfony/filesystem": "^2.3.0|^3" 69 | }, 70 | "require-dev": { 71 | "phpunit/phpunit": "^4.4.0,<4.8", 72 | "squizlabs/php_codesniffer": "^2.0.0" 73 | }, 74 | "bin": [ 75 | "src/bin/pdepend" 76 | ], 77 | "type": "library", 78 | "autoload": { 79 | "psr-4": { 80 | "PDepend\\": "src/main/php/PDepend" 81 | } 82 | }, 83 | "notification-url": "https://packagist.org/downloads/", 84 | "license": [ 85 | "BSD-3-Clause" 86 | ], 87 | "description": "Official version of pdepend to be handled with Composer", 88 | "time": "2016-03-10 15:15:04" 89 | }, 90 | { 91 | "name": "phpmd/phpmd", 92 | "version": "2.4.3", 93 | "source": { 94 | "type": "git", 95 | "url": "https://github.com/phpmd/phpmd.git", 96 | "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e" 97 | }, 98 | "dist": { 99 | "type": "zip", 100 | "url": "https://api.github.com/repos/phpmd/phpmd/zipball/2b9c2417a18696dfb578b38c116cd0ddc19b256e", 101 | "reference": "2b9c2417a18696dfb578b38c116cd0ddc19b256e", 102 | "shasum": "" 103 | }, 104 | "require": { 105 | "pdepend/pdepend": "^2.0.4", 106 | "php": ">=5.3.0" 107 | }, 108 | "require-dev": { 109 | "phpunit/phpunit": "^4.0", 110 | "squizlabs/php_codesniffer": "^2.0" 111 | }, 112 | "bin": [ 113 | "src/bin/phpmd" 114 | ], 115 | "type": "project", 116 | "autoload": { 117 | "psr-0": { 118 | "PHPMD\\": "src/main/php" 119 | } 120 | }, 121 | "notification-url": "https://packagist.org/downloads/", 122 | "license": [ 123 | "BSD-3-Clause" 124 | ], 125 | "authors": [ 126 | { 127 | "name": "Manuel Pichler", 128 | "email": "github@manuel-pichler.de", 129 | "homepage": "https://github.com/manuelpichler", 130 | "role": "Project Founder" 131 | }, 132 | { 133 | "name": "Other contributors", 134 | "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", 135 | "role": "Contributors" 136 | }, 137 | { 138 | "name": "Marc Würth", 139 | "email": "ravage@bluewin.ch", 140 | "homepage": "https://github.com/ravage84", 141 | "role": "Project Maintainer" 142 | } 143 | ], 144 | "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", 145 | "homepage": "http://phpmd.org/", 146 | "keywords": [ 147 | "mess detection", 148 | "mess detector", 149 | "pdepend", 150 | "phpmd", 151 | "pmd" 152 | ], 153 | "time": "2016-04-04 11:52:04" 154 | }, 155 | { 156 | "name": "squizlabs/php_codesniffer", 157 | "version": "2.7.0", 158 | "source": { 159 | "type": "git", 160 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 161 | "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed" 162 | }, 163 | "dist": { 164 | "type": "zip", 165 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", 166 | "reference": "571e27b6348e5b3a637b2abc82ac0d01e6d7bbed", 167 | "shasum": "" 168 | }, 169 | "require": { 170 | "ext-simplexml": "*", 171 | "ext-tokenizer": "*", 172 | "ext-xmlwriter": "*", 173 | "php": ">=5.1.2" 174 | }, 175 | "require-dev": { 176 | "phpunit/phpunit": "~4.0" 177 | }, 178 | "bin": [ 179 | "scripts/phpcs", 180 | "scripts/phpcbf" 181 | ], 182 | "type": "library", 183 | "extra": { 184 | "branch-alias": { 185 | "dev-master": "2.x-dev" 186 | } 187 | }, 188 | "autoload": { 189 | "classmap": [ 190 | "CodeSniffer.php", 191 | "CodeSniffer/CLI.php", 192 | "CodeSniffer/Exception.php", 193 | "CodeSniffer/File.php", 194 | "CodeSniffer/Fixer.php", 195 | "CodeSniffer/Report.php", 196 | "CodeSniffer/Reporting.php", 197 | "CodeSniffer/Sniff.php", 198 | "CodeSniffer/Tokens.php", 199 | "CodeSniffer/Reports/", 200 | "CodeSniffer/Tokenizers/", 201 | "CodeSniffer/DocGenerators/", 202 | "CodeSniffer/Standards/AbstractPatternSniff.php", 203 | "CodeSniffer/Standards/AbstractScopeSniff.php", 204 | "CodeSniffer/Standards/AbstractVariableSniff.php", 205 | "CodeSniffer/Standards/IncorrectPatternException.php", 206 | "CodeSniffer/Standards/Generic/Sniffs/", 207 | "CodeSniffer/Standards/MySource/Sniffs/", 208 | "CodeSniffer/Standards/PEAR/Sniffs/", 209 | "CodeSniffer/Standards/PSR1/Sniffs/", 210 | "CodeSniffer/Standards/PSR2/Sniffs/", 211 | "CodeSniffer/Standards/Squiz/Sniffs/", 212 | "CodeSniffer/Standards/Zend/Sniffs/" 213 | ] 214 | }, 215 | "notification-url": "https://packagist.org/downloads/", 216 | "license": [ 217 | "BSD-3-Clause" 218 | ], 219 | "authors": [ 220 | { 221 | "name": "Greg Sherwood", 222 | "role": "lead" 223 | } 224 | ], 225 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 226 | "homepage": "http://www.squizlabs.com/php-codesniffer", 227 | "keywords": [ 228 | "phpcs", 229 | "standards" 230 | ], 231 | "time": "2016-09-01 23:53:02" 232 | }, 233 | { 234 | "name": "symfony/config", 235 | "version": "v3.1.3", 236 | "source": { 237 | "type": "git", 238 | "url": "https://github.com/symfony/config.git", 239 | "reference": "a7630397b91be09cdd2fe57fd13612e258700598" 240 | }, 241 | "dist": { 242 | "type": "zip", 243 | "url": "https://api.github.com/repos/symfony/config/zipball/a7630397b91be09cdd2fe57fd13612e258700598", 244 | "reference": "a7630397b91be09cdd2fe57fd13612e258700598", 245 | "shasum": "" 246 | }, 247 | "require": { 248 | "php": ">=5.5.9", 249 | "symfony/filesystem": "~2.8|~3.0" 250 | }, 251 | "suggest": { 252 | "symfony/yaml": "To use the yaml reference dumper" 253 | }, 254 | "type": "library", 255 | "extra": { 256 | "branch-alias": { 257 | "dev-master": "3.1-dev" 258 | } 259 | }, 260 | "autoload": { 261 | "psr-4": { 262 | "Symfony\\Component\\Config\\": "" 263 | }, 264 | "exclude-from-classmap": [ 265 | "/Tests/" 266 | ] 267 | }, 268 | "notification-url": "https://packagist.org/downloads/", 269 | "license": [ 270 | "MIT" 271 | ], 272 | "authors": [ 273 | { 274 | "name": "Fabien Potencier", 275 | "email": "fabien@symfony.com" 276 | }, 277 | { 278 | "name": "Symfony Community", 279 | "homepage": "https://symfony.com/contributors" 280 | } 281 | ], 282 | "description": "Symfony Config Component", 283 | "homepage": "https://symfony.com", 284 | "time": "2016-07-26 08:04:17" 285 | }, 286 | { 287 | "name": "symfony/dependency-injection", 288 | "version": "v3.1.3", 289 | "source": { 290 | "type": "git", 291 | "url": "https://github.com/symfony/dependency-injection.git", 292 | "reference": "6abd4952d07042d11bbb8122f3b57469691acdb5" 293 | }, 294 | "dist": { 295 | "type": "zip", 296 | "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6abd4952d07042d11bbb8122f3b57469691acdb5", 297 | "reference": "6abd4952d07042d11bbb8122f3b57469691acdb5", 298 | "shasum": "" 299 | }, 300 | "require": { 301 | "php": ">=5.5.9" 302 | }, 303 | "require-dev": { 304 | "symfony/config": "~2.8|~3.0", 305 | "symfony/expression-language": "~2.8|~3.0", 306 | "symfony/yaml": "~2.8.7|~3.0.7|~3.1.1|~3.2" 307 | }, 308 | "suggest": { 309 | "symfony/config": "", 310 | "symfony/expression-language": "For using expressions in service container configuration", 311 | "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", 312 | "symfony/yaml": "" 313 | }, 314 | "type": "library", 315 | "extra": { 316 | "branch-alias": { 317 | "dev-master": "3.1-dev" 318 | } 319 | }, 320 | "autoload": { 321 | "psr-4": { 322 | "Symfony\\Component\\DependencyInjection\\": "" 323 | }, 324 | "exclude-from-classmap": [ 325 | "/Tests/" 326 | ] 327 | }, 328 | "notification-url": "https://packagist.org/downloads/", 329 | "license": [ 330 | "MIT" 331 | ], 332 | "authors": [ 333 | { 334 | "name": "Fabien Potencier", 335 | "email": "fabien@symfony.com" 336 | }, 337 | { 338 | "name": "Symfony Community", 339 | "homepage": "https://symfony.com/contributors" 340 | } 341 | ], 342 | "description": "Symfony DependencyInjection Component", 343 | "homepage": "https://symfony.com", 344 | "time": "2016-07-28 11:13:48" 345 | }, 346 | { 347 | "name": "symfony/filesystem", 348 | "version": "v3.1.3", 349 | "source": { 350 | "type": "git", 351 | "url": "https://github.com/symfony/filesystem.git", 352 | "reference": "bb29adceb552d202b6416ede373529338136e84f" 353 | }, 354 | "dist": { 355 | "type": "zip", 356 | "url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f", 357 | "reference": "bb29adceb552d202b6416ede373529338136e84f", 358 | "shasum": "" 359 | }, 360 | "require": { 361 | "php": ">=5.5.9" 362 | }, 363 | "type": "library", 364 | "extra": { 365 | "branch-alias": { 366 | "dev-master": "3.1-dev" 367 | } 368 | }, 369 | "autoload": { 370 | "psr-4": { 371 | "Symfony\\Component\\Filesystem\\": "" 372 | }, 373 | "exclude-from-classmap": [ 374 | "/Tests/" 375 | ] 376 | }, 377 | "notification-url": "https://packagist.org/downloads/", 378 | "license": [ 379 | "MIT" 380 | ], 381 | "authors": [ 382 | { 383 | "name": "Fabien Potencier", 384 | "email": "fabien@symfony.com" 385 | }, 386 | { 387 | "name": "Symfony Community", 388 | "homepage": "https://symfony.com/contributors" 389 | } 390 | ], 391 | "description": "Symfony Filesystem Component", 392 | "homepage": "https://symfony.com", 393 | "time": "2016-07-20 05:44:26" 394 | }, 395 | { 396 | "name": "wp-coding-standards/wpcs", 397 | "version": "0.10.0", 398 | "source": { 399 | "type": "git", 400 | "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", 401 | "reference": "b39490465f6fd7375743a395019cd597e12119c9" 402 | }, 403 | "dist": { 404 | "type": "zip", 405 | "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/b39490465f6fd7375743a395019cd597e12119c9", 406 | "reference": "b39490465f6fd7375743a395019cd597e12119c9", 407 | "shasum": "" 408 | }, 409 | "require": { 410 | "squizlabs/php_codesniffer": "^2.6" 411 | }, 412 | "type": "library", 413 | "notification-url": "https://packagist.org/downloads/", 414 | "license": [ 415 | "MIT" 416 | ], 417 | "authors": [ 418 | { 419 | "name": "Contributors", 420 | "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" 421 | } 422 | ], 423 | "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", 424 | "keywords": [ 425 | "phpcs", 426 | "standards", 427 | "wordpress" 428 | ], 429 | "time": "2016-08-29 20:04:47" 430 | } 431 | ], 432 | "aliases": [], 433 | "minimum-stability": "stable", 434 | "stability-flags": { 435 | "wearerequired/wp-requirements-check": 20 436 | }, 437 | "prefer-stable": false, 438 | "prefer-lowest": false, 439 | "platform": { 440 | "php": ">=5.4" 441 | }, 442 | "platform-dev": [] 443 | } 444 | -------------------------------------------------------------------------------- /css/src/simple-user-adding.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple User Adding 3 | * https://required.ch 4 | * 5 | * Copyright (c) 2015 required+ 6 | * Licensed under the GPLv2+ license. 7 | */ 8 | 9 | #email { 10 | float: left; 11 | } 12 | 13 | #sua_email_note { 14 | float: left; 15 | margin-left: 10px; 16 | } 17 | 18 | #first_name, 19 | #last_name { 20 | width: 12em; 21 | } 22 | 23 | #first_name { 24 | margin-right: .5em; 25 | } 26 | 27 | #notification_msg { 28 | width: 25em; 29 | height: 120px; 30 | } 31 | 32 | .disabled { 33 | display: none; 34 | } 35 | -------------------------------------------------------------------------------- /grunt/aliases.yaml: -------------------------------------------------------------------------------- 1 | # Default task 2 | default: 3 | - 'checktextdomain' 4 | - 'replace:header' 5 | - 'replace:plugin' 6 | - 'jshint' 7 | - 'uglify' 8 | - 'concat' 9 | - 'sass' 10 | - 'postcss' 11 | - 'clean:js' 12 | 13 | # Build task 14 | build: 15 | - 'default' 16 | - 'clean' 17 | - 'copy:main' 18 | - 'compress' # Can comment this out for WordPress.org plugins 19 | 20 | # Prepare a WordPress.org release 21 | release:prepare: 22 | - 'build' 23 | - 'copy:svn' 24 | 25 | # Deploy out a WordPress.org release 26 | release:deploy: 27 | - 'wp_deploy' 28 | 29 | # WordPress.org release task 30 | release: 31 | - 'release:prepare' 32 | - 'release:deploy' 33 | -------------------------------------------------------------------------------- /grunt/checktextdomain.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | dist: { 3 | options: { 4 | text_domain: 'simple-user-adding', 5 | report_missing: true, 6 | correct_domain: true, 7 | keywords: [ 8 | '__:1,2d', 9 | '_e:1,2d', 10 | '_x:1,2c,3d', 11 | 'esc_html__:1,2d', 12 | 'esc_html_e:1,2d', 13 | 'esc_html_x:1,2c,3d', 14 | 'esc_attr__:1,2d', 15 | 'esc_attr_e:1,2d', 16 | 'esc_attr_x:1,2c,3d', 17 | '_ex:1,2c,3d', 18 | '_n:1,2,4d', 19 | '_nx:1,2,4c,5d', 20 | '_n_noop:1,2,3d', 21 | '_nx_noop:1,2,3c,4d' 22 | ] 23 | }, 24 | files: [ { 25 | src: [ '*.php', '**/*.php', '!node_modules/**', '!tests/**', '!release/**' ], 26 | expand: true 27 | } ] 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /grunt/clean.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | release: [ 3 | 'release/<%= package.version %>/', 4 | 'release/svn/' 5 | ], 6 | js: [ 7 | '!js/*.js', 8 | '!js/*.min.js', 9 | 'js/*.js.map', 10 | '!js/*.min.js.map', 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /grunt/compress.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | main: { 3 | options: { 4 | mode: 'zip', 5 | archive: './release/<%= package.name %>.<%= package.version %>.zip' 6 | }, 7 | expand: true, 8 | cwd: 'release/<%= package.version %>/', 9 | src: [ '**/*' ], 10 | dest: '<%= package.name %>/' 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /grunt/concat.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | options: { 3 | stripBanners: true, 4 | banner: '/*! <%= package.title %> - v<%= package.version %>\n' + 5 | ' * <%= package.homepage %>\n' + 6 | ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + 7 | ' * Licensed GPLv2+' + 8 | ' */\n', 9 | separator: ';\n' 10 | }, 11 | dist: { 12 | src: [ 13 | 'js/src/simple-user-adding.js' 14 | ], 15 | dest: 'js/simple-user-adding.js' 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /grunt/copy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | main: { 3 | src: [ 4 | '**', 5 | '!node_modules/**', 6 | '!release/**', 7 | '!assets/**', 8 | '!.git/**', 9 | '!.sass-cache/**', 10 | '!css/src/**', 11 | '!js/src/**', 12 | '!img/src/**', 13 | '!Gruntfile.*', 14 | '!grunt/**', 15 | '!package.json', 16 | '!.gitignore', 17 | '!.gitmodules', 18 | '!tests/**', 19 | '!bin/**', 20 | '!.travis.yml', 21 | '!phpunit.xml', 22 | '!composer.lock' 23 | ], 24 | dest: 'release/<%= package.version %>/' 25 | }, 26 | svn: { 27 | cwd: 'release/<%= package.version %>/', 28 | expand: true, 29 | src: '**', 30 | dest: 'release/svn/' 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /grunt/jshint.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | options: { 3 | curly: true, 4 | eqeqeq: true, 5 | immed: true, 6 | latedef: true, 7 | newcap: true, 8 | noarg: true, 9 | sub: true, 10 | undef: true, 11 | boss: true, 12 | eqnull: true, 13 | globals: { 14 | exports: true, 15 | module: false 16 | } 17 | }, 18 | all: [ 19 | 'js/src/**/*.js', 20 | 'js/test/**/*.js' 21 | ] 22 | }; 23 | -------------------------------------------------------------------------------- /grunt/phpunit.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | default: {} 3 | }; 4 | -------------------------------------------------------------------------------- /grunt/postcss.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | options: { 3 | // or 4 | map: { 5 | inline: false, // save all source maps as separate files... 6 | annotation: 'css/' // ...to the specified directory 7 | }, 8 | 9 | processors: [ 10 | require( 'autoprefixer' )( { 11 | browsers: [ 12 | 'last 2 versions', 13 | '> 5%', 14 | 'ie 9' 15 | ] 16 | } ), // add vendor prefixes 17 | require( 'cssnano' )() // minify the result 18 | ] 19 | }, 20 | dist: { 21 | src: 'css/simple-user-adding.css', 22 | dest: 'css/simple-user-adding.min.css' 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /grunt/replace.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | header: { 3 | src: [ '<%= package.name %>.php' ], 4 | overwrite: true, 5 | replacements: [ { 6 | from: /\* Version:(\s*?)[\w.-]+$/m, 7 | to: '* Version:$1<%= package.version %>' 8 | } ] 9 | }, 10 | plugin: { 11 | src: [ 'classes/plugin.php' ], 12 | overwrite: true, 13 | replacements: [ 14 | { 15 | from: /^(\s*?)const(\s+?)VERSION(\s*?)=(\s+?)'[^']+';/m, 16 | to: "$1const$2VERSION$3=$4'<%= package.version %>';" 17 | } 18 | ] 19 | }, 20 | composer: { 21 | src: [ 'composer.json' ], 22 | overwrite: true, 23 | replacements: [ // "version": "1.0.0", 24 | { 25 | from: /^(\s*?)"version":(\s*?)"[^"]+",/m, 26 | to: '$1"version":$2"<%= package.version %>",' 27 | } 28 | ] 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /grunt/sass.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | dist: { 3 | files: { 4 | 'css/simple-user-adding.css': 'css/src/simple-user-adding.scss' 5 | } 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /grunt/test.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | files: [ 'assets/js/test/**/*.js' ] 3 | }; 4 | -------------------------------------------------------------------------------- /grunt/uglify.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | all: { 3 | files: { 4 | 'js/simple-user-adding.min.js': [ 'js/simple-user-adding.js' ] 5 | }, 6 | options: { 7 | banner: '/*! <%= package.title %> - v<%= package.version %>\n' + 8 | ' * <%= package.homepage %>\n' + 9 | ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + 10 | ' * Licensed GPLv2+' + 11 | ' */\n', 12 | sourceMap: true, 13 | mangle: { 14 | except: [ 'jQuery' ] 15 | } 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /grunt/watch.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | options: { 3 | livereload: true 4 | }, 5 | 6 | config: { 7 | files: 'grunt/watch.js' 8 | }, 9 | 10 | sass: { 11 | files: [ 'css/src/*.scss' ], 12 | tasks: [ 'sass', 'postcss' ] 13 | }, 14 | 15 | php: { 16 | files: [ '**/*.php' ], 17 | tasks: [ 'checktextdomain', 'phpunit' ], 18 | options: { 19 | debounceDelay: 5000 20 | } 21 | }, 22 | 23 | scripts: { 24 | files: 'js/src/**/*.*', 25 | tasks: [ 'jshint', 'concat', 'uglify', 'clean:js' ] 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /grunt/wp_deploy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | dist: { 3 | options: { 4 | plugin_slug: 'simple-user-adding', 5 | svn_user: 'wearerequired', 6 | build_dir: 'release/svn/', 7 | assets_dir: 'assets/' 8 | } 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /init.php: -------------------------------------------------------------------------------- 1 | can_modify_email( true ); 28 | 29 | global $wp_version; 30 | 31 | if ( version_compare( $wp_version, '4.3', '<' ) ) { 32 | /** 33 | * Email login credentials to a newly-registered user. 34 | * 35 | * A new user registration notification is also sent to admin email. 36 | * 37 | * @since 2.0.0 38 | * 39 | * @param int $user_id User ID. 40 | * @param string $plaintext_pass Optional. The user's plaintext password. Default empty. 41 | */ 42 | function wp_new_user_notification( $user_id, $plaintext_pass = '' ) { 43 | $user = get_userdata( $user_id ); 44 | 45 | // The blogname option is escaped with esc_html on the way into the database in sanitize_option 46 | // we want to reverse this for the plain text arena of emails. 47 | $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 48 | 49 | if ( class_exists( 'WP_Digest_Queue' ) ) { 50 | WP_Digest_Queue::add( get_option( 'admin_email' ), 'new_user_notification', $user_id ); 51 | } else { 52 | $message = sprintf( __( 'New user registration on your site %s:', 'simple-user-adding' ), $blogname ) . "\r\n\r\n"; 53 | $message .= sprintf( __( 'Username: %s', 'simple-user-adding' ), $user->user_login ) . "\r\n\r\n"; 54 | $message .= sprintf( __( 'Email: %s', 'simple-user-adding' ), $user->user_email ) . "\r\n"; 55 | 56 | @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration', 'simple-user-adding' ), $blogname ), $message ); 57 | } 58 | 59 | if ( empty( $plaintext_pass ) ) { 60 | return; 61 | } 62 | 63 | $message = sprintf( __( 'Username: %s', 'simple-user-adding' ), $user->user_login ) . "\r\n"; 64 | $message .= sprintf( __( 'Password: %s', 'simple-user-adding' ), $plaintext_pass ) . "\r\n"; 65 | $message .= wp_login_url() . "\r\n"; 66 | 67 | $message = apply_filters( 'sua_notification_message', $message, $user ); 68 | 69 | wp_mail( $user->user_email, sprintf( __( '[%s] Your username and password', 'simple-user-adding' ), $blogname ), $message ); 70 | } 71 | } else { 72 | /** 73 | * Email login credentials to a newly-registered user. 74 | * 75 | * A new user registration notification is also sent to admin email. 76 | * 77 | * @since 2.0.0 78 | * @since 4.3.0 The `$plaintext_pass` parameter was changed to `$notify`. 79 | * 80 | * @param int $user_id User ID. 81 | * @param string $notify Optional. Type of notification that should happen. Accepts 'admin' or an empty 82 | * string (admin only), or 'both' (admin and user). The empty string value was kept 83 | * for backward-compatibility purposes with the renamed parameter. Default empty. 84 | */ 85 | function wp_new_user_notification( $user_id, $notify = '' ) { 86 | global $wpdb; 87 | $user = get_userdata( $user_id ); 88 | 89 | // The blogname option is escaped with esc_html on the way into the database in sanitize_option 90 | // we want to reverse this for the plain text arena of emails. 91 | $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 92 | 93 | if ( class_exists( 'WP_Digest_Queue' ) ) { 94 | WP_Digest_Queue::add( get_option( 'admin_email' ), 'new_user_notification', $user_id ); 95 | } else { 96 | $message = sprintf( __( 'New user registration on your site %s:', 'simple-user-adding' ), $blogname ) . "\r\n\r\n"; 97 | $message .= sprintf( __( 'Username: %s', 'simple-user-adding' ), $user->user_login ) . "\r\n\r\n"; 98 | $message .= sprintf( __( 'Email: %s', 'simple-user-adding' ), $user->user_email ) . "\r\n"; 99 | 100 | @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration', 'simple-user-adding' ), $blogname ), $message ); 101 | } 102 | 103 | if ( 'admin' === $notify || empty( $notify ) ) { 104 | return; 105 | } 106 | 107 | // Generate something random for a password reset key. 108 | $key = wp_generate_password( 20, false ); 109 | 110 | /** This action is documented in wp-login.php */ 111 | do_action( 'retrieve_password_key', $user->user_login, $key ); 112 | 113 | // Now insert the key, hashed, into the DB. 114 | if ( empty( $wp_hasher ) ) { 115 | require_once ABSPATH . WPINC . '/class-phpass.php'; 116 | $wp_hasher = new PasswordHash( 8, true ); 117 | } 118 | $hashed = time() . ':' . $wp_hasher->HashPassword( $key ); 119 | $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) ); 120 | 121 | $message = sprintf( __( 'Username: %s', 'simple-user-adding' ), $user->user_login ) . "\r\n\r\n"; 122 | $message .= __( 'To set your password, visit the following address:', 'simple-user-adding' ) . "\r\n\r\n"; 123 | $message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . ">\r\n\r\n"; 124 | 125 | $message .= wp_login_url() . "\r\n"; 126 | 127 | $message = apply_filters( 'sua_notification_message', $message, $user ); 128 | 129 | wp_mail( $user->user_email, sprintf( __( '[%s] Your username and password info', 'simple-user-adding' ), $blogname ), $message ); 130 | } 131 | } 132 | endif; 133 | -------------------------------------------------------------------------------- /js/src/simple-user-adding.js: -------------------------------------------------------------------------------- 1 | /* global jQuery, validateForm */ 2 | 3 | /** 4 | * Simple User Adding 5 | * 6 | * Copyright (c) 2015 required+ 7 | * Licensed under the GPLv2+ license. 8 | */ 9 | 10 | (function( $ ) { 11 | 'use strict'; 12 | $( function() { 13 | // Allow capitalizing a word, e.g. jOhN -> John 14 | String.prototype.capitalize = function() { 15 | return this.charAt( 0 ).toUpperCase() + this.slice( 1 ).toLowerCase(); 16 | }; 17 | 18 | var firstName, 19 | lastName, 20 | firstNameField = $( '#first_name' ), 21 | lastNameField = $( '#last_name' ), 22 | emailNote = $( '#sua_email_note' ), 23 | additionalFieldsShown = false; 24 | 25 | // Detect email input change 26 | $( "#email" ).on( 'change keyup paste', function() { 27 | var val = $( this ).val(), 28 | parts = val.substr( 0, val.indexOf( '@' ) ).split( '.' ); 29 | 30 | firstName = parts[ 0 ] ? parts[ 0 ] : ''; 31 | lastName = parts[ 1 ] ? parts[ 1 ] : ''; 32 | 33 | if ( lastName.indexOf( '+' ) >= 0 ) { 34 | lastName = lastName.substr( 0, lastName.indexOf( '+' ) ); 35 | } 36 | 37 | if ( 0 === firstName.length || firstNameField.val().length > 0 || lastNameField.val().length > 0 ) { 38 | emailNote.addClass( 'hidden' ); 39 | return; 40 | } 41 | 42 | $( '#sua_email_name' ).text( $.trim( firstName.capitalize() + ' ' + lastName.capitalize() ) ); 43 | emailNote.removeClass( 'hidden' ); 44 | } ); 45 | 46 | $( '#sua_email_note_insert' ).click( function( e ) { 47 | e.preventDefault(); 48 | 49 | if ( firstNameField.val().length === 0 ) { 50 | firstNameField.val( firstName.capitalize() ); 51 | } 52 | 53 | if ( lastNameField.val().length === 0 ) { 54 | lastNameField.val( lastName.capitalize() ); 55 | } 56 | 57 | if ( !additionalFieldsShown ) { 58 | $( '#sua_showmore' ).click(); 59 | } 60 | 61 | emailNote.addClass( 'hidden' ); 62 | } ); 63 | 64 | // Show/hide additional fields on request. 65 | $( '#sua_showmore' ).click( function( e ) { 66 | e.preventDefault(); 67 | additionalFieldsShown = !additionalFieldsShown; 68 | $( this ).val( additionalFieldsShown ? $( this ).attr( 'data-less' ) : $( this ).attr( 'data-more' ) ); 69 | 70 | $( '#sua_createuser .additional' ).toggleClass( 'hidden' ); 71 | 72 | if ( $( '[name=send_user_notification]' ).is( ':checked' ) ) { 73 | $( '.notification_msg_row' ).removeClass( 'hidden' ); 74 | } 75 | } ); 76 | 77 | $( '[name=send_user_notification]' ).change( function() { 78 | if ( $( this ).is( ':checked' ) ) { 79 | $( '.notification_msg_row' ).removeClass( 'disabled' ); 80 | } else { 81 | $( '.notification_msg_row' ).addClass( 'disabled' ); 82 | } 83 | } ); 84 | 85 | // JS form validation 86 | $( '#sua_createuser' ).submit( function( e ) { 87 | if ( !validateForm( this ) ) { 88 | e.preventDefault(); 89 | } 90 | } ); 91 | } ); 92 | }( jQuery )); 93 | -------------------------------------------------------------------------------- /lib/requirements-check.php: -------------------------------------------------------------------------------- 1 | $setting = $args[ $setting ]; 21 | } 22 | } 23 | } 24 | 25 | /** 26 | * @return bool True if the install passes the requirements, false otherwise. 27 | */ 28 | public function passes() { 29 | $passes = $this->php_passes() && $this->wp_passes(); 30 | if ( ! $passes ) { 31 | add_action( 'admin_notices', array( $this, 'deactivate' ) ); 32 | } 33 | 34 | return $passes; 35 | } 36 | 37 | /** 38 | * Deactivate the plugin again. 39 | */ 40 | public function deactivate() { 41 | if ( isset( $this->file ) ) { 42 | deactivate_plugins( plugin_basename( $this->file ) ); 43 | } 44 | } 45 | 46 | /** 47 | * @return bool True if the PHP version is high enough, false otherwise. 48 | */ 49 | private function php_passes() { 50 | if ( $this->__php_at_least( $this->php ) ) { 51 | return true; 52 | } else { 53 | add_action( 'admin_notices', array( $this, 'php_version_notice' ) ); 54 | 55 | return false; 56 | } 57 | } 58 | 59 | /** 60 | * Compare the current PHP version with the minimum required version. 61 | */ 62 | private static function __php_at_least( $min_version ) { 63 | return version_compare( phpversion(), $min_version, '>=' ); 64 | } 65 | 66 | /** 67 | * Show the PHP version notice. 68 | */ 69 | public function php_version_notice() { 70 | ?> 71 |
72 |

title ), $this->php ); ?>

73 |
74 | __wp_at_least( $this->wp ) ) { 82 | return true; 83 | } else { 84 | add_action( 'admin_notices', array( $this, 'wp_version_notice' ) ); 85 | 86 | return false; 87 | } 88 | } 89 | 90 | /** 91 | * Compare the current WordPress version with the minimum required version. 92 | */ 93 | private static function __wp_at_least( $min_version ) { 94 | return version_compare( get_bloginfo( 'version' ), $min_version, '>=' ); 95 | } 96 | 97 | /** 98 | * SHow the WordPress version notice. 99 | */ 100 | public function wp_version_notice() { 101 | ?> 102 |
103 |

title ), $this->wp ); ?>

104 |
105 | __FILE__ = $__FILE__; 31 | } 32 | 33 | return static::get_instance(); 34 | } 35 | 36 | /** 37 | * Returns the plugin's object instance. 38 | * 39 | * @return object The plugin object instance. 40 | */ 41 | public static function get_instance() { 42 | if ( isset( static::$instance ) ) { 43 | return static::$instance; 44 | } 45 | } 46 | 47 | /** 48 | * Add a WordPress hook (action/filter). 49 | * 50 | * @param mixed $hook,... first parameter is the name of the hook. 51 | * If second or third parameters are included, 52 | * they will be used as a priority (if an integer) 53 | * or as a class method callback name (if a string). 54 | * 55 | * @return bool Always returns true. 56 | */ 57 | public function hook( $hook ) { 58 | $priority = 10; 59 | $method = $this->sanitize_method( $hook ); 60 | $args = func_get_args(); 61 | unset( $args[0] ); 62 | foreach ( (array) $args as $arg ) { 63 | if ( is_int( $arg ) ) { 64 | $priority = $arg; 65 | } else { 66 | $method = $arg; 67 | } 68 | } 69 | 70 | return add_action( $hook, array( $this, $method ), $priority, 999 ); 71 | } 72 | 73 | /** 74 | * Sanitize a method name by replacing dots and dashes. 75 | * 76 | * @param string $method The method name to sanitize. 77 | * 78 | * @return string The sanitized method name. 79 | */ 80 | private function sanitize_method( $method ) { 81 | return str_replace( array( '.', '-' ), array( '_DOT_', '_DASH_' ), $method ); 82 | } 83 | 84 | /** 85 | * Includes a file (relative to the plugin base path) 86 | * and optionally globalizes a named array passed in 87 | * 88 | * @param string $file the file to include 89 | * @param array $data a named array of data to globalize 90 | */ 91 | protected function include_file( $file, $data = array() ) { 92 | extract( $data, EXTR_SKIP ); 93 | include( $this->get_path() . $file ); 94 | } 95 | 96 | /** 97 | * Returns the URL to the plugin directory 98 | * 99 | * @return string The URL to the plugin directory. 100 | */ 101 | public function get_url() { 102 | return plugin_dir_url( $this->__FILE__ ); 103 | } 104 | 105 | /** 106 | * Returns the path to the plugin directory. 107 | * 108 | * @return string The absolute path to the plugin directory. 109 | */ 110 | public function get_path() { 111 | return plugin_dir_path( $this->__FILE__ ); 112 | } 113 | 114 | /** 115 | * @param string $domain The plugin textdomain. 116 | * @param string $path Relative path to the `languages` folder. 117 | * 118 | * @return bool Returns true if the textdomain was loaded successfully, false otherwise. 119 | */ 120 | public function load_textdomain( $domain, $path ) { 121 | return load_plugin_textdomain( $domain, false, basename( dirname( $this->__FILE__ ) ) . $path ); 122 | } 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simple-user-adding", 3 | "title": "Simple User Adding", 4 | "description": "This plugin makes adding users to your WordPress site easier than ever before.", 5 | "version": "1.1.1", 6 | "homepage": "http://required.ch", 7 | "license": "GPL-2.0+", 8 | "author": { 9 | "name": "required+", 10 | "email": "support@required.ch", 11 | "url": "http://required.ch" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/wearerequired/simple-user-adding" 16 | }, 17 | "devDependencies": { 18 | "autoprefixer": "^6.0.0", 19 | "cssnano": "^3.0.0", 20 | "grunt": "~1.0.0", 21 | "grunt-checktextdomain": "~1.0.0", 22 | "grunt-contrib-clean": "^1.0.0", 23 | "grunt-contrib-concat": "~1.0.0", 24 | "grunt-contrib-compress": "~1.3.0", 25 | "grunt-contrib-copy": "~1.0.0", 26 | "grunt-contrib-jshint": "~1.0.0", 27 | "grunt-contrib-sass": "~1.0.0", 28 | "grunt-contrib-uglify": "^2.0.0", 29 | "grunt-contrib-watch": "^1.0.0", 30 | "grunt-phpunit": "~0.3.6", 31 | "grunt-postcss": "~0.8.0", 32 | "grunt-text-replace": "~0.4.0", 33 | "grunt-wp-deploy": "^1.0.0", 34 | "load-grunt-config": "~0.19.0", 35 | "time-grunt": "^1.0.0" 36 | }, 37 | "keywords": [] 38 | } 39 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | ./tests/ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /simple-user-adding.php: -------------------------------------------------------------------------------- 1 | 'Simple User Adding', 40 | 'php' => '5.3', 41 | 'wp' => '4.0', 42 | 'file' => __FILE__, 43 | ) ); 44 | 45 | if ( $requirements_check->passes() ) { 46 | include( dirname( __FILE__ ) . '/init.php' ); 47 | } 48 | 49 | unset( $requirements_check ); 50 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | assertTrue( true ); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /views/simple-user-adding-form.php: -------------------------------------------------------------------------------- 1 | 10 | * @license GPL-2.0+ 11 | * @link http://wp.required.ch/plugins/wp-widget-disable 12 | * @copyright 2015 required gmbh 13 | */ 14 | 15 | // Load up the passed data, else set to a default. 16 | $creating = isset( $_POST['createuser'] ); 17 | $new_user_send_notification = ( $creating && ! isset( $_POST['send_user_notification'] ) ) ? false : true; 18 | ?> 19 | 20 |
21 |

22 | 23 | 24 |

25 | 26 |

27 | 28 | 29 | 'notice notice-error is-dismissible', 36 | 'text' => __( 'Required fields missing.', 'simple-user-adding' ) 37 | ); 38 | break; 39 | case 'enter_email': 40 | $message = array( 41 | 'class' => 'notice notice-error is-dismissible', 42 | 'text' => __( 'Please enter a valid email address.', 'simple-user-adding' ) 43 | ); 44 | break; 45 | case 'user_email_exists': 46 | $message = array( 47 | 'class' => 'notice notice-error is-dismissible', 48 | 'text' => __( 'A user with this email address already exists.', 'simple-user-adding' ) 49 | ); 50 | break; 51 | case 'user_name_exists': 52 | $message = array( 53 | 'class' => 'notice notice-error is-dismissible', 54 | 'text' => __( 'A user with this username already exists.', 'simple-user-adding' ) 55 | ); 56 | break; 57 | case 'success': 58 | $message = array( 59 | 'class' => 'notice notice-success is-dismissible', 60 | 'text' => __( 'User successfully added.', 'simple-user-adding' ) 61 | ); 62 | break; 63 | case 'failure': 64 | $message = array( 65 | 'class' => 'notice notice-success is-dismissible', 66 | 'text' => __( 'There was an error adding the user. Please try again.', 'simple-user-adding' ) 67 | ); 68 | break; 69 | } 70 | } 71 | 72 | if ( ! empty( $message ) ) { 73 | echo '

' . esc_html( $message['text'] ) . '

'; 74 | } 75 | ?> 76 | 77 |
> 85 | 86 | 87 | 92 | 95 | 96 | 97 | 102 | 112 | 113 | 114 | 117 | 122 | 123 | 124 | 133 | 145 | 146 | 147 | 148 | 151 | 155 | 156 | 157 | 158 | 161 | 162 | $desc ) : ?> 163 | 164 | 167 | 170 | 171 | 172 | 173 | can_modify_email() ) : ?> 174 | 175 | 177 | 182 | 183 | 184 | 185 | 186 | 187 | 190 | 191 | 192 |
88 | 91 | 93 | 94 |
98 | 101 | 103 | 104 | 105 | 111 |
115 | 116 | 118 | 121 |
125 | 132 | 134 | /> 135 |
176 | 178 | 179 | 180 |

181 |
188 | 189 |
193 | 194 | 208 | 209 | 210 | 211 | 212 |
213 |
214 | --------------------------------------------------------------------------------