@@ -248,8 +248,8 @@ |
||
248 | 248 | |
249 | 249 | // do not reindex array! |
250 | 250 | $field['options'] = array( |
251 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_html( '- Select -', 'give' ) ), |
|
252 | - ) + $field['options']; |
|
251 | + '' => ( $field['placeholder'] ? $field['placeholder'] : esc_html( '- Select -', 'give' ) ), |
|
252 | + ) + $field['options']; |
|
253 | 253 | |
254 | 254 | foreach ( $field['options'] as $value => $text ) { |
255 | 255 | $new_listbox['values'][] = array( |
@@ -13,330 +13,330 @@ |
||
13 | 13 | * @version 1.6 |
14 | 14 | */ |
15 | 15 | class EDD_SL_Plugin_Updater { |
16 | - private $api_url = ''; |
|
17 | - private $api_data = array(); |
|
18 | - private $name = ''; |
|
19 | - private $slug = ''; |
|
20 | - |
|
21 | - /** |
|
22 | - * Class constructor. |
|
23 | - * |
|
24 | - * @uses plugin_basename() |
|
25 | - * @uses hook() |
|
26 | - * |
|
27 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | - * @param string $_plugin_file Path to the plugin file. |
|
29 | - * @param array $_api_data Optional data to send with API calls. |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
34 | - $this->api_data = $_api_data; |
|
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | - $this->version = $_api_data['version']; |
|
38 | - |
|
39 | - // Set up hooks. |
|
40 | - $this->init(); |
|
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Set up WordPress filters to hook into WP's update process. |
|
46 | - * |
|
47 | - * @uses add_filter() |
|
48 | - * |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function init() { |
|
16 | + private $api_url = ''; |
|
17 | + private $api_data = array(); |
|
18 | + private $name = ''; |
|
19 | + private $slug = ''; |
|
20 | + |
|
21 | + /** |
|
22 | + * Class constructor. |
|
23 | + * |
|
24 | + * @uses plugin_basename() |
|
25 | + * @uses hook() |
|
26 | + * |
|
27 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | + * @param string $_plugin_file Path to the plugin file. |
|
29 | + * @param array $_api_data Optional data to send with API calls. |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | + $this->api_url = trailingslashit( $_api_url ); |
|
34 | + $this->api_data = $_api_data; |
|
35 | + $this->name = plugin_basename( $_plugin_file ); |
|
36 | + $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | + $this->version = $_api_data['version']; |
|
38 | + |
|
39 | + // Set up hooks. |
|
40 | + $this->init(); |
|
41 | + add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Set up WordPress filters to hook into WP's update process. |
|
46 | + * |
|
47 | + * @uses add_filter() |
|
48 | + * |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function init() { |
|
52 | 52 | |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
55 | 55 | |
56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | - } |
|
56 | + add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | - * |
|
62 | - * This function dives into the update API just when WordPress creates its update array, |
|
63 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | - * |
|
67 | - * @uses api_request() |
|
68 | - * |
|
69 | - * @param array $_transient_data Update array build by WordPress. |
|
70 | - * @return array Modified update array with custom plugin data. |
|
71 | - */ |
|
72 | - function check_update( $_transient_data ) { |
|
59 | + /** |
|
60 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | + * |
|
62 | + * This function dives into the update API just when WordPress creates its update array, |
|
63 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | + * |
|
67 | + * @uses api_request() |
|
68 | + * |
|
69 | + * @param array $_transient_data Update array build by WordPress. |
|
70 | + * @return array Modified update array with custom plugin data. |
|
71 | + */ |
|
72 | + function check_update( $_transient_data ) { |
|
73 | 73 | |
74 | - global $pagenow; |
|
74 | + global $pagenow; |
|
75 | 75 | |
76 | - if( ! is_object( $_transient_data ) ) { |
|
77 | - $_transient_data = new stdClass; |
|
78 | - } |
|
76 | + if( ! is_object( $_transient_data ) ) { |
|
77 | + $_transient_data = new stdClass; |
|
78 | + } |
|
79 | 79 | |
80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | - return $_transient_data; |
|
82 | - } |
|
80 | + if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | + return $_transient_data; |
|
82 | + } |
|
83 | 83 | |
84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
85 | 85 | |
86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
87 | 87 | |
88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
89 | 89 | |
90 | - $this->did_check = true; |
|
90 | + $this->did_check = true; |
|
91 | 91 | |
92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
92 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
93 | 93 | |
94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
94 | + $_transient_data->response[ $this->name ] = $version_info; |
|
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - $_transient_data->last_checked = time(); |
|
99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
98 | + $_transient_data->last_checked = time(); |
|
99 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | 100 | |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - return $_transient_data; |
|
106 | - } |
|
105 | + return $_transient_data; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | - * |
|
111 | - * @param string $file |
|
112 | - * @param array $plugin |
|
113 | - */ |
|
114 | - public function show_update_notification( $file, $plugin ) { |
|
108 | + /** |
|
109 | + * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | + * |
|
111 | + * @param string $file |
|
112 | + * @param array $plugin |
|
113 | + */ |
|
114 | + public function show_update_notification( $file, $plugin ) { |
|
115 | 115 | |
116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | - return; |
|
118 | - } |
|
116 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | + return; |
|
118 | + } |
|
119 | 119 | |
120 | - if( ! is_multisite() ) { |
|
121 | - return; |
|
122 | - } |
|
120 | + if( ! is_multisite() ) { |
|
121 | + return; |
|
122 | + } |
|
123 | 123 | |
124 | - if ( $this->name != $file ) { |
|
125 | - return; |
|
126 | - } |
|
124 | + if ( $this->name != $file ) { |
|
125 | + return; |
|
126 | + } |
|
127 | 127 | |
128 | - // Remove our filter on the site transient |
|
129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
128 | + // Remove our filter on the site transient |
|
129 | + remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
130 | 130 | |
131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
131 | + $update_cache = get_site_transient( 'update_plugins' ); |
|
132 | 132 | |
133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
133 | + if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
134 | 134 | |
135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | - $version_info = get_transient( $cache_key ); |
|
135 | + $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | + $version_info = get_transient( $cache_key ); |
|
137 | 137 | |
138 | - if( false === $version_info ) { |
|
138 | + if( false === $version_info ) { |
|
139 | 139 | |
140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
140 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
141 | 141 | |
142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
143 | - } |
|
142 | + set_transient( $cache_key, $version_info, 3600 ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - if( ! is_object( $version_info ) ) { |
|
147 | - return; |
|
148 | - } |
|
146 | + if( ! is_object( $version_info ) ) { |
|
147 | + return; |
|
148 | + } |
|
149 | 149 | |
150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
150 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
151 | 151 | |
152 | - $update_cache->response[ $this->name ] = $version_info; |
|
152 | + $update_cache->response[ $this->name ] = $version_info; |
|
153 | 153 | |
154 | - } |
|
154 | + } |
|
155 | 155 | |
156 | - $update_cache->last_checked = time(); |
|
157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
156 | + $update_cache->last_checked = time(); |
|
157 | + $update_cache->checked[ $this->name ] = $this->version; |
|
158 | 158 | |
159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
159 | + set_site_transient( 'update_plugins', $update_cache ); |
|
160 | 160 | |
161 | - } else { |
|
161 | + } else { |
|
162 | 162 | |
163 | - $version_info = $update_cache->response[ $this->name ]; |
|
163 | + $version_info = $update_cache->response[ $this->name ]; |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - // Restore our filter |
|
168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
167 | + // Restore our filter |
|
168 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
169 | 169 | |
170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
170 | + if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
171 | 171 | |
172 | - // build a plugin list row, with update notification |
|
173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
172 | + // build a plugin list row, with update notification |
|
173 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | + echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
175 | 175 | |
176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
176 | + $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
177 | 177 | |
178 | - if ( empty( $version_info->download_link ) ) { |
|
179 | - printf( |
|
178 | + if ( empty( $version_info->download_link ) ) { |
|
179 | + printf( |
|
180 | 180 | /* translators: 1: name 2: changelog URL 3: version */ |
181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
182 | - esc_html( $version_info->name ), |
|
183 | - esc_url( $changelog_link ), |
|
184 | - esc_html( $version_info->new_version ) |
|
185 | - ); |
|
186 | - } else { |
|
187 | - printf( |
|
181 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
182 | + esc_html( $version_info->name ), |
|
183 | + esc_url( $changelog_link ), |
|
184 | + esc_html( $version_info->new_version ) |
|
185 | + ); |
|
186 | + } else { |
|
187 | + printf( |
|
188 | 188 | /* translators: 1: name 2: changelog URL 3: version 4: update URL */ |
189 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
190 | - esc_html( $version_info->name ), |
|
191 | - esc_url( $changelog_link ), |
|
192 | - esc_html( $version_info->new_version ), |
|
193 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
194 | - ); |
|
195 | - } |
|
196 | - |
|
197 | - echo '</div></td></tr>'; |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * Updates information on the "View version x.x details" page with custom data. |
|
204 | - * |
|
205 | - * @uses api_request() |
|
206 | - * |
|
207 | - * @param mixed $_data |
|
208 | - * @param string $_action |
|
209 | - * @param object $_args |
|
210 | - * @return object $_data |
|
211 | - */ |
|
212 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
213 | - |
|
214 | - |
|
215 | - if ( $_action != 'plugin_information' ) { |
|
216 | - |
|
217 | - return $_data; |
|
218 | - |
|
219 | - } |
|
220 | - |
|
221 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
222 | - |
|
223 | - return $_data; |
|
224 | - |
|
225 | - } |
|
226 | - |
|
227 | - $to_send = array( |
|
228 | - 'slug' => $this->slug, |
|
229 | - 'is_ssl' => is_ssl(), |
|
230 | - 'fields' => array( |
|
231 | - 'banners' => false, // These will be supported soon hopefully |
|
232 | - 'reviews' => false |
|
233 | - ) |
|
234 | - ); |
|
235 | - |
|
236 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
237 | - |
|
238 | - if ( false !== $api_response ) { |
|
239 | - $_data = $api_response; |
|
240 | - } |
|
241 | - |
|
242 | - return $_data; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * Disable SSL verification in order to prevent download update failures |
|
248 | - * |
|
249 | - * @param array $args |
|
250 | - * @param string $url |
|
251 | - * @return object $array |
|
252 | - */ |
|
253 | - function http_request_args( $args, $url ) { |
|
254 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
255 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
256 | - $args['sslverify'] = false; |
|
257 | - } |
|
258 | - return $args; |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
263 | - * |
|
264 | - * @uses get_bloginfo() |
|
265 | - * @uses wp_remote_post() |
|
266 | - * @uses is_wp_error() |
|
267 | - * |
|
268 | - * @param string $_action The requested action. |
|
269 | - * @param array $_data Parameters for the API action. |
|
270 | - * @return false||object |
|
271 | - */ |
|
272 | - private function api_request( $_action, $_data ) { |
|
273 | - |
|
274 | - global $wp_version; |
|
275 | - |
|
276 | - $data = array_merge( $this->api_data, $_data ); |
|
277 | - |
|
278 | - if ( $data['slug'] != $this->slug ) |
|
279 | - return; |
|
280 | - |
|
281 | - if ( empty( $data['license'] ) ) |
|
282 | - return; |
|
283 | - |
|
284 | - if( $this->api_url == home_url() ) { |
|
285 | - return false; // Don't allow a plugin to ping itself |
|
286 | - } |
|
287 | - |
|
288 | - $api_params = array( |
|
289 | - 'edd_action' => 'get_version', |
|
290 | - 'license' => $data['license'], |
|
291 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
292 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
293 | - 'slug' => $data['slug'], |
|
294 | - 'author' => $data['author'], |
|
295 | - 'url' => home_url() |
|
296 | - ); |
|
189 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
190 | + esc_html( $version_info->name ), |
|
191 | + esc_url( $changelog_link ), |
|
192 | + esc_html( $version_info->new_version ), |
|
193 | + esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
194 | + ); |
|
195 | + } |
|
196 | + |
|
197 | + echo '</div></td></tr>'; |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * Updates information on the "View version x.x details" page with custom data. |
|
204 | + * |
|
205 | + * @uses api_request() |
|
206 | + * |
|
207 | + * @param mixed $_data |
|
208 | + * @param string $_action |
|
209 | + * @param object $_args |
|
210 | + * @return object $_data |
|
211 | + */ |
|
212 | + function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
213 | + |
|
214 | + |
|
215 | + if ( $_action != 'plugin_information' ) { |
|
216 | + |
|
217 | + return $_data; |
|
218 | + |
|
219 | + } |
|
220 | + |
|
221 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
222 | + |
|
223 | + return $_data; |
|
224 | + |
|
225 | + } |
|
226 | + |
|
227 | + $to_send = array( |
|
228 | + 'slug' => $this->slug, |
|
229 | + 'is_ssl' => is_ssl(), |
|
230 | + 'fields' => array( |
|
231 | + 'banners' => false, // These will be supported soon hopefully |
|
232 | + 'reviews' => false |
|
233 | + ) |
|
234 | + ); |
|
235 | + |
|
236 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
237 | + |
|
238 | + if ( false !== $api_response ) { |
|
239 | + $_data = $api_response; |
|
240 | + } |
|
241 | + |
|
242 | + return $_data; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * Disable SSL verification in order to prevent download update failures |
|
248 | + * |
|
249 | + * @param array $args |
|
250 | + * @param string $url |
|
251 | + * @return object $array |
|
252 | + */ |
|
253 | + function http_request_args( $args, $url ) { |
|
254 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
255 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
256 | + $args['sslverify'] = false; |
|
257 | + } |
|
258 | + return $args; |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
263 | + * |
|
264 | + * @uses get_bloginfo() |
|
265 | + * @uses wp_remote_post() |
|
266 | + * @uses is_wp_error() |
|
267 | + * |
|
268 | + * @param string $_action The requested action. |
|
269 | + * @param array $_data Parameters for the API action. |
|
270 | + * @return false||object |
|
271 | + */ |
|
272 | + private function api_request( $_action, $_data ) { |
|
273 | + |
|
274 | + global $wp_version; |
|
275 | + |
|
276 | + $data = array_merge( $this->api_data, $_data ); |
|
277 | + |
|
278 | + if ( $data['slug'] != $this->slug ) |
|
279 | + return; |
|
280 | + |
|
281 | + if ( empty( $data['license'] ) ) |
|
282 | + return; |
|
283 | + |
|
284 | + if( $this->api_url == home_url() ) { |
|
285 | + return false; // Don't allow a plugin to ping itself |
|
286 | + } |
|
287 | + |
|
288 | + $api_params = array( |
|
289 | + 'edd_action' => 'get_version', |
|
290 | + 'license' => $data['license'], |
|
291 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
292 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
293 | + 'slug' => $data['slug'], |
|
294 | + 'author' => $data['author'], |
|
295 | + 'url' => home_url() |
|
296 | + ); |
|
297 | 297 | |
298 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
298 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
299 | 299 | |
300 | - if ( ! is_wp_error( $request ) ) { |
|
301 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
302 | - } |
|
300 | + if ( ! is_wp_error( $request ) ) { |
|
301 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
302 | + } |
|
303 | 303 | |
304 | - if ( $request && isset( $request->sections ) ) { |
|
305 | - $request->sections = maybe_unserialize( $request->sections ); |
|
306 | - } else { |
|
307 | - $request = false; |
|
308 | - } |
|
304 | + if ( $request && isset( $request->sections ) ) { |
|
305 | + $request->sections = maybe_unserialize( $request->sections ); |
|
306 | + } else { |
|
307 | + $request = false; |
|
308 | + } |
|
309 | 309 | |
310 | - return $request; |
|
311 | - } |
|
310 | + return $request; |
|
311 | + } |
|
312 | 312 | |
313 | - public function show_changelog() { |
|
313 | + public function show_changelog() { |
|
314 | 314 | |
315 | 315 | |
316 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
317 | - return; |
|
318 | - } |
|
316 | + if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
317 | + return; |
|
318 | + } |
|
319 | 319 | |
320 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
321 | - return; |
|
322 | - } |
|
323 | - |
|
324 | - if( empty( $_REQUEST['slug'] ) ) { |
|
325 | - return; |
|
326 | - } |
|
327 | - |
|
328 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
329 | - wp_die( esc_html( 'You do not have permission to install plugin updates.', 'edd' ), esc_html( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
330 | - } |
|
331 | - |
|
332 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
333 | - |
|
334 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
335 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - exit; |
|
340 | - } |
|
320 | + if( empty( $_REQUEST['plugin'] ) ) { |
|
321 | + return; |
|
322 | + } |
|
323 | + |
|
324 | + if( empty( $_REQUEST['slug'] ) ) { |
|
325 | + return; |
|
326 | + } |
|
327 | + |
|
328 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
329 | + wp_die( esc_html( 'You do not have permission to install plugin updates.', 'edd' ), esc_html( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
330 | + } |
|
331 | + |
|
332 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
333 | + |
|
334 | + if( $response && isset( $response->sections['changelog'] ) ) { |
|
335 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + exit; |
|
340 | + } |
|
341 | 341 | |
342 | 342 | } |