Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#9476 closed defect (bug) (fixed)

add_rewrite_endpoint() doesn't work

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

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 15 years ago.

Download all attachments as: .zip

Change History (6)

#1 in reply to: ↑ description @filosofo
15 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
15 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
15 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
15 years ago

  • Keywords commit added

#5 @ryan
15 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.