Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#46135 closed enhancement (duplicate)

Add filter to disable wp_favicon_request

Reported by: shawfactor's profile shawfactor Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.0
Component: Customize Keywords: good-first-bug has-patch
Focuses: Cc:

Description

A number of other functions in wp-includes/load.php have fikters that enable them to be disabled. However wp_favicon_request does not.

Disabling this function via a pluginn could be useful, especially in a multisite environment where you wanted to dynamicly serve a favicon in the root directory or even run a redirect.

Attachments (2)

43135.diff (721 bytes) - added by sebastienserre 6 years ago.
43135.1.diff (706 bytes) - added by priyankkpatel 5 years ago.
Patch for wp-admin/load.php with filter added.

Download all attachments as: .zip

Change History (11)

#1 @shawfactor
6 years ago

I a, unfamiliar with the contribution process, the fix/enhancement on this is trivial but I'd love to write to and get started co tributing to core.

Version 0, edited 6 years ago by shawfactor (next)

#2 @johnbillion
6 years ago

  • Focuses accessibility multisite removed
  • Keywords needs-patch good-first-bug reporter-feedback added

Thanks for the ticket, @shawfactor ! Welcome to WordPress Trac.

Out of interest, is there a particular reason you want or need to disable this handling? It always helps to know the background behind requests, as it helps gauge priority and effect.

The Core Contributor Handbook is a good place to get started with contributing to WordPress: https://make.wordpress.org/core/handbook/. There are links there to some tutorials and guides that should help to get you started. Don't forget to join our Slack too: https://chat.wordpress.org/ .

Last edited 6 years ago by johnbillion (previous) (diff)

#3 @shawfactor
6 years ago

Yes as I outlined on multisite you may want different favicons per site. You can of course do this when html is returned via a meta tag but on non html requests many browsers still look for a favicon.ico at the root of the domain.

On multisite i would like to write a plugin to either generate the favicon dynamicly or redirect the request (differently depending on the site). Currently this is impossible due to the lack of a filter.

Most other functions in load.php have filters to disable them, but this function does not.

#4 @SergeyBiryukov
6 years ago

  • Component changed from General to Customize

#5 follow-up: @andraganescu
6 years ago

Welcome @shawfactor, how do you imagine this would be more useful:

  • simply applying a filter to disable the function
  • applying a filter to set a specific header, other than the default then exit OR doing nothing if the filter returns false

@sebastienserre
6 years ago

#6 in reply to: ↑ 5 @shawfactor
6 years ago

I think simply a filter to disable IE prevent the function doing anything would be best for two reasons:

  1. It would be consistent with other functions in the same file
  1. Any handling of the url could be then left to a plugin or theme using later hooks.

Replying to andraganescu:

Welcome @shawfactor, how do you imagine this would be more useful:

  • simply applying a filter to disable the function
  • applying a filter to set a specific header, other than the default then exit OR doing nothing if the filter returns false

@priyankkpatel
5 years ago

Patch for wp-admin/load.php with filter added.

#7 @shawfactor
5 years ago

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

@priyankkpatel yes that looks perfect. I am very unfamiliar with this process but how does this get accepted and added to core?

#8 @desrosj
5 years ago

  • Keywords has-patch added; needs-patch removed
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version changed from 5.0.3 to 3.0

Thanks for testing the latest patch, @shawfactor!

The ticket should remain open until it is committed to the WordPress Core code repository.

It looks like the only thing the wp_favicon_request() function does is set a Content-Type header if the URL being requested is site.com/favicon.ico (introduced in [13205]).

Can you provide an example to help me understand how adding a filter here would accomplish dynamically serving a favicon?

#9 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Thanks for the ticket! Going to close in favor of #47398, which has some more discussion on removing or overriding wp_favicon_request(). The latest patch there deprecates wp_favicon_request() and introduces a more flexible alternative. Any feedback welcome!

Note: See TracTickets for help on using tickets.