Insert custom content before widget title/after widget opening tag

You can use the dynamic_sidebar_params filter: add_filter( ‘dynamic_sidebar_params’, function( $params ) { // target a sidebar id: if( isset( $params[0][‘id’] ) && ‘sidebar-1’ === $params[0][‘id’] { // target a widget name: if( isset( $params[0][‘widget_name’] ) && ‘Text’ === $params[0][‘widget_name’] ) { // target a widget id: if( isset( $params[0][‘widget_id’] ) && ‘text-8’ === $params[0][‘widget_id’] ) … Read more

Tips for targeting widget dragable for WP Pointer on widgets.php page

Since the Feature Me widget in the Available Widgets list, is wrapped into something like this: <div id=”widget-5_feature_me-__i__”>…</div> I then wonder if the following would work (untested): ‘target’ => “div[id$=’_feature_me-__i__’]”, to target all div elements with id’s that end with _feature_me-__i__. I think there should only be a single match, at most, if this works.

Using jQuery in widget development

You can hook into the DOMNodeInserted event to find out when your widget has been added to the side bar. jQuery(document).on(‘DOMNodeInserted’, ‘.widget-top’, function () { alert(jQuery(‘.widget-title’, this).text()); }); The code above will alert to any newly added widget. Once you’re hooked into the newly created widget, you can traverse it to find your specific class … Read more

Custom Tag Cloud widget missing tags

What tags/terms/taxons do you get? The the_tags( $before = null, $sep = ‘, ‘, $after=”” ) function is a wrapper for get_the_tag_list( $before=””, $sep = ”, $after=””, $id = 0 ). This function applies the filter the_tags on the get_the_term_list( 0, ‘post_tag’, $before=””, $sep = ”, $after=”” ) (0 is the $id and $post_tag the … Read more

Creating a one click demo importer

I believe that if you are not going to do a massive sql insert (which I think is likely just as efficient) that you need to go ahead and utilize the plugin api and at the time of the button being pressed, create them. I think it’s pretty clear your choice is either to create … Read more

Theme Customizer – Choose where widget area appears, to let users organise widgets

You can move around sections in the customizer simply by accessing the datastructure and assign a different value to the panel. So supposing that your widget area, created in the usual way, is called wpse210938_area and you want to move it to the panel wpse210938_panel, you do this: add_action( ‘customize_register’, ‘wpse210938_move_widget_area’ ); function wpse210938_move_widget_area () … Read more

add_page_menu to make shortcut to widgets

You can add a link to the widgets.php like that: add_action( ‘admin_menu’, ‘f711_add_widgets_shortcut’, 999 ); function f711_add_widgets_shortcut() { add_menu_page( ‘Widgets’, ‘Widgets’, ‘publish_pages’, ‘widgets.php’, ”, ”, 61 ); } Be sure to check your permission settings, and you may also include another image. You can find the documentation about the function at The Codex.

dynamic_sidebar() returns false in admin section

Yes, you have to make sure to hook this function at some point after the sidebars are registered. It’s not quite explained, but implied in the codex that this function dynamic_sidebar( $index ) expects them to be registered and loaded as registered by the time it runs. Otherwise, it won’t have anything to match the … Read more