[buddypress-trac] [BuddyPress Trac] #4954: Migrate BP's custom URI parser to use WP's Rewrite API
buddypress-trac
noreply at wordpress.org
Wed Feb 12 17:46:42 UTC 2014
#4954: Migrate BP's custom URI parser to use WP's Rewrite API
---------------------------+------------------------------
Reporter: boonebgorges | Owner: johnjamesjacoby
Type: task | Status: new
Priority: high | Milestone: 2.0
Component: Rewrite Rules | Version:
Severity: major | Resolution:
Keywords: |
---------------------------+------------------------------
Comment (by r-a-y):
Attached is a first pass at rewrite rules.
This patch has no slug administration stuff and still uses our existing BP
directory pages as I wanted to port our current URI functionality to work
with rewrite rules at least for a first pass.
'''Note:''' When you apply the patch, make sure to manually flush the
existing rewrite rules by going to "Settings > Permalinks" in the admin
area.
Some dev notes:
* '''Current URI properties are set on 'init'''' - Our old method of URI
parsing is defined in the `bp_core_set_uri_globals()` function, which runs
on `'init'`. With rewrite rules, URI parsing starts on `'parse_query'`,
which runs later than `'init'`. This has the potential to break plugins
looking for stuff like the `current_X` items, `displayed_user` or
`current_group` objects on `'bp_init'`. To workaround this, I had to
unfortunately duplicate some logic. See the `backpat_globals()` method in
the members and groups component loaders, which uses the new
`bp_core_get_from_uri()` function. It's definitely not pretty, but
perhaps we can leave this in for a few releases with the intent of
removing this method entirely in a future release.
* '''Some hooks are moved to 'bp_parse_query'''' - `bp_setup_nav()` and
`_bp_maybe_remove_redirect_canonical()` now run on 'bp_parse_query' to
account for the URI property changes above. This should rarely break
anything.
* '''AJAX and bp_current_X() checks''' - With rewrite rules, the
`'parse_query'` hook does not run during AJAX requests. That means any BP
URI property checks (using a `bp_is_current_X() function`) during AJAX
will fail. To workaround this, I decided to keep on using
`bp_core_set_uri_globals()`, but run it on AJAX only. I don't see a
better way around this without using some version of that function during
AJAX. Might build upon the new `bp_core_get_from_uri()` function, which
is lighter than the old bp_core_set_uri_globals(). Will look into this
some more.
* '''Shortlink canonical redirection''' - Try something like
`domain.com/?bp_user_id=1` or `domain.com/?bp_group_id=1`. This will
redirect to the pretty permalink. Still a lot of work to do to our output
link functions if we want to support non-fancy permalinks entirely.
* '''bp-default compatibility''' - Yup, still works :) I've tweaked
`bp_core_load_template()` to only run on bp-default set ups, while making
sure plugins that are using the existing filters in that function will
still work.
* '''BP directory page as front page''' - Briefly tested with the activity
directory and this also works fine. Though I should point out that if we
are getting rid of WP pages, setting a BP component as the front page will
be a little harder to implement.
* '''Existing routing unit tests pass''' - With some modifications to
initialize and flush rewrite rules.
* '''Root profiles doesn't work yet''' - Still need to look into this.
First thoughts are this is going to be a PITA.
* '''Search functionality doesn't work yet''' - Ran out of time for this
patch. Need to probably write a specialized rewrite rule for
`BP_SEARCH_SLUG`.
Feedback appreciated.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4954#comment:13>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list