Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#55829 closed defect (bug) (fixed)

Doc error on ticket 10886

Reported by: stevemullen's profile stevemullen Owned by:
Milestone: WordPress.org Priority: normal
Severity: normal Version: 6.0
Component: Bootstrap/Load Keywords:
Focuses: docs Cc:

Description

This is a follow-up to #10886.

The example, pasted to many places, has two problems:

  • it contains unbalanced parenthesis
  • $this is not a valid parameter. I believe the function expects ($do_parse, $wp, $extra_query_vars)
function wporg_add_custom_query( $do_parse, $this, $extra_query_vars ) {
    if ( 'CUSTOM_VALUE' === $extra_query_vars['custom_arg'] {
        return false;
    }
 
    return $do_parse;
}
 
add_filter( 'do_parse_request', 'wporg_add_custom_query' );

Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Focuses docs added
  • Milestone changed from Awaiting Review to WordPress.org
  • Resolution set to fixed
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the ticket.

Just to clarify for anyone looking at this, it's about this post: Changes to do_parse_request filter in WordPress 6.0.

Good catch! There is also an issue with the add_filter() call there, it should specify the number of arguments:

add_filter( 'do_parse_request', 'wporg_add_custom_query', 10, 3 );

Otherwise, only the first argument is actually passed to the filter.

I have updated the post to correct these issues.

Note: See TracTickets for help on using tickets.