Using widget options ‘outside’ the widget

@JonathonByrd’s answer is probably ‘best’ – certainly you should using get_option if at all possible, since there’s no guarantee the option name will stay the same between WordPress versions. Similarly – @JonathonByrd also relies on using a global variable which may be removed/renamed (though perhaps very unlikely). Unfortunately there are no public wrappers which we … Read more

How to load Widget javascript + css files only if used?

wp_print_scripts and wp_print_styles hooks are fired way before your widget function so that is way it’s not working. A solution to that would be to include the scripts in the footer using wp_print_footer_scripts hook, take a look at Jan’s answer to a similar question Or a much nicer solution take a look at Sorich’s answer … Read more

Can I create my own “Recent Posts” widget or customize the existing one?

It’s usually best to copy the existing one, name it something unique, and then add your own functionality. Copy the WP_Widget_Recent_Posts class from wp-includes/class-wp-widget-recent-posts.php into your functions.php (or, preferably, another file in your theme devoted just to widgets) and rename to something else, like My_Widget_Recent_Posts Add your functionality in there. Don’t forget to call register_widget(‘My_Widget_Recent_Posts’) … Read more

Give Editor Access To Sidebar

The edit_theme_options capability should allow the user to edit the sidebar as described on this page : http://codex.wordpress.org/Appearance_Widgets_SubPanel Code to add to functions.php $role = get_role(‘editor’); $role->add_cap(‘edit_theme_options’); Edit: This should work to prevent editor accessing themes or menus function custom_admin_menu() { $user = new WP_User(get_current_user_id()); if (!empty( $user->roles) && is_array($user->roles)) { foreach ($user->roles as $role) … Read more

How Can I Add the “Insert From URL” Tab to a Custom 3.5 Media Uploader?

I’ve been digging through the source code for a similar reason; I’d like to add the “Attachment Display Settings” to the default “select” frame. As far as I can tell, this can’t be done by passing parameters to wp.media(), as we would all like. wp.media currently has the two frames (“post” and “select”), and the … Read more

Loading scripts only if a particular shortcode or widget is present

You can use the function is_active_widget . E.g.: function check_widget() { if( is_active_widget( ”, ”, ‘search’ ) ) { // check if search widget is used wp_enqueue_script(‘my-script’); } } add_action( ‘init’, ‘check_widget’ ); To load the script in the page where the widget is loaded only, you will have to add the is_active_widget() code, in … Read more

How can I modify the WordPress default widget output?

To expand on Mark’s answer, there’s not much (generally) available in the way of filters in the default WordPress widgets (except for perhaps widget_text). But adding your own custom widget is easy – put this in your functions.php: require_once(“my_widget.php”); add_action(“widgets_init”, “my_custom_widgets_init”); function my_custom_widgets_init(){ register_widget(“My_Custom_Widget_Class”); } Then you simply want to copy the existing categories widget … Read more