Better way to get plugin version

This commit is contained in:
Andy Miller
2016-04-26 12:57:29 -06:00
parent 59dbec5371
commit 5c95964052
2 changed files with 11 additions and 1 deletions

View File

@@ -66,6 +66,8 @@ class AdminPlugin extends Plugin
*/
protected $base;
protected $version;
/**
* @return array
*/
@@ -243,6 +245,13 @@ class AdminPlugin extends Plugin
// Only activate admin if we're inside the admin path.
if ($this->active) {
// Store this version and prefer newer method
if (method_exists($this, 'getBlueprint')) {
$this->version = $this->getBlueprint()->version;
} else {
$this->version = $this->grav['plugins']->get('admin')->blueprints()->version;
}
// Test for correct Grav 1.1 version
if (version_compare(GRAV_VERSION, '1.1.0-beta.1', '<')) {
$messages = $this->grav['messages'];
@@ -439,6 +448,7 @@ class AdminPlugin extends Plugin
$twig->twig_vars['base_url'] = $twig->twig_vars['base_url_relative'];
$twig->twig_vars['base_path'] = GRAV_ROOT;
$twig->twig_vars['admin'] = $this->admin;
$twig->twig_vars['admin_version'] = $this->version;
// Gather Plugin-hooked nav items
$this->grav->fireEvent('onAdminMenu');

View File

@@ -64,7 +64,7 @@
{% block content_bottom %}{% endblock %}
</div>
<footer id="footer">
<a href="http://getgrav.org">Grav</a> v<span class="grav-version">{{ constant('GRAV_VERSION') }}</span> - Admin v{{ admin.gpm.getInstalledPlugin('admin').version }} - {{ "PLUGIN_ADMIN.WAS_MADE_WITH"|tu|lower }} <i class="fa fa-heart"></i> {{ "PLUGIN_ADMIN.BY"|tu|lower }} <a href="http://www.rockettheme.com">RocketTheme</a>.
<a href="http://getgrav.org">Grav</a> v<span class="grav-version">{{ constant('GRAV_VERSION') }}</span> - Admin v{{ admin_version }} - {{ "PLUGIN_ADMIN.WAS_MADE_WITH"|tu|lower }} <i class="fa fa-heart"></i> {{ "PLUGIN_ADMIN.BY"|tu|lower }} <a href="http://www.rockettheme.com">RocketTheme</a>.
</footer>
</div>
</div>