{"id":5036,"date":"2018-04-19T15:25:00","date_gmt":"2018-04-19T09:55:00","guid":{"rendered":"https:\/\/millionclues.com\/?p=5036"},"modified":"2018-04-19T15:25:00","modified_gmt":"2018-04-19T09:55:00","slug":"read-plugin-version","status":"publish","type":"post","link":"https:\/\/millionclues.com\/wordpress-tips\/read-plugin-version\/","title":{"rendered":"Read Plugin Version Of Any WordPress Plugin"},"content":{"rendered":"<p>Using the <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_file_data\/\">get_file_data()<\/a> function. More efficient than using get_plugin_data() function. <\/p>\n<pre><code class=\"language-php line-numbers\">$plugin_data = get_file_data( WP_PLUGIN_DIR . '\/plugin-folder-name-in-wp-content-plugins-folder\/plugin-main-file.php', array( 'Version' =&gt; 'Version' ) );<\/code><\/pre>\n<p>$plugin_data[&#8216;Version&#8217;] will have the version. <\/p>\n<p>To read version from within the same plugin:<\/p>\n<pre><code class=\"language-php line-numbers\">$plugin_data = get_file_data( __FILE__, array( 'Version' =&gt; 'Version' ) );<\/code><\/pre>\n<p>Refer: https:\/\/wordpress.stackexchange.com\/a\/285644\/90061<\/p>\n<p>Pro tip: Use <a href=\"http:\/\/php.net\/manual\/en\/function.version-compare.php\">version_compare()<\/a> PHP function to compare versions. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using the get_file_data() function. More efficient than using get_plugin_data() function. $plugin_data = get_file_data( WP_PLUGIN_DIR . &#8216;\/plugin-folder-name-in-wp-content-plugins-folder\/plugin-main-file.php&#8217;, array( &#8216;Version&#8217; =&gt; &#8216;Version&#8217; ) ); $plugin_data[&#8216;Version&#8217;] will have the version. To read version from within the same plugin: $plugin_data = get_file_data( __FILE__, array(<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/millionclues.com\/wordpress-tips\/read-plugin-version\/\">Read more &#8250;<\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[65],"tags":[205,20,67],"class_list":["post-5036","post","type-post","status-publish","format-standard","hentry","category-wordpress-tips","tag-code-snippets","tag-wordpress","tag-wordpress-plugins"],"_links":{"self":[{"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/posts\/5036"}],"collection":[{"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/comments?post=5036"}],"version-history":[{"count":2,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/posts\/5036\/revisions"}],"predecessor-version":[{"id":5038,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/posts\/5036\/revisions\/5038"}],"wp:attachment":[{"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/media?parent=5036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/categories?post=5036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/millionclues.com\/wp-json\/wp\/v2\/tags?post=5036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}