Members - Version 1.1.0

Version Description

Download this release

Release Info

Developer greenshady
Plugin Icon 128x128 Members
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.2 to 1.1.0

admin/class-meta-box-content-permissions.php CHANGED
@@ -54,10 +54,13 @@ final class Members_Meta_Box_Content_Permissions {
54
  */
55
  public function load() {
56
 
 
57
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
58
 
 
59
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
60
 
 
61
  add_action( 'save_post', array( $this, 'update' ), 10, 2 );
62
  }
63
 
@@ -119,7 +122,11 @@ final class Members_Meta_Box_Content_Permissions {
119
  if ( empty( $roles ) )
120
  $roles = members_convert_old_post_meta( $post->ID );
121
 
122
- wp_nonce_field( 'members_cp_meta_nonce', 'members_cp_meta' ); ?>
 
 
 
 
123
 
124
  <p>
125
  <?php esc_html_e( "Limit access to this post's content to users of the selected roles.", 'members' ); ?>
@@ -149,8 +156,11 @@ final class Members_Meta_Box_Content_Permissions {
149
  <label for="members_access_error"><?php esc_html_e( 'Custom error messsage:', 'members' ); ?></label>
150
  <textarea class="widefat" id="members_access_error" name="members_access_error" rows="6"><?php echo esc_textarea( get_post_meta( $post->ID, '_members_access_error', true ) ); ?></textarea>
151
  <span class="howto"><?php _e( 'Message shown to users that do no have permission to view the post.', 'members' ); ?></span>
152
- </p>
153
- <?php }
 
 
 
154
 
155
  /**
156
  * Saves the post meta.
54
  */
55
  public function load() {
56
 
57
+ // Enqueue scripts/styles.
58
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
59
 
60
+ // Add custom meta boxes.
61
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
62
 
63
+ // Save metadata on post save.
64
  add_action( 'save_post', array( $this, 'update' ), 10, 2 );
65
  }
66
 
122
  if ( empty( $roles ) )
123
  $roles = members_convert_old_post_meta( $post->ID );
124
 
125
+ // Nonce field to validate on save.
126
+ wp_nonce_field( 'members_cp_meta_nonce', 'members_cp_meta' );
127
+
128
+ // Hook for firing at the top of the meta box.
129
+ do_action( 'members_cp_meta_box_before', $post ); ?>
130
 
131
  <p>
132
  <?php esc_html_e( "Limit access to this post's content to users of the selected roles.", 'members' ); ?>
156
  <label for="members_access_error"><?php esc_html_e( 'Custom error messsage:', 'members' ); ?></label>
157
  <textarea class="widefat" id="members_access_error" name="members_access_error" rows="6"><?php echo esc_textarea( get_post_meta( $post->ID, '_members_access_error', true ) ); ?></textarea>
158
  <span class="howto"><?php _e( 'Message shown to users that do no have permission to view the post.', 'members' ); ?></span>
159
+ </p><?php
160
+
161
+ // Hook that fires at the end of the meta box.
162
+ do_action( 'members_cp_meta_box_after', $post );
163
+ }
164
 
165
  /**
166
  * Saves the post meta.
admin/class-role-edit.php CHANGED
@@ -101,21 +101,30 @@ final class Members_Admin_Role_Edit {
101
  // Get all the capabilities.
102
  $this->capabilities = members_get_capabilities();
103
 
 
 
 
 
 
 
 
104
  // Is the role editable?
105
  $this->is_editable = members_is_role_editable( $this->role->name );
106
 
107
  // Check if the form has been submitted.
108
- if ( $this->is_editable && ( isset( $_POST['grant-caps'] ) || isset( $_POST['deny-caps'] ) || isset( $_POST['grant-new-caps'] ) || isset( $_POST['deny-new-caps'] ) ) ) {
 
 
 
109
 
 
110
  $grant_caps = ! empty( $_POST['grant-caps'] ) ? array_unique( $_POST['grant-caps'] ) : array();
111
  $deny_caps = ! empty( $_POST['deny-caps'] ) ? array_unique( $_POST['deny-caps'] ) : array();
112
 
 
113
  $grant_new_caps = ! empty( $_POST['grant-new-caps'] ) ? array_unique( $_POST['grant-new-caps'] ) : array();
114
  $deny_new_caps = ! empty( $_POST['deny-new-caps'] ) ? array_unique( $_POST['deny-new-caps'] ) : array();
115
 
116
- // Verify the nonce.
117
- check_admin_referer( 'edit_role', 'members_edit_role_nonce' );
118
-
119
  // Set the $role_updated variable to true.
120
  $this->role_updated = true;
121
 
@@ -170,6 +179,9 @@ final class Members_Admin_Role_Edit {
170
  // Reset the Members role object.
171
  $this->members_role = members_get_role( $this->role->name );
172
 
 
 
 
173
  } // End check for form submission.
174
 
175
  // If successful update.
101
  // Get all the capabilities.
102
  $this->capabilities = members_get_capabilities();
103
 
104
+ // Add all caps from the cap groups.
105
+ foreach ( members_get_cap_groups() as $group )
106
+ $this->capabilities = array_merge( $this->capabilities, $group->caps );
107
+
108
+ // Make sure we have a unique array of caps.
109
+ $this->capabilities = array_unique( $this->capabilities );
110
+
111
  // Is the role editable?
112
  $this->is_editable = members_is_role_editable( $this->role->name );
113
 
114
  // Check if the form has been submitted.
115
+ if ( $this->is_editable && isset( $_POST['members_edit_role_nonce'] ) ) {
116
+
117
+ // Verify the nonce.
118
+ check_admin_referer( 'edit_role', 'members_edit_role_nonce' );
119
 
120
+ // Get the granted and denied caps.
121
  $grant_caps = ! empty( $_POST['grant-caps'] ) ? array_unique( $_POST['grant-caps'] ) : array();
122
  $deny_caps = ! empty( $_POST['deny-caps'] ) ? array_unique( $_POST['deny-caps'] ) : array();
123
 
124
+ // Get the new (custom) granted and denied caps.
125
  $grant_new_caps = ! empty( $_POST['grant-new-caps'] ) ? array_unique( $_POST['grant-new-caps'] ) : array();
126
  $deny_new_caps = ! empty( $_POST['deny-new-caps'] ) ? array_unique( $_POST['deny-new-caps'] ) : array();
127
 
 
 
 
128
  // Set the $role_updated variable to true.
129
  $this->role_updated = true;
130
 
179
  // Reset the Members role object.
180
  $this->members_role = members_get_role( $this->role->name );
181
 
182
+ // Action hook for when a role is updated.
183
+ do_action( 'members_role_updated', $this->role->name );
184
+
185
  } // End check for form submission.
186
 
187
  // If successful update.
admin/class-role-list-table.php CHANGED
@@ -176,6 +176,22 @@ class Members_Role_List_Table extends WP_List_Table {
176
  return get_column_headers( $this->screen );
177
  }
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  /**
180
  * The checkbox column callback.
181
  *
176
  return get_column_headers( $this->screen );
177
  }
178
 
179
+ /**
180
+ * Returns the default column output. By default, this will return an empty string. The
181
+ * purpose of the method is to provide plugin authors a hook to return content for
182
+ * custom columns: `members_manage_roles_column_{$column_name}`.
183
+ *
184
+ * @since 1.1.0
185
+ * @access protected
186
+ * @param string $role
187
+ * @param string $column_name
188
+ * @return string
189
+ */
190
+ protected function column_default( $role, $column_name ) {
191
+
192
+ return apply_filters( "members_manage_roles_column_{$column_name}", '', $role );
193
+ }
194
+
195
  /**
196
  * The checkbox column callback.
197
  *
admin/class-role-new.php CHANGED
@@ -136,7 +136,7 @@ final class Members_Admin_Role_New {
136
  }
137
 
138
  // Check if the current user can create roles and the form has been submitted.
139
- if ( current_user_can( 'create_roles' ) && ( isset( $_POST['role_name'] ) || isset( $_POST['role'] ) || isset( $_POST['grant-caps'] ) || isset( $_POST['deny-caps'] ) || isset( $_POST['grant-new-caps'] ) || isset( $_POST['deny-new-caps'] ) ) ) {
140
 
141
  // Verify the nonce.
142
  check_admin_referer( 'new_role', 'members_new_role_nonce' );
@@ -146,13 +146,23 @@ final class Members_Admin_Role_New {
146
  $new_caps = array();
147
  $is_duplicate = false;
148
 
 
 
 
 
 
 
 
 
 
 
149
  // Check if any capabilities were selected.
150
  if ( isset( $_POST['grant-caps'] ) || isset( $_POST['deny-caps'] ) ) {
151
 
152
  $grant_caps = ! empty( $_POST['grant-caps'] ) ? array_unique( $_POST['grant-caps'] ) : array();
153
  $deny_caps = ! empty( $_POST['deny-caps'] ) ? array_unique( $_POST['deny-caps'] ) : array();
154
 
155
- foreach ( members_get_capabilities() as $cap ) {
156
 
157
  if ( in_array( $cap, $grant_caps ) )
158
  $new_caps[ $cap ] = true;
@@ -165,8 +175,6 @@ final class Members_Admin_Role_New {
165
  $grant_new_caps = ! empty( $_POST['grant-new-caps'] ) ? array_unique( $_POST['grant-new-caps'] ) : array();
166
  $deny_new_caps = ! empty( $_POST['deny-new-caps'] ) ? array_unique( $_POST['deny-new-caps'] ) : array();
167
 
168
- $_m_caps = members_get_capabilities();
169
-
170
  foreach ( $grant_new_caps as $grant_new_cap ) {
171
 
172
  $_cap = members_sanitize_cap( $grant_new_cap );
@@ -185,7 +193,7 @@ final class Members_Admin_Role_New {
185
 
186
  // Sanitize the new role name/label. We just want to strip any tags here.
187
  if ( ! empty( $_POST['role_name'] ) )
188
- $this->role_name = strip_tags( $_POST['role_name'] );
189
 
190
  // Sanitize the new role, removing any unwanted characters.
191
  if ( ! empty( $_POST['role'] ) )
@@ -203,9 +211,12 @@ final class Members_Admin_Role_New {
203
 
204
  add_role( $this->role, $this->role_name, $new_caps );
205
 
 
 
 
206
  // If the current user can edit roles, redirect to edit role screen.
207
  if ( current_user_can( 'edit_roles' ) ) {
208
- wp_redirect( add_query_arg( 'message', 'role_added', members_get_edit_role_url( $this->role ) ) );
209
  exit;
210
  }
211
 
136
  }
137
 
138
  // Check if the current user can create roles and the form has been submitted.
139
+ if ( current_user_can( 'create_roles' ) && isset( $_POST['members_new_role_nonce'] ) ) {
140
 
141
  // Verify the nonce.
142
  check_admin_referer( 'new_role', 'members_new_role_nonce' );
146
  $new_caps = array();
147
  $is_duplicate = false;
148
 
149
+ // Get all the capabilities.
150
+ $_m_caps = members_get_capabilities();
151
+
152
+ // Add all caps from the cap groups.
153
+ foreach ( members_get_cap_groups() as $group )
154
+ $_m_caps = array_merge( $_m_caps, $group->caps );
155
+
156
+ // Make sure we have a unique array of caps.
157
+ $_m_caps = array_unique( $_m_caps );
158
+
159
  // Check if any capabilities were selected.
160
  if ( isset( $_POST['grant-caps'] ) || isset( $_POST['deny-caps'] ) ) {
161
 
162
  $grant_caps = ! empty( $_POST['grant-caps'] ) ? array_unique( $_POST['grant-caps'] ) : array();
163
  $deny_caps = ! empty( $_POST['deny-caps'] ) ? array_unique( $_POST['deny-caps'] ) : array();
164
 
165
+ foreach ( $_m_caps as $cap ) {
166
 
167
  if ( in_array( $cap, $grant_caps ) )
168
  $new_caps[ $cap ] = true;
175
  $grant_new_caps = ! empty( $_POST['grant-new-caps'] ) ? array_unique( $_POST['grant-new-caps'] ) : array();
176
  $deny_new_caps = ! empty( $_POST['deny-new-caps'] ) ? array_unique( $_POST['deny-new-caps'] ) : array();
177
 
 
 
178
  foreach ( $grant_new_caps as $grant_new_cap ) {
179
 
180
  $_cap = members_sanitize_cap( $grant_new_cap );
193
 
194
  // Sanitize the new role name/label. We just want to strip any tags here.
195
  if ( ! empty( $_POST['role_name'] ) )
196
+ $this->role_name = wp_strip_all_tags( $_POST['role_name'] );
197
 
198
  // Sanitize the new role, removing any unwanted characters.
199
  if ( ! empty( $_POST['role'] ) )
211
 
212
  add_role( $this->role, $this->role_name, $new_caps );
213
 
214
+ // Action hook for when a role is added.
215
+ do_action( 'members_role_added', $this->role );
216
+
217
  // If the current user can edit roles, redirect to edit role screen.
218
  if ( current_user_can( 'edit_roles' ) ) {
219
+ wp_redirect( esc_url_raw( add_query_arg( 'message', 'role_added', members_get_edit_role_url( $this->role ) ) ) );
220
  exit;
221
  }
222
 
admin/functions-admin.php CHANGED
@@ -110,6 +110,9 @@ function members_delete_role( $role ) {
110
 
111
  // Remove the role.
112
  remove_role( $role );
 
 
 
113
  }
114
 
115
  /**
110
 
111
  // Remove the role.
112
  remove_role( $role );
113
+
114
+ // Remove the role from the role factory.
115
+ members_role_factory()->remove_role( $role );
116
  }
117
 
118
  /**
admin/functions-cap-groups.php CHANGED
@@ -208,6 +208,37 @@ function members_register_cap_groups() {
208
 
209
  // Hook for registering cap groups. Plugins should always register on this hook.
210
  do_action( 'members_register_cap_groups' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  }
212
 
213
  /**
208
 
209
  // Hook for registering cap groups. Plugins should always register on this hook.
210
  do_action( 'members_register_cap_groups' );
211
+
212
+ // Check if the `all` group is registered.
213
+ if ( members_cap_group_exists( 'all' ) ) {
214
+
215
+ // Set up an empty caps array and get the `all` group object.
216
+ $caps = array();
217
+ $_group = members_get_cap_group( 'all' );
218
+
219
+ // Get the caps from every registered group.
220
+ foreach ( members_get_cap_groups() as $group )
221
+ $caps = array_merge( $caps, $group->caps );
222
+
223
+ // Sort the caps alphabetically.
224
+ asort( $caps );
225
+
226
+ // Assign all caps to the `all` group.
227
+ $_group->caps = array_unique( $caps );
228
+ }
229
+
230
+ // Check if the `custom` group is registered and there's possibly other non-default groups.
231
+ if ( has_action( 'members_register_cap_groups' ) && members_cap_group_exists( 'custom' ) ) {
232
+
233
+ // Get the custom group object.
234
+ $custom = members_cap_group_factory()->groups[ 'custom' ];
235
+
236
+ // Unset the custom group object.
237
+ unset( members_cap_group_factory()->groups[ 'custom' ] );
238
+
239
+ // Move the custom group object to the end.
240
+ members_cap_group_factory()->groups[ 'custom' ] = $custom;
241
+ }
242
  }
243
 
244
  /**
changelog.md CHANGED
@@ -1,5 +1,37 @@
1
  # Change Log
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## [1.0.2] - 2015-09-15
4
 
5
  ### Fixed
1
  # Change Log
2
 
3
+ ## [1.1.0] - 2015-10-12
4
+
5
+ ### Added
6
+
7
+ * `Text Domain` plugin header added.
8
+ * `Domain Path` plugin header added.
9
+ * `members_role_updated` action hook for when a role is edited/updated.
10
+ * `members_role_added` action hook for when a new role is created.
11
+ * `members_manage_roles_column_{$column_name}` filter hook for handling the output of custom manage roles screen columns.
12
+ * `members_cp_meta_box_before` action hook for hooking in before the Content Permissions meta box.
13
+ * `members_cp_meta_box_after` action hook for hooking in after the Content Permissions meta box.
14
+ * Added the `Members_Role_Factory::remove_role()` method to remove a stored role.
15
+
16
+ ### Changed
17
+
18
+ * Edit/New role forms just check the nonce instead of checking for form fields + nonce to see if the form was submitted (fields can be legitimately empty).
19
+
20
+ ### Fixed
21
+
22
+ * Correct "undefined index" notices with widgets.
23
+ * Make sure custom caps (post types, taxonomies, etc.) that aren't stored get saved when editing a role.
24
+ * Make sure the "All" capability group actually lists all caps from all groups.
25
+ * Use the `$user` variable instead of `$author` variable in `members_list_users()`.
26
+ * "Custom" cap group should always be added last.
27
+ * Make sure roles edited with no caps get processed. Previously, we bailed if no caps were set.
28
+ * Remove deleted roles from the manage roles screen list without having to refresh the page.
29
+
30
+ ### Security
31
+
32
+ * Use `wp_strip_all_tags()` over `strip_tags()` for sanitizing the role name.
33
+ * Use `esc_url_raw()` to escape the redirect URL after creating a new role.
34
+
35
  ## [1.0.2] - 2015-09-15
36
 
37
  ### Fixed
inc/class-role-factory.php CHANGED
@@ -105,6 +105,20 @@ final class Members_Role_Factory {
105
  return isset( $this->roles[ $role ] ) ? $this->roles[ $role ] : false;
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /**
109
  * Returns an array of role objects.
110
  *
105
  return isset( $this->roles[ $role ] ) ? $this->roles[ $role ] : false;
106
  }
107
 
108
+ /**
109
+ * Removes a role object (doesn't remove from DB).
110
+ *
111
+ * @since 1.1.0
112
+ * @access public
113
+ * @param string $role
114
+ * @return void
115
+ */
116
+ public function remove_role( $role ) {
117
+
118
+ if ( isset( $this->roles[ $role ] ) )
119
+ unset( $this->roles[ $role ] );
120
+ }
121
+
122
  /**
123
  * Returns an array of role objects.
124
  *
inc/class-widget-login.php CHANGED
@@ -18,6 +18,15 @@
18
  */
19
  class Members_Widget_Login extends WP_Widget {
20
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Set up the widget's unique name, ID, class, description, and other options.
23
  *
@@ -42,6 +51,26 @@ class Members_Widget_Login extends WP_Widget {
42
 
43
  // Create the widget.
44
  parent::__construct( 'members-widget-login', esc_attr__( 'Members: Login Form', 'members' ), $widget_options, $control_options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /**
@@ -56,6 +85,8 @@ class Members_Widget_Login extends WP_Widget {
56
  function widget( $sidebar, $instance ) {
57
  global $user_identity, $user_ID;
58
 
 
 
59
  // Set up the arguments for wp_login_form().
60
  $args = array(
61
  'form_id' => ! empty( $instance['form_id'] ) ? esc_attr( $instance['form_id'] ) : 'loginform',
@@ -167,28 +198,8 @@ class Members_Widget_Login extends WP_Widget {
167
  */
168
  function form( $instance ) {
169
 
170
- // Set up the default form values. */
171
- $defaults = array(
172
- 'title' => esc_attr__( 'Log In', 'members' ),
173
- 'label_username' => esc_attr__( 'Username', 'members' ),
174
- 'label_password' => esc_attr__( 'Password', 'members' ),
175
- 'label_log_in' => esc_attr__( 'Log In', 'members' ),
176
- 'label_remember' => esc_attr__('Remember Me', 'members' ),
177
- 'form_id' => 'loginform',
178
- 'id_username' => 'user_login',
179
- 'id_password' => 'user_pass',
180
- 'id_remember' => 'rememberme',
181
- 'id_submit' => 'wp-submit',
182
- 'remember' => true,
183
- 'value_remember' => false,
184
- 'value_username' => '',
185
- 'show_avatar' => true,
186
- 'logged_out_text' => esc_html__( 'Please log into the site.', 'members' ),
187
- 'logged_in_text' => esc_html__( 'You are currently logged in.', 'members' )
188
- );
189
-
190
  // Merge the user-selected arguments with the defaults.
191
- $instance = wp_parse_args( (array) $instance, $defaults );
192
 
193
  $logged_in_text = format_to_edit( $instance['logged_in_text'] );
194
  $logged_out_text = format_to_edit( $instance['logged_out_text'] ); ?>
18
  */
19
  class Members_Widget_Login extends WP_Widget {
20
 
21
+ /**
22
+ * Default arguments for the widget settings.
23
+ *
24
+ * @since 1.0.3
25
+ * @access public
26
+ * @var array
27
+ */
28
+ public $defaults = array();
29
+
30
  /**
31
  * Set up the widget's unique name, ID, class, description, and other options.
32
  *
51
 
52
  // Create the widget.
53
  parent::__construct( 'members-widget-login', esc_attr__( 'Members: Login Form', 'members' ), $widget_options, $control_options );
54
+
55
+ // Set up the defaults.
56
+ $this->defaults = array(
57
+ 'title' => esc_attr__( 'Log In', 'members' ),
58
+ 'label_username' => esc_attr__( 'Username', 'members' ),
59
+ 'label_password' => esc_attr__( 'Password', 'members' ),
60
+ 'label_log_in' => esc_attr__( 'Log In', 'members' ),
61
+ 'label_remember' => esc_attr__('Remember Me', 'members' ),
62
+ 'form_id' => 'loginform',
63
+ 'id_username' => 'user_login',
64
+ 'id_password' => 'user_pass',
65
+ 'id_remember' => 'rememberme',
66
+ 'id_submit' => 'wp-submit',
67
+ 'remember' => true,
68
+ 'value_remember' => false,
69
+ 'value_username' => '',
70
+ 'show_avatar' => true,
71
+ 'logged_out_text' => esc_html__( 'Please log into the site.', 'members' ),
72
+ 'logged_in_text' => esc_html__( 'You are currently logged in.', 'members' )
73
+ );
74
  }
75
 
76
  /**
85
  function widget( $sidebar, $instance ) {
86
  global $user_identity, $user_ID;
87
 
88
+ $instance = wp_parse_args( $instance, $this->defaults );
89
+
90
  // Set up the arguments for wp_login_form().
91
  $args = array(
92
  'form_id' => ! empty( $instance['form_id'] ) ? esc_attr( $instance['form_id'] ) : 'loginform',
198
  */
199
  function form( $instance ) {
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  // Merge the user-selected arguments with the defaults.
202
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
203
 
204
  $logged_in_text = format_to_edit( $instance['logged_in_text'] );
205
  $logged_out_text = format_to_edit( $instance['logged_out_text'] ); ?>
inc/class-widget-users.php CHANGED
@@ -18,6 +18,15 @@
18
  */
19
  class Members_Widget_Users extends WP_Widget {
20
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Set up the widget's unique name, ID, class, description, and other options.
23
  *
@@ -42,6 +51,21 @@ class Members_Widget_Users extends WP_Widget {
42
 
43
  // Create the widget.
44
  parent::__construct( 'members-widget-users', esc_html__( 'Members: Users', 'members' ), $widget_options, $control_options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /**
@@ -55,6 +79,8 @@ class Members_Widget_Users extends WP_Widget {
55
  */
56
  function widget( $sidebar, $instance ) {
57
 
 
 
58
  // Set up the arguments for get_users().
59
  $args = array(
60
  'role' => $instance['role'],
@@ -150,23 +176,8 @@ class Members_Widget_Users extends WP_Widget {
150
  */
151
  function form( $instance ) {
152
 
153
- // Set up the default form values.
154
- $defaults = array(
155
- 'title' => esc_attr__( 'Users', 'members' ),
156
- 'order' => 'ASC',
157
- 'orderby' => 'login',
158
- 'role' => '',
159
- 'meta_key' => '',
160
- 'meta_value' => '',
161
- 'include' => '',
162
- 'exclude' => '',
163
- 'search' => '',
164
- 'offset' => '',
165
- 'number' => ''
166
- );
167
-
168
  // Merge the user-selected arguments with the defaults.
169
- $instance = wp_parse_args( (array) $instance, $defaults );
170
 
171
  $order = array(
172
  'ASC' => esc_attr__( 'Ascending', 'members' ),
18
  */
19
  class Members_Widget_Users extends WP_Widget {
20
 
21
+ /**
22
+ * Default arguments for the widget settings.
23
+ *
24
+ * @since 1.0.3
25
+ * @access public
26
+ * @var array
27
+ */
28
+ public $defaults = array();
29
+
30
  /**
31
  * Set up the widget's unique name, ID, class, description, and other options.
32
  *
51
 
52
  // Create the widget.
53
  parent::__construct( 'members-widget-users', esc_html__( 'Members: Users', 'members' ), $widget_options, $control_options );
54
+
55
+ // Set up the defaults.
56
+ $this->defaults = array(
57
+ 'title' => esc_attr__( 'Users', 'members' ),
58
+ 'order' => 'ASC',
59
+ 'orderby' => 'login',
60
+ 'role' => '',
61
+ 'meta_key' => '',
62
+ 'meta_value' => '',
63
+ 'include' => '',
64
+ 'exclude' => '',
65
+ 'search' => '',
66
+ 'offset' => '',
67
+ 'number' => ''
68
+ );
69
  }
70
 
71
  /**
79
  */
80
  function widget( $sidebar, $instance ) {
81
 
82
+ $instance = wp_parse_args( $instance, $this->defaults );
83
+
84
  // Set up the arguments for get_users().
85
  $args = array(
86
  'role' => $instance['role'],
176
  */
177
  function form( $instance ) {
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  // Merge the user-selected arguments with the defaults.
180
+ $instance = wp_parse_args( (array) $instance, $this->defaults );
181
 
182
  $order = array(
183
  'ASC' => esc_attr__( 'Ascending', 'members' ),
inc/template.php CHANGED
@@ -135,7 +135,7 @@ function members_list_users( $args = array() ) {
135
 
136
  foreach ( $users as $user ) {
137
 
138
- $url = get_author_posts_url( $author->ID, $author->user_nicename );
139
 
140
  $class = sanitize_html_class( "user-{$user->ID}" );
141
 
135
 
136
  foreach ( $users as $user ) {
137
 
138
+ $url = get_author_posts_url( $user->ID, $user->user_nicename );
139
 
140
  $class = sanitize_html_class( "user-{$user->ID}" );
141
 
members.php CHANGED
@@ -3,9 +3,11 @@
3
  * Plugin Name: Members
4
  * Plugin URI: http://themehybrid.com/plugins/members
5
  * Description: A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private.
6
- * Version: 1.0.2
7
  * Author: Justin Tadlock
8
  * Author URI: http://themehybrid.com
 
 
9
  *
10
  * The members plugin was created because the WordPress community is lacking a solid permissions
11
  * plugin that is both open source and works completely within the confines of the APIs in WordPress.
@@ -23,7 +25,7 @@
23
  * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  *
25
  * @package Members
26
- * @version 1.0.2
27
  * @author Justin Tadlock <justin@justintadlock.com>
28
  * @copyright Copyright (c) 2009 - 2015, Justin Tadlock
29
  * @link http://themehybrid.com/plugins/members
3
  * Plugin Name: Members
4
  * Plugin URI: http://themehybrid.com/plugins/members
5
  * Description: A user and role management plugin that puts you in full control of your site's permissions. This plugin allows you to edit your roles and their capabilities, clone existing roles, assign multiple roles per user, block post content, or even make your site completely private.
6
+ * Version: 1.1.0
7
  * Author: Justin Tadlock
8
  * Author URI: http://themehybrid.com
9
+ * Text Domain: members
10
+ * Domain Path: /languages
11
  *
12
  * The members plugin was created because the WordPress community is lacking a solid permissions
13
  * plugin that is both open source and works completely within the confines of the APIs in WordPress.
25
  * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  *
27
  * @package Members
28
+ * @version 1.1.0
29
  * @author Justin Tadlock <justin@justintadlock.com>
30
  * @copyright Copyright (c) 2009 - 2015, Justin Tadlock
31
  * @link http://themehybrid.com/plugins/members
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: greenshady
4
  Donate link: http://themehybrid.com/donate
5
  Tags: admin, role, roles, member, members, profile, shortcode, user, users, widget, widgets
6
  Requires at least: 4.3
7
- Stable tag: 1.0.2
8
 
9
  The most powerful user, role, and capability management plugin for WordPress.
10
 
4
  Donate link: http://themehybrid.com/donate
5
  Tags: admin, role, roles, member, members, profile, shortcode, user, users, widget, widgets
6
  Requires at least: 4.3
7
+ Stable tag: 1.1.0
8
 
9
  The most powerful user, role, and capability management plugin for WordPress.
10