From 1bcd450f5aa5a67c9e3f801014f06cc1eec1bf13 Mon Sep 17 00:00:00 2001 From: Florian TIAR Date: Sat, 24 Sep 2016 16:39:42 +0200 Subject: [PATCH 01/50] Add suport of checkboxes roles on add user form --- controllers/checklist.php | 4 ++-- multiple-roles.php | 1 + views/checklist.html.php | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/checklist.php b/controllers/checklist.php index fabf181..9ed8cb3 100644 --- a/controllers/checklist.php +++ b/controllers/checklist.php @@ -27,7 +27,7 @@ public function __construct( $model ) { * @param string $hook The current admin screen. */ public function remove_dropdown( $hook ) { - if ( $hook != 'user-edit.php' ) + if ( $hook != 'user-edit.php' && $hook != 'user-new.php' ) return; wp_enqueue_script( 'md-multiple-roles', MDMR_URL . 'views/js/scripts.js', array( 'jquery' ) ); } @@ -46,7 +46,7 @@ public function output_checklist( $user ) { wp_nonce_field( 'update-md-multiple-roles', 'md_multiple_roles_nonce' ); $roles = $this->model->get_roles(); - $user_roles = $user->roles; + $user_roles = ( isset( $user->roles ) ) ? $user->roles : null; include( MDMR_PATH . 'views/checklist.html.php' ); diff --git a/multiple-roles.php b/multiple-roles.php index 27337e2..ad8eacc 100644 --- a/multiple-roles.php +++ b/multiple-roles.php @@ -25,6 +25,7 @@ function md_multiple_roles() { add_action( 'admin_enqueue_scripts', array( $checklist, 'remove_dropdown' ) ); add_action( 'show_user_profile', array( $checklist, 'output_checklist' ) ); add_action( 'edit_user_profile', array( $checklist, 'output_checklist' ) ); + add_action( 'user_new_form', array( $checklist, 'output_checklist' ) ); add_action( 'profile_update', array( $checklist, 'process_checklist' ) ); add_action( 'user_register', array( $checklist, 'process_checklist' ) ); diff --git a/views/checklist.html.php b/views/checklist.html.php index 4a7ad40..7248de3 100644 --- a/views/checklist.html.php +++ b/views/checklist.html.php @@ -17,7 +17,9 @@ type="checkbox" name="md_multiple_roles[]" value="" - + /> From b6563d9b3c818296bba9775a3ec4e6535c4c64cc Mon Sep 17 00:00:00 2001 From: Florian TIAR Date: Sat, 24 Sep 2016 16:43:37 +0200 Subject: [PATCH 02/50] Bump version to 1.2 --- multiple-roles.php | 4 ++-- readme.txt | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/multiple-roles.php b/multiple-roles.php index ad8eacc..82d257f 100644 --- a/multiple-roles.php +++ b/multiple-roles.php @@ -2,8 +2,8 @@ /* Plugin Name: Multiple Roles Description: Allow users to have multiple roles on one site. -Version: 1.0 -Author: Michael Dance +Version: 1.1 +Author: Michael Dance, Florian Tiar Author URI: http://mikedance.com */ diff --git a/readme.txt b/readme.txt index fb091ba..c7a8a3a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,9 +1,9 @@ === Multiple Roles === -Contributors: SeventhSteel +Contributors: SeventhSteel, mista-flo Tags: multiple roles, multiple roles per user, user roles, edit user roles, edit roles, more than one role, more than one role per user, more than one role for each user, many roles per user, unlimited roles Requires at least: 3.1 Tested up to: 4.2.1 -Stable tag: 1.0 +Stable tag: 1.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -58,5 +58,8 @@ Sure. The user will still be able to log in and out, but won't be able to access == Changelog == += 1.1 = +* Add support of role checkbox in new user form (admin). + = 1.0 = * Initial release. \ No newline at end of file From a713681c5c233535dbb19d10e02e8798e96f96cc Mon Sep 17 00:00:00 2001 From: Florian TIAR Date: Mon, 26 Sep 2016 13:57:52 +0200 Subject: [PATCH 03/50] Add gitignore for PHP storm file --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..180cb14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +### WordPress template +*.log +.htaccess + +# PHP Storm files +.idea \ No newline at end of file From 58d78143100df6e255de8c05d5d304b92c6bd96b Mon Sep 17 00:00:00 2001 From: Florian TIAR Date: Mon, 26 Sep 2016 14:10:06 +0200 Subject: [PATCH 04/50] Prepare i18n (add textdomain) --- controllers/column.php | 2 +- languages/multiple-roles.pot | 34 ++++++++++++++++++++++++++++++++++ multiple-roles.php | 5 +++++ views/checklist.html.php | 4 ++-- views/column.html.php | 2 +- 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 languages/multiple-roles.pot diff --git a/controllers/column.php b/controllers/column.php index 95c3ef1..832941b 100644 --- a/controllers/column.php +++ b/controllers/column.php @@ -29,7 +29,7 @@ public function __construct( $model ) { */ public function replace_column( $columns ) { unset( $columns['role'] ); - $columns['md_multiple_roles_column'] = 'Roles'; + $columns['md_multiple_roles_column'] = __( 'Roles', MDMR_TXTDOMAIN ); return $columns; } diff --git a/languages/multiple-roles.pot b/languages/multiple-roles.pot new file mode 100644 index 0000000..603884d --- /dev/null +++ b/languages/multiple-roles.pot @@ -0,0 +1,34 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Multiple Roles\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-26 14:09+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Florian TIAR \n" +"Language-Team: Florian TIAR \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;\n" +"X-Generator: Poedit 1.8.6\n" +"X-Poedit-KeywordsList: _e;__;_x;esc_html__;esc_html_e;_n;_ex;esc_html_x;" +"esc_attr_x;translate;esc_attr__;esc_attr_e\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-SearchPathExcluded-0: node_modules\n" +"X-Poedit-SearchPathExcluded-1: assets\n" +"X-Poedit-SearchPathExcluded-2: fields\n" + +#: controllers/column.php:32 views/checklist.html.php:11 +msgid "Roles" +msgstr "" + +#: views/checklist.html.php:8 +msgid "Permissions" +msgstr "" + +#: views/column.html.php:14 +msgid "None" +msgstr "" diff --git a/multiple-roles.php b/multiple-roles.php index 82d257f..4ee0206 100644 --- a/multiple-roles.php +++ b/multiple-roles.php @@ -5,10 +5,12 @@ Version: 1.1 Author: Michael Dance, Florian Tiar Author URI: http://mikedance.com +Text Domain: multiple-roles */ define( 'MDMR_PATH', plugin_dir_path( __FILE__ ) ); define( 'MDMR_URL', plugin_dir_url( __FILE__ ) ); +define( 'MDMR_TXTDOMAIN', 'multiple-roles' ); /** * Load files and add hooks to get things rolling. @@ -33,6 +35,9 @@ function md_multiple_roles() { add_filter( 'manage_users_columns', array( $column, 'replace_column' ), 11 ); add_filter( 'manage_users_custom_column', array( $column, 'output_column_content' ), 10, 3 ); + add_action( 'init', function() { + load_plugin_textdomain( MDMR_TXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); + } ); } md_multiple_roles(); \ No newline at end of file diff --git a/views/checklist.html.php b/views/checklist.html.php index 7248de3..889038e 100644 --- a/views/checklist.html.php +++ b/views/checklist.html.php @@ -5,10 +5,10 @@ * @var $roles array All WordPress roles in name => label pairs. * @var $user_roles array An array of role names belonging to the current user. */ -?>

Permissions

+?>

- +
Roles $label ) : ?>