twodinks.com

Snippets

Members-Only WordPress menus

by 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)
*/

Leave a Comment more...

A different way to include stylesheets

by 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.

Leave a Comment more...

Why limit yourself to Thesis Hooks?

by on Oct.15, 2010, under Snippets, Thesis, WordPress

Nuh uh. Not when you can start using WordPress Action Hooks to get more done!

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!