WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Hiding unpublished widgets on frontend

[Resolved] Hiding unpublished widgets on frontend

  • There is a problem to prevent displaying ww-widgets with a post_status != ‘publish’ at the frontend. I’ve one ww-widget which is used on several hundred posts and pages and shall be temporarily hidden. I’ve looked through the code and made five modifications in file widget-wrangler.php and one modification in file common/widget_display.inc. This will prevent the display of not published ww-widgets at the frontend. All my tests were successful but there might be a better way to implement this. I would appreciate it if you could add this feature to the next version.

    widget-wrangler.php#135: added a second param $widget_status=false to function ww_get_single_widget()
    function ww_get_single_widget($post_id, $widget_status=false){

    widget-wrangler.php#137: inserted line
    $status = $widget_status ? ("post_status` = ‘”.$widget_status.”‘ AND”) : “”;
    `
    widget-wrangler.php#143: inserted line
    ". $status ."

    widget-wrangler.php#215: added a second param ‘publish’
    if($widget = ww_get_single_widget($widgets_array[$sidebar_slug][$i]['id'], 'publish'))

    widget-wrangler.php#244: added a second param ‘publish’
    return ww_theme_single_widget(ww_get_single_widget($id), 'publish');

    common/widget_display.inc#60: inserted line
    if (empty($widget)) { return ''; }

    https://wordpress.org/plugins/widget-wrangler/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jonathan Daggerhart

    @daggerhart

    Thanks for the thorough notes. I’ve incorporated this into the 1.5.3 release, with a few additions.

    The admin sortable widgets UI still shows drafts, with an indicator that a widget is a draft. My thinking was that you could place a draft widget throughout pages, and then publish it when ready.

    Commit for hiding unpublished widgets: https://plugins.trac.wordpress.org/changeset/873764

    Plugin Author Jonathan Daggerhart

    @daggerhart

    JochenT,

    Have you had a chance to test this yet? I found a small issue with saving draft widgets to posts, but I’m holding off on committing a new release in case you have further suggestions or issues.

    I’ve changed this back to -not resolved- until I commit the next fix.

    Please let me know if you have further feedback on this issue.

    Thanks,
    Jonathan

    Hi Jonathan,

    thank you very much for the quick updates. I think I’ve had found the same problem like you. When moving a draft widget at the post edit screen into a sidebar it is displayed, but not saved at that position. It will be repositioned at the ‘Disabled’ section again. Also when setting a published widget to draft it is removed from the selected sidebar to the ‘Disabled’ section.

    In this context I’ve found another problem which relates to posts which do not have status publish or draft. This may be the hard wired WP status ‘review’ or custom statuses. Widgets with such a status are not displayed. But I don’t know if anyone needs this currently. I do not.

    All other behaviour of this new feature works like a charme. And what I already wanted to say before: The display of the config forms of cloned widgets in the widget edit screen is absolutely cool. I haven’t thought that this would be possible.

    Plugin Author Jonathan Daggerhart

    @daggerhart

    This should be fixed and working well in 1.5.4. If someone else want’s more post statuses available than publish and draft, I’ll make adjustments at that time.

    Glad you like the real widget form in widget wrangler, I wasn’t really sure anyone was using cloned widgets at all, but thought that feature could help.

    Let me know if you run into other issues, or need additional features.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Hiding unpublished widgets on frontend’ is closed to new replies.