How can I remove items from Wordpress's "Write" SubPanel?
November 14, 2007 7:40 AM Subscribe
I need to customise Wordpress's "Write" SubPanel to remove all of the advanced options.
I'm adapting Wordpress (2.3.1) into a multi-user app and need to hide all of the advanced writing options (discussion, password, slug and so on). I've tried a couple of extensions:
1: custom write panel which doesn't want to play with 2.3.x; and
2: clutter free which does exactly what I want but only on a user-by-user basis rather than hiding things from either everyone or an entire role
I've tried searching the source to see if there's anything obvious in the PHP that I can just comment out, but nothing. The Wordpress manual states there's an option in the admin screens, but that isn't there on my install, which is the latest version of Wordpress.
Hope me.
I'm adapting Wordpress (2.3.1) into a multi-user app and need to hide all of the advanced writing options (discussion, password, slug and so on). I've tried a couple of extensions:
1: custom write panel which doesn't want to play with 2.3.x; and
2: clutter free which does exactly what I want but only on a user-by-user basis rather than hiding things from either everyone or an entire role
I've tried searching the source to see if there's anything obvious in the PHP that I can just comment out, but nothing. The Wordpress manual states there's an option in the admin screens, but that isn't there on my install, which is the latest version of Wordpress.
Hope me.
Response by poster: Well, a role would be much more preferable, but if that's a major PITA, just hide them from everyone.
posted by TheDonF at 8:07 AM on November 14, 2007
posted by TheDonF at 8:07 AM on November 14, 2007
Best answer: A hacky solution (nicking some code from here):
In /wp-admin/edit-form-advanced.php, about line 74, you'll see some <fieldset>s that represent each of the sidebar boxes. If you add:
then you can wrap the fieldsets you want to hide thusly:
That basically works, although this approach of just removing the boxes outright throws up some JavaScript errors, and it might feck things up when you submit the form (although my few tests seem to indicate it's working okay).
A better approach might be to hide them in the browser using CSS, but just adding
posted by chrismear at 8:40 AM on November 14, 2007
In /wp-admin/edit-form-advanced.php, about line 74, you'll see some <fieldset>s that represent each of the sidebar boxes. If you add:
<?php $current_role = $wpdb->prefix . 'capabilities'; $current_user->role = array_keys($current_user->$current_role); $current_role = $current_user->role[0]; if ($current_role == 'author' || $current_role == 'editor') { $show_scary_boxes = false; } else { $show_scary_boxes = true; }?>
then you can wrap the fieldsets you want to hide thusly:
<?php if ($hide_scary_boxes) { ?><fieldset id="categorydiv" class="dbx-box">...</fieldset><?php } ?>
That basically works, although this approach of just removing the boxes outright throws up some JavaScript errors, and it might feck things up when you submit the form (although my few tests seem to indicate it's working okay).
A better approach might be to hide them in the browser using CSS, but just adding
display: none
seems to clash with the JavaScript that does the show/hide trickery when you click on the plus/minus buttons, and the boxes show up anyway. So you'll probably have to do something clever there. But this is a start, anyway.posted by chrismear at 8:40 AM on November 14, 2007
Okay, try this:
and then add the class 'scary-box' to the fieldsets you want to hide. Seems to work for me in Firefox.
posted by chrismear at 9:03 AM on November 14, 2007
<?php $current_role = $wpdb->prefix . 'capabilities'; $current_user->role = array_keys($current_user->$current_role); $current_role = $current_user->role[0]; if ($current_role == 'author' || $current_role == 'editor') {?><script type="text/javascript"> function hideScaryBoxes() { $$('.scary-box').each(function(b){b.hide();}); } addLoadEvent(hideScaryBoxes);</script><?php }?>
and then add the class 'scary-box' to the fieldsets you want to hide. Seems to work for me in Firefox.
posted by chrismear at 9:03 AM on November 14, 2007
Best answer: Alternatively, hide them with CSS by making the boxes height:0; and overflow:hidden (maybe even position:absolute; top:0; left:0; too, for good measure). That'll render them pretty invisdible, but still part of the DOM, so no JS errors, and no loadEvent stuff (in which the users may see the boxes flash up before the script executes).
posted by armoured-ant at 11:51 PM on November 14, 2007
posted by armoured-ant at 11:51 PM on November 14, 2007
Response by poster: Yay for UK Metazens (or whatever we're calling ourselves these days).
I went for amoured-ant's solution in the end by applying the CSS to the id attributes of the fieldsets. chrismear's link to the Wordpress site was also really useful for doing something else that needed fixing.
Beers all round at the next meetup!
posted by TheDonF at 8:32 AM on November 15, 2007
I went for amoured-ant's solution in the end by applying the CSS to the id attributes of the fieldsets. chrismear's link to the Wordpress site was also really useful for doing something else that needed fixing.
Beers all round at the next meetup!
posted by TheDonF at 8:32 AM on November 15, 2007
This thread is closed to new comments.
Which one are you trying to do?
posted by chrismear at 8:00 AM on November 14, 2007