[buddypress-trac] [BuddyPress Trac] #6801: Filtering custom activity pages with parse_args

buddypress-trac noreply at wordpress.org
Tue Jan 12 04:17:26 UTC 2016


#6801: Filtering custom activity pages with parse_args
--------------------------+----------------------
 Reporter:  snd26         |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  API           |     Version:  2.4.0
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |
--------------------------+----------------------
Changes (by boonebgorges):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 The problem is likely that `is_page( 'test-1' )` is not true during AJAX
 requests. AJAX requests have URLs like `example.com/wp-admin/admin-
 ajax.php`, not `example.com/test-1/`. As such, WP doesn't do its normal
 bootstrap, parsing the request according to rewrite rules, running a
 `WP_Query`, etc. This is not a bug in BuddyPress, but a side effect of how
 WP AJAX requests work. See
 http://wordpress.stackexchange.com/questions/71070/conditional-ajax-
 inclusion for more information.

 As a workaround, you can build your own conditional that looks like this.
 (Untested, but this should give you a starting point.)

 {{{
 function bp6801_is_test_1_page() {
     $is_test_1_page = false;

     if ( is_page( 'test-1' ) ) {
         $is_test_1_page = true;
     } elseif ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
         $referer_page_id = url_to_postid( wp_get_referer() );
         $referer_page = get_post( $referer_page_id );
         if ( $referer_page instanceof WP_Post && 'test-1' ===
 $referer_page->post_name ) {
             $is_test_1_page = true;
         }
     }

     return $is_test_1_page;
 }
 }}}

 You can use this to tell whether to modify your 'per_page' setting,
 whether or not you're in an AJAX request.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6801#comment:3>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list