Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#9476 closed defect (bug) (fixed)

add_rewrite_endpoint() doesn't work

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


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);

Shouldn't it flush the rules automatically?

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 in reply to: ↑ description @filosofo7 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.

comment:2 @Denis-de-Bernardy7 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.

@Denis-de-Bernardy7 years ago

comment:3 @Denis-de-Bernardy7 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.

comment:4 @Denis-de-Bernardy6 years ago

  • Keywords commit added

comment:5 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

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

Note: See TracTickets for help on using tickets.