[wp-hackers] Possible bug with endpoints
Jennifer Hodgdon
yahgrp at poplarware.com
Fri May 18 18:04:20 GMT 2007
Seamus --
I may be wrong, but I don't think you can change the endpoint code as
you are suggesting, because I think it will break the use of endpoints
of this form:
existingurl/testendpoint/val/
Endpoints of this form work with the existing rewrite code, and tell
it to set up q['testendpoint'] = 'val' in the query vars. This is used
for things like tags, language switching, etc., and appears to be what
the endpoint code was set up to do, rather than just having
existingurl/testendpoint/
with no trailing value, as you are trying to do.
By the way, did you try isset instead of empty, in your redirect
function? It is possible that that will fix your issue, but i am not
sure without testing it (or reading the query parsing code more than I
have time to do at the moment).
Hope this helps clarify --
Jennifer
Seamus Leahy wrote [in part]:
> I think I have found a bug with rewrite endpoints, but I would like for
> someone with more experience and knowledge to check it out since I am a
> newbie at hacking WordPress.
[snipped]
>
> I created a test plugin and I did the testing with WP 2.2.
> The plugin:
>
> -----------------------------------------------------------------
> <?php
> /*
> Plugin Name: Test Endpoint
> Plugin URI:
> Description:
> Version: 1.0
> Author: Seamus Leahy
> */
> function TestEndpoint(){
> add_action('init', 'TestEndpointInit');
> add_action('template_redirect', 'TestEndpointRedirect');
> }
>
> function TestEndpointInit(){
> global $wp_rewrite;
> $wp_rewrite->add_endpoint("testendpoint", EP_ALL);
> $wp_rewrite->flush_rules();
> }
>
> function TestEndpointRedirect(){
> $my_var = get_query_var('testendpoint');
>
> if (empty($my_var)){
> return;
> }
>
> die( '<h1>We hit the endpoint: testendpoint!</h1>');
>
> }
>
> TestEndpoint();
>
> ?>
> -----------------------------------------------------------------
>
> The test:
> 1. Install the plugin and activate it
> 2. Go to an existing page, append to the URL "/testendpoint/", and go to
> the new URL
> - Expected results: " We hit the endpoint: testendpoint!"
> - Actually results: The original page without the endpoint
> 3. Change the file /wp_include/rewrite.php as stated above
> 4. Repeat step 2
> - Actually results: " We hit the endpoint: testendpoint!"
--
Jennifer Hodgdon
Poplar ProductivityWare * www.poplarware.com
Web Databases/Scripts * Modeling/Analysis/Palm OS Software
More information about the wp-hackers
mailing list