Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For a theme (usually placed at the top of functions.php):

Code Block
languagephp
<?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
languagephp
<?php

$mypluginprefix_data = get_file_data( __FILE__, array( ['Version' => 'Version' ]), 'plugin' );

define( 'MYPLUGINPREFIX_VERSION', $mypluginprefix_data['Version'] );

...