@@ -232,7 +232,7 @@ |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @access public |
234 | 234 | * |
235 | - * @return bool |
|
235 | + * @return null|boolean |
|
236 | 236 | */ |
237 | 237 | public function check_for_token() { |
238 | 238 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | */ |
121 | 121 | if ( |
122 | 122 | is_user_logged_in() |
123 | - || ! give_is_setting_enabled( give_get_option( 'email_access' ) ) |
|
123 | + || ! give_is_setting_enabled(give_get_option('email_access')) |
|
124 | 124 | || is_admin() |
125 | 125 | ) { |
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Are db columns setup? |
130 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
131 | - if ( empty( $is_setup ) ) { |
|
130 | + $is_setup = give_get_option('email_access_installed'); |
|
131 | + if (empty($is_setup)) { |
|
132 | 132 | $this->create_columns(); |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Timeouts. |
136 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
137 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
136 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
137 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
138 | 138 | |
139 | 139 | // Setup login. |
140 | 140 | $this->check_for_token(); |
141 | 141 | |
142 | - if ( $this->token_exists ) { |
|
143 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
144 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
145 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
142 | + if ($this->token_exists) { |
|
143 | + add_filter('give_can_view_receipt', '__return_true'); |
|
144 | + add_filter('give_user_pending_verification', '__return_false'); |
|
145 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
@@ -157,25 +157,25 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return bool |
159 | 159 | */ |
160 | - public function can_send_email( $customer_id ) { |
|
160 | + public function can_send_email($customer_id) { |
|
161 | 161 | /* @var WPDB $wpdb */ |
162 | 162 | global $wpdb; |
163 | 163 | |
164 | 164 | // Prevent multiple emails within X minutes |
165 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
165 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
166 | 166 | |
167 | 167 | // Does a user row exist? |
168 | 168 | $exists = (int) $wpdb->get_var( |
169 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
169 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
170 | 170 | ); |
171 | 171 | |
172 | - if ( 0 < $exists ) { |
|
172 | + if (0 < $exists) { |
|
173 | 173 | $row_id = (int) $wpdb->get_var( |
174 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
174 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
175 | 175 | ); |
176 | 176 | |
177 | - if ( $row_id < 1 ) { |
|
178 | - give_set_error( 'give_email_access_attempts_exhausted', __( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
177 | + if ($row_id < 1) { |
|
178 | + give_set_error('give_email_access_attempts_exhausted', __('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
179 | 179 | |
180 | 180 | return false; |
181 | 181 | } |
@@ -195,34 +195,34 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - public function send_email( $customer_id, $email ) { |
|
198 | + public function send_email($customer_id, $email) { |
|
199 | 199 | |
200 | - $verify_key = wp_generate_password( 20, false ); |
|
200 | + $verify_key = wp_generate_password(20, false); |
|
201 | 201 | |
202 | 202 | // Generate a new verify key |
203 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
203 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
204 | 204 | |
205 | 205 | // Get the donation history page |
206 | - $page_id = give_get_option( 'history_page' ); |
|
206 | + $page_id = give_get_option('history_page'); |
|
207 | 207 | |
208 | - $access_url = add_query_arg( array( |
|
208 | + $access_url = add_query_arg(array( |
|
209 | 209 | 'give_nl' => $verify_key, |
210 | - ), get_permalink( $page_id ) ); |
|
210 | + ), get_permalink($page_id)); |
|
211 | 211 | |
212 | 212 | // Nice subject and message. |
213 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( __( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
213 | + $subject = apply_filters('give_email_access_token_subject', sprintf(__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
214 | 214 | |
215 | - $message = __( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
216 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . __( 'Access Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
215 | + $message = __('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
216 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.__('Access Donation Details »', 'give').'</a>'."\n\n"; |
|
217 | 217 | $message .= "\n\n"; |
218 | - $message .= __( 'Sincerely,', 'give' ) . "\n"; |
|
219 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
218 | + $message .= __('Sincerely,', 'give')."\n"; |
|
219 | + $message .= get_bloginfo('name')."\n"; |
|
220 | 220 | |
221 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
221 | + $message = apply_filters('give_email_access_token_message', $message); |
|
222 | 222 | |
223 | 223 | // Send the email. |
224 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', __( 'Your Access Link', 'give' ) ) ); |
|
225 | - Give()->emails->send( $email, $subject, $message ); |
|
224 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', __('Your Access Link', 'give'))); |
|
225 | + Give()->emails->send($email, $subject, $message); |
|
226 | 226 | |
227 | 227 | } |
228 | 228 | |
@@ -236,26 +236,26 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function check_for_token() { |
238 | 238 | |
239 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
239 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
240 | 240 | |
241 | 241 | // Check for cookie. |
242 | - if ( empty( $token ) ) { |
|
243 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
242 | + if (empty($token)) { |
|
243 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Must have a token. |
247 | - if ( ! empty( $token ) ) { |
|
247 | + if ( ! empty($token)) { |
|
248 | 248 | |
249 | - if ( ! $this->is_valid_token( $token ) ) { |
|
250 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
249 | + if ( ! $this->is_valid_token($token)) { |
|
250 | + if ( ! $this->is_valid_verify_key($token)) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | $this->token_exists = true; |
256 | 256 | // Set cookie. |
257 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
258 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
257 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
258 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
259 | 259 | |
260 | 260 | return true; |
261 | 261 | } |
@@ -271,26 +271,26 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | - public function is_valid_token( $token ) { |
|
274 | + public function is_valid_token($token) { |
|
275 | 275 | |
276 | 276 | global $wpdb; |
277 | 277 | |
278 | 278 | // Make sure token isn't expired. |
279 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
279 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
280 | 280 | |
281 | 281 | $email = $wpdb->get_var( |
282 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
282 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
283 | 283 | ); |
284 | 284 | |
285 | - if ( ! empty( $email ) ) { |
|
285 | + if ( ! empty($email)) { |
|
286 | 286 | $this->token_email = $email; |
287 | 287 | $this->token = $token; |
288 | 288 | return true; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set error only if email access form isn't being submitted |
292 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
293 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', __( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
292 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
293 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', __('Your access token has expired. Please request a new one below:', 'give'))); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | return false; |
@@ -309,25 +309,25 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return void |
311 | 311 | */ |
312 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
312 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
313 | 313 | global $wpdb; |
314 | 314 | |
315 | - $now = date( 'Y-m-d H:i:s' ); |
|
315 | + $now = date('Y-m-d H:i:s'); |
|
316 | 316 | |
317 | 317 | // Insert or update? |
318 | 318 | $row_id = (int) $wpdb->get_var( |
319 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
319 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
320 | 320 | ); |
321 | 321 | |
322 | 322 | // Update. |
323 | - if ( ! empty( $row_id ) ) { |
|
323 | + if ( ! empty($row_id)) { |
|
324 | 324 | $wpdb->query( |
325 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
325 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
326 | 326 | ); |
327 | 327 | } // Insert. |
328 | 328 | else { |
329 | 329 | $wpdb->query( |
330 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
330 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
331 | 331 | ); |
332 | 332 | } |
333 | 333 | } |
@@ -342,21 +342,21 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return bool |
344 | 344 | */ |
345 | - public function is_valid_verify_key( $token ) { |
|
345 | + public function is_valid_verify_key($token) { |
|
346 | 346 | /* @var WPDB $wpdb */ |
347 | 347 | global $wpdb; |
348 | 348 | |
349 | 349 | // See if the verify_key exists. |
350 | 350 | $row = $wpdb->get_row( |
351 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
351 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
352 | 352 | ); |
353 | 353 | |
354 | - $now = date( 'Y-m-d H:i:s' ); |
|
354 | + $now = date('Y-m-d H:i:s'); |
|
355 | 355 | |
356 | 356 | // Set token and remove verify key. |
357 | - if ( ! empty( $row ) ) { |
|
357 | + if ( ! empty($row)) { |
|
358 | 358 | $wpdb->query( |
359 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
359 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
360 | 360 | ); |
361 | 361 | |
362 | 362 | $this->token_email = $row->email; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return mixed |
382 | 382 | */ |
383 | - public function users_donations_args( $args ) { |
|
383 | + public function users_donations_args($args) { |
|
384 | 384 | $args['user'] = $this->token_email; |
385 | 385 | |
386 | 386 | return $args; |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | global $wpdb; |
402 | 402 | |
403 | 403 | // Create columns in customers table |
404 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
404 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
405 | 405 | |
406 | 406 | // Columns added properly |
407 | - if ( $query ) { |
|
408 | - give_update_option( 'email_access_installed', 1 ); |
|
407 | + if ($query) { |
|
408 | + give_update_option('email_access_installed', 1); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | * @uses api_request() |
78 | 78 | * |
79 | 79 | * @param array $_transient_data Update array build by WordPress. |
80 | - * @return array Modified update array with custom plugin data. |
|
80 | + * @return stdClass Modified update array with custom plugin data. |
|
81 | 81 | */ |
82 | 82 | public function check_update( $_transient_data ) { |
83 | 83 |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | /** |
7 | 9 | * Allows plugins to use their own update API. |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * Allows plugins to use their own update API. |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param string $_plugin_file Path to the plugin file. |
30 | 30 | * @param array $_api_data Optional data to send with API calls. |
31 | 31 | */ |
32 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
32 | + public function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
33 | 33 | |
34 | 34 | global $edd_plugin_data; |
35 | 35 | |
36 | - $this->api_url = trailingslashit( $_api_url ); |
|
36 | + $this->api_url = trailingslashit($_api_url); |
|
37 | 37 | $this->api_data = $_api_data; |
38 | - $this->name = plugin_basename( $_plugin_file ); |
|
39 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
38 | + $this->name = plugin_basename($_plugin_file); |
|
39 | + $this->slug = basename($_plugin_file, '.php'); |
|
40 | 40 | $this->version = $_api_data['version']; |
41 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
42 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
43 | - $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
41 | + $this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : false; |
|
42 | + $this->beta = ! empty($this->api_data['beta']) ? true : false; |
|
43 | + $this->cache_key = md5(serialize($this->slug.$this->api_data['license'].$this->beta)); |
|
44 | 44 | |
45 | - $edd_plugin_data[ $this->slug ] = $this->api_data; |
|
45 | + $edd_plugin_data[$this->slug] = $this->api_data; |
|
46 | 46 | |
47 | 47 | // Set up hooks. |
48 | 48 | $this->init(); |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function init() { |
60 | 60 | |
61 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
62 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
63 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); |
|
64 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
65 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
61 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
62 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
63 | + remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10); |
|
64 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
65 | + add_action('admin_init', array($this, 'show_changelog')); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | |
@@ -79,41 +79,41 @@ discard block |
||
79 | 79 | * @param array $_transient_data Update array build by WordPress. |
80 | 80 | * @return array Modified update array with custom plugin data. |
81 | 81 | */ |
82 | - public function check_update( $_transient_data ) { |
|
82 | + public function check_update($_transient_data) { |
|
83 | 83 | |
84 | 84 | global $pagenow; |
85 | 85 | |
86 | - if ( ! is_object( $_transient_data ) ) { |
|
86 | + if ( ! is_object($_transient_data)) { |
|
87 | 87 | $_transient_data = new stdClass; |
88 | 88 | } |
89 | 89 | |
90 | - if ( 'plugins.php' == $pagenow && is_multisite() ) { |
|
90 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
91 | 91 | return $_transient_data; |
92 | 92 | } |
93 | 93 | |
94 | - if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { |
|
94 | + if ( ! empty($_transient_data->response) && ! empty($_transient_data->response[$this->name]) && false === $this->wp_override) { |
|
95 | 95 | return $_transient_data; |
96 | 96 | } |
97 | 97 | |
98 | 98 | $version_info = $this->get_cached_version_info(); |
99 | 99 | |
100 | - if ( false === $version_info ) { |
|
101 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); |
|
100 | + if (false === $version_info) { |
|
101 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta)); |
|
102 | 102 | |
103 | - $this->set_version_info_cache( $version_info ); |
|
103 | + $this->set_version_info_cache($version_info); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
107 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
107 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
108 | 108 | |
109 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
109 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
110 | 110 | |
111 | - $_transient_data->response[ $this->name ] = $version_info; |
|
111 | + $_transient_data->response[$this->name] = $version_info; |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - $_transient_data->last_checked = current_time( 'timestamp' ); |
|
116 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
115 | + $_transient_data->last_checked = current_time('timestamp'); |
|
116 | + $_transient_data->checked[$this->name] = $this->version; |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -126,97 +126,97 @@ discard block |
||
126 | 126 | * @param string $file |
127 | 127 | * @param array $plugin |
128 | 128 | */ |
129 | - public function show_update_notification( $file, $plugin ) { |
|
129 | + public function show_update_notification($file, $plugin) { |
|
130 | 130 | |
131 | - if ( is_network_admin() ) { |
|
131 | + if (is_network_admin()) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
135 | + if ( ! current_user_can('update_plugins')) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | - if( ! is_multisite() ) { |
|
139 | + if ( ! is_multisite()) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | - if ( $this->name != $file ) { |
|
143 | + if ($this->name != $file) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Remove our filter on the site transient |
148 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
148 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
149 | 149 | |
150 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
150 | + $update_cache = get_site_transient('update_plugins'); |
|
151 | 151 | |
152 | - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
|
152 | + $update_cache = is_object($update_cache) ? $update_cache : new stdClass(); |
|
153 | 153 | |
154 | - if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
154 | + if (empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
155 | 155 | |
156 | 156 | $version_info = $this->get_cached_version_info(); |
157 | 157 | |
158 | - if ( false === $version_info ) { |
|
159 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); |
|
158 | + if (false === $version_info) { |
|
159 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta)); |
|
160 | 160 | |
161 | - $this->set_version_info_cache( $version_info ); |
|
161 | + $this->set_version_info_cache($version_info); |
|
162 | 162 | } |
163 | 163 | |
164 | - if ( ! is_object( $version_info ) ) { |
|
164 | + if ( ! is_object($version_info)) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
168 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
169 | 169 | |
170 | - $update_cache->response[ $this->name ] = $version_info; |
|
170 | + $update_cache->response[$this->name] = $version_info; |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | - $update_cache->last_checked = current_time( 'timestamp' ); |
|
175 | - $update_cache->checked[ $this->name ] = $this->version; |
|
174 | + $update_cache->last_checked = current_time('timestamp'); |
|
175 | + $update_cache->checked[$this->name] = $this->version; |
|
176 | 176 | |
177 | - set_site_transient( 'update_plugins', $update_cache ); |
|
177 | + set_site_transient('update_plugins', $update_cache); |
|
178 | 178 | |
179 | 179 | } else { |
180 | 180 | |
181 | - $version_info = $update_cache->response[ $this->name ]; |
|
181 | + $version_info = $update_cache->response[$this->name]; |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | |
185 | 185 | // Restore our filter |
186 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
186 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
187 | 187 | |
188 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
188 | + if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
189 | 189 | |
190 | 190 | // build a plugin list row, with update notification |
191 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
191 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
192 | 192 | # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
193 | - echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">'; |
|
193 | + echo '<tr class="plugin-update-tr" id="'.$this->slug.'-update" data-slug="'.$this->slug.'" data-plugin="'.$this->slug.'/'.$file.'">'; |
|
194 | 194 | echo '<td colspan="3" class="plugin-update colspanchange">'; |
195 | 195 | echo '<div class="update-message notice inline notice-warning notice-alt">'; |
196 | 196 | |
197 | - $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' ); |
|
197 | + $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'); |
|
198 | 198 | |
199 | - if ( empty( $version_info->download_link ) ) { |
|
199 | + if (empty($version_info->download_link)) { |
|
200 | 200 | printf( |
201 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give' ), |
|
202 | - esc_html( $version_info->name ), |
|
203 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
|
204 | - esc_html( $version_info->new_version ), |
|
201 | + __('There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give'), |
|
202 | + esc_html($version_info->name), |
|
203 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">', |
|
204 | + esc_html($version_info->new_version), |
|
205 | 205 | '</a>' |
206 | 206 | ); |
207 | 207 | } else { |
208 | 208 | printf( |
209 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give' ), |
|
210 | - esc_html( $version_info->name ), |
|
211 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
|
212 | - esc_html( $version_info->new_version ), |
|
209 | + __('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give'), |
|
210 | + esc_html($version_info->name), |
|
211 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">', |
|
212 | + esc_html($version_info->new_version), |
|
213 | 213 | '</a>', |
214 | - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">', |
|
214 | + '<a href="'.esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)).'">', |
|
215 | 215 | '</a>' |
216 | 216 | ); |
217 | 217 | } |
218 | 218 | |
219 | - do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); |
|
219 | + do_action("in_plugin_update_message-{$file}", $plugin, $version_info); |
|
220 | 220 | |
221 | 221 | echo '</div></td></tr>'; |
222 | 222 | } |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | * @param object $_args |
233 | 233 | * @return object $_data |
234 | 234 | */ |
235 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
235 | + public function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
236 | 236 | |
237 | - if ( $_action != 'plugin_information' ) { |
|
237 | + if ($_action != 'plugin_information') { |
|
238 | 238 | |
239 | 239 | return $_data; |
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
243 | + if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
244 | 244 | |
245 | 245 | return $_data; |
246 | 246 | |
@@ -255,20 +255,20 @@ discard block |
||
255 | 255 | ) |
256 | 256 | ); |
257 | 257 | |
258 | - $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
258 | + $cache_key = 'edd_api_request_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta)); |
|
259 | 259 | |
260 | 260 | // Get the transient where we store the api request for this plugin for 24 hours |
261 | - $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); |
|
261 | + $edd_api_request_transient = $this->get_cached_version_info($cache_key); |
|
262 | 262 | |
263 | 263 | //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now. |
264 | - if ( empty( $edd_api_request_transient ) ) { |
|
264 | + if (empty($edd_api_request_transient)) { |
|
265 | 265 | |
266 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
266 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
267 | 267 | |
268 | 268 | // Expires in 3 hours |
269 | - $this->set_version_info_cache( $api_response, $cache_key ); |
|
269 | + $this->set_version_info_cache($api_response, $cache_key); |
|
270 | 270 | |
271 | - if ( false !== $api_response ) { |
|
271 | + if (false !== $api_response) { |
|
272 | 272 | $_data = $api_response; |
273 | 273 | } |
274 | 274 | |
@@ -277,20 +277,20 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | // Convert sections into an associative array, since we're getting an object, but Core expects an array. |
280 | - if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) { |
|
280 | + if (isset($_data->sections) && ! is_array($_data->sections)) { |
|
281 | 281 | $new_sections = array(); |
282 | - foreach ( $_data->sections as $key => $value ) { |
|
283 | - $new_sections[ $key ] = $value; |
|
282 | + foreach ($_data->sections as $key => $value) { |
|
283 | + $new_sections[$key] = $value; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | $_data->sections = $new_sections; |
287 | 287 | } |
288 | 288 | |
289 | 289 | // Convert banners into an associative array, since we're getting an object, but Core expects an array. |
290 | - if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) { |
|
290 | + if (isset($_data->banners) && ! is_array($_data->banners)) { |
|
291 | 291 | $new_banners = array(); |
292 | - foreach ( $_data->banners as $key => $value ) { |
|
293 | - $new_banners[ $key ] = $value; |
|
292 | + foreach ($_data->banners as $key => $value) { |
|
293 | + $new_banners[$key] = $value; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $_data->banners = $new_banners; |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @param string $url |
307 | 307 | * @return object $array |
308 | 308 | */ |
309 | - public function http_request_args( $args, $url ) { |
|
309 | + public function http_request_args($args, $url) { |
|
310 | 310 | // If it is an https request and we are performing a package download, disable ssl verification |
311 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
311 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
312 | 312 | $args['sslverify'] = false; |
313 | 313 | } |
314 | 314 | return $args; |
@@ -325,50 +325,50 @@ discard block |
||
325 | 325 | * @param array $_data Parameters for the API action. |
326 | 326 | * @return false|object |
327 | 327 | */ |
328 | - private function api_request( $_action, $_data ) { |
|
328 | + private function api_request($_action, $_data) { |
|
329 | 329 | |
330 | 330 | global $wp_version; |
331 | 331 | |
332 | - $data = array_merge( $this->api_data, $_data ); |
|
332 | + $data = array_merge($this->api_data, $_data); |
|
333 | 333 | |
334 | - if ( $data['slug'] != $this->slug ) { |
|
334 | + if ($data['slug'] != $this->slug) { |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | - if( $this->api_url == trailingslashit (home_url() ) ) { |
|
338 | + if ($this->api_url == trailingslashit(home_url())) { |
|
339 | 339 | return false; // Don't allow a plugin to ping itself |
340 | 340 | } |
341 | 341 | |
342 | 342 | $api_params = array( |
343 | 343 | 'edd_action' => 'get_version', |
344 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
345 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
346 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
347 | - 'version' => isset( $data['version'] ) ? $data['version'] : false, |
|
344 | + 'license' => ! empty($data['license']) ? $data['license'] : '', |
|
345 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
346 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
347 | + 'version' => isset($data['version']) ? $data['version'] : false, |
|
348 | 348 | 'slug' => $data['slug'], |
349 | 349 | 'author' => $data['author'], |
350 | 350 | 'url' => home_url(), |
351 | - 'beta' => ! empty( $data['beta'] ), |
|
351 | + 'beta' => ! empty($data['beta']), |
|
352 | 352 | ); |
353 | 353 | |
354 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
354 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
355 | 355 | |
356 | - if ( ! is_wp_error( $request ) ) { |
|
357 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
356 | + if ( ! is_wp_error($request)) { |
|
357 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
358 | 358 | } |
359 | 359 | |
360 | - if ( $request && isset( $request->sections ) ) { |
|
361 | - $request->sections = maybe_unserialize( $request->sections ); |
|
360 | + if ($request && isset($request->sections)) { |
|
361 | + $request->sections = maybe_unserialize($request->sections); |
|
362 | 362 | } else { |
363 | 363 | $request = false; |
364 | 364 | } |
365 | 365 | |
366 | - if ( $request && isset( $request->banners ) ) { |
|
367 | - $request->banners = maybe_unserialize( $request->banners ); |
|
366 | + if ($request && isset($request->banners)) { |
|
367 | + $request->banners = maybe_unserialize($request->banners); |
|
368 | 368 | } |
369 | 369 | |
370 | - if( ! empty( $request->sections ) ) { |
|
371 | - foreach( $request->sections as $key => $section ) { |
|
370 | + if ( ! empty($request->sections)) { |
|
371 | + foreach ($request->sections as $key => $section) { |
|
372 | 372 | $request->$key = (array) $section; |
373 | 373 | } |
374 | 374 | } |
@@ -380,97 +380,97 @@ discard block |
||
380 | 380 | |
381 | 381 | global $edd_plugin_data; |
382 | 382 | |
383 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
383 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
387 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
387 | + if (empty($_REQUEST['plugin'])) { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | - if( empty( $_REQUEST['slug'] ) ) { |
|
391 | + if (empty($_REQUEST['slug'])) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | |
395 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
396 | - wp_die( __( 'You do not have permission to install plugin updates', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
395 | + if ( ! current_user_can('update_plugins')) { |
|
396 | + wp_die(__('You do not have permission to install plugin updates', 'give'), __('Error', 'give'), array('response' => 403)); |
|
397 | 397 | } |
398 | 398 | |
399 | - $data = $edd_plugin_data[ $_REQUEST['slug'] ]; |
|
400 | - $beta = ! empty( $data['beta'] ) ? true : false; |
|
401 | - $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); |
|
402 | - $version_info = $this->get_cached_version_info( $cache_key ); |
|
399 | + $data = $edd_plugin_data[$_REQUEST['slug']]; |
|
400 | + $beta = ! empty($data['beta']) ? true : false; |
|
401 | + $cache_key = md5('edd_plugin_'.sanitize_key($_REQUEST['plugin']).'_'.$beta.'_version_info'); |
|
402 | + $version_info = $this->get_cached_version_info($cache_key); |
|
403 | 403 | |
404 | - if( false === $version_info ) { |
|
404 | + if (false === $version_info) { |
|
405 | 405 | |
406 | 406 | $api_params = array( |
407 | 407 | 'edd_action' => 'get_version', |
408 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
409 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
408 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
409 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
410 | 410 | 'slug' => $_REQUEST['slug'], |
411 | 411 | 'author' => $data['author'], |
412 | 412 | 'url' => home_url(), |
413 | - 'beta' => ! empty( $data['beta'] ) |
|
413 | + 'beta' => ! empty($data['beta']) |
|
414 | 414 | ); |
415 | 415 | |
416 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
416 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
417 | 417 | |
418 | - if ( ! is_wp_error( $request ) ) { |
|
419 | - $version_info = json_decode( wp_remote_retrieve_body( $request ) ); |
|
418 | + if ( ! is_wp_error($request)) { |
|
419 | + $version_info = json_decode(wp_remote_retrieve_body($request)); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
423 | - if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { |
|
424 | - $version_info->sections = maybe_unserialize( $version_info->sections ); |
|
423 | + if ( ! empty($version_info) && isset($version_info->sections)) { |
|
424 | + $version_info->sections = maybe_unserialize($version_info->sections); |
|
425 | 425 | } else { |
426 | 426 | $version_info = false; |
427 | 427 | } |
428 | 428 | |
429 | - if( ! empty( $version_info ) ) { |
|
430 | - foreach( $version_info->sections as $key => $section ) { |
|
429 | + if ( ! empty($version_info)) { |
|
430 | + foreach ($version_info->sections as $key => $section) { |
|
431 | 431 | $version_info->$key = (array) $section; |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - $this->set_version_info_cache( $version_info, $cache_key ); |
|
435 | + $this->set_version_info_cache($version_info, $cache_key); |
|
436 | 436 | |
437 | 437 | } |
438 | 438 | |
439 | - if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
|
440 | - echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; |
|
439 | + if ( ! empty($version_info) && isset($version_info->sections['changelog'])) { |
|
440 | + echo '<div style="background:#fff;padding:10px;">'.$version_info->sections['changelog'].'</div>'; |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | exit; |
444 | 444 | } |
445 | 445 | |
446 | - public function get_cached_version_info( $cache_key = '' ) { |
|
446 | + public function get_cached_version_info($cache_key = '') { |
|
447 | 447 | |
448 | - if( empty( $cache_key ) ) { |
|
448 | + if (empty($cache_key)) { |
|
449 | 449 | $cache_key = $this->cache_key; |
450 | 450 | } |
451 | 451 | |
452 | - $cache = get_option( $cache_key ); |
|
452 | + $cache = get_option($cache_key); |
|
453 | 453 | |
454 | - if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) { |
|
454 | + if (empty($cache['timeout']) || current_time('timestamp') > $cache['timeout']) { |
|
455 | 455 | return false; // Cache is expired |
456 | 456 | } |
457 | 457 | |
458 | - return json_decode( $cache['value'] ); |
|
458 | + return json_decode($cache['value']); |
|
459 | 459 | |
460 | 460 | } |
461 | 461 | |
462 | - public function set_version_info_cache( $value = '', $cache_key = '' ) { |
|
462 | + public function set_version_info_cache($value = '', $cache_key = '') { |
|
463 | 463 | |
464 | - if( empty( $cache_key ) ) { |
|
464 | + if (empty($cache_key)) { |
|
465 | 465 | $cache_key = $this->cache_key; |
466 | 466 | } |
467 | 467 | |
468 | 468 | $data = array( |
469 | - 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ), |
|
470 | - 'value' => json_encode( $value ) |
|
469 | + 'timeout' => strtotime('+3 hours', current_time('timestamp')), |
|
470 | + 'value' => json_encode($value) |
|
471 | 471 | ); |
472 | 472 | |
473 | - update_option( $cache_key, $data ); |
|
473 | + update_option($cache_key, $data); |
|
474 | 474 | |
475 | 475 | } |
476 | 476 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * before_widget, and after_widget. |
80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
81 | 81 | */ |
82 | - public function widget( $args, $instance ){ |
|
83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + public function widget($args, $instance) { |
|
83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
85 | 85 | |
86 | 86 | echo $args['before_widget']; |
87 | 87 | |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0 |
92 | 92 | */ |
93 | - do_action( 'give_before_forms_widget' ); |
|
93 | + do_action('give_before_forms_widget'); |
|
94 | 94 | |
95 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
95 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
96 | 96 | |
97 | - give_get_donation_form( $instance ); |
|
97 | + give_get_donation_form($instance); |
|
98 | 98 | |
99 | 99 | echo $args['after_widget']; |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.0 |
105 | 105 | */ |
106 | - do_action( 'give_after_forms_widget' ); |
|
106 | + do_action('give_after_forms_widget'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function form( $instance ){ |
|
116 | + public function form($instance) { |
|
117 | 117 | $defaults = array( |
118 | 118 | 'title' => '', |
119 | 119 | 'id' => '', |
@@ -123,84 +123,84 @@ discard block |
||
123 | 123 | 'continue_button_title' => '', |
124 | 124 | ); |
125 | 125 | |
126 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
126 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
127 | 127 | |
128 | 128 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
129 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
129 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
130 | 130 | |
131 | 131 | // Query Give Forms |
132 | 132 | $args = array( |
133 | 133 | 'post_type' => 'give_forms', |
134 | - 'posts_per_page' => - 1, |
|
134 | + 'posts_per_page' => -1, |
|
135 | 135 | 'post_status' => 'publish', |
136 | 136 | ); |
137 | 137 | |
138 | - $give_forms = get_posts( $args ); |
|
138 | + $give_forms = get_posts($args); |
|
139 | 139 | ?> |
140 | 140 | <div class="give_forms_widget_container"> |
141 | 141 | |
142 | 142 | <?php // Widget: widget Title. ?> |
143 | 143 | <p> |
144 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
145 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
146 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
144 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
145 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
146 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
147 | 147 | </p> |
148 | 148 | |
149 | 149 | <?php // Widget: Give Form?> |
150 | 150 | <p> |
151 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
152 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
153 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
154 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
155 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
156 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
151 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
152 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
153 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
154 | + <?php foreach ($give_forms as $give_form) { ?> |
|
155 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
156 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
157 | 157 | <?php } ?> |
158 | 158 | </select><br> |
159 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
159 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
160 | 160 | </p> |
161 | 161 | |
162 | 162 | <?php // Widget: Display Style ?> |
163 | 163 | <p class="give_forms_display_style_setting_row"> |
164 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
165 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
166 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
167 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
168 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
164 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
165 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
166 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
167 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
168 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
169 | 169 | <small class="give-field-description"> |
170 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
170 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
171 | 171 | </small> |
172 | 172 | </p> |
173 | 173 | |
174 | 174 | <?php // Widget: Continue Button Title. ?> |
175 | 175 | <p class="give_forms_continue_button_title_setting_row"> |
176 | - <label for="<?php echo $this->get_field_id( 'continue_button_title' ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
177 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'continue_button_title' ); ?>" name="<?php echo $this->get_field_name( 'continue_button_title' ); ?>" value="<?php esc_attr_e( $instance['continue_button_title'] ); ?>" /><br> |
|
178 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
176 | + <label for="<?php echo $this->get_field_id('continue_button_title'); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
177 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('continue_button_title'); ?>" name="<?php echo $this->get_field_name('continue_button_title'); ?>" value="<?php esc_attr_e($instance['continue_button_title']); ?>" /><br> |
|
178 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
179 | 179 | </p> |
180 | 180 | |
181 | 181 | <?php // Widget: Floating Labels ?> |
182 | 182 | <p> |
183 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
184 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
185 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
186 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
183 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
184 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
185 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
186 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
187 | 187 | <small class="give-field-description"> |
188 | 188 | <?php |
189 | 189 | printf( |
190 | 190 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
191 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
192 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
191 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
192 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
193 | 193 | ); |
194 | 194 | ?></small> |
195 | 195 | </p> |
196 | 196 | |
197 | 197 | <?php // Widget: Display Content ?> |
198 | 198 | <p> |
199 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
200 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
201 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
202 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
203 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
199 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
200 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
201 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
202 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
203 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
204 | 204 | </div> |
205 | 205 | <?php |
206 | 206 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return void |
212 | 212 | */ |
213 | - function widget_init(){ |
|
214 | - register_widget( $this->self ); |
|
213 | + function widget_init() { |
|
214 | + register_widget($this->self); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return array |
224 | 224 | */ |
225 | - public function update( $new_instance, $old_instance ){ |
|
225 | + public function update($new_instance, $old_instance) { |
|
226 | 226 | $this->flush_widget_cache(); |
227 | 227 | |
228 | 228 | return $new_instance; |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return void |
235 | 235 | */ |
236 | - public function flush_widget_cache(){ |
|
237 | - wp_cache_delete( $this->self, 'widget' ); |
|
236 | + public function flush_widget_cache() { |
|
237 | + wp_cache_delete($this->self, 'widget'); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() { |
26 | 26 | |
27 | - $this->shortcode['title'] = esc_html__( 'Donation Form', 'give' ); |
|
28 | - $this->shortcode['label'] = esc_html__( 'Donation Form', 'give' ); |
|
27 | + $this->shortcode['title'] = esc_html__('Donation Form', 'give'); |
|
28 | + $this->shortcode['label'] = esc_html__('Donation Form', 'give'); |
|
29 | 29 | |
30 | - parent::__construct( 'give_form' ); |
|
30 | + parent::__construct('give_form'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | $create_form_link = sprintf( |
41 | 41 | /* translators: %s: create new form URL */ |
42 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
43 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
42 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
43 | + admin_url('post-new.php?post_type=give_forms') |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | return array( |
@@ -50,68 +50,68 @@ discard block |
||
50 | 50 | 'post_type' => 'give_forms', |
51 | 51 | ), |
52 | 52 | 'name' => 'id', |
53 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
54 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
53 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
54 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
55 | 55 | 'required' => array( |
56 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
57 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
56 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
57 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
58 | 58 | ), |
59 | 59 | ), |
60 | 60 | array( |
61 | 61 | 'type' => 'container', |
62 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
62 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
63 | 63 | ), |
64 | 64 | array( |
65 | 65 | 'type' => 'listbox', |
66 | 66 | 'name' => 'show_title', |
67 | - 'label' => esc_attr__( 'Show Title', 'give' ), |
|
68 | - 'tooltip' => esc_attr__( 'Do you want to display the form title?', 'give' ), |
|
67 | + 'label' => esc_attr__('Show Title', 'give'), |
|
68 | + 'tooltip' => esc_attr__('Do you want to display the form title?', 'give'), |
|
69 | 69 | 'options' => array( |
70 | - 'true' => esc_html__( 'Show', 'give' ), |
|
71 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
70 | + 'true' => esc_html__('Show', 'give'), |
|
71 | + 'false' => esc_html__('Hide', 'give'), |
|
72 | 72 | ), |
73 | 73 | ), |
74 | 74 | array( |
75 | 75 | 'type' => 'listbox', |
76 | 76 | 'name' => 'show_goal', |
77 | - 'label' => esc_attr__( 'Show Goal', 'give' ), |
|
78 | - 'tooltip' => esc_attr__( 'Do you want to display the donation goal?', 'give' ), |
|
77 | + 'label' => esc_attr__('Show Goal', 'give'), |
|
78 | + 'tooltip' => esc_attr__('Do you want to display the donation goal?', 'give'), |
|
79 | 79 | 'options' => array( |
80 | - 'true' => esc_html__( 'Show', 'give' ), |
|
81 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
80 | + 'true' => esc_html__('Show', 'give'), |
|
81 | + 'false' => esc_html__('Hide', 'give'), |
|
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | array( |
85 | 85 | 'type' => 'listbox', |
86 | 86 | 'name' => 'show_content', |
87 | 87 | 'minWidth' => 240, |
88 | - 'label' => esc_attr__( 'Display Content', 'give' ), |
|
89 | - 'tooltip' => esc_attr__( 'Do you want to display the form content?', 'give' ), |
|
88 | + 'label' => esc_attr__('Display Content', 'give'), |
|
89 | + 'tooltip' => esc_attr__('Do you want to display the form content?', 'give'), |
|
90 | 90 | 'options' => array( |
91 | - 'none' => esc_html__( 'No Content', 'give' ), |
|
92 | - 'above' => esc_html__( 'Display content ABOVE the fields', 'give' ), |
|
93 | - 'below' => esc_html__( 'Display content BELOW the fields', 'give' ), |
|
91 | + 'none' => esc_html__('No Content', 'give'), |
|
92 | + 'above' => esc_html__('Display content ABOVE the fields', 'give'), |
|
93 | + 'below' => esc_html__('Display content BELOW the fields', 'give'), |
|
94 | 94 | ), |
95 | 95 | ), |
96 | 96 | array( |
97 | 97 | 'type' => 'listbox', |
98 | 98 | 'name' => 'display_style', |
99 | 99 | 'classes' => 'give-display-style', |
100 | - 'label' => esc_attr__( 'Display Options', 'give' ), |
|
101 | - 'tooltip' => esc_attr__( 'How would you like to display donation information?', 'give' ), |
|
100 | + 'label' => esc_attr__('Display Options', 'give'), |
|
101 | + 'tooltip' => esc_attr__('How would you like to display donation information?', 'give'), |
|
102 | 102 | 'options' => array( |
103 | - 'onpage' => esc_html__( 'All Fields', 'give' ), |
|
104 | - 'modal' => esc_html__( 'Modal', 'give' ), |
|
105 | - 'reveal' => esc_html__( 'Reveal', 'give' ), |
|
106 | - 'button' => esc_html__( 'Button', 'give' ), |
|
103 | + 'onpage' => esc_html__('All Fields', 'give'), |
|
104 | + 'modal' => esc_html__('Modal', 'give'), |
|
105 | + 'reveal' => esc_html__('Reveal', 'give'), |
|
106 | + 'button' => esc_html__('Button', 'give'), |
|
107 | 107 | ), |
108 | 108 | ), |
109 | 109 | array( |
110 | 110 | 'type' => 'textbox', |
111 | 111 | 'classes' => 'give-hidden give-continue-button-title', |
112 | 112 | 'name' => 'continue_button_title', |
113 | - 'label' => esc_attr__( 'Button Text', 'give' ), |
|
114 | - 'tooltip' => esc_attr__( 'The button label for displaying the additional payment fields.', 'give' ), |
|
113 | + 'label' => esc_attr__('Button Text', 'give'), |
|
114 | + 'tooltip' => esc_attr__('The button label for displaying the additional payment fields.', 'give'), |
|
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | } |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_API' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_API')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'api'; |
46 | - $this->label = esc_html__( 'API', 'give' ); |
|
46 | + $this->label = esc_html__('API', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
60 | - $pages[ $this->id ] = $this->label; |
|
59 | + public function add_settings_page($pages) { |
|
60 | + $pages[$this->id] = $this->label; |
|
61 | 61 | |
62 | 62 | return $pages; |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
74 | 74 | |
75 | 75 | // Get settings. |
76 | - $settings = apply_filters( 'give_settings_api', array( |
|
76 | + $settings = apply_filters('give_settings_api', array( |
|
77 | 77 | array( |
78 | 78 | 'id' => 'give_tools_api', |
79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ), |
82 | 82 | array( |
83 | 83 | 'id' => 'api', |
84 | - 'name' => esc_html__( 'API', 'give' ), |
|
84 | + 'name' => esc_html__('API', 'give'), |
|
85 | 85 | 'type' => 'api', |
86 | 86 | ), |
87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @since 1.8 |
98 | 98 | * @param array $settings |
99 | 99 | */ |
100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
101 | 101 | |
102 | 102 | // Output. |
103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function output() { |
113 | 113 | $settings = $this->get_settings(); |
114 | 114 | |
115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Data' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'data'; |
46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
46 | + $this->label = esc_html__('Data', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | |
51 | 51 | // Do not use main form for this tab. |
52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
52 | + if (give_get_current_setting_tab() === $this->id) { |
|
53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $pages Lst of pages. |
63 | 63 | * @return array |
64 | 64 | */ |
65 | - public function add_settings_page( $pages ) { |
|
66 | - $pages[ $this->id ] = $this->label; |
|
65 | + public function add_settings_page($pages) { |
|
66 | + $pages[$this->id] = $this->label; |
|
67 | 67 | |
68 | 68 | return $pages; |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
80 | 80 | |
81 | 81 | // Get settings. |
82 | - $settings = apply_filters( 'give_settings_data', array( |
|
82 | + $settings = apply_filters('give_settings_data', array( |
|
83 | 83 | array( |
84 | 84 | 'id' => 'give_tools_tools', |
85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ), |
88 | 88 | array( |
89 | 89 | 'id' => 'api', |
90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
90 | + 'name' => esc_html__('Tools', 'give'), |
|
91 | 91 | 'type' => 'data', |
92 | 92 | ), |
93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @since 1.8 |
104 | 104 | * @param array $settings |
105 | 105 | */ |
106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
107 | 107 | |
108 | 108 | // Output. |
109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function output() { |
119 | 119 | $settings = $this->get_settings(); |
120 | 120 | |
121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 |
@@ -205,7 +205,7 @@ |
||
205 | 205 | * |
206 | 206 | * @param bool $force If set to true then all cached values will be delete instead of only expired |
207 | 207 | * |
208 | - * @return bool |
|
208 | + * @return false|null |
|
209 | 209 | */ |
210 | 210 | public static function delete_all_expired( $force = false ) { |
211 | 211 | global $wpdb; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return static |
44 | 44 | */ |
45 | 45 | public static function get_instance() { |
46 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
46 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
47 | 47 | self::$instance = new Give_Cache(); |
48 | 48 | } |
49 | 49 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setup_hooks() { |
60 | 60 | // weekly delete all expired cache. |
61 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
61 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | * @return string |
73 | 73 | */ |
74 | 74 | |
75 | - public static function get_key( $action, $query_args = null ) { |
|
75 | + public static function get_key($action, $query_args = null) { |
|
76 | 76 | $cache_key = "give_cache_{$action}"; |
77 | 77 | |
78 | 78 | // Bailout. |
79 | - if ( ! empty( $query_args ) ) { |
|
80 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
79 | + if ( ! empty($query_args)) { |
|
80 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return $cache_key; |
@@ -95,26 +95,26 @@ discard block |
||
95 | 95 | * @return mixed |
96 | 96 | */ |
97 | 97 | |
98 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
99 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
100 | - if ( ! $custom_key ) { |
|
101 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
98 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
99 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
100 | + if ( ! $custom_key) { |
|
101 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
102 | 102 | } |
103 | 103 | |
104 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
104 | + $cache_key = self::get_key($cache_key, $query_args); |
|
105 | 105 | } |
106 | 106 | |
107 | - $option = get_option( $cache_key ); |
|
107 | + $option = get_option($cache_key); |
|
108 | 108 | |
109 | 109 | // Backward compatibility (<1.8.7). |
110 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
110 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
111 | 111 | return $option; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Get current time. |
115 | - $current_time = current_time( 'timestamp', 1 ); |
|
115 | + $current_time = current_time('timestamp', 1); |
|
116 | 116 | |
117 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
117 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
118 | 118 | $option = $option['data']; |
119 | 119 | } else { |
120 | 120 | $option = false; |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | 139 | |
140 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
141 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
142 | - if ( ! $custom_key ) { |
|
143 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
140 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
141 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
142 | + if ( ! $custom_key) { |
|
143 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
144 | 144 | } |
145 | 145 | |
146 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
146 | + $cache_key = self::get_key($cache_key, $query_args); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $option_value = array( |
150 | 150 | 'data' => $data, |
151 | - 'expiration' => ! is_null( $expiration ) |
|
152 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
151 | + 'expiration' => ! is_null($expiration) |
|
152 | + ? ($expiration + current_time('timestamp', 1)) |
|
153 | 153 | : null, |
154 | 154 | ); |
155 | 155 | |
156 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
156 | + $result = update_option($cache_key, $option_value, 'no'); |
|
157 | 157 | |
158 | 158 | return $result; |
159 | 159 | } |
@@ -168,27 +168,27 @@ discard block |
||
168 | 168 | * @return bool|WP_Error |
169 | 169 | */ |
170 | 170 | |
171 | - public static function delete( $cache_keys ) { |
|
171 | + public static function delete($cache_keys) { |
|
172 | 172 | $result = true; |
173 | 173 | $invalid_keys = array(); |
174 | 174 | |
175 | - if ( ! empty( $cache_keys ) ) { |
|
176 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
175 | + if ( ! empty($cache_keys)) { |
|
176 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
177 | 177 | |
178 | - foreach ( $cache_keys as $cache_key ) { |
|
179 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
178 | + foreach ($cache_keys as $cache_key) { |
|
179 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
180 | 180 | $invalid_keys[] = $cache_key; |
181 | 181 | $result = false; |
182 | 182 | } |
183 | 183 | |
184 | - delete_option( $cache_key ); |
|
184 | + delete_option($cache_key); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if( ! $result ) { |
|
188 | + if ( ! $result) { |
|
189 | 189 | $result = new WP_Error( |
190 | 190 | 'give_invalid_cache_key', |
191 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
191 | + __('Cache key format should be give_cache_*', 'give'), |
|
192 | 192 | $invalid_keys |
193 | 193 | ); |
194 | 194 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public static function delete_all_expired( $force = false ) { |
|
210 | + public static function delete_all_expired($force = false) { |
|
211 | 211 | global $wpdb; |
212 | 212 | $options = $wpdb->get_results( |
213 | 213 | $wpdb->prepare( |
@@ -221,30 +221,30 @@ discard block |
||
221 | 221 | ); |
222 | 222 | |
223 | 223 | // Bailout. |
224 | - if ( empty( $options ) ) { |
|
224 | + if (empty($options)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - $current_time = current_time( 'timestamp', 1 ); |
|
228 | + $current_time = current_time('timestamp', 1); |
|
229 | 229 | |
230 | 230 | // Delete log cache. |
231 | - foreach ( $options as $option ) { |
|
232 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
231 | + foreach ($options as $option) { |
|
232 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
233 | 233 | |
234 | 234 | if ( |
235 | 235 | ( |
236 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
237 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
238 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
239 | - || empty( $option['option_value']['expiration'] ) |
|
240 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
236 | + ! self::is_valid_cache_key($option['option_name']) |
|
237 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
238 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
239 | + || empty($option['option_value']['expiration']) |
|
240 | + || ($current_time < $option['option_value']['expiration']) |
|
241 | 241 | ) |
242 | 242 | && ! $force |
243 | 243 | ) { |
244 | 244 | continue; |
245 | 245 | } |
246 | 246 | |
247 | - self::delete( $option['option_name'] ); |
|
247 | + self::delete($option['option_name']); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return array |
262 | 262 | */ |
263 | - public static function get_options_like( $option_name, $fields = false ) { |
|
263 | + public static function get_options_like($option_name, $fields = false) { |
|
264 | 264 | global $wpdb; |
265 | 265 | |
266 | - if ( empty( $option_name ) ) { |
|
266 | + if (empty($option_name)) { |
|
267 | 267 | return array(); |
268 | 268 | } |
269 | 269 | |
270 | 270 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
271 | 271 | |
272 | - if ( $fields ) { |
|
272 | + if ($fields) { |
|
273 | 273 | $options = $wpdb->get_results( |
274 | 274 | $wpdb->prepare( |
275 | 275 | "SELECT {$field_names } |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | - if ( ! empty( $options ) && $fields ) { |
|
297 | - foreach ( $options as $index => $option ) { |
|
298 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
299 | - $options[ $index ] = $option; |
|
296 | + if ( ! empty($options) && $fields) { |
|
297 | + foreach ($options as $index => $option) { |
|
298 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
299 | + $options[$index] = $option; |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @return bool|int |
315 | 315 | */ |
316 | - public static function is_valid_cache_key( $cache_key ) { |
|
317 | - return ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
316 | + public static function is_valid_cache_key($cache_key) { |
|
317 | + return (false !== strpos($cache_key, 'give_cache_')); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | 28 | <h1><?php echo get_admin_page_title(); ?> |
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h1> |
32 | 32 | |
33 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
33 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
35 | 35 | </div> |
36 | 36 | <?php |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | function give_add_ons_get_feed() { |
49 | 49 | |
50 | 50 | $addons_debug = false; //set to true to debug |
51 | - $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
|
51 | + $cache = Give_Cache::get('give_add_ons_feed', true); |
|
52 | 52 | |
53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
55 | 55 | |
56 | - if ( ! is_wp_error( $feed ) ) { |
|
57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
59 | - Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
|
56 | + if ( ! is_wp_error($feed)) { |
|
57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
58 | + $cache = wp_remote_retrieve_body($feed); |
|
59 | + Give_Cache::set('give_add_ons_feed', $cache, HOUR_IN_SECONDS, true); |
|
60 | 60 | } |
61 | 61 | } else { |
62 | 62 | $cache = sprintf( |
63 | 63 | '<div class="error"><p>%s</p></div>', |
64 | - esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
|
64 | + esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give') |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array An array of updated action links. |
25 | 25 | */ |
26 | -function give_plugin_action_links( $actions ) { |
|
26 | +function give_plugin_action_links($actions) { |
|
27 | 27 | $new_actions = array( |
28 | 28 | 'settings' => sprintf( |
29 | 29 | '<a href="%1$s">%2$s</a>', |
30 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings' ), |
|
31 | - __( 'Settings', 'give' ) |
|
30 | + admin_url('edit.php?post_type=give_forms&page=give-settings'), |
|
31 | + __('Settings', 'give') |
|
32 | 32 | ), |
33 | 33 | ); |
34 | 34 | |
35 | - return array_merge( $new_actions, $actions ); |
|
35 | + return array_merge($new_actions, $actions); |
|
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' ); |
|
38 | +add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links'); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,35 +48,35 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $plugin_meta, $plugin_file ) { |
|
52 | - if ( $plugin_file != GIVE_PLUGIN_BASENAME ) { |
|
51 | +function give_plugin_row_meta($plugin_meta, $plugin_file) { |
|
52 | + if ($plugin_file != GIVE_PLUGIN_BASENAME) { |
|
53 | 53 | return $plugin_meta; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $new_meta_links = array( |
57 | 57 | sprintf( |
58 | 58 | '<a href="%1$s" target="_blank">%2$s</a>', |
59 | - esc_url( add_query_arg( array( |
|
59 | + esc_url(add_query_arg(array( |
|
60 | 60 | 'utm_source' => 'plugins-page', |
61 | 61 | 'utm_medium' => 'plugin-row', |
62 | 62 | 'utm_campaign' => 'admin', |
63 | - ), 'https://givewp.com/documentation/' ) |
|
63 | + ), 'https://givewp.com/documentation/') |
|
64 | 64 | ), |
65 | - __( 'Documentation', 'give' ) |
|
65 | + __('Documentation', 'give') |
|
66 | 66 | ), |
67 | 67 | sprintf( |
68 | 68 | '<a href="%1$s" target="_blank">%2$s</a>', |
69 | - esc_url( add_query_arg( array( |
|
69 | + esc_url(add_query_arg(array( |
|
70 | 70 | 'utm_source' => 'plugins-page', |
71 | 71 | 'utm_medium' => 'plugin-row', |
72 | 72 | 'utm_campaign' => 'admin', |
73 | - ), 'https://givewp.com/addons/' ) |
|
73 | + ), 'https://givewp.com/addons/') |
|
74 | 74 | ), |
75 | - __( 'Add-ons', 'give' ) |
|
75 | + __('Add-ons', 'give') |
|
76 | 76 | ), |
77 | 77 | ); |
78 | 78 | |
79 | - return array_merge( $plugin_meta, $new_meta_links ); |
|
79 | + return array_merge($plugin_meta, $new_meta_links); |
|
80 | 80 | } |
81 | 81 | |
82 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
82 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |