#40034 closed enhancement (worksforme)
Add License and License URI as valid style.css headers to WP_Theme
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Themes | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
The style.css headers License and License URI are required for WordPress.org theme repository but it is not possible to fetch the data using WP_Theme::get().
The reason I realized this is that I am working on an automated testing plugin for theme and wanted to check that the License and License URI were set.
Change History (8)
#1
@
9 years ago
- Keywords needs-patch needs-screenshots added
- Type changed from defect (bug) to enhancement
#4
@
9 years ago
@dd32 Actually that does not work anymore. I am not sure it ever worked. The reason is that there is a check in the beginning of WP_Theme::get().
if ( ! isset( $this->headers[ $header ] ) )
return false;
The fix for this ticket would be to add the following to $file_headers
'License' => 'License', 'LicenseURI' => 'License URI',
#5
@
9 years ago
It works for me:
add_filter( 'extra_theme_headers', 'tc_add_headers' );
function tc_add_headers( $extra_headers ) {
$extra_headers = array( 'License', 'License URI', 'Template Version' );
return $extra_headers;
}
var_dump( get_theme( 'Twenty Seventeen' )->get('License URI') );
That check you're referencing will contain the License key if whitelisted.
#6
@
9 years ago
- Resolution set to worksforme
- Status changed from new to closed
Ok, I got it to work for me too now. The filter that is used for when using the class is https://developer.wordpress.org/reference/hooks/extra_context_headers/
In general, when core doesn't use the field I don't see the benefit in pulling it out - however it is an official field by the themes team.
As a workaround, Theme Check uses the filter to add the extra headers: #20897