Make WordPress Core

Opened 9 years ago

Closed 7 weeks ago

#37051 closed enhancement (wontfix)

New filter `wp_page_path_sql`

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

Make plugin for translations I found next missing filter. WordPress use get_page_by_path in WP->parse_request();

In post meta I save info about language version.

Example:
"Contact" in German and Polish is "Kontakt" so slug will be 'kontakt'. Function get_page_by_path fiund by slug in all languages. But in filter wp_page_path_sql I can add LEFT JOIN and set current language.

I know that exists parse_query action and I can change query via this action but before in wp_page_path_sql will be generate unnecessary sql.

This sql filter will be usefull very much.

Attachments (1)

37051.patch (1.1 KB) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @sebastian.pisula
9 years ago

  • Keywords has-patch added

This ticket was mentioned in Slack in #core by sebastian.pisula. View the logs.


8 years ago

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


7 weeks ago

#4 @SirLouen
7 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

@sebastianpisula it's extremely rare to add a filter to alter an SQL query. We should not be adding filters just anywhere because, apart from the fact that they are too dense for the code, they generate extra unnecessary overhead.

You have here multiple options. You can manipulate the query directly with the query filter, which simply works.

Also consider that if you use a language taxonomy, adapt the JOIN to term_relationships or term_taxonomy instead of postmeta to leverage better indexes.

Note: See TracTickets for help on using tickets.