Make WordPress Core

Opened 18 years ago

Closed 18 years ago

#9476 closed defect (bug) (fixed)

add_rewrite_endpoint() doesn't work

Reported by: Denis-de-Bernardy Owned by: ryan
Priority: normal Milestone: 2.8
Component: Permalinks Version: 2.8
Severity: normal Keywords: has-patch needs-testing commit
Cc: Focuses:

Description

While editing a plugin, I've noticed that this fails miserably:

add_rewrite_endpoint('print', EP_PERMALINK);

While this succeeds:

global $wp_rewrite;
$wp_rewrite->add_endpoint('print', EP_PERMALINK);
$wp_rewrite->flush_rules();

Shouldn't it flush the rules automatically?

Attachments (1)

9476.diff​ (717 bytes ) - added by Denis-de-Bernardy 18 years ago.

Download all attachments as: .zip

Change History (6)

#1 in reply to: ↑ description @filosofo
18 years ago

Replying to Denis-de-Bernardy:

Shouldn't it flush the rules automatically?

No. Adding an endpoint and generating the rewrite rules are two separate actions. When you add an endpoint, you're adding an endpoint to the pool of potential endpoints, which will be used the next time the rewrite rules are generated. So whereas one regenerates the rewrite rules only infrequently (for example, when a plugin is activated), the endpoint needs to be added to the pool of potential endpoints on every load of WP, so that it will be available to use in the case that something else flushes and regenerates the rules.

#2 @Denis-de-Bernardy
18 years ago

Ok... so it's like, the flush should occur on activate and deactivate then.

It should probably be clarified in the docs, then.

#3 @Denis-de-Bernardy
18 years ago

  • Keywords has-patch needs-testing added

Marking as needs testing, as I've resolved to not using this at all on my end.

#4 @Denis-de-Bernardy
18 years ago

  • Keywords commit added

#5 @ryan
18 years ago

  • Resolution → fixed
  • Status new → closed

(In [11102]) Clarify add endpoint phpdoc. Props Denis-de-Bernardy. fixes #9476

Note: See TracTickets for help on using tickets.