Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#4141 closed enhancement (fixed)

Wrapper Function for getting the currently displayed page url.

Reported by: chrisclayton Owned by: boonebgorges
Milestone: 1.6 Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

We need a template function for returning the current page url as get_permalink() doesn't work with buddypress generated pages.

See here for history: http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/current-url/

Attachments (1)

bp_get_permalink_function.patch (1.1 KB) - added by chrisclayton 10 years ago.
Not finished, needs work and advice.

Download all attachments as: .zip

Change History (8)

@chrisclayton
10 years ago

Not finished, needs work and advice.

#1 @DJPaul
10 years ago

  • Keywords dev-feedback removed

I think the idea might have merit, but for implementation, I'd reconstruct the current URL through the $bp->canonical_stack. Maybe something like bp_rel_canonical() which I put into trunk a couple weeks ago.

#2 @boonebgorges
10 years ago

What about wp_guess_url()?

#3 @chrisclayton
10 years ago

Agreed. Knew there was a reason i wanted advice :) Don't think i was too confident in that patch.

Haven't tested it and i could be reading it wrong, but looking through the bp_rel_canonical function (thanks btw, somehow i missed that update) it already seems to detect every url possible so, wouldn't we just be repeating the same code in both? (or am i reading it wrong?)

Wouldn't moving the url building stuff into bp_get_permalink() and returning the url_stack and then changing bp_rel_canonical() to simply just echo the bp_get_permalink()?

echo "<link rel='canonical' href='" . bp_get_permalink() . "' />\n";

Work perfectly, while keeping the DRY (Dont Repeat Yourself) principle intact?

Last edited 10 years ago by chrisclayton (previous) (diff)

#4 @boonebgorges
10 years ago

Yes, you're right that the canonical logic should be separated out and not repeated. bp_get_permalink() may not be the best name for such a function, though, as it's not really parallel to get_permalink() (which is used inside of the post loop or can be fed a post/post_id, and does not refer to the current page).

#5 @boonebgorges
10 years ago

  • Milestone changed from Awaiting Review to 1.6
  • Owner changed from chrisclayton to boonebgorges
  • Status changed from new to assigned

#6 @chrisclayton
10 years ago

Yeah, i was just using bp_get_permalink to refer to it by until i came up with something better. :)

#7 @boonebgorges
10 years ago

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

(In [5985]) Some canonical URL reconfiguration:

  • Introduces bp_get_canonical_url() and bp_get_requested_url(), to abstract some commonly used canonical logic
  • Provides an easy way for plugins to access the current canonical URL, using bp_get_canonical_url(). Fixes #4141
Note: See TracTickets for help on using tickets.