Snippets
Members-Only WordPress menus
by Dave on Feb.17, 2011, under Snippets
// register the new sidebar; this will hold a WP custom menu widget, give it a logical name
register_sidebars(1,array(‘name’ => ‘Members-Only Menu’,
‘before_widget’ => ‘<li id=”%1$s”>’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
)
);
// create function to display widget
// this menu is limited to user levels above “subscriber”
function widgetized() {
if (current_user_can(‘level_1′)){ ?>
<div id=”membermenu”>
<ul>
<?php thesis_default_widget(5); ?>
</ul>
</div>
<?php }
}
// i put the member-exclusive menu above the header, basically the first thing on the page
add_action(‘thesis_hook_before_header’, ‘widgetized’, ’1′);
/* user level key
Administrator: level_10
Editor: level_7
Author: level_2
Contributor: level_1
Subscriber: level_0 (you wouldn’t use this as you’d just use the is_user_logged_in() function)
*/
A different way to include stylesheets
by Dave on Oct.15, 2010, under Snippets, Thesis, WordPress
Here’s another way to link to stylesheets. It may be overkill for some things, but definitely useful for plugin developers. I’m thinking of sending the link to every plugin author who echoes 50 lines of CSS into my page headers. Thanks alot.
Why limit yourself to Thesis Hooks?
by Dave on Oct.15, 2010, under Snippets, Thesis, WordPress
Nuh uh. Not when you can start using WordPress Action Hooks to get more done!