@@ -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}
0 commit comments