wp-header-search
Easily find a value for a supplied key in a theme and plugin header files.
This can be useful during builds for doing things like linting version increments,comparing the WP Tested Up To version, checking theme textdomains, and more!
Install
Install with yarn:
$ yarn add wp-header-search --dev
-- OR --
Install with npm:
$ npm install wp-header-search --save-dev
Usage
const searchHeader = ; async { /* Ran in module inside a plugin */ console; //=> '1.3.0-rc.1' /* Ran in module inside a theme */ console; //=> '1.7.0' /* Capture any header name's value you need! */ console; //=> 'GNU General Public License v2 or later'} ;
Internally this uses wp-project-header to automatically determine if it's running inside of a theme or plugin, so you don't have to worry about passing the file path in.
Sometimes you might need to override that setting though, so a second parameter for the path to a header file is available. For example getting a parent theme's version from style.css:
const searchHeader = path = ; async { console; //=> '2.1.1'} ;