Opened 11 years ago
Closed 10 years ago
#5307 closed defect (bug) (duplicate)
is_page() does not work on BP pages and class names are different
Reported by: | juggledad | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.9 |
Component: | Core | Keywords: | |
Cc: | juggledad@… |
Description
1) create a page in WP called 'member'
2) activate the theme twenty twelve
3) edit the 'style.css' and add
body.home-page, body.page {background-color: blue;}
4) edit content-page.php and add the following before line 11 (the <article id=…)
<?php echo 'is_page()='.is_page().'<br>'; ?>
5) view the home page, you will see the background is blue
6) view the page you will see the background is blue and you will see 'is_page()=1'
7) activate BuddyPress
8) go to dashboard->settings->BuddyPress->pages set the Members Directore to the page 'member'
9) view the home page - you will see the background is blue
10) view the 'member' page - you will see the background is no longer blue and and you will see 'is_page()= '
11) go to dashboard->settings->reading->Front page displays
- select ' A static page (select below)' and set Front Page as 'member' - hit save
12) 10) view the 'member' page - you will see the background is no longer blue and and you will see 'is_page()= '
BP is changing the classes passed on pages and not setting the is_page() when viewing the pages it uses. This can cause issues with themes.
This did not happen in version 1.7.1
Attachments (1)
Change History (26)
#4
@
11 years ago
Can confirm stuff like if ( is_page( 'members' ) )
isn't working in 1.9.1
I'm 96.73% sure it worked in BP 1.8 because I had functionality in my install which relied on the outcome of the condition. I noticed today this functionality no longer works which must be because of the is_page
check.
#5
follow-up:
↓ 8
@
11 years ago
@henrywright
theme compatibility is the issue and as far as I'm aware has never been able return a value via is_page().
If you have been using is_page() then are you sure you hadn't been overloading bp templates directly to the parent theme root e.g running my-theme/members/index.php should effectively disable the theme compat class and you are no longer operating in that mode where BP looks for the the_content() to directly inject bp output to.
In bp 1.7 if you run the bp-default theme and add is_page('members') to the members index template it will return true and in all versions past and future would continue to do so.
#6
@
11 years ago
I guess the point is that BuddyPress should be supporting ALL WordPress conditionals. If every plugin can change the way you would expect wordpress to normally work then chaos could result.
BuddyPress 1.7.2 declared theme independence…and it has a setting for Pages. If they are 'Pages' then the is_page() should work. If they are not 'Pages' then call them something else.
#7
@
11 years ago
@juggledad that is a given, I and more importantly the core devs understand the importance of this and are striving to bring BP into parity with WP behaviour as things move forward and indeed tickets addressing things like user registration usernames demonstrates this, and the task jjj is tackling in re-factoring to use re-write rules is a major step in this direction, but all this takes time, BP was built originally to serve a specific case and did things it's way, untangling that is a pretty complex task but it's getting there with every iteration.
#8
in reply to:
↑ 5
@
11 years ago
Replying to hnla:
In bp 1.7 if you run the bp-default theme and add is_page('members') to the members index template it will return true and in all versions past and future would continue to do so.
Got ya! That's exactly it. I decided to move away from bp-default when I upgraded to 1.9.1 this week ( call me a laggard :) ). That explains why I could use is_page
successfully in 1.8
#9
@
11 years ago
call me a laggard
You're a laggard! :)
With the additions to the template hierarchy for theme compat introduced in 1.8 there is almost no scenario I can think of where one would want to run template files directly in theme root thus disabling theme compat where new builds are concerned.
#12
@
11 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Hi r-a-y and hnla
I've given this a regression test and came across an issue. As Hugo confirms, with the patch in place, is_page
returns true. However, when I navigate to a page such as members/username/messages
, my header and footer area seem to be replaced with white space. See attached screen grab. As you can see that's my custom theme - I'm just about to test on a standard install...
Anybody else seeing the same?
Note: In the screenshot below, there should be a header above the grey bar which has the inbox, sent and compose links. There should also be a footer at the bottom of the page.
#13
@
11 years ago
It seems the reason for the white space is a check I have in header.php
if ( is_page( 'login' ) ) { // do something } else { // output header }
This seems to be returning true
when on the members/username/messages
page. Also seems to be returning true when on members/username/settings
#14
follow-up:
↓ 15
@
11 years ago
- Keywords reporter-feedback added
henry.wright - Are you saying that is_page( 'login' )
returns true on a user's "Messages" or "Settings" page? I tested your conditional in Twenty Twelve's header.php, but could not duplicate your problem. is_page( 'login' )
returns false for me.
I don't think your issue is related to the change in r7735 because your is_page() conditional is checking a non-BuddyPress page. There might be an issue with the way you have set up your conditional.
#15
in reply to:
↑ 14
@
11 years ago
Replying to r-a-y:
henry.wright - Are you saying that
is_page( 'login' )
returns true on a user's "Messages" or "Settings" page?
Yes. In fact, it is any BP component page - activity, settings, messages etc.
It doesn't matter which page I check for i.e. 'login', 'contact', 'hello' - they all return true
when on one of these BP component pages.
Non-BP component areas of the site are unaffected. So for example, it returns false
on the about me page example.com/about/
I'm sure the conditional is set up properly.
Could it be something like root profiles causing the problem? They're enabled.
#17
@
11 years ago
Could it be something like root profiles causing the problem? They're enabled.
That sounds about right. Thanks for mentioning this. Can you turn root profiles off temporarily to see if the problem disappears?
#18
@
11 years ago
r-a-y
Problem is gone with root profiles disabled! These root profiles do love to misbehave!
#19
follow-up:
↓ 20
@
11 years ago
Problem is gone with root profiles disabled! These root profiles do love to misbehave!
Thanks for testing! They do love to misbehave! Once we move over to rewrite rules, this should hopefully resolve itself.
One thing though, is this a big-enough problem that we need to fix in the interim (BP 1.9.2)?
Perhaps you can workaround this by checking if the current page is a BP page with the is_buddypress()
conditional and then doing checks for the login page?
#20
in reply to:
↑ 19
@
11 years ago
Replying to r-a-y:
One thing though, is this a big-enough problem that we need to fix in the interim (BP 1.9.2)?
No problem r-a-y, I can work around it until the move over to rewrite rules.
I wonder how many people will be using is_page
with root profiles? I doubt there will be many but it will cause issues for them so maybe it will be a good idea to make people aware of it?
#21
follow-up:
↓ 22
@
11 years ago
I wonder how many people will be using is_page with root profiles?
Extremely few I would have thought and those that might would probably simply drop in another solution.
I'm not sure I would be using is_page() as a conditional in this manner? Tending to wonder whether I would use it at all in BP terms, yes in other WP scenarios perhaps.
Also I'm wondering whether your use case isn't covered by the work done in 1.8 to further refine the template hierarchy in theme compat templates?
#22
in reply to:
↑ 21
@
11 years ago
Replying to hnla:
I'm not sure I would be using is_page() as a conditional in this manner? Tending to wonder whether I would use it at all in BP terms, yes in other WP scenarios perhaps.
I tend to use conditionals quite a lot throughout my themes, probably indicating that I need to break my templates into parts a little bit more than I already do. I use the Theme My Login plugin and use is_page
in my theme's header.php file to identify when a user is on what I call an entry page (register, login, reset password etc). If the current page is an entry page I don't output the header and footer navbars - so I'm just using is_page to remove the clutter from the page. Of course a better way of doing it would be to use template parts - which I'm thinking of doing going forward. Less conditionals will make everything easier to read too.
As far as I'm aware BP's theme compat layer never did set is_page(), tested quickly in 1.7 & 1.7.2 and is_page() returns false.
#5204 was added with a patch to address the body class issue.
#4954 May well address the is_page() part? but haven't looked at how WP tests for this condition, so guessing a bit.