• Resolved FriendlyWP

    (@mmcginnis)


    Great plugin, thanks! I’m having an issue where the widget content is inserted without the widget-wrapping code (the div etc). So if I insert a Recent Posts widget in a page, it just dives straight into the heading and content.

    This is fine in many circumstances, but it would be awesome to be able to wrap the widget in normal widget code (divs, classes/IDs) so that I can do some special styles on it via my theme. Relying on my authors to go into the Text view and add the wrapping elements themselves isn’t going to work.

    Is there something I’m missing or is this a feature request? 🙂 Thanks again!

    http://wordpress.org/extend/plugins/amr-shortcode-any-widget/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author anmari

    (@anmari)

    hi mcginnis,

    The widget wrapping html is generated by the themes per sidebar of which there could be several with different html (eg if styled differently). That html and is not part of the widget code – the plugin calls the widget function, not the themes sidebars.

    If you want some html, it can added by yourself around the shortcode in the text editor. That way you can can influence the styling – be aware that one should not re-use ‘id’s though on same page – that will cause your html to be invalid.

    If you are trying to access a particular styling used in a sidebar, then hopefully your theme uses classes for styling!

    Thread Starter FriendlyWP

    (@mmcginnis)

    Hi anmari!

    I’m developing the site for some folks who don’t know any HTML, so making them to remember to wrap shortcodes in code will be a challenge. They barely understand shortcodes. 🙂

    I’m not a plugin person and don’t want to step on your toes but I’ve updated your code to add two attributes: ‘class’ and ‘wrap’, so that people using the shortcode can specify whether the widget should be wrapped (in a div) and so they can add an optional class name.

    It does change the shortcode a bit, as users now must specify the name of the widget explicitly via name=”widget name” every time. So instead of:

    [do_widget archives]

    they’d need to use:

    [do_widget name=archives] or [do_widget name="widget name"]

    The additional attributes would be added like this:

    [do_widget name="archives" wrap="yes" class="my-classname"]

    This would output:

    <div class="amr_widget my-classname">
    .... widget code as before ...
    </div>

    If they just wanted to wrap the widget, like so:

    {do_widget name="archives" wrap="yes"]

    it would output:

    <div class="amr_widget">
    .... widget code as before ...
    </div>

    Here’s the new code. You can see my changes by searching for comments beginning MKM:

    http://friendlywebconsulting.com/files/amr_shortcode_any_widget.zip

    Feel free to use or discard as you wish – just figured I’d share in case someone else was looking for the same kind of thing. Thanks so much for doing all the heavy lifting on this fantastic plugin!!!

    Michelle

    Mitchelle,

    Thanks for your solution above.
    Please, where should the class be placed? Should it be in the child’s theme CSS?

    Mitchelle, please, should the code in http://friendlywebconsulting.com/files/amr_shortcode_any_widget.zip
    be used to overwrite the original plugin php code?

    Thread Starter FriendlyWP

    (@mmcginnis)

    Hi stardrive, If you wanted to use it, yes, you’d use the file in that ZIP rather than the original plugin code. Then you’d be able to add the class etc per my notes above. Remember I made those changes a couple of versions ago, so the plugin won’t be up to date.

    Thank you, Michelle.
    I will consider adding the classes as per your notes above.

    Plugin Author anmari

    (@anmari)

    Hi Y’all

    see version 2.8 just uploaded. It has heaps more features and has taken on the concepts requested above. Of course I have to consider people already using the plugin and avoiding problems on plugin upgrade (compatibility will previous shortcode usage). And of course that everyone uses different themes etc so wrap html is different etc.

    It should pick up html (ie div or aside etc ) from the first sidebar in the theme. If not you can override. See changelog for more details.

    Note:
    It needs to convert the widgets sidebar from one id to another so wordpress will save the sidebar when themes change. It SHOULD do this automatically – tested on a few test sites.

    Please read the changelog and the settings page. If you see anything odd, please check whether it is intended function.
    If you have done due diligence and genuinely think there is a bug, I do wish to know. Please start a new thread for that.

    Have fun!

    Plugin Author anmari

    (@anmari)

    see 2.1

    Many Thanks, Anmari, for the update and the information.
    I will re-use the plugin and follow your steps above in the next couple of days and revert back as necessary.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Widgets not wrapped in divs / widget id stuff?’ is closed to new replies.