WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#33467 closed defect (bug) (wontfix)

Widgets that display to non logged-in users only NOT editable in customizer

Reported by: lisaleague Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Customize Keywords:
Focuses: Cc:

Description

Widgets that will only display to non-logged in users are only editable in the admin, not through the customizer because they don't display (because you're obviously logged in).

These widgets ARE editable in the admin dashboard.

Change History (8)

#1 @swissspidy
4 years ago

  • Component changed from General to Customize

#2 @chriscct7
4 years ago

  • Version changed from 4.3 to 3.9

#3 @westonruter
4 years ago

  • Keywords reporter-feedback added

@lisaleague Thanks for the report. Do you have an example plugin with such a widget? I would think that the widget would still be editable in the Customizer, even if it wouldn't be displayed in the preview. Usually in this case the widget's control just receives a bit of transparency to indicate it is not active in the current view.

#4 @lisaleague
4 years ago

Hi @westonruter, I just put my text widget back up here - http://www.qpractice.com - you have to scroll to see it appear.

It does not display to my logged in members (subscribers), or me. It's on every non-logged in page, but not in the customizer anywhere https://www.evernote.com/l/AAmEt6AfvmZBB7CN9mrUZ-6FnDTyT52Bae8
The widget is sticky message, based on this - http://briangardner.com/genesis-sticky-message/

In general, I think the widgets in the customizer are hard to work with because you have to go to the page they're on. So that's extra clicks vs. having all in one place like the admin dashboard. The way menus are done is better because you can access them all at once.

#5 @westonruter
4 years ago

OK, so you're talking about an entire widget _area_ (sidebar) only being displayed to non-authenticated visitors? Do you have such an “Anonymous User” sidebar? I thought you were referring to one specific widget. This being the case, the reason why the sidebar is not being displayed is because the Customizer thinks that the sidebar doesn't belong on the current template (which it doesn't, because you are logged-in), and so it hides it from being displayed.

Does your theme template code have something like this:

if ( ! is_user_logged_in() ) {
    dynamic_sidebar( 'anonymous-visitors' );
}

If so, then you can quickly resolve your problem by changing this to:

if ( ! is_user_logged_in() || is_customize_preview() ) {
    dynamic_sidebar( 'anonymous-visitors' );
}

This will ensure the sidebar can be managed in the Customizer.

#6 follow-up: @lisaleague
4 years ago

  • Keywords reporter-feedback removed

Nope, I con't have a conditional like that - just

if ( ! is_user_logged_in() ) {

I have -

genesis_register_sidebar( array(
	'id'          => 'sticky-message',
	'name'        => __( 'Sticky Message', 'bg-mobile-first' ),
	'description' => __( 'This is the sticky message widget area.', 'bg-mobile-first' ),
) );

add_action( 'genesis_before', 'mobile_first_sticky_message' );
function mobile_first_sticky_message() {
	if ( ! is_user_logged_in() ) {
		genesis_widget_area( 'sticky-message', array(
			'before' => '<div class="sticky-message">',
			'after'  => '</div>',
		) );
	}
}

add_action( 'wp_enqueue_scripts', 'mobile_first_sticky_message_scripts' );
function mobile_first_sticky_message_scripts() {
	wp_enqueue_script( 'mobile-first-stickey-message', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-messages.js', array( 'jquery' ), '1.0.1' );
	
}

so would I just change to

if ( ! is_user_logged_in() || is_customize_preview() ) {

If so that's an easy fix. Sorry, I thought it was a customizer thing.

#7 in reply to: ↑ 6 @westonruter
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to lisaleague:

so would I just change to

if ( ! is_user_logged_in() || is_customize_preview() ) {

If so that's an easy fix. Sorry, I thought it was a customizer thing.

Exactly! That should be all you need.

#8 @lisaleague
4 years ago

Thanks @westonruter, now I will actually use the customizer more:)

Since I was a big opponent of menus in the customizer, I have to say that that's actually better than I thought. This gives me a possible idea for a fix for a missing link in the menu panel.

Note: See TracTickets for help on using tickets.