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/error-tracking.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
  *
66 66
  * @since 1.0
67 67
  * @uses  Give_Session::get()
68
- * @return mixed array if errors are present, false if none found
68
+ * @return string array if errors are present, false if none found
69 69
  */
70 70
 function give_get_errors() {
71 71
 	return Give()->session->get( 'give_errors' );
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 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
 
@@ -29,33 +29,33 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @return void
31 31
  */
32
-function give_print_errors( $form_id ) {
32
+function give_print_errors($form_id) {
33 33
 
34 34
 	$errors = give_get_errors();
35 35
 
36
-	$request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0;
36
+	$request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0;
37 37
 
38 38
 	//Sanity checks first: Ensure that gateway returned errors display on the appropriate form
39
-	if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
39
+	if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
40 40
 		return;
41 41
 	}
42 42
 
43
-	if ( $errors ) {
44
-		$classes = apply_filters( 'give_error_class', array(
43
+	if ($errors) {
44
+		$classes = apply_filters('give_error_class', array(
45 45
 			'give_errors'
46
-		) );
47
-		echo '<div class="' . implode( ' ', $classes ) . '">';
46
+		));
47
+		echo '<div class="'.implode(' ', $classes).'">';
48 48
 		// Loop error codes and display errors
49
-		foreach ( $errors as $error_id => $error ) {
50
-			echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>';
49
+		foreach ($errors as $error_id => $error) {
50
+			echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>';
51 51
 		}
52 52
 		echo '</div>';
53 53
 		give_clear_errors();
54 54
 	}
55 55
 }
56 56
 
57
-add_action( 'give_purchase_form_before_personal_info', 'give_print_errors' );
58
-add_action( 'give_ajax_checkout_errors', 'give_print_errors' );
57
+add_action('give_purchase_form_before_personal_info', 'give_print_errors');
58
+add_action('give_ajax_checkout_errors', 'give_print_errors');
59 59
 
60 60
 /**
61 61
  * Get Errors
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * @return mixed array if errors are present, false if none found
69 69
  */
70 70
 function give_get_errors() {
71
-	return Give()->session->get( 'give_errors' );
71
+	return Give()->session->get('give_errors');
72 72
 }
73 73
 
74 74
 /**
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @return void
86 86
  */
87
-function give_set_error( $error_id, $error_message ) {
87
+function give_set_error($error_id, $error_message) {
88 88
 	$errors = give_get_errors();
89
-	if ( ! $errors ) {
89
+	if ( ! $errors) {
90 90
 		$errors = array();
91 91
 	}
92
-	$errors[ $error_id ] = $error_message;
93
-	Give()->session->set( 'give_errors', $errors );
92
+	$errors[$error_id] = $error_message;
93
+	Give()->session->set('give_errors', $errors);
94 94
 }
95 95
 
96 96
 /**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
  * @return void
102 102
  */
103 103
 function give_clear_errors() {
104
-	Give()->session->set( 'give_errors', null );
104
+	Give()->session->set('give_errors', null);
105 105
 }
106 106
 
107 107
 /**
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return string
116 116
  */
117
-function give_unset_error( $error_id ) {
117
+function give_unset_error($error_id) {
118 118
 	$errors = give_get_errors();
119
-	if ( $errors ) {
120
-		unset( $errors[ $error_id ] );
121
-		Give()->session->set( 'give_errors', $errors );
119
+	if ($errors) {
120
+		unset($errors[$error_id]);
121
+		Give()->session->set('give_errors', $errors);
122 122
 	}
123 123
 }
124 124
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  * @return void
130 130
  */
131 131
 function _give_die_handler() {
132
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
132
+	if (defined('GIVE_UNIT_TESTS')) {
133 133
 		return '_give_die_handler';
134 134
 	} else {
135 135
 		die();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
  * @since  1.0
145 145
  * @return void
146 146
  */
147
-function give_die( $message = '', $title = '', $status = 400 ) {
148
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
149
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
150
-	wp_die( $message, $title, array( 'response' => $status ) );
147
+function give_die($message = '', $title = '', $status = 400) {
148
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
149
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
150
+	wp_die($message, $title, array('response' => $status));
151 151
 }
152 152
 
153 153
 /**
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
  *
163 163
  * @return   string  $error
164 164
  */
165
-function give_output_error( $message, $echo = true, $error_id = 'warning' ) {
166
-	$error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error  give_' . $error_id . '">' . $message . '</p></div>';
165
+function give_output_error($message, $echo = true, $error_id = 'warning') {
166
+	$error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error  give_'.$error_id.'">'.$message.'</p></div>';
167 167
 
168
-	if ( $echo ) {
168
+	if ($echo) {
169 169
 		echo $error;
170 170
 	} else {
171 171
 		return $error;
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
-    }
36
+	if ( empty( $logout_redirect ) ) {
37
+		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
+	}
39 39
 
40 40
 
41
-    // Add user_logout action to logout url.
42
-    $logout_redirect = add_query_arg(
43
-        array(
44
-            'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
47
-        ),
48
-        home_url('/')
49
-    );
41
+	// Add user_logout action to logout url.
42
+	$logout_redirect = add_query_arg(
43
+		array(
44
+			'give_action'       => 'user_logout',
45
+			'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
+			'give_logout_redirect' => urlencode( $logout_redirect )
47
+		),
48
+		home_url('/')
49
+	);
50 50
 
51 51
 	$give_login_redirect = $login_redirect;
52 52
 	$give_logout_redirect = $logout_redirect;
@@ -136,23 +136,23 @@  discard block
 block discarded – undo
136 136
  * @return void
137 137
  */
138 138
 function give_process_user_logout( $data ) {
139
-    if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
139
+	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
140 140
 
141
-        // Prevent occurring of any custom action on wp_logout.
142
-        remove_all_actions( 'wp_logout' );
141
+		// Prevent occurring of any custom action on wp_logout.
142
+		remove_all_actions( 'wp_logout' );
143 143
 
144
-        // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
144
+		// Before logout give action.
145
+		do_action( 'give_before_user_logout' );
146 146
 
147
-        // Logout user.
148
-        wp_logout();
147
+		// Logout user.
148
+		wp_logout();
149 149
 
150
-        // After logout give action.
151
-        do_action( 'give_after_user_logout' );
150
+		// After logout give action.
151
+		do_action( 'give_after_user_logout' );
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
154
-        give_die();
155
-    }
153
+		wp_redirect( $data['give_logout_redirect'] );
154
+		give_die();
155
+	}
156 156
 }
157 157
 
158 158
 add_action( 'give_user_logout', 'give_process_user_logout' );
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 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
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	global $give_login_redirect, $give_logout_redirect;;
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	global $give_login_redirect, $give_logout_redirect; ;
31 31
 
32
-	if ( empty( $login_redirect ) ) {
32
+	if (empty($login_redirect)) {
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
36
+    if (empty($logout_redirect)) {
37
+        $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
38 38
     }
39 39
 
40 40
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $logout_redirect = add_query_arg(
43 43
         array(
44 44
             'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
45
+            'give_logout_nonce' => wp_create_nonce('give-logout-nonce'),
46
+            'give_logout_redirect' => urlencode($logout_redirect)
47 47
         ),
48 48
         home_url('/')
49 49
     );
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
 	ob_start();
55 55
 
56
-	give_get_template_part( 'shortcode', 'login' );
56
+	give_get_template_part('shortcode', 'login');
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @return string Register form
71 71
  */
72
-function give_register_form( $redirect = '' ) {
72
+function give_register_form($redirect = '') {
73 73
 	global $give_options, $give_register_redirect;
74 74
 
75
-	if ( empty( $redirect ) ) {
75
+	if (empty($redirect)) {
76 76
 		$redirect = give_get_current_page_url();
77 77
 	}
78 78
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 
81 81
 	ob_start();
82 82
 
83
-	if ( ! is_user_logged_in() ) {
84
-		give_get_template_part( 'shortcode', 'register' );
83
+	if ( ! is_user_logged_in()) {
84
+		give_get_template_part('shortcode', 'register');
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,27 +135,27 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-    if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+    if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
         // Prevent occurring of any custom action on wp_logout.
142
-        remove_all_actions( 'wp_logout' );
142
+        remove_all_actions('wp_logout');
143 143
 
144 144
         // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
145
+        do_action('give_before_user_logout');
146 146
 
147 147
         // Logout user.
148 148
         wp_logout();
149 149
 
150 150
         // After logout give action.
151
-        do_action( 'give_after_user_logout' );
151
+        do_action('give_after_user_logout');
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
153
+        wp_redirect($data['give_logout_redirect']);
154 154
         give_die();
155 155
     }
156 156
 }
157 157
 
158
-add_action( 'give_user_logout', 'give_process_user_logout' );
158
+add_action('give_user_logout', 'give_process_user_logout');
159 159
 
160 160
 /**
161 161
  * Log User In
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return void
170 170
  */
171
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
172
-	if ( $user_id < 1 ) {
171
+function give_log_user_in($user_id, $user_login, $user_pass) {
172
+	if ($user_id < 1) {
173 173
 		return;
174 174
 	}
175 175
 
176
-	wp_set_auth_cookie( $user_id );
177
-	wp_set_current_user( $user_id, $user_login );
178
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
179
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
176
+	wp_set_auth_cookie($user_id);
177
+	wp_set_current_user($user_id, $user_login);
178
+	do_action('wp_login', $user_login, get_userdata($user_id));
179
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
180 180
 }
181 181
 
182 182
 
@@ -189,70 +189,70 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_process_register_form( $data ) {
192
+function give_process_register_form($data) {
193 193
 
194
-	if ( is_user_logged_in() ) {
194
+	if (is_user_logged_in()) {
195 195
 		return;
196 196
 	}
197 197
 
198
-	if ( empty( $_POST['give_register_submit'] ) ) {
198
+	if (empty($_POST['give_register_submit'])) {
199 199
 		return;
200 200
 	}
201 201
 
202
-	do_action( 'give_pre_process_register_form' );
202
+	do_action('give_pre_process_register_form');
203 203
 
204
-	if ( empty( $data['give_user_login'] ) ) {
205
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
204
+	if (empty($data['give_user_login'])) {
205
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
206 206
 	}
207 207
 
208
-	if ( username_exists( $data['give_user_login'] ) ) {
209
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
208
+	if (username_exists($data['give_user_login'])) {
209
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
210 210
 	}
211 211
 
212
-	if ( ! validate_username( $data['give_user_login'] ) ) {
213
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
212
+	if ( ! validate_username($data['give_user_login'])) {
213
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
214 214
 	}
215 215
 
216
-	if ( email_exists( $data['give_user_email'] ) ) {
217
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
216
+	if (email_exists($data['give_user_email'])) {
217
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
218 218
 	}
219 219
 
220
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
221
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
220
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
221
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
222 222
 	}
223 223
 
224
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
225
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
224
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
225
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
226 226
 	}
227 227
 
228
-	if ( empty( $_POST['give_user_pass'] ) ) {
229
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
228
+	if (empty($_POST['give_user_pass'])) {
229
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
230 230
 	}
231 231
 
232
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
233
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
232
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
233
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
234 234
 	}
235 235
 
236
-	do_action( 'give_process_register_form' );
236
+	do_action('give_process_register_form');
237 237
 
238 238
 	// Check for errors and redirect if none present
239 239
 	$errors = give_get_errors();
240 240
 
241
-	if ( empty( $errors ) ) {
241
+	if (empty($errors)) {
242 242
 
243
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
243
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
244 244
 
245
-		give_register_and_login_new_user( array(
245
+		give_register_and_login_new_user(array(
246 246
 			'user_login'      => $data['give_user_login'],
247 247
 			'user_pass'       => $data['give_user_pass'],
248 248
 			'user_email'      => $data['give_user_email'],
249
-			'user_registered' => date( 'Y-m-d H:i:s' ),
250
-			'role'            => get_option( 'default_role' )
251
-		) );
249
+			'user_registered' => date('Y-m-d H:i:s'),
250
+			'role'            => get_option('default_role')
251
+		));
252 252
 
253
-		wp_redirect( $redirect );
253
+		wp_redirect($redirect);
254 254
 		give_die();
255 255
 	}
256 256
 }
257 257
 
258
-add_action( 'give_user_register', 'give_process_register_form' );
259 258
\ No newline at end of file
259
+add_action('give_user_register', 'give_process_register_form');
260 260
\ No newline at end of file
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 	 * Determines whether results should be displayed in XML or JSON
1438 1438
 	 *
1439 1439
 	 * @since 1.1
1440
-     * @access public
1440
+	 * @access public
1441 1441
 	 *
1442 1442
 	 * @return mixed|void
1443 1443
 	 */
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 *
1456 1456
 	 * @access private
1457 1457
 	 * @since  1.1
1458
-     *
1458
+	 *
1459 1459
 	 * @global Give_Logging $give_logs
1460 1460
 	 * @global WP_Query     $wp_query
1461 1461
 	 *
@@ -1468,15 +1468,15 @@  discard block
 block discarded – undo
1468 1468
 			return;
1469 1469
 		}
1470 1470
 
1471
-        /**
1472
-         * @var Give_Logging $give_logs
1473
-         */
1471
+		/**
1472
+		 * @var Give_Logging $give_logs
1473
+		 */
1474 1474
 		global $give_logs;
1475 1475
 
1476
-        /**
1477
-         * @var WP_Query $wp_query
1478
-         */
1479
-        global $wp_query;
1476
+		/**
1477
+		 * @var WP_Query $wp_query
1478
+		 */
1479
+		global $wp_query;
1480 1480
 
1481 1481
 		$query = array(
1482 1482
 			'give-api'    => $wp_query->query_vars['give-api'],
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
 	 * @param int $status_code
1535 1535
 	 */
1536 1536
 	public function output( $status_code = 200 ) {
1537
-        /**
1538
-         * @var WP_Query $wp_query
1539
-         */
1537
+		/**
1538
+		 * @var WP_Query $wp_query
1539
+		 */
1540 1540
 		global $wp_query;
1541 1541
 
1542 1542
 		$format = $this->get_output_format();
Please login to merge, or discard this patch.
Spacing   +482 added lines, -482 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
 
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 			'v1' => 'GIVE_API_V1',
141 141
 		);
142 142
 
143
-		foreach ( $this->get_versions() as $version => $class ) {
144
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
143
+		foreach ($this->get_versions() as $version => $class) {
144
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
145 145
 		}
146 146
 
147
-		add_action( 'init', array( $this, 'add_endpoint' ) );
148
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
149
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
150
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
153
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
154
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
147
+		add_action('init', array($this, 'add_endpoint'));
148
+		add_action('wp', array($this, 'process_query'), - 1);
149
+		add_filter('query_vars', array($this, 'query_vars'));
150
+		add_action('show_user_profile', array($this, 'user_key_field'));
151
+		add_action('edit_user_profile', array($this, 'user_key_field'));
152
+		add_action('personal_options_update', array($this, 'update_key'));
153
+		add_action('edit_user_profile_update', array($this, 'update_key'));
154
+		add_action('give_process_api_key', array($this, 'process_api_key'));
155 155
 
156 156
 		// Setup a backwards compatibility check for user API Keys
157
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
157
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
158 158
 
159 159
 		// Determine if JSON_PRETTY_PRINT is available
160
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
160
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
161 161
 
162 162
 		// Allow API request logging to be turned off
163
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
163
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
164 164
 
165 165
 		// Setup Give_Payment_Stats instance
166 166
 		$this->stats = new Give_Payment_Stats;
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @since  1.1
178 178
 	 */
179
-	public function add_endpoint( $rewrite_rules ) {
180
-		add_rewrite_endpoint( 'give-api', EP_ALL );
179
+	public function add_endpoint($rewrite_rules) {
180
+		add_rewrite_endpoint('give-api', EP_ALL);
181 181
 	}
182 182
 
183 183
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return string[] $vars New query vars
192 192
 	 */
193
-	public function query_vars( $vars ) {
193
+	public function query_vars($vars) {
194 194
 
195 195
 		$vars[] = 'token';
196 196
 		$vars[] = 'key';
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function get_default_version() {
243 243
 
244
-		$version = get_option( 'give_default_api_version' );
244
+		$version = get_option('give_default_api_version');
245 245
 
246
-		if ( defined( 'GIVE_API_VERSION' ) ) {
246
+		if (defined('GIVE_API_VERSION')) {
247 247
 			$version = GIVE_API_VERSION;
248
-		} elseif ( ! $version ) {
248
+		} elseif ( ! $version) {
249 249
 			$version = 'v1';
250 250
 		}
251 251
 
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$version = $wp_query->query_vars['give-api'];
268 268
 
269
-		if ( strpos( $version, '/' ) ) {
269
+		if (strpos($version, '/')) {
270 270
 
271
-			$version = explode( '/', $version );
272
-			$version = strtolower( $version[0] );
271
+			$version = explode('/', $version);
272
+			$version = strtolower($version[0]);
273 273
 
274
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
274
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
275 275
 
276
-			if ( array_key_exists( $version, $this->versions ) ) {
276
+			if (array_key_exists($version, $this->versions)) {
277 277
 
278 278
 				$this->queried_version = $version;
279 279
 
@@ -310,32 +310,32 @@  discard block
 block discarded – undo
310 310
 		$this->override = false;
311 311
 
312 312
 		// Make sure we have both user and api key
313
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
313
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
314 314
 
315
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
315
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
316 316
 				$this->missing_auth();
317 317
 			}
318 318
 
319 319
 			// Retrieve the user by public API key and ensure they exist
320
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
320
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
321 321
 
322 322
 				$this->invalid_key();
323 323
 
324 324
 			} else {
325 325
 
326
-				$token  = urldecode( $wp_query->query_vars['token'] );
327
-				$secret = $this->get_user_secret_key( $user );
328
-				$public = urldecode( $wp_query->query_vars['key'] );
326
+				$token  = urldecode($wp_query->query_vars['token']);
327
+				$secret = $this->get_user_secret_key($user);
328
+				$public = urldecode($wp_query->query_vars['key']);
329 329
 
330
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
330
+				if (hash_equals(md5($secret.$public), $token)) {
331 331
 					$this->is_valid_request = true;
332 332
 				} else {
333 333
 					$this->invalid_auth();
334 334
 				}
335 335
 			}
336
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
336
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
337 337
 			$this->is_valid_request = true;
338
-			$wp_query->set( 'key', 'public' );
338
+			$wp_query->set('key', 'public');
339 339
 		}
340 340
 	}
341 341
 
@@ -351,25 +351,25 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return bool if user ID is found, false otherwise
353 353
 	 */
354
-	public function get_user( $key = '' ) {
354
+	public function get_user($key = '') {
355 355
 		global $wpdb, $wp_query;
356 356
 
357
-		if ( empty( $key ) ) {
358
-			$key = urldecode( $wp_query->query_vars['key'] );
357
+		if (empty($key)) {
358
+			$key = urldecode($wp_query->query_vars['key']);
359 359
 		}
360 360
 
361
-		if ( empty( $key ) ) {
361
+		if (empty($key)) {
362 362
 			return false;
363 363
 		}
364 364
 
365
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
365
+		$user = get_transient(md5('give_api_user_'.$key));
366 366
 
367
-		if ( false === $user ) {
368
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
369
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
367
+		if (false === $user) {
368
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
369
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
370 370
 		}
371 371
 
372
-		if ( $user != null ) {
372
+		if ($user != null) {
373 373
 			$this->user_id = $user;
374 374
 
375 375
 			return $user;
@@ -378,37 +378,37 @@  discard block
 block discarded – undo
378 378
 		return false;
379 379
 	}
380 380
 
381
-	public function get_user_public_key( $user_id = 0 ) {
381
+	public function get_user_public_key($user_id = 0) {
382 382
 		global $wpdb;
383 383
 
384
-		if ( empty( $user_id ) ) {
384
+		if (empty($user_id)) {
385 385
 			return '';
386 386
 		}
387 387
 
388
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
389
-		$user_public_key = get_transient( $cache_key );
388
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
389
+		$user_public_key = get_transient($cache_key);
390 390
 
391
-		if ( empty( $user_public_key ) ) {
392
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
393
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
391
+		if (empty($user_public_key)) {
392
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
393
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
394 394
 		}
395 395
 
396 396
 		return $user_public_key;
397 397
 	}
398 398
 
399
-	public function get_user_secret_key( $user_id = 0 ) {
399
+	public function get_user_secret_key($user_id = 0) {
400 400
 		global $wpdb;
401 401
 
402
-		if ( empty( $user_id ) ) {
402
+		if (empty($user_id)) {
403 403
 			return '';
404 404
 		}
405 405
 
406
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
407
-		$user_secret_key = get_transient( $cache_key );
406
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
407
+		$user_secret_key = get_transient($cache_key);
408 408
 
409
-		if ( empty( $user_secret_key ) ) {
410
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
411
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
409
+		if (empty($user_secret_key)) {
410
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
411
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
412 412
 		}
413 413
 
414 414
 		return $user_secret_key;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	private function missing_auth() {
426 426
 		$error          = array();
427
-		$error['error'] = esc_html__( 'You must specify both a token and API key!', 'give' );
427
+		$error['error'] = esc_html__('You must specify both a token and API key!', 'give');
428 428
 
429 429
 		$this->data = $error;
430
-		$this->output( 401 );
430
+		$this->output(401);
431 431
 	}
432 432
 
433 433
 	/**
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 	 */
442 442
 	private function invalid_auth() {
443 443
 		$error          = array();
444
-		$error['error'] = esc_html__( 'Your request could not be authenticated!', 'give' );
444
+		$error['error'] = esc_html__('Your request could not be authenticated!', 'give');
445 445
 
446 446
 		$this->data = $error;
447
-		$this->output( 403 );
447
+		$this->output(403);
448 448
 	}
449 449
 
450 450
 	/**
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	private function invalid_key() {
460 460
 		$error          = array();
461
-		$error['error'] = esc_html__( 'Invalid API key!', 'give' );
461
+		$error['error'] = esc_html__('Invalid API key!', 'give');
462 462
 
463 463
 		$this->data = $error;
464
-		$this->output( 403 );
464
+		$this->output(403);
465 465
 	}
466 466
 
467 467
 	/**
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
 	 */
475 475
 	private function invalid_version() {
476 476
 		$error          = array();
477
-		$error['error'] = esc_html__( 'Invalid API version!', 'give' );
477
+		$error['error'] = esc_html__('Invalid API version!', 'give');
478 478
 
479 479
 		$this->data = $error;
480
-		$this->output( 404 );
480
+		$this->output(404);
481 481
 	}
482 482
 
483 483
 	/**
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 		global $wp_query;
494 494
 
495 495
 		// Start logging how long the request takes for logging
496
-		$before = microtime( true );
496
+		$before = microtime(true);
497 497
 
498 498
 		// Check for give-api var. Get out if not present
499
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
499
+		if (empty($wp_query->query_vars['give-api'])) {
500 500
 			return;
501 501
 		}
502 502
 
@@ -510,45 +510,45 @@  discard block
 block discarded – undo
510 510
 		$this->validate_request();
511 511
 
512 512
 		// Only proceed if no errors have been noted
513
-		if ( ! $this->is_valid_request ) {
513
+		if ( ! $this->is_valid_request) {
514 514
 			return;
515 515
 		}
516 516
 
517
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
518
-			define( 'GIVE_DOING_API', true );
517
+		if ( ! defined('GIVE_DOING_API')) {
518
+			define('GIVE_DOING_API', true);
519 519
 		}
520 520
 
521 521
 		$data         = array();
522 522
 		$this->routes = new $this->versions[$this->get_queried_version()];
523 523
 		$this->routes->validate_request();
524 524
 
525
-		switch ( $this->endpoint ) :
525
+		switch ($this->endpoint) :
526 526
 
527 527
 			case 'stats' :
528 528
 
529
-				$data = $this->routes->get_stats( array(
530
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
531
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
532
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
533
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
534
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
535
-				) );
529
+				$data = $this->routes->get_stats(array(
530
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
531
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
532
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
533
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
534
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
535
+				));
536 536
 
537 537
 				break;
538 538
 
539 539
 			case 'forms' :
540 540
 
541
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
541
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
542 542
 
543
-				$data = $this->routes->get_forms( $form );
543
+				$data = $this->routes->get_forms($form);
544 544
 
545 545
 				break;
546 546
 
547 547
 			case 'donors' :
548 548
 
549
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
549
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
550 550
 
551
-				$data = $this->routes->get_customers( $customer );
551
+				$data = $this->routes->get_customers($customer);
552 552
 
553 553
 				break;
554 554
 
@@ -561,14 +561,14 @@  discard block
 block discarded – undo
561 561
 		endswitch;
562 562
 
563 563
 		// Allow extensions to setup their own return data
564
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
564
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
565 565
 
566
-		$after                       = microtime( true );
567
-		$request_time                = ( $after - $before );
566
+		$after                       = microtime(true);
567
+		$request_time                = ($after - $before);
568 568
 		$this->data['request_speed'] = $request_time;
569 569
 
570 570
 		// Log this API request, if enabled. We log it here because we have access to errors.
571
-		$this->log_request( $this->data );
571
+		$this->log_request($this->data);
572 572
 
573 573
 		// Send out data to the output function
574 574
 		$this->output();
@@ -598,25 +598,25 @@  discard block
 block discarded – undo
598 598
 		global $wp_query;
599 599
 
600 600
 		// Whitelist our query options
601
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
601
+		$accepted = apply_filters('give_api_valid_query_modes', array(
602 602
 			'stats',
603 603
 			'forms',
604 604
 			'donors',
605 605
 			'donations'
606
-		) );
606
+		));
607 607
 
608
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
609
-		$query = str_replace( $this->queried_version . '/', '', $query );
608
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
609
+		$query = str_replace($this->queried_version.'/', '', $query);
610 610
 
611 611
 		$error = array();
612 612
 
613 613
 		// Make sure our query is valid
614
-		if ( ! in_array( $query, $accepted ) ) {
615
-			$error['error'] = esc_html__( 'Invalid query!', 'give' );
614
+		if ( ! in_array($query, $accepted)) {
615
+			$error['error'] = esc_html__('Invalid query!', 'give');
616 616
 
617 617
 			$this->data = $error;
618 618
 			// 400 is Bad Request
619
-			$this->output( 400 );
619
+			$this->output(400);
620 620
 		}
621 621
 
622 622
 		$this->endpoint = $query;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	public function get_paged() {
634 634
 		global $wp_query;
635 635
 
636
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
636
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
637 637
 	}
638 638
 
639 639
 
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 	public function per_page() {
649 649
 		global $wp_query;
650 650
 
651
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
651
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
652 652
 
653
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
653
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
654 654
 			$per_page = 99999999;
655 655
 		} // Customers query doesn't support -1
656 656
 
657
-		return apply_filters( 'give_api_results_per_page', $per_page );
657
+		return apply_filters('give_api_results_per_page', $per_page);
658 658
 	}
659 659
 
660 660
 	/**
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 *
668 668
 	 * @return array $dates
669 669
 	 */
670
-	public function get_dates( $args = array() ) {
670
+	public function get_dates($args = array()) {
671 671
 		$dates = array();
672 672
 
673 673
 		$defaults = array(
@@ -678,60 +678,60 @@  discard block
 block discarded – undo
678 678
 			'enddate'   => null
679 679
 		);
680 680
 
681
-		$args = wp_parse_args( $args, $defaults );
681
+		$args = wp_parse_args($args, $defaults);
682 682
 
683
-		$current_time = current_time( 'timestamp' );
683
+		$current_time = current_time('timestamp');
684 684
 
685
-		if ( 'range' === $args['date'] ) {
686
-			$startdate          = strtotime( $args['startdate'] );
687
-			$enddate            = strtotime( $args['enddate'] );
688
-			$dates['day_start'] = date( 'd', $startdate );
689
-			$dates['day_end']   = date( 'd', $enddate );
690
-			$dates['m_start']   = date( 'n', $startdate );
691
-			$dates['m_end']     = date( 'n', $enddate );
692
-			$dates['year']      = date( 'Y', $startdate );
693
-			$dates['year_end']  = date( 'Y', $enddate );
685
+		if ('range' === $args['date']) {
686
+			$startdate          = strtotime($args['startdate']);
687
+			$enddate            = strtotime($args['enddate']);
688
+			$dates['day_start'] = date('d', $startdate);
689
+			$dates['day_end']   = date('d', $enddate);
690
+			$dates['m_start']   = date('n', $startdate);
691
+			$dates['m_end']     = date('n', $enddate);
692
+			$dates['year']      = date('Y', $startdate);
693
+			$dates['year_end']  = date('Y', $enddate);
694 694
 		} else {
695 695
 			// Modify dates based on predefined ranges
696
-			switch ( $args['date'] ) :
696
+			switch ($args['date']) :
697 697
 
698 698
 				case 'this_month' :
699 699
 					$dates['day']     = null;
700
-					$dates['m_start'] = date( 'n', $current_time );
701
-					$dates['m_end']   = date( 'n', $current_time );
702
-					$dates['year']    = date( 'Y', $current_time );
700
+					$dates['m_start'] = date('n', $current_time);
701
+					$dates['m_end']   = date('n', $current_time);
702
+					$dates['year']    = date('Y', $current_time);
703 703
 					break;
704 704
 
705 705
 				case 'last_month' :
706 706
 					$dates['day']     = null;
707
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
707
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
708 708
 					$dates['m_end']   = $dates['m_start'];
709
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
709
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
710 710
 					break;
711 711
 
712 712
 				case 'today' :
713
-					$dates['day']     = date( 'd', $current_time );
714
-					$dates['m_start'] = date( 'n', $current_time );
715
-					$dates['m_end']   = date( 'n', $current_time );
716
-					$dates['year']    = date( 'Y', $current_time );
713
+					$dates['day']     = date('d', $current_time);
714
+					$dates['m_start'] = date('n', $current_time);
715
+					$dates['m_end']   = date('n', $current_time);
716
+					$dates['year']    = date('Y', $current_time);
717 717
 					break;
718 718
 
719 719
 				case 'yesterday' :
720 720
 
721
-					$year  = date( 'Y', $current_time );
722
-					$month = date( 'n', $current_time );
723
-					$day   = date( 'd', $current_time );
721
+					$year  = date('Y', $current_time);
722
+					$month = date('n', $current_time);
723
+					$day   = date('d', $current_time);
724 724
 
725
-					if ( $month == 1 && $day == 1 ) {
725
+					if ($month == 1 && $day == 1) {
726 726
 
727 727
 						$year -= 1;
728 728
 						$month = 12;
729
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
729
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
730 730
 
731
-					} elseif ( $month > 1 && $day == 1 ) {
731
+					} elseif ($month > 1 && $day == 1) {
732 732
 
733 733
 						$month -= 1;
734
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
734
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
735 735
 
736 736
 					} else {
737 737
 
@@ -747,65 +747,65 @@  discard block
 block discarded – undo
747 747
 					break;
748 748
 
749 749
 				case 'this_quarter' :
750
-					$month_now = date( 'n', $current_time );
750
+					$month_now = date('n', $current_time);
751 751
 
752 752
 					$dates['day'] = null;
753 753
 
754
-					if ( $month_now <= 3 ) {
754
+					if ($month_now <= 3) {
755 755
 
756 756
 						$dates['m_start'] = 1;
757 757
 						$dates['m_end']   = 3;
758
-						$dates['year']    = date( 'Y', $current_time );
758
+						$dates['year']    = date('Y', $current_time);
759 759
 
760
-					} else if ( $month_now <= 6 ) {
760
+					} else if ($month_now <= 6) {
761 761
 
762 762
 						$dates['m_start'] = 4;
763 763
 						$dates['m_end']   = 6;
764
-						$dates['year']    = date( 'Y', $current_time );
764
+						$dates['year']    = date('Y', $current_time);
765 765
 
766
-					} else if ( $month_now <= 9 ) {
766
+					} else if ($month_now <= 9) {
767 767
 
768 768
 						$dates['m_start'] = 7;
769 769
 						$dates['m_end']   = 9;
770
-						$dates['year']    = date( 'Y', $current_time );
770
+						$dates['year']    = date('Y', $current_time);
771 771
 
772 772
 					} else {
773 773
 
774 774
 						$dates['m_start'] = 10;
775 775
 						$dates['m_end']   = 12;
776
-						$dates['year']    = date( 'Y', $current_time );
776
+						$dates['year']    = date('Y', $current_time);
777 777
 
778 778
 					}
779 779
 					break;
780 780
 
781 781
 				case 'last_quarter' :
782
-					$month_now = date( 'n', $current_time );
782
+					$month_now = date('n', $current_time);
783 783
 
784 784
 					$dates['day'] = null;
785 785
 
786
-					if ( $month_now <= 3 ) {
786
+					if ($month_now <= 3) {
787 787
 
788 788
 						$dates['m_start'] = 10;
789 789
 						$dates['m_end']   = 12;
790
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
790
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
791 791
 
792
-					} else if ( $month_now <= 6 ) {
792
+					} else if ($month_now <= 6) {
793 793
 
794 794
 						$dates['m_start'] = 1;
795 795
 						$dates['m_end']   = 3;
796
-						$dates['year']    = date( 'Y', $current_time );
796
+						$dates['year']    = date('Y', $current_time);
797 797
 
798
-					} else if ( $month_now <= 9 ) {
798
+					} else if ($month_now <= 9) {
799 799
 
800 800
 						$dates['m_start'] = 4;
801 801
 						$dates['m_end']   = 6;
802
-						$dates['year']    = date( 'Y', $current_time );
802
+						$dates['year']    = date('Y', $current_time);
803 803
 
804 804
 					} else {
805 805
 
806 806
 						$dates['m_start'] = 7;
807 807
 						$dates['m_end']   = 9;
808
-						$dates['year']    = date( 'Y', $current_time );
808
+						$dates['year']    = date('Y', $current_time);
809 809
 
810 810
 					}
811 811
 					break;
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 					$dates['day']     = null;
815 815
 					$dates['m_start'] = null;
816 816
 					$dates['m_end']   = null;
817
-					$dates['year']    = date( 'Y', $current_time );
817
+					$dates['year']    = date('Y', $current_time);
818 818
 					break;
819 819
 
820 820
 				case 'last_year' :
821 821
 					$dates['day']     = null;
822 822
 					$dates['m_start'] = null;
823 823
 					$dates['m_end']   = null;
824
-					$dates['year']    = date( 'Y', $current_time ) - 1;
824
+					$dates['year']    = date('Y', $current_time) - 1;
825 825
 					break;
826 826
 
827 827
 			endswitch;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 		 * @param object $dates The dates used for retrieving earnings/donations
836 836
 		 */
837 837
 
838
-		return apply_filters( 'give_api_stat_dates', $dates );
838
+		return apply_filters('give_api_stat_dates', $dates);
839 839
 	}
840 840
 
841 841
 	/**
@@ -850,11 +850,11 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @return array $customers Multidimensional array of the customers
852 852
 	 */
853
-	public function get_customers( $customer = null ) {
853
+	public function get_customers($customer = null) {
854 854
 
855 855
 		$customers = array();
856 856
 		$error     = array();
857
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
857
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
858 858
 			return $customers;
859 859
 		}
860 860
 
@@ -862,64 +862,64 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$paged    = $this->get_paged();
864 864
 		$per_page = $this->per_page();
865
-		$offset   = $per_page * ( $paged - 1 );
865
+		$offset   = $per_page * ($paged - 1);
866 866
 
867
-		if ( is_numeric( $customer ) ) {
867
+		if (is_numeric($customer)) {
868 868
 			$field = 'id';
869 869
 		} else {
870 870
 			$field = 'email';
871 871
 		}
872 872
 
873
-		$customer_query = Give()->customers->get_customers( array(
873
+		$customer_query = Give()->customers->get_customers(array(
874 874
 			'number' => $per_page,
875 875
 			'offset' => $offset,
876 876
 			$field   => $customer
877
-		) );
877
+		));
878 878
 		$customer_count = 0;
879 879
 
880
-		if ( $customer_query ) {
880
+		if ($customer_query) {
881 881
 
882
-			foreach ( $customer_query as $customer_obj ) {
882
+			foreach ($customer_query as $customer_obj) {
883 883
 
884
-				$names      = explode( ' ', $customer_obj->name );
885
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
884
+				$names      = explode(' ', $customer_obj->name);
885
+				$first_name = ! empty($names[0]) ? $names[0] : '';
886 886
 				$last_name  = '';
887
-				if ( ! empty( $names[1] ) ) {
888
-					unset( $names[0] );
889
-					$last_name = implode( ' ', $names );
887
+				if ( ! empty($names[1])) {
888
+					unset($names[0]);
889
+					$last_name = implode(' ', $names);
890 890
 				}
891 891
 
892
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
893
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
894
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
895
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
896
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
897
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
898
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
892
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
893
+				$customers['donors'][$customer_count]['info']['username']     = '';
894
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
895
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
896
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
897
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
898
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
899 899
 
900
-				if ( ! empty( $customer_obj->user_id ) ) {
900
+				if ( ! empty($customer_obj->user_id)) {
901 901
 
902
-					$user_data = get_userdata( $customer_obj->user_id );
902
+					$user_data = get_userdata($customer_obj->user_id);
903 903
 
904 904
 					// Customer with registered account
905
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
906
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
907
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
905
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
906
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
907
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
908 908
 
909 909
 				}
910 910
 
911
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
912
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
911
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
912
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
913 913
 
914
-				$customer_count ++;
914
+				$customer_count++;
915 915
 
916 916
 			}
917 917
 
918
-		} elseif ( $customer ) {
918
+		} elseif ($customer) {
919 919
 
920 920
 			$error['error'] = sprintf(
921 921
 				/* translators: %s: customer */
922
-				esc_html__( 'Donor %s not found!', 'give' ),
922
+				esc_html__('Donor %s not found!', 'give'),
923 923
 				$customer
924 924
 			);
925 925
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
 		} else {
929 929
 
930
-			$error['error'] = esc_html__( 'No donors found!', 'give' );
930
+			$error['error'] = esc_html__('No donors found!', 'give');
931 931
 
932 932
 			return $error;
933 933
 
@@ -946,38 +946,38 @@  discard block
 block discarded – undo
946 946
 	 *
947 947
 	 * @return array $customers Multidimensional array of the forms
948 948
 	 */
949
-	public function get_forms( $form = null ) {
949
+	public function get_forms($form = null) {
950 950
 
951 951
 		$forms = array();
952 952
 		$error = array();
953 953
 
954
-		if ( $form == null ) {
954
+		if ($form == null) {
955 955
 			$forms['forms'] = array();
956 956
 
957
-			$form_list = get_posts( array(
957
+			$form_list = get_posts(array(
958 958
 				'post_type'        => 'give_forms',
959 959
 				'posts_per_page'   => $this->per_page(),
960 960
 				'suppress_filters' => true,
961 961
 				'paged'            => $this->get_paged()
962
-			) );
962
+			));
963 963
 
964
-			if ( $form_list ) {
964
+			if ($form_list) {
965 965
 				$i = 0;
966
-				foreach ( $form_list as $form_info ) {
967
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
968
-					$i ++;
966
+				foreach ($form_list as $form_info) {
967
+					$forms['forms'][$i] = $this->get_form_data($form_info);
968
+					$i++;
969 969
 				}
970 970
 			}
971 971
 		} else {
972
-			if ( get_post_type( $form ) == 'give_forms' ) {
973
-				$form_info = get_post( $form );
972
+			if (get_post_type($form) == 'give_forms') {
973
+				$form_info = get_post($form);
974 974
 
975
-				$forms['forms'][0] = $this->get_form_data( $form_info );
975
+				$forms['forms'][0] = $this->get_form_data($form_info);
976 976
 
977 977
 			} else {
978 978
 				$error['error'] = sprintf(
979 979
 					/* translators: %s: form */
980
-					esc_html__( 'Form %s not found!', 'give' ),
980
+					esc_html__('Form %s not found!', 'give'),
981 981
 					$form
982 982
 				);
983 983
 
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 	 *
998 998
 	 * @return array                Array of post data to return back in the API
999 999
 	 */
1000
-	private function get_form_data( $form_info ) {
1000
+	private function get_form_data($form_info) {
1001 1001
 
1002 1002
 		$form = array();
1003 1003
 
@@ -1007,46 +1007,46 @@  discard block
 block discarded – undo
1007 1007
 		$form['info']['create_date']   = $form_info->post_date;
1008 1008
 		$form['info']['modified_date'] = $form_info->post_modified;
1009 1009
 		$form['info']['status']        = $form_info->post_status;
1010
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1011
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1012
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1010
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1011
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1012
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1013 1013
 
1014
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1015
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1016
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1014
+		if (give_get_option('enable_categories') == 'on') {
1015
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1016
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1017 1017
 		}
1018
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1019
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1018
+		if (give_get_option('enable_tags') == 'on') {
1019
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1020 1020
 		}
1021 1021
 
1022
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1023
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1024
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1025
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1026
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1022
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1023
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1024
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1025
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1026
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1027 1027
 		}
1028 1028
 
1029 1029
 		$counter = 0;
1030
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1031
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1032
-				$counter ++;
1030
+		if (give_has_variable_prices($form_info->ID)) {
1031
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1032
+				$counter++;
1033 1033
 				//muli-level item
1034
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1035
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1034
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1035
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1036 1036
 
1037 1037
 			}
1038 1038
 		} else {
1039
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1039
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1040 1040
 		}
1041 1041
 
1042
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1042
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1043 1043
 
1044 1044
 			//Sensitive data here
1045
-			do_action( 'give_api_sensitive_data' );
1045
+			do_action('give_api_sensitive_data');
1046 1046
 
1047 1047
 		}
1048 1048
 
1049
-		return apply_filters( 'give_api_forms_form', $form );
1049
+		return apply_filters('give_api_forms_form', $form);
1050 1050
 
1051 1051
 	}
1052 1052
 
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 	 *
1062 1062
 	 * @return array
1063 1063
 	 */
1064
-	public function get_stats( $args = array() ) {
1064
+	public function get_stats($args = array()) {
1065 1065
 		$defaults = array(
1066 1066
 			'type'      => null,
1067 1067
 			'form'      => null,
@@ -1070,9 +1070,9 @@  discard block
 block discarded – undo
1070 1070
 			'enddate'   => null
1071 1071
 		);
1072 1072
 
1073
-		$args = wp_parse_args( $args, $defaults );
1073
+		$args = wp_parse_args($args, $defaults);
1074 1074
 
1075
-		$dates = $this->get_dates( $args );
1075
+		$dates = $this->get_dates($args);
1076 1076
 
1077 1077
 		$stats    = array();
1078 1078
 		$earnings = array(
@@ -1083,41 +1083,41 @@  discard block
 block discarded – undo
1083 1083
 		);
1084 1084
 		$error    = array();
1085 1085
 
1086
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1086
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1087 1087
 			return $stats;
1088 1088
 		}
1089 1089
 
1090
-		if ( $args['type'] == 'donations' ) {
1090
+		if ($args['type'] == 'donations') {
1091 1091
 
1092
-			if ( $args['form'] == null ) {
1093
-				if ( $args['date'] == null ) {
1092
+			if ($args['form'] == null) {
1093
+				if ($args['date'] == null) {
1094 1094
 					$sales = $this->get_default_sales_stats();
1095
-				} elseif ( $args['date'] === 'range' ) {
1095
+				} elseif ($args['date'] === 'range') {
1096 1096
 					// Return sales for a date range
1097 1097
 
1098 1098
 					// Ensure the end date is later than the start date
1099
-					if ( $args['enddate'] < $args['startdate'] ) {
1100
-						$error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' );
1099
+					if ($args['enddate'] < $args['startdate']) {
1100
+						$error['error'] = esc_html__('The end date must be later than the start date!', 'give');
1101 1101
 					}
1102 1102
 
1103 1103
 					// Ensure both the start and end date are specified
1104
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1105
-						$error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' );
1104
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1105
+						$error['error'] = esc_html__('Invalid or no date range specified!', 'give');
1106 1106
 					}
1107 1107
 
1108 1108
 					$total = 0;
1109 1109
 
1110 1110
 					// Loop through the years
1111 1111
 					$y = $dates['year'];
1112
-					while ( $y <= $dates['year_end'] ) :
1112
+					while ($y <= $dates['year_end']) :
1113 1113
 
1114
-						if ( $dates['year'] == $dates['year_end'] ) {
1114
+						if ($dates['year'] == $dates['year_end']) {
1115 1115
 							$month_start = $dates['m_start'];
1116 1116
 							$month_end   = $dates['m_end'];
1117
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1117
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1118 1118
 							$month_start = $dates['m_start'];
1119 1119
 							$month_end   = 12;
1120
-						} elseif ( $y == $dates['year_end'] ) {
1120
+						} elseif ($y == $dates['year_end']) {
1121 1121
 							$month_start = 1;
1122 1122
 							$month_end   = $dates['m_end'];
1123 1123
 						} else {
@@ -1126,113 +1126,113 @@  discard block
 block discarded – undo
1126 1126
 						}
1127 1127
 
1128 1128
 						$i = $month_start;
1129
-						while ( $i <= $month_end ) :
1129
+						while ($i <= $month_end) :
1130 1130
 
1131
-							if ( $i == $dates['m_start'] ) {
1131
+							if ($i == $dates['m_start']) {
1132 1132
 								$d = $dates['day_start'];
1133 1133
 							} else {
1134 1134
 								$d = 1;
1135 1135
 							}
1136 1136
 
1137
-							if ( $i == $dates['m_end'] ) {
1137
+							if ($i == $dates['m_end']) {
1138 1138
 								$num_of_days = $dates['day_end'];
1139 1139
 							} else {
1140
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1140
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1141 1141
 							}
1142 1142
 
1143
-							while ( $d <= $num_of_days ) :
1144
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1145
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1146
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1147
-									$sales['sales'][ $date_key ] = 0;
1143
+							while ($d <= $num_of_days) :
1144
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1145
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1146
+								if ( ! isset($sales['sales'][$date_key])) {
1147
+									$sales['sales'][$date_key] = 0;
1148 1148
 								}
1149
-								$sales['sales'][ $date_key ] += $sale_count;
1149
+								$sales['sales'][$date_key] += $sale_count;
1150 1150
 								$total += $sale_count;
1151
-								$d ++;
1151
+								$d++;
1152 1152
 							endwhile;
1153
-							$i ++;
1153
+							$i++;
1154 1154
 						endwhile;
1155 1155
 
1156
-						$y ++;
1156
+						$y++;
1157 1157
 					endwhile;
1158 1158
 
1159 1159
 					$sales['totals'] = $total;
1160 1160
 				} else {
1161
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1161
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1162 1162
 						$sales_count = 0;
1163 1163
 
1164 1164
 						// Loop through the months
1165 1165
 						$month = $dates['m_start'];
1166 1166
 
1167
-						while ( $month <= $dates['m_end'] ) :
1168
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1169
-							$month ++;
1167
+						while ($month <= $dates['m_end']) :
1168
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1169
+							$month++;
1170 1170
 						endwhile;
1171 1171
 
1172
-						$sales['donations'][ $args['date'] ] = $sales_count;
1172
+						$sales['donations'][$args['date']] = $sales_count;
1173 1173
 					} else {
1174
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1174
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1175 1175
 					}
1176 1176
 				}
1177
-			} elseif ( $args['form'] == 'all' ) {
1178
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1177
+			} elseif ($args['form'] == 'all') {
1178
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1179 1179
 				$i     = 0;
1180
-				foreach ( $forms as $form_info ) {
1181
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1182
-					$i ++;
1180
+				foreach ($forms as $form_info) {
1181
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1182
+					$i++;
1183 1183
 				}
1184 1184
 			} else {
1185
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1186
-					$form_info             = get_post( $args['form'] );
1187
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1185
+				if (get_post_type($args['form']) == 'give_forms') {
1186
+					$form_info             = get_post($args['form']);
1187
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1188 1188
 				} else {
1189 1189
 					$error['error'] = sprintf(
1190 1190
 						/* translators: %s: form */
1191
-						esc_html__( 'Product %s not found!', 'give' ),
1191
+						esc_html__('Product %s not found!', 'give'),
1192 1192
 						$args['form']
1193 1193
 					);
1194 1194
 				}
1195 1195
 			}
1196 1196
 
1197
-			if ( ! empty( $error ) ) {
1197
+			if ( ! empty($error)) {
1198 1198
 				return $error;
1199 1199
 			}
1200 1200
 
1201 1201
 			return $sales;
1202 1202
 
1203
-		} elseif ( $args['type'] == 'earnings' ) {
1204
-			if ( $args['form'] == null ) {
1205
-				if ( $args['date'] == null ) {
1203
+		} elseif ($args['type'] == 'earnings') {
1204
+			if ($args['form'] == null) {
1205
+				if ($args['date'] == null) {
1206 1206
 					$earnings = $this->get_default_earnings_stats();
1207
-				} elseif ( $args['date'] === 'range' ) {
1207
+				} elseif ($args['date'] === 'range') {
1208 1208
 					// Return sales for a date range
1209 1209
 
1210 1210
 					// Ensure the end date is later than the start date
1211
-					if ( $args['enddate'] < $args['startdate'] ) {
1212
-						$error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' );
1211
+					if ($args['enddate'] < $args['startdate']) {
1212
+						$error['error'] = esc_html__('The end date must be later than the start date!', 'give');
1213 1213
 					}
1214 1214
 
1215 1215
 					// Ensure both the start and end date are specified
1216
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1217
-						$error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' );
1216
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1217
+						$error['error'] = esc_html__('Invalid or no date range specified!', 'give');
1218 1218
 					}
1219 1219
 
1220 1220
 					$total = (float) 0.00;
1221 1221
 
1222 1222
 					// Loop through the years
1223 1223
 					$y = $dates['year'];
1224
-					if ( ! isset( $earnings['earnings'] ) ) {
1224
+					if ( ! isset($earnings['earnings'])) {
1225 1225
 						$earnings['earnings'] = array();
1226 1226
 					}
1227
-					while ( $y <= $dates['year_end'] ) :
1227
+					while ($y <= $dates['year_end']) :
1228 1228
 
1229
-						if ( $dates['year'] == $dates['year_end'] ) {
1229
+						if ($dates['year'] == $dates['year_end']) {
1230 1230
 							$month_start = $dates['m_start'];
1231 1231
 							$month_end   = $dates['m_end'];
1232
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1232
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1233 1233
 							$month_start = $dates['m_start'];
1234 1234
 							$month_end   = 12;
1235
-						} elseif ( $y == $dates['year_end'] ) {
1235
+						} elseif ($y == $dates['year_end']) {
1236 1236
 							$month_start = 1;
1237 1237
 							$month_end   = $dates['m_end'];
1238 1238
 						} else {
@@ -1241,92 +1241,92 @@  discard block
 block discarded – undo
1241 1241
 						}
1242 1242
 
1243 1243
 						$i = $month_start;
1244
-						while ( $i <= $month_end ) :
1244
+						while ($i <= $month_end) :
1245 1245
 
1246
-							if ( $i == $dates['m_start'] ) {
1246
+							if ($i == $dates['m_start']) {
1247 1247
 								$d = $dates['day_start'];
1248 1248
 							} else {
1249 1249
 								$d = 1;
1250 1250
 							}
1251 1251
 
1252
-							if ( $i == $dates['m_end'] ) {
1252
+							if ($i == $dates['m_end']) {
1253 1253
 								$num_of_days = $dates['day_end'];
1254 1254
 							} else {
1255
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1255
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1256 1256
 							}
1257 1257
 
1258
-							while ( $d <= $num_of_days ) :
1259
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1260
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1261
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1262
-									$earnings['earnings'][ $date_key ] = 0;
1258
+							while ($d <= $num_of_days) :
1259
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1260
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1261
+								if ( ! isset($earnings['earnings'][$date_key])) {
1262
+									$earnings['earnings'][$date_key] = 0;
1263 1263
 								}
1264
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1264
+								$earnings['earnings'][$date_key] += $earnings_stat;
1265 1265
 								$total += $earnings_stat;
1266
-								$d ++;
1266
+								$d++;
1267 1267
 							endwhile;
1268 1268
 
1269
-							$i ++;
1269
+							$i++;
1270 1270
 						endwhile;
1271 1271
 
1272
-						$y ++;
1272
+						$y++;
1273 1273
 					endwhile;
1274 1274
 
1275 1275
 					$earnings['totals'] = $total;
1276 1276
 				} else {
1277
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1277
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1278 1278
 						$earnings_count = (float) 0.00;
1279 1279
 
1280 1280
 						// Loop through the months
1281 1281
 						$month = $dates['m_start'];
1282 1282
 
1283
-						while ( $month <= $dates['m_end'] ) :
1284
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1285
-							$month ++;
1283
+						while ($month <= $dates['m_end']) :
1284
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1285
+							$month++;
1286 1286
 						endwhile;
1287 1287
 
1288
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1288
+						$earnings['earnings'][$args['date']] = $earnings_count;
1289 1289
 					} else {
1290
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1290
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1291 1291
 					}
1292 1292
 				}
1293
-			} elseif ( $args['form'] == 'all' ) {
1294
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1293
+			} elseif ($args['form'] == 'all') {
1294
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1295 1295
 
1296 1296
 				$i = 0;
1297
-				foreach ( $forms as $form_info ) {
1298
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1299
-					$i ++;
1297
+				foreach ($forms as $form_info) {
1298
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1299
+					$i++;
1300 1300
 				}
1301 1301
 			} else {
1302
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1303
-					$form_info               = get_post( $args['form'] );
1304
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1302
+				if (get_post_type($args['form']) == 'give_forms') {
1303
+					$form_info               = get_post($args['form']);
1304
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1305 1305
 				} else {
1306 1306
 					$error['error'] = sprintf(
1307 1307
 						/* translators: %s: form */
1308
-						esc_html__( 'Form %s not found!', 'give' ),
1308
+						esc_html__('Form %s not found!', 'give'),
1309 1309
 						$args['form']
1310 1310
 					);
1311 1311
 				}
1312 1312
 			}
1313 1313
 
1314
-			if ( ! empty( $error ) ) {
1314
+			if ( ! empty($error)) {
1315 1315
 				return $error;
1316 1316
 			}
1317 1317
 
1318 1318
 			return $earnings;
1319
-		} elseif ( $args['type'] == 'donors' ) {
1319
+		} elseif ($args['type'] == 'donors') {
1320 1320
 			$customers                          = new Give_DB_Customers();
1321 1321
 			$stats['donations']['total_donors'] = $customers->count();
1322 1322
 
1323 1323
 			return $stats;
1324 1324
 
1325
-		} elseif ( empty( $args['type'] ) ) {
1326
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1327
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1325
+		} elseif (empty($args['type'])) {
1326
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1327
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1328 1328
 
1329
-			return array( 'stats' => $stats );
1329
+			return array('stats' => $stats);
1330 1330
 		}
1331 1331
 	}
1332 1332
 
@@ -1342,18 +1342,18 @@  discard block
 block discarded – undo
1342 1342
 
1343 1343
 		$sales = array();
1344 1344
 
1345
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1345
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1346 1346
 			return $sales;
1347 1347
 		}
1348 1348
 
1349
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1349
+		if (isset($wp_query->query_vars['id'])) {
1350 1350
 			$query   = array();
1351
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1352
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1351
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1352
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1353 1353
 			$query   = array();
1354
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1355
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1356
-			$args  = array(
1354
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1355
+		} elseif (isset($wp_query->query_vars['email'])) {
1356
+			$args = array(
1357 1357
 				'fields'     => 'ids',
1358 1358
 				'meta_key'   => '_give_payment_user_email',
1359 1359
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
 				'page'       => $this->get_paged(),
1362 1362
 				'status'     => 'publish'
1363 1363
 			);
1364
-			$query = give_get_payments( $args );
1364
+			$query = give_get_payments($args);
1365 1365
 		} else {
1366 1366
 			$args  = array(
1367 1367
 				'fields' => 'ids',
@@ -1369,14 +1369,14 @@  discard block
 block discarded – undo
1369 1369
 				'page'   => $this->get_paged(),
1370 1370
 				'status' => 'publish'
1371 1371
 			);
1372
-			$query = give_get_payments( $args );
1372
+			$query = give_get_payments($args);
1373 1373
 		}
1374
-		if ( $query ) {
1374
+		if ($query) {
1375 1375
 			$i = 0;
1376
-			foreach ( $query as $payment ) {
1376
+			foreach ($query as $payment) {
1377 1377
 
1378
-				if ( is_numeric( $payment ) ) {
1379
-					$payment      = new Give_Payment( $payment );
1378
+				if (is_numeric($payment)) {
1379
+					$payment      = new Give_Payment($payment);
1380 1380
 					$payment_meta = $payment->get_meta();
1381 1381
 					$user_info    = $payment->user_info;
1382 1382
 				} else {
@@ -1386,40 +1386,40 @@  discard block
 block discarded – undo
1386 1386
 				$payment_meta = $payment->get_meta();
1387 1387
 				$user_info    = $payment->user_info;
1388 1388
 
1389
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1390
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1391
-
1392
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1393
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1394
-				$sales['donations'][ $i ]['key']            = $payment->key;
1395
-				$sales['donations'][ $i ]['total']          = $payment->total;
1396
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1397
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1398
-				$sales['donations'][ $i ]['fname']          = $first_name;
1399
-				$sales['donations'][ $i ]['lname']          = $last_name;
1400
-				$sales['donations'][ $i ]['email']          = $payment->email;
1401
-				$sales['donations'][ $i ]['date']           = $payment->date;
1402
-
1403
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1404
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1405
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1406
-
1407
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1408
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1409
-				$sales['donations'][ $i ]['form']['price'] = $price;
1410
-
1411
-				if ( give_has_variable_prices( $form_id ) ) {
1412
-					if ( isset( $payment_meta['price_id'] ) ) {
1413
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1414
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1415
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1416
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1389
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1390
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1391
+
1392
+				$sales['donations'][$i]['ID']             = $payment->number;
1393
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1394
+				$sales['donations'][$i]['key']            = $payment->key;
1395
+				$sales['donations'][$i]['total']          = $payment->total;
1396
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1397
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1398
+				$sales['donations'][$i]['fname']          = $first_name;
1399
+				$sales['donations'][$i]['lname']          = $last_name;
1400
+				$sales['donations'][$i]['email']          = $payment->email;
1401
+				$sales['donations'][$i]['date']           = $payment->date;
1402
+
1403
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1404
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1405
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1406
+
1407
+				$sales['donations'][$i]['form']['id']    = $form_id;
1408
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1409
+				$sales['donations'][$i]['form']['price'] = $price;
1410
+
1411
+				if (give_has_variable_prices($form_id)) {
1412
+					if (isset($payment_meta['price_id'])) {
1413
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1414
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1415
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1416
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1417 1417
 
1418 1418
 					}
1419 1419
 				}
1420 1420
 
1421 1421
 				//Add custom meta to API
1422
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1422
+				foreach ($payment_meta as $meta_key => $meta_value) {
1423 1423
 
1424 1424
 					$exceptions = array(
1425 1425
 						'form_title',
@@ -1432,19 +1432,19 @@  discard block
 block discarded – undo
1432 1432
 					);
1433 1433
 
1434 1434
 					//Don't clutter up results with dupes
1435
-					if ( in_array( $meta_key, $exceptions ) ) {
1435
+					if (in_array($meta_key, $exceptions)) {
1436 1436
 						continue;
1437 1437
 					}
1438 1438
 
1439
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1439
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1440 1440
 
1441 1441
 				}
1442 1442
 
1443
-				$i ++;
1443
+				$i++;
1444 1444
 			}
1445 1445
 		}
1446 1446
 
1447
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1447
+		return apply_filters('give_api_donations_endpoint', $sales);
1448 1448
 	}
1449 1449
 
1450 1450
 	/**
@@ -1460,9 +1460,9 @@  discard block
 block discarded – undo
1460 1460
 	public function get_output_format() {
1461 1461
 		global $wp_query;
1462 1462
 
1463
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1463
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1464 1464
 
1465
-		return apply_filters( 'give_api_output_format', $format );
1465
+		return apply_filters('give_api_output_format', $format);
1466 1466
 	}
1467 1467
 
1468 1468
 
@@ -1479,8 +1479,8 @@  discard block
 block discarded – undo
1479 1479
 	 *
1480 1480
 	 * @return void
1481 1481
 	 */
1482
-	private function log_request( $data = array() ) {
1483
-		if ( ! $this->log_requests ) {
1482
+	private function log_request($data = array()) {
1483
+		if ( ! $this->log_requests) {
1484 1484
 			return;
1485 1485
 		}
1486 1486
 
@@ -1496,36 +1496,36 @@  discard block
 block discarded – undo
1496 1496
 
1497 1497
 		$query = array(
1498 1498
 			'give-api'    => $wp_query->query_vars['give-api'],
1499
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1500
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1501
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1502
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1503
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1504
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1505
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1506
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1507
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1508
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1509
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1510
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1499
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1500
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1501
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1502
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1503
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1504
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1505
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1506
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1507
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1508
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1509
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1510
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1511 1511
 		);
1512 1512
 
1513 1513
 		$log_data = array(
1514 1514
 			'log_type'     => 'api_request',
1515
-			'post_excerpt' => http_build_query( $query ),
1516
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1515
+			'post_excerpt' => http_build_query($query),
1516
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1517 1517
 		);
1518 1518
 
1519 1519
 		$log_meta = array(
1520 1520
 			'request_ip' => give_get_ip(),
1521 1521
 			'user'       => $this->user_id,
1522
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1523
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1522
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1523
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1524 1524
 			'time'       => $data['request_speed'],
1525 1525
 			'version'    => $this->get_queried_version()
1526 1526
 		);
1527 1527
 
1528
-		$give_logs->insert_log( $log_data, $log_meta );
1528
+		$give_logs->insert_log($log_data, $log_meta);
1529 1529
 	}
1530 1530
 
1531 1531
 
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
 	 *
1550 1550
 	 * @param int $status_code
1551 1551
 	 */
1552
-	public function output( $status_code = 200 ) {
1552
+	public function output($status_code = 200) {
1553 1553
         /**
1554 1554
          * @var WP_Query $wp_query
1555 1555
          */
@@ -1557,27 +1557,27 @@  discard block
 block discarded – undo
1557 1557
 
1558 1558
 		$format = $this->get_output_format();
1559 1559
 
1560
-		status_header( $status_code );
1560
+		status_header($status_code);
1561 1561
 
1562
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1562
+		do_action('give_api_output_before', $this->data, $this, $format);
1563 1563
 
1564
-		switch ( $format ) :
1564
+		switch ($format) :
1565 1565
 
1566 1566
 			case 'xml' :
1567 1567
 
1568
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1569
-				$xml = Array2XML::createXML( 'give', $this->data );
1568
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1569
+				$xml = Array2XML::createXML('give', $this->data);
1570 1570
 				echo $xml->saveXML();
1571 1571
 
1572 1572
 				break;
1573 1573
 
1574 1574
 			case 'json' :
1575 1575
 
1576
-				header( 'Content-Type: application/json' );
1577
-				if ( ! empty( $this->pretty_print ) ) {
1578
-					echo json_encode( $this->data, $this->pretty_print );
1576
+				header('Content-Type: application/json');
1577
+				if ( ! empty($this->pretty_print)) {
1578
+					echo json_encode($this->data, $this->pretty_print);
1579 1579
 				} else {
1580
-					echo json_encode( $this->data );
1580
+					echo json_encode($this->data);
1581 1581
 				}
1582 1582
 
1583 1583
 				break;
@@ -1586,13 +1586,13 @@  discard block
 block discarded – undo
1586 1586
 			default :
1587 1587
 
1588 1588
 				// Allow other formats to be added via extensions
1589
-				do_action( 'give_api_output_' . $format, $this->data, $this );
1589
+				do_action('give_api_output_'.$format, $this->data, $this);
1590 1590
 
1591 1591
 				break;
1592 1592
 
1593 1593
 		endswitch;
1594 1594
 
1595
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1595
+		do_action('give_api_output_after', $this->data, $this, $format);
1596 1596
 
1597 1597
 		give_die();
1598 1598
 	}
@@ -1609,37 +1609,37 @@  discard block
 block discarded – undo
1609 1609
 	 *
1610 1610
 	 * @return void
1611 1611
 	 */
1612
-	function user_key_field( $user ) {
1612
+	function user_key_field($user) {
1613 1613
 
1614
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1615
-			$user = get_userdata( $user->ID );
1614
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1615
+			$user = get_userdata($user->ID);
1616 1616
 			?>
1617 1617
 			<table class="form-table">
1618 1618
 				<tbody>
1619 1619
 				<tr>
1620 1620
 					<th>
1621
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1621
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1622 1622
 					</th>
1623 1623
 					<td>
1624 1624
 						<?php
1625
-						$public_key = $this->get_user_public_key( $user->ID );
1626
-						$secret_key = $this->get_user_secret_key( $user->ID );
1625
+						$public_key = $this->get_user_public_key($user->ID);
1626
+						$secret_key = $this->get_user_secret_key($user->ID);
1627 1627
 						?>
1628
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1628
+						<?php if (empty($user->give_user_public_key)) { ?>
1629 1629
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1630
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1630
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1631 1631
 						<?php } else { ?>
1632
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1633
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1632
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>&nbsp;</strong>
1633
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1634 1634
 							<br/>
1635
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1636
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1635
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>&nbsp;</strong>
1636
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1637 1637
 							<br/>
1638
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1639
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1638
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>&nbsp;</strong>
1639
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1640 1640
 							<br/>
1641 1641
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1642
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1642
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1643 1643
 						<?php } ?>
1644 1644
 					</td>
1645 1645
 				</tr>
@@ -1658,69 +1658,69 @@  discard block
 block discarded – undo
1658 1658
 	 *
1659 1659
 	 * @return void
1660 1660
 	 */
1661
-	public function process_api_key( $args ) {
1661
+	public function process_api_key($args) {
1662 1662
 
1663
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1663
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1664 1664
 
1665
-			wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
1665
+			wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
1666 1666
 
1667 1667
 		}
1668 1668
 
1669
-		if ( empty( $args['user_id'] ) ) {
1670
-			wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) );
1669
+		if (empty($args['user_id'])) {
1670
+			wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401));
1671 1671
 		}
1672 1672
 
1673
-		if ( is_numeric( $args['user_id'] ) ) {
1674
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1673
+		if (is_numeric($args['user_id'])) {
1674
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1675 1675
 		} else {
1676
-			$userdata = get_user_by( 'login', $args['user_id'] );
1676
+			$userdata = get_user_by('login', $args['user_id']);
1677 1677
 			$user_id  = $userdata->ID;
1678 1678
 		}
1679
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1679
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1680 1680
 
1681
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1681
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1682 1682
 			wp_die(
1683 1683
 				sprintf(
1684 1684
 					/* translators: %s: process */
1685
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1685
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1686 1686
 					$process
1687 1687
 				),
1688
-				esc_html__( 'Error', 'give' ),
1689
-				array( 'response' => 403 )
1688
+				esc_html__('Error', 'give'),
1689
+				array('response' => 403)
1690 1690
 			);
1691
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1691
+		} elseif ( ! current_user_can('manage_give_settings')) {
1692 1692
 			wp_die(
1693 1693
 				sprintf(
1694 1694
 					/* translators: %s: process */
1695
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1695
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1696 1696
 					$process
1697 1697
 				),
1698
-				esc_html__( 'Error', 'give' ),
1699
-				array( 'response' => 403 )
1698
+				esc_html__('Error', 'give'),
1699
+				array('response' => 403)
1700 1700
 			);
1701 1701
 		}
1702 1702
 
1703
-		switch ( $process ) {
1703
+		switch ($process) {
1704 1704
 			case 'generate':
1705
-				if ( $this->generate_api_key( $user_id ) ) {
1706
-					delete_transient( 'give-total-api-keys' );
1707
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1705
+				if ($this->generate_api_key($user_id)) {
1706
+					delete_transient('give-total-api-keys');
1707
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1708 1708
 					exit();
1709 1709
 				} else {
1710
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1710
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1711 1711
 					exit();
1712 1712
 				}
1713 1713
 				break;
1714 1714
 			case 'regenerate':
1715
-				$this->generate_api_key( $user_id, true );
1716
-				delete_transient( 'give-total-api-keys' );
1717
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1715
+				$this->generate_api_key($user_id, true);
1716
+				delete_transient('give-total-api-keys');
1717
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1718 1718
 				exit();
1719 1719
 				break;
1720 1720
 			case 'revoke':
1721
-				$this->revoke_api_key( $user_id );
1722
-				delete_transient( 'give-total-api-keys' );
1723
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1721
+				$this->revoke_api_key($user_id);
1722
+				delete_transient('give-total-api-keys');
1723
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1724 1724
 				exit();
1725 1725
 				break;
1726 1726
 			default;
@@ -1739,34 +1739,34 @@  discard block
 block discarded – undo
1739 1739
 	 *
1740 1740
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1741 1741
 	 */
1742
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1742
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1743 1743
 
1744
-		if ( empty( $user_id ) ) {
1744
+		if (empty($user_id)) {
1745 1745
 			return false;
1746 1746
 		}
1747 1747
 
1748
-		$user = get_userdata( $user_id );
1748
+		$user = get_userdata($user_id);
1749 1749
 
1750
-		if ( ! $user ) {
1750
+		if ( ! $user) {
1751 1751
 			return false;
1752 1752
 		}
1753 1753
 
1754
-		$public_key = $this->get_user_public_key( $user_id );
1755
-		$secret_key = $this->get_user_secret_key( $user_id );
1754
+		$public_key = $this->get_user_public_key($user_id);
1755
+		$secret_key = $this->get_user_secret_key($user_id);
1756 1756
 
1757
-		if ( empty( $public_key ) || $regenerate == true ) {
1758
-			$new_public_key = $this->generate_public_key( $user->user_email );
1759
-			$new_secret_key = $this->generate_private_key( $user->ID );
1757
+		if (empty($public_key) || $regenerate == true) {
1758
+			$new_public_key = $this->generate_public_key($user->user_email);
1759
+			$new_secret_key = $this->generate_private_key($user->ID);
1760 1760
 		} else {
1761 1761
 			return false;
1762 1762
 		}
1763 1763
 
1764
-		if ( $regenerate == true ) {
1765
-			$this->revoke_api_key( $user->ID );
1764
+		if ($regenerate == true) {
1765
+			$this->revoke_api_key($user->ID);
1766 1766
 		}
1767 1767
 
1768
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1769
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1768
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1769
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1770 1770
 
1771 1771
 		return true;
1772 1772
 	}
@@ -1781,26 +1781,26 @@  discard block
 block discarded – undo
1781 1781
 	 *
1782 1782
 	 * @return string
1783 1783
 	 */
1784
-	public function revoke_api_key( $user_id = 0 ) {
1784
+	public function revoke_api_key($user_id = 0) {
1785 1785
 
1786
-		if ( empty( $user_id ) ) {
1786
+		if (empty($user_id)) {
1787 1787
 			return false;
1788 1788
 		}
1789 1789
 
1790
-		$user = get_userdata( $user_id );
1790
+		$user = get_userdata($user_id);
1791 1791
 
1792
-		if ( ! $user ) {
1792
+		if ( ! $user) {
1793 1793
 			return false;
1794 1794
 		}
1795 1795
 
1796
-		$public_key = $this->get_user_public_key( $user_id );
1797
-		$secret_key = $this->get_user_secret_key( $user_id );
1798
-		if ( ! empty( $public_key ) ) {
1799
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1800
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1801
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1802
-			delete_user_meta( $user_id, $public_key );
1803
-			delete_user_meta( $user_id, $secret_key );
1796
+		$public_key = $this->get_user_public_key($user_id);
1797
+		$secret_key = $this->get_user_secret_key($user_id);
1798
+		if ( ! empty($public_key)) {
1799
+			delete_transient(md5('give_api_user_'.$public_key));
1800
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1801
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1802
+			delete_user_meta($user_id, $public_key);
1803
+			delete_user_meta($user_id, $secret_key);
1804 1804
 		} else {
1805 1805
 			return false;
1806 1806
 		}
@@ -1825,22 +1825,22 @@  discard block
 block discarded – undo
1825 1825
 	 *
1826 1826
 	 * @return void
1827 1827
 	 */
1828
-	public function update_key( $user_id ) {
1829
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1828
+	public function update_key($user_id) {
1829
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1830 1830
 
1831
-			$user = get_userdata( $user_id );
1831
+			$user = get_userdata($user_id);
1832 1832
 
1833
-			$public_key = $this->get_user_public_key( $user_id );
1834
-			$secret_key = $this->get_user_secret_key( $user_id );
1833
+			$public_key = $this->get_user_public_key($user_id);
1834
+			$secret_key = $this->get_user_secret_key($user_id);
1835 1835
 
1836
-			if ( empty( $public_key ) ) {
1837
-				$new_public_key = $this->generate_public_key( $user->user_email );
1838
-				$new_secret_key = $this->generate_private_key( $user->ID );
1836
+			if (empty($public_key)) {
1837
+				$new_public_key = $this->generate_public_key($user->user_email);
1838
+				$new_secret_key = $this->generate_private_key($user->ID);
1839 1839
 
1840
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1841
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1840
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1841
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1842 1842
 			} else {
1843
-				$this->revoke_api_key( $user_id );
1843
+				$this->revoke_api_key($user_id);
1844 1844
 			}
1845 1845
 		}
1846 1846
 	}
@@ -1855,9 +1855,9 @@  discard block
 block discarded – undo
1855 1855
 	 *
1856 1856
 	 * @return string
1857 1857
 	 */
1858
-	private function generate_public_key( $user_email = '' ) {
1859
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1860
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1858
+	private function generate_public_key($user_email = '') {
1859
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1860
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1861 1861
 
1862 1862
 		return $public;
1863 1863
 	}
@@ -1872,9 +1872,9 @@  discard block
 block discarded – undo
1872 1872
 	 *
1873 1873
 	 * @return string
1874 1874
 	 */
1875
-	private function generate_private_key( $user_id = 0 ) {
1876
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1877
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1875
+	private function generate_private_key($user_id = 0) {
1876
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1877
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1878 1878
 
1879 1879
 		return $secret;
1880 1880
 	}
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 	 *
1890 1890
 	 * @return string
1891 1891
 	 */
1892
-	public function get_token( $user_id = 0 ) {
1893
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1892
+	public function get_token($user_id = 0) {
1893
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1894 1894
 	}
1895 1895
 
1896 1896
 	/**
@@ -1904,9 +1904,9 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
 		// Default sales return
1906 1906
 		$sales                               = array();
1907
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1908
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1909
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1907
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1908
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1909
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1910 1910
 		$sales['donations']['totals']        = give_get_total_sales();
1911 1911
 
1912 1912
 		return $sales;
@@ -1923,9 +1923,9 @@  discard block
 block discarded – undo
1923 1923
 
1924 1924
 		// Default earnings return
1925 1925
 		$earnings                              = array();
1926
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1927
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1928
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1926
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1927
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1928
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1929 1929
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1930 1930
 
1931 1931
 		return $earnings;
@@ -1945,25 +1945,25 @@  discard block
 block discarded – undo
1945 1945
 	 *
1946 1946
 	 * @return string            The API key/secret for the user supplied
1947 1947
 	 */
1948
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1948
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1949 1949
 
1950
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1950
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1951 1951
 			return $check;
1952 1952
 		}
1953 1953
 
1954 1954
 		$return = $check;
1955 1955
 
1956
-		switch ( $meta_key ) {
1956
+		switch ($meta_key) {
1957 1957
 			case 'give_user_public_key':
1958
-				$return = Give()->api->get_user_public_key( $object_id );
1958
+				$return = Give()->api->get_user_public_key($object_id);
1959 1959
 				break;
1960 1960
 			case 'give_user_secret_key':
1961
-				$return = Give()->api->get_user_secret_key( $object_id );
1961
+				$return = Give()->api->get_user_secret_key($object_id);
1962 1962
 				break;
1963 1963
 		}
1964 1964
 
1965
-		if ( ! $single ) {
1966
-			$return = array( $return );
1965
+		if ( ! $single) {
1966
+			$return = array($return);
1967 1967
 		}
1968 1968
 
1969 1969
 		return $return;
Please login to merge, or discard this patch.
includes/shortcodes.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		//validate display_style and float_labels value
93 93
 		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
94
+			 || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
95 95
 		) {
96 96
 
97 97
 			$atts[ $key ] = '';
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function give_login_form_shortcode( $atts, $content = null ) {
171 171
 	$atts = shortcode_atts( array(
172
-        // Add backward compatibility for redirect attribute.
173
-        'redirect'          => '',
172
+		// Add backward compatibility for redirect attribute.
173
+		'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177 177
 	), $atts, 'give_login' );
178 178
 
179
-    // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
179
+	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
+	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
181 181
 
182 182
 	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
183 183
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 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
 
@@ -25,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('Error: No Donation form ID for the shortcode provided.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check that this form even has Goals enabled
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( esc_html__( 'Error: This form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(esc_html__('Error: This form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
         // Add backward compatibility for redirect attribute.
173 173
         'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177
-	), $atts, 'give_login' );
177
+	), $atts, 'give_login');
178 178
 
179 179
     // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
180
+    $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
181 181
 
182
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
182
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
183 183
 }
184 184
 
185
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
185
+add_shortcode('give_login', 'give_login_form_shortcode');
186 186
 
187 187
 /**
188 188
  * Register Shortcode
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
  * @uses  give_register_form()
198 198
  * @return string
199 199
  */
200
-function give_register_form_shortcode( $atts, $content = null ) {
201
-	$atts = shortcode_atts( array(
200
+function give_register_form_shortcode($atts, $content = null) {
201
+	$atts = shortcode_atts(array(
202 202
 		'redirect' => '',
203
-	), $atts, 'give_register' );
203
+	), $atts, 'give_register');
204 204
 
205
-	return give_register_form( $atts['redirect'] );
205
+	return give_register_form($atts['redirect']);
206 206
 }
207 207
 
208
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
208
+add_shortcode('give_register', 'give_register_form_shortcode');
209 209
 
210 210
 
211 211
 /**
@@ -220,62 +220,62 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string
222 222
  */
223
-function give_receipt_shortcode( $atts, $content = null ) {
223
+function give_receipt_shortcode($atts, $content = null) {
224 224
 
225 225
 	global $give_receipt_args, $payment;
226 226
 
227
-	$give_receipt_args = shortcode_atts( array(
228
-		'error'          => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ),
227
+	$give_receipt_args = shortcode_atts(array(
228
+		'error'          => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'),
229 229
 		'price'          => true,
230 230
 		'donor'          => true,
231 231
 		'date'           => true,
232 232
 		'payment_key'    => false,
233 233
 		'payment_method' => true,
234 234
 		'payment_id'     => true
235
-	), $atts, 'give_receipt' );
235
+	), $atts, 'give_receipt');
236 236
 
237 237
 	//set $session var
238 238
 	$session = give_get_purchase_session();
239 239
 
240 240
 	//set payment key var
241
-	if ( isset( $_GET['payment_key'] ) ) {
242
-		$payment_key = urldecode( $_GET['payment_key'] );
243
-	} elseif ( $session ) {
241
+	if (isset($_GET['payment_key'])) {
242
+		$payment_key = urldecode($_GET['payment_key']);
243
+	} elseif ($session) {
244 244
 		$payment_key = $session['purchase_key'];
245
-	} elseif ( $give_receipt_args['payment_key'] ) {
245
+	} elseif ($give_receipt_args['payment_key']) {
246 246
 		$payment_key = $give_receipt_args['payment_key'];
247 247
 	}
248 248
 
249
-	$email_access = give_get_option( 'email_access' );
249
+	$email_access = give_get_option('email_access');
250 250
 
251 251
 	// No payment_key found & Email Access is Turned on:
252
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
252
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
253 253
 
254 254
 		ob_start();
255 255
 
256
-		give_get_template_part( 'email-login-form' );
256
+		give_get_template_part('email-login-form');
257 257
 
258 258
 		return ob_get_clean();
259 259
 
260
-	} elseif ( ! isset( $payment_key ) ) {
260
+	} elseif ( ! isset($payment_key)) {
261 261
 
262
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
262
+		return give_output_error($give_receipt_args['error'], false, 'error');
263 263
 
264 264
 	}
265 265
 
266
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
267
-	$user_can_view = give_can_view_receipt( $payment_key );
266
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
267
+	$user_can_view = give_can_view_receipt($payment_key);
268 268
 
269 269
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt
270
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
270
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
271 271
 
272 272
 		ob_start();
273 273
 
274
-		give_get_template_part( 'email-login-form' );
274
+		give_get_template_part('email-login-form');
275 275
 
276 276
 		return ob_get_clean();
277 277
 
278
-	} elseif ( ! $user_can_view ) {
278
+	} elseif ( ! $user_can_view) {
279 279
 
280 280
 		global $give_login_redirect;
281 281
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 		ob_start();
285 285
 
286
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) );
286
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give')));
287 287
 
288
-		give_get_template_part( 'shortcode', 'login' );
288
+		give_get_template_part('shortcode', 'login');
289 289
 
290 290
 		$login_form = ob_get_clean();
291 291
 
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 	 * Or if user is logged in and the user can view sensitive shop data
303 303
 	 *
304 304
 	 */
305
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
306
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
305
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
306
+		return give_output_error($give_receipt_args['error'], false, 'error');
307 307
 	}
308 308
 
309 309
 	ob_start();
310 310
 
311
-	give_get_template_part( 'shortcode', 'receipt' );
311
+	give_get_template_part('shortcode', 'receipt');
312 312
 
313 313
 	$display = ob_get_clean();
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 }
319 319
 
320
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
320
+add_shortcode('give_receipt', 'give_receipt_shortcode');
321 321
 
322 322
 /**
323 323
  * Profile Editor Shortcode
@@ -337,18 +337,18 @@  discard block
 block discarded – undo
337 337
  *
338 338
  * @return string Output generated from the profile editor
339 339
  */
340
-function give_profile_editor_shortcode( $atts, $content = null ) {
340
+function give_profile_editor_shortcode($atts, $content = null) {
341 341
 
342 342
 	ob_start();
343 343
 
344
-	give_get_template_part( 'shortcode', 'profile-editor' );
344
+	give_get_template_part('shortcode', 'profile-editor');
345 345
 
346 346
 	$display = ob_get_clean();
347 347
 
348 348
 	return $display;
349 349
 }
350 350
 
351
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
351
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
352 352
 
353 353
 /**
354 354
  * Process Profile Updater Form
@@ -361,30 +361,30 @@  discard block
 block discarded – undo
361 361
  *
362 362
  * @return bool
363 363
  */
364
-function give_process_profile_editor_updates( $data ) {
364
+function give_process_profile_editor_updates($data) {
365 365
 	// Profile field change request
366
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
366
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
367 367
 		return false;
368 368
 	}
369 369
 
370 370
 	// Nonce security
371
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
371
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
372 372
 		return false;
373 373
 	}
374 374
 
375 375
 	$user_id       = get_current_user_id();
376
-	$old_user_data = get_userdata( $user_id );
377
-
378
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
379
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
380
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
381
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
382
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
383
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
384
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
385
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
386
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
387
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
376
+	$old_user_data = get_userdata($user_id);
377
+
378
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
379
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
380
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
381
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
382
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
383
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
384
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
385
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
386
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
387
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
388 388
 
389 389
 	$userdata = array(
390 390
 		'ID'           => $user_id,
@@ -404,45 +404,45 @@  discard block
 block discarded – undo
404 404
 		'country' => $country
405 405
 	);
406 406
 
407
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
407
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
408 408
 
409 409
 	// New password
410
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
411
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
412
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
410
+	if ( ! empty($data['give_new_user_pass1'])) {
411
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
412
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
413 413
 		} else {
414 414
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
415 415
 		}
416 416
 	}
417 417
 
418 418
 	// Make sure the new email doesn't belong to another user
419
-	if ( $email != $old_user_data->user_email ) {
420
-		if ( email_exists( $email ) ) {
421
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
419
+	if ($email != $old_user_data->user_email) {
420
+		if (email_exists($email)) {
421
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
422 422
 		}
423 423
 	}
424 424
 
425 425
 	// Check for errors
426 426
 	$errors = give_get_errors();
427 427
 
428
-	if ( $errors ) {
428
+	if ($errors) {
429 429
 		// Send back to the profile editor if there are errors
430
-		wp_redirect( $data['give_redirect'] );
430
+		wp_redirect($data['give_redirect']);
431 431
 		give_die();
432 432
 	}
433 433
 
434 434
 	// Update the user
435
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
436
-	$updated = wp_update_user( $userdata );
435
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
436
+	$updated = wp_update_user($userdata);
437 437
 
438
-	if ( $updated ) {
439
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
440
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
438
+	if ($updated) {
439
+		do_action('give_user_profile_updated', $user_id, $userdata);
440
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
441 441
 		give_die();
442 442
 	}
443 443
 
444 444
 	return false;
445 445
 }
446 446
 
447
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
447
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
448 448
 
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@
 block discarded – undo
182 182
 	 *
183 183
 	 * @param  array $data Array of attributes for a donation form
184 184
 	 *
185
-	 * @return mixed  false if data isn't passed and class not instantiated for creation, or New Form ID
185
+	 * @return boolean  false if data isn't passed and class not instantiated for creation, or New Form ID
186 186
 	 */
187 187
 	public function create( $data = array() ) {
188 188
 
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -463,31 +463,31 @@
 block discarded – undo
463 463
 
464 464
 	}
465 465
 
466
-    /**
467
-     * Get if form type set or not.
468
-     *
469
-     * @since 1.6
470
-     * @return bool true if form type is 'multi' and false otherwise.
471
-     */
472
-    public function is_set_type_donation_form() {
473
-        $form_type = $this->get_type();
474
-
475
-        return ( 'set' === $form_type ? true : false );
476
-
477
-    }
478
-
479
-    /**
480
-     * Get if form type multi or not.
481
-     *
482
-     * @since 1.6
483
-     * @return bool true if form type is 'multi' and false otherwise.
484
-     */
485
-    public function is_multi_type_donation_form() {
486
-        $form_type = $this->get_type();
487
-
488
-        return ( 'multi' === $form_type ? true : false );
489
-
490
-    }
466
+	/**
467
+	 * Get if form type set or not.
468
+	 *
469
+	 * @since 1.6
470
+	 * @return bool true if form type is 'multi' and false otherwise.
471
+	 */
472
+	public function is_set_type_donation_form() {
473
+		$form_type = $this->get_type();
474
+
475
+		return ( 'set' === $form_type ? true : false );
476
+
477
+	}
478
+
479
+	/**
480
+	 * Get if form type multi or not.
481
+	 *
482
+	 * @since 1.6
483
+	 * @return bool true if form type is 'multi' and false otherwise.
484
+	 */
485
+	public function is_multi_type_donation_form() {
486
+		$form_type = $this->get_type();
487
+
488
+		return ( 'multi' === $form_type ? true : false );
489
+
490
+	}
491 491
 
492 492
 	/**
493 493
 	 * Retrieve the sale count for the donation form
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 	 * @param bool $_id
101 101
 	 * @param array $_args
102 102
 	 */
103
-	public function __construct( $_id = false, $_args = array() ) {
103
+	public function __construct($_id = false, $_args = array()) {
104 104
 
105 105
 
106
-		$donation_form = WP_Post::get_instance( $_id );
106
+		$donation_form = WP_Post::get_instance($_id);
107 107
 
108
-		return $this->setup_donation_form( $donation_form );
108
+		return $this->setup_donation_form($donation_form);
109 109
 	}
110 110
 
111 111
 	/**
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return bool             If the setup was successful or not
121 121
 	 */
122
-	private function setup_donation_form( $donation_form ) {
122
+	private function setup_donation_form($donation_form) {
123 123
 
124
-		if ( ! is_object( $donation_form ) ) {
124
+		if ( ! is_object($donation_form)) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
128
+		if ( ! is_a($donation_form, 'WP_Post')) {
129 129
 			return false;
130 130
 		}
131 131
 
132
-		if ( 'give_forms' !== $donation_form->post_type ) {
132
+		if ('give_forms' !== $donation_form->post_type) {
133 133
 			return false;
134 134
 		}
135 135
 
136
-		foreach ( $donation_form as $key => $value ) {
136
+		foreach ($donation_form as $key => $value) {
137 137
 
138
-			switch ( $key ) {
138
+			switch ($key) {
139 139
 
140 140
 				default:
141 141
 					$this->$key = $value;
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
 	 * @return mixed
160 160
 	 * @throws Exception
161 161
 	 */
162
-	public function __get( $key ) {
162
+	public function __get($key) {
163 163
 
164
-		if ( method_exists( $this, 'get_' . $key ) ) {
164
+		if (method_exists($this, 'get_'.$key)) {
165 165
 
166
-			return call_user_func( array( $this, 'get_' . $key ) );
166
+			return call_user_func(array($this, 'get_'.$key));
167 167
 
168 168
 		} else {
169 169
 
170 170
 			/* translators: %s: property key */
171
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
171
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
172 172
 
173 173
 		}
174 174
 
@@ -184,30 +184,30 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @return mixed  false if data isn't passed and class not instantiated for creation, or New Form ID
186 186
 	 */
187
-	public function create( $data = array() ) {
187
+	public function create($data = array()) {
188 188
 
189
-		if ( $this->id != 0 ) {
189
+		if ($this->id != 0) {
190 190
 			return false;
191 191
 		}
192 192
 
193 193
 		$defaults = array(
194 194
 			'post_type'   => 'give_forms',
195 195
 			'post_status' => 'draft',
196
-			'post_title'  => esc_html__( 'New Donation Form', 'give' )
196
+			'post_title'  => esc_html__('New Donation Form', 'give')
197 197
 		);
198 198
 
199
-		$args = wp_parse_args( $data, $defaults );
199
+		$args = wp_parse_args($data, $defaults);
200 200
 
201 201
 		/**
202 202
 		 * Fired before a donation form is created
203 203
 		 *
204 204
 		 * @param array $args The post object arguments used for creation.
205 205
 		 */
206
-		do_action( 'give_form_pre_create', $args );
206
+		do_action('give_form_pre_create', $args);
207 207
 
208
-		$id = wp_insert_post( $args, true );
208
+		$id = wp_insert_post($args, true);
209 209
 
210
-		$donation_form = WP_Post::get_instance( $id );
210
+		$donation_form = WP_Post::get_instance($id);
211 211
 
212 212
 		/**
213 213
 		 * Fired after a donation form is created
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 		 * @param int $id The post ID of the created item.
216 216
 		 * @param array $args The post object arguments used for creation.
217 217
 		 */
218
-		do_action( 'give_form_post_create', $id, $args );
218
+		do_action('give_form_post_create', $id, $args);
219 219
 
220
-		return $this->setup_donation_form( $donation_form );
220
+		return $this->setup_donation_form($donation_form);
221 221
 
222 222
 	}
223 223
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @return string Name of the donation form
241 241
 	 */
242 242
 	public function get_name() {
243
-		return get_the_title( $this->ID );
243
+		return get_the_title($this->ID);
244 244
 	}
245 245
 
246 246
 	/**
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function get_price() {
253 253
 
254
-		if ( ! isset( $this->price ) ) {
254
+		if ( ! isset($this->price)) {
255 255
 
256
-			$this->price = get_post_meta( $this->ID, '_give_set_price', true );
256
+			$this->price = get_post_meta($this->ID, '_give_set_price', true);
257 257
 
258
-			if ( $this->price ) {
258
+			if ($this->price) {
259 259
 
260
-				$this->price = give_sanitize_amount( $this->price );
260
+				$this->price = give_sanitize_amount($this->price);
261 261
 
262 262
 			} else {
263 263
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		 * @param string $price The donation form price.
276 276
 		 * @param string|int $id The form ID.
277 277
 		 */
278
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
278
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
279 279
 	}
280 280
 
281 281
 	/**
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	public function get_minimum_price() {
288 288
 
289
-		if ( ! isset( $this->minimum_price ) ) {
289
+		if ( ! isset($this->minimum_price)) {
290 290
 
291
-			$allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true );
292
-			$this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true );
291
+			$allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true);
292
+			$this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true);
293 293
 
294
-			if ( $allow_custom_amount != 'no' && $this->minimum_price ) {
294
+			if ($allow_custom_amount != 'no' && $this->minimum_price) {
295 295
 
296
-				$this->minimum_price = give_sanitize_amount( $this->minimum_price );
296
+				$this->minimum_price = give_sanitize_amount($this->minimum_price);
297 297
 
298 298
 			} else {
299 299
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 
304 304
 		}
305 305
 
306
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
306
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_prices() {
316 316
 
317
-		if ( ! isset( $this->prices ) ) {
317
+		if ( ! isset($this->prices)) {
318 318
 
319
-			$this->prices = get_post_meta( $this->ID, '_give_donation_levels', true );
319
+			$this->prices = get_post_meta($this->ID, '_give_donation_levels', true);
320 320
 
321 321
 		}
322 322
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 		 * @param array $prices The array of mulit-level prices.
329 329
 		 * @param int|string The ID of the form.
330 330
 		 */
331
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
331
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
332 332
 
333 333
 	}
334 334
 
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	public function get_goal() {
342 342
 
343
-		if ( ! isset( $this->goal ) ) {
343
+		if ( ! isset($this->goal)) {
344 344
 
345
-			$this->goal = get_post_meta( $this->ID, '_give_set_goal', true );
345
+			$this->goal = get_post_meta($this->ID, '_give_set_goal', true);
346 346
 
347
-			if ( $this->goal ) {
347
+			if ($this->goal) {
348 348
 
349
-				$this->goal = give_sanitize_amount( $this->goal );
349
+				$this->goal = give_sanitize_amount($this->goal);
350 350
 
351 351
 			} else {
352 352
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 
357 357
 		}
358 358
 
359
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
359
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
360 360
 
361 361
 	}
362 362
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	public function is_single_price_mode() {
370 370
 
371
-		$option = get_post_meta( $this->ID, '_give_price_options_mode', true );
371
+		$option = get_post_meta($this->ID, '_give_price_options_mode', true);
372 372
 		$ret    = 0;
373 373
 
374
-		if ( empty( $option ) || $option === 'set' ) {
374
+		if (empty($option) || $option === 'set') {
375 375
 			$ret = 1;
376 376
 		}
377 377
 		
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 		 * @param bool $ret Is donation form in single price mode?
384 384
 		 * @param int|string The ID of the donation form.
385 385
 		 */
386
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
386
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
387 387
 
388 388
 	}
389 389
 
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 	 */
396 396
 	public function is_custom_price_mode() {
397 397
 
398
-		$option = get_post_meta( $this->ID, '_give_custom_amount', true );
398
+		$option = get_post_meta($this->ID, '_give_custom_amount', true);
399 399
 		$ret    = 0;
400 400
 
401
-		if ( $option === 'yes' ) {
401
+		if ($option === 'yes') {
402 402
 			$ret = 1;
403 403
 		}
404 404
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		 * @param bool $ret Is donation form in custom price mode?
411 411
 		 * @param int|string The ID of the donation form.
412 412
 		 */
413
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
413
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
414 414
 
415 415
 	}
416 416
 
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	public function has_variable_prices() {
426 426
 
427
-		$option = get_post_meta( $this->ID, '_give_price_option', true );
427
+		$option = get_post_meta($this->ID, '_give_price_option', true);
428 428
 		$ret    = 0;
429 429
 
430
-		if ( $option === 'multi' ) {
430
+		if ($option === 'multi') {
431 431
 			$ret = 1;
432 432
 		}
433 433
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		 * @param bool $ret Does donation form have variable prices?
438 438
 		 * @param int|string The ID of the donation form.
439 439
 		 */
440
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
440
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
441 441
 
442 442
 	}
443 443
 
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
 	 */
450 450
 	public function get_type() {
451 451
 
452
-		if ( ! isset( $this->type ) ) {
452
+		if ( ! isset($this->type)) {
453 453
 
454
-			$this->type = get_post_meta( $this->ID, '_give_price_option', true );
454
+			$this->type = get_post_meta($this->ID, '_give_price_option', true);
455 455
 
456
-			if ( empty( $this->type ) ) {
456
+			if (empty($this->type)) {
457 457
 				$this->type = 'set';
458 458
 			}
459 459
 
460 460
 		}
461 461
 
462
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
462
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
463 463
 
464 464
 	}
465 465
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     public function is_set_type_donation_form() {
473 473
         $form_type = $this->get_type();
474 474
 
475
-        return ( 'set' === $form_type ? true : false );
475
+        return ('set' === $form_type ? true : false);
476 476
 
477 477
     }
478 478
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
     public function is_multi_type_donation_form() {
486 486
         $form_type = $this->get_type();
487 487
 
488
-        return ( 'multi' === $form_type ? true : false );
488
+        return ('multi' === $form_type ? true : false);
489 489
 
490 490
     }
491 491
 
@@ -497,15 +497,15 @@  discard block
 block discarded – undo
497 497
 	 */
498 498
 	public function get_sales() {
499 499
 
500
-		if ( ! isset( $this->sales ) ) {
500
+		if ( ! isset($this->sales)) {
501 501
 
502
-			if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) {
503
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
502
+			if ('' == get_post_meta($this->ID, '_give_form_sales', true)) {
503
+				add_post_meta($this->ID, '_give_form_sales', 0);
504 504
 			} // End if
505 505
 
506
-			$this->sales = get_post_meta( $this->ID, '_give_form_sales', true );
506
+			$this->sales = get_post_meta($this->ID, '_give_form_sales', true);
507 507
 
508
-			if ( $this->sales < 0 ) {
508
+			if ($this->sales < 0) {
509 509
 				// Never let sales be less than zero
510 510
 				$this->sales = 0;
511 511
 			}
@@ -525,13 +525,13 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return int|false  New number of total sales
527 527
 	 */
528
-	public function increase_sales( $quantity = 1 ) {
528
+	public function increase_sales($quantity = 1) {
529 529
 
530
-		$sales       = give_get_form_sales_stats( $this->ID );
531
-		$quantity    = absint( $quantity );
530
+		$sales       = give_get_form_sales_stats($this->ID);
531
+		$quantity    = absint($quantity);
532 532
 		$total_sales = $sales + $quantity;
533 533
 
534
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
534
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
535 535
 
536 536
 			$this->sales = $total_sales;
537 537
 
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
 	 *
552 552
 	 * @return int|false  New number of total sales
553 553
 	 */
554
-	public function decrease_sales( $quantity = 1 ) {
554
+	public function decrease_sales($quantity = 1) {
555 555
 
556
-		$sales = give_get_form_sales_stats( $this->ID );
556
+		$sales = give_get_form_sales_stats($this->ID);
557 557
 
558 558
 		// Only decrease if not already zero
559
-		if ( $sales > 0 ) {
559
+		if ($sales > 0) {
560 560
 
561
-			$quantity    = absint( $quantity );
561
+			$quantity    = absint($quantity);
562 562
 			$total_sales = $sales - $quantity;
563 563
 
564
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
564
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
565 565
 
566 566
 				$this->sales = $sales;
567 567
 
@@ -583,15 +583,15 @@  discard block
 block discarded – undo
583 583
 	 */
584 584
 	public function get_earnings() {
585 585
 
586
-		if ( ! isset( $this->earnings ) ) {
586
+		if ( ! isset($this->earnings)) {
587 587
 
588
-			if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) {
589
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
588
+			if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) {
589
+				add_post_meta($this->ID, '_give_form_earnings', 0);
590 590
 			}
591 591
 
592
-			$this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true );
592
+			$this->earnings = get_post_meta($this->ID, '_give_form_earnings', true);
593 593
 
594
-			if ( $this->earnings < 0 ) {
594
+			if ($this->earnings < 0) {
595 595
 				// Never let earnings be less than zero
596 596
 				$this->earnings = 0;
597 597
 			}
@@ -611,12 +611,12 @@  discard block
 block discarded – undo
611 611
 	 * 
612 612
 	 * @return float|false
613 613
 	 */
614
-	public function increase_earnings( $amount = 0 ) {
614
+	public function increase_earnings($amount = 0) {
615 615
 
616
-		$earnings   = give_get_form_earnings_stats( $this->ID );
616
+		$earnings   = give_get_form_earnings_stats($this->ID);
617 617
 		$new_amount = $earnings + (float) $amount;
618 618
 
619
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
619
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
620 620
 
621 621
 			$this->earnings = $new_amount;
622 622
 
@@ -634,16 +634,16 @@  discard block
 block discarded – undo
634 634
 	 * @since 1.0
635 635
 	 * @return float|false
636 636
 	 */
637
-	public function decrease_earnings( $amount ) {
637
+	public function decrease_earnings($amount) {
638 638
 
639
-		$earnings = give_get_form_earnings_stats( $this->ID );
639
+		$earnings = give_get_form_earnings_stats($this->ID);
640 640
 
641
-		if ( $earnings > 0 ) {
641
+		if ($earnings > 0) {
642 642
 			// Only decrease if greater than zero
643 643
 			$new_amount = $earnings - (float) $amount;
644 644
 
645 645
 
646
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
646
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
647 647
 
648 648
 				$this->earnings = $new_amount;
649 649
 
@@ -663,22 +663,22 @@  discard block
 block discarded – undo
663 663
 	 * @since 1.0
664 664
 	 * @return bool
665 665
 	 */
666
-	public function is_free( $price_id = false ) {
666
+	public function is_free($price_id = false) {
667 667
 
668 668
 		$is_free          = false;
669
-		$variable_pricing = give_has_variable_prices( $this->ID );
669
+		$variable_pricing = give_has_variable_prices($this->ID);
670 670
 
671
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
672
-			$price = give_get_price_option_amount( $this->ID, $price_id );
673
-		} elseif ( ! $variable_pricing ) {
674
-			$price = get_post_meta( $this->ID, '_give_set_price', true );
671
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
672
+			$price = give_get_price_option_amount($this->ID, $price_id);
673
+		} elseif ( ! $variable_pricing) {
674
+			$price = get_post_meta($this->ID, '_give_set_price', true);
675 675
 		}
676 676
 
677
-		if ( isset( $price ) && (float) $price == 0 ) {
677
+		if (isset($price) && (float) $price == 0) {
678 678
 			$is_free = true;
679 679
 		}
680 680
 
681
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
681
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
682 682
 
683 683
 	}
684 684
 
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
 	 */
696 696
 	public function is_close_donation_form() {
697 697
 		return (
698
-				'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) )
699
-				&& ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) )
700
-				&& ( $this->get_goal() <= $this->get_earnings()
698
+				'yes' === get_post_meta($this->ID, '_give_goal_option', true) )
699
+				&& ('yes' === get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true))
700
+				&& ($this->get_goal() <= $this->get_earnings()
701 701
 		);
702 702
 	}
703 703
 
@@ -713,29 +713,29 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 * @return bool                             The result of the update query
715 715
 	 */
716
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
716
+	private function update_meta($meta_key = '', $meta_value = '') {
717 717
 
718 718
 		/* @var WPDB $wpdb */
719 719
 		global $wpdb;
720 720
 
721
-		if ( empty( $meta_key ) || empty( $meta_value ) ) {
721
+		if (empty($meta_key) || empty($meta_value)) {
722 722
 			return false;
723 723
 		}
724 724
 
725 725
 		// Make sure if it needs to be serialized, we do
726
-		$meta_value = maybe_serialize( $meta_value );
726
+		$meta_value = maybe_serialize($meta_value);
727 727
 
728
-		if ( is_numeric( $meta_value ) ) {
729
-			$value_type = is_float( $meta_value ) ? '%f' : '%d';
728
+		if (is_numeric($meta_value)) {
729
+			$value_type = is_float($meta_value) ? '%f' : '%d';
730 730
 		} else {
731 731
 			$value_type = "'%s'";
732 732
 		}
733 733
 
734
-		$sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key );
734
+		$sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key);
735 735
 
736
-		if ( $wpdb->query( $sql ) ) {
736
+		if ($wpdb->query($sql)) {
737 737
 
738
-			clean_post_cache( $this->ID );
738
+			clean_post_cache($this->ID);
739 739
 
740 740
 			return true;
741 741
 
Please login to merge, or discard this patch.
includes/class-give-logging.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param array $log_data Log entry data
215 215
 	 * @param array $log_meta Log entry meta
216 216
 	 *
217
-	 * @return bool True if successful, false otherwise
217
+	 * @return boolean|null True if successful, false otherwise
218 218
 	 */
219 219
 	public function update_log( $log_data = array(), $log_meta = array() ) {
220 220
 
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
  * @param string $title
393 393
  * @param string $message
394 394
  * @param int $parent
395
- * @param null $type
395
+ * @param string $type
396 396
  *
397 397
  * @global $give_logs GIVE Logs Object
398 398
  *
399 399
  * @uses Give_Logging::add()
400 400
  *
401
- * @return mixed ID of the new log entry
401
+ * @return integer ID of the new log entry
402 402
  */
403 403
 function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
404 404
 	/* @var Give_Logging $give_logs */
Please login to merge, or discard this 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.