#40034 closed enhancement (worksforme)
Add License and License URI as valid style.css headers to WP_Theme
| Reported by: | grapplerulrich | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Themes | Version: | |
| Severity: | normal | Keywords: | needs-patch |
| Cc: | Focuses: |
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)
#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 → worksforme
- Status new → 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/
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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