Skip to content

Commit 35d1d7c

Browse files
committed
removed plugins_api hook from main plugin, handled by PucFactory
1 parent 2356a17 commit 35d1d7c

File tree

4 files changed

+13
-100
lines changed

4 files changed

+13
-100
lines changed

README.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22
Contributors: MILL3 Studio
33
Donate link: https://mill3.studio/
44
Tags: custom
5-
Requires at least: 6.0.0
6-
Tested up to: 6.5
5+
Requires at least: 6.3.0
6+
Tested up to: 6.3
77
License: GPLv2 or later
8+
Requires: PHP8
89
License URI: http://www.gnu.org/licenses/gpl-2.0.html
910

1011
MILL3 WP utils, includes Gutenberg editor sidebar resizer.
1112

1213
== Description ==
1314

14-
TODO
15-
16-
== Screenshots ==
17-
18-
TODO
15+
MILL3 WP utils, includes Gutenberg editor sidebar resizer.
1916

2017
== Changelog ==
2118

@@ -25,7 +22,13 @@ TODO
2522
= 0.0.2 =
2623
* Gutenberg Sidebar : added max-width CSS rule on container
2724

25+
= 0.0.3.x =
26+
* Self-update class era
27+
28+
= 0.0.4 =
29+
* First release
30+
2831
== TODO ==
2932

30-
[ ] class-mill3-wp-utils-updater.php : use plugin-update-checker library https://github.com/YahnisElsts/plugin-update-checker
33+
[X] class-mill3-wp-utils-updater.php : use plugin-update-checker library https://github.com/YahnisElsts/plugin-update-checker
3134
[ ] Built admin interface for settings and enabling components

includes/class-mill3-wp-utils-updater.php

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class Mill3_Wp_Utils_Updater
1010

1111
private $api_url;
1212

13-
private $plugin_version;
14-
1513
private $plugin_file;
1614

1715
private $plugin_slug;
@@ -22,52 +20,16 @@ function __construct()
2220
{
2321
$this->api_url = MILL3_WP_UTILS_PLUGINS_API;
2422
$this->plugin_file = MILL3_WP_UTILS_PLUGIN_FILE;
25-
$this->plugin_version = MILL3_WP_UTILS_VERSION;
2623
$this->plugin_slug = MILL3_WP_UTILS_PLUGIN_SLUG;
2724

2825
$this->updater = PucFactory::buildUpdateChecker(
2926
$this->api_url,
3027
$this->plugin_file,
3128
$this->plugin_slug
3229
);
33-
3430
$this->updater->setBranch('master');
3531
}
3632

37-
/**
38-
* Force the plugin directory to match existing directory structure, Github releases are structured differently, ie: plugin-name-x.x.x.zip
39-
*/
40-
public function upgrader_package_options($options)
41-
{
42-
// get data from the updater instance
43-
$update = $this->updater->getUpdate();
44-
45-
// stop here if the plugin is not the one we want to modify
46-
if (isset($options['hook_extra']['plugin']) && $options['hook_extra']['plugin'] !== $update->filename) {
47-
return $options;
48-
}
49-
50-
$destination = $options['destination'] ?? '';
51-
$package = $options['package'] ?? '';
52-
$dirname = isset($options['hook_extra']['plugin'])
53-
? dirname($options['hook_extra']['plugin'])
54-
: '';
55-
56-
if (empty($dirname) || '.' === $dirname) {
57-
return $options;
58-
}
59-
60-
if ('api.github.com' !== parse_url($package, PHP_URL_HOST)) {
61-
return $options;
62-
}
63-
64-
if (WP_PLUGIN_DIR === $destination) {
65-
$options['destination'] = path_join($destination, $dirname);
66-
}
67-
68-
return $options;
69-
}
70-
7133
public function check_for_update($transient)
7234
{
7335
// Only proceed if the transient contains the 'checked' array
@@ -93,48 +55,4 @@ public function check_for_update($transient)
9355
return $transient;
9456
}
9557

96-
public function plugins_api($false, $action, $args)
97-
{
98-
if ($action !== 'plugin_information' || $args->slug !== MILL3_WP_UTILS_PLUGIN_SLUG) {
99-
return false;
100-
}
101-
102-
// get response from the API
103-
$response = $this->get_remote_version('/infos');
104-
105-
// decode the response
106-
$plugin_info = json_decode(wp_remote_retrieve_body($response), true);
107-
108-
// Populate the plugin information
109-
$result = (object) array(
110-
'name' => $plugin_info['name'],
111-
'slug' => $plugin_info['slug'],
112-
'version' => $plugin_info['version'],
113-
'author' => $plugin_info['author'],
114-
'author_profile' => $plugin_info['author_profile'],
115-
'homepage' => $plugin_info['homepage'],
116-
'download_link' => $plugin_info['download_link'],
117-
// 'trunk' => $plugin_info['trunk'],
118-
// 'requires' => $plugin_info['requires'],
119-
'tested' => $plugin_info['tested'],
120-
'requires_php' => $plugin_info['requires_php'],
121-
'sections' => array(
122-
'description' => $plugin_info['sections']['description'],
123-
'installation' => $plugin_info['sections']['installation'],
124-
'changelog' => $plugin_info['sections']['changelog'],
125-
)
126-
// 'banners' => array(
127-
// 'low' => $plugin_info['banners']['low'],
128-
// 'high' => $plugin_info['banners']['high'],
129-
// ),
130-
);
131-
132-
return $result;
133-
}
134-
135-
public function get_remote_version($uri = '')
136-
{
137-
$response = wp_remote_get($this->api_url . $uri);
138-
return $response;
139-
}
14058
}

includes/class-mill3-wp-utils.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,7 @@ private function set_updates()
158158
$plugin_updates = new \Mill3_Plugins\Utils\Updater\Mill3_Wp_Utils_Updater();
159159

160160
// register the hooks to WP core update process
161-
162-
// after the plugin is downloaded, force the plugin directory to match existing directory structure
163-
// $this->loader->add_filter('upgrader_package_options', $plugin_updates, 'upgrader_package_options', 10, 1);
164-
165-
// check for updates
166161
$this->loader->add_filter('pre_set_site_transient_update_plugins', $plugin_updates, 'check_for_update');
167-
168-
// the 'View details' link in the plugin list
169-
$this->loader->add_filter('plugins_api', $plugin_updates, 'plugins_api', 10, 3);
170162
}
171163

172164
/**

mill3-wp-utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: MILL3 WP Utils
44
* Plugin URI: https://github.com/Mill3/mill3-wp-utils-plugin
55
* Description: MILL3 WP utils, includes Gutenberg editor sidebar resizer.
6-
* Version: 0.0.3.9.1
6+
* Version: 0.0.3.9.2
77
* Author: MILL3 Studio
88
* Author URI: https://mill3.studio/
99
* Tested up to: 6.6.6
@@ -27,7 +27,7 @@
2727
* Start at version 0.0.1 and use SemVer - https://semver.org
2828
* Rename this for your plugin and update it as you release new versions.
2929
*/
30-
define( 'MILL3_WP_UTILS_VERSION', '0.0.3.9.1' );
30+
define( 'MILL3_WP_UTILS_VERSION', '0.0.3.9.2' );
3131

3232

3333
/**

0 commit comments

Comments
 (0)