From 4e8270e88255b4e3127a9234f155bb07839be786 Mon Sep 17 00:00:00 2001 From: Daan Meijer Date: Fri, 22 Aug 2025 08:54:40 +0200 Subject: [PATCH] updates package er in --- camping-care-widget.php | 1 + src/Updates.php | 90 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/Updates.php diff --git a/camping-care-widget.php b/camping-care-widget.php index bb4d033..07aeb1a 100644 --- a/camping-care-widget.php +++ b/camping-care-widget.php @@ -26,3 +26,4 @@ add_action('wp_enqueue_scripts', function(){ \CampingCareWidget\Widget::init(); \CampingCareWidget\Admin::init(); +\CampingCareWidget\Updates::init(); diff --git a/src/Updates.php b/src/Updates.php new file mode 100644 index 0000000..a3552d2 --- /dev/null +++ b/src/Updates.php @@ -0,0 +1,90 @@ + woocommerce [is_ssl] => [fields] => Array ( [banners] => 1 [reviews] => 1 [downloaded] => [active_installs] => 1 ) [per_page] => 24 [locale] => en_US ) + */ + function get_plugin_info($res, $action, $args) + { + + // do nothing if this is not about getting plugin information + if ('plugin_information' !== $action) { + return $res; + } + + $pluginName = plugin_basename(__DIR__); + + // do nothing if it is not our plugin + if ($pluginName !== $args->slug) { + return $res; + } + + // info.json is the file with the actual plugin information on your server + $remote = wp_remote_get( + 'https://wordpress-plugin-repository.exp.sforum.nl/plugins/' . urlencode($pluginName) . '/info.json', + array( + 'timeout' => 10, + 'headers' => array( + 'Accept' => 'application/json' + ) + ) + ); + + // do nothing if we don't get the correct response from the server + if ( + is_wp_error($remote) + || 200 !== wp_remote_retrieve_response_code($remote) + || empty(wp_remote_retrieve_body($remote)) + ) { + return $res; + } + + $res = json_decode(wp_remote_retrieve_body($remote)); + return $res; +// +// $res = (object)[]; +// $res->name = $remote->name; +// $res->slug = $remote->slug; +// $res->author = $remote->author; +// $res->author_profile = $remote->author_profile; +// $res->version = $remote->version; +// $res->tested = $remote->tested; +// $res->requires = $remote->requires; +// $res->requires_php = $remote->requires_php; +// $res->download_link = $remote->download_url; +// $res->trunk = $remote->download_url; +// $res->last_updated = $remote->last_updated; +// $res->sections = array( +// 'description' => $remote->sections->description, +// 'installation' => $remote->sections->installation, +// 'changelog' => $remote->sections->changelog +// // you can add your custom sections (tabs) here +// ); +// // in case you want the screenshots tab, use the following HTML format for its content: +// //
  1. CAPTION

    CAPTION

+// if (!empty($remote->sections->screenshots)) { +// $res->sections['screenshots'] = $remote->sections->screenshots; +// } +// +// $res->banners = array( +// 'low' => $remote->banners->low, +// 'high' => $remote->banners->high +// ); +// +// return $res; + + } + +} \ No newline at end of file