WordPress.org

Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#4313 closed enhancement (invalid)

Automatically activate Widgets

Reported by: kretzschmar Owned by:
Milestone: Priority: low
Severity: minor Version:
Component: Administration Keywords: 2nd-opinion
Focuses: Cc:
PR Number:

Description

In my theme dKret2 I heavily rely on widgets. Every Siebarblock is it's own Widget and can be dragged around (of course). If a user activates dKret for the first time he only get's a limited view of the possibilities because all sidebars (I register 6) are empty.
It would be good if I could automatically add some Widgets to my different sidebars.
I didn't even find a easy way of checking empty sidebars so I could display a hint to activate some widgets.

Change History (11)

#1 @zamoose
13 years ago

I'm not quite sure what you're asking here. Widgets are included by default in WP 2.2+ -- that was one of the big features added in 2.2.

#2 @foolswisdom
13 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Closing INVALID.

As zamoose describes sidebars can be pre-populated with widgets. Look how Default theme does it in WordPress 2.2 .

#3 @kretzschmar
13 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

I know that. I would like to pre-populate the sidebar with WIDGETS (own widgets wich I registered). So I need a way to add e.g. the dkret-search-widget to the sidebar-1 and
dkret-meta-widget to sidebar-2.
The way the default theme pre-populates the sidebar is the way I do right now.

I would also like to be able to have a function to only check, if a registered sidebar is populated. So if all sidebars aren't populated I can post a link to the Widget Page ('Please add some Widgets').

#4 @rob1n
13 years ago

I don't see a real need for this. Widgets are meant to be populated by the user, and the recommended (and, IMO, correct way) to use widgets to provide a standard, hardcoded sidebar in replacement of the dynamic sidebar. Does dynamic_sidebar() return false if there are no widgets for any sidebars?

#5 @rob1n
13 years ago

  • Keywords 2nd-opinion added
  • Milestone changed from 2.3 to 2.4
  • Priority changed from high to low
  • Severity changed from normal to minor

#6 follow-up: @kretzschmar
13 years ago

It does return false BUT I have 6 Sidebars and I would like to check if ALL of them aren't populated. If one is, the widgets are automatically displayed from that function.

I want to display some of the sidebars ONLY if there is a widget in it. E.G. a user doesn't want sidebars in his footer at all he just doesn't populate the footerbars. Have a look at my theme and you see what I mean with A LOT of diffrent sidebars. BUT if the user has NO widget active he has forgotten to populate them. I want to inform him about his mistake BEFORE he asks me what is wrong with my theme and why it looks diffrent as on my homepage.

http://diekretzschmars.de/dkret-theme/

dKret2

#7 @rob1n
13 years ago

so do each sidebar individually, with a if ( dynamic_sidebar(id) ) or whatever.

I'm not seeing the issue here -- and it sounds like a bit of documentation need.

#8 in reply to: ↑ 6 @Otto42
13 years ago

Replying to kretzschmar:

It does return false BUT I have 6 Sidebars and I would like to check if ALL of them aren't populated. If one is, the widgets are automatically displayed from that function.

function exist_active_widgets()
$sidebars_widgets = wp_get_sidebars_widgets();
foreach ($sidebars_widgets as $sidebar) 
  if (!empty($sidebar)) return true;
return false;
}
...
if (!exist_active_widgets()) 
echo "User has no active widgets in any sidebar.";

That help any?

#9 @kretzschmar
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Thanks Otto42. I could have done this myself. Blame on me!

#10 @rob1n
13 years ago

  • Milestone 2.4 deleted
  • Resolution fixed deleted
  • Status changed from closed to reopened

#11 @rob1n
13 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.