@@ -358,9 +358,9 @@ |
||
358 | 358 | require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
359 | 359 | require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
360 | 360 | |
361 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | - } |
|
361 | + if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
362 | + require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
366 | 366 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | */ |
41 | 41 | |
42 | 42 | // Exit if accessed directly. |
43 | -if ( ! defined( 'ABSPATH' ) ) { |
|
43 | +if ( ! defined('ABSPATH')) { |
|
44 | 44 | exit; |
45 | 45 | } |
46 | 46 | |
47 | -if ( ! class_exists( 'Give' ) ) : |
|
47 | +if ( ! class_exists('Give')) : |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Main Give Class |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @return Give |
196 | 196 | */ |
197 | 197 | public static function instance() { |
198 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) { |
|
198 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) { |
|
199 | 199 | self::$instance = new Give; |
200 | 200 | self::$instance->setup_constants(); |
201 | 201 | |
202 | - add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) ); |
|
202 | + add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); |
|
203 | 203 | |
204 | 204 | self::$instance->includes(); |
205 | 205 | self::$instance->roles = new Give_Roles(); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function __clone() { |
234 | 234 | // Cloning instances of the class is forbidden |
235 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
235 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function __wakeup() { |
247 | 247 | // Unserializing instances of the class is forbidden. |
248 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'give' ), '1.0' ); |
|
248 | + _doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'give'), '1.0'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -259,33 +259,33 @@ discard block |
||
259 | 259 | private function setup_constants() { |
260 | 260 | |
261 | 261 | // Plugin version |
262 | - if ( ! defined( 'GIVE_VERSION' ) ) { |
|
263 | - define( 'GIVE_VERSION', '1.7' ); |
|
262 | + if ( ! defined('GIVE_VERSION')) { |
|
263 | + define('GIVE_VERSION', '1.7'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Plugin Folder Path |
267 | - if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) { |
|
268 | - define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
267 | + if ( ! defined('GIVE_PLUGIN_DIR')) { |
|
268 | + define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Plugin Folder URL |
272 | - if ( ! defined( 'GIVE_PLUGIN_URL' ) ) { |
|
273 | - define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
|
272 | + if ( ! defined('GIVE_PLUGIN_URL')) { |
|
273 | + define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__)); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Plugin Basename aka: "give/give.php" |
277 | - if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) { |
|
278 | - define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
|
277 | + if ( ! defined('GIVE_PLUGIN_BASENAME')) { |
|
278 | + define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Plugin Root File |
282 | - if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) { |
|
283 | - define( 'GIVE_PLUGIN_FILE', __FILE__ ); |
|
282 | + if ( ! defined('GIVE_PLUGIN_FILE')) { |
|
283 | + define('GIVE_PLUGIN_FILE', __FILE__); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Make sure CAL_GREGORIAN is defined |
287 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
288 | - define( 'CAL_GREGORIAN', 1 ); |
|
287 | + if ( ! defined('CAL_GREGORIAN')) { |
|
288 | + define('CAL_GREGORIAN', 1); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
@@ -300,121 +300,121 @@ discard block |
||
300 | 300 | private function includes() { |
301 | 301 | global $give_options; |
302 | 302 | |
303 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php'; |
|
304 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php'; |
|
303 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php'; |
|
304 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php'; |
|
305 | 305 | $give_options = give_get_settings(); |
306 | 306 | |
307 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php'; |
|
308 | - require_once GIVE_PLUGIN_DIR . 'includes/post-types.php'; |
|
309 | - require_once GIVE_PLUGIN_DIR . 'includes/scripts.php'; |
|
310 | - require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php'; |
|
311 | - require_once GIVE_PLUGIN_DIR . 'includes/actions.php'; |
|
312 | - require_once GIVE_PLUGIN_DIR . 'includes/filters.php'; |
|
313 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php'; |
|
314 | - |
|
315 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php'; |
|
316 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php'; |
|
317 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php'; |
|
318 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php'; |
|
319 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php'; |
|
320 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php'; |
|
321 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php'; |
|
322 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php'; |
|
323 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php'; |
|
324 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php'; |
|
325 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php'; |
|
326 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php'; |
|
327 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php'; |
|
328 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php'; |
|
329 | - |
|
330 | - require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php'; |
|
331 | - require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php'; |
|
332 | - require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php'; |
|
333 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php'; |
|
334 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php'; |
|
335 | - require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php'; |
|
336 | - require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php'; |
|
337 | - require_once GIVE_PLUGIN_DIR . 'includes/formatting.php'; |
|
338 | - require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php'; |
|
339 | - require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php'; |
|
340 | - require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php'; |
|
341 | - require_once GIVE_PLUGIN_DIR . 'includes/login-register.php'; |
|
342 | - require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php'; |
|
343 | - require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php'; |
|
344 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php'; |
|
345 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php'; |
|
346 | - require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php'; |
|
347 | - |
|
348 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php'; |
|
349 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php'; |
|
350 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php'; |
|
351 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php'; |
|
352 | - require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php'; |
|
353 | - |
|
354 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php'; |
|
355 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php'; |
|
356 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php'; |
|
357 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php'; |
|
358 | - require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php'; |
|
359 | - |
|
360 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php'; |
|
361 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php'; |
|
362 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php'; |
|
363 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php'; |
|
364 | - require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php'; |
|
365 | - |
|
366 | - if( defined( 'WP_CLI' ) && WP_CLI ) { |
|
367 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php'; |
|
307 | + require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php'; |
|
308 | + require_once GIVE_PLUGIN_DIR.'includes/post-types.php'; |
|
309 | + require_once GIVE_PLUGIN_DIR.'includes/scripts.php'; |
|
310 | + require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php'; |
|
311 | + require_once GIVE_PLUGIN_DIR.'includes/actions.php'; |
|
312 | + require_once GIVE_PLUGIN_DIR.'includes/filters.php'; |
|
313 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php'; |
|
314 | + |
|
315 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php'; |
|
316 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php'; |
|
317 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php'; |
|
318 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php'; |
|
319 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php'; |
|
320 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php'; |
|
321 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php'; |
|
322 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php'; |
|
323 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php'; |
|
324 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php'; |
|
325 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php'; |
|
326 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php'; |
|
327 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php'; |
|
328 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php'; |
|
329 | + |
|
330 | + require_once GIVE_PLUGIN_DIR.'includes/country-functions.php'; |
|
331 | + require_once GIVE_PLUGIN_DIR.'includes/template-functions.php'; |
|
332 | + require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php'; |
|
333 | + require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php'; |
|
334 | + require_once GIVE_PLUGIN_DIR.'includes/forms/template.php'; |
|
335 | + require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php'; |
|
336 | + require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php'; |
|
337 | + require_once GIVE_PLUGIN_DIR.'includes/formatting.php'; |
|
338 | + require_once GIVE_PLUGIN_DIR.'includes/price-functions.php'; |
|
339 | + require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php'; |
|
340 | + require_once GIVE_PLUGIN_DIR.'includes/process-donation.php'; |
|
341 | + require_once GIVE_PLUGIN_DIR.'includes/login-register.php'; |
|
342 | + require_once GIVE_PLUGIN_DIR.'includes/user-functions.php'; |
|
343 | + require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php'; |
|
344 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php'; |
|
345 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php'; |
|
346 | + require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php'; |
|
347 | + |
|
348 | + require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php'; |
|
349 | + require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php'; |
|
350 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php'; |
|
351 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php'; |
|
352 | + require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php'; |
|
353 | + |
|
354 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php'; |
|
355 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php'; |
|
356 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php'; |
|
357 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php'; |
|
358 | + require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php'; |
|
359 | + |
|
360 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php'; |
|
361 | + require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php'; |
|
362 | + require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php'; |
|
363 | + require_once GIVE_PLUGIN_DIR.'includes/emails/template.php'; |
|
364 | + require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php'; |
|
365 | + |
|
366 | + if (defined('WP_CLI') && WP_CLI) { |
|
367 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
371 | - |
|
372 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php'; |
|
373 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php'; |
|
374 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
|
375 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php'; |
|
376 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
377 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php'; |
|
378 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php'; |
|
379 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php'; |
|
380 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php'; |
|
381 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php'; |
|
382 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php'; |
|
383 | - |
|
384 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php'; |
|
385 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php'; |
|
386 | - |
|
387 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php'; |
|
388 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php'; |
|
389 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php'; |
|
390 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php'; |
|
391 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php'; |
|
392 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php'; |
|
393 | - |
|
394 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php'; |
|
395 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php'; |
|
396 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php'; |
|
397 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php'; |
|
398 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php'; |
|
399 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php'; |
|
400 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php'; |
|
401 | - |
|
402 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
403 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php'; |
|
404 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php'; |
|
405 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
406 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php'; |
|
407 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php'; |
|
408 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
410 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
411 | - |
|
412 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
413 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php'; |
|
370 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
371 | + |
|
372 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php'; |
|
373 | + require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php'; |
|
374 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php'; |
|
375 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php'; |
|
376 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
377 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php'; |
|
378 | + require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php'; |
|
379 | + require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php'; |
|
380 | + require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php'; |
|
381 | + require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php'; |
|
382 | + require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php'; |
|
383 | + |
|
384 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php'; |
|
385 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php'; |
|
386 | + |
|
387 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php'; |
|
388 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php'; |
|
389 | + require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php'; |
|
390 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php'; |
|
391 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php'; |
|
392 | + require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php'; |
|
393 | + |
|
394 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php'; |
|
395 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php'; |
|
396 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php'; |
|
397 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php'; |
|
398 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php'; |
|
399 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php'; |
|
400 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php'; |
|
401 | + |
|
402 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php'; |
|
403 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php'; |
|
404 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php'; |
|
405 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php'; |
|
406 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php'; |
|
407 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php'; |
|
408 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php'; |
|
409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php'; |
|
410 | + require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php'; |
|
411 | + |
|
412 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
413 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php'; |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | - require_once GIVE_PLUGIN_DIR . 'includes/install.php'; |
|
417 | + require_once GIVE_PLUGIN_DIR.'includes/install.php'; |
|
418 | 418 | |
419 | 419 | } |
420 | 420 | |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | */ |
429 | 429 | public function load_textdomain() { |
430 | 430 | // Set filter for Give's languages directory |
431 | - $give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/'; |
|
432 | - $give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir ); |
|
431 | + $give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/'; |
|
432 | + $give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir); |
|
433 | 433 | |
434 | 434 | // Traditional WordPress plugin locale filter |
435 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'give' ); |
|
436 | - $mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale ); |
|
435 | + $locale = apply_filters('plugin_locale', get_locale(), 'give'); |
|
436 | + $mofile = sprintf('%1$s-%2$s.mo', 'give', $locale); |
|
437 | 437 | |
438 | 438 | // Setup paths to current locale file |
439 | - $mofile_local = $give_lang_dir . $mofile; |
|
440 | - $mofile_global = WP_LANG_DIR . '/give/' . $mofile; |
|
439 | + $mofile_local = $give_lang_dir.$mofile; |
|
440 | + $mofile_global = WP_LANG_DIR.'/give/'.$mofile; |
|
441 | 441 | |
442 | - if ( file_exists( $mofile_global ) ) { |
|
442 | + if (file_exists($mofile_global)) { |
|
443 | 443 | // Look in global /wp-content/languages/give folder |
444 | - load_textdomain( 'give', $mofile_global ); |
|
445 | - } elseif ( file_exists( $mofile_local ) ) { |
|
444 | + load_textdomain('give', $mofile_global); |
|
445 | + } elseif (file_exists($mofile_local)) { |
|
446 | 446 | // Look in local location from filter `give_languages_directory` |
447 | - load_textdomain( 'give', $mofile_local ); |
|
447 | + load_textdomain('give', $mofile_local); |
|
448 | 448 | } else { |
449 | 449 | // Load the default language files packaged up w/ Give |
450 | - load_plugin_textdomain( 'give', false, $give_lang_dir ); |
|
450 | + load_plugin_textdomain('give', false, $give_lang_dir); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 |
@@ -45,22 +45,22 @@ discard block |
||
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | 47 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
50 | - } |
|
48 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | + extract( $args ); |
|
50 | + } |
|
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array( $template_name . '.php' ); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists( $located ) ) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
58 | + give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include( $located ); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | * @param string $template_path Template file path. Default is empty. |
45 | 45 | * @param string $default_path Default path. Default is empty. |
46 | 46 | */ |
47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
49 | - extract( $args ); |
|
47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
48 | + if ( ! empty($args) && is_array($args)) { |
|
49 | + extract($args); |
|
50 | 50 | } |
51 | 51 | |
52 | - $template_names = array( $template_name . '.php' ); |
|
52 | + $template_names = array($template_name.'.php'); |
|
53 | 53 | |
54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
55 | 55 | |
56 | - if ( ! file_exists( $located ) ) { |
|
56 | + if ( ! file_exists($located)) { |
|
57 | 57 | /* translators: %s: the template */ |
58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
75 | 75 | * @param array $args Passed arguments. |
76 | 76 | */ |
77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
78 | 78 | |
79 | - include( $located ); |
|
79 | + include($located); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
91 | 91 | * @param array $args Passed arguments. |
92 | 92 | */ |
93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param string $slug Template part file slug {slug}.php. |
119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
120 | 120 | */ |
121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
122 | 122 | |
123 | 123 | // Setup possible parts |
124 | 124 | $templates = array(); |
125 | - if ( isset( $name ) ) { |
|
126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
125 | + if (isset($name)) { |
|
126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
127 | 127 | } |
128 | - $templates[] = $slug . '.php'; |
|
128 | + $templates[] = $slug.'.php'; |
|
129 | 129 | |
130 | 130 | // Allow template parts to be filtered |
131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
132 | 132 | |
133 | 133 | // Return the part that is found |
134 | - return give_locate_template( $templates, $load, false ); |
|
134 | + return give_locate_template($templates, $load, false); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string The template filename if one is located. |
154 | 154 | */ |
155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
156 | 156 | // No file found yet |
157 | 157 | $located = false; |
158 | 158 | |
159 | 159 | // Try to find a template file |
160 | - foreach ( (array) $template_names as $template_name ) { |
|
160 | + foreach ((array) $template_names as $template_name) { |
|
161 | 161 | |
162 | 162 | // Continue if template is empty |
163 | - if ( empty( $template_name ) ) { |
|
163 | + if (empty($template_name)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Trim off any slashes from the template name |
168 | - $template_name = ltrim( $template_name, '/' ); |
|
168 | + $template_name = ltrim($template_name, '/'); |
|
169 | 169 | |
170 | 170 | // try locating this template file by looping through the template paths |
171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
172 | 172 | |
173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
174 | - $located = $template_path . $template_name; |
|
173 | + if (file_exists($template_path.$template_name)) { |
|
174 | + $located = $template_path.$template_name; |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if ( $located ) { |
|
179 | + if ($located) { |
|
180 | 180 | break; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
185 | - load_template( $located, $require_once ); |
|
184 | + if ((true == $load) && ! empty($located)) { |
|
185 | + load_template($located, $require_once); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
200 | 200 | |
201 | 201 | $file_paths = array( |
202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
204 | 204 | 100 => give_get_templates_dir() |
205 | 205 | ); |
206 | 206 | |
207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
208 | 208 | |
209 | 209 | // sort the file paths based on priority |
210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
210 | + ksort($file_paths, SORT_NUMERIC); |
|
211 | 211 | |
212 | - return array_map( 'trailingslashit', $file_paths ); |
|
212 | + return array_map('trailingslashit', $file_paths); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | */ |
223 | 223 | function give_get_theme_template_dir_name() { |
224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | function give_version_in_header() { |
234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
237 | +add_action('wp_head', 'give_version_in_header'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | */ |
245 | 245 | function give_is_donation_history_page() { |
246 | 246 | |
247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
247 | + $ret = is_page(give_get_option('history_page')); |
|
248 | 248 | |
249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array Modified array of classes |
260 | 260 | */ |
261 | -function give_add_body_classes( $class ) { |
|
261 | +function give_add_body_classes($class) { |
|
262 | 262 | $classes = (array) $class; |
263 | 263 | |
264 | - if ( give_is_success_page() ) { |
|
264 | + if (give_is_success_page()) { |
|
265 | 265 | $classes[] = 'give-success'; |
266 | 266 | $classes[] = 'give-page'; |
267 | 267 | } |
268 | 268 | |
269 | - if ( give_is_failed_transaction_page() ) { |
|
269 | + if (give_is_failed_transaction_page()) { |
|
270 | 270 | $classes[] = 'give-failed-transaction'; |
271 | 271 | $classes[] = 'give-page'; |
272 | 272 | } |
273 | 273 | |
274 | - if ( give_is_donation_history_page() ) { |
|
274 | + if (give_is_donation_history_page()) { |
|
275 | 275 | $classes[] = 'give-donation-history'; |
276 | 276 | $classes[] = 'give-page'; |
277 | 277 | } |
278 | 278 | |
279 | - if ( give_is_test_mode() ) { |
|
279 | + if (give_is_test_mode()) { |
|
280 | 280 | $classes[] = 'give-test-mode'; |
281 | 281 | $classes[] = 'give-page'; |
282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
285 | 285 | $current_theme = wp_get_theme(); |
286 | 286 | |
287 | - switch ( $current_theme->template ) { |
|
287 | + switch ($current_theme->template) { |
|
288 | 288 | |
289 | 289 | case 'Divi': |
290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | - return array_unique( $classes ); |
|
301 | + return array_unique($classes); |
|
302 | 302 | } |
303 | 303 | |
304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
304 | +add_filter('body_class', 'give_add_body_classes'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array |
319 | 319 | */ |
320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
322 | 322 | return $classes; |
323 | 323 | } |
324 | 324 | |
325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
326 | 326 | |
327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
328 | - unset( $classes[ $key ] ); |
|
327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
328 | + unset($classes[$key]); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | return $classes; |
332 | 332 | } |
333 | 333 | |
334 | 334 | |
335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,84 +342,84 @@ discard block |
||
342 | 342 | */ |
343 | 343 | function give_get_placeholder_img_src() { |
344 | 344 | |
345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
346 | 346 | |
347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Global |
353 | 353 | */ |
354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Output the start of the page wrapper. |
358 | 358 | */ |
359 | 359 | function give_output_content_wrapper() { |
360 | - give_get_template_part( 'global/wrapper-start' ); |
|
360 | + give_get_template_part('global/wrapper-start'); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Output the end of the page wrapper. |
367 | 367 | */ |
368 | 368 | function give_output_content_wrapper_end() { |
369 | - give_get_template_part( 'global/wrapper-end' ); |
|
369 | + give_get_template_part('global/wrapper-end'); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Single Give Form |
375 | 375 | */ |
376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
377 | 377 | function give_left_sidebar_pre_wrap() { |
378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
383 | 383 | function give_left_sidebar_post_wrap() { |
384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
389 | 389 | function give_get_forms_sidebar() { |
390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
390 | + give_get_template_part('single-give-form/sidebar'); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
394 | +if ( ! function_exists('give_show_form_images')) { |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Output the donation form featured image. |
398 | 398 | */ |
399 | 399 | function give_show_form_images() { |
400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
401 | + give_get_template_part('single-give-form/featured-image'); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
406 | +if ( ! function_exists('give_template_single_title')) { |
|
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Output the form title. |
410 | 410 | */ |
411 | 411 | function give_template_single_title() { |
412 | - give_get_template_part( 'single-give-form/title' ); |
|
412 | + give_get_template_part('single-give-form/title'); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
416 | +if ( ! function_exists('give_show_avatars')) { |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Output the product title. |
420 | 420 | */ |
421 | 421 | function give_show_avatars() { |
422 | - echo do_shortcode( '[give_donors_gravatars]' ); |
|
422 | + echo do_shortcode('[give_donors_gravatars]'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * Conditional Functions |
428 | 428 | */ |
429 | 429 | |
430 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
430 | +if ( ! function_exists('is_give_form')) { |
|
431 | 431 | |
432 | 432 | /** |
433 | 433 | * is_give_form |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * @return bool |
440 | 440 | */ |
441 | 441 | function is_give_form() { |
442 | - return is_singular( array( 'give_form' ) ); |
|
442 | + return is_singular(array('give_form')); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
446 | +if ( ! function_exists('is_give_category')) { |
|
447 | 447 | |
448 | 448 | /** |
449 | 449 | * is_give_category |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return bool |
460 | 460 | */ |
461 | - function is_give_category( $term = '' ) { |
|
462 | - return is_tax( 'give_forms_category', $term ); |
|
461 | + function is_give_category($term = '') { |
|
462 | + return is_tax('give_forms_category', $term); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
466 | +if ( ! function_exists('is_give_tag')) { |
|
467 | 467 | |
468 | 468 | /** |
469 | 469 | * is_give_tag |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | * |
479 | 479 | * @return bool |
480 | 480 | */ |
481 | - function is_give_tag( $term = '' ) { |
|
482 | - return is_tax( 'give_forms_tag', $term ); |
|
481 | + function is_give_tag($term = '') { |
|
482 | + return is_tax('give_forms_tag', $term); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
486 | +if ( ! function_exists('is_give_taxonomy')) { |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * is_give_taxonomy |
@@ -495,6 +495,6 @@ discard block |
||
495 | 495 | * @return bool |
496 | 496 | */ |
497 | 497 | function is_give_taxonomy() { |
498 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
498 | + return is_tax(get_object_taxonomies('give_form')); |
|
499 | 499 | } |
500 | 500 | } |
@@ -33,20 +33,20 @@ discard block |
||
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | - } |
|
36 | + if ( empty( $logout_redirect ) ) { |
|
37 | + $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - // Add user_logout action to logout url. |
|
42 | - $logout_redirect = add_query_arg( |
|
43 | - array( |
|
44 | - 'give_action' => 'user_logout', |
|
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | - ), |
|
48 | - home_url('/') |
|
49 | - ); |
|
41 | + // Add user_logout action to logout url. |
|
42 | + $logout_redirect = add_query_arg( |
|
43 | + array( |
|
44 | + 'give_action' => 'user_logout', |
|
45 | + 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | + 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
47 | + ), |
|
48 | + home_url('/') |
|
49 | + ); |
|
50 | 50 | |
51 | 51 | $give_login_redirect = $login_redirect; |
52 | 52 | $give_logout_redirect = $logout_redirect; |
@@ -136,31 +136,31 @@ discard block |
||
136 | 136 | * @return void |
137 | 137 | */ |
138 | 138 | function give_process_user_logout( $data ) { |
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
139 | + if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
140 | 140 | |
141 | - // Prevent occurring of any custom action on wp_logout. |
|
142 | - remove_all_actions( 'wp_logout' ); |
|
141 | + // Prevent occurring of any custom action on wp_logout. |
|
142 | + remove_all_actions( 'wp_logout' ); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Fires before processing user logout. |
146 | 146 | * |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - do_action( 'give_before_user_logout' ); |
|
149 | + do_action( 'give_before_user_logout' ); |
|
150 | 150 | |
151 | - // Logout user. |
|
152 | - wp_logout(); |
|
151 | + // Logout user. |
|
152 | + wp_logout(); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Fires after processing user logout. |
156 | 156 | * |
157 | 157 | * @since 1.0 |
158 | 158 | */ |
159 | - do_action( 'give_after_user_logout' ); |
|
159 | + do_action( 'give_after_user_logout' ); |
|
160 | 160 | |
161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
162 | - give_die(); |
|
163 | - } |
|
161 | + wp_redirect( $data['give_logout_redirect'] ); |
|
162 | + give_die(); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | add_action( 'give_user_logout', 'give_process_user_logout' ); |
@@ -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,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string Login form |
28 | 28 | */ |
29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
30 | 30 | global $give_login_redirect, $give_logout_redirect; |
31 | 31 | |
32 | - if ( empty( $login_redirect ) ) { |
|
32 | + if (empty($login_redirect)) { |
|
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
36 | + if (empty($logout_redirect)) { |
|
37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $logout_redirect = add_query_arg( |
43 | 43 | array( |
44 | 44 | 'give_action' => 'user_logout', |
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
47 | 47 | ), |
48 | 48 | home_url('/') |
49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | ob_start(); |
55 | 55 | |
56 | - give_get_template_part( 'shortcode', 'login' ); |
|
56 | + give_get_template_part('shortcode', 'login'); |
|
57 | 57 | |
58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string Register form |
70 | 70 | */ |
71 | -function give_register_form( $redirect = '' ) { |
|
71 | +function give_register_form($redirect = '') { |
|
72 | 72 | global $give_register_redirect; |
73 | 73 | |
74 | - if ( empty( $redirect ) ) { |
|
74 | + if (empty($redirect)) { |
|
75 | 75 | $redirect = give_get_current_page_url(); |
76 | 76 | } |
77 | 77 | |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | |
80 | 80 | ob_start(); |
81 | 81 | |
82 | - if ( ! is_user_logged_in() ) { |
|
83 | - give_get_template_part( 'shortcode', 'register' ); |
|
82 | + if ( ! is_user_logged_in()) { |
|
83 | + give_get_template_part('shortcode', 'register'); |
|
84 | 84 | } |
85 | 85 | |
86 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
86 | + return apply_filters('give_register_form', ob_get_clean()); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,34 +95,34 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return void |
97 | 97 | */ |
98 | -function give_process_login_form( $data ) { |
|
99 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
100 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
101 | - if ( ! $user_data ) { |
|
102 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
98 | +function give_process_login_form($data) { |
|
99 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
100 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
101 | + if ( ! $user_data) { |
|
102 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
103 | 103 | } |
104 | - if ( $user_data ) { |
|
104 | + if ($user_data) { |
|
105 | 105 | $user_ID = $user_data->ID; |
106 | 106 | $user_email = $user_data->user_email; |
107 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
108 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
107 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
108 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
109 | 109 | } else { |
110 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
110 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
111 | 111 | } |
112 | 112 | } else { |
113 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
113 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
114 | 114 | } |
115 | 115 | // Check for errors and redirect if none present |
116 | 116 | $errors = give_get_errors(); |
117 | - if ( ! $errors ) { |
|
118 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
119 | - wp_redirect( $redirect ); |
|
117 | + if ( ! $errors) { |
|
118 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
119 | + wp_redirect($redirect); |
|
120 | 120 | give_die(); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
125 | +add_action('give_user_login', 'give_process_login_form'); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | /** |
@@ -134,18 +134,18 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return void |
136 | 136 | */ |
137 | -function give_process_user_logout( $data ) { |
|
138 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
137 | +function give_process_user_logout($data) { |
|
138 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
139 | 139 | |
140 | 140 | // Prevent occurring of any custom action on wp_logout. |
141 | - remove_all_actions( 'wp_logout' ); |
|
141 | + remove_all_actions('wp_logout'); |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Fires before processing user logout. |
145 | 145 | * |
146 | 146 | * @since 1.0 |
147 | 147 | */ |
148 | - do_action( 'give_before_user_logout' ); |
|
148 | + do_action('give_before_user_logout'); |
|
149 | 149 | |
150 | 150 | // Logout user. |
151 | 151 | wp_logout(); |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @since 1.0 |
157 | 157 | */ |
158 | - do_action( 'give_after_user_logout' ); |
|
158 | + do_action('give_after_user_logout'); |
|
159 | 159 | |
160 | - wp_redirect( $data['give_logout_redirect'] ); |
|
160 | + wp_redirect($data['give_logout_redirect']); |
|
161 | 161 | give_die(); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
165 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Log User In |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
179 | - if ( $user_id < 1 ) { |
|
178 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
179 | + if ($user_id < 1) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
183 | - wp_set_auth_cookie( $user_id ); |
|
184 | - wp_set_current_user( $user_id, $user_login ); |
|
183 | + wp_set_auth_cookie($user_id); |
|
184 | + wp_set_current_user($user_id, $user_login); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Fires after the user has successfully logged in. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $user_login Username. |
192 | 192 | * @param WP_User $$user WP_User object of the logged-in user. |
193 | 193 | */ |
194 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
194 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires after give user has successfully logged in. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $user_login Username. |
203 | 203 | * @param string $user_pass User password. |
204 | 204 | */ |
205 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
205 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return void |
217 | 217 | */ |
218 | -function give_process_register_form( $data ) { |
|
218 | +function give_process_register_form($data) { |
|
219 | 219 | |
220 | - if ( is_user_logged_in() ) { |
|
220 | + if (is_user_logged_in()) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
224 | + if (empty($_POST['give_register_submit'])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
@@ -230,38 +230,38 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @since 1.0 |
232 | 232 | */ |
233 | - do_action( 'give_pre_process_register_form' ); |
|
233 | + do_action('give_pre_process_register_form'); |
|
234 | 234 | |
235 | - if ( empty( $data['give_user_login'] ) ) { |
|
236 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
235 | + if (empty($data['give_user_login'])) { |
|
236 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
240 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
239 | + if (username_exists($data['give_user_login'])) { |
|
240 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
241 | 241 | } |
242 | 242 | |
243 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
244 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
243 | + if ( ! validate_username($data['give_user_login'])) { |
|
244 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
245 | 245 | } |
246 | 246 | |
247 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
248 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
247 | + if (email_exists($data['give_user_email'])) { |
|
248 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
249 | 249 | } |
250 | 250 | |
251 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
252 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
251 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
252 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
253 | 253 | } |
254 | 254 | |
255 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
256 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
255 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
256 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
257 | 257 | } |
258 | 258 | |
259 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
260 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
259 | + if (empty($_POST['give_user_pass'])) { |
|
260 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
264 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
263 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
264 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -269,26 +269,26 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @since 1.0 |
271 | 271 | */ |
272 | - do_action( 'give_process_register_form' ); |
|
272 | + do_action('give_process_register_form'); |
|
273 | 273 | |
274 | 274 | // Check for errors and redirect if none present |
275 | 275 | $errors = give_get_errors(); |
276 | 276 | |
277 | - if ( empty( $errors ) ) { |
|
277 | + if (empty($errors)) { |
|
278 | 278 | |
279 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
279 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
280 | 280 | |
281 | - give_register_and_login_new_user( array( |
|
281 | + give_register_and_login_new_user(array( |
|
282 | 282 | 'user_login' => $data['give_user_login'], |
283 | 283 | 'user_pass' => $data['give_user_pass'], |
284 | 284 | 'user_email' => $data['give_user_email'], |
285 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
286 | - 'role' => get_option( 'default_role' ) |
|
287 | - ) ); |
|
285 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
286 | + 'role' => get_option('default_role') |
|
287 | + )); |
|
288 | 288 | |
289 | - wp_redirect( $redirect ); |
|
289 | + wp_redirect($redirect); |
|
290 | 290 | give_die(); |
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
295 | 294 | \ No newline at end of file |
295 | +add_action('give_user_register', 'give_process_register_form'); |
|
296 | 296 | \ No newline at end of file |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param atring $class Export class. |
37 | 37 | */ |
38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
39 | 39 | |
40 | 40 | $export = new $_REQUEST['class']; |
41 | 41 | $export->export(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | function give_export_earnings() { |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
57 | 57 | |
58 | 58 | $earnings_export = new Give_Earnings_Export(); |
59 | 59 | |
60 | 60 | $earnings_export->export(); |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * @return void |
74 | 74 | */ |
75 | 75 | function give_export_all_customers() { |
76 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-customers.php'; |
|
76 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-customers.php'; |
|
77 | 77 | |
78 | 78 | $customer_export = new Give_Donors_Export(); |
79 | 79 | |
80 | 80 | $customer_export->export(); |
81 | 81 | } |
82 | 82 | |
83 | -add_action( 'give_email_export', 'give_export_all_customers' ); |
|
83 | +add_action('give_email_export', 'give_export_all_customers'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Add a hook allowing extensions to register a hook on the batch export process |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | function give_register_batch_exporters() { |
92 | - if ( is_admin() ) { |
|
92 | + if (is_admin()) { |
|
93 | 93 | /** |
94 | 94 | * Fires in the admin, while plugins loaded. |
95 | 95 | * |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param string $class Export class. |
101 | 101 | */ |
102 | - do_action( 'give_register_batch_exporter' ); |
|
102 | + do_action('give_register_batch_exporter'); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
106 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Register the payments batch exporter |
110 | 110 | * @since 1.5 |
111 | 111 | */ |
112 | 112 | function give_register_payments_batch_export() { |
113 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
113 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
114 | 114 | } |
115 | 115 | |
116 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
116 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Loads the payments batch process if needed |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return void |
126 | 126 | */ |
127 | -function give_include_payments_batch_processor( $class ) { |
|
127 | +function give_include_payments_batch_processor($class) { |
|
128 | 128 | |
129 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
130 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
129 | + if ('Give_Batch_Payments_Export' === $class) { |
|
130 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @since 1.5.2 |
138 | 138 | */ |
139 | 139 | function give_register_customers_batch_export() { |
140 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
140 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
141 | 141 | } |
142 | 142 | |
143 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
143 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
144 | 144 | |
145 | 145 | /** |
146 | 146 | * Loads the customers batch process if needed |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return void |
153 | 153 | */ |
154 | -function give_include_customers_batch_processor( $class ) { |
|
154 | +function give_include_customers_batch_processor($class) { |
|
155 | 155 | |
156 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
157 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
156 | + if ('Give_Batch_Customers_Export' === $class) { |
|
157 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * @since 1.5 |
166 | 166 | */ |
167 | 167 | function give_register_forms_batch_export() { |
168 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
168 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
171 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Loads the file downloads batch process if needed |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return void |
181 | 181 | */ |
182 | -function give_include_forms_batch_processor( $class ) { |
|
182 | +function give_include_forms_batch_processor($class) { |
|
183 | 183 | |
184 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
185 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
184 | + if ('Give_Batch_Forms_Export' === $class) { |
|
185 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - if ( 'none' === $this->get_template() ) { |
|
82 | + if ('none' === $this->get_template()) { |
|
83 | 83 | $this->html = false; |
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - public function __set( $key, $value ) { |
|
96 | + public function __set($key, $value) { |
|
97 | 97 | $this->$key = $value; |
98 | 98 | } |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | 105 | public function get_from_name() { |
106 | - if ( ! $this->from_name ) { |
|
107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
106 | + if ( ! $this->from_name) { |
|
107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | 118 | public function get_from_address() { |
119 | - if ( ! $this->from_address ) { |
|
120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
119 | + if ( ! $this->from_address) { |
|
120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_content_type() { |
132 | - if ( ! $this->content_type && $this->html ) { |
|
133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
134 | - } else if ( ! $this->html ) { |
|
132 | + if ( ! $this->content_type && $this->html) { |
|
133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
134 | + } else if ( ! $this->html) { |
|
135 | 135 | $this->content_type = 'text/plain'; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | */ |
146 | 146 | public function get_headers() { |
147 | - if ( ! $this->headers ) { |
|
147 | + if ( ! $this->headers) { |
|
148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_templates() { |
162 | 162 | $templates = array( |
163 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
164 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
163 | + 'default' => esc_html__('Default Template', 'give'), |
|
164 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
165 | 165 | ); |
166 | 166 | |
167 | - return apply_filters( 'give_email_templates', $templates ); |
|
167 | + return apply_filters('give_email_templates', $templates); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @since 1.0 |
174 | 174 | */ |
175 | 175 | public function get_template() { |
176 | - if ( ! $this->template ) { |
|
177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
176 | + if ( ! $this->template) { |
|
177 | + $this->template = give_get_option('email_template', 'default'); |
|
178 | 178 | } |
179 | 179 | |
180 | - return apply_filters( 'give_email_template', $this->template ); |
|
180 | + return apply_filters('give_email_template', $this->template); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | 188 | public function get_heading() { |
189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
189 | + return apply_filters('give_email_heading', $this->heading); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function parse_tags( $content ) { |
|
199 | + public function parse_tags($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
@@ -205,19 +205,19 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - public function build_email( $message ) { |
|
208 | + public function build_email($message) { |
|
209 | 209 | |
210 | - if ( false === $this->html ) { |
|
211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
210 | + if (false === $this->html) { |
|
211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
212 | 212 | } |
213 | 213 | |
214 | - $message = $this->text_to_html( $message ); |
|
214 | + $message = $this->text_to_html($message); |
|
215 | 215 | |
216 | 216 | $template = $this->get_template(); |
217 | 217 | |
218 | 218 | ob_start(); |
219 | 219 | |
220 | - give_get_template_part( 'emails/header', $template, true ); |
|
220 | + give_get_template_part('emails/header', $template, true); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Fires in the email head. |
@@ -226,17 +226,17 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param Give_Emails $this The email object. |
228 | 228 | */ |
229 | - do_action( 'give_email_header', $this ); |
|
229 | + do_action('give_email_header', $this); |
|
230 | 230 | |
231 | - if ( has_action( 'give_email_template_' . $template ) ) { |
|
231 | + if (has_action('give_email_template_'.$template)) { |
|
232 | 232 | /** |
233 | 233 | * Fires in a specific email template. |
234 | 234 | * |
235 | 235 | * @since 1.0 |
236 | 236 | */ |
237 | - do_action( "give_email_template_{$template}" ); |
|
237 | + do_action("give_email_template_{$template}"); |
|
238 | 238 | } else { |
239 | - give_get_template_part( 'emails/body', $template, true ); |
|
239 | + give_get_template_part('emails/body', $template, true); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param Give_Emails $this The email object. |
248 | 248 | */ |
249 | - do_action( 'give_email_body', $this ); |
|
249 | + do_action('give_email_body', $this); |
|
250 | 250 | |
251 | - give_get_template_part( 'emails/footer', $template, true ); |
|
251 | + give_get_template_part('emails/footer', $template, true); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Fires in the email footer. |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param Give_Emails $this The email object. |
259 | 259 | */ |
260 | - do_action( 'give_email_footer', $this ); |
|
260 | + do_action('give_email_footer', $this); |
|
261 | 261 | |
262 | 262 | $body = ob_get_clean(); |
263 | - $message = str_replace( '{email}', $message, $body ); |
|
263 | + $message = str_replace('{email}', $message, $body); |
|
264 | 264 | |
265 | - return apply_filters( 'give_email_message', $message, $this ); |
|
265 | + return apply_filters('give_email_message', $message, $this); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return bool |
277 | 277 | */ |
278 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
278 | + public function send($to, $subject, $message, $attachments = '') { |
|
279 | 279 | |
280 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
281 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
280 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
281 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
282 | 282 | |
283 | 283 | return false; |
284 | 284 | } |
@@ -290,16 +290,16 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param Give_Emails $this The email object. |
292 | 292 | */ |
293 | - do_action( 'give_email_send_before', $this ); |
|
293 | + do_action('give_email_send_before', $this); |
|
294 | 294 | |
295 | - $subject = $this->parse_tags( $subject ); |
|
296 | - $message = $this->parse_tags( $message ); |
|
295 | + $subject = $this->parse_tags($subject); |
|
296 | + $message = $this->parse_tags($message); |
|
297 | 297 | |
298 | - $message = $this->build_email( $message ); |
|
298 | + $message = $this->build_email($message); |
|
299 | 299 | |
300 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
300 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
301 | 301 | |
302 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
302 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * Fires after sending an email. |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @param Give_Emails $this The email object. |
310 | 310 | */ |
311 | - do_action( 'give_email_send_after', $this ); |
|
311 | + do_action('give_email_send_after', $this); |
|
312 | 312 | |
313 | 313 | return $sent; |
314 | 314 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | * @since 1.0 |
321 | 321 | */ |
322 | 322 | public function send_before() { |
323 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
324 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
325 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
323 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
324 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
325 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | * @since 1.0 |
332 | 332 | */ |
333 | 333 | public function send_after() { |
334 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
335 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
336 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
334 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
335 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
336 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
337 | 337 | |
338 | 338 | // Reset heading to an empty string |
339 | 339 | $this->heading = ''; |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @since 1.0 |
346 | 346 | */ |
347 | - public function text_to_html( $message ) { |
|
347 | + public function text_to_html($message) { |
|
348 | 348 | |
349 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
350 | - $message = wpautop( $message ); |
|
349 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
350 | + $message = wpautop($message); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $message; |
@@ -10,61 +10,61 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file. |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types. |
26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type'); |
|
27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids', |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies. |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms. |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies. |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages. |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | Give()->roles->remove_caps(); |
73 | 73 | |
74 | 74 | // Delete the Roles. |
75 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
76 | - foreach ( $give_roles as $role ) { |
|
77 | - remove_role( $role ); |
|
75 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
76 | + foreach ($give_roles as $role) { |
|
77 | + remove_role($role); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Remove all database tables. |
81 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' ); |
|
82 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' ); |
|
83 | - $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' ); |
|
81 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors'); |
|
82 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers'); |
|
83 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta'); |
|
84 | 84 | |
85 | 85 | // Cleanup Cron Events. |
86 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
87 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
88 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
86 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
87 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
88 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
89 | 89 | |
90 | 90 | // Get all options. |
91 | 91 | $give_option_names = $wpdb->get_results( |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ARRAY_A |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! empty( $give_option_names ) ) { |
|
99 | + if ( ! empty($give_option_names)) { |
|
100 | 100 | // Convert option name to transient or option name. |
101 | 101 | $new_give_option_names = array(); |
102 | 102 | |
103 | - foreach ( $give_option_names as $option ) { |
|
104 | - $new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) ) |
|
105 | - ? str_replace( '_transient_', '', $option['option_name'] ) |
|
103 | + foreach ($give_option_names as $option) { |
|
104 | + $new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_')) |
|
105 | + ? str_replace('_transient_', '', $option['option_name']) |
|
106 | 106 | : $option['option_name']; |
107 | 107 | } |
108 | 108 | |
109 | 109 | $give_option_names = $new_give_option_names; |
110 | 110 | |
111 | 111 | // Delete all the Plugin Options. |
112 | - foreach ( $give_option_names as $option ) { |
|
113 | - if ( false !== strpos( $option, '_transient_' ) ) { |
|
114 | - delete_transient( $option ); |
|
112 | + foreach ($give_option_names as $option) { |
|
113 | + if (false !== strpos($option, '_transient_')) { |
|
114 | + delete_transient($option); |
|
115 | 115 | } else { |
116 | - delete_option( $option ); |
|
116 | + delete_option($option); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param $field_args |
226 | 226 | * @param $field |
227 | 227 | * |
228 | - * @return bool |
|
228 | + * @return false|null |
|
229 | 229 | */ |
230 | 230 | function give_format_admin_multilevel_amount( $field_args, $field ) { |
231 | 231 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param array $field_args |
376 | 376 | * @param object $field |
377 | 377 | * |
378 | - * @return mixed |
|
378 | + * @return string |
|
379 | 379 | */ |
380 | 380 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
381 | 381 | return stripslashes( $value ); |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param array $field_args |
409 | 409 | * @param object $field |
410 | 410 | * |
411 | - * @return mixed |
|
411 | + * @return string |
|
412 | 412 | */ |
413 | 413 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
414 | 414 | return give_sanitize_amount( $value ); |
@@ -258,50 +258,50 @@ |
||
258 | 258 | $negative = $price < 0; |
259 | 259 | |
260 | 260 | if ( $negative ) { |
261 | - // Remove proceeding "-". |
|
261 | + // Remove proceeding "-". |
|
262 | 262 | $price = substr( $price, 1 ); |
263 | 263 | } |
264 | 264 | |
265 | 265 | $symbol = give_currency_symbol( $currency ); |
266 | 266 | |
267 | - switch ( $currency ): |
|
268 | - case 'GBP' : |
|
269 | - case 'BRL' : |
|
270 | - case 'EUR' : |
|
271 | - case 'USD' : |
|
272 | - case 'AUD' : |
|
273 | - case 'CAD' : |
|
274 | - case 'HKD' : |
|
275 | - case 'MXN' : |
|
276 | - case 'NZD' : |
|
277 | - case 'SGD' : |
|
278 | - case 'JPY' : |
|
279 | - case 'THB' : |
|
280 | - case 'INR' : |
|
281 | - case 'RIAL' : |
|
282 | - case 'TRY' : |
|
283 | - case 'RUB' : |
|
284 | - case 'SEK' : |
|
285 | - case 'PLN' : |
|
286 | - case 'PHP' : |
|
287 | - case 'TWD' : |
|
288 | - case 'MYR' : |
|
289 | - case 'CZK' : |
|
290 | - case 'DKK' : |
|
291 | - case 'HUF' : |
|
292 | - case 'ILS' : |
|
293 | - case 'MAD' : |
|
294 | - case 'KRW' : |
|
295 | - case 'ZAR' : |
|
296 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
297 | - break; |
|
298 | - case 'NOK' : |
|
299 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
300 | - break; |
|
301 | - default : |
|
302 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
303 | - break; |
|
304 | - endswitch; |
|
267 | + switch ( $currency ): |
|
268 | + case 'GBP' : |
|
269 | + case 'BRL' : |
|
270 | + case 'EUR' : |
|
271 | + case 'USD' : |
|
272 | + case 'AUD' : |
|
273 | + case 'CAD' : |
|
274 | + case 'HKD' : |
|
275 | + case 'MXN' : |
|
276 | + case 'NZD' : |
|
277 | + case 'SGD' : |
|
278 | + case 'JPY' : |
|
279 | + case 'THB' : |
|
280 | + case 'INR' : |
|
281 | + case 'RIAL' : |
|
282 | + case 'TRY' : |
|
283 | + case 'RUB' : |
|
284 | + case 'SEK' : |
|
285 | + case 'PLN' : |
|
286 | + case 'PHP' : |
|
287 | + case 'TWD' : |
|
288 | + case 'MYR' : |
|
289 | + case 'CZK' : |
|
290 | + case 'DKK' : |
|
291 | + case 'HUF' : |
|
292 | + case 'ILS' : |
|
293 | + case 'MAD' : |
|
294 | + case 'KRW' : |
|
295 | + case 'ZAR' : |
|
296 | + $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
297 | + break; |
|
298 | + case 'NOK' : |
|
299 | + $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
300 | + break; |
|
301 | + default : |
|
302 | + $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
303 | + break; |
|
304 | + endswitch; |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Filter formatted amount with currency |
@@ -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,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option('thousands_separator', ','); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option('decimal_separator', '.'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -62,67 +62,67 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string $amount Newly sanitized amount |
64 | 64 | */ |
65 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
65 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
66 | 66 | |
67 | 67 | // Bailout. |
68 | - if ( empty( $number ) ) { |
|
68 | + if (empty($number)) { |
|
69 | 69 | return $number; |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Remove slash from amount. |
73 | 73 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
74 | 74 | // To prevent notices and warning remove slash from amount/number. |
75 | - $number = wp_unslash( $number ); |
|
75 | + $number = wp_unslash($number); |
|
76 | 76 | |
77 | 77 | $thousand_separator = give_get_price_thousand_separator(); |
78 | 78 | |
79 | 79 | $locale = localeconv(); |
80 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
80 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
81 | 81 | |
82 | 82 | // Remove locale from string |
83 | - if ( ! is_float( $number ) ) { |
|
84 | - $number = str_replace( $decimals, '.', $number ); |
|
83 | + if ( ! is_float($number)) { |
|
84 | + $number = str_replace($decimals, '.', $number); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Remove thousand amount formatting if amount has. |
88 | 88 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
89 | 89 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
90 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
91 | - $number = str_replace( $thousand_separator, '', $number ); |
|
92 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
93 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
90 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
91 | + $number = str_replace($thousand_separator, '', $number); |
|
92 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
93 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | // Remove non numeric entity before decimal separator. |
97 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
97 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
98 | 98 | $default_dp = give_get_price_decimals(); |
99 | 99 | |
100 | 100 | // Reset negative amount to zero. |
101 | - if ( 0 > $number ) { |
|
102 | - $number = number_format( 0, $default_dp, '.' ); |
|
101 | + if (0 > $number) { |
|
102 | + $number = number_format(0, $default_dp, '.'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // If number does not have decimal then add number of decimals to it. |
106 | 106 | if ( |
107 | - false === strpos( $number, '.' ) |
|
108 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
107 | + false === strpos($number, '.') |
|
108 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
109 | 109 | ) { |
110 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
110 | + $number = number_format($number, $default_dp, '.', ''); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Format number by custom number of decimals. |
114 | - if ( false !== $dp ) { |
|
115 | - $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
116 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
117 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
114 | + if (false !== $dp) { |
|
115 | + $dp = intval(empty($dp) ? $default_dp : $dp); |
|
116 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
117 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Trim zeros. |
121 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
122 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
121 | + if ($trim_zeros && strstr($number, '.')) { |
|
122 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
123 | 123 | } |
124 | 124 | |
125 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
125 | + return apply_filters('give_sanitize_amount', $number); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -135,22 +135,22 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string $amount Newly formatted amount or Price Not Available |
137 | 137 | */ |
138 | -function give_format_amount( $amount, $decimals = true ) { |
|
139 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
140 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
138 | +function give_format_amount($amount, $decimals = true) { |
|
139 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
140 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
141 | 141 | |
142 | - if ( empty( $amount ) ) { |
|
142 | + if (empty($amount)) { |
|
143 | 143 | $amount = 0; |
144 | 144 | } else { |
145 | 145 | // Sanitize amount before formatting. |
146 | - $amount = give_sanitize_amount( $amount ); |
|
146 | + $amount = give_sanitize_amount($amount); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $decimals = $decimals ? give_get_price_decimals() : 0; |
150 | 150 | |
151 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
151 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
152 | 152 | |
153 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
153 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -167,33 +167,33 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return float|string formatted amount number with large number names. |
169 | 169 | */ |
170 | -function give_human_format_large_amount( $amount ) { |
|
170 | +function give_human_format_large_amount($amount) { |
|
171 | 171 | |
172 | 172 | // Get thousand separator. |
173 | 173 | $thousands_sep = give_get_price_thousand_separator(); |
174 | 174 | |
175 | 175 | // Sanitize amount. |
176 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
176 | + $sanitize_amount = give_sanitize_amount($amount); |
|
177 | 177 | |
178 | 178 | // Explode amount to calculate name of large numbers. |
179 | - $amount_array = explode( $thousands_sep, $amount ); |
|
179 | + $amount_array = explode($thousands_sep, $amount); |
|
180 | 180 | |
181 | 181 | // Calculate amount parts count. |
182 | - $amount_count_parts = count( $amount_array ); |
|
182 | + $amount_count_parts = count($amount_array); |
|
183 | 183 | |
184 | 184 | // Human format amount (default). |
185 | 185 | $human_format_amount = $amount; |
186 | 186 | |
187 | 187 | // Calculate large number formatted amount. |
188 | - if ( 4 < $amount_count_parts ) { |
|
189 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
190 | - } elseif ( 3 < $amount_count_parts ) { |
|
191 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
192 | - } elseif ( 2 < $amount_count_parts ) { |
|
193 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
188 | + if (4 < $amount_count_parts) { |
|
189 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
190 | + } elseif (3 < $amount_count_parts) { |
|
191 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
192 | + } elseif (2 < $amount_count_parts) { |
|
193 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
194 | 194 | } |
195 | 195 | |
196 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
196 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return string $amount Newly formatted amount or Price Not Available |
208 | 208 | */ |
209 | -function give_format_decimal( $amount, $dp = false ) { |
|
209 | +function give_format_decimal($amount, $dp = false) { |
|
210 | 210 | $decimal_separator = give_get_price_decimal_separator(); |
211 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
211 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
212 | 212 | |
213 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
214 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
213 | + if (false !== strpos($formatted_amount, '.')) { |
|
214 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
215 | 215 | } |
216 | 216 | |
217 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
217 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return bool |
230 | 230 | */ |
231 | -function give_format_admin_multilevel_amount( $field_args, $field ) { |
|
231 | +function give_format_admin_multilevel_amount($field_args, $field) { |
|
232 | 232 | |
233 | - if ( empty( $field->value ) ) { |
|
233 | + if (empty($field->value)) { |
|
234 | 234 | return false; |
235 | 235 | } |
236 | 236 | |
237 | - $field->value = give_format_decimal( $field->value ); |
|
237 | + $field->value = give_format_decimal($field->value); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -247,24 +247,24 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return mixed|string|void |
249 | 249 | */ |
250 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
250 | +function give_currency_filter($price = '', $currency = '') { |
|
251 | 251 | |
252 | - if ( empty( $currency ) ) { |
|
252 | + if (empty($currency)) { |
|
253 | 253 | $currency = give_get_currency(); |
254 | 254 | } |
255 | 255 | |
256 | - $position = give_get_option( 'currency_position', 'before' ); |
|
256 | + $position = give_get_option('currency_position', 'before'); |
|
257 | 257 | |
258 | 258 | $negative = $price < 0; |
259 | 259 | |
260 | - if ( $negative ) { |
|
260 | + if ($negative) { |
|
261 | 261 | // Remove proceeding "-". |
262 | - $price = substr( $price, 1 ); |
|
262 | + $price = substr($price, 1); |
|
263 | 263 | } |
264 | 264 | |
265 | - $symbol = give_currency_symbol( $currency ); |
|
265 | + $symbol = give_currency_symbol($currency); |
|
266 | 266 | |
267 | - switch ( $currency ): |
|
267 | + switch ($currency): |
|
268 | 268 | case 'GBP' : |
269 | 269 | case 'BRL' : |
270 | 270 | case 'EUR' : |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | case 'MAD' : |
294 | 294 | case 'KRW' : |
295 | 295 | case 'ZAR' : |
296 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
296 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
297 | 297 | break; |
298 | 298 | case 'NOK' : |
299 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
299 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
300 | 300 | break; |
301 | 301 | default : |
302 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
302 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
303 | 303 | break; |
304 | 304 | endswitch; |
305 | 305 | |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | * filter name will be give_usd_currency_filter_after |
316 | 316 | * |
317 | 317 | */ |
318 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
318 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
319 | 319 | |
320 | - if ( $negative ) { |
|
320 | + if ($negative) { |
|
321 | 321 | // Prepend the minus sign before the currency sign. |
322 | - $formatted = '-' . $formatted; |
|
322 | + $formatted = '-'.$formatted; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | return $formatted; |
@@ -335,22 +335,22 @@ discard block |
||
335 | 335 | */ |
336 | 336 | function give_currency_decimal_filter() { |
337 | 337 | |
338 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
338 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
339 | 339 | |
340 | 340 | // Set default number of decimals. |
341 | 341 | $decimals = give_get_price_decimals(); |
342 | 342 | |
343 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
343 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
344 | 344 | |
345 | 345 | |
346 | 346 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
347 | - if ( 1 <= func_num_args() ) { |
|
348 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
347 | + if (1 <= func_num_args()) { |
|
348 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | $currency = give_get_currency(); |
352 | 352 | |
353 | - switch ( $currency ) { |
|
353 | + switch ($currency) { |
|
354 | 354 | case 'RIAL' : |
355 | 355 | case 'JPY' : |
356 | 356 | case 'TWD' : |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | break; |
361 | 361 | } |
362 | 362 | |
363 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
363 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
364 | 364 | } |
365 | 365 | |
366 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
367 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
366 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
367 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * Sanitize thousand separator |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return mixed |
380 | 380 | */ |
381 | -function give_sanitize_thousand_separator( $value, $field_args, $field ) { |
|
382 | - return stripslashes( $value ); |
|
381 | +function give_sanitize_thousand_separator($value, $field_args, $field) { |
|
382 | + return stripslashes($value); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return mixed |
397 | 397 | */ |
398 | -function give_sanitize_number_decimals( $value, $field_args, $field ) { |
|
399 | - return absint( $value ); |
|
398 | +function give_sanitize_number_decimals($value, $field_args, $field) { |
|
399 | + return absint($value); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return mixed |
413 | 413 | */ |
414 | -function give_sanitize_price_field_value( $value, $field_args, $field ) { |
|
415 | - return give_sanitize_amount( $value ); |
|
414 | +function give_sanitize_price_field_value($value, $field_args, $field) { |
|
415 | + return give_sanitize_amount($value); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return string Date format string |
428 | 428 | */ |
429 | -function give_date_format ( $date_context = '' ) { |
|
429 | +function give_date_format($date_context = '') { |
|
430 | 430 | /** |
431 | 431 | * Filter the date context |
432 | 432 | * |
@@ -447,20 +447,20 @@ discard block |
||
447 | 447 | * |
448 | 448 | * } |
449 | 449 | */ |
450 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
450 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
451 | 451 | |
452 | 452 | // Set date format to default date format. |
453 | 453 | $date_format = get_option('date_format'); |
454 | 454 | |
455 | 455 | |
456 | 456 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
457 | - if( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
458 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
459 | - ? $date_format_contexts[ $date_context ] |
|
457 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
458 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
459 | + ? $date_format_contexts[$date_context] |
|
460 | 460 | : $date_format; |
461 | 461 | } |
462 | 462 | |
463 | - return apply_filters( 'give_date_format', $date_format ); |
|
463 | + return apply_filters('give_date_format', $date_format); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -473,13 +473,13 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | -function give_get_cache_key( $action, $query_args ) { |
|
476 | +function give_get_cache_key($action, $query_args) { |
|
477 | 477 | // Bailout. |
478 | - if( ! is_array( $query_args ) || empty( $query_args ) ) { |
|
478 | + if ( ! is_array($query_args) || empty($query_args)) { |
|
479 | 479 | return ''; |
480 | 480 | } |
481 | 481 | |
482 | - return "give_cache_{$action}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
482 | + return "give_cache_{$action}_".substr(md5(serialize($query_args)), 0, 15); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * @param string|array $var |
491 | 491 | * @return string|array |
492 | 492 | */ |
493 | -function give_clean( $var ) { |
|
494 | - if ( is_array( $var ) ) { |
|
495 | - return array_map( 'give_clean', $var ); |
|
493 | +function give_clean($var) { |
|
494 | + if (is_array($var)) { |
|
495 | + return array_map('give_clean', $var); |
|
496 | 496 | } else { |
497 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
497 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | * @param $size |
507 | 507 | * @return int |
508 | 508 | */ |
509 | -function give_let_to_num( $size ) { |
|
510 | - $l = substr( $size, -1 ); |
|
511 | - $ret = substr( $size, 0, -1 ); |
|
512 | - switch ( strtoupper( $l ) ) { |
|
509 | +function give_let_to_num($size) { |
|
510 | + $l = substr($size, -1); |
|
511 | + $ret = substr($size, 0, -1); |
|
512 | + switch (strtoupper($l)) { |
|
513 | 513 | case 'P': |
514 | 514 | $ret *= 1024; |
515 | 515 | case 'T': |
@@ -689,7 +689,7 @@ |
||
689 | 689 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
690 | 690 | esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
691 | 691 | ); |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $messages[$subscription['id']] = sprintf( |
694 | 694 | __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
695 | 695 | human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @access private |
220 | 220 | * @since 1.0 |
221 | 221 | * |
222 | - * @return bool |
|
222 | + * @return false|null |
|
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @access public |
476 | 476 | * @since 1.7 |
477 | 477 | * |
478 | - * @return bool|void |
|
478 | + * @return false|null |
|
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @access public |
528 | 528 | * @since 1.7 |
529 | 529 | * |
530 | - * @return bool|void |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @access private |
608 | 608 | * @since 1.7 |
609 | 609 | * |
610 | - * @return bool|void |
|
610 | + * @return false|null |
|
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * @access private |
803 | 803 | * @since 1.7 |
804 | 804 | * |
805 | - * @return void|bool |
|
805 | + * @return false|null |
|
806 | 806 | */ |
807 | 807 | private function __remove_license_key_from_subscriptions(){ |
808 | 808 | $subscriptions = get_option( 'give_subscriptions', array() ); |
@@ -10,11 +10,11 @@ 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 | |
17 | -if ( ! class_exists( 'Give_License' ) ) : |
|
17 | +if ( ! class_exists('Give_License')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_License Class |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var string |
105 | 105 | */ |
106 | - private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
106 | + private $api_url = 'https://givewp.com/edd-sl-api/'; |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Account URL |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @var null|string |
115 | 115 | */ |
116 | - private $account_url = 'https://givewp.com/my-account/'; |
|
116 | + private $account_url = 'https://givewp.com/my-account/'; |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Ccheckout URL |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $_checkout_url |
143 | 143 | * @param string $_account_url |
144 | 144 | */ |
145 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) { |
|
145 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) { |
|
146 | 146 | $give_options = give_get_settings(); |
147 | 147 | |
148 | 148 | $this->file = $_file; |
149 | 149 | $this->item_name = $_item_name; |
150 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
150 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
151 | 151 | $this->version = $_version; |
152 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
153 | - $this->license_data = get_option( $this->item_shortname . '_license_active' ); |
|
152 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
153 | + $this->license_data = get_option($this->item_shortname.'_license_active'); |
|
154 | 154 | $this->author = $_author; |
155 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
156 | - $this->checkout_url = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url; |
|
157 | - $this->account_url = is_null( $_account_url ) ? $this->account_url : $_account_url; |
|
155 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
156 | + $this->checkout_url = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url; |
|
157 | + $this->account_url = is_null($_account_url) ? $this->account_url : $_account_url; |
|
158 | 158 | |
159 | 159 | // Setup hooks |
160 | 160 | $this->includes(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return void |
174 | 174 | */ |
175 | 175 | private function includes() { |
176 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
176 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
177 | 177 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
178 | 178 | } |
179 | 179 | } |
@@ -191,26 +191,26 @@ discard block |
||
191 | 191 | private function hooks() { |
192 | 192 | |
193 | 193 | // Register settings |
194 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
194 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
195 | 195 | |
196 | 196 | // Activate license key on settings save |
197 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
197 | + add_action('admin_init', array($this, 'activate_license')); |
|
198 | 198 | |
199 | 199 | // Deactivate license key |
200 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
200 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
201 | 201 | |
202 | 202 | // Updater |
203 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
203 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
204 | 204 | |
205 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
205 | + add_action('admin_notices', array($this, 'notices')); |
|
206 | 206 | |
207 | 207 | // Check license weekly. |
208 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) ); |
|
209 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) ); |
|
208 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check')); |
|
209 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check')); |
|
210 | 210 | |
211 | 211 | // Check subscription weekly. |
212 | - add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) ); |
|
213 | - add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) ); |
|
212 | + add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check')); |
|
213 | + add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function auto_updater() { |
225 | 225 | |
226 | - if ( ! $this->is_valid_license() ) { |
|
226 | + if ( ! $this->is_valid_license()) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
@@ -252,16 +252,16 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return array License settings. |
254 | 254 | */ |
255 | - public function settings( $settings ) { |
|
255 | + public function settings($settings) { |
|
256 | 256 | |
257 | 257 | $give_license_settings = array( |
258 | 258 | array( |
259 | 259 | 'name' => $this->item_name, |
260 | - 'id' => $this->item_shortname . '_license_key', |
|
260 | + 'id' => $this->item_shortname.'_license_key', |
|
261 | 261 | 'desc' => '', |
262 | 262 | 'type' => 'license_key', |
263 | 263 | 'options' => array( |
264 | - 'license' => get_option( $this->item_shortname . '_license_active' ), |
|
264 | + 'license' => get_option($this->item_shortname.'_license_active'), |
|
265 | 265 | 'shortname' => $this->item_shortname, |
266 | 266 | 'item_name' => $this->item_name, |
267 | 267 | 'api_url' => $this->api_url, |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | ); |
274 | 274 | |
275 | - return array_merge( $settings, $give_license_settings ); |
|
275 | + return array_merge($settings, $give_license_settings); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return array License settings content. |
289 | 289 | */ |
290 | - public function license_settings_content( $settings ) { |
|
290 | + public function license_settings_content($settings) { |
|
291 | 291 | |
292 | 292 | $give_license_settings = array( |
293 | 293 | array( |
294 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
294 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
295 | 295 | 'desc' => '<hr>', |
296 | 296 | 'type' => 'give_title', |
297 | 297 | 'id' => 'give_title' |
298 | 298 | ), |
299 | 299 | ); |
300 | 300 | |
301 | - return array_merge( $settings, $give_license_settings ); |
|
301 | + return array_merge($settings, $give_license_settings); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -313,37 +313,37 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function activate_license() { |
315 | 315 | // Bailout: Check if license key set of not. |
316 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
316 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Security check. |
321 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
321 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
322 | 322 | |
323 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
323 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Check if user have correct permissions. |
328 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
328 | + if ( ! current_user_can('manage_give_settings')) { |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Allow third party addon developers to handle license activation. |
333 | - if( $this->__is_third_party_addon() ){ |
|
334 | - do_action( 'give_activate_license', $this ); |
|
333 | + if ($this->__is_third_party_addon()) { |
|
334 | + do_action('give_activate_license', $this); |
|
335 | 335 | return; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // Delete previous license setting if a empty license key submitted. |
339 | - if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
340 | - delete_option( $this->item_shortname . '_license_active' ); |
|
339 | + if (empty($_POST[$this->item_shortname.'_license_key'])) { |
|
340 | + delete_option($this->item_shortname.'_license_active'); |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Do not simultaneously activate any addon if user want to deactivate any addon. |
345 | - foreach ( $_POST as $key => $value ) { |
|
346 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
345 | + foreach ($_POST as $key => $value) { |
|
346 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
347 | 347 | // Don't activate a key when deactivating a different key |
348 | 348 | return; |
349 | 349 | } |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | |
352 | 352 | |
353 | 353 | // Check if plugin previously installed. |
354 | - if ( $this->is_valid_license() ) { |
|
354 | + if ($this->is_valid_license()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | 358 | // Get license key. |
359 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
359 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
360 | 360 | |
361 | 361 | // Bailout. |
362 | - if( empty( $license ) ) { |
|
362 | + if (empty($license)) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $api_params = array( |
371 | 371 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
372 | 372 | 'license' => $license, |
373 | - 'item_name' => urlencode( $this->item_name ), |
|
373 | + 'item_name' => urlencode($this->item_name), |
|
374 | 374 | 'url' => home_url() |
375 | 375 | ); |
376 | 376 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | ); |
386 | 386 | |
387 | 387 | // Make sure there are no errors |
388 | - if ( is_wp_error( $response ) ) { |
|
388 | + if (is_wp_error($response)) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | // Tell WordPress to look for updates |
393 | - set_site_transient( 'update_plugins', null ); |
|
393 | + set_site_transient('update_plugins', null); |
|
394 | 394 | |
395 | 395 | // Decode license data |
396 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
397 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
396 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
397 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
398 | 398 | |
399 | 399 | // Check subscription for license key and store this to db (if any). |
400 | 400 | $this->__single_subscription_check(); |
@@ -412,34 +412,34 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function deactivate_license() { |
414 | 414 | |
415 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
415 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
419 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
420 | 420 | |
421 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
421 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
425 | + if ( ! current_user_can('manage_give_settings')) { |
|
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | 429 | // Allow third party addon developers to handle license deactivation. |
430 | - if( $this->__is_third_party_addon() ){ |
|
431 | - do_action( 'give_deactivate_license', $this ); |
|
430 | + if ($this->__is_third_party_addon()) { |
|
431 | + do_action('give_deactivate_license', $this); |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // Run on deactivate button press |
436 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
436 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
441 | 441 | 'license' => $this->license, |
442 | - 'item_name' => urlencode( $this->item_name ), |
|
442 | + 'item_name' => urlencode($this->item_name), |
|
443 | 443 | 'url' => home_url() |
444 | 444 | ); |
445 | 445 | |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors |
457 | - if ( is_wp_error( $response ) ) { |
|
457 | + if (is_wp_error($response)) { |
|
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
461 | 461 | // Decode the license data |
462 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
462 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
463 | 463 | |
464 | 464 | // Remove license data. |
465 | - delete_option( $this->item_shortname . '_license_active' ); |
|
465 | + delete_option($this->item_shortname.'_license_active'); |
|
466 | 466 | |
467 | 467 | // Remove license key from subscriptions if exist. |
468 | 468 | $this->__remove_license_key_from_subscriptions(); |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function weekly_license_check() { |
481 | 481 | |
482 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
482 | + if ( ! empty($_POST['give_settings'])) { |
|
483 | 483 | // Don't fire when saving settings |
484 | 484 | return false; |
485 | 485 | } |
486 | 486 | |
487 | - if( empty( $this->license ) ) { |
|
487 | + if (empty($this->license)) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | // Allow third party addon developers to handle their license check. |
492 | - if( $this->__is_third_party_addon() ){ |
|
493 | - do_action( 'give_weekly_license_check', $this ); |
|
492 | + if ($this->__is_third_party_addon()) { |
|
493 | + do_action('give_weekly_license_check', $this); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $api_params = array( |
499 | 499 | 'edd_action'=> 'check_license', |
500 | 500 | 'license' => $this->license, |
501 | - 'item_name' => urlencode( $this->item_name ), |
|
501 | + 'item_name' => urlencode($this->item_name), |
|
502 | 502 | 'url' => home_url() |
503 | 503 | ); |
504 | 504 | |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Make sure the response came back okay. |
516 | - if ( is_wp_error( $response ) ) { |
|
516 | + if (is_wp_error($response)) { |
|
517 | 517 | return false; |
518 | 518 | } |
519 | 519 | |
520 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
521 | - update_option( $this->item_shortname . '_license_active', $license_data ); |
|
520 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
521 | + update_option($this->item_shortname.'_license_active', $license_data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -531,24 +531,24 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function weekly_subscription_check() { |
533 | 533 | |
534 | - if( ! empty( $_POST['give_settings'] ) ) { |
|
534 | + if ( ! empty($_POST['give_settings'])) { |
|
535 | 535 | // Don't fire when saving settings |
536 | 536 | return false; |
537 | 537 | } |
538 | 538 | |
539 | 539 | // Remove old subscription data. |
540 | - if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){ |
|
541 | - delete_option( 'give_subscriptions' ); |
|
542 | - update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) ); |
|
540 | + if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) { |
|
541 | + delete_option('give_subscriptions'); |
|
542 | + update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1))); |
|
543 | 543 | } |
544 | 544 | |
545 | - if( empty( $this->license ) ) { |
|
545 | + if (empty($this->license)) { |
|
546 | 546 | return false; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Allow third party addon developers to handle there subscription check. |
550 | - if( $this->__is_third_party_addon() ){ |
|
551 | - do_action( 'give_weekly_subscription_check', $this ); |
|
550 | + if ($this->__is_third_party_addon()) { |
|
551 | + do_action('give_weekly_subscription_check', $this); |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | // This is custom feature to check subscriptions. |
563 | 563 | 'edd_action'=> 'check_subscription', |
564 | 564 | 'license' => $this->license, |
565 | - 'item_name' => urlencode( $this->item_name ), |
|
565 | + 'item_name' => urlencode($this->item_name), |
|
566 | 566 | 'url' => home_url() |
567 | 567 | ); |
568 | 568 | |
@@ -577,27 +577,27 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure the response came back okay. |
580 | - if ( is_wp_error( $response ) ) { |
|
580 | + if (is_wp_error($response)) { |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
584 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
585 | 585 | |
586 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
587 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
586 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
587 | + $subscriptions = get_option('give_subscriptions', array()); |
|
588 | 588 | |
589 | 589 | // Update subscription data only if subscription does not exist already. |
590 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
591 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
592 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
590 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
591 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
592 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | // Store licenses for subscription. |
596 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
597 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
596 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
597 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
598 | 598 | } |
599 | 599 | |
600 | - update_option( 'give_subscriptions', $subscriptions ); |
|
600 | + update_option('give_subscriptions', $subscriptions); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private function __single_subscription_check() { |
613 | 613 | // Do not fire if license key is not set. |
614 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
614 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | |
618 | - if( empty( $this->license ) ) { |
|
618 | + if (empty($this->license)) { |
|
619 | 619 | return false; |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // This is custom feature to check subscriptions. |
627 | 627 | 'edd_action'=> 'check_subscription', |
628 | 628 | 'license' => $this->license, |
629 | - 'item_name' => urlencode( $this->item_name ), |
|
629 | + 'item_name' => urlencode($this->item_name), |
|
630 | 630 | 'url' => home_url() |
631 | 631 | ); |
632 | 632 | |
@@ -641,27 +641,27 @@ discard block |
||
641 | 641 | ); |
642 | 642 | |
643 | 643 | // Make sure the response came back okay. |
644 | - if ( is_wp_error( $response ) ) { |
|
644 | + if (is_wp_error($response)) { |
|
645 | 645 | return false; |
646 | 646 | } |
647 | 647 | |
648 | - $subscription_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
648 | + $subscription_data = json_decode(wp_remote_retrieve_body($response), true); |
|
649 | 649 | |
650 | - if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) { |
|
651 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
650 | + if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) { |
|
651 | + $subscriptions = get_option('give_subscriptions', array()); |
|
652 | 652 | |
653 | 653 | // Update subscription data only if subscription does not exist already. |
654 | - if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) { |
|
655 | - $subscriptions[ $subscription_data['id'] ] = $subscription_data; |
|
656 | - $subscriptions[ $subscription_data['id'] ]['licenses'] = array(); |
|
654 | + if ( ! array_key_exists($subscription_data['id'], $subscriptions)) { |
|
655 | + $subscriptions[$subscription_data['id']] = $subscription_data; |
|
656 | + $subscriptions[$subscription_data['id']]['licenses'] = array(); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | // Store licenses for subscription. |
660 | - if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) { |
|
661 | - $subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license; |
|
660 | + if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) { |
|
661 | + $subscriptions[$subscription_data['id']]['licenses'][] = $this->license; |
|
662 | 662 | } |
663 | 663 | |
664 | - update_option( 'give_subscriptions', $subscriptions ); |
|
664 | + update_option('give_subscriptions', $subscriptions); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
@@ -679,87 +679,87 @@ discard block |
||
679 | 679 | static $addon_license_key_in_subscriptions; |
680 | 680 | |
681 | 681 | // Set default value. |
682 | - $addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array(); |
|
682 | + $addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array(); |
|
683 | 683 | |
684 | - if( empty( $this->license ) ) { |
|
684 | + if (empty($this->license)) { |
|
685 | 685 | return; |
686 | 686 | } |
687 | 687 | |
688 | - if( ! current_user_can( 'manage_shop_settings' ) ) { |
|
688 | + if ( ! current_user_can('manage_shop_settings')) { |
|
689 | 689 | return; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Do not show licenses notices on license tab. |
693 | - if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) { |
|
693 | + if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) { |
|
694 | 694 | return; |
695 | 695 | } |
696 | 696 | |
697 | 697 | $messages = array(); |
698 | 698 | |
699 | 699 | // Get subscriptions. |
700 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
700 | + $subscriptions = get_option('give_subscriptions'); |
|
701 | 701 | |
702 | 702 | // Show subscription messages. |
703 | - if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) { |
|
703 | + if ( ! empty($subscriptions) && ! $showed_subscriptions_message) { |
|
704 | 704 | |
705 | - foreach ( $subscriptions as $subscription ) { |
|
705 | + foreach ($subscriptions as $subscription) { |
|
706 | 706 | // Subscription expires timestamp. |
707 | - $subscription_expires = strtotime( $subscription['expires'] ); |
|
707 | + $subscription_expires = strtotime($subscription['expires']); |
|
708 | 708 | |
709 | 709 | // Start showing subscriptions message before one week of renewal date. |
710 | - if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) { |
|
710 | + if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) { |
|
711 | 711 | continue; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // Check if subscription message already exist in messages. |
715 | - if( array_key_exists( $subscription['id'], $messages ) ) { |
|
715 | + if (array_key_exists($subscription['id'], $messages)) { |
|
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | |
719 | - if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) { |
|
719 | + if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) { |
|
720 | 720 | |
721 | - if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired. |
|
721 | + if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired. |
|
722 | 722 | $messages[$subscription['id']] = sprintf( |
723 | - __( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
724 | - urldecode( $subscription['invoice_url'] ), |
|
723 | + __('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
724 | + urldecode($subscription['invoice_url']), |
|
725 | 725 | $subscription['payment_id'], |
726 | 726 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
727 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
727 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
728 | 728 | ); |
729 | - }else{ |
|
729 | + } else { |
|
730 | 730 | $messages[$subscription['id']] = sprintf( |
731 | - __( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ), |
|
732 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ), |
|
733 | - urldecode( $subscription['invoice_url'] ), |
|
731 | + __('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'), |
|
732 | + human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])), |
|
733 | + urldecode($subscription['invoice_url']), |
|
734 | 734 | $subscription['payment_id'], |
735 | 735 | "{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired", |
736 | - esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) ) |
|
736 | + esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'])) |
|
737 | 737 | ); |
738 | 738 | } |
739 | 739 | } |
740 | 740 | |
741 | 741 | // Stop validation for these licencse keys. |
742 | - $addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] ); |
|
742 | + $addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']); |
|
743 | 743 | } |
744 | 744 | $showed_subscriptions_message = true; |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Show non subscription addon messages. |
748 | - if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) { |
|
748 | + if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) { |
|
749 | 749 | |
750 | 750 | $messages['general'] = sprintf( |
751 | - __( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ), |
|
752 | - admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) |
|
751 | + __('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'), |
|
752 | + admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses') |
|
753 | 753 | ); |
754 | 754 | $showed_invalid_message = true; |
755 | 755 | |
756 | 756 | } |
757 | 757 | |
758 | 758 | // Print messages. |
759 | - if( ! empty( $messages ) ) { |
|
760 | - foreach( $messages as $notice_id => $message ) { |
|
761 | - echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">'; |
|
762 | - echo '<p>' . $message . '</p>'; |
|
759 | + if ( ! empty($messages)) { |
|
760 | + foreach ($messages as $notice_id => $message) { |
|
761 | + echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">'; |
|
762 | + echo '<p>'.$message.'</p>'; |
|
763 | 763 | echo '</div>'; |
764 | 764 | } |
765 | 765 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @return bool |
775 | 775 | */ |
776 | 776 | public function is_valid_license() { |
777 | - if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) { |
|
777 | + if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) { |
|
778 | 778 | return true; |
779 | 779 | } |
780 | 780 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return bool |
791 | 791 | */ |
792 | 792 | private function __is_third_party_addon() { |
793 | - return ( false === strpos( $this->api_url, 'givewp.com/' ) ); |
|
793 | + return (false === strpos($this->api_url, 'givewp.com/')); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -804,26 +804,26 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return void|bool |
806 | 806 | */ |
807 | - private function __remove_license_key_from_subscriptions(){ |
|
808 | - $subscriptions = get_option( 'give_subscriptions', array() ); |
|
807 | + private function __remove_license_key_from_subscriptions() { |
|
808 | + $subscriptions = get_option('give_subscriptions', array()); |
|
809 | 809 | |
810 | 810 | // Bailout. |
811 | - if( empty( $this->license ) ) { |
|
811 | + if (empty($this->license)) { |
|
812 | 812 | return false; |
813 | 813 | } |
814 | 814 | |
815 | - if( ! empty( $subscriptions ) ) { |
|
816 | - foreach ( $subscriptions as $subscription_id => $subscription ) { |
|
817 | - $license_index = array_search( $this->license, $subscription['licenses'] ); |
|
818 | - if( false !== $license_index ) { |
|
815 | + if ( ! empty($subscriptions)) { |
|
816 | + foreach ($subscriptions as $subscription_id => $subscription) { |
|
817 | + $license_index = array_search($this->license, $subscription['licenses']); |
|
818 | + if (false !== $license_index) { |
|
819 | 819 | // Remove license key. |
820 | - unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] ); |
|
820 | + unset($subscriptions[$subscription_id]['licenses'][$license_index]); |
|
821 | 821 | |
822 | 822 | // Rearrange license keys. |
823 | - $subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] ); |
|
823 | + $subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']); |
|
824 | 824 | |
825 | 825 | // Update subscription information. |
826 | - update_option( 'give_subscriptions', $subscriptions ); |
|
826 | + update_option('give_subscriptions', $subscriptions); |
|
827 | 827 | break; |
828 | 828 | } |
829 | 829 | } |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * |
839 | 839 | * @return void |
840 | 840 | */ |
841 | - private function __remove_license_notices_show_blocker(){ |
|
841 | + private function __remove_license_notices_show_blocker() { |
|
842 | 842 | global $wpdb; |
843 | 843 | |
844 | 844 | // Delete permanent notice blocker. |
@@ -876,18 +876,18 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return bool |
878 | 878 | */ |
879 | - private function __is_notice_dismissed( $notice_id ){ |
|
879 | + private function __is_notice_dismissed($notice_id) { |
|
880 | 880 | $current_user = wp_get_current_user(); |
881 | 881 | $is_notice_dismissed = false; |
882 | 882 | |
883 | 883 | // Ge is notice dismissed permanently. |
884 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
884 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
885 | 885 | ? $already_dismiss_notices |
886 | 886 | : array(); |
887 | 887 | |
888 | 888 | |
889 | - if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) { |
|
890 | - $is_notice_dismissed = true; |
|
889 | + if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) { |
|
890 | + $is_notice_dismissed = true; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | return $is_notice_dismissed; |