{"id":5106,"date":"2018-01-23T15:25:59","date_gmt":"2018-01-23T20:25:59","guid":{"rendered":"https:\/\/themespress.ca\/?p=5106"},"modified":"2022-10-01T14:42:58","modified_gmt":"2022-10-01T18:42:58","slug":"display-current-version-of-plugin","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/display-current-version-of-plugin\/","title":{"rendered":"Display the Current Version Of Your WordPress Plugin"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Below is a tutorial that will show you how to validate and display the version of your plugin. Our function will need to validate the version of the WordPress plugin. This can also be beneficial in order to automate the plugin&#8217;s update by using a variable parameter.<\/p>\n<p>As you know in our main plugin file we need the core parameters such as version for example.<br \/>\nThis is an exemple :<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >Display the Current Version Of Your WordPress Plugin<\/h2><div id=\"ts-enlighterjs-container-7703638\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-7703638\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/*\nPlugin Name: Le nom du Plugin\nPlugin URI: Url de l&#039;auteur ou du site web \nDescription: Description du plugin\nVersion: 2.4\nAuthor: Le nom de l&#039;auteur\nAuthor URI: URI du plugin\n*\/<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>In the example below, we will create a <strong>function that will look the written version in the Version data<\/strong> (Fetching the 2.4) :<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-1407106\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-1407106\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function ma_function_version_number() {\n   \/\/ If get_plugins() isn&#039;t available, require it\n   if ( ! function_exists( &#039;get_plugins&#039; ) )\n   require_once( ABSPATH . &#039;wp-admin\/includes\/plugin.php&#039; );\n \n   \/\/ Variable et donner get dans le folder\n   $plugin_folder = get_plugins( &#039;\/&#039; . &#039;nomdufichierplugin&#039; );\n   \/\/ Le fichier ou se trouve la d&eacute;claration du plugin\n   $plugin_file = &#039;mapageprincipaleduplugin.php&#039;;\n \n   \/\/ Afficher le num&eacute;ro de la version ou retourner un r&eacute;sultat vide \n   if ( isset( $plugin_folder[$plugin_file][&#039;Version&#039;] ) ) {\n\treturn $plugin_folder[$plugin_file][&#039;Version&#039;];\n   } else {\n   \/\/ Otherwise return null\n   return NULL;\n   }\n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>This funciton will net the data found under Version. It does an echo thus displaying the 2.4.<\/p>\n<p>We then display the results somewhere in the plugin.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-2568408\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-2568408\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">&lt;?php $version = ma_function_version_number(); echo $version; ?&gt;<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>And voil\u00e0! Once you&#8217;ll update the plugin and change the version number, it will be automatically updated in the plugin itself.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"Below is a tutorial that will show you how to validate and display the version of your plugin. Our function will need to validate the version of the WordPress plugin.<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/display-current-version-of-plugin\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":5108,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[],"class_list":["post-5106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=5106"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/5106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/5108"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=5106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=5106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=5106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}