...
For a theme (usually placed at the top of functions.php):
Code Block | ||
---|---|---|
| ||
<?php
$mythemeprefix_data = wp_get_theme( 'my-theme-slug' ); //theme slug is usually the github repo name.
define( 'MYTHEMEPREFIX_VERSION', $mythemeprefix_data->get( 'Version' ) ); |
...
For a plugin (usually placed at the top of the plugin bootstrap file):
Code Block | ||
---|---|---|
| ||
<?php
$mypluginprefix_data = get_file_data( __FILE__, ['Version' => 'Version' ], 'plugin' );
define( 'MYPLUGINPREFIX_VERSION', $mypluginprefix_data['Version'] ); |
...