WordPress.org

Ready to get started?Download WordPress

Forums

Nothing But Widgets (17 posts)

  1. mythusmage
    Member
    Posted 8 years ago #

    For the next big upgared of WordPress (whenever that is) how about replacing plug-ins entirely with widgets. Where one would usually put the plug-in script one would put a widget instead.

    In addition, instead of limiting widget insertion to sidebars, expand it to main index, footer, header, comments, archives, pop-up comments, link pages, about pages, my plan to conquer the world as soon as I've finished my high-school science finals page, and any other template a theme may use. A post rating widget for the main index and individual post template for example.

  2. Zirotti
    Member
    Posted 8 years ago #

    That would then require that all current plugins out there right now, be rewritten. Besides aesthetics, any other reasons for it?

  3. mythusmage
    Member
    Posted 8 years ago #

    Make it easier to install plug-in functionality. Besides, if everybody has widgets in their sidebar, plug-in scripts that must be installed in that sidebar for the plug-in to work are going to be pretty dang useless.

    Please remember that widgets over-ride plug-ins.

  4. Kafkaesqui

    Posted 8 years ago #

    A large percentage of plugins, having nothing to do with the sidebar (or displaying a new 'widget' on your blog in some way), would make for lousy widgets.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Making widgets work in the header/footer/etc is actually relatively easy, but more than a little pointless.

    As for the rest, not every plugin lends itself well to the drag and drop mechanism.

  6. ladydelaluna
    Member
    Posted 8 years ago #

    "Make it easier to install plug-in functionality."

    "As for the rest, not every plugin lends itself well to the drag and drop mechanism."

    Almost all plugins out there now (that IMO are worth having, anyway) are drag, drop, and activate simple. The ones that aren't don't typically require much configuring outside the WP admin anyway.
    ++++++++
    "A large percentage of plugins, having nothing to do with the sidebar (or displaying a new 'widget' on your blog in some way), would make for lousy widgets."

    Agreed!

  7. mythusmage
    Member
    Posted 8 years ago #

    "Making widgets work in the header/footer/etc is actually relatively easy, but more than a little pointless."

    How so?

  8. jennmiller
    Member
    Posted 8 years ago #

    I'd rather forget about widgets and keep plugins the way they are.

  9. mythusmage
    Member
    Posted 8 years ago #

    You get right down to it, widgets are a way of making the installation of code into a template easier. Instead of copy-paste you use the Widgets page in "Admin-Presentation" to put newly added plug-in code into the template you wish the function to appear.

    It's not for all plug-ins. Not all plug-ins have code that needs to be installed in a template. But for those plug-ins that do, it can be a great help.

    And, I must add, there are codes that do need to be installed in header, footer, or main index (for example) for a plug-in to work.

  10. Nebelmond
    Member
    Posted 8 years ago #

    Actualy, I think it should be done the other way around. Realize widgets as a plugin, that's where they belong, so that you can get them if you really want them, but they don't bloat a standard install.

  11. ladydelaluna
    Member
    Posted 8 years ago #

    Nebelmond said it!

    Widgets are great for people that need them, but not everyone who uses wordpress is on the same level of expertise.

    I've been hand-coding for over 10 years. Widgets actually kind of annoy me because I can't get into them the way I'd like. With plugins, I can modify them until they break and then fix them again.

    I think of widgets as nothing more than hand-holding... and I don't need my hand held, neither do many others who know more than I even do... so to make it "the standard" would be somewhat of an insult to a lot of people.

  12. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    mythusmage: Bear with me for a moment.

    Using widgets in a template has two basic parts to it:
    -In the functions.php, the "sidebars" are created using the register_sidebars() call. This essentially creates the places where the widgets are allowed to be. The drag and drop spaces on the widgets config page is the main visible result of this functionality.
    -In the rest of the template itself, wherever these widgets should actually be run/displayed, a call is made to the dynamic_sidebar() function. This actually pulls the data about what widgets should be in that sidebar and runs and displays them. It does this, usually, as an unordered list, however you can make that work however you like in the original register_sidebar() parameters.

    Ignore the "sidebar" name for a moment and realize what it's doing. It's a) creating places for you to drag and drop the widgets and b) displaying them when the relevant parts of the template are displayed.

    So if you want widgets in, say, the header, then you:
    -Create a new "sidebar" for it in functions.php with register_sidebar, and
    -Make a call to dynamic_sidebar in your header.php (or whatever your header's name is).

    Just that easy, really. Example code:

    Top of functions.php:

    if ( function_exists('register_sidebars') )
    {
    register_sidebar(array('name'=>'Sidebar'));
    register_sidebar(array(
    'name'=>'Header',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => "</div>n",
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => "</h2>n");
    }

    In your sidebar.php, it's basically the same as normal, like this:

    <ul>
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar("Sidebar") ); ?>
    </ul>

    And your header.php would have something in it like this:

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar("Header") ); ?>

    You'd have to mess with the CSS to get the widgets to live side by side instead of top to bottom, and you might need to change the before and after stuff in the functions.php above to make that work properly, but there's no built in limitation as to *where* the widgets live on the page. The register_sidebar doesn't create a "sidebar", it creates a dynamic chunk of widgets which get placed wherever the call to dynamic_sidebar is. That's how you could put them in the header/footer/whatever.

    I do think this would be a bit pointless though, because most things you put in the header/footer are not the types of things that cause something to display. The field of things you need to put there is limited.

    I disagree with ladydelaluna above though. I've been a programmer for 22 years now, and I like the widget concept. It's not really hand holding, except in the most simplistic sense. What it really is doing is taking the code out of the templates (where it can be lost by simply changing templates) and putting it into the database or plugins. If I'm using widgets and I change my template, my sidebars come right along with me into my new template. I don't have to re-edit my new template. If I upgrade my template to a newer version, all my hacks are normally lost. Not anymore, not if I'm able to keep them in widgets.

    I think that eliminating the need for template hacking is a good goal, in the long run. Template changes are easily lost and such. Ideally, you wouldn't need to hack the templates, you'd have your changes in separate places in a way that would apply to any template. Widgets are a sort of first stab at that by divorcing the sidebar content from the template itself.

  13. ladydelaluna
    Member
    Posted 8 years ago #

    I see your point, Otto - but then again, I'm not much of a theme-switching kind of person. If I do, then I want things so completely different that it's worth just putting them where I want them again. I've changed site designs and really prefer knowing exactly where and what my lines of code are doing when I FTP my files down to my editor.

    That said, I'll give the retort that "What's good for the goose isn't always good for the gander." :) I like it this way, others like it the other way. It's the same debate between WYSIWYG editors and hand-coding... been going on for a decade now. ;)

  14. jennmiller
    Member
    Posted 8 years ago #

    Forcing widget use over plugin use would penalize some of us who have been with WP for a very long time. Not every theme uses "sidebar.php" but current plugins work just fine. If widgets are optional, great, but if they become more than an "easy way" to use WP, I'll be out of the game :(

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    There's no reason to get rid of plugins entirely. Widgets rely on plugins, and would continue to do so even if they were integrated into WP itself.

    ladydelaluna: Well, if you *really* like to keep your hand-coded PHP, check out my ExecPHP widget: http://ottodestruct.com/blog/2006/04/09/fun-with-widgets/

    :)

  16. ladydelaluna
    Member
    Posted 8 years ago #

    i'll have to dig into that if and when i decide to dig deeper into widgets, otto - thanks for the link though - a good resource for others when they wind up having problems for sure!

    jennmiller also said what's on my mind about widgets... i'm used to the way things work without them, and i like it that way. :)

  17. mythusmage
    Member
    Posted 8 years ago #

    What are widgets really?. As far as I can see, a widget is simply a way to put plug-in associated code where it needs to go. This being done through a control panel that allows one to drag and drop the code to the appropriate location. And that's all it is.

    When you don't need to put code anywhere, or the plug-in does it for you when activated, then you don't need a widget for that plug-in.

Topic Closed

This topic has been closed to new replies.

About this Topic