WordPress Trick: Remove Dashboard Widgets
Want to remove some dashboard widgets programmatically? Perhaps to hide useless cruft from every role but the Administrator? Dump this in your themes functions.php: function remove_dashboard_widgets() { global $wp_meta_boxes; unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); } if (!current_user_can(‘manage_options’)) { add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’ ); } This removes all dashboard widgets, so you’ll probably want to [...]
WordPress Trick: Hide Admin Panels From Specific User Roles
When you’re building a WordPress website for a client, sometimes you’ll want to hide certain admin panels from specific user roles; do editors really need “custom fields”? Drop the following code into your functions.php file to hide the Custom Fields meta-box from editors. function hide_meta_boxes() { remove_meta_box(‘postcustom’,'post’,'normal’); remove_meta_box(‘postcustom’,'page’,'normal’); } if (!current_user_can(‘manage_options’)) { add_action(‘admin_init’,'hide_meta_boxes’); } The [...]
WordPress Trick: Google MP3 Player Shortcode
Here’s another WordPress shortcode which is quite useful. It piggybacks on Googles excellent Flash-based MP3 player (the one they use in Gmail and so on), makes it easy to embed playable MP3s in your posts. Syntax: . Dump this in your functions.php: function mp3player($attr) { $src = str_replace(“=”, “”, $attr[0]); return ”; } add_shortcode(‘mp3′, ‘mp3player’); [...]
WordPress Trick: Create A Google Viewer PDF Shortcode [Update]
Want your PDFs to view through Google Reader? Wrap it in a shortcode like this: . Drop the following in your functions.php: function pdflink($attr, $content) { return ”.$content.”; } add_shortcode(‘pdf’, ‘pdflink’); [Update]: Here’s an updated shortcode function which allows you to also embed PDFs using this syntax: . Note how it’s just a tad shorter, [...]
WordPress Trick: Output Content In Two Columns Separated By <!–more–> Tag [Updated]
Need to split up your WordPress content in two columns without too much of a hassle? How about if you could do that by simply inserting the <!–more–> to indicate where you want the split? Well that’s what you can do using this trick. Replace the_content(); in your theme with this code. That probably means [...]
Sliding Doors In WordPress
A default WordPress page menu is built like this: – which outputs a plain menu, <li><a href=” … “>Menu Item</a></li> and so on. If you want to use the sliding doors CSS technique, however, you need more markup. So do this: – which’ll output this a more CSS friendly markup: <li><a href=” … “><span>Menu Item</span></a></li>.
WordPress 3
Work has started on version 3 of WordPress, and while I’m looking forward to custom post types (so I can build “Add News”, “Add Employee”, “Add Video” sections), the big news is the merge with WordPress Multi User. Rumors are, it’ll be renamed WordPress Multi Site.
Image Symlinks [Updated: Bulk Insert]
Image Symlinks is born of a desire to speed up and simplify WordPress post images, while retaining quality. Very briefly, it works like this: Upload large source image Use Symlink-image-button to insert image into post Decide width and/or height of inserted image How’s that different from using the built-in WordPress image upload and insertion mechanism? [...]