@@ -13,328 +13,328 @@ |
||
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( |
|
180 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
181 | - esc_html( $version_info->name ), |
|
182 | - esc_url( $changelog_link ), |
|
183 | - esc_html( $version_info->new_version ) |
|
184 | - ); |
|
185 | - } else { |
|
186 | - printf( |
|
187 | - __( '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' ), |
|
188 | - esc_html( $version_info->name ), |
|
189 | - esc_url( $changelog_link ), |
|
190 | - esc_html( $version_info->new_version ), |
|
191 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
192 | - ); |
|
193 | - } |
|
178 | + if ( empty( $version_info->download_link ) ) { |
|
179 | + printf( |
|
180 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
181 | + esc_html( $version_info->name ), |
|
182 | + esc_url( $changelog_link ), |
|
183 | + esc_html( $version_info->new_version ) |
|
184 | + ); |
|
185 | + } else { |
|
186 | + printf( |
|
187 | + __( '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' ), |
|
188 | + esc_html( $version_info->name ), |
|
189 | + esc_url( $changelog_link ), |
|
190 | + esc_html( $version_info->new_version ), |
|
191 | + esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
192 | + ); |
|
193 | + } |
|
194 | 194 | |
195 | - echo '</div></td></tr>'; |
|
196 | - } |
|
197 | - } |
|
195 | + echo '</div></td></tr>'; |
|
196 | + } |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * Updates information on the "View version x.x details" page with custom data. |
|
202 | - * |
|
203 | - * @uses api_request() |
|
204 | - * |
|
205 | - * @param mixed $_data |
|
206 | - * @param string $_action |
|
207 | - * @param object $_args |
|
208 | - * @return object $_data |
|
209 | - */ |
|
210 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
200 | + /** |
|
201 | + * Updates information on the "View version x.x details" page with custom data. |
|
202 | + * |
|
203 | + * @uses api_request() |
|
204 | + * |
|
205 | + * @param mixed $_data |
|
206 | + * @param string $_action |
|
207 | + * @param object $_args |
|
208 | + * @return object $_data |
|
209 | + */ |
|
210 | + function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
211 | 211 | |
212 | 212 | |
213 | - if ( $_action != 'plugin_information' ) { |
|
213 | + if ( $_action != 'plugin_information' ) { |
|
214 | 214 | |
215 | - return $_data; |
|
215 | + return $_data; |
|
216 | 216 | |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
219 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
220 | 220 | |
221 | - return $_data; |
|
221 | + return $_data; |
|
222 | 222 | |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - $to_send = array( |
|
226 | - 'slug' => $this->slug, |
|
227 | - 'is_ssl' => is_ssl(), |
|
228 | - 'fields' => array( |
|
229 | - 'banners' => false, // These will be supported soon hopefully |
|
230 | - 'reviews' => false |
|
231 | - ) |
|
232 | - ); |
|
225 | + $to_send = array( |
|
226 | + 'slug' => $this->slug, |
|
227 | + 'is_ssl' => is_ssl(), |
|
228 | + 'fields' => array( |
|
229 | + 'banners' => false, // These will be supported soon hopefully |
|
230 | + 'reviews' => false |
|
231 | + ) |
|
232 | + ); |
|
233 | 233 | |
234 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
234 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
235 | 235 | |
236 | - if ( false !== $api_response ) { |
|
237 | - $_data = $api_response; |
|
238 | - } |
|
236 | + if ( false !== $api_response ) { |
|
237 | + $_data = $api_response; |
|
238 | + } |
|
239 | 239 | |
240 | - return $_data; |
|
241 | - } |
|
240 | + return $_data; |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | - /** |
|
245 | - * Disable SSL verification in order to prevent download update failures |
|
246 | - * |
|
247 | - * @param array $args |
|
248 | - * @param string $url |
|
249 | - * @return object $array |
|
250 | - */ |
|
251 | - function http_request_args( $args, $url ) { |
|
252 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
253 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | - $args['sslverify'] = false; |
|
255 | - } |
|
256 | - return $args; |
|
257 | - } |
|
244 | + /** |
|
245 | + * Disable SSL verification in order to prevent download update failures |
|
246 | + * |
|
247 | + * @param array $args |
|
248 | + * @param string $url |
|
249 | + * @return object $array |
|
250 | + */ |
|
251 | + function http_request_args( $args, $url ) { |
|
252 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
253 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | + $args['sslverify'] = false; |
|
255 | + } |
|
256 | + return $args; |
|
257 | + } |
|
258 | 258 | |
259 | - /** |
|
260 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
261 | - * |
|
262 | - * @uses get_bloginfo() |
|
263 | - * @uses wp_remote_post() |
|
264 | - * @uses is_wp_error() |
|
265 | - * |
|
266 | - * @param string $_action The requested action. |
|
267 | - * @param array $_data Parameters for the API action. |
|
268 | - * @return false||object |
|
269 | - */ |
|
270 | - private function api_request( $_action, $_data ) { |
|
271 | - |
|
272 | - global $wp_version; |
|
273 | - |
|
274 | - $data = array_merge( $this->api_data, $_data ); |
|
275 | - |
|
276 | - if ( $data['slug'] != $this->slug ) |
|
277 | - return; |
|
278 | - |
|
279 | - if ( empty( $data['license'] ) ) |
|
280 | - return; |
|
281 | - |
|
282 | - if( $this->api_url == home_url() ) { |
|
283 | - return false; // Don't allow a plugin to ping itself |
|
284 | - } |
|
285 | - |
|
286 | - $api_params = array( |
|
287 | - 'edd_action' => 'get_version', |
|
288 | - 'license' => $data['license'], |
|
289 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
290 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
291 | - 'slug' => $data['slug'], |
|
292 | - 'author' => $data['author'], |
|
293 | - 'url' => home_url() |
|
294 | - ); |
|
259 | + /** |
|
260 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
261 | + * |
|
262 | + * @uses get_bloginfo() |
|
263 | + * @uses wp_remote_post() |
|
264 | + * @uses is_wp_error() |
|
265 | + * |
|
266 | + * @param string $_action The requested action. |
|
267 | + * @param array $_data Parameters for the API action. |
|
268 | + * @return false||object |
|
269 | + */ |
|
270 | + private function api_request( $_action, $_data ) { |
|
271 | + |
|
272 | + global $wp_version; |
|
273 | + |
|
274 | + $data = array_merge( $this->api_data, $_data ); |
|
275 | + |
|
276 | + if ( $data['slug'] != $this->slug ) |
|
277 | + return; |
|
278 | + |
|
279 | + if ( empty( $data['license'] ) ) |
|
280 | + return; |
|
281 | + |
|
282 | + if( $this->api_url == home_url() ) { |
|
283 | + return false; // Don't allow a plugin to ping itself |
|
284 | + } |
|
285 | + |
|
286 | + $api_params = array( |
|
287 | + 'edd_action' => 'get_version', |
|
288 | + 'license' => $data['license'], |
|
289 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
290 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
291 | + 'slug' => $data['slug'], |
|
292 | + 'author' => $data['author'], |
|
293 | + 'url' => home_url() |
|
294 | + ); |
|
295 | 295 | |
296 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
296 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
297 | 297 | |
298 | - if ( ! is_wp_error( $request ) ) { |
|
299 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
300 | - } |
|
298 | + if ( ! is_wp_error( $request ) ) { |
|
299 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
300 | + } |
|
301 | 301 | |
302 | - if ( $request && isset( $request->sections ) ) { |
|
303 | - $request->sections = maybe_unserialize( $request->sections ); |
|
304 | - } else { |
|
305 | - $request = false; |
|
306 | - } |
|
302 | + if ( $request && isset( $request->sections ) ) { |
|
303 | + $request->sections = maybe_unserialize( $request->sections ); |
|
304 | + } else { |
|
305 | + $request = false; |
|
306 | + } |
|
307 | 307 | |
308 | - return $request; |
|
309 | - } |
|
308 | + return $request; |
|
309 | + } |
|
310 | 310 | |
311 | - public function show_changelog() { |
|
311 | + public function show_changelog() { |
|
312 | 312 | |
313 | 313 | |
314 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
315 | - return; |
|
316 | - } |
|
314 | + if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
319 | - return; |
|
320 | - } |
|
321 | - |
|
322 | - if( empty( $_REQUEST['slug'] ) ) { |
|
323 | - return; |
|
324 | - } |
|
325 | - |
|
326 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
327 | - wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
328 | - } |
|
329 | - |
|
330 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
331 | - |
|
332 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
333 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - exit; |
|
338 | - } |
|
318 | + if( empty( $_REQUEST['plugin'] ) ) { |
|
319 | + return; |
|
320 | + } |
|
321 | + |
|
322 | + if( empty( $_REQUEST['slug'] ) ) { |
|
323 | + return; |
|
324 | + } |
|
325 | + |
|
326 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
327 | + wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
328 | + } |
|
329 | + |
|
330 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
331 | + |
|
332 | + if( $response && isset( $response->sections['changelog'] ) ) { |
|
333 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + exit; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Customer (Donors) |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Admin/Customers |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Customer (Donors) |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Admin/Customers |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * View Donation Details |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Admin/Payments |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * View Donation Details |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Admin/Payments |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Donor Reports Table Class |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Admin/Reports |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Donor Reports Table Class |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Admin/Reports |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | case 'num_purchases' : |
175 | 175 | $value = '<a href="' . |
176 | - admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
177 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
176 | + admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
177 | + ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case 'amount_spent' : |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Donors Export Class |
|
4 | - * |
|
5 | - * This class handles donor export |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Admin/Reports |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.0 |
|
12 | - */ |
|
3 | + * Donors Export Class |
|
4 | + * |
|
5 | + * This class handles donor export |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Admin/Reports |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Earnings Export Class |
|
4 | - * |
|
5 | - * This class handles earnings export |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Admin/Reports |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.0 |
|
12 | - */ |
|
3 | + * Earnings Export Class |
|
4 | + * |
|
5 | + * This class handles earnings export |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Admin/Reports |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Payments Export Class |
|
4 | - * |
|
5 | - * This class handles payment export |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Admin/Reports |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.4.4 |
|
12 | - */ |
|
3 | + * Payments Export Class |
|
4 | + * |
|
5 | + * This class handles payment export |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Admin/Reports |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.4.4 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Export Class |
|
4 | - * |
|
5 | - * This is the base class for all export methods. Each data export type (donors, payments, etc) extend this class |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Admin/Reports |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.0 |
|
12 | - */ |
|
3 | + * Export Class |
|
4 | + * |
|
5 | + * This is the base class for all export methods. Each data export type (donors, payments, etc) extend this class |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Admin/Reports |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Download Reports Table Class |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Admin/Reports |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Download Reports Table Class |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Admin/Reports |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |