@@ -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 | |
@@ -74,57 +74,57 @@ discard block |
||
| 74 | 74 | public function __construct() { |
| 75 | 75 | |
| 76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
| 77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
| 77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
| 78 | 78 | |
| 79 | 79 | // PHP Sessions. |
| 80 | - if ( $this->use_php_sessions ) { |
|
| 80 | + if ($this->use_php_sessions) { |
|
| 81 | 81 | |
| 82 | - if ( is_multisite() ) { |
|
| 82 | + if (is_multisite()) { |
|
| 83 | 83 | |
| 84 | - $this->prefix = '_' . get_current_blog_id(); |
|
| 84 | + $this->prefix = '_'.get_current_blog_id(); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
| 88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
| 89 | 89 | |
| 90 | 90 | } else { |
| 91 | 91 | |
| 92 | - if ( ! $this->should_start_session() ) { |
|
| 92 | + if ( ! $this->should_start_session()) { |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Use WP_Session. |
| 97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
| 97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
| 98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
| 102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Include utilities class |
| 106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
| 107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
| 106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
| 107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
| 108 | 108 | } |
| 109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
| 110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
| 111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
| 109 | + if ( ! class_exists('WP_Session')) { |
|
| 110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
| 111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
| 115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Init Session. |
| 120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
| 120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
| 121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
| 122 | 122 | } else { |
| 123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
| 123 | + add_action('init', array($this, 'init'), - 1); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Set cookie on Donation Completion page. |
| 127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
| 127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function init() { |
| 142 | 142 | |
| 143 | - if ( $this->use_php_sessions ) { |
|
| 144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
| 143 | + if ($this->use_php_sessions) { |
|
| 144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
| 145 | 145 | } else { |
| 146 | 146 | $this->session = WP_Session::get_instance(); |
| 147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return string|array Session variable. |
| 178 | 178 | */ |
| 179 | - public function get( $key ) { |
|
| 180 | - $key = sanitize_key( $key ); |
|
| 179 | + public function get($key) { |
|
| 180 | + $key = sanitize_key($key); |
|
| 181 | 181 | $return = false; |
| 182 | 182 | |
| 183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
| 183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
| 184 | 184 | |
| 185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
| 186 | - if ( ! empty( $matches ) ) { |
|
| 187 | - $this->set( $key, null ); |
|
| 185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
| 186 | + if ( ! empty($matches)) { |
|
| 187 | + $this->set($key, null); |
|
| 188 | 188 | |
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
| 193 | - $return = $this->session[ $key ]; |
|
| 192 | + if (is_numeric($this->session[$key])) { |
|
| 193 | + $return = $this->session[$key]; |
|
| 194 | 194 | } else { |
| 195 | 195 | |
| 196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
| 196 | + $maybe_json = json_decode($this->session[$key]); |
|
| 197 | 197 | |
| 198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
| 199 | - if ( is_null( $maybe_json ) ) { |
|
| 200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
| 201 | - if ( $is_serialized ) { |
|
| 202 | - $value = @unserialize( $this->session[ $key ] ); |
|
| 203 | - $this->set( $key, (array) $value ); |
|
| 199 | + if (is_null($maybe_json)) { |
|
| 200 | + $is_serialized = is_serialized($this->session[$key]); |
|
| 201 | + if ($is_serialized) { |
|
| 202 | + $value = @unserialize($this->session[$key]); |
|
| 203 | + $this->set($key, (array) $value); |
|
| 204 | 204 | $return = $value; |
| 205 | 205 | } else { |
| 206 | - $return = $this->session[ $key ]; |
|
| 206 | + $return = $this->session[$key]; |
|
| 207 | 207 | } |
| 208 | 208 | } else { |
| 209 | - $return = json_decode( $this->session[ $key ], true ); |
|
| 209 | + $return = json_decode($this->session[$key], true); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @return string Session variable. |
| 231 | 231 | */ |
| 232 | - public function set( $key, $value ) { |
|
| 232 | + public function set($key, $value) { |
|
| 233 | 233 | |
| 234 | - $key = sanitize_key( $key ); |
|
| 234 | + $key = sanitize_key($key); |
|
| 235 | 235 | |
| 236 | - if ( is_array( $value ) ) { |
|
| 237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
| 236 | + if (is_array($value)) { |
|
| 237 | + $this->session[$key] = wp_json_encode($value); |
|
| 238 | 238 | } else { |
| 239 | - $this->session[ $key ] = esc_attr( $value ); |
|
| 239 | + $this->session[$key] = esc_attr($value); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if ( $this->use_php_sessions ) { |
|
| 243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
| 242 | + if ($this->use_php_sessions) { |
|
| 243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - return $this->session[ $key ]; |
|
| 246 | + return $this->session[$key]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | * @hook |
| 259 | 259 | */ |
| 260 | 260 | public function set_session_cookies() { |
| 261 | - if ( ! headers_sent() ) { |
|
| 262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
| 263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
| 261 | + if ( ! headers_sent()) { |
|
| 262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
| 263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public function set_expiration_variant_time() { |
| 279 | 279 | |
| 280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
| 280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function set_expiration_time() { |
| 294 | 294 | |
| 295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
| 295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
| 310 | 310 | $ret = false; |
| 311 | 311 | |
| 312 | 312 | // If the database variable is already set, no need to run auto detection. |
| 313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
| 313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
| 314 | 314 | |
| 315 | - if ( ! $give_use_php_sessions ) { |
|
| 315 | + if ( ! $give_use_php_sessions) { |
|
| 316 | 316 | |
| 317 | 317 | // Attempt to detect if the server supports PHP sessions. |
| 318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
| 319 | 319 | |
| 320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
| 320 | + $this->set('give_use_php_sessions', 1); |
|
| 321 | 321 | |
| 322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
| 322 | + if ($this->get('give_use_php_sessions')) { |
|
| 323 | 323 | |
| 324 | 324 | $ret = true; |
| 325 | 325 | |
| 326 | 326 | // Set the database option. |
| 327 | - update_option( 'give_use_php_sessions', true ); |
|
| 327 | + update_option('give_use_php_sessions', true); |
|
| 328 | 328 | |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
| 337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
| 337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
| 338 | 338 | $ret = true; |
| 339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
| 339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
| 340 | 340 | $ret = false; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
| 343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $start_session = true; |
| 359 | 359 | |
| 360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
| 360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
| 361 | 361 | |
| 362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
| 362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
| 363 | 363 | 'feed', |
| 364 | 364 | 'feed', |
| 365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
| 367 | 367 | 'feed/rdf', |
| 368 | 368 | 'feed/atom', |
| 369 | 369 | 'comments/feed/', |
| 370 | - ) ); |
|
| 371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
| 372 | - $uri = untrailingslashit( $uri ); |
|
| 373 | - if ( in_array( $uri, $blacklist ) ) { |
|
| 370 | + )); |
|
| 371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
| 372 | + $uri = untrailingslashit($uri); |
|
| 373 | + if (in_array($uri, $blacklist)) { |
|
| 374 | 374 | $start_session = false; |
| 375 | 375 | } |
| 376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
| 376 | + if (false !== strpos($uri, 'feed=')) { |
|
| 377 | 377 | $start_session = false; |
| 378 | 378 | } |
| 379 | - if ( is_admin() ) { |
|
| 379 | + if (is_admin()) { |
|
| 380 | 380 | $start_session = false; |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - return apply_filters( 'give_start_session', $start_session ); |
|
| 384 | + return apply_filters('give_start_session', $start_session); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | */ |
| 398 | 398 | public function maybe_start_session() { |
| 399 | 399 | |
| 400 | - if ( ! $this->should_start_session() ) { |
|
| 400 | + if ( ! $this->should_start_session()) { |
|
| 401 | 401 | return; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if ( ! session_id() && ! headers_sent() ) { |
|
| 404 | + if ( ! session_id() && ! headers_sent()) { |
|
| 405 | 405 | session_start(); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | $expiration = false; |
| 422 | 422 | |
| 423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
| 423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
| 424 | 424 | |
| 425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
| 425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
| 426 | 426 | |
| 427 | 427 | } |
| 428 | 428 | |
@@ -662,9 +662,12 @@ discard block |
||
| 662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
| 663 | 663 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
| 664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
| 665 | - <?php else : ?> |
|
| 665 | + <?php else { |
|
| 666 | + : ?> |
|
| 666 | 667 | <span class="give-icon give-icon-default"></span> |
| 667 | - <?php endif; ?> |
|
| 668 | + <?php endif; |
|
| 669 | +} |
|
| 670 | +?> |
|
| 668 | 671 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
| 669 | 672 | </a> |
| 670 | 673 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -674,9 +677,12 @@ discard block |
||
| 674 | 677 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
| 675 | 678 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
| 676 | 679 | <?php echo $sub_tab['icon-html']; ?> |
| 677 | - <?php else : ?> |
|
| 680 | + <?php else { |
|
| 681 | + : ?> |
|
| 678 | 682 | <span class="give-icon give-icon-default"></span> |
| 679 | - <?php endif; ?> |
|
| 683 | + <?php endif; |
|
| 684 | +} |
|
| 685 | +?> |
|
| 680 | 686 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
| 681 | 687 | </a> |
| 682 | 688 | </li> |
@@ -703,11 +709,14 @@ discard block |
||
| 703 | 709 | </div> |
| 704 | 710 | |
| 705 | 711 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
| 706 | - <?php else : ?> |
|
| 712 | + <?php else { |
|
| 713 | + : ?> |
|
| 707 | 714 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
| 708 | 715 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
| 709 | 716 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
| 710 | - <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
|
| 717 | + <div id="<?php echo $sub_fields['id']; |
|
| 718 | +} |
|
| 719 | +?>" class="panel give_options_panel give-hidden"> |
|
| 711 | 720 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
| 712 | 721 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
| 713 | 722 | <?php give_render_field( $sub_field ); ?> |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function __construct() { |
| 48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
| 49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
| 49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
| 50 | 50 | |
| 51 | 51 | // Setup. |
| 52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
| 52 | + add_action('admin_init', array($this, 'setup')); |
|
| 53 | 53 | |
| 54 | 54 | // Add metabox. |
| 55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
| 55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
| 56 | 56 | |
| 57 | 57 | // Save form meta. |
| 58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
| 58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
| 59 | 59 | |
| 60 | 60 | // cmb2 old setting loaders. |
| 61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
| 62 | 62 | // Add offline donations options. |
| 63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
| 63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
| 64 | 64 | |
| 65 | 65 | // Maintain active tab query parameter after save. |
| 66 | - add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 ); |
|
| 66 | + add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function get_settings() { |
| 89 | 89 | $post_id = give_get_admin_post_id(); |
| 90 | - $price_placeholder = give_format_decimal( '1.00', false, false ); |
|
| 90 | + $price_placeholder = give_format_decimal('1.00', false, false); |
|
| 91 | 91 | |
| 92 | 92 | // Start with an underscore to hide fields from custom fields list |
| 93 | 93 | $prefix = '_give_'; |
@@ -96,27 +96,27 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * Repeatable Field Groups |
| 98 | 98 | */ |
| 99 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
| 99 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
| 100 | 100 | 'id' => 'form_field_options', |
| 101 | - 'title' => __( 'Donation Options', 'give' ), |
|
| 101 | + 'title' => __('Donation Options', 'give'), |
|
| 102 | 102 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
| 103 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
| 103 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
| 104 | 104 | // Donation Option. |
| 105 | 105 | array( |
| 106 | - 'name' => __( 'Donation Option', 'give' ), |
|
| 107 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
| 108 | - 'id' => $prefix . 'price_option', |
|
| 106 | + 'name' => __('Donation Option', 'give'), |
|
| 107 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
| 108 | + 'id' => $prefix.'price_option', |
|
| 109 | 109 | 'type' => 'radio_inline', |
| 110 | 110 | 'default' => 'multi', |
| 111 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
| 112 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
| 113 | - 'set' => __( 'Set Donation', 'give' ), |
|
| 114 | - ) ), |
|
| 111 | + 'options' => apply_filters('give_forms_price_options', array( |
|
| 112 | + 'multi' => __('Multi-level Donation', 'give'), |
|
| 113 | + 'set' => __('Set Donation', 'give'), |
|
| 114 | + )), |
|
| 115 | 115 | ), |
| 116 | 116 | array( |
| 117 | - 'name' => __( 'Set Donation', 'give' ), |
|
| 118 | - 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
| 119 | - 'id' => $prefix . 'set_price', |
|
| 117 | + 'name' => __('Set Donation', 'give'), |
|
| 118 | + 'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
| 119 | + 'id' => $prefix.'set_price', |
|
| 120 | 120 | 'type' => 'text_small', |
| 121 | 121 | 'data_type' => 'price', |
| 122 | 122 | 'attributes' => array( |
@@ -126,34 +126,34 @@ discard block |
||
| 126 | 126 | ), |
| 127 | 127 | // Display Style. |
| 128 | 128 | array( |
| 129 | - 'name' => __( 'Display Style', 'give' ), |
|
| 130 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
| 131 | - 'id' => $prefix . 'display_style', |
|
| 129 | + 'name' => __('Display Style', 'give'), |
|
| 130 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
| 131 | + 'id' => $prefix.'display_style', |
|
| 132 | 132 | 'type' => 'radio_inline', |
| 133 | 133 | 'default' => 'buttons', |
| 134 | 134 | 'options' => array( |
| 135 | - 'buttons' => __( 'Buttons', 'give' ), |
|
| 136 | - 'radios' => __( 'Radios', 'give' ), |
|
| 137 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
| 135 | + 'buttons' => __('Buttons', 'give'), |
|
| 136 | + 'radios' => __('Radios', 'give'), |
|
| 137 | + 'dropdown' => __('Dropdown', 'give'), |
|
| 138 | 138 | ), |
| 139 | 139 | 'wrapper_class' => 'give-hidden', |
| 140 | 140 | ), |
| 141 | 141 | // Custom Amount. |
| 142 | 142 | array( |
| 143 | - 'name' => __( 'Custom Amount', 'give' ), |
|
| 144 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
| 145 | - 'id' => $prefix . 'custom_amount', |
|
| 143 | + 'name' => __('Custom Amount', 'give'), |
|
| 144 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
| 145 | + 'id' => $prefix.'custom_amount', |
|
| 146 | 146 | 'type' => 'radio_inline', |
| 147 | 147 | 'default' => 'disabled', |
| 148 | 148 | 'options' => array( |
| 149 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 150 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 149 | + 'enabled' => __('Enabled', 'give'), |
|
| 150 | + 'disabled' => __('Disabled', 'give'), |
|
| 151 | 151 | ), |
| 152 | 152 | ), |
| 153 | 153 | array( |
| 154 | - 'name' => __( 'Minimum Amount', 'give' ), |
|
| 155 | - 'description' => __( 'Enter the minimum custom donation amount.', 'give' ), |
|
| 156 | - 'id' => $prefix . 'custom_amount_minimum', |
|
| 154 | + 'name' => __('Minimum Amount', 'give'), |
|
| 155 | + 'description' => __('Enter the minimum custom donation amount.', 'give'), |
|
| 156 | + 'id' => $prefix.'custom_amount_minimum', |
|
| 157 | 157 | 'type' => 'text_small', |
| 158 | 158 | 'data_type' => 'price', |
| 159 | 159 | 'attributes' => array( |
@@ -163,37 +163,37 @@ discard block |
||
| 163 | 163 | 'wrapper_class' => 'give-hidden', |
| 164 | 164 | ), |
| 165 | 165 | array( |
| 166 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
| 167 | - 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
| 168 | - 'id' => $prefix . 'custom_amount_text', |
|
| 166 | + 'name' => __('Custom Amount Text', 'give'), |
|
| 167 | + 'description' => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
| 168 | + 'id' => $prefix.'custom_amount_text', |
|
| 169 | 169 | 'type' => 'text_medium', |
| 170 | 170 | 'attributes' => array( |
| 171 | 171 | 'rows' => 3, |
| 172 | - 'placeholder' => __( 'Give a Custom Amount', 'give' ), |
|
| 172 | + 'placeholder' => __('Give a Custom Amount', 'give'), |
|
| 173 | 173 | ), |
| 174 | 174 | 'wrapper_class' => 'give-hidden', |
| 175 | 175 | ), |
| 176 | 176 | // Donation Levels. |
| 177 | 177 | array( |
| 178 | - 'id' => $prefix . 'donation_levels', |
|
| 178 | + 'id' => $prefix.'donation_levels', |
|
| 179 | 179 | 'type' => 'group', |
| 180 | 180 | 'options' => array( |
| 181 | - 'add_button' => __( 'Add Level', 'give' ), |
|
| 182 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
| 181 | + 'add_button' => __('Add Level', 'give'), |
|
| 182 | + 'header_title' => __('Donation Level', 'give'), |
|
| 183 | 183 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
| 184 | 184 | ), |
| 185 | 185 | 'wrapper_class' => 'give-hidden', |
| 186 | 186 | // Fields array works the same, except id's only need to be unique for this group. |
| 187 | 187 | // Prefix is not needed. |
| 188 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
| 188 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
| 189 | 189 | array( |
| 190 | - 'name' => __( 'ID', 'give' ), |
|
| 191 | - 'id' => $prefix . 'id', |
|
| 190 | + 'name' => __('ID', 'give'), |
|
| 191 | + 'id' => $prefix.'id', |
|
| 192 | 192 | 'type' => 'levels_id', |
| 193 | 193 | ), |
| 194 | 194 | array( |
| 195 | - 'name' => __( 'Amount', 'give' ), |
|
| 196 | - 'id' => $prefix . 'amount', |
|
| 195 | + 'name' => __('Amount', 'give'), |
|
| 196 | + 'id' => $prefix.'amount', |
|
| 197 | 197 | 'type' => 'text_small', |
| 198 | 198 | 'data_type' => 'price', |
| 199 | 199 | 'attributes' => array( |
@@ -202,112 +202,112 @@ discard block |
||
| 202 | 202 | ), |
| 203 | 203 | ), |
| 204 | 204 | array( |
| 205 | - 'name' => __( 'Text', 'give' ), |
|
| 206 | - 'id' => $prefix . 'text', |
|
| 205 | + 'name' => __('Text', 'give'), |
|
| 206 | + 'id' => $prefix.'text', |
|
| 207 | 207 | 'type' => 'text', |
| 208 | 208 | 'attributes' => array( |
| 209 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
| 209 | + 'placeholder' => __('Donation Level', 'give'), |
|
| 210 | 210 | 'class' => 'give-multilevel-text-field', |
| 211 | 211 | ), |
| 212 | 212 | ), |
| 213 | 213 | array( |
| 214 | - 'name' => __( 'Default', 'give' ), |
|
| 215 | - 'id' => $prefix . 'default', |
|
| 214 | + 'name' => __('Default', 'give'), |
|
| 215 | + 'id' => $prefix.'default', |
|
| 216 | 216 | 'type' => 'give_default_radio_inline', |
| 217 | 217 | ), |
| 218 | - ) ), |
|
| 218 | + )), |
|
| 219 | 219 | ), |
| 220 | 220 | array( |
| 221 | 221 | 'name' => 'donation_options_docs', |
| 222 | 222 | 'type' => 'docs_link', |
| 223 | 223 | 'url' => 'http://docs.givewp.com/form-donation-options', |
| 224 | - 'title' => __( 'Donation Options', 'give' ), |
|
| 224 | + 'title' => __('Donation Options', 'give'), |
|
| 225 | 225 | ), |
| 226 | 226 | ), |
| 227 | 227 | $post_id |
| 228 | 228 | ), |
| 229 | - ) ), |
|
| 229 | + )), |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Display Options |
| 233 | 233 | */ |
| 234 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
| 234 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
| 235 | 235 | 'id' => 'form_display_options', |
| 236 | - 'title' => __( 'Form Display', 'give' ), |
|
| 236 | + 'title' => __('Form Display', 'give'), |
|
| 237 | 237 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
| 238 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
| 238 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
| 239 | 239 | array( |
| 240 | - 'name' => __( 'Display Options', 'give' ), |
|
| 241 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
| 242 | - 'id' => $prefix . 'payment_display', |
|
| 240 | + 'name' => __('Display Options', 'give'), |
|
| 241 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
| 242 | + 'id' => $prefix.'payment_display', |
|
| 243 | 243 | 'type' => 'radio_inline', |
| 244 | 244 | 'options' => array( |
| 245 | - 'onpage' => __( 'All Fields', 'give' ), |
|
| 246 | - 'modal' => __( 'Modal', 'give' ), |
|
| 247 | - 'reveal' => __( 'Reveal', 'give' ), |
|
| 248 | - 'button' => __( 'Button', 'give' ), |
|
| 245 | + 'onpage' => __('All Fields', 'give'), |
|
| 246 | + 'modal' => __('Modal', 'give'), |
|
| 247 | + 'reveal' => __('Reveal', 'give'), |
|
| 248 | + 'button' => __('Button', 'give'), |
|
| 249 | 249 | ), |
| 250 | 250 | 'default' => 'onpage', |
| 251 | 251 | ), |
| 252 | 252 | array( |
| 253 | - 'id' => $prefix . 'reveal_label', |
|
| 254 | - 'name' => __( 'Continue Button', 'give' ), |
|
| 255 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
| 253 | + 'id' => $prefix.'reveal_label', |
|
| 254 | + 'name' => __('Continue Button', 'give'), |
|
| 255 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
| 256 | 256 | 'type' => 'text_small', |
| 257 | 257 | 'attributes' => array( |
| 258 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
| 258 | + 'placeholder' => __('Donate Now', 'give'), |
|
| 259 | 259 | ), |
| 260 | 260 | 'wrapper_class' => 'give-hidden', |
| 261 | 261 | ), |
| 262 | 262 | array( |
| 263 | - 'id' => $prefix . 'checkout_label', |
|
| 264 | - 'name' => __( 'Submit Button', 'give' ), |
|
| 265 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
| 263 | + 'id' => $prefix.'checkout_label', |
|
| 264 | + 'name' => __('Submit Button', 'give'), |
|
| 265 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
| 266 | 266 | 'type' => 'text_small', |
| 267 | 267 | 'attributes' => array( |
| 268 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
| 268 | + 'placeholder' => __('Donate Now', 'give'), |
|
| 269 | 269 | ), |
| 270 | 270 | ), |
| 271 | 271 | array( |
| 272 | - 'name' => __( 'Default Gateway', 'give' ), |
|
| 273 | - 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
| 274 | - 'id' => $prefix . 'default_gateway', |
|
| 272 | + 'name' => __('Default Gateway', 'give'), |
|
| 273 | + 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
| 274 | + 'id' => $prefix.'default_gateway', |
|
| 275 | 275 | 'type' => 'default_gateway', |
| 276 | 276 | ), |
| 277 | 277 | array( |
| 278 | - 'name' => __( 'Guest Donations', 'give' ), |
|
| 279 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
| 280 | - 'id' => $prefix . 'logged_in_only', |
|
| 278 | + 'name' => __('Guest Donations', 'give'), |
|
| 279 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
| 280 | + 'id' => $prefix.'logged_in_only', |
|
| 281 | 281 | 'type' => 'radio_inline', |
| 282 | 282 | 'default' => 'enabled', |
| 283 | 283 | 'options' => array( |
| 284 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 285 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 284 | + 'enabled' => __('Enabled', 'give'), |
|
| 285 | + 'disabled' => __('Disabled', 'give'), |
|
| 286 | 286 | ), |
| 287 | 287 | ), |
| 288 | 288 | array( |
| 289 | - 'name' => __( 'Registration', 'give' ), |
|
| 290 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
| 291 | - 'id' => $prefix . 'show_register_form', |
|
| 289 | + 'name' => __('Registration', 'give'), |
|
| 290 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
| 291 | + 'id' => $prefix.'show_register_form', |
|
| 292 | 292 | 'type' => 'radio', |
| 293 | 293 | 'options' => array( |
| 294 | - 'none' => __( 'None', 'give' ), |
|
| 295 | - 'registration' => __( 'Registration', 'give' ), |
|
| 296 | - 'login' => __( 'Login', 'give' ), |
|
| 297 | - 'both' => __( 'Registration + Login', 'give' ), |
|
| 294 | + 'none' => __('None', 'give'), |
|
| 295 | + 'registration' => __('Registration', 'give'), |
|
| 296 | + 'login' => __('Login', 'give'), |
|
| 297 | + 'both' => __('Registration + Login', 'give'), |
|
| 298 | 298 | ), |
| 299 | 299 | 'default' => 'none', |
| 300 | 300 | ), |
| 301 | 301 | array( |
| 302 | - 'name' => __( 'Floating Labels', 'give' ), |
|
| 302 | + 'name' => __('Floating Labels', 'give'), |
|
| 303 | 303 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
| 304 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
| 305 | - 'id' => $prefix . 'form_floating_labels', |
|
| 304 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
| 305 | + 'id' => $prefix.'form_floating_labels', |
|
| 306 | 306 | 'type' => 'radio_inline', |
| 307 | 307 | 'options' => array( |
| 308 | - 'global' => __( 'Global Option', 'give' ), |
|
| 309 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 310 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 308 | + 'global' => __('Global Option', 'give'), |
|
| 309 | + 'enabled' => __('Enabled', 'give'), |
|
| 310 | + 'disabled' => __('Disabled', 'give'), |
|
| 311 | 311 | ), |
| 312 | 312 | 'default' => 'global', |
| 313 | 313 | ), |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | 'name' => 'form_display_docs', |
| 316 | 316 | 'type' => 'docs_link', |
| 317 | 317 | 'url' => 'http://docs.givewp.com/form-display-options', |
| 318 | - 'title' => __( 'Form Display', 'give' ), |
|
| 318 | + 'title' => __('Form Display', 'give'), |
|
| 319 | 319 | ), |
| 320 | 320 | ), |
| 321 | 321 | $post_id |
@@ -326,27 +326,27 @@ discard block |
||
| 326 | 326 | /** |
| 327 | 327 | * Donation Goals |
| 328 | 328 | */ |
| 329 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
| 329 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
| 330 | 330 | 'id' => 'donation_goal_options', |
| 331 | - 'title' => __( 'Donation Goal', 'give' ), |
|
| 331 | + 'title' => __('Donation Goal', 'give'), |
|
| 332 | 332 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
| 333 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
| 333 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
| 334 | 334 | // Goals |
| 335 | 335 | array( |
| 336 | - 'name' => __( 'Donation Goal', 'give' ), |
|
| 337 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
| 338 | - 'id' => $prefix . 'goal_option', |
|
| 336 | + 'name' => __('Donation Goal', 'give'), |
|
| 337 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
| 338 | + 'id' => $prefix.'goal_option', |
|
| 339 | 339 | 'type' => 'radio_inline', |
| 340 | 340 | 'default' => 'disabled', |
| 341 | 341 | 'options' => array( |
| 342 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 343 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 342 | + 'enabled' => __('Enabled', 'give'), |
|
| 343 | + 'disabled' => __('Disabled', 'give'), |
|
| 344 | 344 | ), |
| 345 | 345 | ), |
| 346 | 346 | array( |
| 347 | - 'name' => __( 'Goal Amount', 'give' ), |
|
| 348 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
| 349 | - 'id' => $prefix . 'set_goal', |
|
| 347 | + 'name' => __('Goal Amount', 'give'), |
|
| 348 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
| 349 | + 'id' => $prefix.'set_goal', |
|
| 350 | 350 | 'type' => 'text_small', |
| 351 | 351 | 'data_type' => 'price', |
| 352 | 352 | 'attributes' => array( |
@@ -357,97 +357,97 @@ discard block |
||
| 357 | 357 | ), |
| 358 | 358 | |
| 359 | 359 | array( |
| 360 | - 'name' => __( 'Goal Format', 'give' ), |
|
| 361 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
| 362 | - 'id' => $prefix . 'goal_format', |
|
| 360 | + 'name' => __('Goal Format', 'give'), |
|
| 361 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
| 362 | + 'id' => $prefix.'goal_format', |
|
| 363 | 363 | 'type' => 'radio_inline', |
| 364 | 364 | 'default' => 'amount', |
| 365 | 365 | 'options' => array( |
| 366 | - 'amount' => __( 'Amount', 'give' ), |
|
| 367 | - 'percentage' => __( 'Percentage', 'give' ), |
|
| 366 | + 'amount' => __('Amount', 'give'), |
|
| 367 | + 'percentage' => __('Percentage', 'give'), |
|
| 368 | 368 | ), |
| 369 | 369 | 'wrapper_class' => 'give-hidden', |
| 370 | 370 | ), |
| 371 | 371 | array( |
| 372 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
| 373 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
| 374 | - 'id' => $prefix . 'goal_color', |
|
| 372 | + 'name' => __('Progress Bar Color', 'give'), |
|
| 373 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
| 374 | + 'id' => $prefix.'goal_color', |
|
| 375 | 375 | 'type' => 'colorpicker', |
| 376 | 376 | 'default' => '#2bc253', |
| 377 | 377 | 'wrapper_class' => 'give-hidden', |
| 378 | 378 | ), |
| 379 | 379 | |
| 380 | 380 | array( |
| 381 | - 'name' => __( 'Close Form', 'give' ), |
|
| 382 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
| 383 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
| 381 | + 'name' => __('Close Form', 'give'), |
|
| 382 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
| 383 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
| 384 | 384 | 'type' => 'radio_inline', |
| 385 | 385 | 'default' => 'disabled', |
| 386 | 386 | 'options' => array( |
| 387 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 388 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 387 | + 'enabled' => __('Enabled', 'give'), |
|
| 388 | + 'disabled' => __('Disabled', 'give'), |
|
| 389 | 389 | ), |
| 390 | 390 | 'wrapper_class' => 'give-hidden', |
| 391 | 391 | ), |
| 392 | 392 | array( |
| 393 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
| 394 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
| 395 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
| 393 | + 'name' => __('Goal Achieved Message', 'give'), |
|
| 394 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
| 395 | + 'id' => $prefix.'form_goal_achieved_message', |
|
| 396 | 396 | 'type' => 'wysiwyg', |
| 397 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
| 397 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
| 398 | 398 | 'wrapper_class' => 'give-hidden', |
| 399 | 399 | ), |
| 400 | 400 | array( |
| 401 | 401 | 'name' => 'donation_goal_docs', |
| 402 | 402 | 'type' => 'docs_link', |
| 403 | 403 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
| 404 | - 'title' => __( 'Donation Goal', 'give' ), |
|
| 404 | + 'title' => __('Donation Goal', 'give'), |
|
| 405 | 405 | ), |
| 406 | 406 | ), |
| 407 | 407 | $post_id |
| 408 | 408 | ), |
| 409 | - ) ), |
|
| 409 | + )), |
|
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | 412 | * Content Field |
| 413 | 413 | */ |
| 414 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
| 414 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
| 415 | 415 | 'id' => 'form_content_options', |
| 416 | - 'title' => __( 'Form Content', 'give' ), |
|
| 416 | + 'title' => __('Form Content', 'give'), |
|
| 417 | 417 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
| 418 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
| 418 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
| 419 | 419 | |
| 420 | 420 | // Donation content. |
| 421 | 421 | array( |
| 422 | - 'name' => __( 'Display Content', 'give' ), |
|
| 423 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
| 424 | - 'id' => $prefix . 'display_content', |
|
| 422 | + 'name' => __('Display Content', 'give'), |
|
| 423 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
| 424 | + 'id' => $prefix.'display_content', |
|
| 425 | 425 | 'type' => 'radio_inline', |
| 426 | 426 | 'options' => array( |
| 427 | - 'enabled' => __( 'Enabled', 'give' ), |
|
| 428 | - 'disabled' => __( 'Disabled', 'give' ), |
|
| 427 | + 'enabled' => __('Enabled', 'give'), |
|
| 428 | + 'disabled' => __('Disabled', 'give'), |
|
| 429 | 429 | ), |
| 430 | 430 | 'default' => 'disabled', |
| 431 | 431 | ), |
| 432 | 432 | |
| 433 | 433 | // Content placement. |
| 434 | 434 | array( |
| 435 | - 'name' => __( 'Content Placement', 'give' ), |
|
| 436 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
| 437 | - 'id' => $prefix . 'content_placement', |
|
| 435 | + 'name' => __('Content Placement', 'give'), |
|
| 436 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
| 437 | + 'id' => $prefix.'content_placement', |
|
| 438 | 438 | 'type' => 'radio_inline', |
| 439 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 440 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
| 441 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
| 439 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 440 | + 'give_pre_form' => __('Above fields', 'give'), |
|
| 441 | + 'give_post_form' => __('Below fields', 'give'), |
|
| 442 | 442 | ) |
| 443 | 443 | ), |
| 444 | 444 | 'default' => 'give_pre_form', |
| 445 | 445 | 'wrapper_class' => 'give-hidden', |
| 446 | 446 | ), |
| 447 | 447 | array( |
| 448 | - 'name' => __( 'Content', 'give' ), |
|
| 449 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
| 450 | - 'id' => $prefix . 'form_content', |
|
| 448 | + 'name' => __('Content', 'give'), |
|
| 449 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
| 450 | + 'id' => $prefix.'form_content', |
|
| 451 | 451 | 'type' => 'wysiwyg', |
| 452 | 452 | 'wrapper_class' => 'give-hidden', |
| 453 | 453 | ), |
@@ -455,51 +455,51 @@ discard block |
||
| 455 | 455 | 'name' => 'form_content_docs', |
| 456 | 456 | 'type' => 'docs_link', |
| 457 | 457 | 'url' => 'http://docs.givewp.com/form-content', |
| 458 | - 'title' => __( 'Form Content', 'give' ), |
|
| 458 | + 'title' => __('Form Content', 'give'), |
|
| 459 | 459 | ), |
| 460 | 460 | ), |
| 461 | 461 | $post_id |
| 462 | 462 | ), |
| 463 | - ) ), |
|
| 463 | + )), |
|
| 464 | 464 | |
| 465 | 465 | /** |
| 466 | 466 | * Terms & Conditions |
| 467 | 467 | */ |
| 468 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
| 468 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
| 469 | 469 | 'id' => 'form_terms_options', |
| 470 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
| 470 | + 'title' => __('Terms & Conditions', 'give'), |
|
| 471 | 471 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
| 472 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
| 472 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
| 473 | 473 | // Donation Option |
| 474 | 474 | array( |
| 475 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
| 476 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
| 477 | - 'id' => $prefix . 'terms_option', |
|
| 475 | + 'name' => __('Terms and Conditions', 'give'), |
|
| 476 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
| 477 | + 'id' => $prefix.'terms_option', |
|
| 478 | 478 | 'type' => 'radio_inline', |
| 479 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
| 480 | - 'global' => __( 'Global Option', 'give' ), |
|
| 481 | - 'enabled' => __( 'Customize', 'give' ), |
|
| 482 | - 'disabled' => __( 'Disable', 'give' ), |
|
| 479 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
| 480 | + 'global' => __('Global Option', 'give'), |
|
| 481 | + 'enabled' => __('Customize', 'give'), |
|
| 482 | + 'disabled' => __('Disable', 'give'), |
|
| 483 | 483 | ) |
| 484 | 484 | ), |
| 485 | 485 | 'default' => 'global', |
| 486 | 486 | ), |
| 487 | 487 | array( |
| 488 | - 'id' => $prefix . 'agree_label', |
|
| 489 | - 'name' => __( 'Agreement Label', 'give' ), |
|
| 490 | - 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
| 488 | + 'id' => $prefix.'agree_label', |
|
| 489 | + 'name' => __('Agreement Label', 'give'), |
|
| 490 | + 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
| 491 | 491 | 'type' => 'text', |
| 492 | 492 | 'size' => 'regular', |
| 493 | 493 | 'attributes' => array( |
| 494 | - 'placeholder' => __( 'Agree to Terms?', 'give' ), |
|
| 494 | + 'placeholder' => __('Agree to Terms?', 'give'), |
|
| 495 | 495 | ), |
| 496 | 496 | 'wrapper_class' => 'give-hidden', |
| 497 | 497 | ), |
| 498 | 498 | array( |
| 499 | - 'id' => $prefix . 'agree_text', |
|
| 500 | - 'name' => __( 'Agreement Text', 'give' ), |
|
| 501 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
| 502 | - 'default' => give_get_option( 'agreement_text' ), |
|
| 499 | + 'id' => $prefix.'agree_text', |
|
| 500 | + 'name' => __('Agreement Text', 'give'), |
|
| 501 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
| 502 | + 'default' => give_get_option('agreement_text'), |
|
| 503 | 503 | 'type' => 'wysiwyg', |
| 504 | 504 | 'wrapper_class' => 'give-hidden', |
| 505 | 505 | ), |
@@ -507,18 +507,18 @@ discard block |
||
| 507 | 507 | 'name' => 'terms_docs', |
| 508 | 508 | 'type' => 'docs_link', |
| 509 | 509 | 'url' => 'http://docs.givewp.com/form-terms', |
| 510 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
| 510 | + 'title' => __('Terms and Conditions', 'give'), |
|
| 511 | 511 | ), |
| 512 | 512 | ), |
| 513 | 513 | $post_id |
| 514 | 514 | ), |
| 515 | - ) ), |
|
| 515 | + )), |
|
| 516 | 516 | ); |
| 517 | 517 | |
| 518 | 518 | /** |
| 519 | 519 | * Filter the metabox tabbed panel settings. |
| 520 | 520 | */ |
| 521 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
| 521 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
| 522 | 522 | |
| 523 | 523 | // Output. |
| 524 | 524 | return $settings; |
@@ -535,8 +535,8 @@ discard block |
||
| 535 | 535 | add_meta_box( |
| 536 | 536 | $this->get_metabox_ID(), |
| 537 | 537 | $this->get_metabox_label(), |
| 538 | - array( $this, 'output' ), |
|
| 539 | - array( 'give_forms' ), |
|
| 538 | + array($this, 'output'), |
|
| 539 | + array('give_forms'), |
|
| 540 | 540 | 'normal', |
| 541 | 541 | 'high' |
| 542 | 542 | ); |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | function enqueue_script() { |
| 554 | 554 | global $post; |
| 555 | 555 | |
| 556 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
| 556 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
| 557 | 557 | |
| 558 | 558 | } |
| 559 | 559 | } |
@@ -591,32 +591,32 @@ discard block |
||
| 591 | 591 | public function get_tabs() { |
| 592 | 592 | $tabs = array(); |
| 593 | 593 | |
| 594 | - if ( ! empty( $this->settings ) ) { |
|
| 595 | - foreach ( $this->settings as $setting ) { |
|
| 596 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
| 594 | + if ( ! empty($this->settings)) { |
|
| 595 | + foreach ($this->settings as $setting) { |
|
| 596 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
| 597 | 597 | continue; |
| 598 | 598 | } |
| 599 | 599 | $tab = array( |
| 600 | 600 | 'id' => $setting['id'], |
| 601 | 601 | 'label' => $setting['title'], |
| 602 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
| 602 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
| 603 | 603 | ); |
| 604 | 604 | |
| 605 | - if ( $this->has_sub_tab( $setting ) ) { |
|
| 606 | - if ( empty( $setting['sub-fields'] ) ) { |
|
| 605 | + if ($this->has_sub_tab($setting)) { |
|
| 606 | + if (empty($setting['sub-fields'])) { |
|
| 607 | 607 | $tab = array(); |
| 608 | 608 | } else { |
| 609 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
| 609 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
| 610 | 610 | $tab['sub-fields'][] = array( |
| 611 | 611 | 'id' => $sub_fields['id'], |
| 612 | 612 | 'label' => $sub_fields['title'], |
| 613 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
| 613 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
| 614 | 614 | ); |
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if ( ! empty( $tab ) ) { |
|
| 619 | + if ( ! empty($tab)) { |
|
| 620 | 620 | $tabs[] = $tab; |
| 621 | 621 | } |
| 622 | 622 | } |
@@ -634,33 +634,33 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | public function output() { |
| 636 | 636 | // Bailout. |
| 637 | - if ( $form_data_tabs = $this->get_tabs() ) : |
|
| 638 | - $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options'; |
|
| 639 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
| 637 | + if ($form_data_tabs = $this->get_tabs()) : |
|
| 638 | + $active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options'; |
|
| 639 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
| 640 | 640 | ?> |
| 641 | 641 | <input id="give_form_active_tab" type="hidden" name="give_form_active_tab"> |
| 642 | 642 | <div class="give-metabox-panel-wrap"> |
| 643 | 643 | <ul class="give-form-data-tabs give-metabox-tabs"> |
| 644 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
| 644 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
| 645 | 645 | <?php |
| 646 | 646 | // Determine if current tab is active. |
| 647 | 647 | $is_active = $active_tab === $form_data_tab['id'] ? true : false; |
| 648 | 648 | ?> |
| 649 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
| 649 | + <li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
| 650 | 650 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
| 651 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
| 651 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
| 652 | 652 | <?php echo $form_data_tab['icon-html']; ?> |
| 653 | 653 | <?php else : ?> |
| 654 | 654 | <span class="give-icon give-icon-default"></span> |
| 655 | 655 | <?php endif; ?> |
| 656 | 656 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
| 657 | 657 | </a> |
| 658 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
| 658 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
| 659 | 659 | <ul class="give-metabox-sub-tabs give-hidden"> |
| 660 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
| 660 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
| 661 | 661 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
| 662 | 662 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
| 663 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
| 663 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
| 664 | 664 | <?php echo $sub_tab['icon-html']; ?> |
| 665 | 665 | <?php else : ?> |
| 666 | 666 | <span class="give-icon give-icon-default"></span> |
@@ -675,30 +675,30 @@ discard block |
||
| 675 | 675 | <?php endforeach; ?> |
| 676 | 676 | </ul> |
| 677 | 677 | |
| 678 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
| 679 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
| 680 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
| 678 | + <?php foreach ($this->settings as $setting) : ?> |
|
| 679 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
| 680 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
| 681 | 681 | <?php |
| 682 | 682 | // Determine if current panel is active. |
| 683 | 683 | $is_active = $active_tab === $setting['id'] ? true : false; |
| 684 | 684 | ?> |
| 685 | - <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>"> |
|
| 686 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
| 687 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
| 688 | - <?php give_render_field( $field ); ?> |
|
| 685 | + <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>"> |
|
| 686 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
| 687 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
| 688 | + <?php give_render_field($field); ?> |
|
| 689 | 689 | <?php endforeach; ?> |
| 690 | 690 | <?php endif; ?> |
| 691 | 691 | </div> |
| 692 | 692 | |
| 693 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
| 693 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
| 694 | 694 | <?php else : ?> |
| 695 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
| 696 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
| 697 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
| 695 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
| 696 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
| 697 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
| 698 | 698 | <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
| 699 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
| 700 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
| 701 | - <?php give_render_field( $sub_field ); ?> |
|
| 699 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
| 700 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
| 701 | + <?php give_render_field($sub_field); ?> |
|
| 702 | 702 | <?php endforeach; ?> |
| 703 | 703 | <?php endif; ?> |
| 704 | 704 | </div> |
@@ -722,9 +722,9 @@ discard block |
||
| 722 | 722 | * |
| 723 | 723 | * @return bool |
| 724 | 724 | */ |
| 725 | - private function has_sub_tab( $field_setting ) { |
|
| 725 | + private function has_sub_tab($field_setting) { |
|
| 726 | 726 | $has_sub_tab = false; |
| 727 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
| 727 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
| 728 | 728 | $has_sub_tab = true; |
| 729 | 729 | } |
| 730 | 730 | |
@@ -739,13 +739,13 @@ discard block |
||
| 739 | 739 | * @return array |
| 740 | 740 | */ |
| 741 | 741 | function cmb2_metabox_settings() { |
| 742 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
| 742 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
| 743 | 743 | $give_forms_settings = $all_cmb2_settings; |
| 744 | 744 | |
| 745 | 745 | // Filter settings: Use only give forms related settings. |
| 746 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
| 747 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
| 748 | - unset( $give_forms_settings[ $index ] ); |
|
| 746 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
| 747 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
| 748 | + unset($give_forms_settings[$index]); |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
@@ -763,96 +763,96 @@ discard block |
||
| 763 | 763 | * |
| 764 | 764 | * @return void |
| 765 | 765 | */ |
| 766 | - public function save( $post_id, $post ) { |
|
| 766 | + public function save($post_id, $post) { |
|
| 767 | 767 | |
| 768 | 768 | // $post_id and $post are required. |
| 769 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
| 769 | + if (empty($post_id) || empty($post)) { |
|
| 770 | 770 | return; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | // Don't save meta boxes for revisions or autosaves. |
| 774 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 774 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 775 | 775 | return; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | // Check the nonce. |
| 779 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
| 779 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
| 780 | 780 | return; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 784 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
| 784 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
| 785 | 785 | return; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | // Check user has permission to edit. |
| 789 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 789 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 790 | 790 | return; |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | // Fire action before saving form meta. |
| 794 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
| 794 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * Filter the meta key to save. |
| 798 | 798 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
| 799 | 799 | */ |
| 800 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
| 800 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
| 801 | 801 | |
| 802 | 802 | // Save form meta data. |
| 803 | - if ( ! empty( $form_meta_keys ) ) { |
|
| 804 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
| 803 | + if ( ! empty($form_meta_keys)) { |
|
| 804 | + foreach ($form_meta_keys as $form_meta_key) { |
|
| 805 | 805 | |
| 806 | 806 | // Set default value for checkbox fields. |
| 807 | 807 | if ( |
| 808 | - ! isset( $_POST[ $form_meta_key ] ) |
|
| 809 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
| 808 | + ! isset($_POST[$form_meta_key]) |
|
| 809 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
| 810 | 810 | ) { |
| 811 | - $_POST[ $form_meta_key ] = ''; |
|
| 811 | + $_POST[$form_meta_key] = ''; |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
| 815 | - $setting_field = $this->get_setting_field( $form_meta_key ); |
|
| 816 | - if ( ! empty( $setting_field['type'] ) ) { |
|
| 817 | - switch ( $setting_field['type'] ) { |
|
| 814 | + if (isset($_POST[$form_meta_key])) { |
|
| 815 | + $setting_field = $this->get_setting_field($form_meta_key); |
|
| 816 | + if ( ! empty($setting_field['type'])) { |
|
| 817 | + switch ($setting_field['type']) { |
|
| 818 | 818 | case 'textarea': |
| 819 | 819 | case 'wysiwyg': |
| 820 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
| 820 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
| 821 | 821 | break; |
| 822 | 822 | |
| 823 | 823 | case 'group': |
| 824 | 824 | $form_meta_value = array(); |
| 825 | 825 | |
| 826 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
| 826 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
| 827 | 827 | |
| 828 | 828 | // Do not save template input field values. |
| 829 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
| 829 | + if ('{{row-count-placeholder}}' === $index) { |
|
| 830 | 830 | continue; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $group_meta_value = array(); |
| 834 | - foreach ( $group as $field_id => $field_value ) { |
|
| 835 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
| 834 | + foreach ($group as $field_id => $field_value) { |
|
| 835 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
| 836 | 836 | case 'wysiwyg': |
| 837 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
| 837 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
| 838 | 838 | break; |
| 839 | 839 | |
| 840 | 840 | default: |
| 841 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
| 841 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if ( ! empty( $group_meta_value ) ) { |
|
| 846 | - $form_meta_value[ $index ] = $group_meta_value; |
|
| 845 | + if ( ! empty($group_meta_value)) { |
|
| 846 | + $form_meta_value[$index] = $group_meta_value; |
|
| 847 | 847 | } |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | // Arrange repeater field keys in order. |
| 851 | - $form_meta_value = array_values( $form_meta_value ); |
|
| 851 | + $form_meta_value = array_values($form_meta_value); |
|
| 852 | 852 | break; |
| 853 | 853 | |
| 854 | 854 | default: |
| 855 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
| 855 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
| 856 | 856 | }// End switch(). |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -862,24 +862,24 @@ discard block |
||
| 862 | 862 | */ |
| 863 | 863 | $form_meta_value = apply_filters( |
| 864 | 864 | 'give_pre_save_form_meta_value', |
| 865 | - $this->sanitize_form_meta( $form_meta_value, $setting_field ), |
|
| 865 | + $this->sanitize_form_meta($form_meta_value, $setting_field), |
|
| 866 | 866 | $form_meta_key, |
| 867 | 867 | $this, |
| 868 | 868 | $post_id |
| 869 | 869 | ); |
| 870 | 870 | |
| 871 | 871 | // Save data. |
| 872 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
| 872 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
| 873 | 873 | |
| 874 | 874 | // Fire after saving form meta key. |
| 875 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
| 875 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
| 876 | 876 | }// End if(). |
| 877 | 877 | }// End if(). |
| 878 | 878 | }// End foreach(). |
| 879 | 879 | }// End if(). |
| 880 | 880 | |
| 881 | 881 | // Fire action after saving form meta. |
| 882 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
| 882 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | |
@@ -892,10 +892,10 @@ discard block |
||
| 892 | 892 | * |
| 893 | 893 | * @return string |
| 894 | 894 | */ |
| 895 | - private function get_field_id( $field ) { |
|
| 895 | + private function get_field_id($field) { |
|
| 896 | 896 | $field_id = ''; |
| 897 | 897 | |
| 898 | - if ( array_key_exists( 'id', $field ) ) { |
|
| 898 | + if (array_key_exists('id', $field)) { |
|
| 899 | 899 | $field_id = $field['id']; |
| 900 | 900 | |
| 901 | 901 | } |
@@ -912,12 +912,12 @@ discard block |
||
| 912 | 912 | * |
| 913 | 913 | * @return array |
| 914 | 914 | */ |
| 915 | - private function get_fields_id( $setting ) { |
|
| 915 | + private function get_fields_id($setting) { |
|
| 916 | 916 | $meta_keys = array(); |
| 917 | 917 | |
| 918 | - if ( ! empty( $setting ) ) { |
|
| 919 | - foreach ( $setting['fields'] as $field ) { |
|
| 920 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
| 918 | + if ( ! empty($setting)) { |
|
| 919 | + foreach ($setting['fields'] as $field) { |
|
| 920 | + if ($field_id = $this->get_field_id($field)) { |
|
| 921 | 921 | $meta_keys[] = $field_id; |
| 922 | 922 | } |
| 923 | 923 | } |
@@ -935,14 +935,14 @@ discard block |
||
| 935 | 935 | * |
| 936 | 936 | * @return array |
| 937 | 937 | */ |
| 938 | - private function get_sub_fields_id( $setting ) { |
|
| 938 | + private function get_sub_fields_id($setting) { |
|
| 939 | 939 | $meta_keys = array(); |
| 940 | 940 | |
| 941 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
| 942 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
| 943 | - if ( ! empty( $fields['fields'] ) ) { |
|
| 944 | - foreach ( $fields['fields'] as $field ) { |
|
| 945 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
| 941 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
| 942 | + foreach ($setting['sub-fields'] as $fields) { |
|
| 943 | + if ( ! empty($fields['fields'])) { |
|
| 944 | + foreach ($fields['fields'] as $field) { |
|
| 945 | + if ($field_id = $this->get_field_id($field)) { |
|
| 946 | 946 | $meta_keys[] = $field_id; |
| 947 | 947 | } |
| 948 | 948 | } |
@@ -964,14 +964,14 @@ discard block |
||
| 964 | 964 | private function get_meta_keys_from_settings() { |
| 965 | 965 | $meta_keys = array(); |
| 966 | 966 | |
| 967 | - foreach ( $this->settings as $setting ) { |
|
| 968 | - if ( $this->has_sub_tab( $setting ) ) { |
|
| 969 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
| 967 | + foreach ($this->settings as $setting) { |
|
| 968 | + if ($this->has_sub_tab($setting)) { |
|
| 969 | + $meta_key = $this->get_sub_fields_id($setting); |
|
| 970 | 970 | } else { |
| 971 | - $meta_key = $this->get_fields_id( $setting ); |
|
| 971 | + $meta_key = $this->get_fields_id($setting); |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
| 974 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | return $meta_keys; |
@@ -988,10 +988,10 @@ discard block |
||
| 988 | 988 | * |
| 989 | 989 | * @return string |
| 990 | 990 | */ |
| 991 | - function get_field_type( $field_id, $group_id = '' ) { |
|
| 992 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
| 991 | + function get_field_type($field_id, $group_id = '') { |
|
| 992 | + $field = $this->get_setting_field($field_id, $group_id); |
|
| 993 | 993 | |
| 994 | - $type = array_key_exists( 'type', $field ) |
|
| 994 | + $type = array_key_exists('type', $field) |
|
| 995 | 995 | ? $field['type'] |
| 996 | 996 | : ''; |
| 997 | 997 | |
@@ -1009,12 +1009,12 @@ discard block |
||
| 1009 | 1009 | * |
| 1010 | 1010 | * @return array |
| 1011 | 1011 | */ |
| 1012 | - private function get_field( $setting, $field_id ) { |
|
| 1012 | + private function get_field($setting, $field_id) { |
|
| 1013 | 1013 | $setting_field = array(); |
| 1014 | 1014 | |
| 1015 | - if ( ! empty( $setting['fields'] ) ) { |
|
| 1016 | - foreach ( $setting['fields'] as $field ) { |
|
| 1017 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
| 1015 | + if ( ! empty($setting['fields'])) { |
|
| 1016 | + foreach ($setting['fields'] as $field) { |
|
| 1017 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
| 1018 | 1018 | $setting_field = $field; |
| 1019 | 1019 | break; |
| 1020 | 1020 | } |
@@ -1034,12 +1034,12 @@ discard block |
||
| 1034 | 1034 | * |
| 1035 | 1035 | * @return array |
| 1036 | 1036 | */ |
| 1037 | - private function get_sub_field( $setting, $field_id ) { |
|
| 1037 | + private function get_sub_field($setting, $field_id) { |
|
| 1038 | 1038 | $setting_field = array(); |
| 1039 | 1039 | |
| 1040 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
| 1041 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
| 1042 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
| 1040 | + if ( ! empty($setting['sub-fields'])) { |
|
| 1041 | + foreach ($setting['sub-fields'] as $fields) { |
|
| 1042 | + if ($field = $this->get_field($fields, $field_id)) { |
|
| 1043 | 1043 | $setting_field = $field; |
| 1044 | 1044 | break; |
| 1045 | 1045 | } |
@@ -1059,17 +1059,17 @@ discard block |
||
| 1059 | 1059 | * |
| 1060 | 1060 | * @return array |
| 1061 | 1061 | */ |
| 1062 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
| 1062 | + function get_setting_field($field_id, $group_id = '') { |
|
| 1063 | 1063 | $setting_field = array(); |
| 1064 | 1064 | |
| 1065 | 1065 | $_field_id = $field_id; |
| 1066 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
| 1066 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
| 1067 | 1067 | |
| 1068 | - if ( ! empty( $this->settings ) ) { |
|
| 1069 | - foreach ( $this->settings as $setting ) { |
|
| 1068 | + if ( ! empty($this->settings)) { |
|
| 1069 | + foreach ($this->settings as $setting) { |
|
| 1070 | 1070 | if ( |
| 1071 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
| 1072 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
| 1071 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
| 1072 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
| 1073 | 1073 | ) { |
| 1074 | 1074 | break; |
| 1075 | 1075 | } |
@@ -1077,9 +1077,9 @@ discard block |
||
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | // Get field from group. |
| 1080 | - if ( ! empty( $group_id ) ) { |
|
| 1081 | - foreach ( $setting_field['fields'] as $field ) { |
|
| 1082 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
| 1080 | + if ( ! empty($group_id)) { |
|
| 1081 | + foreach ($setting_field['fields'] as $field) { |
|
| 1082 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
| 1083 | 1083 | $setting_field = $field; |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
@@ -1098,14 +1098,14 @@ discard block |
||
| 1098 | 1098 | * |
| 1099 | 1099 | * @return mixed |
| 1100 | 1100 | */ |
| 1101 | - function add_offline_donations_setting_tab( $settings ) { |
|
| 1102 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
| 1103 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
| 1101 | + function add_offline_donations_setting_tab($settings) { |
|
| 1102 | + if (give_is_gateway_active('offline')) { |
|
| 1103 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
| 1104 | 1104 | 'id' => 'offline_donations_options', |
| 1105 | - 'title' => __( 'Offline Donations', 'give' ), |
|
| 1105 | + 'title' => __('Offline Donations', 'give'), |
|
| 1106 | 1106 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
| 1107 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
| 1108 | - ) ); |
|
| 1107 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
| 1108 | + )); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | return $settings; |
@@ -1123,37 +1123,33 @@ discard block |
||
| 1123 | 1123 | * |
| 1124 | 1124 | * @return mixed |
| 1125 | 1125 | */ |
| 1126 | - function sanitize_form_meta( $meta_value, $setting_field ) { |
|
| 1127 | - switch ( $setting_field['type'] ) { |
|
| 1126 | + function sanitize_form_meta($meta_value, $setting_field) { |
|
| 1127 | + switch ($setting_field['type']) { |
|
| 1128 | 1128 | case 'group': |
| 1129 | - if ( ! empty( $setting_field['fields'] ) ) { |
|
| 1130 | - foreach ( $setting_field['fields'] as $field ) { |
|
| 1131 | - if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) { |
|
| 1129 | + if ( ! empty($setting_field['fields'])) { |
|
| 1130 | + foreach ($setting_field['fields'] as $field) { |
|
| 1131 | + if (empty($field['data_type']) || 'price' !== $field['data_type']) { |
|
| 1132 | 1132 | continue; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - foreach ( $meta_value as $index => $meta_data ) { |
|
| 1136 | - if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) { |
|
| 1135 | + foreach ($meta_value as $index => $meta_data) { |
|
| 1136 | + if ( ! isset($meta_value[$index][$field['id']])) { |
|
| 1137 | 1137 | continue; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | - $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ? |
|
| 1141 | - give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) : |
|
| 1142 | - ( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ? |
|
| 1143 | - give_sanitize_amount_for_db( '1.00' ) : |
|
| 1144 | - 0 ); |
|
| 1140 | + $meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) ? |
|
| 1141 | + give_sanitize_amount_for_db($meta_value[$index][$field['id']]) : (('_give_amount' === $field['id'] && empty($field_value)) ? |
|
| 1142 | + give_sanitize_amount_for_db('1.00') : 0); |
|
| 1145 | 1143 | } |
| 1146 | 1144 | } |
| 1147 | 1145 | } |
| 1148 | 1146 | break; |
| 1149 | 1147 | |
| 1150 | 1148 | default: |
| 1151 | - if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) { |
|
| 1149 | + if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) { |
|
| 1152 | 1150 | $meta_value = $meta_value ? |
| 1153 | - give_sanitize_amount_for_db( $meta_value ) : |
|
| 1154 | - ( in_array( $setting_field['id'], array( '_give_set_price', '_give_custom_amount_minimum', '_give_set_goal' ) ) ? |
|
| 1155 | - give_sanitize_amount_for_db( '1.00' ) : |
|
| 1156 | - 0 ); |
|
| 1151 | + give_sanitize_amount_for_db($meta_value) : (in_array($setting_field['id'], array('_give_set_price', '_give_custom_amount_minimum', '_give_set_goal')) ? |
|
| 1152 | + give_sanitize_amount_for_db('1.00') : 0); |
|
| 1157 | 1153 | } |
| 1158 | 1154 | } |
| 1159 | 1155 | |
@@ -1171,12 +1167,12 @@ discard block |
||
| 1171 | 1167 | * |
| 1172 | 1168 | * @return string The URL after redirect. |
| 1173 | 1169 | */ |
| 1174 | - public function maintain_active_tab( $location, $post_id ) { |
|
| 1170 | + public function maintain_active_tab($location, $post_id) { |
|
| 1175 | 1171 | if ( |
| 1176 | - 'give_forms' === get_post_type( $post_id ) && |
|
| 1177 | - ! empty( $_POST['give_form_active_tab'] ) |
|
| 1172 | + 'give_forms' === get_post_type($post_id) && |
|
| 1173 | + ! empty($_POST['give_form_active_tab']) |
|
| 1178 | 1174 | ) { |
| 1179 | - $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location ); |
|
| 1175 | + $location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location); |
|
| 1180 | 1176 | } |
| 1181 | 1177 | |
| 1182 | 1178 | return $location; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.8.13 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -75,63 +75,63 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function init() { |
| 77 | 77 | // Bail early if screen cannot be detected. |
| 78 | - if ( empty( $this->screen ) ) { |
|
| 78 | + if (empty($this->screen)) { |
|
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $content = array(); |
| 83 | 83 | |
| 84 | 84 | // Define content and hook into the appropriate action. |
| 85 | - switch ( $this->screen ) { |
|
| 85 | + switch ($this->screen) { |
|
| 86 | 86 | // Forms screen. |
| 87 | 87 | case 'edit-give_forms': |
| 88 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 88 | + $this->form = $this->post_exists('give_forms'); |
|
| 89 | 89 | |
| 90 | - if ( $this->form ) { |
|
| 90 | + if ($this->form) { |
|
| 91 | 91 | // Form exists. Bail out. |
| 92 | 92 | return false; |
| 93 | 93 | } else { |
| 94 | 94 | // No forms exist. |
| 95 | - $content = $this->get_content( 'no_forms' ); |
|
| 95 | + $content = $this->get_content('no_forms'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) ); |
|
| 98 | + add_action('manage_posts_extra_tablenav', array($this, 'render')); |
|
| 99 | 99 | break; |
| 100 | 100 | // Donations screen. |
| 101 | 101 | case 'give_forms_page_give-payment-history': |
| 102 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 103 | - $this->donation = $this->post_exists( 'give_payment' ); |
|
| 102 | + $this->form = $this->post_exists('give_forms'); |
|
| 103 | + $this->donation = $this->post_exists('give_payment'); |
|
| 104 | 104 | |
| 105 | - if ( $this->donation ) { |
|
| 105 | + if ($this->donation) { |
|
| 106 | 106 | // Donation exists. Bail out. |
| 107 | 107 | return false; |
| 108 | - } elseif ( ! $this->form ) { |
|
| 108 | + } elseif ( ! $this->form) { |
|
| 109 | 109 | // No forms and no donations exist. |
| 110 | - $content = $this->get_content( 'no_donations_or_forms' ); |
|
| 110 | + $content = $this->get_content('no_donations_or_forms'); |
|
| 111 | 111 | } else { |
| 112 | 112 | // No donations exist but a form does exist. |
| 113 | - $content = $this->get_content( 'no_donations' ); |
|
| 113 | + $content = $this->get_content('no_donations'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_action( 'give_payments_page_bottom', array( $this, 'render' ) ); |
|
| 116 | + add_action('give_payments_page_bottom', array($this, 'render')); |
|
| 117 | 117 | break; |
| 118 | 118 | // Donors screen. |
| 119 | 119 | case 'give_forms_page_give-donors': |
| 120 | - $this->form = $this->post_exists( 'give_forms' ); |
|
| 120 | + $this->form = $this->post_exists('give_forms'); |
|
| 121 | 121 | $this->donor = $this->donor_exists(); |
| 122 | 122 | |
| 123 | - if ( $this->donor ) { |
|
| 123 | + if ($this->donor) { |
|
| 124 | 124 | // Donor exists. Bail out. |
| 125 | 125 | return false; |
| 126 | - } elseif ( ! $this->form ) { |
|
| 126 | + } elseif ( ! $this->form) { |
|
| 127 | 127 | // No forms and no donors exist. |
| 128 | - $content = $this->get_content( 'no_donors_or_forms' ); |
|
| 128 | + $content = $this->get_content('no_donors_or_forms'); |
|
| 129 | 129 | } else { |
| 130 | 130 | // No donors exist but a form does exist. |
| 131 | - $content = $this->get_content( 'no_donors' ); |
|
| 131 | + $content = $this->get_content('no_donors'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - add_action( 'give_donors_table_bottom', array( $this, 'render' ) ); |
|
| 134 | + add_action('give_donors_table_bottom', array($this, 'render')); |
|
| 135 | 135 | break; |
| 136 | 136 | default: |
| 137 | 137 | return null; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $this->content = $content; |
| 141 | 141 | |
| 142 | 142 | // Hide non-essential UI elements. |
| 143 | - add_action( 'admin_head', array( $this, 'hide_ui' ) ); |
|
| 143 | + add_action('admin_head', array($this, 'hide_ui')); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param string $which The location of the list table hook: 'top' or 'bottom'. |
| 152 | 152 | */ |
| 153 | - public function render( $which = 'bottom') { |
|
| 153 | + public function render($which = 'bottom') { |
|
| 154 | 154 | // Bail out to prevent content from rendering twice. |
| 155 | - if ( 'top' === $which ) { |
|
| 155 | + if ('top' === $which) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @param string $screen The current screen ID. |
| 179 | 179 | */ |
| 180 | - $content = apply_filters( 'give_blank_slate_content', $this->content, $screen ); |
|
| 180 | + $content = apply_filters('give_blank_slate_content', $this->content, $screen); |
|
| 181 | 181 | |
| 182 | - $template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php'; |
|
| 182 | + $template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php'; |
|
| 183 | 183 | |
| 184 | 184 | include $template_path; |
| 185 | 185 | } |
@@ -201,17 +201,17 @@ discard block |
||
| 201 | 201 | * @param string $post_type Post type used in the query. |
| 202 | 202 | * @return bool True if post exists, otherwise false. |
| 203 | 203 | */ |
| 204 | - private function post_exists( $post_type ) { |
|
| 204 | + private function post_exists($post_type) { |
|
| 205 | 205 | // Attempt to get a single post of the post type. |
| 206 | - $query = new WP_Query( array( |
|
| 206 | + $query = new WP_Query(array( |
|
| 207 | 207 | 'post_type' => $post_type, |
| 208 | 208 | 'posts_per_page' => 1, |
| 209 | 209 | 'no_found_rows' => false, |
| 210 | 210 | 'update_post_meta_cache' => false, |
| 211 | 211 | 'update_post_term_cache' => false, |
| 212 | 212 | 'fields' => 'ids', |
| 213 | - 'post_status' => array( 'any', 'trash' ), |
|
| 214 | - ) ); |
|
| 213 | + 'post_status' => array('any', 'trash'), |
|
| 214 | + )); |
|
| 215 | 215 | |
| 216 | 216 | return $query->have_posts(); |
| 217 | 217 | } |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | * @return bool True if donor exists, otherwise false. |
| 225 | 225 | */ |
| 226 | 226 | private function donor_exists() { |
| 227 | - $donors = Give()->donors->get_donors( array( 'number' => 1 ) ); |
|
| 227 | + $donors = Give()->donors->get_donors(array('number' => 1)); |
|
| 228 | 228 | |
| 229 | - return ! empty( $donors ); |
|
| 229 | + return ! empty($donors); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | * @param string $context The key used to determine which content is returned. |
| 238 | 238 | * @return array Blank slate content. |
| 239 | 239 | */ |
| 240 | - private function get_content( $context ) { |
|
| 240 | + private function get_content($context) { |
|
| 241 | 241 | // Define default content. |
| 242 | 242 | $defaults = array( |
| 243 | - 'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | - 'image_alt' => __( 'Give Icon', 'give' ), |
|
| 245 | - 'heading' => __( 'No donation forms found.', 'give' ), |
|
| 246 | - 'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ), |
|
| 247 | - 'cta_text' => __( 'Create Donation Form', 'give' ), |
|
| 248 | - 'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ), |
|
| 243 | + 'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg', |
|
| 244 | + 'image_alt' => __('Give Icon', 'give'), |
|
| 245 | + 'heading' => __('No donation forms found.', 'give'), |
|
| 246 | + 'message' => __('The first step towards accepting online donations is to create a form.', 'give'), |
|
| 247 | + 'cta_text' => __('Create Donation Form', 'give'), |
|
| 248 | + 'cta_link' => admin_url('post-new.php?post_type=give_forms'), |
|
| 249 | 249 | 'help' => sprintf( |
| 250 | - __( 'Need help? Get started with %sGive 101%s.', 'wbpr' ), |
|
| 250 | + __('Need help? Get started with %sGive 101%s.', 'wbpr'), |
|
| 251 | 251 | '<a href="http://docs.givewp.com/give101/" target="_blank">', |
| 252 | 252 | '</a>' |
| 253 | 253 | ), |
@@ -256,40 +256,40 @@ discard block |
||
| 256 | 256 | // Define contextual content. |
| 257 | 257 | $content = array( |
| 258 | 258 | 'no_donations_or_forms' => array( |
| 259 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 260 | - 'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ), |
|
| 259 | + 'heading' => __('No donations found.', 'give'), |
|
| 260 | + 'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'), |
|
| 261 | 261 | ), |
| 262 | 262 | 'no_donations' => array( |
| 263 | - 'heading' => __( 'No donations found.', 'give' ), |
|
| 264 | - 'message' => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ), |
|
| 265 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 266 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 263 | + 'heading' => __('No donations found.', 'give'), |
|
| 264 | + 'message' => __('When your first donation arrives, a record of the donation will appear here.', 'give'), |
|
| 265 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 266 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 267 | 267 | 'help' => sprintf( |
| 268 | - __( 'Need help? Learn more about %sDonations%s.', 'wbpr' ), |
|
| 268 | + __('Need help? Learn more about %sDonations%s.', 'wbpr'), |
|
| 269 | 269 | '<a href="http://docs.givewp.com/core-donations/">', |
| 270 | 270 | '</a>' |
| 271 | 271 | ), |
| 272 | 272 | ), |
| 273 | 273 | 'no_donors_or_forms' => array( |
| 274 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 275 | - 'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ), |
|
| 274 | + 'heading' => __('No donors found.', 'give'), |
|
| 275 | + 'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'), |
|
| 276 | 276 | ), |
| 277 | 277 | 'no_donors' => array( |
| 278 | - 'heading' => __( 'No donors found.', 'give' ), |
|
| 279 | - 'message' => __( 'When your first donation arrives, the donor will appear here.', 'give' ), |
|
| 280 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
| 281 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
| 278 | + 'heading' => __('No donors found.', 'give'), |
|
| 279 | + 'message' => __('When your first donation arrives, the donor will appear here.', 'give'), |
|
| 280 | + 'cta_text' => __('View All Forms', 'give'), |
|
| 281 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
| 282 | 282 | 'help' => sprintf( |
| 283 | - __( 'Need help? Learn more about %sDonors%s.', 'wbpr' ), |
|
| 283 | + __('Need help? Learn more about %sDonors%s.', 'wbpr'), |
|
| 284 | 284 | '<a href="http://docs.givewp.com/core-donors/">', |
| 285 | 285 | '</a>' |
| 286 | 286 | ), |
| 287 | 287 | ), |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - if ( isset( $content[ $context ] ) ) { |
|
| 290 | + if (isset($content[$context])) { |
|
| 291 | 291 | // Merge contextual content with defaults. |
| 292 | - return wp_parse_args( $content[ $context ], $defaults ); |
|
| 292 | + return wp_parse_args($content[$context], $defaults); |
|
| 293 | 293 | } else { |
| 294 | 294 | // Return defaults if context is undefined. |
| 295 | 295 | return $defaults; |
@@ -95,5 +95,8 @@ |
||
| 95 | 95 | <?php endif; ?> |
| 96 | 96 | <?php echo $form_close_tag; ?> |
| 97 | 97 | </div> |
| 98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 98 | +<?php else { |
|
| 99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
| 100 | +} |
|
| 101 | +?> |
|
| 99 | 102 | <?php endif; ?> |
| 100 | 103 | \ No newline at end of file |
@@ -2,12 +2,12 @@ discard block |
||
| 2 | 2 | /** |
| 3 | 3 | * Admin View: Settings |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if ( ! defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Bailout: Do not output anything if setting tab is not defined. |
| 10 | -if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
| 10 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
| 11 | 11 | /** |
| 12 | 12 | * Filter the form action. |
| 13 | 13 | * |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @since 1.8 |
| 19 | 19 | */ |
| 20 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
| 20 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Filter the main form tab. |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @since 1.8 |
| 31 | 31 | */ |
| 32 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
| 33 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
| 32 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
| 33 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
| 34 | 34 | ?> |
| 35 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
| 35 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
| 36 | 36 | <?php |
| 37 | 37 | echo $form_open_tag; |
| 38 | 38 | |
| 39 | 39 | /* @var Give_Settings_Page $current_setting_obj */ |
| 40 | 40 | if ( |
| 41 | - ! empty( $current_setting_obj ) && |
|
| 42 | - method_exists( $current_setting_obj, 'get_heading_html' ) |
|
| 41 | + ! empty($current_setting_obj) && |
|
| 42 | + method_exists($current_setting_obj, 'get_heading_html') |
|
| 43 | 43 | ) { |
| 44 | 44 | echo $current_setting_obj->get_heading_html(); |
| 45 | 45 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // Backward compatibility. |
| 48 | 48 | echo sprintf( |
| 49 | 49 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
| 50 | - esc_html( $tabs[ $current_tab ] ) |
|
| 50 | + esc_html($tabs[$current_tab]) |
|
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | ?> |
| 56 | 56 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
| 57 | 57 | <?php |
| 58 | - foreach ( $tabs as $name => $label ) { |
|
| 59 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>'; |
|
| 58 | + foreach ($tabs as $name => $label) { |
|
| 59 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>'; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @since 1.8 |
| 70 | 70 | */ |
| 71 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
| 71 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
| 72 | 72 | ?> |
| 73 | 73 | </div> |
| 74 | 74 | <div class="give-sub-nav-tab-wrapper"> |
| 75 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
| 75 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
| 76 | 76 | </a> |
| 77 | 77 | <nav class="give-sub-nav-tab give-hidden"></nav> |
| 78 | 78 | </div> |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @since 1.8 |
| 89 | 89 | */ |
| 90 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
| 90 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Trigger Action. |
@@ -98,15 +98,15 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @since 1.8 |
| 100 | 100 | */ |
| 101 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
| 101 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
| 102 | 102 | |
| 103 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
| 103 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
| 104 | 104 | <div class="give-submit-wrap"> |
| 105 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
| 106 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/> |
|
| 105 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
| 106 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/> |
|
| 107 | 107 | </div> |
| 108 | 108 | <?php endif; ?> |
| 109 | 109 | <?php echo $form_close_tag; ?> |
| 110 | 110 | </div> |
| 111 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
| 111 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
| 112 | 112 | <?php endif; ?> |
| 113 | 113 | \ No newline at end of file |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="give-blank-slate"> |
| 20 | - <?php if ( ! empty( $content['image_url'] ) ) : ?> |
|
| 21 | - <img class="give-blank-slate__image" src="<?php echo esc_url( $content['image_url'] ); ?>" alt="<?php echo esc_attr( $content['image_alt'] ); ?>"> |
|
| 20 | + <?php if ( ! empty($content['image_url'])) : ?> |
|
| 21 | + <img class="give-blank-slate__image" src="<?php echo esc_url($content['image_url']); ?>" alt="<?php echo esc_attr($content['image_alt']); ?>"> |
|
| 22 | 22 | <?php endif; ?> |
| 23 | 23 | |
| 24 | - <?php if ( ! empty( $content['heading'] ) ) : ?> |
|
| 25 | - <h2 class="give-blank-slate__heading"><?php esc_html_e( $content['heading'] ); ?></h2> |
|
| 24 | + <?php if ( ! empty($content['heading'])) : ?> |
|
| 25 | + <h2 class="give-blank-slate__heading"><?php esc_html_e($content['heading']); ?></h2> |
|
| 26 | 26 | <?php endif; ?> |
| 27 | 27 | |
| 28 | - <?php if ( ! empty( $content['message'] ) ) : ?> |
|
| 29 | - <p class="give-blank-slate__message"><?php esc_html_e( $content['message'] ); ?></p> |
|
| 28 | + <?php if ( ! empty($content['message'])) : ?> |
|
| 29 | + <p class="give-blank-slate__message"><?php esc_html_e($content['message']); ?></p> |
|
| 30 | 30 | <?php endif; ?> |
| 31 | 31 | |
| 32 | - <?php if ( ! empty( $content['cta_text']) && ! empty( $content['cta_link'] ) ) : ?> |
|
| 33 | - <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url( $content['cta_link'] ); ?>"><?php esc_html_e( $content['cta_text'] ); ?></a> |
|
| 32 | + <?php if ( ! empty($content['cta_text']) && ! empty($content['cta_link'])) : ?> |
|
| 33 | + <a class="give-blank-slate__cta button button-primary" href="<?php echo esc_url($content['cta_link']); ?>"><?php esc_html_e($content['cta_text']); ?></a> |
|
| 34 | 34 | <?php endif; ?> |
| 35 | 35 | |
| 36 | - <?php if ( ! empty( $content['help'] ) ) : ?> |
|
| 36 | + <?php if ( ! empty($content['help'])) : ?> |
|
| 37 | 37 | <p class="give-blank-slate__help"> |
| 38 | 38 | <?php |
| 39 | 39 | $allowed_html = array( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'code' => array(), |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - echo wp_kses( $content['help'], $allowed_html ); |
|
| 50 | + echo wp_kses($content['help'], $allowed_html); |
|
| 51 | 51 | ?> |
| 52 | 52 | </p> |
| 53 | 53 | <?php endif; ?> |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @since 1.5 |
| 21 | 21 | */ |
| 22 | 22 | function give_register_batch_recount_export_classes() { |
| 23 | - add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 ); |
|
| 23 | + add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 ); |
|
| 26 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10); |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,39 +35,39 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | -function give_include_batch_export_class( $class ) { |
|
| 39 | - switch ( $class ) { |
|
| 38 | +function give_include_batch_export_class($class) { |
|
| 39 | + switch ($class) { |
|
| 40 | 40 | |
| 41 | 41 | case 'Give_Tools_Delete_Donors': |
| 42 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 42 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php'; |
|
| 43 | 43 | break; |
| 44 | 44 | |
| 45 | 45 | case 'Give_Tools_Import_Donors': |
| 46 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 46 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-import-donors.php'; |
|
| 47 | 47 | break; |
| 48 | 48 | |
| 49 | 49 | case 'Give_Tools_Delete_Test_Transactions': |
| 50 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 50 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php'; |
|
| 51 | 51 | break; |
| 52 | 52 | |
| 53 | 53 | case 'Give_Tools_Recount_Donor_Stats': |
| 54 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 54 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php'; |
|
| 55 | 55 | break; |
| 56 | 56 | |
| 57 | 57 | case 'Give_Tools_Reset_Stats': |
| 58 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 58 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php'; |
|
| 59 | 59 | break; |
| 60 | 60 | |
| 61 | 61 | case 'Give_Tools_Recount_All_Stats': |
| 62 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 62 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php'; |
|
| 63 | 63 | break; |
| 64 | 64 | |
| 65 | 65 | case 'Give_Tools_Recount_Form_Stats': |
| 66 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 66 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php'; |
|
| 67 | 67 | break; |
| 68 | 68 | |
| 69 | 69 | case 'Give_Tools_Recount_Income': |
| 70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php'; |
|
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
| 31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
| 32 | 32 | |
| 33 | 33 | // Make sure that payments are only completed once. |
| 34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
| 34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
| 39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
| 39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $payment = new Give_Payment( $payment_id ); |
|
| 43 | + $payment = new Give_Payment($payment_id); |
|
| 44 | 44 | |
| 45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
| 45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
| 46 | 46 | $payment_meta = $payment->payment_meta; |
| 47 | 47 | $completed_date = $payment->completed_date; |
| 48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @param int $payment_id The ID of the payment. |
| 60 | 60 | */ |
| 61 | - do_action( 'give_pre_complete_donation', $payment_id ); |
|
| 61 | + do_action('give_pre_complete_donation', $payment_id); |
|
| 62 | 62 | |
| 63 | 63 | // Ensure these actions only run once, ever. |
| 64 | - if ( empty( $completed_date ) ) { |
|
| 64 | + if (empty($completed_date)) { |
|
| 65 | 65 | |
| 66 | - give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
| 66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
| 74 | 74 | * @param int $payment_id The ID number of the payment. |
| 75 | 75 | * @param array $payment_meta The payment meta. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
| 77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Increase the earnings for this form ID. |
| 82 | - give_increase_earnings( $form_id, $amount ); |
|
| 83 | - give_increase_donation_count( $form_id ); |
|
| 82 | + give_increase_earnings($form_id, $amount); |
|
| 83 | + give_increase_donation_count($form_id); |
|
| 84 | 84 | |
| 85 | 85 | // @todo: Refresh only range related stat cache |
| 86 | 86 | give_delete_donation_stats(); |
| 87 | 87 | |
| 88 | 88 | // Increase the donor's donation stats. |
| 89 | - $donor = new Give_Donor( $donor_id ); |
|
| 89 | + $donor = new Give_Donor($donor_id); |
|
| 90 | 90 | $donor->increase_purchase_count(); |
| 91 | - $donor->increase_value( $amount ); |
|
| 91 | + $donor->increase_value($amount); |
|
| 92 | 92 | |
| 93 | - give_increase_total_earnings( $amount ); |
|
| 93 | + give_increase_total_earnings($amount); |
|
| 94 | 94 | |
| 95 | 95 | // Ensure this action only runs once ever. |
| 96 | - if ( empty( $completed_date ) ) { |
|
| 96 | + if (empty($completed_date)) { |
|
| 97 | 97 | |
| 98 | 98 | // Save the completed date. |
| 99 | - $payment->completed_date = current_time( 'mysql' ); |
|
| 99 | + $payment->completed_date = current_time('mysql'); |
|
| 100 | 100 | $payment->save(); |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param int $payment_id The ID of the payment. |
| 108 | 108 | */ |
| 109 | - do_action( 'give_complete_donation', $payment_id ); |
|
| 109 | + do_action('give_complete_donation', $payment_id); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
| 114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
| 128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
| 129 | 129 | |
| 130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
| 131 | 131 | $stati = give_get_payment_statuses(); |
| 132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
| 133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
| 132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
| 133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
| 134 | 134 | |
| 135 | 135 | // translators: 1: old status 2: new status. |
| 136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
| 136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
| 137 | 137 | |
| 138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
| 138 | + give_insert_payment_note($payment_id, $status_change); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
| 141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | -function give_update_old_payments_with_totals( $data ) { |
|
| 158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
| 157 | +function give_update_old_payments_with_totals($data) { |
|
| 158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
| 162 | + if (get_option('give_payment_totals_upgraded')) { |
|
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $payments = give_get_payments( array( |
|
| 166 | + $payments = give_get_payments(array( |
|
| 167 | 167 | 'offset' => 0, |
| 168 | - 'number' => - 1, |
|
| 168 | + 'number' => -1, |
|
| 169 | 169 | 'mode' => 'all', |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - if ( $payments ) { |
|
| 173 | - foreach ( $payments as $payment ) { |
|
| 172 | + if ($payments) { |
|
| 173 | + foreach ($payments as $payment) { |
|
| 174 | 174 | |
| 175 | - $payment = new Give_Payment( $payment->ID ); |
|
| 175 | + $payment = new Give_Payment($payment->ID); |
|
| 176 | 176 | $meta = $payment->get_meta(); |
| 177 | 177 | |
| 178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
| 184 | + add_option('give_payment_totals_upgraded', 1); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
| 187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
| 198 | 198 | function give_mark_abandoned_donations() { |
| 199 | 199 | $args = array( |
| 200 | 200 | 'status' => 'pending', |
| 201 | - 'number' => - 1, |
|
| 201 | + 'number' => -1, |
|
| 202 | 202 | 'output' => 'give_payments', |
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 206 | 206 | |
| 207 | - $payments = give_get_payments( $args ); |
|
| 207 | + $payments = give_get_payments($args); |
|
| 208 | 208 | |
| 209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
| 209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
| 210 | 210 | |
| 211 | - if ( $payments ) { |
|
| 211 | + if ($payments) { |
|
| 212 | 212 | /** |
| 213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
| 214 | 214 | * |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
| 218 | 218 | */ |
| 219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
| 219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
| 220 | 220 | |
| 221 | - foreach ( $payments as $payment ) { |
|
| 222 | - $gateway = give_get_payment_gateway( $payment ); |
|
| 221 | + foreach ($payments as $payment) { |
|
| 222 | + $gateway = give_get_payment_gateway($payment); |
|
| 223 | 223 | |
| 224 | 224 | // Skip payment gateways. |
| 225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
| 225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
| 226 | 226 | continue; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' ); |
|
| 235 | +Give_Cron::add_weekly_event('give_mark_abandoned_donations'); |
|
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @return void |
| 246 | 246 | */ |
| 247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
| 247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
| 248 | 248 | // Monthly stats. |
| 249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 250 | 250 | |
| 251 | 251 | // @todo: Refresh only range related stat cache |
| 252 | 252 | give_delete_donation_stats(); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
| 255 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
|
| 256 | 256 | |
| 257 | 257 | /* |
| 258 | 258 | * Add meta in payment that store page id and page url. |
@@ -264,18 +264,18 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param {integer} $payment_id Payment id for which the meta value should be updated. |
| 266 | 266 | */ |
| 267 | -function give_payment_save_page_data( $payment_id ) { |
|
| 268 | - $page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false ); |
|
| 267 | +function give_payment_save_page_data($payment_id) { |
|
| 268 | + $page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false); |
|
| 269 | 269 | // Check $page_url is not empty. |
| 270 | - if ( $page_url ) { |
|
| 271 | - update_post_meta( $payment_id, '_give_current_url', $page_url ); |
|
| 272 | - $page_id = url_to_postid( $page_url ); |
|
| 270 | + if ($page_url) { |
|
| 271 | + update_post_meta($payment_id, '_give_current_url', $page_url); |
|
| 272 | + $page_id = url_to_postid($page_url); |
|
| 273 | 273 | // Check $page_id is not empty. |
| 274 | - if ( $page_id ) { |
|
| 275 | - update_post_meta( $payment_id, '_give_current_page_id', $page_id ); |
|
| 274 | + if ($page_id) { |
|
| 275 | + update_post_meta($payment_id, '_give_current_page_id', $page_id); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Fire when payment is save. |
| 281 | -add_action( 'give_insert_payment', 'give_payment_save_page_data' ); |
|
| 282 | 281 | \ No newline at end of file |
| 282 | +add_action('give_insert_payment', 'give_payment_save_page_data'); |
|
| 283 | 283 | \ No newline at end of file |
@@ -1012,7 +1012,7 @@ |
||
| 1012 | 1012 | // Find a match between price_id and level_id. |
| 1013 | 1013 | // First verify array keys exists THEN make the match. |
| 1014 | 1014 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
| 1015 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 1015 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
| 1016 | 1016 | ) { |
| 1017 | 1017 | $donation_amount = $price['_give_amount']; |
| 1018 | 1018 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * |
| 392 | 392 | * @param int|bool $payment_id A given payment |
| 393 | 393 | * |
| 394 | - * @return mixed void|false |
|
| 394 | + * @return false|null void|false |
|
| 395 | 395 | */ |
| 396 | 396 | public function __construct( $payment_id = false ) { |
| 397 | 397 | |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * |
| 1116 | 1116 | * @param string|bool $note The note to add |
| 1117 | 1117 | * |
| 1118 | - * @return bool If the note was specified or not |
|
| 1118 | + * @return false|null If the note was specified or not |
|
| 1119 | 1119 | */ |
| 1120 | 1120 | public function add_note( $note = false ) { |
| 1121 | 1121 | // Bail if no note specified. |
@@ -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 | |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | * |
| 394 | 394 | * @return mixed void|false |
| 395 | 395 | */ |
| 396 | - public function __construct( $payment_id = false ) { |
|
| 396 | + public function __construct($payment_id = false) { |
|
| 397 | 397 | |
| 398 | - if ( empty( $payment_id ) ) { |
|
| 398 | + if (empty($payment_id)) { |
|
| 399 | 399 | return false; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - $this->setup_payment( $payment_id ); |
|
| 402 | + $this->setup_payment($payment_id); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | * |
| 413 | 413 | * @return mixed The value. |
| 414 | 414 | */ |
| 415 | - public function __get( $key ) { |
|
| 415 | + public function __get($key) { |
|
| 416 | 416 | |
| 417 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 417 | + if (method_exists($this, 'get_'.$key)) { |
|
| 418 | 418 | |
| 419 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
| 419 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
| 420 | 420 | |
| 421 | 421 | } else { |
| 422 | 422 | |
@@ -438,18 +438,18 @@ discard block |
||
| 438 | 438 | * @param string $key The property name |
| 439 | 439 | * @param mixed $value The value of the property |
| 440 | 440 | */ |
| 441 | - public function __set( $key, $value ) { |
|
| 442 | - $ignore = array( '_ID' ); |
|
| 441 | + public function __set($key, $value) { |
|
| 442 | + $ignore = array('_ID'); |
|
| 443 | 443 | |
| 444 | - if ( 'status' === $key ) { |
|
| 444 | + if ('status' === $key) { |
|
| 445 | 445 | $this->old_status = $this->status; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if ( ! in_array( $key, $ignore ) ) { |
|
| 449 | - $this->pending[ $key ] = $value; |
|
| 448 | + if ( ! in_array($key, $ignore)) { |
|
| 449 | + $this->pending[$key] = $value; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if ( '_ID' !== $key ) { |
|
| 452 | + if ('_ID' !== $key) { |
|
| 453 | 453 | $this->$key = $value; |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -464,9 +464,9 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @return boolean|null If the item is set or not |
| 466 | 466 | */ |
| 467 | - public function __isset( $name ) { |
|
| 468 | - if ( property_exists( $this, $name ) ) { |
|
| 469 | - return false === empty( $this->$name ); |
|
| 467 | + public function __isset($name) { |
|
| 468 | + if (property_exists($this, $name)) { |
|
| 469 | + return false === empty($this->$name); |
|
| 470 | 470 | } else { |
| 471 | 471 | return null; |
| 472 | 472 | } |
@@ -482,20 +482,20 @@ discard block |
||
| 482 | 482 | * |
| 483 | 483 | * @return bool If the setup was successful or not |
| 484 | 484 | */ |
| 485 | - private function setup_payment( $payment_id ) { |
|
| 485 | + private function setup_payment($payment_id) { |
|
| 486 | 486 | $this->pending = array(); |
| 487 | 487 | |
| 488 | - if ( empty( $payment_id ) ) { |
|
| 488 | + if (empty($payment_id)) { |
|
| 489 | 489 | return false; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $payment = get_post( $payment_id ); |
|
| 492 | + $payment = get_post($payment_id); |
|
| 493 | 493 | |
| 494 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
| 494 | + if ( ! $payment || is_wp_error($payment)) { |
|
| 495 | 495 | return false; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - if ( 'give_payment' !== $payment->post_type ) { |
|
| 498 | + if ('give_payment' !== $payment->post_type) { |
|
| 499 | 499 | return false; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -509,13 +509,13 @@ discard block |
||
| 509 | 509 | * @param Give_Payment $this Payment object. |
| 510 | 510 | * @param int $payment_id The ID of the payment. |
| 511 | 511 | */ |
| 512 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
| 512 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
| 513 | 513 | |
| 514 | 514 | // Primary Identifier. |
| 515 | - $this->ID = absint( $payment_id ); |
|
| 515 | + $this->ID = absint($payment_id); |
|
| 516 | 516 | |
| 517 | 517 | // Protected ID that can never be changed. |
| 518 | - $this->_ID = absint( $payment_id ); |
|
| 518 | + $this->_ID = absint($payment_id); |
|
| 519 | 519 | |
| 520 | 520 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
| 521 | 521 | $this->payment_meta = $this->get_meta(); |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | $this->parent_payment = $payment->post_parent; |
| 532 | 532 | |
| 533 | 533 | $all_payment_statuses = give_get_payment_statuses(); |
| 534 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
| 534 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
| 535 | 535 | |
| 536 | 536 | // Currency Based. |
| 537 | 537 | $this->total = $this->setup_total(); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * @param Give_Payment $this Payment object. |
| 571 | 571 | * @param int $payment_id The ID of the payment. |
| 572 | 572 | */ |
| 573 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
| 573 | + do_action('give_setup_payment', $this, $payment_id); |
|
| 574 | 574 | |
| 575 | 575 | return true; |
| 576 | 576 | } |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * |
| 589 | 589 | * @return void |
| 590 | 590 | */ |
| 591 | - public function update_payment_setup( $payment_id ) { |
|
| 592 | - $this->setup_payment( $payment_id ); |
|
| 591 | + public function update_payment_setup($payment_id) { |
|
| 592 | + $this->setup_payment($payment_id); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -604,24 +604,24 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | // Construct the payment title. |
| 606 | 606 | $payment_title = ''; |
| 607 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
| 608 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
| 609 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
| 607 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
| 608 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
| 609 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
| 610 | 610 | $payment_title = $this->first_name; |
| 611 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
| 611 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
| 612 | 612 | $payment_title = $this->email; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Set Key. |
| 616 | - if ( empty( $this->key ) ) { |
|
| 616 | + if (empty($this->key)) { |
|
| 617 | 617 | |
| 618 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 619 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
| 618 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 619 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
| 620 | 620 | $this->pending['key'] = $this->key; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // Set IP. |
| 624 | - if ( empty( $this->ip ) ) { |
|
| 624 | + if (empty($this->ip)) { |
|
| 625 | 625 | |
| 626 | 626 | $this->ip = give_get_ip(); |
| 627 | 627 | $this->pending['ip'] = $this->ip; |
@@ -648,19 +648,19 @@ discard block |
||
| 648 | 648 | 'status' => $this->status, |
| 649 | 649 | ); |
| 650 | 650 | |
| 651 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
| 651 | + $args = apply_filters('give_insert_payment_args', array( |
|
| 652 | 652 | 'post_title' => $payment_title, |
| 653 | 653 | 'post_status' => $this->status, |
| 654 | 654 | 'post_type' => 'give_payment', |
| 655 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
| 656 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
| 655 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
| 656 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
| 657 | 657 | 'post_parent' => $this->parent_payment, |
| 658 | - ), $payment_data ); |
|
| 658 | + ), $payment_data); |
|
| 659 | 659 | |
| 660 | 660 | // Create a blank payment |
| 661 | - $payment_id = wp_insert_post( $args ); |
|
| 661 | + $payment_id = wp_insert_post($args); |
|
| 662 | 662 | |
| 663 | - if ( ! empty( $payment_id ) ) { |
|
| 663 | + if ( ! empty($payment_id)) { |
|
| 664 | 664 | |
| 665 | 665 | $this->ID = $payment_id; |
| 666 | 666 | $this->_ID = $payment_id; |
@@ -672,40 +672,40 @@ discard block |
||
| 672 | 672 | * |
| 673 | 673 | * @since 1.8.13 |
| 674 | 674 | */ |
| 675 | - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args ); |
|
| 675 | + $donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args); |
|
| 676 | 676 | |
| 677 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
| 678 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
| 677 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
| 678 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
| 679 | 679 | |
| 680 | 680 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
| 681 | - if ( ! empty( $donor->id ) && $this->email !== $donor->email ) { |
|
| 682 | - $donor->add_email( $this->email ); |
|
| 681 | + if ( ! empty($donor->id) && $this->email !== $donor->email) { |
|
| 682 | + $donor->add_email($this->email); |
|
| 683 | 683 | } |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - if ( empty( $donor->id ) ) { |
|
| 687 | - $donor = new Give_Donor( $this->email ); |
|
| 686 | + if (empty($donor->id)) { |
|
| 687 | + $donor = new Give_Donor($this->email); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if ( empty( $donor->id ) ) { |
|
| 690 | + if (empty($donor->id)) { |
|
| 691 | 691 | |
| 692 | 692 | $donor_data = array( |
| 693 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
| 693 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
| 694 | 694 | 'email' => $this->email, |
| 695 | 695 | 'user_id' => $this->user_id, |
| 696 | 696 | ); |
| 697 | 697 | |
| 698 | - $donor->create( $donor_data ); |
|
| 698 | + $donor->create($donor_data); |
|
| 699 | 699 | |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | $this->customer_id = $donor->id; |
| 703 | 703 | $this->pending['customer_id'] = $this->customer_id; |
| 704 | - $donor->attach_payment( $this->ID, false ); |
|
| 704 | + $donor->attach_payment($this->ID, false); |
|
| 705 | 705 | |
| 706 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
| 706 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
| 707 | 707 | |
| 708 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
| 708 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
| 709 | 709 | $this->new = true; |
| 710 | 710 | }// End if(). |
| 711 | 711 | |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | $saved = false; |
| 728 | 728 | |
| 729 | 729 | // Must have an ID. |
| 730 | - if ( empty( $this->ID ) ) { |
|
| 730 | + if (empty($this->ID)) { |
|
| 731 | 731 | |
| 732 | 732 | $payment_id = $this->insert_payment(); |
| 733 | 733 | |
| 734 | - if ( false === $payment_id ) { |
|
| 734 | + if (false === $payment_id) { |
|
| 735 | 735 | $saved = false; |
| 736 | 736 | } else { |
| 737 | 737 | $this->ID = $payment_id; |
@@ -739,42 +739,42 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Set ID if not matching. |
| 742 | - if ( $this->ID !== $this->_ID ) { |
|
| 742 | + if ($this->ID !== $this->_ID) { |
|
| 743 | 743 | $this->ID = $this->_ID; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | // If we have something pending, let's save it. |
| 747 | - if ( ! empty( $this->pending ) ) { |
|
| 747 | + if ( ! empty($this->pending)) { |
|
| 748 | 748 | |
| 749 | 749 | $total_increase = 0; |
| 750 | 750 | $total_decrease = 0; |
| 751 | 751 | |
| 752 | - foreach ( $this->pending as $key => $value ) { |
|
| 752 | + foreach ($this->pending as $key => $value) { |
|
| 753 | 753 | |
| 754 | - switch ( $key ) { |
|
| 754 | + switch ($key) { |
|
| 755 | 755 | |
| 756 | 756 | case 'donations': |
| 757 | 757 | // Update totals for pending donations. |
| 758 | - foreach ( $this->pending[ $key ] as $item ) { |
|
| 758 | + foreach ($this->pending[$key] as $item) { |
|
| 759 | 759 | |
| 760 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
| 761 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
| 760 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
| 761 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
| 762 | 762 | |
| 763 | - switch ( $item['action'] ) { |
|
| 763 | + switch ($item['action']) { |
|
| 764 | 764 | |
| 765 | 765 | case 'add': |
| 766 | 766 | |
| 767 | 767 | $price = $item['price']; |
| 768 | 768 | |
| 769 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 769 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 770 | 770 | |
| 771 | 771 | // Add donation to logs. |
| 772 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
| 773 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
| 772 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
| 773 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
| 774 | 774 | |
| 775 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 776 | - $form->increase_sales( $quantity ); |
|
| 777 | - $form->increase_earnings( $price ); |
|
| 775 | + $form = new Give_Donate_Form($item['id']); |
|
| 776 | + $form->increase_sales($quantity); |
|
| 777 | + $form->increase_earnings($price); |
|
| 778 | 778 | |
| 779 | 779 | $total_increase += $price; |
| 780 | 780 | } |
@@ -799,15 +799,15 @@ discard block |
||
| 799 | 799 | ), |
| 800 | 800 | ); |
| 801 | 801 | |
| 802 | - $found_logs = get_posts( $log_args ); |
|
| 803 | - foreach ( $found_logs as $log ) { |
|
| 804 | - wp_delete_post( $log->ID, true ); |
|
| 802 | + $found_logs = get_posts($log_args); |
|
| 803 | + foreach ($found_logs as $log) { |
|
| 804 | + wp_delete_post($log->ID, true); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
| 808 | - $form = new Give_Donate_Form( $item['id'] ); |
|
| 809 | - $form->decrease_sales( $quantity ); |
|
| 810 | - $form->decrease_earnings( $item['amount'] ); |
|
| 807 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
| 808 | + $form = new Give_Donate_Form($item['id']); |
|
| 809 | + $form->decrease_sales($quantity); |
|
| 810 | + $form->decrease_earnings($item['amount']); |
|
| 811 | 811 | |
| 812 | 812 | $total_decrease += $item['amount']; |
| 813 | 813 | } |
@@ -818,44 +818,44 @@ discard block |
||
| 818 | 818 | break; |
| 819 | 819 | |
| 820 | 820 | case 'status': |
| 821 | - $this->update_status( $this->status ); |
|
| 821 | + $this->update_status($this->status); |
|
| 822 | 822 | break; |
| 823 | 823 | |
| 824 | 824 | case 'gateway': |
| 825 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
| 825 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
| 826 | 826 | break; |
| 827 | 827 | |
| 828 | 828 | case 'mode': |
| 829 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
| 829 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
| 830 | 830 | break; |
| 831 | 831 | |
| 832 | 832 | case 'transaction_id': |
| 833 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
| 833 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
| 834 | 834 | break; |
| 835 | 835 | |
| 836 | 836 | case 'ip': |
| 837 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
| 837 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
| 838 | 838 | break; |
| 839 | 839 | |
| 840 | 840 | case 'customer_id': |
| 841 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
| 841 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
| 842 | 842 | break; |
| 843 | 843 | |
| 844 | 844 | case 'user_id': |
| 845 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
| 845 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
| 846 | 846 | $this->user_info['id'] = $this->user_id; |
| 847 | 847 | break; |
| 848 | 848 | |
| 849 | 849 | case 'form_title': |
| 850 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
| 850 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
| 851 | 851 | break; |
| 852 | 852 | |
| 853 | 853 | case 'form_id': |
| 854 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
| 854 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
| 855 | 855 | break; |
| 856 | 856 | |
| 857 | 857 | case 'price_id': |
| 858 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
| 858 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
| 859 | 859 | break; |
| 860 | 860 | |
| 861 | 861 | case 'first_name': |
@@ -871,15 +871,15 @@ discard block |
||
| 871 | 871 | break; |
| 872 | 872 | |
| 873 | 873 | case 'email': |
| 874 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
| 874 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
| 875 | 875 | break; |
| 876 | 876 | |
| 877 | 877 | case 'key': |
| 878 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
| 878 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | case 'number': |
| 882 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
| 882 | + $this->update_meta('_give_payment_number', $this->number); |
|
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'date': |
@@ -889,11 +889,11 @@ discard block |
||
| 889 | 889 | 'edit_date' => true, |
| 890 | 890 | ); |
| 891 | 891 | |
| 892 | - wp_update_post( $args ); |
|
| 892 | + wp_update_post($args); |
|
| 893 | 893 | break; |
| 894 | 894 | |
| 895 | 895 | case 'completed_date': |
| 896 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
| 896 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
| 897 | 897 | break; |
| 898 | 898 | |
| 899 | 899 | case 'parent_payment': |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | 'post_parent' => $this->parent_payment, |
| 903 | 903 | ); |
| 904 | 904 | |
| 905 | - wp_update_post( $args ); |
|
| 905 | + wp_update_post($args); |
|
| 906 | 906 | break; |
| 907 | 907 | |
| 908 | 908 | default: |
@@ -913,33 +913,33 @@ discard block |
||
| 913 | 913 | * |
| 914 | 914 | * @param Give_Payment $this Payment object. |
| 915 | 915 | */ |
| 916 | - do_action( 'give_payment_save', $this, $key ); |
|
| 916 | + do_action('give_payment_save', $this, $key); |
|
| 917 | 917 | break; |
| 918 | 918 | }// End switch(). |
| 919 | 919 | }// End foreach(). |
| 920 | 920 | |
| 921 | - if ( 'pending' !== $this->status ) { |
|
| 921 | + if ('pending' !== $this->status) { |
|
| 922 | 922 | |
| 923 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 923 | + $donor = new Give_Donor($this->customer_id); |
|
| 924 | 924 | |
| 925 | 925 | $total_change = $total_increase - $total_decrease; |
| 926 | - if ( $total_change < 0 ) { |
|
| 926 | + if ($total_change < 0) { |
|
| 927 | 927 | |
| 928 | - $total_change = - ( $total_change ); |
|
| 928 | + $total_change = - ($total_change); |
|
| 929 | 929 | // Decrease the donor's donation stats. |
| 930 | - $donor->decrease_value( $total_change ); |
|
| 931 | - give_decrease_total_earnings( $total_change ); |
|
| 930 | + $donor->decrease_value($total_change); |
|
| 931 | + give_decrease_total_earnings($total_change); |
|
| 932 | 932 | |
| 933 | - } elseif ( $total_change > 0 ) { |
|
| 933 | + } elseif ($total_change > 0) { |
|
| 934 | 934 | |
| 935 | 935 | // Increase the donor's donation stats. |
| 936 | - $donor->increase_value( $total_change ); |
|
| 937 | - give_increase_total_earnings( $total_change ); |
|
| 936 | + $donor->increase_value($total_change); |
|
| 937 | + give_increase_total_earnings($total_change); |
|
| 938 | 938 | |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
| 942 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
| 943 | 943 | |
| 944 | 944 | $new_meta = array( |
| 945 | 945 | 'form_title' => $this->form_title, |
@@ -950,12 +950,12 @@ discard block |
||
| 950 | 950 | ); |
| 951 | 951 | |
| 952 | 952 | $meta = $this->get_meta(); |
| 953 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
| 953 | + $merged_meta = array_merge($meta, $new_meta); |
|
| 954 | 954 | |
| 955 | 955 | // Only save the payment meta if it's changed. |
| 956 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
| 957 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
| 958 | - if ( false !== $updated ) { |
|
| 956 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
| 957 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
| 958 | + if (false !== $updated) { |
|
| 959 | 959 | $saved = true; |
| 960 | 960 | } |
| 961 | 961 | } |
@@ -964,8 +964,8 @@ discard block |
||
| 964 | 964 | $saved = true; |
| 965 | 965 | }// End if(). |
| 966 | 966 | |
| 967 | - if ( true === $saved ) { |
|
| 968 | - $this->setup_payment( $this->ID ); |
|
| 967 | + if (true === $saved) { |
|
| 968 | + $this->setup_payment($this->ID); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | return $saved; |
@@ -983,12 +983,12 @@ discard block |
||
| 983 | 983 | * |
| 984 | 984 | * @return bool True when successful, false otherwise |
| 985 | 985 | */ |
| 986 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
| 986 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
| 987 | 987 | |
| 988 | - $donation = new Give_Donate_Form( $form_id ); |
|
| 988 | + $donation = new Give_Donate_Form($form_id); |
|
| 989 | 989 | |
| 990 | 990 | // Bail if this post isn't a give donation form. |
| 991 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
| 991 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
| 992 | 992 | return false; |
| 993 | 993 | } |
| 994 | 994 | |
@@ -998,59 +998,59 @@ discard block |
||
| 998 | 998 | 'price_id' => false, |
| 999 | 999 | ); |
| 1000 | 1000 | |
| 1001 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
| 1001 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
| 1002 | 1002 | |
| 1003 | 1003 | // Allow overriding the price. |
| 1004 | - if ( false !== $args['price'] ) { |
|
| 1004 | + if (false !== $args['price']) { |
|
| 1005 | 1005 | $donation_amount = $args['price']; |
| 1006 | 1006 | } else { |
| 1007 | 1007 | |
| 1008 | 1008 | // Deal with variable pricing. |
| 1009 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
| 1010 | - $prices = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
| 1009 | + if (give_has_variable_prices($donation->ID)) { |
|
| 1010 | + $prices = give_get_meta($form_id, '_give_donation_levels', true); |
|
| 1011 | 1011 | $donation_amount = ''; |
| 1012 | 1012 | // Loop through prices. |
| 1013 | - foreach ( $prices as $price ) { |
|
| 1013 | + foreach ($prices as $price) { |
|
| 1014 | 1014 | // Find a match between price_id and level_id. |
| 1015 | 1015 | // First verify array keys exists THEN make the match. |
| 1016 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
| 1016 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
| 1017 | 1017 | && $args['price_id'] == $price['_give_id']['level_id'] |
| 1018 | 1018 | ) { |
| 1019 | 1019 | $donation_amount = $price['_give_amount']; |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | 1022 | // Fallback to the lowest price point. |
| 1023 | - if ( $donation_amount == '' ) { |
|
| 1024 | - $donation_amount = give_get_lowest_price_option( $donation->ID ); |
|
| 1025 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
| 1023 | + if ($donation_amount == '') { |
|
| 1024 | + $donation_amount = give_get_lowest_price_option($donation->ID); |
|
| 1025 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | } else { |
| 1028 | 1028 | // Simple form price. |
| 1029 | - $donation_amount = give_get_form_price( $donation->ID ); |
|
| 1029 | + $donation_amount = give_get_form_price($donation->ID); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | // Sanitizing the price here so we don't have a dozen calls later. |
| 1034 | - $donation_amount = give_maybe_sanitize_amount( $donation_amount ); |
|
| 1035 | - $total = round( $donation_amount, give_get_price_decimals( $this->ID ) ); |
|
| 1034 | + $donation_amount = give_maybe_sanitize_amount($donation_amount); |
|
| 1035 | + $total = round($donation_amount, give_get_price_decimals($this->ID)); |
|
| 1036 | 1036 | |
| 1037 | 1037 | // Add Options. |
| 1038 | 1038 | $default_options = array(); |
| 1039 | - if ( false !== $args['price_id'] ) { |
|
| 1039 | + if (false !== $args['price_id']) { |
|
| 1040 | 1040 | $default_options['price_id'] = (int) $args['price_id']; |
| 1041 | 1041 | } |
| 1042 | - $options = wp_parse_args( $options, $default_options ); |
|
| 1042 | + $options = wp_parse_args($options, $default_options); |
|
| 1043 | 1043 | |
| 1044 | 1044 | // Do not allow totals to go negative. |
| 1045 | - if ( $total < 0 ) { |
|
| 1045 | + if ($total < 0) { |
|
| 1046 | 1046 | $total = 0; |
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | $donation = array( |
| 1050 | 1050 | 'name' => $donation->post_title, |
| 1051 | 1051 | 'id' => $donation->ID, |
| 1052 | - 'price' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
| 1053 | - 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ), |
|
| 1052 | + 'price' => round($total, give_get_price_decimals($this->ID)), |
|
| 1053 | + 'subtotal' => round($total, give_get_price_decimals($this->ID)), |
|
| 1054 | 1054 | 'price_id' => $args['price_id'], |
| 1055 | 1055 | 'action' => 'add', |
| 1056 | 1056 | 'options' => $options, |
@@ -1058,7 +1058,7 @@ discard block |
||
| 1058 | 1058 | |
| 1059 | 1059 | $this->pending['donations'][] = $donation; |
| 1060 | 1060 | |
| 1061 | - $this->increase_subtotal( $total ); |
|
| 1061 | + $this->increase_subtotal($total); |
|
| 1062 | 1062 | |
| 1063 | 1063 | return true; |
| 1064 | 1064 | |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | * |
| 1076 | 1076 | * @return bool If the item was removed or not |
| 1077 | 1077 | */ |
| 1078 | - public function remove_donation( $form_id, $args = array() ) { |
|
| 1078 | + public function remove_donation($form_id, $args = array()) { |
|
| 1079 | 1079 | |
| 1080 | 1080 | // Set some defaults. |
| 1081 | 1081 | $defaults = array( |
@@ -1083,12 +1083,12 @@ discard block |
||
| 1083 | 1083 | 'price' => false, |
| 1084 | 1084 | 'price_id' => false, |
| 1085 | 1085 | ); |
| 1086 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1086 | + $args = wp_parse_args($args, $defaults); |
|
| 1087 | 1087 | |
| 1088 | - $form = new Give_Donate_Form( $form_id ); |
|
| 1088 | + $form = new Give_Donate_Form($form_id); |
|
| 1089 | 1089 | |
| 1090 | 1090 | // Bail if this post isn't a valid give donation form. |
| 1091 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
| 1091 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
| 1092 | 1092 | return false; |
| 1093 | 1093 | } |
| 1094 | 1094 | |
@@ -1101,7 +1101,7 @@ discard block |
||
| 1101 | 1101 | |
| 1102 | 1102 | $this->pending['donations'][] = $pending_args; |
| 1103 | 1103 | |
| 1104 | - $this->decrease_subtotal( $this->total ); |
|
| 1104 | + $this->decrease_subtotal($this->total); |
|
| 1105 | 1105 | |
| 1106 | 1106 | return true; |
| 1107 | 1107 | } |
@@ -1117,13 +1117,13 @@ discard block |
||
| 1117 | 1117 | * |
| 1118 | 1118 | * @return bool If the note was specified or not |
| 1119 | 1119 | */ |
| 1120 | - public function add_note( $note = false ) { |
|
| 1120 | + public function add_note($note = false) { |
|
| 1121 | 1121 | // Bail if no note specified. |
| 1122 | - if ( ! $note ) { |
|
| 1122 | + if ( ! $note) { |
|
| 1123 | 1123 | return false; |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | - give_insert_payment_note( $this->ID, $note ); |
|
| 1126 | + give_insert_payment_note($this->ID, $note); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | /** |
@@ -1136,8 +1136,8 @@ discard block |
||
| 1136 | 1136 | * |
| 1137 | 1137 | * @return void |
| 1138 | 1138 | */ |
| 1139 | - private function increase_subtotal( $amount = 0.00 ) { |
|
| 1140 | - $amount = (float) $amount; |
|
| 1139 | + private function increase_subtotal($amount = 0.00) { |
|
| 1140 | + $amount = (float) $amount; |
|
| 1141 | 1141 | $this->subtotal += $amount; |
| 1142 | 1142 | |
| 1143 | 1143 | $this->recalculate_total(); |
@@ -1153,11 +1153,11 @@ discard block |
||
| 1153 | 1153 | * |
| 1154 | 1154 | * @return void |
| 1155 | 1155 | */ |
| 1156 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
| 1157 | - $amount = (float) $amount; |
|
| 1156 | + private function decrease_subtotal($amount = 0.00) { |
|
| 1157 | + $amount = (float) $amount; |
|
| 1158 | 1158 | $this->subtotal -= $amount; |
| 1159 | 1159 | |
| 1160 | - if ( $this->subtotal < 0 ) { |
|
| 1160 | + if ($this->subtotal < 0) { |
|
| 1161 | 1161 | $this->subtotal = 0; |
| 1162 | 1162 | } |
| 1163 | 1163 | |
@@ -1186,24 +1186,24 @@ discard block |
||
| 1186 | 1186 | * |
| 1187 | 1187 | * @return bool $updated Returns if the status was successfully updated. |
| 1188 | 1188 | */ |
| 1189 | - public function update_status( $status = false ) { |
|
| 1189 | + public function update_status($status = false) { |
|
| 1190 | 1190 | |
| 1191 | 1191 | // standardize the 'complete(d)' status. |
| 1192 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
| 1192 | + if ($status == 'completed' || $status == 'complete') { |
|
| 1193 | 1193 | $status = 'publish'; |
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
| 1196 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
| 1197 | 1197 | |
| 1198 | - if ( $old_status === $status ) { |
|
| 1198 | + if ($old_status === $status) { |
|
| 1199 | 1199 | return false; // Don't permit status changes that aren't changes. |
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
| 1202 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
| 1203 | 1203 | |
| 1204 | 1204 | $updated = false; |
| 1205 | 1205 | |
| 1206 | - if ( $do_change ) { |
|
| 1206 | + if ($do_change) { |
|
| 1207 | 1207 | |
| 1208 | 1208 | /** |
| 1209 | 1209 | * Fires before changing payment status. |
@@ -1214,21 +1214,21 @@ discard block |
||
| 1214 | 1214 | * @param string $status The new status. |
| 1215 | 1215 | * @param string $old_status The old status. |
| 1216 | 1216 | */ |
| 1217 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
| 1217 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
| 1218 | 1218 | |
| 1219 | 1219 | $update_fields = array( |
| 1220 | 1220 | 'ID' => $this->ID, |
| 1221 | 1221 | 'post_status' => $status, |
| 1222 | - 'edit_date' => current_time( 'mysql' ), |
|
| 1222 | + 'edit_date' => current_time('mysql'), |
|
| 1223 | 1223 | ); |
| 1224 | 1224 | |
| 1225 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
| 1225 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
| 1226 | 1226 | |
| 1227 | 1227 | $all_payment_statuses = give_get_payment_statuses(); |
| 1228 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
| 1228 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
| 1229 | 1229 | |
| 1230 | 1230 | // Process any specific status functions. |
| 1231 | - switch ( $status ) { |
|
| 1231 | + switch ($status) { |
|
| 1232 | 1232 | case 'refunded': |
| 1233 | 1233 | $this->process_refund(); |
| 1234 | 1234 | break; |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | * @param string $status The new status. |
| 1256 | 1256 | * @param string $old_status The old status. |
| 1257 | 1257 | */ |
| 1258 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
| 1258 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
| 1259 | 1259 | |
| 1260 | 1260 | }// End if(). |
| 1261 | 1261 | |
@@ -1290,41 +1290,41 @@ discard block |
||
| 1290 | 1290 | * |
| 1291 | 1291 | * @return mixed The value from the post meta |
| 1292 | 1292 | */ |
| 1293 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
| 1293 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
| 1294 | 1294 | |
| 1295 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
| 1295 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
| 1296 | 1296 | |
| 1297 | - if ( $meta_key === '_give_payment_meta' ) { |
|
| 1297 | + if ($meta_key === '_give_payment_meta') { |
|
| 1298 | 1298 | $meta = (array) $meta; |
| 1299 | 1299 | |
| 1300 | - if ( empty( $meta['key'] ) ) { |
|
| 1300 | + if (empty($meta['key'])) { |
|
| 1301 | 1301 | $meta['key'] = $this->setup_payment_key(); |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | - if ( empty( $meta['form_title'] ) ) { |
|
| 1304 | + if (empty($meta['form_title'])) { |
|
| 1305 | 1305 | $meta['form_title'] = $this->setup_form_title(); |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - if ( empty( $meta['email'] ) ) { |
|
| 1308 | + if (empty($meta['email'])) { |
|
| 1309 | 1309 | $meta['email'] = $this->setup_email(); |
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | - if ( empty( $meta['date'] ) ) { |
|
| 1313 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
| 1312 | + if (empty($meta['date'])) { |
|
| 1313 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
| 1314 | 1314 | } |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
| 1317 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
| 1318 | 1318 | |
| 1319 | 1319 | // Security check. |
| 1320 | - if ( is_serialized( $meta ) ) { |
|
| 1321 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches ); |
|
| 1322 | - if ( ! empty( $matches ) ) { |
|
| 1320 | + if (is_serialized($meta)) { |
|
| 1321 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches); |
|
| 1322 | + if ( ! empty($matches)) { |
|
| 1323 | 1323 | $meta = array(); |
| 1324 | 1324 | } |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
| 1327 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | /** |
@@ -1339,23 +1339,23 @@ discard block |
||
| 1339 | 1339 | * |
| 1340 | 1340 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
| 1341 | 1341 | */ |
| 1342 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 1343 | - if ( empty( $meta_key ) ) { |
|
| 1342 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 1343 | + if (empty($meta_key)) { |
|
| 1344 | 1344 | return false; |
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
| 1347 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
| 1348 | 1348 | |
| 1349 | 1349 | $current_meta = $this->get_meta(); |
| 1350 | - $current_meta[ $meta_key ] = $meta_value; |
|
| 1350 | + $current_meta[$meta_key] = $meta_value; |
|
| 1351 | 1351 | |
| 1352 | 1352 | $meta_key = '_give_payment_meta'; |
| 1353 | 1353 | $meta_value = $current_meta; |
| 1354 | 1354 | |
| 1355 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
| 1355 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
| 1356 | 1356 | |
| 1357 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1358 | - give_update_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
| 1357 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1358 | + give_update_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
| 1359 | 1359 | |
| 1360 | 1360 | $current_meta = $this->get_meta(); |
| 1361 | 1361 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1365,9 +1365,9 @@ discard block |
||
| 1365 | 1365 | |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
| 1368 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
| 1369 | 1369 | |
| 1370 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 1370 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | /** |
@@ -1382,14 +1382,14 @@ discard block |
||
| 1382 | 1382 | $process_refund = true; |
| 1383 | 1383 | |
| 1384 | 1384 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1385 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
| 1385 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
| 1386 | 1386 | $process_refund = false; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1390 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
| 1390 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
| 1391 | 1391 | |
| 1392 | - if ( false === $process_refund ) { |
|
| 1392 | + if (false === $process_refund) { |
|
| 1393 | 1393 | return; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
@@ -1400,13 +1400,13 @@ discard block |
||
| 1400 | 1400 | * |
| 1401 | 1401 | * @param Give_Payment $this Payment object. |
| 1402 | 1402 | */ |
| 1403 | - do_action( 'give_pre_refund_payment', $this ); |
|
| 1403 | + do_action('give_pre_refund_payment', $this); |
|
| 1404 | 1404 | |
| 1405 | - $decrease_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
| 1406 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
| 1407 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
| 1405 | + $decrease_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
| 1406 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
| 1407 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
| 1408 | 1408 | |
| 1409 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
| 1409 | + $this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
| 1410 | 1410 | $this->delete_sales_logs(); |
| 1411 | 1411 | |
| 1412 | 1412 | // @todo: Refresh only range related stat cache |
@@ -1419,7 +1419,7 @@ discard block |
||
| 1419 | 1419 | * |
| 1420 | 1420 | * @param Give_Payment $this Payment object. |
| 1421 | 1421 | */ |
| 1422 | - do_action( 'give_post_refund_payment', $this ); |
|
| 1422 | + do_action('give_post_refund_payment', $this); |
|
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | /** |
@@ -1446,26 +1446,26 @@ discard block |
||
| 1446 | 1446 | $process_pending = true; |
| 1447 | 1447 | |
| 1448 | 1448 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1449 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
| 1449 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
| 1450 | 1450 | $process_pending = false; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1454 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
| 1454 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
| 1455 | 1455 | |
| 1456 | - if ( false === $process_pending ) { |
|
| 1456 | + if (false === $process_pending) { |
|
| 1457 | 1457 | return; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_pending', true, $this ); |
|
| 1461 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_pending', true, $this ); |
|
| 1462 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this ); |
|
| 1460 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_pending', true, $this); |
|
| 1461 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_pending', true, $this); |
|
| 1462 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this); |
|
| 1463 | 1463 | |
| 1464 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
| 1464 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
| 1465 | 1465 | $this->delete_sales_logs(); |
| 1466 | 1466 | |
| 1467 | 1467 | $this->completed_date = false; |
| 1468 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1468 | + $this->update_meta('_give_completed_date', ''); |
|
| 1469 | 1469 | |
| 1470 | 1470 | // @todo: Refresh only range related stat cache |
| 1471 | 1471 | give_delete_donation_stats(); |
@@ -1483,26 +1483,26 @@ discard block |
||
| 1483 | 1483 | $process_cancelled = true; |
| 1484 | 1484 | |
| 1485 | 1485 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
| 1486 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
| 1486 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
| 1487 | 1487 | $process_cancelled = false; |
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1491 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
| 1491 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
| 1492 | 1492 | |
| 1493 | - if ( false === $process_cancelled ) { |
|
| 1493 | + if (false === $process_cancelled) { |
|
| 1494 | 1494 | return; |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this ); |
|
| 1498 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this ); |
|
| 1499 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this ); |
|
| 1497 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_cancelled', true, $this); |
|
| 1498 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_cancelled', true, $this); |
|
| 1499 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this); |
|
| 1500 | 1500 | |
| 1501 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
| 1501 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
| 1502 | 1502 | $this->delete_sales_logs(); |
| 1503 | 1503 | |
| 1504 | 1504 | $this->completed_date = false; |
| 1505 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1505 | + $this->update_meta('_give_completed_date', ''); |
|
| 1506 | 1506 | |
| 1507 | 1507 | // @todo: Refresh only range related stat cache |
| 1508 | 1508 | give_delete_donation_stats(); |
@@ -1518,26 +1518,26 @@ discard block |
||
| 1518 | 1518 | $process_revoked = true; |
| 1519 | 1519 | |
| 1520 | 1520 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
| 1521 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
| 1521 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
| 1522 | 1522 | $process_revoked = false; |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
| 1526 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
| 1526 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
| 1527 | 1527 | |
| 1528 | - if ( false === $process_revoked ) { |
|
| 1528 | + if (false === $process_revoked) { |
|
| 1529 | 1529 | return; |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_revoked', true, $this ); |
|
| 1533 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this ); |
|
| 1534 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this ); |
|
| 1532 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_revoked', true, $this); |
|
| 1533 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_revoked', true, $this); |
|
| 1534 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this); |
|
| 1535 | 1535 | |
| 1536 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
| 1536 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
| 1537 | 1537 | $this->delete_sales_logs(); |
| 1538 | 1538 | |
| 1539 | 1539 | $this->completed_date = false; |
| 1540 | - $this->update_meta( '_give_completed_date', '' ); |
|
| 1540 | + $this->update_meta('_give_completed_date', ''); |
|
| 1541 | 1541 | |
| 1542 | 1542 | // @todo: Refresh only range related stat cache |
| 1543 | 1543 | give_delete_donation_stats(); |
@@ -1555,25 +1555,25 @@ discard block |
||
| 1555 | 1555 | * |
| 1556 | 1556 | * @return void |
| 1557 | 1557 | */ |
| 1558 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
| 1558 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
| 1559 | 1559 | |
| 1560 | - give_undo_donation( $this->ID ); |
|
| 1560 | + give_undo_donation($this->ID); |
|
| 1561 | 1561 | |
| 1562 | 1562 | // Decrease store earnings. |
| 1563 | - if ( true === $alter_store_earnings ) { |
|
| 1564 | - give_decrease_total_earnings( $this->total ); |
|
| 1563 | + if (true === $alter_store_earnings) { |
|
| 1564 | + give_decrease_total_earnings($this->total); |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | 1567 | // Decrement the stats for the donor. |
| 1568 | - if ( ! empty( $this->customer_id ) ) { |
|
| 1568 | + if ( ! empty($this->customer_id)) { |
|
| 1569 | 1569 | |
| 1570 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 1570 | + $donor = new Give_Donor($this->customer_id); |
|
| 1571 | 1571 | |
| 1572 | - if ( true === $alter_customer_value ) { |
|
| 1573 | - $donor->decrease_value( $this->total ); |
|
| 1572 | + if (true === $alter_customer_value) { |
|
| 1573 | + $donor->decrease_value($this->total); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | - if ( true === $alter_customer_purchase_count ) { |
|
| 1576 | + if (true === $alter_customer_purchase_count) { |
|
| 1577 | 1577 | $donor->decrease_donation_count(); |
| 1578 | 1578 | } |
| 1579 | 1579 | } |
@@ -1622,13 +1622,13 @@ discard block |
||
| 1622 | 1622 | * @return string The date the payment was completed |
| 1623 | 1623 | */ |
| 1624 | 1624 | private function setup_completed_date() { |
| 1625 | - $payment = get_post( $this->ID ); |
|
| 1625 | + $payment = get_post($this->ID); |
|
| 1626 | 1626 | |
| 1627 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
| 1627 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
| 1628 | 1628 | return false; // This payment was never completed. |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
| 1631 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
| 1632 | 1632 | |
| 1633 | 1633 | return $date; |
| 1634 | 1634 | } |
@@ -1642,7 +1642,7 @@ discard block |
||
| 1642 | 1642 | * @return string The payment mode |
| 1643 | 1643 | */ |
| 1644 | 1644 | private function setup_mode() { |
| 1645 | - return $this->get_meta( '_give_payment_mode' ); |
|
| 1645 | + return $this->get_meta('_give_payment_mode'); |
|
| 1646 | 1646 | } |
| 1647 | 1647 | |
| 1648 | 1648 | /** |
@@ -1654,7 +1654,7 @@ discard block |
||
| 1654 | 1654 | * @return bool The payment import |
| 1655 | 1655 | */ |
| 1656 | 1656 | private function setup_import() { |
| 1657 | - return (bool) $this->get_meta( '_give_payment_import' ); |
|
| 1657 | + return (bool) $this->get_meta('_give_payment_import'); |
|
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | 1660 | /** |
@@ -1666,18 +1666,18 @@ discard block |
||
| 1666 | 1666 | * @return float The payment total |
| 1667 | 1667 | */ |
| 1668 | 1668 | private function setup_total() { |
| 1669 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
| 1669 | + $amount = $this->get_meta('_give_payment_total', true); |
|
| 1670 | 1670 | |
| 1671 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
| 1672 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
| 1673 | - $meta = maybe_unserialize( $meta ); |
|
| 1671 | + if (empty($amount) && '0.00' != $amount) { |
|
| 1672 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
| 1673 | + $meta = maybe_unserialize($meta); |
|
| 1674 | 1674 | |
| 1675 | - if ( isset( $meta['amount'] ) ) { |
|
| 1675 | + if (isset($meta['amount'])) { |
|
| 1676 | 1676 | $amount = $meta['amount']; |
| 1677 | 1677 | } |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | - return round( (float) $amount, give_get_price_decimals( $this->ID ) ); |
|
| 1680 | + return round((float) $amount, give_get_price_decimals($this->ID)); |
|
| 1681 | 1681 | } |
| 1682 | 1682 | |
| 1683 | 1683 | /** |
@@ -1703,7 +1703,7 @@ discard block |
||
| 1703 | 1703 | * @return string The currency for the payment |
| 1704 | 1704 | */ |
| 1705 | 1705 | private function setup_currency() { |
| 1706 | - $currency = ! empty( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency( $this->form_id, $this ), $this ); |
|
| 1706 | + $currency = ! empty($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency($this->form_id, $this), $this); |
|
| 1707 | 1707 | |
| 1708 | 1708 | return $currency; |
| 1709 | 1709 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | * @return string The gateway |
| 1718 | 1718 | */ |
| 1719 | 1719 | private function setup_gateway() { |
| 1720 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
| 1720 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
| 1721 | 1721 | |
| 1722 | 1722 | return $gateway; |
| 1723 | 1723 | } |
@@ -1731,11 +1731,11 @@ discard block |
||
| 1731 | 1731 | * @return string The donation ID |
| 1732 | 1732 | */ |
| 1733 | 1733 | private function setup_transaction_id() { |
| 1734 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
| 1734 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
| 1735 | 1735 | |
| 1736 | - if ( empty( $transaction_id ) ) { |
|
| 1736 | + if (empty($transaction_id)) { |
|
| 1737 | 1737 | $gateway = $this->gateway; |
| 1738 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
| 1738 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | return $transaction_id; |
@@ -1750,7 +1750,7 @@ discard block |
||
| 1750 | 1750 | * @return string The IP address for the payment |
| 1751 | 1751 | */ |
| 1752 | 1752 | private function setup_ip() { |
| 1753 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
| 1753 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
| 1754 | 1754 | |
| 1755 | 1755 | return $ip; |
| 1756 | 1756 | } |
@@ -1764,7 +1764,7 @@ discard block |
||
| 1764 | 1764 | * @return int The Donor ID. |
| 1765 | 1765 | */ |
| 1766 | 1766 | private function setup_donor_id() { |
| 1767 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
| 1767 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
| 1768 | 1768 | |
| 1769 | 1769 | return $customer_id; |
| 1770 | 1770 | } |
@@ -1778,7 +1778,7 @@ discard block |
||
| 1778 | 1778 | * @return int The User ID |
| 1779 | 1779 | */ |
| 1780 | 1780 | private function setup_user_id() { |
| 1781 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
| 1781 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
| 1782 | 1782 | |
| 1783 | 1783 | return $user_id; |
| 1784 | 1784 | } |
@@ -1792,10 +1792,10 @@ discard block |
||
| 1792 | 1792 | * @return string The email address for the payment. |
| 1793 | 1793 | */ |
| 1794 | 1794 | private function setup_email() { |
| 1795 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
| 1795 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
| 1796 | 1796 | |
| 1797 | - if ( empty( $email ) && $this->customer_id ) { |
|
| 1798 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
| 1797 | + if (empty($email) && $this->customer_id) { |
|
| 1798 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | 1801 | return $email; |
@@ -1815,23 +1815,23 @@ discard block |
||
| 1815 | 1815 | 'last_name' => $this->last_name, |
| 1816 | 1816 | ); |
| 1817 | 1817 | |
| 1818 | - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array(); |
|
| 1818 | + $user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array(); |
|
| 1819 | 1819 | |
| 1820 | - if ( is_serialized( $user_info ) ) { |
|
| 1821 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches ); |
|
| 1822 | - if ( ! empty( $matches ) ) { |
|
| 1820 | + if (is_serialized($user_info)) { |
|
| 1821 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches); |
|
| 1822 | + if ( ! empty($matches)) { |
|
| 1823 | 1823 | $user_info = array(); |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
| 1827 | + $user_info = wp_parse_args($user_info, $defaults); |
|
| 1828 | 1828 | |
| 1829 | - if ( empty( $user_info ) ) { |
|
| 1829 | + if (empty($user_info)) { |
|
| 1830 | 1830 | // Get the donor, but only if it's been created. |
| 1831 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 1831 | + $donor = new Give_Donor($this->customer_id); |
|
| 1832 | 1832 | |
| 1833 | - if ( $donor->id > 0 ) { |
|
| 1834 | - $name = explode( ' ', $donor->name, 2 ); |
|
| 1833 | + if ($donor->id > 0) { |
|
| 1834 | + $name = explode(' ', $donor->name, 2); |
|
| 1835 | 1835 | $user_info = array( |
| 1836 | 1836 | 'first_name' => $name[0], |
| 1837 | 1837 | 'last_name' => $name[1], |
@@ -1841,29 +1841,29 @@ discard block |
||
| 1841 | 1841 | } |
| 1842 | 1842 | } else { |
| 1843 | 1843 | // Get the donor, but only if it's been created. |
| 1844 | - $donor = new Give_Donor( $this->customer_id ); |
|
| 1845 | - if ( $donor->id > 0 ) { |
|
| 1846 | - foreach ( $user_info as $key => $value ) { |
|
| 1847 | - if ( ! empty( $value ) ) { |
|
| 1844 | + $donor = new Give_Donor($this->customer_id); |
|
| 1845 | + if ($donor->id > 0) { |
|
| 1846 | + foreach ($user_info as $key => $value) { |
|
| 1847 | + if ( ! empty($value)) { |
|
| 1848 | 1848 | continue; |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | - switch ( $key ) { |
|
| 1851 | + switch ($key) { |
|
| 1852 | 1852 | case 'first_name': |
| 1853 | - $name = explode( ' ', $donor->name, 2 ); |
|
| 1853 | + $name = explode(' ', $donor->name, 2); |
|
| 1854 | 1854 | |
| 1855 | - $user_info[ $key ] = $name[0]; |
|
| 1855 | + $user_info[$key] = $name[0]; |
|
| 1856 | 1856 | break; |
| 1857 | 1857 | |
| 1858 | 1858 | case 'last_name': |
| 1859 | - $name = explode( ' ', $donor->name, 2 ); |
|
| 1860 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
| 1859 | + $name = explode(' ', $donor->name, 2); |
|
| 1860 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
| 1861 | 1861 | |
| 1862 | - $user_info[ $key ] = $last_name; |
|
| 1862 | + $user_info[$key] = $last_name; |
|
| 1863 | 1863 | break; |
| 1864 | 1864 | |
| 1865 | 1865 | case 'email': |
| 1866 | - $user_info[ $key ] = $donor->email; |
|
| 1866 | + $user_info[$key] = $donor->email; |
|
| 1867 | 1867 | break; |
| 1868 | 1868 | } |
| 1869 | 1869 | } |
@@ -1884,7 +1884,7 @@ discard block |
||
| 1884 | 1884 | */ |
| 1885 | 1885 | private function setup_address() { |
| 1886 | 1886 | |
| 1887 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
| 1887 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
| 1888 | 1888 | 'line1' => '', |
| 1889 | 1889 | 'line2' => '', |
| 1890 | 1890 | 'city' => '', |
@@ -1906,7 +1906,7 @@ discard block |
||
| 1906 | 1906 | */ |
| 1907 | 1907 | private function setup_form_title() { |
| 1908 | 1908 | |
| 1909 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
| 1909 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
| 1910 | 1910 | |
| 1911 | 1911 | return $form_id; |
| 1912 | 1912 | } |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | */ |
| 1922 | 1922 | private function setup_form_id() { |
| 1923 | 1923 | |
| 1924 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
| 1924 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
| 1925 | 1925 | |
| 1926 | 1926 | return $form_id; |
| 1927 | 1927 | } |
@@ -1935,7 +1935,7 @@ discard block |
||
| 1935 | 1935 | * @return int The Form Price ID. |
| 1936 | 1936 | */ |
| 1937 | 1937 | private function setup_price_id() { |
| 1938 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
| 1938 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
| 1939 | 1939 | |
| 1940 | 1940 | return $price_id; |
| 1941 | 1941 | } |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | * @return string The Payment Key. |
| 1950 | 1950 | */ |
| 1951 | 1951 | private function setup_payment_key() { |
| 1952 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
| 1952 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
| 1953 | 1953 | |
| 1954 | 1954 | return $key; |
| 1955 | 1955 | } |
@@ -1965,11 +1965,11 @@ discard block |
||
| 1965 | 1965 | private function setup_payment_number() { |
| 1966 | 1966 | $number = $this->ID; |
| 1967 | 1967 | |
| 1968 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 1968 | + if (give_get_option('enable_sequential')) { |
|
| 1969 | 1969 | |
| 1970 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
| 1970 | + $number = $this->get_meta('_give_payment_number', true); |
|
| 1971 | 1971 | |
| 1972 | - if ( ! $number ) { |
|
| 1972 | + if ( ! $number) { |
|
| 1973 | 1973 | |
| 1974 | 1974 | $number = $this->ID; |
| 1975 | 1975 | |
@@ -1987,7 +1987,7 @@ discard block |
||
| 1987 | 1987 | * @return array The payment object as an array. |
| 1988 | 1988 | */ |
| 1989 | 1989 | public function array_convert() { |
| 1990 | - return get_object_vars( $this ); |
|
| 1990 | + return get_object_vars($this); |
|
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | 1993 | |
@@ -2000,7 +2000,7 @@ discard block |
||
| 2000 | 2000 | * @return bool |
| 2001 | 2001 | */ |
| 2002 | 2002 | public function is_completed() { |
| 2003 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
| 2003 | + return ('publish' === $this->status && $this->completed_date); |
|
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | 2006 | /** |
@@ -2012,7 +2012,7 @@ discard block |
||
| 2012 | 2012 | * @return string Date payment was completed. |
| 2013 | 2013 | */ |
| 2014 | 2014 | private function get_completed_date() { |
| 2015 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
| 2015 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | /** |
@@ -2024,7 +2024,7 @@ discard block |
||
| 2024 | 2024 | * @return float Payment subtotal. |
| 2025 | 2025 | */ |
| 2026 | 2026 | private function get_subtotal() { |
| 2027 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
| 2027 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | /** |
@@ -2036,7 +2036,7 @@ discard block |
||
| 2036 | 2036 | * @return string Payment currency code. |
| 2037 | 2037 | */ |
| 2038 | 2038 | private function get_currency() { |
| 2039 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
| 2039 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | /** |
@@ -2048,7 +2048,7 @@ discard block |
||
| 2048 | 2048 | * @return string Gateway used. |
| 2049 | 2049 | */ |
| 2050 | 2050 | private function get_gateway() { |
| 2051 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
| 2051 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | 2054 | /** |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | * @return string Donation ID from merchant processor. |
| 2061 | 2061 | */ |
| 2062 | 2062 | private function get_transaction_id() { |
| 2063 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
| 2063 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | /** |
@@ -2072,7 +2072,7 @@ discard block |
||
| 2072 | 2072 | * @return string Payment IP address |
| 2073 | 2073 | */ |
| 2074 | 2074 | private function get_ip() { |
| 2075 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
| 2075 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | /** |
@@ -2084,7 +2084,7 @@ discard block |
||
| 2084 | 2084 | * @return int Payment donor ID. |
| 2085 | 2085 | */ |
| 2086 | 2086 | private function get_donor_id() { |
| 2087 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
| 2087 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
| 2088 | 2088 | } |
| 2089 | 2089 | |
| 2090 | 2090 | /** |
@@ -2096,7 +2096,7 @@ discard block |
||
| 2096 | 2096 | * @return int Payment user ID. |
| 2097 | 2097 | */ |
| 2098 | 2098 | private function get_user_id() { |
| 2099 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
| 2099 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
| 2100 | 2100 | } |
| 2101 | 2101 | |
| 2102 | 2102 | /** |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | * @return string Payment donor email. |
| 2109 | 2109 | */ |
| 2110 | 2110 | private function get_email() { |
| 2111 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
| 2111 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
| 2112 | 2112 | } |
| 2113 | 2113 | |
| 2114 | 2114 | /** |
@@ -2120,7 +2120,7 @@ discard block |
||
| 2120 | 2120 | * @return array Payment user info. |
| 2121 | 2121 | */ |
| 2122 | 2122 | private function get_user_info() { |
| 2123 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
| 2123 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | 2126 | /** |
@@ -2132,7 +2132,7 @@ discard block |
||
| 2132 | 2132 | * @return array Payment billing address. |
| 2133 | 2133 | */ |
| 2134 | 2134 | private function get_address() { |
| 2135 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
| 2135 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | 2138 | /** |
@@ -2144,7 +2144,7 @@ discard block |
||
| 2144 | 2144 | * @return string Payment key. |
| 2145 | 2145 | */ |
| 2146 | 2146 | private function get_key() { |
| 2147 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
| 2147 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | 2150 | /** |
@@ -2156,7 +2156,7 @@ discard block |
||
| 2156 | 2156 | * @return string Payment form id |
| 2157 | 2157 | */ |
| 2158 | 2158 | private function get_form_id() { |
| 2159 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
| 2159 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
| 2160 | 2160 | } |
| 2161 | 2161 | |
| 2162 | 2162 | /** |
@@ -2168,7 +2168,7 @@ discard block |
||
| 2168 | 2168 | * @return int|string Payment number |
| 2169 | 2169 | */ |
| 2170 | 2170 | private function get_number() { |
| 2171 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
| 2171 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
| 2172 | 2172 | } |
| 2173 | 2173 | |
| 2174 | 2174 | } |
@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @return static |
| 52 | 52 | */ |
| 53 | 53 | public static function get_instance() { |
| 54 | - if ( null === static::$instance ) { |
|
| 54 | + if (null === static::$instance) { |
|
| 55 | 55 | self::$instance = new static(); |
| 56 | 56 | self::$instance->setup(); |
| 57 | 57 | } |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | * @since 1.8.13 |
| 67 | 67 | */ |
| 68 | 68 | private function setup() { |
| 69 | - add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) ); |
|
| 70 | - add_action( 'wp', array( self::$instance, '__schedule_events' ) ); |
|
| 69 | + add_filter('cron_schedules', array(self::$instance, '__add_schedules')); |
|
| 70 | + add_action('wp', array(self::$instance, '__schedule_events')); |
|
| 71 | 71 | |
| 72 | 72 | // Load async event only when cron is running. |
| 73 | - if( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 74 | - add_action( 'init', array( self::$instance, '__load_async_events' ) ); |
|
| 73 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
| 74 | + add_action('init', array(self::$instance, '__load_async_events')); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,23 +82,23 @@ discard block |
||
| 82 | 82 | * @since 1.8.13 |
| 83 | 83 | */ |
| 84 | 84 | public function __load_async_events() { |
| 85 | - $async_events = get_option( 'give_async_events', array() ); |
|
| 85 | + $async_events = get_option('give_async_events', array()); |
|
| 86 | 86 | |
| 87 | 87 | // Bailout. |
| 88 | - if ( empty( $async_events ) ) { |
|
| 88 | + if (empty($async_events)) { |
|
| 89 | 89 | return; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - foreach ( $async_events as $index => $event ) { |
|
| 92 | + foreach ($async_events as $index => $event) { |
|
| 93 | 93 | // Set cron name. |
| 94 | 94 | $cron_name = "give_async_scheduled_events_{$index}"; |
| 95 | 95 | |
| 96 | 96 | // Setup cron. |
| 97 | - wp_schedule_single_event( current_time( 'timestamp', 1 ), $cron_name, $event['params'] ); |
|
| 97 | + wp_schedule_single_event(current_time('timestamp', 1), $cron_name, $event['params']); |
|
| 98 | 98 | |
| 99 | 99 | // Add cron action. |
| 100 | - add_action( $cron_name, $event['callback'], 10, count( $event['params'] ) ); |
|
| 101 | - add_action( $cron_name, array( $this, '__delete_async_events' ), 9999, 0 ); |
|
| 100 | + add_action($cron_name, $event['callback'], 10, count($event['params'])); |
|
| 101 | + add_action($cron_name, array($this, '__delete_async_events'), 9999, 0); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | * @since 1.8.13 |
| 109 | 109 | */ |
| 110 | 110 | public function __delete_async_events() { |
| 111 | - $async_events = get_option( 'give_async_events', array() ); |
|
| 112 | - $cron_name_parts = explode( '_', current_action() ); |
|
| 113 | - $cron_id = end( $cron_name_parts ); |
|
| 111 | + $async_events = get_option('give_async_events', array()); |
|
| 112 | + $cron_name_parts = explode('_', current_action()); |
|
| 113 | + $cron_id = end($cron_name_parts); |
|
| 114 | 114 | |
| 115 | - if ( ! empty( $async_events[ $cron_id ] ) ) { |
|
| 116 | - unset( $async_events[ $cron_id ] ); |
|
| 117 | - update_option( 'give_async_events', $async_events ); |
|
| 115 | + if ( ! empty($async_events[$cron_id])) { |
|
| 116 | + unset($async_events[$cron_id]); |
|
| 117 | + update_option('give_async_events', $async_events); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | * |
| 129 | 129 | * @return array An array of non-default cron schedules. |
| 130 | 130 | */ |
| 131 | - public function __add_schedules( $schedules = array() ) { |
|
| 131 | + public function __add_schedules($schedules = array()) { |
|
| 132 | 132 | // Adds once weekly to the existing schedules. |
| 133 | 133 | $schedules['weekly'] = array( |
| 134 | 134 | 'interval' => 604800, |
| 135 | - 'display' => __( 'Once Weekly', 'give' ), |
|
| 135 | + 'display' => __('Once Weekly', 'give'), |
|
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | 138 | return $schedules; |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @return void |
| 161 | 161 | */ |
| 162 | 162 | private function weekly_events() { |
| 163 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
| 164 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
| 163 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
| 164 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * @return void |
| 175 | 175 | */ |
| 176 | 176 | private function daily_events() { |
| 177 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
| 178 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
| 177 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
| 178 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return string |
| 191 | 191 | */ |
| 192 | - public static function get_cron_action( $type = 'weekly' ) { |
|
| 193 | - switch ( $type ) { |
|
| 192 | + public static function get_cron_action($type = 'weekly') { |
|
| 193 | + switch ($type) { |
|
| 194 | 194 | case 'daily': |
| 195 | 195 | $cron_action = 'give_daily_scheduled_events'; |
| 196 | 196 | break; |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | * @param $action |
| 213 | 213 | * @param string $type |
| 214 | 214 | */ |
| 215 | - private static function add_event( $action, $type = 'weekly' ) { |
|
| 216 | - $cron_event = self::get_cron_action( $type ); |
|
| 217 | - add_action( $cron_event, $action ); |
|
| 215 | + private static function add_event($action, $type = 'weekly') { |
|
| 216 | + $cron_event = self::get_cron_action($type); |
|
| 217 | + add_action($cron_event, $action); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @param $action |
| 227 | 227 | */ |
| 228 | - public static function add_weekly_event( $action ) { |
|
| 229 | - self::add_event( $action, 'weekly' ); |
|
| 228 | + public static function add_weekly_event($action) { |
|
| 229 | + self::add_event($action, 'weekly'); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @param $action |
| 239 | 239 | */ |
| 240 | - public static function add_daily_event( $action ) { |
|
| 241 | - self::add_event( $action, 'daily' ); |
|
| 240 | + public static function add_daily_event($action) { |
|
| 241 | + self::add_event($action, 'daily'); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | * @param string $action |
| 252 | 252 | * @param array $args |
| 253 | 253 | */ |
| 254 | - public static function add_async_event( $action, $args = array() ) { |
|
| 254 | + public static function add_async_event($action, $args = array()) { |
|
| 255 | 255 | |
| 256 | 256 | // Cache async events. |
| 257 | - $async_events = get_option( 'give_async_events', array() ); |
|
| 258 | - $async_events[ uniqid() ] = array( |
|
| 257 | + $async_events = get_option('give_async_events', array()); |
|
| 258 | + $async_events[uniqid()] = array( |
|
| 259 | 259 | 'callback' => $action, |
| 260 | 260 | 'params' => $args, |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | 263 | |
| 264 | - update_option( 'give_async_events', $async_events ); |
|
| 264 | + update_option('give_async_events', $async_events); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |