Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#18554 closed enhancement (wontfix)

Twenty Eleven body classes for singular does not check condition is_front_page()

Reported by: gabriel-reguly's profile Gabriel Reguly Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Themes Keywords: close
Focuses: Cc:

Description

Maybe this is by design, but I found odd that function twentyeleven_body_classes tests for is_home() but does not test for is_front_page().

As in:

if ( is_singular() && ! is_home() 

So I propose a fix for this:

if ( is_singular() && ! is_home() && ! is_front_page()

Please find the amended file attached.

Regards,
Gabriel

Attachments (1)

functions.php (20.2 KB) - added by Gabriel Reguly 13 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @kawauso
13 years ago

  • Keywords reporter-feedback added

Could you explain your reasoning for checking is_front_page() ?

Also for future, have a look at the following links on how to make a patch:

Mark Jaquith's Unix WordPress Toolbox

Peter Westwood's Windows WordPress Toolbox

#2 @SergeyBiryukov
13 years ago

  • Keywords has-patch removed

#3 in reply to: ↑ 1 @Gabriel Reguly
13 years ago

  • Keywords reporter-feedback removed

Replying to kawauso:

Could you explain your reasoning for checking is_front_page() ?

Because I do not want to have 'singular' added to body classes at my home page, which is a static page.

See, using only is_home() is not enough when the home page is a static page.

Thanks for the links regarding submitting a patch, if this ticket is found to be correct I'll submit a patch.


#4 @andrewryno
13 years ago

  • Keywords close added

Pretty sure this is by design.

http://codex.wordpress.org/Function_Reference/is_singular

It returns true for pages, single posts and attachments. A static front page is still a page, so it should be labeled as 'singular'.

Suggest closing as wontfix.

#5 @Gabriel Reguly
13 years ago

Please notice that is_singular() also returns true for the is_page_template() conditions (because they are pages) yet are checked for at the function and not labeled as 'singular'.

	if ( is_singular() && ! is_home() ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) 
		$classes[] = 'singular';

So thanks for the explanation, but, sorry, I am still wondering if is_home_page() should be added or not.

Maybe the theme developers could explain their intention.

I am fine with the current situation, I just have added a filter and redirected it to my own version ;-)

// fix body class
function my_theme_body_classes( $classes ) {
	remove_filter( 'body_class', 'twentyeleven_body_classes' );
// baseado em function twentyeleven_body_classes( $classes ) {
	if ( ! is_multi_author() ) {
		$classes[] = 'single-author';
	}
	if ( is_singular() && ! is_home() && ! is_front_page() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) ) 
		$classes[] = 'singular';
			
	return $classes;
}
add_filter( 'body_class', 'my_theme_body_classes', 5 );

Just suggested the enhancement as someone else could benefit from it.

#6 @andrewryno
13 years ago

Showcase is there because while it's a page, it is used to display posts. I'm honestly not sure why sidebar-page.php isn't marked as singular though.

I'd hazard a guess (without looking at the code right now) that twentyten uses the singular class to designate a page without a sidebar. Can't be sure without looking at the code though.

If that's true, then it should be left as is and just overwritten in a child theme if needed.

#7 @Gabriel Reguly
13 years ago

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

You guess is correct.

So I will close the ticket.

Thanks for your time.

#8 @dd32
13 years ago

  • Milestone Awaiting Review deleted

#9 @tomauger
13 years ago

@andrewryno I'm having trouble understanding the logic behind linking the 'singular' designation with the sidebar. It's perfectly reasonable to have a sidebar on a singular page.

And yet the default Twenty Eleven theme's css, the presence of the .singular class overrides the default #content's size and alignment. Setting the page to the page-sidebar.php template strangely removes the ".singular" class, replacing it with the various page-template classes instead. This has to be an oversight, though possibly not exactly the issue that Gabriel originally addressed.

Note: See TracTickets for help on using tickets.