Skip to content

Commit

Permalink
Update channel added
Browse files Browse the repository at this point in the history
  • Loading branch information
skito committed Aug 31, 2022
1 parent 069c597 commit ac5ffad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Hooks/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static function Init($sender)
add_action('entase_event_import_cron', function() { \Entase\Plugins\WP\Hooks\Cron::Run('event_import'); });
add_action('entase_production_import_cron', function() { \Entase\Plugins\WP\Hooks\Cron::Run('production_import'); });

// Register update channel
add_filter('update_plugins_github.com', ['Entase\Plugins\WP\Hooks\Update', 'Check'], 10, 3);


/*register_activation_hook($sender, ['\FTAPI\Hooks\Install', 'Register']);
add_action('init', ['\FTAPI\Hooks\Init', 'Register']);
add_action('wp', ['\FTAPI\Hooks\WP', 'Register']);
Expand All @@ -56,6 +60,5 @@ public static function Init($sender)
add_action( 'save_post', ['\FTAPI\Hooks\Dashboard', 'SaveMeta'] );
}*/


}
}
27 changes: 27 additions & 0 deletions src/Hooks/Update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Entase\Plugins\WP\Hooks;

class Update
{
public static function Check($update, $plugin_data, $plugin_file)
{
touch(\Entase\Plugins\WP\Conf::BasePath.'/update.log');
static $response = false;

if (empty( $plugin_data['UpdateURI'] ) || !empty($update))
return $update;

if($response === false)
$response = wp_remote_get($plugin_data['UpdateURI']);

if(empty($response['body']))
return $update;

$custom_plugins_data = json_decode($response['body'],true);

if(!empty($custom_plugins_data[$plugin_file]))
return $custom_plugins_data[$plugin_file];
else return $update;
}
}

0 comments on commit ac5ffad

Please sign in to comment.