Make WordPress Core

Opened 4 years ago

Closed 5 weeks ago

Last modified 4 days ago

#54381 closed enhancement (fixed)

Add filter to validate_theme_requirements

Reported by: kraftbj's profile kraftbj Owned by: kraftbj's profile kraftbj
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

There may be the need to add extra requirements for a theme to validate that site administrators may want to add. The validate_theme_requirements function looks keen for this, but there are currently no hooks in the function.

An example use case: A particular site on a multisite should never have a theme changed via the UI (a mission-critical site). The multisite, generally, has various themes network activated. Such a filter could allow a site administrator to check the blog ID and return a WP_Error if the blog ID is in a "theme_change_disallowed" array.

Proposing a validate_theme_requirement filter that hooks at the end of the current function to allow additional validation requirements. Intentionally not filtering the current failing conditions (incompatible WP or PHP) to prevent poor implementation of the filter to lead to a PHP/WP version-related fatal.

Attachments (1)

54381-validate-theme-requirements-filter.diff (792 bytes) - added by sachinrajcp123 4 months ago.

Download all attachments as: .zip

Change History (13)

This ticket was mentioned in PR #1812 on WordPress/wordpress-develop by kraftbj.


4 years ago
#1

  • Keywords has-patch has-unit-tests added

Adds a filter, validate_theme_requirements, to allow for additional theme validation requirements.

Trac ticket: https://core.trac.wordpress.org/ticket/54381

#2 @sachinrajcp123
4 months ago

Enhancement: Add filter hook to allow customization of validate_theme_requirements() results.

#3 @kraftbj
4 months ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to kraftbj
  • Status changed from new to accepted

Refreshed the patch to see if we can land in 6.9!

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


8 weeks ago

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


5 weeks ago

#6 @wildworks
5 weeks ago

This ticket was featured on today's 6.9 Bug Scrub.

Maybe @jorbin will take a look at this ticket if he has time.

#7 @joedolson
5 weeks ago

It really seems like we should add the same filtering capabilities in validate_plugin_requirements(), at the same time, which seems to have the same limitations.

This ticket was mentioned in PR #10361 on WordPress/wordpress-develop by @joedolson.


5 weeks ago
#8

For API consistency, add a filter to validate_plugin_requirement comparable to validate_theme_requirement

Not sure where tests for this might live, if we need them.

Trac ticket: https://core.trac.wordpress.org/ticket/54381

@jorbin commented on PR #10361:


5 weeks ago
#10

@joedolson good catch. I agree.

#11 @jorbin
5 weeks ago

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

In 60995:

Plugins and Themes: Add filters to validation functions.

It is now possible to add additional validation requirements for themes and plugins besides the built in core checks.

Developed in https://github.com/WordPress/wordpress-develop/pull/1812 and https://github.com/WordPress/wordpress-develop/pull/10361.

Props kraftbj, mukesh27, jorbin, joedolson.
Fixes #54381.

#12 @desrosj
4 days ago

The miscellaneous developer-focused changes developer note mentioned the two new hooks introduced in [60995] but did not cover their usage in depth: https://make.wordpress.org/core/2025/11/17/miscellaneous-developer-focused-changes-in-6-9/.

Note: See TracTickets for help on using tickets.