WordPress Access Control - Version 4.0.13

Version Description

  • September 19, 2014 =

  • Adding a variety of bulk action tools

Download this release

Release Info

Developer brandon.wamboldt
Plugin Icon wp plugin WordPress Access Control
Version 4.0.13
Comparing to
See all releases

Code changes from version 4.0.12 to 4.0.13

Files changed (3) hide show
  1. readme.txt +5 -1
  2. templates/options.php +113 -0
  3. wordpress-access-control.php +51 -2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
5
  Requires at least: 3.0
6
  Tested up to: 4.0
7
- Stable tag: 4.0.12
8
 
9
  Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
10
 
@@ -64,6 +64,10 @@ Yes, this is a new feature in 3.1.3. Use the syntax [members role="administrator
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 4.0.12 - September 13, 2014 =
68
 
69
  * Fix PHP warning if there is no post
4
  Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
5
  Requires at least: 3.0
6
  Tested up to: 4.0
7
+ Stable tag: 4.0.13
8
 
9
  Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
10
 
64
 
65
  == Changelog ==
66
 
67
+ = 4.0.13 - September 19, 2014 =
68
+
69
+ * Adding a variety of bulk action tools
70
+
71
  = 4.0.12 - September 13, 2014 =
72
 
73
  * Fix PHP warning if there is no post
templates/options.php CHANGED
@@ -263,4 +263,117 @@ post state to Members Only, then set the Search Options to show restricted posts
263
 
264
  <p class="submit"><input type="submit" value="<?php _e('Save Changes', 'wpac') ?>" class="button-primary" id="submit" name="submit"></p>
265
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  </div>
263
 
264
  <p class="submit"><input type="submit" value="<?php _e('Save Changes', 'wpac') ?>" class="button-primary" id="submit" name="submit"></p>
265
  </form>
266
+
267
+ <h3 class="title"><?php _e('Bulk Actions', 'wpac') ?></h3>
268
+
269
+ <table class="form-table">
270
+ <tbody>
271
+ <tr>
272
+ <th scope="row">
273
+ <?php _e('Add Role By Existing Role', 'wpac') ?>
274
+ </th>
275
+ <td>
276
+ <form action="options-general.php?page=wpac-options" method="post">
277
+ <input type="hidden" value="wpac-options" name="options_page">
278
+ <input type="hidden" value="bulk_set_same" name="action">
279
+ <?php wp_nonce_field('wpac_options_save') ?>
280
+ Make all
281
+ <select name="bulk_post_type">
282
+ <?php
283
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
284
+
285
+ foreach ($wpac_enabled_post_types as $post_type) {
286
+ echo '<option value="' . $post_type . '">' . $all_post_types[$post_type]->labels->name . '</option>';
287
+ }
288
+ ?>
289
+ </select>
290
+ accessible by
291
+ <select name="bulk_grant_role">
292
+ <?php
293
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
294
+
295
+ foreach ($roles as $role => $label) {
296
+ echo '<option value="' . $role . '">' . $label . '</option>';
297
+ }
298
+ ?>
299
+ </select>
300
+ where
301
+ <select name="bulk_has_role">
302
+ <?php
303
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
304
+
305
+ foreach ($roles as $role => $label) {
306
+ echo '<option value="' . $role . '">' . $label . '</option>';
307
+ }
308
+ ?>
309
+ </select>
310
+ already has access
311
+
312
+ <br><br><input type="submit" value="<?php _e('Execute', 'wpac') ?>" class="button-secondary" id="submit" name="submit">
313
+ </form>
314
+ </td>
315
+ </tr>
316
+
317
+ <tr>
318
+ <th scope="row">
319
+ <?php _e('Add Role To Post Type', 'wpac') ?>
320
+ </th>
321
+ <td>
322
+ <form action="options-general.php?page=wpac-options" method="post">
323
+ <input type="hidden" value="wpac-options" name="options_page">
324
+ <input type="hidden" value="bulk_set_all_roles" name="action">
325
+ <?php wp_nonce_field('wpac_options_save') ?>
326
+ Make all
327
+ <select name="bulk_post_type">
328
+ <?php
329
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
330
+
331
+ foreach ($wpac_enabled_post_types as $post_type) {
332
+ echo '<option value="' . $post_type . '">' . $all_post_types[$post_type]->labels->name . '</option>';
333
+ }
334
+ ?>
335
+ </select>
336
+ accessible by
337
+ <select name="bulk_role">
338
+ <?php
339
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
340
+
341
+ foreach ($roles as $role => $label) {
342
+ echo '<option value="' . $role . '">' . $label . '</option>';
343
+ }
344
+ ?>
345
+ </select>
346
+
347
+ <br><br><input type="submit" value="<?php _e('Execute', 'wpac') ?>" class="button-secondary" id="submit" name="submit">
348
+ </form>
349
+ </td>
350
+ </tr>
351
+
352
+ <tr>
353
+ <th scope="row">
354
+ <?php _e('Set Post Type Accessibility', 'wpac') ?>
355
+ </th>
356
+ <td>
357
+ <form action="options-general.php?page=wpac-options" method="post">
358
+ <input type="hidden" value="wpac-options" name="options_page">
359
+ <input type="hidden" value="bulk_set_all" name="action">
360
+ <?php wp_nonce_field('wpac_options_save') ?>
361
+ Make all
362
+ <select name="bulk_post_type">
363
+ <?php
364
+ $roles = array_map('translate_user_role', $wp_roles->get_names());
365
+
366
+ foreach ($wpac_enabled_post_types as $post_type) {
367
+ echo '<option value="' . $post_type . '">' . $all_post_types[$post_type]->labels->name . '</option>';
368
+ }
369
+ ?>
370
+ </select>
371
+ only accessible to members
372
+
373
+ <br><br><input type="submit" value="<?php _e('Execute', 'wpac') ?>" class="button-secondary" id="submit" name="submit">
374
+ </form>
375
+ </td>
376
+ </tr>
377
+ </tbody>
378
+ </table>
379
  </div>
wordpress-access-control.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
5
  * Author: Brandon Wamboldt
6
  * Author URI: http://brandonwamboldt.ca/
7
- * Version: 4.0.12
8
  * Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
9
  */
10
 
@@ -63,7 +63,7 @@ class WordPressAccessControl
63
  public static function options_page()
64
  {
65
  // Save options?
66
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'update') {
67
  if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpac_options_save')) {
68
  $admin_error = __('Security check failed, please try again', 'wpac');
69
  } else {
@@ -173,6 +173,55 @@ class WordPressAccessControl
173
 
174
  $admin_message = '<strong>' . __('Settings Saved.') . '</strong>';
175
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
 
178
  include(dirname(__FILE__) . '/templates/options.php');
4
  * Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
5
  * Author: Brandon Wamboldt
6
  * Author URI: http://brandonwamboldt.ca/
7
+ * Version: 4.0.13
8
  * Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
9
  */
10
 
63
  public static function options_page()
64
  {
65
  // Save options?
66
+ if (isset($_POST['action']) && $_POST['action'] == 'update') {
67
  if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'wpac_options_save')) {
68
  $admin_error = __('Security check failed, please try again', 'wpac');
69
  } else {
173
 
174
  $admin_message = '<strong>' . __('Settings Saved.') . '</strong>';
175
  }
176
+ } elseif (isset($_POST['action']) && $_POST['action'] == 'bulk_set_all_roles') {
177
+ // Get all posts of the given post type
178
+ $posts = get_posts(array('post_type' => $_POST['bulk_post_type'], 'post_status' => 'any', 'posts_per_page' => -1));
179
+
180
+ foreach ($posts as $post) {
181
+ $restricted_to = maybe_unserialize(get_post_meta($post->ID, '_wpac_restricted_to', true));
182
+
183
+ if (!is_array($restricted_to)) {
184
+ $restricted_to = array();
185
+ }
186
+
187
+ $restricted_to[] = $_POST['bulk_role'];
188
+ $restricted_to = array_unique($restricted_to);
189
+
190
+ update_post_meta($post->ID, '_wpac_restricted_to', serialize($restricted_to));
191
+ }
192
+
193
+ $admin_message = '<strong>' . sprintf(__('Updated %d posts'), count($posts)) . '</strong>';
194
+ } elseif (isset($_POST['action']) && $_POST['action'] == 'bulk_set_same') {
195
+ // Get all posts of the given post type
196
+ $posts = get_posts(array('post_type' => $_POST['bulk_post_type'], 'post_status' => 'any', 'posts_per_page' => -1));
197
+ $count = 0;
198
+
199
+ foreach ($posts as $post) {
200
+ $restricted_to = maybe_unserialize(get_post_meta($post->ID, '_wpac_restricted_to', true));
201
+
202
+ if (!is_array($restricted_to)) {
203
+ continue;
204
+ } elseif (!in_array($_POST['bulk_has_role'], $restricted_to)) {
205
+ continue;
206
+ }
207
+
208
+ $restricted_to[] = $_POST['bulk_grant_role'];
209
+ $restricted_to = array_unique($restricted_to);
210
+
211
+ update_post_meta($post->ID, '_wpac_restricted_to', serialize($restricted_to));
212
+ $count++;
213
+ }
214
+
215
+ $admin_message = '<strong>' . sprintf(__('Updated %d posts'), $count) . '</strong>';
216
+ } elseif (isset($_POST['action']) && $_POST['action'] == 'bulk_set_all') {
217
+ // Get all posts of the given post type
218
+ $posts = get_posts(array('post_type' => $_POST['bulk_post_type'], 'post_status' => 'any', 'posts_per_page' => -1));
219
+
220
+ foreach ($posts as $post) {
221
+ update_post_meta($post->ID, '_wpac_is_members_only', 'true');
222
+ }
223
+
224
+ $admin_message = '<strong>' . sprintf(__('Updated %d posts'), count($posts)) . '</strong>';
225
  }
226
 
227
  include(dirname(__FILE__) . '/templates/options.php');