Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 10 years ago

#12507 closed enhancement (fixed)

Make /page/ filterable

Reported by: scribu's profile scribu Owned by: ryan's profile ryan
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Permalinks Keywords: has-patch needs-testing
Focuses: Cc:

Description

It should be easy to change the /page/ part of a permalink, for i18n purposes etc.

Attachments (5)

pagination_base.diff (1.6 KB) - added by scribu 15 years ago.
Introduce 'pagination_base' filter
pagination_base.2.diff (1.7 KB) - added by scribu 15 years ago.
Make pagination_base a private var in WP_Rewrite
pagination_base.3.diff (3.7 KB) - added by scribu 15 years ago.
fix canonical redirect and wp_unique_slug()
pagination_base.4.diff (6.4 KB) - added by scribu 15 years ago.
Make <!--nextpage--> links use pagination_base
pagination_base.5.diff (7.7 KB) - added by scribu 15 years ago.
DRY for wp_link_pages()

Download all attachments as: .zip

Change History (20)

@scribu
15 years ago

Introduce 'pagination_base' filter

#1 @scribu
15 years ago

  • Keywords has-patch needs-testing added

#2 @nacin
15 years ago

If it is for i18n, then we should probably use _x() here and then apply a filter over that.

It may also make sense to also make this a method or property of WP_Rewrite, much like category/tag bases.

#3 @filosofo
15 years ago

Also, it would be good if all the endpoints were defined consistently, say by calling the add_endpoint method in init. Then at the bottom of init we could pass a reference to the WP_Rewrite object which would allow all such rewrite properties to be manipulated by plugin.

I really do like the idea, sort of hinted at in scribu's patch, of having a consistent API shared between rewrite and link generation for determining link structure.

Since its use is limited to 2 places in core, I'm not sure get_pagination_base would need to be a public function.

#4 @filosofo
15 years ago

class WP_Structure {

   function get_pagination_base() {}
   function get_post_structure() {}
   function get_category_structure() {}

   ...
   
   function init() {
      $this->rewrite = new WP_Rewrite;
      $this->rewrite->page_base = $this->get_pagination_base();

   }
}

$wp_structure_class = apply_filters('wp_structure_class', 'WP_Structure');
$wp_structure = new $wp_structure_class;

Everything--links, rewrite rules, etc.--all able to be changed easily in one place by extending WP_Structure.

#5 follow-up: @scribu
15 years ago

Replying to nacin:

If it is for i18n, then we should probably use _x() here and then apply a filter over that.

I agree, but it might cause trouble when a user switches the localization file, since the permalink rules aren't flushed.

It may also make sense to also make this a method or property of WP_Rewrite, much like category/tag bases.

Agreed.

Replying to filosofo:

Also, it would be good if all the endpoints were defined consistently, say by calling the add_endpoint method in init. Then at the bottom of init we could pass a reference to the WP_Rewrite object which would allow all such rewrite properties to be manipulated by plugin.

I really do like the idea, sort of hinted at in scribu's patch, of having a consistent API shared between rewrite and link generation for determining link structure.

Yeah, the rewrite API needs work. What else is new? :)

I like were you're going with this, but please open your own ticket.

#6 @dphiffer
15 years ago

  • Cc dphiffer added

#7 in reply to: ↑ 5 @filosofo
15 years ago

Replying to scribu:

I like were you're going with this, but please open your own ticket.

I will, but my main point here is that get_pagination_base be marked private. No need to expose a public API for this.

@scribu
15 years ago

Make pagination_base a private var in WP_Rewrite

#8 @scribu
15 years ago

In pagination_base.2.diff I've simply made pagination_base a variable in the WP_Rewrite class. It seems consistent with all the rest of the vars.

#9 @TobiasBg
15 years ago

I like your idea, scribu.

And I suggest not only doing it for /page/, but also for /trackback/ and /comment-page-X/, as they also seem to be hardcoded here.

@scribu
15 years ago

fix canonical redirect and wp_unique_slug()

#11 @scribu
15 years ago

pagination_base.3.diff makes redirect_canonical() and wp_unique_slug() aware of $wp_rewrite->pagination_base

@scribu
15 years ago

Make <!--nextpage--> links use pagination_base

@scribu
15 years ago

DRY for wp_link_pages()

#12 @scribu
15 years ago

  • Milestone changed from Future Release to 3.1

#13 @scribu
15 years ago

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

(In [15582]) Don't hardcode the pagination base. Fixes #12507

#14 @scribu
15 years ago

  • Milestone changed from Awaiting Triage to 3.1

#15 @chriscct7
10 years ago

#18084 was marked as a duplicate.

Note: See TracTickets for help on using tickets.