Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/15/2023 10:23:05 AM (2 years ago)
Author:
imath
Message:

Improve BP_Component methods relative to setting BP Rewrites

So far BP_Component::add_rewrite_tags(),
BP_Component::add_rewrite_rules() & BP_Component::add_permastructs()
were just firing hooks. Thanks to the BP Rewrites plugin we were able to
test how we can use them to actually enjoy the WP Rewrite API in
BuddyPress. Compared to what was tested in this feature as plugin, some
improvements has been brought so that it's easier to benefit from the BP
Rewrites API for custom components (analyzing the included PHPUnit tests
can give BP plugin authors a preview about how to process).

Introduce the BP_Component::pre_query() method to avoid superfluous Post
queries when a BuddyPress page is displayed.

The src/bp-core/bp-rewrites.php file has also been inited, this is the
place where all Core component rewrites function will be placed.

Props r-a-y, johnjamesjacoby, boonebgorges

See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/assets/class-bptest-component.php

    r13108 r13422  
    3535        parent::setup_globals( $this->globals );
    3636    }
     37
     38    public function add_rewrite_tags( $rewrite_tags = array() ) {
     39        parent::add_rewrite_tags( $rewrite_tags );
     40    }
     41
     42    public function add_rewrite_rules( $rewrite_rules = array() ) {
     43        parent::add_rewrite_rules( $rewrite_rules );
     44    }
     45
     46    public function add_permastructs( $permastructs = array() ) {
     47        parent::add_permastructs( $permastructs );
     48    }
    3749}
Note: See TracChangeset for help on using the changeset viewer.