Read Plugin Version Of Any WordPress Plugin

[ad_1]

Using the get_file_data() function. More efficient than using get_plugin_data() function.

$plugin_data = get_file_data( WP_PLUGIN_DIR . '/plugin-folder-name-in-wp-content-plugins-folder/plugin-main-file.php', array( 'Version' => 'Version' ) );

$plugin_data[‘Version’] will have the version.

To read version from within the same plugin:

$plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ) );

Refer: https://wordpress.stackexchange.com/a/285644/90061

Pro tip: Use version_compare() PHP function to compare versions.

[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads