Closed strangerkir closed 3 years ago
I've implemented some improvements for supporting non-default Plugin headers here https://github.com/inpsyde/modularity/commit/6a0283d9114e317038eff8af82ce29adb837c970 . The new logic will only map internally default Plugin Headers to generalize them to Properties. Custom Headers will not be touched and stay as they are added.
You can access for example following Headers:
/**
* Author: Inpsyde GmbH
* AuthorURI: https://www.inpsyde.com
*
* WC requires at least: 2.2
* WC tested up to: 2.3
*/
like following:
$properties = Inpsyde\Modularity\Properties\PluginProperties::new(__FILE__);
// Default Headers
$properties->author(); // Inpsyde GmbH
$properties->get(Properties::PROP_AUTHOR); // same as above
$properties->authorUri(); // https://www.inpsyde.com
$properties->get(Properties::PROP_AUTHOR_URI); // same as above
// Custom Headers
$properties->get('WC requires at least'); // 2.2
$properties->get('WC tested up to'); // 2.3
released with version 1.3.0. Please close if this issue is consider for you as solved @strangerkir . :)
Please close if this issue is consider for you as solved
Sorry, just noticed your comment. Yep, everything is fine. Thanks!
Is your feature request related to a problem? Please describe. I want to get the
WC requires at least
field value, that is not provided by properties. I tried to extendPluginProperties
and overwriteHEADERS
constant, but it's not worked because it's called in the constructor asself::HEADERS
, so the constant is used from thePluginProperties
class, not from the extending one.Describe the solution you'd like It would be great to have an option to get value of any of WP plugin header fields with
Properties::get()
. Probably, just merge everything returned by theget_plugin_data()
function, as discussed in Slack.Describe alternatives you've considered Another option is to allow classes extending the
PluginProperties
to overwrite the parsed headers list. For example, use the protected methodheaders()
instead of a class constant. Or, it should be possible to override that constant if it's used asstatic::HEADERS
instead ofself::HEADERS
.Additional context This is how it's expected to work. Plugin header:
/**
Usage of properties:
or if this property was configured in custom
HEADERS
constant:Usage of properties: