Completed
Pull Request — master (#801)
by
unknown
18:24
created
includes/admin/payments/payments-history.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) exit;
13
+if ( ! defined('ABSPATH')) exit;
14 14
 
15 15
 /**
16 16
  * Payment History Page
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 function give_payment_history_page() {
25 25
 	global $give_options;
26 26
 
27
-	$give_payment = get_post_type_object( 'give_payment' );
27
+	$give_payment = get_post_type_object('give_payment');
28 28
 
29
-	if ( isset( $_GET['view'] ) && 'view-order-details' == $_GET['view'] ) {
30
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-order-details.php';
29
+	if (isset($_GET['view']) && 'view-order-details' == $_GET['view']) {
30
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-order-details.php';
31 31
 	} else {
32
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
32
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
33 33
 		$payments_table = new Give_Payment_History_Table();
34 34
 		$payments_table->prepare_items();
35 35
 	?>
36 36
 	<div class="wrap">
37 37
 		<h2><?php echo $give_payment->labels->menu_name ?></h2>
38
-		<?php do_action( 'give_payments_page_top' ); ?>
39
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
38
+		<?php do_action('give_payments_page_top'); ?>
39
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
40 40
 			<input type="hidden" name="post_type" value="give_forms" />
41 41
 			<input type="hidden" name="page" value="give-payment-history" />
42 42
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			
47 47
 			<?php $payments_table->display() ?>
48 48
 		</form>
49
-		<?php do_action( 'give_payments_page_bottom' ); ?>
49
+		<?php do_action('give_payments_page_bottom'); ?>
50 50
 	</div>
51 51
 <?php
52 52
 	}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
  * @param $title
62 62
  * @return string
63 63
  */
64
-function give_view_order_details_title( $admin_title, $title ) {
64
+function give_view_order_details_title($admin_title, $title) {
65 65
 
66
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base )
66
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base)
67 67
 		return $admin_title;
68 68
 
69
-	if( ! isset( $_GET['give-action'] ) )
69
+	if ( ! isset($_GET['give-action']))
70 70
 		return $admin_title;
71 71
 
72
-	switch( $_GET['give-action'] ) :
72
+	switch ($_GET['give-action']) :
73 73
 
74 74
 		case 'view-order-details' :
75
-			$title = __( 'View Donation Details', 'give' ) . ' - ' . $admin_title;
75
+			$title = __('View Donation Details', 'give').' - '.$admin_title;
76 76
 			break;
77 77
 		case 'edit-payment' :
78
-			$title = __( 'Edit Payment', 'give' ) . ' - ' . $admin_title;
78
+			$title = __('Edit Payment', 'give').' - '.$admin_title;
79 79
 			break;
80 80
 		default:
81 81
 			$title = $admin_title;
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	return $title;
86 86
 }
87
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
87
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
88 88
 
89 89
 /**
90 90
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
  * @param $context
97 97
  * @return string
98 98
  */
99
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
99
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
100 100
 
101
-	$post = get_post( $post_id );
102
-	if( ! $post )
101
+	$post = get_post($post_id);
102
+	if ( ! $post)
103 103
 		return $url;
104 104
 
105
-	if( 'give_payment' != $post->post_type )
105
+	if ('give_payment' != $post->post_type)
106 106
 		return $url;
107 107
 
108
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $post_id );
108
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$post_id);
109 109
 
110 110
 	return $url;
111 111
 }
112
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
112
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.
includes/admin/reporting/class-give-graph.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @since 1.0
80 80
 	 */
81
-	public function __construct( $_data ) {
81
+	public function __construct($_data) {
82 82
 
83 83
 		$this->data = $_data;
84 84
 
85 85
 		// Generate unique ID
86
-		$this->id = md5( rand() );
86
+		$this->id = md5(rand());
87 87
 
88 88
 		// Setup default options;
89
-		$this->options = apply_filters( 'give_graph_args', array(
89
+		$this->options = apply_filters('give_graph_args', array(
90 90
 			'y_mode'          => null,
91 91
 			'x_mode'          => null,
92 92
 			'y_decimals'      => 0,
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			'bars'            => true,
104 104
 			'lines'           => false,
105 105
 			'points'          => true
106
-		) );
106
+		));
107 107
 
108 108
 	}
109 109
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @since 1.0
117 117
 	 */
118
-	public function set( $key, $value ) {
119
-		$this->options[ $key ] = $value;
118
+	public function set($key, $value) {
119
+		$this->options[$key] = $value;
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.0
128 128
 	 */
129
-	public function get( $key ) {
130
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
129
+	public function get($key) {
130
+		return isset($this->options[$key]) ? $this->options[$key] : false;
131 131
 	}
132 132
 
133 133
 	/**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @since 1.0
137 137
 	 */
138 138
 	public function get_data() {
139
-		return apply_filters( 'give_get_graph_data', $this->data, $this );
139
+		return apply_filters('give_get_graph_data', $this->data, $this);
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function load_scripts() {
148 148
 		// Use minified libraries if SCRIPT_DEBUG is turned off
149
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
149
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
150 150
 
151
-		wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
152
-		wp_enqueue_script( 'jquery-flot-orderbars' );
151
+		wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
152
+		wp_enqueue_script('jquery-flot-orderbars');
153 153
 
154
-		wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
155
-		wp_enqueue_script( 'jquery-flot-time' );
154
+		wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
155
+		wp_enqueue_script('jquery-flot-time');
156 156
 
157
-		wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
158
-		wp_enqueue_script( 'jquery-flot-resize' );
157
+		wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
158
+		wp_enqueue_script('jquery-flot-resize');
159 159
 
160
-		wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
161
-		wp_enqueue_script( 'jquery-flot' );
160
+		wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION);
161
+		wp_enqueue_script('jquery-flot');
162 162
 
163 163
 	}
164 164
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 					[
186 186
 						<?php
187 187
 							$order = 0;
188
-							foreach( $this->get_data() as $label => $data ) :
188
+							foreach ($this->get_data() as $label => $data) :
189 189
 						?>
190 190
 						{
191
-							label : "<?php echo esc_attr( $label ); ?>",
192
-							id    : "<?php echo sanitize_key( $label ); ?>",
191
+							label : "<?php echo esc_attr($label); ?>",
192
+							id    : "<?php echo sanitize_key($label); ?>",
193 193
 							// data format is: [ point on x, value on y ]
194
-							data  : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
194
+							data  : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>],
195 195
 							points: {
196 196
 								show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
197 197
 							},
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 								fill     : true,
207 207
 								fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
208 208
 							},
209
-							<?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
209
+							<?php if ($this->options['multiple_y_axes']) : ?>
210 210
 							yaxis : <?php echo $yaxis_count; ?>
211 211
 							<?php endif; ?>
212 212
 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 						grid: {
221 221
 							show           : true,
222 222
 							aboveData      : false,
223
-							color          : "<?php echo $this->options[ 'color' ]; ?>",
224
-							backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
225
-							borderColor    : "<?php echo $this->options[ 'bordercolor' ]; ?>",
226
-							borderWidth    : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
223
+							color          : "<?php echo $this->options['color']; ?>",
224
+							backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
225
+							borderColor    : "<?php echo $this->options['bordercolor']; ?>",
226
+							borderWidth    : <?php echo absint($this->options['borderwidth']); ?>,
227 227
 							clickable      : false,
228 228
 							hoverable      : true
229 229
 						},
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 							mode        : "<?php echo $this->options['x_mode']; ?>",
235 235
 							timeFormat  : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
236 236
 							tickSize    : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
237
-							<?php if( $this->options['x_mode'] != 'time' ) : ?>
237
+							<?php if ($this->options['x_mode'] != 'time') : ?>
238 238
 							tickDecimals: <?php echo $this->options['x_decimals']; ?>
239 239
 							<?php endif; ?>
240 240
 						},
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 							min         : 0,
244 244
 							mode        : "<?php echo $this->options['y_mode']; ?>",
245 245
 							timeFormat  : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
246
-							<?php if( $this->options['y_mode'] != 'time' ) : ?>
246
+							<?php if ($this->options['y_mode'] != 'time') : ?>
247 247
 							tickDecimals: <?php echo $this->options['y_decimals']; ?>
248 248
 							<?php endif; ?>
249 249
 						}
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 * @since 1.0
304 304
 	 */
305 305
 	public function display() {
306
-		do_action( 'give_before_graph', $this );
306
+		do_action('give_before_graph', $this);
307 307
 		echo $this->build_graph();
308
-		do_action( 'give_after_graph', $this );
308
+		do_action('give_after_graph', $this);
309 309
 	}
310 310
 
311 311
 }
Please login to merge, or discard this patch.
includes/admin/plugins.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return array $links
28 28
  */
29
-function give_plugin_action_links( $links, $file ) {
30
-	$settings_link = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings' ) . '">' . esc_html__( 'Settings', 'give' ) . '</a>';
31
-	if ( $file == 'give/give.php' ) {
32
-		array_unshift( $links, $settings_link );
29
+function give_plugin_action_links($links, $file) {
30
+	$settings_link = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings').'">'.esc_html__('Settings', 'give').'</a>';
31
+	if ($file == 'give/give.php') {
32
+		array_unshift($links, $settings_link);
33 33
 	}
34 34
 
35 35
 	return $links;
36 36
 }
37 37
 
38
-add_filter( 'plugin_action_links', 'give_plugin_action_links', 10, 2 );
38
+add_filter('plugin_action_links', 'give_plugin_action_links', 10, 2);
39 39
 
40 40
 
41 41
 /**
@@ -48,33 +48,33 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @return array $input
50 50
  */
51
-function give_plugin_row_meta( $input, $file ) {
52
-	if ( $file != 'give/give.php' ) {
51
+function give_plugin_row_meta($input, $file) {
52
+	if ($file != 'give/give.php') {
53 53
 		return $input;
54 54
 	}
55 55
 
56
-	$give_addons_link = esc_url( add_query_arg( array(
56
+	$give_addons_link = esc_url(add_query_arg(array(
57 57
 			'utm_source'   => 'plugins-page',
58 58
 			'utm_medium'   => 'plugin-row',
59 59
 			'utm_campaign' => 'admin',
60
-		), 'https://givewp.com/addons/' )
60
+		), 'https://givewp.com/addons/')
61 61
 	);
62 62
 
63
-	$give_docs_link = esc_url( add_query_arg( array(
63
+	$give_docs_link = esc_url(add_query_arg(array(
64 64
 			'utm_source'   => 'plugins-page',
65 65
 			'utm_medium'   => 'plugin-row',
66 66
 			'utm_campaign' => 'admin',
67
-		), 'https://givewp.com/documentation/' )
67
+		), 'https://givewp.com/documentation/')
68 68
 	);
69 69
 
70 70
 	$links = array(
71
-		'<a href="' . $give_docs_link . '" target="_blank">' . esc_html__( 'Documentation', 'give' ) . '</a>',
72
-		'<a href="' . $give_addons_link . '" target="_blank">' . esc_html__( 'Add-ons', 'give' ) . '</a>',
71
+		'<a href="'.$give_docs_link.'" target="_blank">'.esc_html__('Documentation', 'give').'</a>',
72
+		'<a href="'.$give_addons_link.'" target="_blank">'.esc_html__('Add-ons', 'give').'</a>',
73 73
 	);
74 74
 
75
-	$input = array_merge( $input, $links );
75
+	$input = array_merge($input, $links);
76 76
 
77 77
 	return $input;
78 78
 }
79 79
 
80
-add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
80
+add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2);
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return string $default_price
69 69
  */
70
-function give_get_default_multilevel_amount( $form_id ) {
70
+function give_get_default_multilevel_amount($form_id) {
71 71
 	$default_price = '1.00';
72
-	$prices        = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
72
+	$prices        = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
73 73
 
74
-	foreach ( $prices as $price ) {
74
+	foreach ($prices as $price) {
75 75
 
76
-		if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
76
+		if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
77 77
 			$default_price = $price['_give_amount'];
78 78
 		}
79 79
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
  * @return string $default_price
95 95
  * @since      1.0
96 96
  */
97
-function give_get_default_form_amount( $form_id ) {
97
+function give_get_default_form_amount($form_id) {
98 98
 
99
-	if ( give_has_variable_prices( $form_id ) ) {
99
+	if (give_has_variable_prices($form_id)) {
100 100
 
101
-		$default_amount = give_get_default_multilevel_amount( $form_id );
101
+		$default_amount = give_get_default_multilevel_amount($form_id);
102 102
 
103 103
 	} else {
104 104
 
105
-		$default_amount = get_post_meta( $form_id, '_give_set_price', true );
105
+		$default_amount = get_post_meta($form_id, '_give_set_price', true);
106 106
 
107 107
 	}
108 108
 
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
  * 
124 124
  * @return bool
125 125
  */
126
-function give_is_custom_price_mode( $form_id = 0 ) {
126
+function give_is_custom_price_mode($form_id = 0) {
127 127
 
128
-	if ( empty( $form_id ) ) {
128
+	if (empty($form_id)) {
129 129
 		return false;
130 130
 	}
131 131
 
132
-	$form = new Give_Donate_Form( $form_id );
132
+	$form = new Give_Donate_Form($form_id);
133 133
 
134 134
 	return $form->is_custom_price_mode();
135 135
 }
136 136
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
 	 *
296 296
 	 * @return mixed void|false
297 297
 	 */
298
-	public function __construct( $payment_id = false ) {
298
+	public function __construct($payment_id = false) {
299 299
 
300
-		if ( empty( $payment_id ) ) {
300
+		if (empty($payment_id)) {
301 301
 			return false;
302 302
 		}
303 303
 
304
-		$this->setup_payment( $payment_id );
304
+		$this->setup_payment($payment_id);
305 305
 	}
306 306
 
307 307
 	/**
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @return mixed        The value
315 315
 	 */
316
-	public function __get( $key ) {
316
+	public function __get($key) {
317 317
 
318
-		if ( method_exists( $this, 'get_' . $key ) ) {
318
+		if (method_exists($this, 'get_'.$key)) {
319 319
 
320
-			$value = call_user_func( array( $this, 'get_' . $key ) );
320
+			$value = call_user_func(array($this, 'get_'.$key));
321 321
 
322 322
 		} else {
323 323
 
@@ -338,18 +338,18 @@  discard block
 block discarded – undo
338 338
 	 * @param string $key The property name
339 339
 	 * @param mixed $value The value of the property
340 340
 	 */
341
-	public function __set( $key, $value ) {
342
-		$ignore = array( '_ID' );
341
+	public function __set($key, $value) {
342
+		$ignore = array('_ID');
343 343
 
344
-		if ( $key === 'status' ) {
344
+		if ($key === 'status') {
345 345
 			$this->old_status = $this->status;
346 346
 		}
347 347
 
348
-		if ( ! in_array( $key, $ignore ) ) {
349
-			$this->pending[ $key ] = $value;
348
+		if ( ! in_array($key, $ignore)) {
349
+			$this->pending[$key] = $value;
350 350
 		}
351 351
 
352
-		if ( '_ID' !== $key ) {
352
+		if ('_ID' !== $key) {
353 353
 			$this->$key = $value;
354 354
 		}
355 355
 	}
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return boolean       If the item is set or not
365 365
 	 */
366
-	public function __isset( $name ) {
367
-		if ( property_exists( $this, $name ) ) {
368
-			return false === empty( $this->$name );
366
+	public function __isset($name) {
367
+		if (property_exists($this, $name)) {
368
+			return false === empty($this->$name);
369 369
 		} else {
370 370
 			return null;
371 371
 		}
@@ -380,31 +380,31 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return bool            If the setup was successful or not
382 382
 	 */
383
-	private function setup_payment( $payment_id ) {
383
+	private function setup_payment($payment_id) {
384 384
 		$this->pending = array();
385 385
 
386
-		if ( empty( $payment_id ) ) {
386
+		if (empty($payment_id)) {
387 387
 			return false;
388 388
 		}
389 389
 
390
-		$payment = get_post( $payment_id );
390
+		$payment = get_post($payment_id);
391 391
 
392
-		if ( ! $payment || is_wp_error( $payment ) ) {
392
+		if ( ! $payment || is_wp_error($payment)) {
393 393
 			return false;
394 394
 		}
395 395
 
396
-		if ( 'give_payment' !== $payment->post_type ) {
396
+		if ('give_payment' !== $payment->post_type) {
397 397
 			return false;
398 398
 		}
399 399
 
400 400
 		// Allow extensions to perform actions before the payment is loaded
401
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
401
+		do_action('give_pre_setup_payment', $this, $payment_id);
402 402
 
403 403
 		// Primary Identifier
404
-		$this->ID = absint( $payment_id );
404
+		$this->ID = absint($payment_id);
405 405
 
406 406
 		// Protected ID that can never be changed
407
-		$this->_ID = absint( $payment_id );
407
+		$this->_ID = absint($payment_id);
408 408
 
409 409
 		// We have a payment, get the generic payment_meta item to reduce calls to it
410 410
 		$this->payment_meta = $this->get_meta();
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		$this->parent_payment = $payment->post_parent;
420 420
 
421 421
 		$all_payment_statuses  = give_get_payment_statuses();
422
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
422
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
423 423
 
424 424
 		// Items
425 425
 		$this->fees = $this->setup_fees();
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 		$this->number     = $this->setup_payment_number();
453 453
 
454 454
 		// Allow extensions to add items to this object via hook
455
-		do_action( 'give_setup_payment', $this, $payment_id );
455
+		do_action('give_setup_payment', $this, $payment_id);
456 456
 
457 457
 		return true;
458 458
 	}
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
      * 
471 471
      * @return void
472 472
      */
473
-    public function update_payment_setup( $payment_id ){
474
-        $this->setup_payment( $payment_id );
473
+    public function update_payment_setup($payment_id) {
474
+        $this->setup_payment($payment_id);
475 475
     }
476 476
 
477 477
 	/**
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 
485 485
 		// Construct the payment title
486 486
 		$payment_title = '';
487
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
488
-			$payment_title = $this->first_name . ' ' . $this->last_name;
489
-		} else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
487
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
488
+			$payment_title = $this->first_name.' '.$this->last_name;
489
+		} else if ( ! empty($this->first_name) && empty($this->last_name)) {
490 490
 			$payment_title = $this->first_name;
491
-		} else if ( ! empty( $this->email ) && is_email( $this->email ) ) {
491
+		} else if ( ! empty($this->email) && is_email($this->email)) {
492 492
 			$payment_title = $this->email;
493 493
 		}
494 494
 
495 495
 		//Set Key
496
-		if ( empty( $this->key ) ) {
496
+		if (empty($this->key)) {
497 497
 
498
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
499
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
498
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
499
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
500 500
 			$this->pending['key'] = $this->key;
501 501
 		}
502 502
 
503 503
 		//Set IP
504
-		if ( empty( $this->ip ) ) {
504
+		if (empty($this->ip)) {
505 505
 
506 506
 			$this->ip            = give_get_ip();
507 507
 			$this->pending['ip'] = $this->ip;
@@ -528,58 +528,58 @@  discard block
 block discarded – undo
528 528
 			'fees'         => $this->fees,
529 529
 		);
530 530
 
531
-		$args = apply_filters( 'give_insert_payment_args', array(
531
+		$args = apply_filters('give_insert_payment_args', array(
532 532
 			'post_title'    => $payment_title,
533 533
 			'post_status'   => $this->status,
534 534
 			'post_type'     => 'give_payment',
535
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
536
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
535
+			'post_date'     => ! empty($this->date) ? $this->date : null,
536
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
537 537
 			'post_parent'   => $this->parent_payment,
538
-		), $payment_data );
538
+		), $payment_data);
539 539
 
540 540
 		// Create a blank payment
541
-		$payment_id = wp_insert_post( $args );
541
+		$payment_id = wp_insert_post($args);
542 542
 
543
-		if ( ! empty( $payment_id ) ) {
543
+		if ( ! empty($payment_id)) {
544 544
 
545 545
 			$this->ID  = $payment_id;
546 546
 			$this->_ID = $payment_id;
547 547
 
548 548
 			$customer = new stdClass;
549 549
 
550
-			if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) {
551
-				$customer = new Give_Customer( get_current_user_id(), true );
550
+			if (did_action('give_pre_process_purchase') && is_user_logged_in()) {
551
+				$customer = new Give_Customer(get_current_user_id(), true);
552 552
 			}
553 553
 
554
-			if ( empty( $customer->id ) ) {
555
-				$customer = new Give_Customer( $this->email );
554
+			if (empty($customer->id)) {
555
+				$customer = new Give_Customer($this->email);
556 556
 			}
557 557
 
558
-			if ( empty( $customer->id ) ) {
558
+			if (empty($customer->id)) {
559 559
 
560 560
 				$customer_data = array(
561
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
561
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
562 562
 					'email'   => $this->email,
563 563
 					'user_id' => $this->user_id,
564 564
 				);
565 565
 
566
-				$customer->create( $customer_data );
566
+				$customer->create($customer_data);
567 567
 
568 568
 			}
569 569
 
570 570
 			$this->customer_id            = $customer->id;
571 571
 			$this->pending['customer_id'] = $this->customer_id;
572
-			$customer->attach_payment( $this->ID, false );
572
+			$customer->attach_payment($this->ID, false);
573 573
 
574
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
575
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
576
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
577
-				foreach ( $this->fees as $fee ) {
578
-					$this->increase_fees( $fee['amount'] );
574
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
575
+			if ( ! empty($this->payment_meta['fees'])) {
576
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
577
+				foreach ($this->fees as $fee) {
578
+					$this->increase_fees($fee['amount']);
579 579
 				}
580 580
 			}
581 581
 
582
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
582
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
583 583
 			$this->new = true;
584 584
 		}
585 585
 
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
 		$saved = false;
600 600
 
601 601
 		//Must have an ID 
602
-		if ( empty( $this->ID ) ) {
602
+		if (empty($this->ID)) {
603 603
 
604 604
 			$payment_id = $this->insert_payment();
605 605
 
606
-			if ( false === $payment_id ) {
606
+			if (false === $payment_id) {
607 607
 				$saved = false;
608 608
 			} else {
609 609
 				$this->ID = $payment_id;
@@ -612,48 +612,48 @@  discard block
 block discarded – undo
612 612
 		}
613 613
 
614 614
 		//Set ID if not matching
615
-		if ( $this->ID !== $this->_ID ) {
615
+		if ($this->ID !== $this->_ID) {
616 616
 			$this->ID = $this->_ID;
617 617
 		}
618 618
 
619 619
 		// If we have something pending, let's save it
620
-		if ( ! empty( $this->pending ) ) {
620
+		if ( ! empty($this->pending)) {
621 621
 
622 622
 			$total_increase = 0;
623 623
 			$total_decrease = 0;
624 624
 
625
-			foreach ( $this->pending as $key => $value ) {
625
+			foreach ($this->pending as $key => $value) {
626 626
 
627
-				switch ( $key ) {
627
+				switch ($key) {
628 628
 
629 629
 					case 'donations':
630 630
 						// Update totals for pending donations
631
-						foreach ( $this->pending[ $key ] as $item ) {
631
+						foreach ($this->pending[$key] as $item) {
632 632
 
633
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
634
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
633
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
634
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
635 635
 
636
-							switch ( $item['action'] ) {
636
+							switch ($item['action']) {
637 637
 
638 638
 								case 'add':
639 639
 
640 640
 									$price = $item['price'];
641 641
 
642
-									if ( 'publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status ) {
642
+									if ('publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status) {
643 643
 
644 644
 										// Add sales logs
645
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
645
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
646 646
 
647 647
 										$y = 0;
648
-										while ( $y < $quantity ) {
648
+										while ($y < $quantity) {
649 649
 
650
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
651
-											$y ++;
650
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
651
+											$y++;
652 652
 										}
653 653
 
654
-										$form = new Give_Donate_Form( $item['id'] );
655
-										$form->increase_sales( $quantity );
656
-										$form->increase_earnings( $price );
654
+										$form = new Give_Donate_Form($item['id']);
655
+										$form->increase_sales($quantity);
656
+										$form->increase_earnings($price);
657 657
 
658 658
 										$total_increase += $price;
659 659
 									}
@@ -678,15 +678,15 @@  discard block
 block discarded – undo
678 678
 										)
679 679
 									);
680 680
 
681
-									$found_logs = get_posts( $log_args );
682
-									foreach ( $found_logs as $log ) {
683
-										wp_delete_post( $log->ID, true );
681
+									$found_logs = get_posts($log_args);
682
+									foreach ($found_logs as $log) {
683
+										wp_delete_post($log->ID, true);
684 684
 									}
685 685
 
686
-									if ( 'publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status ) {
687
-										$form = new Give_Donate_Form( $item['id'] );
688
-										$form->decrease_sales( $quantity );
689
-										$form->decrease_earnings( $item['amount'] );
686
+									if ('publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status) {
687
+										$form = new Give_Donate_Form($item['id']);
688
+										$form->decrease_sales($quantity);
689
+										$form->decrease_earnings($item['amount']);
690 690
 
691 691
 										$total_decrease += $item['amount'];
692 692
 									}
@@ -699,17 +699,17 @@  discard block
 block discarded – undo
699 699
 
700 700
 					case 'fees':
701 701
 
702
-						if ( 'publish' !== $this->status && 'complete' !== $this->status && 'revoked' !== $this->status ) {
702
+						if ('publish' !== $this->status && 'complete' !== $this->status && 'revoked' !== $this->status) {
703 703
 							break;
704 704
 						}
705 705
 
706
-						if ( empty( $this->pending[ $key ] ) ) {
706
+						if (empty($this->pending[$key])) {
707 707
 							break;
708 708
 						}
709 709
 
710
-						foreach ( $this->pending[ $key ] as $fee ) {
710
+						foreach ($this->pending[$key] as $fee) {
711 711
 
712
-							switch ( $fee['action'] ) {
712
+							switch ($fee['action']) {
713 713
 
714 714
 								case 'add':
715 715
 									$total_increase += $fee['amount'];
@@ -726,43 +726,43 @@  discard block
 block discarded – undo
726 726
 						break;
727 727
 
728 728
 					case 'status':
729
-						$this->update_status( $this->status );
729
+						$this->update_status($this->status);
730 730
 						break;
731 731
 
732 732
 					case 'gateway':
733
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
733
+						$this->update_meta('_give_payment_gateway', $this->gateway);
734 734
 						break;
735 735
 
736 736
 					case 'mode':
737
-						$this->update_meta( '_give_payment_mode', $this->mode );
737
+						$this->update_meta('_give_payment_mode', $this->mode);
738 738
 						break;
739 739
 
740 740
 					case 'transaction_id':
741
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
741
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
742 742
 						break;
743 743
 
744 744
 					case 'ip':
745
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
745
+						$this->update_meta('_give_payment_user_ip', $this->ip);
746 746
 						break;
747 747
 
748 748
 					case 'customer_id':
749
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
749
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
750 750
 						break;
751 751
 
752 752
 					case 'user_id':
753
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
753
+						$this->update_meta('_give_payment_user_id', $this->user_id);
754 754
 						break;
755 755
 
756 756
 					case 'form_title':
757
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
757
+						$this->update_meta('_give_payment_form_title', $this->form_title);
758 758
 						break;
759 759
 
760 760
 					case 'form_id':
761
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
761
+						$this->update_meta('_give_payment_form_id', $this->form_id);
762 762
 						break;
763 763
 
764 764
 					case 'price_id':
765
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
765
+						$this->update_meta('_give_payment_price_id', $this->price_id);
766 766
 						break;
767 767
 
768 768
 					case 'first_name':
@@ -778,15 +778,15 @@  discard block
 block discarded – undo
778 778
 						break;
779 779
 
780 780
 					case 'email':
781
-						$this->update_meta( '_give_payment_user_email', $this->email );
781
+						$this->update_meta('_give_payment_user_email', $this->email);
782 782
 						break;
783 783
 
784 784
 					case 'key':
785
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
785
+						$this->update_meta('_give_payment_purchase_key', $this->key);
786 786
 						break;
787 787
 
788 788
 					case 'number':
789
-						$this->update_meta( '_give_payment_number', $this->number );
789
+						$this->update_meta('_give_payment_number', $this->number);
790 790
 						break;
791 791
 
792 792
 					case 'date':
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 							'edit_date' => true,
797 797
 						);
798 798
 
799
-						wp_update_post( $args );
799
+						wp_update_post($args);
800 800
 						break;
801 801
 
802 802
 					case 'completed_date':
803
-						$this->update_meta( '_give_completed_date', $this->completed_date );
803
+						$this->update_meta('_give_completed_date', $this->completed_date);
804 804
 						break;
805 805
 
806 806
 					case 'parent_payment':
@@ -809,38 +809,38 @@  discard block
 block discarded – undo
809 809
 							'post_parent' => $this->parent_payment,
810 810
 						);
811 811
 
812
-						wp_update_post( $args );
812
+						wp_update_post($args);
813 813
 						break;
814 814
 
815 815
 					default:
816
-						do_action( 'give_payment_save', $this, $key );
816
+						do_action('give_payment_save', $this, $key);
817 817
 						break;
818 818
 				}
819 819
 			}
820 820
 
821
-			if ( 'pending' !== $this->status ) {
821
+			if ('pending' !== $this->status) {
822 822
 
823
-				$customer = new Give_Customer( $this->customer_id );
823
+				$customer = new Give_Customer($this->customer_id);
824 824
 
825 825
 				$total_change = $total_increase - $total_decrease;
826
-				if ( $total_change < 0 ) {
826
+				if ($total_change < 0) {
827 827
 
828
-					$total_change = - ( $total_change );
828
+					$total_change = - ($total_change);
829 829
 					// Decrease the customer's purchase stats
830
-					$customer->decrease_value( $total_change );
831
-					give_decrease_total_earnings( $total_change );
830
+					$customer->decrease_value($total_change);
831
+					give_decrease_total_earnings($total_change);
832 832
 
833
-				} else if ( $total_change > 0 ) {
833
+				} else if ($total_change > 0) {
834 834
 
835 835
 					// Increase the customer's purchase stats
836
-					$customer->increase_value( $total_change );
837
-					give_increase_total_earnings( $total_change );
836
+					$customer->increase_value($total_change);
837
+					give_increase_total_earnings($total_change);
838 838
 
839 839
 				}
840 840
 
841 841
 			}
842 842
 
843
-			$this->update_meta( '_give_payment_total', $this->total );
843
+			$this->update_meta('_give_payment_total', $this->total);
844 844
 
845 845
 			$new_meta = array(
846 846
 				'form_title' => $this->form_title,
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 			);
853 853
 
854 854
 			$meta        = $this->get_meta();
855
-			$merged_meta = array_merge( $meta, $new_meta );
855
+			$merged_meta = array_merge($meta, $new_meta);
856 856
 
857 857
 			// Only save the payment meta if it's changed
858
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
859
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
860
-				if ( false !== $updated ) {
858
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
859
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
860
+				if (false !== $updated) {
861 861
 					$saved = true;
862 862
 				}
863 863
 			}
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 			$saved         = true;
867 867
 		}
868 868
 
869
-		if ( true === $saved ) {
870
-			$this->setup_payment( $this->ID );
869
+		if (true === $saved) {
870
+			$this->setup_payment($this->ID);
871 871
 		}
872 872
 
873 873
 		return $saved;
@@ -884,12 +884,12 @@  discard block
 block discarded – undo
884 884
 	 *
885 885
 	 * @return bool True when successful, false otherwise
886 886
 	 */
887
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
887
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
888 888
 
889
-		$donation = new Give_Donate_Form( $form_id );
889
+		$donation = new Give_Donate_Form($form_id);
890 890
 
891 891
 		// Bail if this post isn't a give donation form
892
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
892
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
893 893
 			return false;
894 894
 		}
895 895
 
@@ -900,60 +900,60 @@  discard block
 block discarded – undo
900 900
 			'fees'     => array(),
901 901
 		);
902 902
 
903
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
903
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
904 904
 
905 905
 		// Allow overriding the price
906
-		if ( false !== $args['price'] ) {
906
+		if (false !== $args['price']) {
907 907
 			$item_price = $args['price'];
908 908
 		} else {
909 909
 
910 910
 			// Deal with variable pricing
911
-			if ( give_has_variable_prices( $donation->ID ) ) {
912
-				$prices     = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
911
+			if (give_has_variable_prices($donation->ID)) {
912
+				$prices     = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
913 913
 				$item_price = '';
914 914
 				//Loop through prices
915
-				foreach ( $prices as $price ) {
915
+				foreach ($prices as $price) {
916 916
 					//Find a match between price_id and level_id
917 917
 					//First verify array keys exists THEN make the match
918
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
918
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
919 919
 					     && $args['price_id'] == $price['_give_id']['level_id']
920 920
 					) {
921 921
 						$item_price = $price['_give_amount'];
922 922
 					}
923 923
 				}
924 924
 				//Fallback to the lowest price point
925
-				if ( $item_price == '' ) {
926
-					$item_price       = give_get_lowest_price_option( $donation->ID );
927
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
925
+				if ($item_price == '') {
926
+					$item_price       = give_get_lowest_price_option($donation->ID);
927
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
928 928
 				}
929 929
 			} else {
930 930
 				//Simple form price
931
-				$item_price = give_get_form_price( $donation->ID );
931
+				$item_price = give_get_form_price($donation->ID);
932 932
 			}
933 933
 
934 934
 		}
935 935
 
936 936
 		// Sanitizing the price here so we don't have a dozen calls later
937
-		$item_price = give_sanitize_amount( $item_price );
938
-		$total      = round( $item_price, give_currency_decimal_filter() );
937
+		$item_price = give_sanitize_amount($item_price);
938
+		$total      = round($item_price, give_currency_decimal_filter());
939 939
 
940 940
 		//Add Options
941 941
 		$default_options = array();
942
-		if ( false !== $args['price_id'] ) {
942
+		if (false !== $args['price_id']) {
943 943
 			$default_options['price_id'] = (int) $args['price_id'];
944 944
 		}
945
-		$options = wp_parse_args( $options, $default_options );
945
+		$options = wp_parse_args($options, $default_options);
946 946
 
947 947
 		// Do not allow totals to go negative
948
-		if ( $total < 0 ) {
948
+		if ($total < 0) {
949 949
 			$total = 0;
950 950
 		}
951 951
 
952 952
 		$donation = array(
953 953
 			'name'     => $donation->post_title,
954 954
 			'id'       => $donation->ID,
955
-			'price'    => round( $total, give_currency_decimal_filter() ),
956
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
955
+			'price'    => round($total, give_currency_decimal_filter()),
956
+			'subtotal' => round($total, give_currency_decimal_filter()),
957 957
 			'fees'     => $args['fees'],
958 958
 			'price_id' => $args['price_id'],
959 959
 			'action'   => 'add',
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 
963 963
 		$this->pending['donations'][] = $donation;
964 964
 
965
-		$this->increase_subtotal( $total );
965
+		$this->increase_subtotal($total);
966 966
 
967 967
 		return true;
968 968
 
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 	 *
979 979
 	 * @return bool If the item was removed or not
980 980
 	 */
981
-	public function remove_donation( $form_id, $args = array() ) {
981
+	public function remove_donation($form_id, $args = array()) {
982 982
 
983 983
 		// Set some defaults
984 984
 		$defaults = array(
@@ -986,12 +986,12 @@  discard block
 block discarded – undo
986 986
 			'price'    => false,
987 987
 			'price_id' => false,
988 988
 		);
989
-		$args     = wp_parse_args( $args, $defaults );
989
+		$args = wp_parse_args($args, $defaults);
990 990
 
991
-		$form = new Give_Donate_Form( $form_id );
991
+		$form = new Give_Donate_Form($form_id);
992 992
 
993 993
 		// Bail if this post isn't a valid give donation form
994
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
994
+		if ( ! $form || $form->post_type !== 'give_forms') {
995 995
 			return false;
996 996
 		}
997 997
 
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
 		$this->pending['donations'][] = $pending_args;
1006 1006
 
1007
-		$this->decrease_subtotal( $this->total );
1007
+		$this->decrease_subtotal($this->total);
1008 1008
 
1009 1009
 		return true;
1010 1010
 	}
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 	 *
1020 1020
 	 * @return bool If the fee was added
1021 1021
 	 */
1022
-	public function add_fee( $args, $global = true ) {
1022
+	public function add_fee($args, $global = true) {
1023 1023
 
1024 1024
 		$default_args = array(
1025 1025
 			'label'    => '',
@@ -1029,16 +1029,16 @@  discard block
 block discarded – undo
1029 1029
 			'price_id' => 0,
1030 1030
 		);
1031 1031
 
1032
-		$fee          = wp_parse_args( $args, $default_args );
1032
+		$fee          = wp_parse_args($args, $default_args);
1033 1033
 		$this->fees[] = $fee;
1034 1034
 
1035 1035
 
1036 1036
 		$added_fee               = $fee;
1037 1037
 		$added_fee['action']     = 'add';
1038 1038
 		$this->pending['fees'][] = $added_fee;
1039
-		reset( $this->fees );
1039
+		reset($this->fees);
1040 1040
 
1041
-		$this->increase_fees( $fee['amount'] );
1041
+		$this->increase_fees($fee['amount']);
1042 1042
 
1043 1043
 		return true;
1044 1044
 	}
@@ -1052,11 +1052,11 @@  discard block
 block discarded – undo
1052 1052
 	 *
1053 1053
 	 * @return bool     If the fee was removed successfully
1054 1054
 	 */
1055
-	public function remove_fee( $key ) {
1055
+	public function remove_fee($key) {
1056 1056
 		$removed = false;
1057 1057
 
1058
-		if ( is_numeric( $key ) ) {
1059
-			$removed = $this->remove_fee_by( 'index', $key );
1058
+		if (is_numeric($key)) {
1059
+			$removed = $this->remove_fee_by('index', $key);
1060 1060
 		}
1061 1061
 
1062 1062
 		return $removed;
@@ -1073,47 +1073,47 @@  discard block
 block discarded – undo
1073 1073
 	 *
1074 1074
 	 * @return boolean             If the item is removed
1075 1075
 	 */
1076
-	public function remove_fee_by( $key, $value, $global = false ) {
1076
+	public function remove_fee_by($key, $value, $global = false) {
1077 1077
 
1078
-		$allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array(
1078
+		$allowed_fee_keys = apply_filters('give_payment_fee_keys', array(
1079 1079
 			'index',
1080 1080
 			'label',
1081 1081
 			'amount',
1082 1082
 			'type',
1083
-		) );
1083
+		));
1084 1084
 
1085
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1085
+		if ( ! in_array($key, $allowed_fee_keys)) {
1086 1086
 			return false;
1087 1087
 		}
1088 1088
 
1089 1089
 		$removed = false;
1090
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1090
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1091 1091
 
1092
-			$removed_fee             = $this->fees[ $value ];
1092
+			$removed_fee             = $this->fees[$value];
1093 1093
 			$removed_fee['action']   = 'remove';
1094 1094
 			$this->pending['fees'][] = $removed_fee;
1095 1095
 
1096
-			$this->decrease_fees( $removed_fee['amount'] );
1096
+			$this->decrease_fees($removed_fee['amount']);
1097 1097
 
1098
-			unset( $this->fees[ $value ] );
1098
+			unset($this->fees[$value]);
1099 1099
 			$removed = true;
1100 1100
 
1101
-		} else if ( 'index' !== $key ) {
1101
+		} else if ('index' !== $key) {
1102 1102
 
1103
-			foreach ( $this->fees as $index => $fee ) {
1103
+			foreach ($this->fees as $index => $fee) {
1104 1104
 
1105
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1105
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1106 1106
 
1107 1107
 					$removed_fee             = $fee;
1108 1108
 					$removed_fee['action']   = 'remove';
1109 1109
 					$this->pending['fees'][] = $removed_fee;
1110 1110
 
1111
-					$this->decrease_fees( $removed_fee['amount'] );
1111
+					$this->decrease_fees($removed_fee['amount']);
1112 1112
 
1113
-					unset( $this->fees[ $index ] );
1113
+					unset($this->fees[$index]);
1114 1114
 					$removed = true;
1115 1115
 
1116
-					if ( false === $global ) {
1116
+					if (false === $global) {
1117 1117
 						break;
1118 1118
 					}
1119 1119
 
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 
1124 1124
 		}
1125 1125
 
1126
-		if ( true === $removed ) {
1127
-			$this->fees = array_values( $this->fees );
1126
+		if (true === $removed) {
1127
+			$this->fees = array_values($this->fees);
1128 1128
 		}
1129 1129
 
1130 1130
 		return $removed;
@@ -1139,14 +1139,14 @@  discard block
 block discarded – undo
1139 1139
 	 *
1140 1140
 	 * @return array        The Fees for the type specified
1141 1141
 	 */
1142
-	public function get_fees( $type = 'all' ) {
1142
+	public function get_fees($type = 'all') {
1143 1143
 		$fees = array();
1144 1144
 
1145
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1145
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1146 1146
 
1147
-			foreach ( $this->fees as $fee_id => $fee ) {
1147
+			foreach ($this->fees as $fee_id => $fee) {
1148 1148
 
1149
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1149
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1150 1150
 					continue;
1151 1151
 				}
1152 1152
 
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 			}
1157 1157
 		}
1158 1158
 
1159
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1159
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1160 1160
 	}
1161 1161
 
1162 1162
 	/**
@@ -1168,13 +1168,13 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @return void
1170 1170
 	 */
1171
-	public function add_note( $note = false ) {
1171
+	public function add_note($note = false) {
1172 1172
 		// Bail if no note specified
1173
-		if ( ! $note ) {
1173
+		if ( ! $note) {
1174 1174
 			return false;
1175 1175
 		}
1176 1176
 
1177
-		give_insert_payment_note( $this->ID, $note );
1177
+		give_insert_payment_note($this->ID, $note);
1178 1178
 	}
1179 1179
 
1180 1180
 	/**
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	 *
1187 1187
 	 * @return void
1188 1188
 	 */
1189
-	private function increase_subtotal( $amount = 0.00 ) {
1189
+	private function increase_subtotal($amount = 0.00) {
1190 1190
 		$amount = (float) $amount;
1191 1191
 		$this->subtotal += $amount;
1192 1192
 
@@ -1202,11 +1202,11 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return void
1204 1204
 	 */
1205
-	private function decrease_subtotal( $amount = 0.00 ) {
1205
+	private function decrease_subtotal($amount = 0.00) {
1206 1206
 		$amount = (float) $amount;
1207 1207
 		$this->subtotal -= $amount;
1208 1208
 
1209
-		if ( $this->subtotal < 0 ) {
1209
+		if ($this->subtotal < 0) {
1210 1210
 			$this->subtotal = 0;
1211 1211
 		}
1212 1212
 
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 	 *
1223 1223
 	 * @return void
1224 1224
 	 */
1225
-	private function increase_fees( $amount = 0.00 ) {
1225
+	private function increase_fees($amount = 0.00) {
1226 1226
 		$amount = (float) $amount;
1227 1227
 		$this->fees_total += $amount;
1228 1228
 
@@ -1238,11 +1238,11 @@  discard block
 block discarded – undo
1238 1238
 	 *
1239 1239
 	 * @return void
1240 1240
 	 */
1241
-	private function decrease_fees( $amount = 0.00 ) {
1241
+	private function decrease_fees($amount = 0.00) {
1242 1242
 		$amount = (float) $amount;
1243 1243
 		$this->fees_total -= $amount;
1244 1244
 
1245
-		if ( $this->fees_total < 0 ) {
1245
+		if ($this->fees_total < 0) {
1246 1246
 			$this->fees_total = 0;
1247 1247
 		}
1248 1248
 
@@ -1268,41 +1268,41 @@  discard block
 block discarded – undo
1268 1268
 	 *
1269 1269
 	 * @return bool Returns if the status was successfully updated
1270 1270
 	 */
1271
-	public function update_status( $status = false ) {
1271
+	public function update_status($status = false) {
1272 1272
 
1273 1273
 		//standardize the 'complete(d)' status
1274
-		if ( $status == 'completed' || $status == 'complete' ) {
1274
+		if ($status == 'completed' || $status == 'complete') {
1275 1275
 			$status = 'publish';
1276 1276
 		}
1277 1277
 
1278
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1278
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1279 1279
 
1280
-		if ( $old_status === $status ) {
1280
+		if ($old_status === $status) {
1281 1281
 			return false; // Don't permit status changes that aren't changes
1282 1282
 		}
1283 1283
 
1284
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1284
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1285 1285
 
1286 1286
 		$updated = false;
1287 1287
 
1288 1288
 
1289
-		if ( $do_change ) {
1289
+		if ($do_change) {
1290 1290
 
1291
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1291
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1292 1292
 
1293 1293
 			$update_fields = array(
1294 1294
 				'ID'          => $this->ID,
1295 1295
 				'post_status' => $status,
1296
-				'edit_date'   => current_time( 'mysql' )
1296
+				'edit_date'   => current_time('mysql')
1297 1297
 			);
1298 1298
 
1299
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1299
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1300 1300
 
1301 1301
 			$all_payment_statuses  = give_get_payment_statuses();
1302
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1302
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1303 1303
 
1304 1304
 			// Process any specific status functions
1305
-			switch ( $status ) {
1305
+			switch ($status) {
1306 1306
 				case 'refunded':
1307 1307
 					$this->process_refund();
1308 1308
 					break;
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
                     break;
1318 1318
 			}
1319 1319
 
1320
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1320
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1321 1321
 
1322 1322
 		}
1323 1323
 
@@ -1349,32 +1349,32 @@  discard block
 block discarded – undo
1349 1349
 	 *
1350 1350
 	 * @return mixed             The value from the post meta
1351 1351
 	 */
1352
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1352
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1353 1353
 
1354
-		$meta = get_post_meta( $this->ID, $meta_key, $single );
1354
+		$meta = get_post_meta($this->ID, $meta_key, $single);
1355 1355
 
1356
-		if ( $meta_key === '_give_payment_meta' ) {
1356
+		if ($meta_key === '_give_payment_meta') {
1357 1357
 
1358
-			if ( empty( $meta['key'] ) ) {
1358
+			if (empty($meta['key'])) {
1359 1359
 				$meta['key'] = $this->setup_payment_key();
1360 1360
 			}
1361 1361
 
1362
-			if ( empty( $meta['form_title'] ) ) {
1362
+			if (empty($meta['form_title'])) {
1363 1363
 				$meta['form_title'] = $this->setup_form_title();
1364 1364
 			}
1365 1365
 
1366
-			if ( empty( $meta['email'] ) ) {
1366
+			if (empty($meta['email'])) {
1367 1367
 				$meta['email'] = $this->setup_email();
1368 1368
 			}
1369 1369
 
1370
-			if ( empty( $meta['date'] ) ) {
1371
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1370
+			if (empty($meta['date'])) {
1371
+				$meta['date'] = get_post_field('post_date', $this->ID);
1372 1372
 			}
1373 1373
 		}
1374 1374
 
1375
-		$meta = apply_filters( 'give_get_payment_meta_' . $meta_key, $meta, $this->ID );
1375
+		$meta = apply_filters('give_get_payment_meta_'.$meta_key, $meta, $this->ID);
1376 1376
 
1377
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1377
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1378 1378
 	}
1379 1379
 
1380 1380
 	/**
@@ -1388,23 +1388,23 @@  discard block
 block discarded – undo
1388 1388
 	 *
1389 1389
 	 * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure
1390 1390
 	 */
1391
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1392
-		if ( empty( $meta_key ) ) {
1391
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1392
+		if (empty($meta_key)) {
1393 1393
 			return false;
1394 1394
 		}
1395 1395
 
1396
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1396
+		if ($meta_key == 'key' || $meta_key == 'date') {
1397 1397
 
1398 1398
 			$current_meta              = $this->get_meta();
1399
-			$current_meta[ $meta_key ] = $meta_value;
1399
+			$current_meta[$meta_key] = $meta_value;
1400 1400
 
1401 1401
 			$meta_key   = '_give_payment_meta';
1402 1402
 			$meta_value = $current_meta;
1403 1403
 
1404
-		} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1404
+		} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1405 1405
 
1406
-			$meta_value = apply_filters( 'give_give_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1407
-			update_post_meta( $this->ID, '_give_payment_user_email', $meta_value );
1406
+			$meta_value = apply_filters('give_give_update_payment_meta_'.$meta_key, $meta_value, $this->ID);
1407
+			update_post_meta($this->ID, '_give_payment_user_email', $meta_value);
1408 1408
 
1409 1409
 			$current_meta                       = $this->get_meta();
1410 1410
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1414,9 +1414,9 @@  discard block
 block discarded – undo
1414 1414
 
1415 1415
 		}
1416 1416
 
1417
-		$meta_value = apply_filters( 'give_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1417
+		$meta_value = apply_filters('give_update_payment_meta_'.$meta_key, $meta_value, $this->ID);
1418 1418
 
1419
-		return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1419
+		return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1420 1420
 	}
1421 1421
 
1422 1422
 	/**
@@ -1430,30 +1430,30 @@  discard block
 block discarded – undo
1430 1430
 		$process_refund = true;
1431 1431
 
1432 1432
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1433
-		if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'refunded' != $this->status ) {
1433
+		if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'refunded' != $this->status) {
1434 1434
 			$process_refund = false;
1435 1435
 		}
1436 1436
 
1437 1437
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1438
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1438
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1439 1439
 
1440
-		if ( false === $process_refund ) {
1440
+		if (false === $process_refund) {
1441 1441
 			return;
1442 1442
 		}
1443 1443
 
1444
-		do_action( 'give_pre_refund_payment', $this );
1444
+		do_action('give_pre_refund_payment', $this);
1445 1445
 
1446
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1447
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1448
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1446
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1447
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1448
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1449 1449
 
1450
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1450
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1451 1451
 		$this->delete_sales_logs();
1452 1452
 
1453 1453
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1454
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1454
+		delete_transient(md5('give_earnings_this_monththis_month'));
1455 1455
 
1456
-		do_action( 'give_post_refund_payment', $this );
1456
+		do_action('give_post_refund_payment', $this);
1457 1457
 	}
1458 1458
 
1459 1459
 	/**
@@ -1477,29 +1477,29 @@  discard block
 block discarded – undo
1477 1477
 		$process_pending = true;
1478 1478
 
1479 1479
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1480
-		if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'pending' != $this->status ) {
1480
+		if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'pending' != $this->status) {
1481 1481
 			$process_pending = false;
1482 1482
 		}
1483 1483
 
1484 1484
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1485
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1485
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1486 1486
 
1487
-		if ( false === $process_pending ) {
1487
+		if (false === $process_pending) {
1488 1488
 			return;
1489 1489
 		}
1490 1490
 
1491
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this );
1492
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this );
1493
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this );
1491
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this);
1492
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this);
1493
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this);
1494 1494
 
1495
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1495
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1496 1496
 		$this->delete_sales_logs();
1497 1497
 
1498 1498
 		$this->completed_date = false;
1499
-		$this->update_meta( '_give_completed_date', '' );
1499
+		$this->update_meta('_give_completed_date', '');
1500 1500
 
1501 1501
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1502
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1502
+		delete_transient(md5('give_earnings_this_monththis_month'));
1503 1503
 	}
1504 1504
 
1505 1505
     /**
@@ -1512,29 +1512,29 @@  discard block
 block discarded – undo
1512 1512
         $process_cancelled = true;
1513 1513
 
1514 1514
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1515
-        if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'cancelled' != $this->status ) {
1515
+        if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'cancelled' != $this->status) {
1516 1516
             $process_cancelled = false;
1517 1517
         }
1518 1518
 
1519 1519
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1520
-        $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1520
+        $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1521 1521
 
1522
-        if ( false === $process_cancelled ) {
1522
+        if (false === $process_cancelled) {
1523 1523
             return;
1524 1524
         }
1525 1525
 
1526
-        $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1527
-        $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1528
-        $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1526
+        $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this);
1527
+        $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this);
1528
+        $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this);
1529 1529
 
1530
-        $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1530
+        $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1531 1531
         $this->delete_sales_logs();
1532 1532
 
1533 1533
         $this->completed_date = false;
1534
-        $this->update_meta( '_give_completed_date', '' );
1534
+        $this->update_meta('_give_completed_date', '');
1535 1535
 
1536 1536
         // Clear the This Month earnings (this_monththis_month is NOT a typo)
1537
-        delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1537
+        delete_transient(md5('give_earnings_this_monththis_month'));
1538 1538
     }
1539 1539
 
1540 1540
 	/**
@@ -1548,25 +1548,25 @@  discard block
 block discarded – undo
1548 1548
 	 *
1549 1549
 	 * @return void
1550 1550
 	 */
1551
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1551
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1552 1552
 
1553
-		give_undo_purchase( false, $this->ID );
1553
+		give_undo_purchase(false, $this->ID);
1554 1554
 
1555 1555
 		// Decrease store earnings
1556
-		if ( true === $alter_store_earnings ) {
1557
-			give_decrease_total_earnings( $this->total );
1556
+		if (true === $alter_store_earnings) {
1557
+			give_decrease_total_earnings($this->total);
1558 1558
 		}
1559 1559
 
1560 1560
 		// Decrement the stats for the customer
1561
-		if ( ! empty( $this->customer_id ) ) {
1561
+		if ( ! empty($this->customer_id)) {
1562 1562
 
1563
-			$customer = new Give_Customer( $this->customer_id );
1563
+			$customer = new Give_Customer($this->customer_id);
1564 1564
 
1565
-			if ( true === $alter_customer_value ) {
1566
-				$customer->decrease_value( $this->total );
1565
+			if (true === $alter_customer_value) {
1566
+				$customer->decrease_value($this->total);
1567 1567
 			}
1568 1568
 
1569
-			if ( true === $alter_customer_purchase_count ) {
1569
+			if (true === $alter_customer_purchase_count) {
1570 1570
 				$customer->decrease_purchase_count();
1571 1571
 			}
1572 1572
 
@@ -1612,13 +1612,13 @@  discard block
 block discarded – undo
1612 1612
 	 * @return string The date the payment was completed
1613 1613
 	 */
1614 1614
 	private function setup_completed_date() {
1615
-		$payment = get_post( $this->ID );
1615
+		$payment = get_post($this->ID);
1616 1616
 
1617
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1617
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1618 1618
 			return false; // This payment was never completed
1619 1619
 		}
1620 1620
 
1621
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1621
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1622 1622
 
1623 1623
 		return $date;
1624 1624
 	}
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 	 * @return string The payment mode
1631 1631
 	 */
1632 1632
 	private function setup_mode() {
1633
-		return $this->get_meta( '_give_payment_mode' );
1633
+		return $this->get_meta('_give_payment_mode');
1634 1634
 	}
1635 1635
 
1636 1636
 	/**
@@ -1640,13 +1640,13 @@  discard block
 block discarded – undo
1640 1640
 	 * @return float The payment total
1641 1641
 	 */
1642 1642
 	private function setup_total() {
1643
-		$amount = $this->get_meta( '_give_payment_total', true );
1643
+		$amount = $this->get_meta('_give_payment_total', true);
1644 1644
 
1645
-		if ( empty( $amount ) && '0.00' != $amount ) {
1646
-			$meta = $this->get_meta( '_give_payment_meta', true );
1647
-			$meta = maybe_unserialize( $meta );
1645
+		if (empty($amount) && '0.00' != $amount) {
1646
+			$meta = $this->get_meta('_give_payment_meta', true);
1647
+			$meta = maybe_unserialize($meta);
1648 1648
 
1649
-			if ( isset( $meta['amount'] ) ) {
1649
+			if (isset($meta['amount'])) {
1650 1650
 				$amount = $meta['amount'];
1651 1651
 			}
1652 1652
 		}
@@ -1675,9 +1675,9 @@  discard block
 block discarded – undo
1675 1675
 	private function setup_fees_total() {
1676 1676
 		$fees_total = (float) 0.00;
1677 1677
 
1678
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1679
-		if ( ! empty( $payment_fees ) ) {
1680
-			foreach ( $payment_fees as $fee ) {
1678
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1679
+		if ( ! empty($payment_fees)) {
1680
+			foreach ($payment_fees as $fee) {
1681 1681
 				$fees_total += (float) $fee['amount'];
1682 1682
 			}
1683 1683
 		}
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 	 * @return string              The currency for the payment
1694 1694
 	 */
1695 1695
 	private function setup_currency() {
1696
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this );
1696
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this);
1697 1697
 
1698 1698
 		return $currency;
1699 1699
 	}
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 	 * @return array The Fees
1706 1706
 	 */
1707 1707
 	private function setup_fees() {
1708
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1708
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1709 1709
 
1710 1710
 		return $payment_fees;
1711 1711
 	}
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
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
 	}
@@ -1729,12 +1729,12 @@  discard block
 block discarded – undo
1729 1729
 	 * @return string The transaction ID for the payment
1730 1730
 	 */
1731 1731
 	private function setup_transaction_id() {
1732
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1732
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1733 1733
 
1734
-		if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
1734
+		if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
1735 1735
 
1736 1736
 			$gateway        = $this->gateway;
1737
-			$transaction_id = apply_filters( 'give_get_payment_transaction_id-' . $gateway, $this->ID );
1737
+			$transaction_id = apply_filters('give_get_payment_transaction_id-'.$gateway, $this->ID);
1738 1738
 
1739 1739
 		}
1740 1740
 
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 	 * @return string The IP address for the payment
1749 1749
 	 */
1750 1750
 	private function setup_ip() {
1751
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
1751
+		$ip = $this->get_meta('_give_payment_user_ip', true);
1752 1752
 
1753 1753
 		return $ip;
1754 1754
 	}
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 	 * @return int The Customer ID
1761 1761
 	 */
1762 1762
 	private function setup_customer_id() {
1763
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
1763
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
1764 1764
 
1765 1765
 		return $customer_id;
1766 1766
 	}
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 	 * @return int The User ID
1773 1773
 	 */
1774 1774
 	private function setup_user_id() {
1775
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
1775
+		$user_id = $this->get_meta('_give_payment_user_id', true);
1776 1776
 
1777 1777
 		return $user_id;
1778 1778
 	}
@@ -1784,10 +1784,10 @@  discard block
 block discarded – undo
1784 1784
 	 * @return string The email address for the payment
1785 1785
 	 */
1786 1786
 	private function setup_email() {
1787
-		$email = $this->get_meta( '_give_payment_user_email', true );
1787
+		$email = $this->get_meta('_give_payment_user_email', true);
1788 1788
 
1789
-		if ( empty( $email ) ) {
1790
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
1789
+		if (empty($email)) {
1790
+			$email = Give()->customers->get_column('email', $this->customer_id);
1791 1791
 		}
1792 1792
 
1793 1793
 		return $email;
@@ -1805,15 +1805,15 @@  discard block
 block discarded – undo
1805 1805
 			'last_name'  => $this->last_name,
1806 1806
 		);
1807 1807
 
1808
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
1809
-		$user_info = wp_parse_args( $user_info, $defaults );
1808
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
1809
+		$user_info = wp_parse_args($user_info, $defaults);
1810 1810
 
1811
-		if ( empty( $user_info ) ) {
1811
+		if (empty($user_info)) {
1812 1812
 			// Get the customer, but only if it's been created
1813
-			$customer = new Give_Customer( $this->customer_id );
1813
+			$customer = new Give_Customer($this->customer_id);
1814 1814
 
1815
-			if ( $customer->id > 0 ) {
1816
-				$name      = explode( ' ', $customer->name, 2 );
1815
+			if ($customer->id > 0) {
1816
+				$name      = explode(' ', $customer->name, 2);
1817 1817
 				$user_info = array(
1818 1818
 					'first_name' => $name[0],
1819 1819
 					'last_name'  => $name[1],
@@ -1823,29 +1823,29 @@  discard block
 block discarded – undo
1823 1823
 			}
1824 1824
 		} else {
1825 1825
 			// Get the customer, but only if it's been created
1826
-			$customer = new Give_Customer( $this->customer_id );
1827
-			if ( $customer->id > 0 ) {
1828
-				foreach ( $user_info as $key => $value ) {
1829
-					if ( ! empty( $value ) ) {
1826
+			$customer = new Give_Customer($this->customer_id);
1827
+			if ($customer->id > 0) {
1828
+				foreach ($user_info as $key => $value) {
1829
+					if ( ! empty($value)) {
1830 1830
 						continue;
1831 1831
 					}
1832 1832
 
1833
-					switch ( $key ) {
1833
+					switch ($key) {
1834 1834
 						case 'first_name':
1835
-							$name = explode( ' ', $customer->name, 2 );
1835
+							$name = explode(' ', $customer->name, 2);
1836 1836
 
1837
-							$user_info[ $key ] = $name[0];
1837
+							$user_info[$key] = $name[0];
1838 1838
 							break;
1839 1839
 
1840 1840
 						case 'last_name':
1841
-							$name      = explode( ' ', $customer->name, 2 );
1842
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
1841
+							$name      = explode(' ', $customer->name, 2);
1842
+							$last_name = ! empty($name[1]) ? $name[1] : '';
1843 1843
 
1844
-							$user_info[ $key ] = $last_name;
1844
+							$user_info[$key] = $last_name;
1845 1845
 							break;
1846 1846
 
1847 1847
 						case 'email':
1848
-							$user_info[ $key ] = $customer->email;
1848
+							$user_info[$key] = $customer->email;
1849 1849
 							break;
1850 1850
 					}
1851 1851
 				}
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 	 */
1866 1866
 	private function setup_address() {
1867 1867
 
1868
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
1868
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
1869 1869
 			'line1'   => '',
1870 1870
 			'line2'   => '',
1871 1871
 			'city'    => '',
@@ -1885,7 +1885,7 @@  discard block
 block discarded – undo
1885 1885
 	 */
1886 1886
 	private function setup_form_title() {
1887 1887
 
1888
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1888
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1889 1889
 
1890 1890
 		return $form_id;
1891 1891
 	}
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 	 */
1899 1899
 	private function setup_form_id() {
1900 1900
 
1901
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1901
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1902 1902
 
1903 1903
 		return $form_id;
1904 1904
 	}
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 	 * @return int The Form Price ID
1911 1911
 	 */
1912 1912
 	private function setup_price_id() {
1913
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1913
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1914 1914
 
1915 1915
 		return $price_id;
1916 1916
 	}
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 	 * @return string The Payment Key
1923 1923
 	 */
1924 1924
 	private function setup_payment_key() {
1925
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1925
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1926 1926
 
1927 1927
 		return $key;
1928 1928
 	}
@@ -1936,11 +1936,11 @@  discard block
 block discarded – undo
1936 1936
 	private function setup_payment_number() {
1937 1937
 		$number = $this->ID;
1938 1938
 
1939
-		if ( give_get_option( 'enable_sequential' ) ) {
1939
+		if (give_get_option('enable_sequential')) {
1940 1940
 
1941
-			$number = $this->get_meta( '_give_payment_number', true );
1941
+			$number = $this->get_meta('_give_payment_number', true);
1942 1942
 
1943
-			if ( ! $number ) {
1943
+			if ( ! $number) {
1944 1944
 
1945 1945
 				$number = $this->ID;
1946 1946
 
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 	 * @return array The payment object as an array
1958 1958
 	 */
1959 1959
 	public function array_convert() {
1960
-		return get_object_vars( $this );
1960
+		return get_object_vars($this);
1961 1961
 	}
1962 1962
 
1963 1963
 	/**
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 	 * @return string Date payment was completed
1968 1968
 	 */
1969 1969
 	private function get_completed_date() {
1970
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1970
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1971 1971
 	}
1972 1972
 
1973 1973
 	/**
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 	 * @return float Payment subtotal
1978 1978
 	 */
1979 1979
 	private function get_subtotal() {
1980
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
1980
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
1981 1981
 	}
1982 1982
 
1983 1983
 	/**
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 	 * @return string Payment currency code
1988 1988
 	 */
1989 1989
 	private function get_currency() {
1990
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
1990
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
1991 1991
 	}
1992 1992
 
1993 1993
 	/**
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
 	 * @return string Gateway used
1998 1998
 	 */
1999 1999
 	private function get_gateway() {
2000
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2000
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2001 2001
 	}
2002 2002
 
2003 2003
 	/**
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
 	 * @return string Transaction ID from merchant processor
2008 2008
 	 */
2009 2009
 	private function get_transaction_id() {
2010
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2010
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2011 2011
 	}
2012 2012
 
2013 2013
 	/**
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 	 * @return string Payment IP address
2018 2018
 	 */
2019 2019
 	private function get_ip() {
2020
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2020
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2021 2021
 	}
2022 2022
 
2023 2023
 	/**
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 	 * @return int Payment customer ID
2028 2028
 	 */
2029 2029
 	private function get_customer_id() {
2030
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2030
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2031 2031
 	}
2032 2032
 
2033 2033
 	/**
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 	 * @return int Payment user ID
2038 2038
 	 */
2039 2039
 	private function get_user_id() {
2040
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2040
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2041 2041
 	}
2042 2042
 
2043 2043
 	/**
@@ -2047,7 +2047,7 @@  discard block
 block discarded – undo
2047 2047
 	 * @return string Payment customer email
2048 2048
 	 */
2049 2049
 	private function get_email() {
2050
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2050
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2051 2051
 	}
2052 2052
 
2053 2053
 	/**
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
 	 * @return array Payment user info
2058 2058
 	 */
2059 2059
 	private function get_user_info() {
2060
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2060
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2061 2061
 	}
2062 2062
 
2063 2063
 	/**
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
 	 * @return array Payment billing address
2068 2068
 	 */
2069 2069
 	private function get_address() {
2070
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2070
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2071 2071
 	}
2072 2072
 
2073 2073
 	/**
@@ -2077,7 +2077,7 @@  discard block
 block discarded – undo
2077 2077
 	 * @return string Payment key
2078 2078
 	 */
2079 2079
 	private function get_key() {
2080
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2080
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2081 2081
 	}
2082 2082
 
2083 2083
 	/**
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
 	 * @return string Payment key
2088 2088
 	 */
2089 2089
 	private function get_form_id() {
2090
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2090
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2091 2091
 	}
2092 2092
 
2093 2093
 	/**
@@ -2097,7 +2097,7 @@  discard block
 block discarded – undo
2097 2097
 	 * @return int|string Payment number
2098 2098
 	 */
2099 2099
 	private function get_number() {
2100
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2100
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2101 2101
 	}
2102 2102
 
2103 2103
 }
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
  * @uses  load_template()
52 52
  * @uses  get_template_part()
53 53
  */
54
-function give_get_template_part( $slug, $name = null, $load = true ) {
54
+function give_get_template_part($slug, $name = null, $load = true) {
55 55
 
56 56
 	// Execute code for this part
57
-	do_action( 'get_template_part_' . $slug, $slug, $name );
57
+	do_action('get_template_part_'.$slug, $slug, $name);
58 58
 
59 59
 	// Setup possible parts
60 60
 	$templates = array();
61
-	if ( isset( $name ) ) {
62
-		$templates[] = $slug . '-' . $name . '.php';
61
+	if (isset($name)) {
62
+		$templates[] = $slug.'-'.$name.'.php';
63 63
 	}
64
-	$templates[] = $slug . '.php';
64
+	$templates[] = $slug.'.php';
65 65
 
66 66
 	// Allow template parts to be filtered
67
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
67
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
68 68
 
69 69
 	// Return the part that is found
70
-	return give_locate_template( $templates, $load, false );
70
+	return give_locate_template($templates, $load, false);
71 71
 }
72 72
 
73 73
 /**
@@ -88,37 +88,37 @@  discard block
 block discarded – undo
88 88
  *
89 89
  * @return string The template filename if one is located.
90 90
  */
91
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
91
+function give_locate_template($template_names, $load = false, $require_once = true) {
92 92
 	// No file found yet
93 93
 	$located = false;
94 94
 
95 95
 	// Try to find a template file
96
-	foreach ( (array) $template_names as $template_name ) {
96
+	foreach ((array) $template_names as $template_name) {
97 97
 
98 98
 		// Continue if template is empty
99
-		if ( empty( $template_name ) ) {
99
+		if (empty($template_name)) {
100 100
 			continue;
101 101
 		}
102 102
 
103 103
 		// Trim off any slashes from the template name
104
-		$template_name = ltrim( $template_name, '/' );
104
+		$template_name = ltrim($template_name, '/');
105 105
 
106 106
 		// try locating this template file by looping through the template paths
107
-		foreach ( give_get_theme_template_paths() as $template_path ) {
107
+		foreach (give_get_theme_template_paths() as $template_path) {
108 108
 
109
-			if ( file_exists( $template_path . $template_name ) ) {
110
-				$located = $template_path . $template_name;
109
+			if (file_exists($template_path.$template_name)) {
110
+				$located = $template_path.$template_name;
111 111
 				break;
112 112
 			}
113 113
 		}
114 114
 
115
-		if ( $located ) {
115
+		if ($located) {
116 116
 			break;
117 117
 		}
118 118
 	}
119 119
 
120
-	if ( ( true == $load ) && ! empty( $located ) ) {
121
-		load_template( $located, $require_once );
120
+	if ((true == $load) && ! empty($located)) {
121
+		load_template($located, $require_once);
122 122
 	}
123 123
 
124 124
 	return $located;
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 	$template_dir = give_get_theme_template_dir_name();
136 136
 
137 137
 	$file_paths = array(
138
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
139
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
138
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
139
+		10  => trailingslashit(get_template_directory()).$template_dir,
140 140
 		100 => give_get_templates_dir()
141 141
 	);
142 142
 
143
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
143
+	$file_paths = apply_filters('give_template_paths', $file_paths);
144 144
 
145 145
 	// sort the file paths based on priority
146
-	ksort( $file_paths, SORT_NUMERIC );
146
+	ksort($file_paths, SORT_NUMERIC);
147 147
 
148
-	return array_map( 'trailingslashit', $file_paths );
148
+	return array_map('trailingslashit', $file_paths);
149 149
 }
150 150
 
151 151
 /**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
  * @return string
158 158
  */
159 159
 function give_get_theme_template_dir_name() {
160
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
160
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
161 161
 }
162 162
 
163 163
 /**
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
  * @return void
168 168
  */
169 169
 function give_version_in_header() {
170
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
170
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
171 171
 }
172 172
 
173
-add_action( 'wp_head', 'give_version_in_header' );
173
+add_action('wp_head', 'give_version_in_header');
174 174
 
175 175
 /**
176 176
  * Determines if we're currently on the Donations History page.
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  */
181 181
 function give_is_donation_history_page() {
182 182
 
183
-	$ret = is_page( give_get_option( 'history_page' ) );
183
+	$ret = is_page(give_get_option('history_page'));
184 184
 
185
-	return apply_filters( 'give_is_donation_history_page', $ret );
185
+	return apply_filters('give_is_donation_history_page', $ret);
186 186
 }
187 187
 
188 188
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  *
195 195
  * @return array Modified array of classes
196 196
  */
197
-function give_add_body_classes( $class ) {
197
+function give_add_body_classes($class) {
198 198
 	$classes = (array) $class;
199 199
 
200
-	if ( give_is_success_page() ) {
200
+	if (give_is_success_page()) {
201 201
 		$classes[] = 'give-success';
202 202
 		$classes[] = 'give-page';
203 203
 	}
204 204
 
205
-	if ( give_is_failed_transaction_page() ) {
205
+	if (give_is_failed_transaction_page()) {
206 206
 		$classes[] = 'give-failed-transaction';
207 207
 		$classes[] = 'give-page';
208 208
 	}
209 209
 
210
-	if ( give_is_donation_history_page() ) {
210
+	if (give_is_donation_history_page()) {
211 211
 		$classes[] = 'give-donation-history';
212 212
 		$classes[] = 'give-page';
213 213
 	}
214 214
 
215
-	if ( give_is_test_mode() ) {
215
+	if (give_is_test_mode()) {
216 216
 		$classes[] = 'give-test-mode';
217 217
 		$classes[] = 'give-page';
218 218
 	}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	//Theme-specific Classes used to prevent conflicts via CSS
221 221
 	$current_theme = wp_get_theme();
222 222
 
223
-	switch ( $current_theme->template ) {
223
+	switch ($current_theme->template) {
224 224
 
225 225
 		case 'Divi':
226 226
 			$classes[] = 'give-divi';
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 
235 235
 	}
236 236
 
237
-	return array_unique( $classes );
237
+	return array_unique($classes);
238 238
 }
239 239
 
240
-add_filter( 'body_class', 'give_add_body_classes' );
240
+add_filter('body_class', 'give_add_body_classes');
241 241
 
242 242
 
243 243
 /**
@@ -253,22 +253,22 @@  discard block
 block discarded – undo
253 253
  *
254 254
  * @return array
255 255
  */
256
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
257
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
256
+function give_add_post_class($classes, $class = '', $post_id = '') {
257
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
258 258
 		return $classes;
259 259
 	}
260 260
 
261 261
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
262 262
 
263
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
264
-		unset( $classes[ $key ] );
263
+	if (false !== ($key = array_search('hentry', $classes))) {
264
+		unset($classes[$key]);
265 265
 	}
266 266
 
267 267
 	return $classes;
268 268
 }
269 269
 
270 270
 
271
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
271
+add_filter('post_class', 'give_add_post_class', 20, 3);
272 272
 
273 273
 /**
274 274
  * Get the placeholder image URL for forms etc
@@ -278,84 +278,84 @@  discard block
 block discarded – undo
278 278
  */
279 279
 function give_get_placeholder_img_src() {
280 280
 
281
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
281
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
282 282
 
283
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
283
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
284 284
 }
285 285
 
286 286
 
287 287
 /**
288 288
  * Global
289 289
  */
290
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
290
+if ( ! function_exists('give_output_content_wrapper')) {
291 291
 
292 292
 	/**
293 293
 	 * Output the start of the page wrapper.
294 294
 	 */
295 295
 	function give_output_content_wrapper() {
296
-		give_get_template_part( 'global/wrapper-start' );
296
+		give_get_template_part('global/wrapper-start');
297 297
 	}
298 298
 }
299
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
299
+if ( ! function_exists('give_output_content_wrapper_end')) {
300 300
 
301 301
 	/**
302 302
 	 * Output the end of the page wrapper.
303 303
 	 */
304 304
 	function give_output_content_wrapper_end() {
305
-		give_get_template_part( 'global/wrapper-end' );
305
+		give_get_template_part('global/wrapper-end');
306 306
 	}
307 307
 }
308 308
 
309 309
 /**
310 310
  * Single Give Form
311 311
  */
312
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
312
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
313 313
 	function give_left_sidebar_pre_wrap() {
314
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
314
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
315 315
 	}
316 316
 }
317 317
 
318
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
318
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
319 319
 	function give_left_sidebar_post_wrap() {
320
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
320
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
321 321
 	}
322 322
 }
323 323
 
324
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
324
+if ( ! function_exists('give_get_forms_sidebar')) {
325 325
 	function give_get_forms_sidebar() {
326
-		give_get_template_part( 'single-give-form/sidebar' );
326
+		give_get_template_part('single-give-form/sidebar');
327 327
 	}
328 328
 }
329 329
 
330
-if ( ! function_exists( 'give_show_form_images' ) ) {
330
+if ( ! function_exists('give_show_form_images')) {
331 331
 
332 332
 	/**
333 333
 	 * Output the product image before the single product summary.
334 334
 	 */
335 335
 	function give_show_form_images() {
336
-		$featured_image_option = give_get_option( 'disable_form_featured_img' );
337
-		if ( $featured_image_option !== 'on' ) {
338
-			give_get_template_part( 'single-give-form/featured-image' );
336
+		$featured_image_option = give_get_option('disable_form_featured_img');
337
+		if ($featured_image_option !== 'on') {
338
+			give_get_template_part('single-give-form/featured-image');
339 339
 		}
340 340
 	}
341 341
 }
342 342
 
343
-if ( ! function_exists( 'give_template_single_title' ) ) {
343
+if ( ! function_exists('give_template_single_title')) {
344 344
 
345 345
 	/**
346 346
 	 * Output the product title.
347 347
 	 */
348 348
 	function give_template_single_title() {
349
-		give_get_template_part( 'single-give-form/title' );
349
+		give_get_template_part('single-give-form/title');
350 350
 	}
351 351
 }
352 352
 
353
-if ( ! function_exists( 'give_show_avatars' ) ) {
353
+if ( ! function_exists('give_show_avatars')) {
354 354
 
355 355
 	/**
356 356
 	 * Output the product title.
357 357
 	 */
358 358
 	function give_show_avatars() {
359
-		echo do_shortcode( '[give_donators_gravatars]' );
359
+		echo do_shortcode('[give_donators_gravatars]');
360 360
 	}
361 361
 }
362 362
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-logging.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function __construct() {
32 32
 		// Create the log post type
33
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
33
+		add_action('init', array($this, 'register_post_type'), 1);
34 34
 
35 35
 		// Create types taxonomy and default types
36
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
36
+		add_action('init', array($this, 'register_taxonomy'), 1);
37 37
 
38 38
 	}
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	public function register_post_type() {
48 48
 		/* Logs post type */
49 49
 		$log_args = array(
50
-			'labels'              => array( 'name' => esc_html__( 'Logs', 'give' ) ),
50
+			'labels'              => array('name' => esc_html__('Logs', 'give')),
51 51
 			'public'              => false,
52 52
 			'exclude_from_search' => true,
53 53
 			'publicly_queryable'  => false,
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 			'query_var'           => false,
56 56
 			'rewrite'             => false,
57 57
 			'capability_type'     => 'post',
58
-			'supports'            => array( 'title', 'editor' ),
58
+			'supports'            => array('title', 'editor'),
59 59
 			'can_export'          => true
60 60
 		);
61 61
 
62
-		register_post_type( 'give_log', $log_args );
62
+		register_post_type('give_log', $log_args);
63 63
 	}
64 64
 
65 65
 	/**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @return void
73 73
 	 */
74 74
 	public function register_taxonomy() {
75
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
75
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
76 76
 	}
77 77
 
78 78
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'api_request'
92 92
 		);
93 93
 
94
-		return apply_filters( 'give_log_types', $terms );
94
+		return apply_filters('give_log_types', $terms);
95 95
 	}
96 96
 
97 97
 	/**
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return bool Whether log type is valid
109 109
 	 */
110
-	function valid_type( $type ) {
111
-		return in_array( $type, $this->log_types() );
110
+	function valid_type($type) {
111
+		return in_array($type, $this->log_types());
112 112
 	}
113 113
 
114 114
 	/**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return int Log ID
130 130
 	 */
131
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
131
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
132 132
 		$log_data = array(
133 133
 			'post_title'   => $title,
134 134
 			'post_content' => $message,
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			'log_type'     => $type
137 137
 		);
138 138
 
139
-		return $this->insert_log( $log_data );
139
+		return $this->insert_log($log_data);
140 140
 	}
141 141
 
142 142
 	/**
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return array Array of the connected logs
154 154
 	 */
155
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
156
-		return $this->get_connected_logs( array(
155
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
156
+		return $this->get_connected_logs(array(
157 157
 			'post_parent' => $object_id,
158 158
 			'paged'       => $paged,
159 159
 			'log_type'    => $type
160
-		) );
160
+		));
161 161
 	}
162 162
 
163 163
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return int The ID of the newly created log item
174 174
 	 */
175
-	function insert_log( $log_data = array(), $log_meta = array() ) {
175
+	function insert_log($log_data = array(), $log_meta = array()) {
176 176
 		$defaults = array(
177 177
 			'post_type'    => 'give_log',
178 178
 			'post_status'  => 'publish',
@@ -181,26 +181,26 @@  discard block
 block discarded – undo
181 181
 			'log_type'     => false
182 182
 		);
183 183
 
184
-		$args = wp_parse_args( $log_data, $defaults );
184
+		$args = wp_parse_args($log_data, $defaults);
185 185
 
186
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
186
+		do_action('give_pre_insert_log', $log_data, $log_meta);
187 187
 
188 188
 		// Store the log entry
189
-		$log_id = wp_insert_post( $args );
189
+		$log_id = wp_insert_post($args);
190 190
 
191 191
 		// Set the log type, if any
192
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
193
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
192
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
193
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
194 194
 		}
195 195
 
196 196
 		// Set log meta, if any
197
-		if ( $log_id && ! empty( $log_meta ) ) {
198
-			foreach ( (array) $log_meta as $key => $meta ) {
199
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
197
+		if ($log_id && ! empty($log_meta)) {
198
+			foreach ((array) $log_meta as $key => $meta) {
199
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
200 200
 			}
201 201
 		}
202 202
 
203
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
203
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
204 204
 
205 205
 		return $log_id;
206 206
 	}
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @return bool True if successful, false otherwise
218 218
 	 */
219
-	public function update_log( $log_data = array(), $log_meta = array() ) {
219
+	public function update_log($log_data = array(), $log_meta = array()) {
220 220
 
221
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
221
+		do_action('give_pre_update_log', $log_data, $log_meta);
222 222
 
223 223
 		$defaults = array(
224 224
 			'post_type'   => 'give_log',
@@ -226,20 +226,20 @@  discard block
 block discarded – undo
226 226
 			'post_parent' => 0
227 227
 		);
228 228
 
229
-		$args = wp_parse_args( $log_data, $defaults );
229
+		$args = wp_parse_args($log_data, $defaults);
230 230
 
231 231
 		// Store the log entry
232
-		$log_id = wp_update_post( $args );
232
+		$log_id = wp_update_post($args);
233 233
 
234
-		if ( $log_id && ! empty( $log_meta ) ) {
235
-			foreach ( (array) $log_meta as $key => $meta ) {
236
-				if ( ! empty( $meta ) ) {
237
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
234
+		if ($log_id && ! empty($log_meta)) {
235
+			foreach ((array) $log_meta as $key => $meta) {
236
+				if ( ! empty($meta)) {
237
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
238 238
 				}
239 239
 			}
240 240
 		}
241 241
 
242
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
242
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
243 243
 	}
244 244
 
245 245
 	/**
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @return mixed array if logs were found, false otherwise
256 256
 	 */
257
-	public function get_connected_logs( $args = array() ) {
257
+	public function get_connected_logs($args = array()) {
258 258
 
259 259
 		$defaults = array(
260 260
 			'post_type'      => 'give_log',
261 261
 			'posts_per_page' => 20,
262 262
 			'post_status'    => 'publish',
263
-			'paged'          => get_query_var( 'paged' ),
263
+			'paged'          => get_query_var('paged'),
264 264
 			'log_type'       => false
265 265
 		);
266 266
 
267
-		$query_args = wp_parse_args( $args, $defaults );
267
+		$query_args = wp_parse_args($args, $defaults);
268 268
 
269
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
269
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
270 270
 			$query_args['tax_query'] = array(
271 271
 				array(
272 272
 					'taxonomy' => 'give_log_type',
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 			);
277 277
 		}
278 278
 		
279
-		$logs = get_posts( $query_args );
279
+		$logs = get_posts($query_args);
280 280
 	
281
-		if ( $logs ) {
281
+		if ($logs) {
282 282
 			return $logs;
283 283
 		}
284 284
 
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return int Log count
301 301
 	 */
302
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
302
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
303 303
 
304 304
 		$query_args = array(
305 305
 			'post_parent'    => $object_id,
306 306
 			'post_type'      => 'give_log',
307
-			'posts_per_page' => - 1,
307
+			'posts_per_page' => -1,
308 308
 			'post_status'    => 'publish',
309 309
 			'fields'         => 'ids',
310 310
 		);
311 311
 
312
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
312
+		if ( ! empty($type) && $this->valid_type($type)) {
313 313
 			$query_args['tax_query'] = array(
314 314
 				array(
315 315
 					'taxonomy' => 'give_log_type',
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 			);
320 320
 		}
321 321
 
322
-		if ( ! empty( $meta_query ) ) {
322
+		if ( ! empty($meta_query)) {
323 323
 			$query_args['meta_query'] = $meta_query;
324 324
 		}
325 325
 
326
-		if ( ! empty( $date_query ) ) {
326
+		if ( ! empty($date_query)) {
327 327
 			$query_args['date_query'] = $date_query;
328 328
 		}
329 329
 
330
-		$logs = new WP_Query( $query_args );
330
+		$logs = new WP_Query($query_args);
331 331
 
332 332
 		return (int) $logs->post_count;
333 333
 	}
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @return void
347 347
 	 */
348
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) {
348
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
349 349
 		$query_args = array(
350 350
 			'post_parent'    => $object_id,
351 351
 			'post_type'      => 'give_log',
352
-			'posts_per_page' => - 1,
352
+			'posts_per_page' => -1,
353 353
 			'post_status'    => 'publish',
354 354
 			'fields'         => 'ids'
355 355
 		);
356 356
 
357
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
357
+		if ( ! empty($type) && $this->valid_type($type)) {
358 358
 			$query_args['tax_query'] = array(
359 359
 				array(
360 360
 					'taxonomy' => 'give_log_type',
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 			);
365 365
 		}
366 366
 
367
-		if ( ! empty( $meta_query ) ) {
367
+		if ( ! empty($meta_query)) {
368 368
 			$query_args['meta_query'] = $meta_query;
369 369
 		}
370 370
 
371
-		$logs = get_posts( $query_args );
371
+		$logs = get_posts($query_args);
372 372
 
373
-		if ( $logs ) {
374
-			foreach ( $logs as $log ) {
375
-				wp_delete_post( $log, true );
373
+		if ($logs) {
374
+			foreach ($logs as $log) {
375
+				wp_delete_post($log, true);
376 376
 			}
377 377
 		}
378 378
 	}
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return mixed ID of the new log entry
402 402
  */
403
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
403
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
404 404
 	global $give_logs;
405
-	$log = $give_logs->add( $title, $message, $parent, $type );
405
+	$log = $give_logs->add($title, $message, $parent, $type);
406 406
 
407 407
 	return $log;
408 408
 }
409 409
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => esc_html__( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => esc_html__( 'PayPal', 'give' ),
29
-			'supports'       => array( 'buy_now' )
27
+			'admin_label'    => esc_html__('PayPal Standard', 'give'),
28
+			'checkout_label' => esc_html__('PayPal', 'give'),
29
+			'supports'       => array('buy_now')
30 30
 		),
31 31
 		'manual' => array(
32
-			'admin_label'    => esc_html__( 'Test Payment', 'give' ),
33
-			'checkout_label' => esc_html__( 'Test Payment', 'give' )
32
+			'admin_label'    => esc_html__('Test Payment', 'give'),
33
+			'checkout_label' => esc_html__('Test Payment', 'give')
34 34
 		),
35 35
 	);
36 36
 
37
-	return apply_filters( 'give_payment_gateways', $gateways );
37
+	return apply_filters('give_payment_gateways', $gateways);
38 38
 
39 39
 }
40 40
 
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 
49 49
 	$gateways = give_get_payment_gateways();
50 50
 
51
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
51
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
52 52
 
53 53
 	$gateway_list = array();
54 54
 
55
-	foreach ( $gateways as $key => $gateway ) {
56
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
57
-			$gateway_list[ $key ] = $gateway;
55
+	foreach ($gateways as $key => $gateway) {
56
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
57
+			$gateway_list[$key] = $gateway;
58 58
 		}
59 59
 	}
60 60
 
61 61
 	// Set order of payment gateway in list.
62
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
62
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
63 63
 
64
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list );
64
+	return apply_filters('give_enabled_payment_gateways', $gateway_list);
65 65
 }
66 66
 
67 67
 /**
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return boolean true if enabled, false otherwise
75 75
  */
76
-function give_is_gateway_active( $gateway ) {
76
+function give_is_gateway_active($gateway) {
77 77
 	$gateways = give_get_enabled_payment_gateways();
78 78
 
79
-	$ret = array_key_exists( $gateway, $gateways );
79
+	$ret = array_key_exists($gateway, $gateways);
80 80
 
81
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
81
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
82 82
 }
83 83
 
84 84
 /**
@@ -91,24 +91,24 @@  discard block
 block discarded – undo
91 91
  *
92 92
  * @return string Gateway ID
93 93
  */
94
-function give_get_default_gateway( $form_id ) {
94
+function give_get_default_gateway($form_id) {
95 95
 
96 96
 	global $give_options;
97 97
 
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = get_post_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = get_post_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	//Single Form settings varies compared to the Global default settings
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 	     $form_id !== null &&
104 104
 	     $default !== $form_default &&
105 105
 	     $form_default !== 'global' &&
106
-	     give_is_gateway_active( $form_default )
106
+	     give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_enabled_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_get_payment_amount( $payment ) == 0 ) {
130
-			$label = esc_html__( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_get_payment_amount($payment) == 0) {
130
+			$label = esc_html__('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_enabled_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = esc_html__( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = esc_html__('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return bool
181 181
  */
182
-function give_gateway_supports_buy_now( $gateway ) {
183
-	$supports = give_get_gateway_supports( $gateway );
184
-	$ret      = in_array( 'buy_now', $supports );
182
+function give_gateway_supports_buy_now($gateway) {
183
+	$supports = give_get_gateway_supports($gateway);
184
+	$ret      = in_array('buy_now', $supports);
185 185
 
186
-	return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway );
186
+	return apply_filters('give_gateway_supports_buy_now', $ret, $gateway);
187 187
 }
188 188
 
189 189
 /**
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	$gateways = give_get_enabled_payment_gateways();
197 197
 	$ret      = false;
198 198
 
199
-	if ( $gateways ) {
200
-		foreach ( $gateways as $gateway_id => $gateway ) {
201
-			if ( give_gateway_supports_buy_now( $gateway_id ) ) {
199
+	if ($gateways) {
200
+		foreach ($gateways as $gateway_id => $gateway) {
201
+			if (give_gateway_supports_buy_now($gateway_id)) {
202 202
 				$ret = true;
203 203
 				break;
204 204
 			}
205 205
 		}
206 206
 	}
207 207
 
208
-	return apply_filters( 'give_give_supports_buy_now', $ret );
208
+	return apply_filters('give_give_supports_buy_now', $ret);
209 209
 }
210 210
 
211 211
 /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return void
220 220
  */
221
-function give_send_to_gateway( $gateway, $payment_data ) {
221
+function give_send_to_gateway($gateway, $payment_data) {
222 222
 
223
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
223
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
224 224
 
225 225
 	// $gateway must match the ID used when registering the gateway
226
-	do_action( 'give_gateway_' . $gateway, $payment_data );
226
+	do_action('give_gateway_'.$gateway, $payment_data);
227 227
 }
228 228
 
229 229
 
@@ -240,32 +240,32 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @return string $enabled_gateway The slug of the gateway
242 242
  */
243
-function give_get_chosen_gateway( $form_id ) {
243
+function give_get_chosen_gateway($form_id) {
244 244
 	$gateways        = give_get_enabled_payment_gateways();
245
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
246
-	if ( empty( $request_form_id ) ) {
247
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
245
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
246
+	if (empty($request_form_id)) {
247
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
248 248
 	}
249
-	$chosen          = give_get_default_gateway( $form_id );
249
+	$chosen          = give_get_default_gateway($form_id);
250 250
 	$enabled_gateway = '';
251 251
 
252 252
 	//Take into account request Form ID args
253
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
253
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
254 254
 		$chosen = $_REQUEST['payment-mode'];
255 255
 	}
256 256
 
257
-	if ( $chosen ) {
258
-		$enabled_gateway = urldecode( $chosen );
259
-	} else if ( count( $gateways ) >= 1 && ! $chosen ) {
260
-		foreach ( $gateways as $gateway_id => $gateway ):
257
+	if ($chosen) {
258
+		$enabled_gateway = urldecode($chosen);
259
+	} else if (count($gateways) >= 1 && ! $chosen) {
260
+		foreach ($gateways as $gateway_id => $gateway):
261 261
 			$enabled_gateway = $gateway_id;
262 262
 		endforeach;
263 263
 	} else {
264
-		$enabled_gateway = give_get_default_gateway( $form_id );
264
+		$enabled_gateway = give_get_default_gateway($form_id);
265 265
 	}
266 266
 
267 267
 
268
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
268
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
269 269
 }
270 270
 
271 271
 /**
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @return int ID of the new log entry
284 284
  */
285
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
286
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
285
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
286
+	return give_record_log($title, $message, $parent, 'gateway_error');
287 287
 }
288 288
 
289 289
 /**
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @return int
298 298
  */
299
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
299
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
300 300
 
301 301
 	$ret  = 0;
302 302
 	$args = array(
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
 		'fields'      => 'ids'
309 309
 	);
310 310
 
311
-	$payments = new WP_Query( $args );
311
+	$payments = new WP_Query($args);
312 312
 
313
-	if ( $payments ) {
313
+	if ($payments) {
314 314
 		$ret = $payments->post_count;
315 315
 	}
316 316
 
@@ -327,27 +327,27 @@  discard block
 block discarded – undo
327 327
  *
328 328
  * @return array $gateways All the available gateways
329 329
  */
330
-function give_get_ordered_payment_gateways( $gateways ) {
330
+function give_get_ordered_payment_gateways($gateways) {
331 331
 
332 332
 	//  Get gateways setting.
333
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
333
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
334 334
 
335 335
 	// Return from here if we do not have gateways setting.
336
-	if ( empty( $gateways_setting ) ) {
336
+	if (empty($gateways_setting)) {
337 337
 		return $gateways;
338 338
 	}
339 339
 
340 340
 	// Reverse array to order payment gateways.
341
-	$gateways_setting = array_reverse( $gateways_setting );
341
+	$gateways_setting = array_reverse($gateways_setting);
342 342
 
343 343
 	// Reorder gateways array
344
-	foreach ( $gateways_setting as $gateway_key => $value ) {
344
+	foreach ($gateways_setting as $gateway_key => $value) {
345 345
 
346
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
347
-		unset( $gateways[ $gateway_key ] );
346
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
347
+		unset($gateways[$gateway_key]);
348 348
 
349
-		if(!empty($new_gateway_value)) {
350
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
349
+		if ( ! empty($new_gateway_value)) {
350
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
351 351
 		}
352 352
 	}
353 353
 
@@ -358,5 +358,5 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @param array $gateways All the available gateways
360 360
 	 */
361
-	return apply_filters( 'give_payment_gateways_order', $gateways );
361
+	return apply_filters('give_payment_gateways_order', $gateways);
362 362
 }
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
  * @return void
38 38
  */
39 39
 function give_load_ajax_gateway() {
40
-	if ( isset( $_POST['give_payment_mode'] ) ) {
41
-		do_action( 'give_purchase_form', $_POST['give_form_id'] );
40
+	if (isset($_POST['give_payment_mode'])) {
41
+		do_action('give_purchase_form', $_POST['give_form_id']);
42 42
 		exit();
43 43
 	}
44 44
 }
45 45
 
46
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
47
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
46
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
47
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
48 48
 
49 49
 /**
50 50
  * Sets an error on checkout if no gateways are enabled
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 function give_no_gateway_error() {
56 56
 	$gateways = give_get_enabled_payment_gateways();
57 57
 
58
-	if ( empty( $gateways ) ) {
59
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
58
+	if (empty($gateways)) {
59
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
60 60
 	} else {
61
-		give_unset_error( 'no_gateways' );
61
+		give_unset_error('no_gateways');
62 62
 	}
63 63
 }
64 64
 
65
-add_action( 'init', 'give_no_gateway_error' );
66 65
\ No newline at end of file
66
+add_action('init', 'give_no_gateway_error');
67 67
\ No newline at end of file
Please login to merge, or discard this patch.