Commit cd716812 authored by Olivier van Helden's avatar Olivier van Helden

Basic update checker. Result is shown on the status page for now, with links to zip and git repo.

parent e20fd1ec
<?php include_once( plugin_dir_path(__FILE__) . 'updater.php'); ?>
<div class="wrap">
<!-- <h1>OpenSimulator</h1> -->
<h1><?= esc_html(get_admin_page_title()); ?></h1>
<p><?php echo $version_info; ?></p>
<p>
<dt><code>[gridinfo]</code> General information (grid name and login uri)</dt>
<dd>
<?php echo w4os_gridinfo_shortcode(); ?>
</dd>
<dd>
<?php echo w4os_gridinfo_shortcode(); ?>
</dd>
</p>
<p>
<dt>
<code>[gridstatus]</code> Online users, regions, etc.</dt>
<dd> <?php echo w4os_gridstatus_shortcode(); ?></dd>
<dt><code>[gridstatus]</code> Online users, regions, etc.</dt>
<dd> <?php echo w4os_gridstatus_shortcode(); ?></dd>
</p>
</div>
<?php
$repo_api="https://git.magiiic.com/api/v4/projects/38";
$version=get_plugin_data(dirname(dirname(__FILE__)) . "/w4os.php")['Version'];
$version_info=__("Version:") . " $version";
$repo = wp_remote_get( "$repo_api", array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
) )
);
$repo_url = json_decode( $repo['body'] )->web_url;
$repo_path = json_decode( $repo['body'] )->path;
$tags = wp_remote_get( "$repo_api/repository/tags", array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
) )
);
$tag_name = json_decode( $tags['body'] )[0]->name;
$remote_version = preg_replace("/^v/", "", $tag_name);
if( $remote_version && version_compare($version, $remote_version, "<"))
{
$updateavailable=true;
$download_link = "$repo_url/-/archive/$tag_name/$repo_path-$tag_name.zip";
$version_info="$version_info (" . __("update availailable:") . " $remote_version, <a href='$download_link'>" . __("download zip") . "</a> " . __("or") . " <a href='$repo_url' target=_blank>" . __("pull from git repository") . "</a>)";
}
......@@ -15,8 +15,8 @@
* @wordpress-plugin
* Plugin Name: OpenSimulator
* Plugin URI: https://git.magiiic.com/opensimulator/w4os
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
* Version: 0.3.2
* Description: OpenSimulator web interface for WordPress.
* Version: 0.3.4
* Author: Speculoos
* Author URI: http://speculoos.world
* License: GPL-2.0+
......@@ -35,7 +35,7 @@ if ( ! defined( 'WPINC' ) ) {
* Start at version 0.1.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'W4OS_VERSION', '0.1.0' );
// define( 'W4OS_VERSION', $version );
/**
* The code that runs during plugin activation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment