Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Patch for "Clean Admin Bar Removal" WordPress plugin to list all roles, not just the prefixed ones.

View clean-admin-bar-removal.patch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff -u clean-admin-bar-removal.orig/clean-admin-bar-removal.php clean-admin-bar-removal/clean-admin-bar-removal.php
--- clean-admin-bar-removal.orig/clean-admin-bar-removal.php 2012-01-09 16:30:32.000000000 -0300
+++ clean-admin-bar-removal/clean-admin-bar-removal.php 2012-01-12 15:14:22.848143592 -0300
@@ -26,6 +26,7 @@
// Show settings page and make changes on save
function clean_admin_bar_settings_page() {
+ global $wp_roles;
$clean_admin_bar_removal_default_roles = get_option('clean_admin_bar_removal_default_roles');
if (!$clean_admin_bar_removal_default_roles) $clean_admin_bar_removal_default_roles = array();
?>
@@ -60,19 +61,17 @@
<form name='clean_admin_bar_settings' id='clean_admin_bar_settings' method='post' action=''>
<p>Turn off the admin bar for <strong>existing users</strong> with the following user roles: </p>
<fieldset>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='administrator' /> Administrator</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='editor' /> Editor</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='author' /> Author</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='contributor' /> Contributor</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='subscriber' /> Subscriber</label></p>
+ <?php
+ foreach( $wp_roles->role_names as $role => $name ) { ?>
+ <p><label><input type='checkbox' name='clean_admin_bar_turn_off[]' value='<?php echo $role ?>' /> <?php echo $name ?></label></p>
+ <?php } ?>
</fieldset>
<p>Disable admin bar by default for <strong>new users</strong> with the following user roles: </p>
<fieldset>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='administrator' <?php if (in_array('administrator',$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?>/> Administrator</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='editor' <?php if (in_array('editor',$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?>/> Editor</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='author' <?php if (in_array('author',$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?>/> Author</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='contributor' <?php if (in_array('contributor',$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?>/> Contributor</label></p>
- <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='subscriber'<?php if (in_array('subscriber',$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?> /> Subscriber</label></p>
+ <?php
+ foreach( $wp_roles->role_names as $role => $name ) { ?>
+ <p><label><input type='checkbox' name='clean_admin_bar_turn_off_by_default[]' value='<?php echo $role ?>' <?php if (in_array($role,$clean_admin_bar_removal_default_roles)) echo ' checked="checked";' ?>/> <?php echo $name ?></label></p>
+ <?php } ?>
</fieldset>
<br />
<p> <input type="submit" id="submit" value="Save Changes" class="button-primary" /> </p> <br />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.