Test Failed
Pull Request — master (#3647)
by Ravinder
10:22
created
includes/admin/admin-filters.php 1 patch
Spacing   +60 added lines, -60 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
 
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @return  mixed
29 29
  */
30
-function __give_sanitize_number_decimals_setting_field( $value ) {
30
+function __give_sanitize_number_decimals_setting_field($value) {
31 31
 	$value_changed = false;
32 32
 	$old_value     = $value;
33 33
 
34
-	if ( isset( $_POST['decimal_separator'] ) ) {
35
-		$value         = ! empty( $_POST['decimal_separator'] ) ? $value : 0;
34
+	if (isset($_POST['decimal_separator'])) {
35
+		$value         = ! empty($_POST['decimal_separator']) ? $value : 0;
36 36
 		$value_changed = true;
37 37
 	}
38 38
 
39
-	if ( $value_changed && ( $old_value !== $value ) ) {
40
-		Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give' ) );
39
+	if ($value_changed && ($old_value !== $value)) {
40
+		Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give'));
41 41
 	}
42 42
 
43
-	$value = absint( $value );
43
+	$value = absint($value);
44 44
 
45
-	if ( 6 <= $value ) {
45
+	if (6 <= $value) {
46 46
 		$value = 5;
47
-		Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give' ) );
47
+		Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give'));
48 48
 	}
49 49
 
50
-	return absint( $value );
50
+	return absint($value);
51 51
 }
52 52
 
53
-add_filter( 'give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10 );
53
+add_filter('give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10);
54 54
 
55 55
 
56 56
 /**
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return  mixed
68 68
  */
69
-function __give_validate_decimal_separator_setting_field( $value ) {
70
-	$thousand_separator = isset( $_POST['thousands_separator'] ) ? give_clean( $_POST['thousands_separator'] ) : '';
71
-	$decimal_separator  = isset( $_POST['decimal_separator'] ) ? give_clean( $_POST['decimal_separator'] ) : '';
69
+function __give_validate_decimal_separator_setting_field($value) {
70
+	$thousand_separator = isset($_POST['thousands_separator']) ? give_clean($_POST['thousands_separator']) : '';
71
+	$decimal_separator  = isset($_POST['decimal_separator']) ? give_clean($_POST['decimal_separator']) : '';
72 72
 
73
-	if ( $decimal_separator === $thousand_separator ) {
73
+	if ($decimal_separator === $thousand_separator) {
74 74
 		$value                    = '';
75 75
 		$_POST['number_decimals'] = 0;
76
-		Give_Admin_Settings::add_error( 'give-decimal-separator', __( 'The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give' ) );
76
+		Give_Admin_Settings::add_error('give-decimal-separator', __('The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give'));
77 77
 	}
78 78
 
79 79
 	return $value;
80 80
 }
81 81
 
82
-add_filter( 'give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10 );
82
+add_filter('give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10);
83 83
 
84 84
 /**
85 85
  * Change $delimiter text to symbol.
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return string $delimiter.
92 92
  */
93
-function __give_import_delimiter_set_callback( $delimiter ) {
93
+function __give_import_delimiter_set_callback($delimiter) {
94 94
 	$delimite_type = array(
95 95
 		'csv'                  => ',',
96 96
 		'tab-separated-values' => "\t",
97 97
 	);
98 98
 
99
-	return ( array_key_exists( $delimiter, $delimite_type ) ? $delimite_type[ $delimiter ] : ',' );
99
+	return (array_key_exists($delimiter, $delimite_type) ? $delimite_type[$delimiter] : ',');
100 100
 }
101 101
 
102
-add_filter( 'give_import_delimiter_set', '__give_import_delimiter_set_callback', 10 );
102
+add_filter('give_import_delimiter_set', '__give_import_delimiter_set_callback', 10);
103 103
 
104 104
 /**
105 105
  * Give unset the page id from the core setting data from the json files.
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
  *
112 112
  * @return array $json_to_array
113 113
  */
114
-function give_import_core_settings_merge_pages( $json_to_array, $type ) {
115
-	if ( 'merge' === $type ) {
116
-		unset( $json_to_array['success_page'] );
117
-		unset( $json_to_array['failure_page'] );
118
-		unset( $json_to_array['history_page'] );
114
+function give_import_core_settings_merge_pages($json_to_array, $type) {
115
+	if ('merge' === $type) {
116
+		unset($json_to_array['success_page']);
117
+		unset($json_to_array['failure_page']);
118
+		unset($json_to_array['history_page']);
119 119
 	}
120 120
 
121 121
 	return $json_to_array;
122 122
 }
123 123
 
124
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2 );
124
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2);
125 125
 
126 126
 /**
127 127
  * Give check the image size from the core setting data from the json files.
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return array $json_to_array
135 135
  */
136
-function give_import_core_settings_merge_image_size( $json_to_array, $type ) {
137
-	if ( 'merge' === $type ) {
136
+function give_import_core_settings_merge_image_size($json_to_array, $type) {
137
+	if ('merge' === $type) {
138 138
 		// Featured image sizes import under Display Options > Post Types > Featured Image Size.
139 139
 		if (
140
-			! empty( $json_to_array['form_featured_img'] )
141
-			&& ! empty( $json_to_array['featured_image_size'] )
142
-			&& give_is_setting_enabled( $json_to_array['form_featured_img'] )
140
+			! empty($json_to_array['form_featured_img'])
141
+			&& ! empty($json_to_array['featured_image_size'])
142
+			&& give_is_setting_enabled($json_to_array['form_featured_img'])
143 143
 		) {
144 144
 			$images_sizes = get_intermediate_image_sizes();
145 145
 
146
-			if ( ! in_array( $json_to_array['featured_image_size'], $images_sizes, true ) ) {
147
-				unset( $json_to_array['featured_image_size'] );
146
+			if ( ! in_array($json_to_array['featured_image_size'], $images_sizes, true)) {
147
+				unset($json_to_array['featured_image_size']);
148 148
 			}
149 149
 		}
150 150
 	}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	return $json_to_array;
153 153
 }
154 154
 
155
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2 );
155
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2);
156 156
 
157 157
 /**
158 158
  * Give upload the image logo from the core setting data from the json files.
@@ -164,24 +164,24 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return array $json_to_array
166 166
  */
167
-function give_import_core_settings_merge_upload_image( $json_to_array, $type ) {
168
-	if ( 'merge' === $type ) {
167
+function give_import_core_settings_merge_upload_image($json_to_array, $type) {
168
+	if ('merge' === $type) {
169 169
 		// Emails > Email Settings > Logo.
170
-		if ( ! empty( $json_to_array['email_logo'] ) ) {
170
+		if ( ! empty($json_to_array['email_logo'])) {
171 171
 
172 172
 			// Need to require these files.
173
-			if ( ! function_exists( 'media_handle_upload' ) ) {
174
-				require_once( ABSPATH . 'wp-admin/includes/image.php' );
175
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
176
-				require_once( ABSPATH . 'wp-admin/includes/media.php' );
173
+			if ( ! function_exists('media_handle_upload')) {
174
+				require_once(ABSPATH.'wp-admin/includes/image.php');
175
+				require_once(ABSPATH.'wp-admin/includes/file.php');
176
+				require_once(ABSPATH.'wp-admin/includes/media.php');
177 177
 			}
178 178
 
179 179
 			$url     = $json_to_array['email_logo'];
180
-			$new_url = media_sideload_image( $url, 0, null, 'src' );
181
-			if ( ! is_wp_error( $new_url ) ) {
180
+			$new_url = media_sideload_image($url, 0, null, 'src');
181
+			if ( ! is_wp_error($new_url)) {
182 182
 				$json_to_array['email_logo'] = $new_url;
183 183
 			} else {
184
-				unset( $json_to_array['email_logo'] );
184
+				unset($json_to_array['email_logo']);
185 185
 			}
186 186
 		}
187 187
 	}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	return $json_to_array;
190 190
 }
191 191
 
192
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2 );
192
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2);
193 193
 
194 194
 /**
195 195
  * Give unset the license key from the core setting data from the json files.
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
  *
202 202
  * @return array $json_to_array
203 203
  */
204
-function give_import_core_settings_merge_license_key( $json_to_array, $type ) {
205
-	if ( 'merge' === $type ) {
206
-		foreach ( $json_to_array as $key => $value ) {
207
-			$is_license_key = strpos( '_license_key', $key );
208
-			if ( ! empty( $is_license_key ) ) {
209
-				unset( $json_to_array[ $key ] );
204
+function give_import_core_settings_merge_license_key($json_to_array, $type) {
205
+	if ('merge' === $type) {
206
+		foreach ($json_to_array as $key => $value) {
207
+			$is_license_key = strpos('_license_key', $key);
208
+			if ( ! empty($is_license_key)) {
209
+				unset($json_to_array[$key]);
210 210
 			}
211 211
 		}
212 212
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	return $json_to_array;
215 215
 }
216 216
 
217
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2 );
217
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2);
218 218
 
219 219
 /**
220 220
  * Give merge the json data and setting data.
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @return array $json_to_array
229 229
  */
230
-function give_import_core_settings_merge_data( $json_to_array, $type, $host_give_options ) {
231
-	if ( 'merge' === $type ) {
232
-		$json_to_array_merge = array_merge( $host_give_options, $json_to_array );
230
+function give_import_core_settings_merge_data($json_to_array, $type, $host_give_options) {
231
+	if ('merge' === $type) {
232
+		$json_to_array_merge = array_merge($host_give_options, $json_to_array);
233 233
 		$json_to_array       = $json_to_array_merge;
234 234
 	}
235 235
 
236 236
 	return $json_to_array;
237 237
 }
238 238
 
239
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3 );
239
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3);
240 240
 
241 241
 /**
242 242
  * Backward Compatibility - Cleanup User Roles.
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return mixed
249 249
  */
250
-function give_bc_1817_cleanup_user_roles( $caps ) {
250
+function give_bc_1817_cleanup_user_roles($caps) {
251 251
 
252 252
 	if (
253
-		! give_has_upgrade_completed( 'v1817_cleanup_user_roles' ) &&
254
-		! isset( $caps['view_give_payments'] )
253
+		! give_has_upgrade_completed('v1817_cleanup_user_roles') &&
254
+		! isset($caps['view_give_payments'])
255 255
 	) {
256 256
 		give_v1817_process_cleanup_user_roles();
257 257
 	}
@@ -259,4 +259,4 @@  discard block
 block discarded – undo
259 259
 	return $caps;
260 260
 }
261 261
 
262
-add_filter( 'user_has_cap', 'give_bc_1817_cleanup_user_roles' );
262
+add_filter('user_has_cap', 'give_bc_1817_cleanup_user_roles');
Please login to merge, or discard this patch.
includes/class-give-translation.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @return static
56 56
 	 */
57 57
 	public static function get_instance() {
58
-		if ( null === static::$instance ) {
58
+		if (null === static::$instance) {
59 59
 			self::$instance = new static();
60 60
 		}
61 61
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @access public
80 80
 	 */
81 81
 	public function setup_hooks() {
82
-		add_action( 'init', array( $this, 'load_translated_texts' ), 999 );
82
+		add_action('init', array($this, 'load_translated_texts'), 999);
83 83
 	}
84 84
 
85 85
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return bool|WP_Error false on success otherwise WP_Error object
112 112
 	 */
113
-	public static function add_text( $args = array() ) {
113
+	public static function add_text($args = array()) {
114 114
 		$error = false;
115 115
 
116 116
 		// Set text params.
@@ -126,43 +126,43 @@  discard block
 block discarded – undo
126 126
 
127 127
 		try {
128 128
 			// Check for errors.
129
-			if ( empty( $args['text'] ) ) {
129
+			if (empty($args['text'])) {
130 130
 				/* @var WP_Error $error */
131
-				$error = new WP_Error( 'EMPTY_TEXT', __( 'Empty string is not allowed.', 'give' ), $args );
132
-				throw new Exception( $error->get_error_message( 'EMPTY_TEXT' ) );
131
+				$error = new WP_Error('EMPTY_TEXT', __('Empty string is not allowed.', 'give'), $args);
132
+				throw new Exception($error->get_error_message('EMPTY_TEXT'));
133 133
 
134
-			} elseif ( empty( $args['id'] ) ) {
134
+			} elseif (empty($args['id'])) {
135 135
 				/* @var WP_Error $error */
136
-				$error = new WP_Error( 'EMPTY_ID', __( 'Empty ID is not allowed.', 'give' ), $args );
137
-				throw new Exception( $error->get_error_message( 'EMPTY_ID' ) );
136
+				$error = new WP_Error('EMPTY_ID', __('Empty ID is not allowed.', 'give'), $args);
137
+				throw new Exception($error->get_error_message('EMPTY_ID'));
138 138
 
139 139
 			} elseif (
140
-				empty( $args['group'] ) &&
141
-				array_key_exists( $args['id'], self::$text_configs )
140
+				empty($args['group']) &&
141
+				array_key_exists($args['id'], self::$text_configs)
142 142
 			) {
143 143
 				/* @var WP_Error $error */
144
-				$error = new WP_Error( 'TEXT_ID_ALREADY_EXIST', __( 'Text ID without a group already exists.', 'give' ), $args );
145
-				throw new Exception( $error->get_error_message( 'TEXT_ID_ALREADY_EXIST' ) );
144
+				$error = new WP_Error('TEXT_ID_ALREADY_EXIST', __('Text ID without a group already exists.', 'give'), $args);
145
+				throw new Exception($error->get_error_message('TEXT_ID_ALREADY_EXIST'));
146 146
 
147 147
 			} elseif (
148
-				! empty( $args['group'] ) &&
149
-				! empty( self::$text_configs[ $args['group'] ] ) &&
150
-				array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] )
148
+				! empty($args['group']) &&
149
+				! empty(self::$text_configs[$args['group']]) &&
150
+				array_key_exists($args['id'], self::$text_configs[$args['group']])
151 151
 			) {
152 152
 				/* @var WP_Error $error */
153
-				$error = new WP_Error( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __( 'Text ID within a group already exists.', 'give' ), $args );
154
-				throw new Exception( $error->get_error_message( 'TEXT_ID_WITHIN_GROUP_ALREADY_EXIST' ) );
153
+				$error = new WP_Error('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST', __('Text ID within a group already exists.', 'give'), $args);
154
+				throw new Exception($error->get_error_message('TEXT_ID_WITHIN_GROUP_ALREADY_EXIST'));
155 155
 
156 156
 			}
157 157
 
158 158
 			// Add text.
159
-			if ( ! empty( $args['group'] ) ) {
160
-				self::$text_configs[ $args['group'] ][ $args['id'] ] = $args;
159
+			if ( ! empty($args['group'])) {
160
+				self::$text_configs[$args['group']][$args['id']] = $args;
161 161
 			} else {
162
-				self::$text_configs[ $args['id'] ] = $args;
162
+				self::$text_configs[$args['id']] = $args;
163 163
 			}
164
-		} catch ( Exception $e ) {
165
-			error_log( $e->getMessage() );
164
+		} catch (Exception $e) {
165
+			error_log($e->getMessage());
166 166
 		}// End try().
167 167
 
168 168
 		/**
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 *
171 171
 		 * @since 2.0
172 172
 		 */
173
-		self::$text_configs = apply_filters( 'give_texts', self::$text_configs );
173
+		self::$text_configs = apply_filters('give_texts', self::$text_configs);
174 174
 
175 175
 		return $error;
176 176
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return string
187 187
 	 */
188
-	public static function add_label( $args = array() ) {
188
+	public static function add_label($args = array()) {
189 189
 		// Set text params.
190 190
 		$args = wp_parse_args(
191 191
 			$args,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		$args['type'] = 'label';
200 200
 		$args['id']   = "{$args['id']}_label";
201 201
 
202
-		return self::add_text( $args );
202
+		return self::add_text($args);
203 203
 	}
204 204
 
205 205
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return string
214 214
 	 */
215
-	public static function add_tooltip( $args = array() ) {
215
+	public static function add_tooltip($args = array()) {
216 216
 		// Set text params.
217 217
 		$args = wp_parse_args(
218 218
 			$args,
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		$args['type'] = 'tooltip';
227 227
 		$args['id']   = "{$args['id']}_tooltip";
228 228
 
229
-		return self::add_text( $args );
229
+		return self::add_text($args);
230 230
 	}
231 231
 
232 232
 	/**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @return string
241 241
 	 */
242
-	public static function add_translation( $args = array() ) {
242
+	public static function add_translation($args = array()) {
243 243
 		$args = wp_parse_args(
244 244
 			$args,
245 245
 			array(
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 		);
251 251
 
252 252
 		// Bailout.
253
-		if ( empty( $args['id'] ) ) {
253
+		if (empty($args['id'])) {
254 254
 			return;
255 255
 		}
256 256
 
257
-		if ( ! empty( $args['group'] ) ) {
258
-			self::$text_translations[ $args['group'] ][ $args['id'] ] = $args['text'];
257
+		if ( ! empty($args['group'])) {
258
+			self::$text_translations[$args['group']][$args['id']] = $args['text'];
259 259
 		} else {
260
-			self::$text_translations[ $args['id'] ] = $args['text'];
260
+			self::$text_translations[$args['id']] = $args['text'];
261 261
 		}
262 262
 	}
263 263
 
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return string
275 275
 	 */
276
-	public static function add_label_translation( $id, $group = '', $text = '' ) {
277
-		return self::get_text( array(
276
+	public static function add_label_translation($id, $group = '', $text = '') {
277
+		return self::get_text(array(
278 278
 			'id' => "{$id}_label",
279 279
 			'group' => $group,
280 280
 			'text' => $text,
281
-		) );
281
+		));
282 282
 	}
283 283
 
284 284
 	/**
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return string
295 295
 	 */
296
-	public static function add_tooltip_translation( $id, $group = '', $text = '' ) {
297
-		return self::get_text( array(
296
+	public static function add_tooltip_translation($id, $group = '', $text = '') {
297
+		return self::get_text(array(
298 298
 			'id' => "{$id}_label",
299 299
 			'group' => $group,
300 300
 			'text' => $text,
301
-		) );
301
+		));
302 302
 	}
303 303
 
304 304
 	/**
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return string
314 314
 	 */
315
-	public static function get_label( $id, $group = '' ) {
316
-		return self::get_text( array(
315
+	public static function get_label($id, $group = '') {
316
+		return self::get_text(array(
317 317
 			'id' => "{$id}_label",
318 318
 			'group' => $group,
319 319
 			'type' => 'label',
320
-		) );
320
+		));
321 321
 	}
322 322
 
323 323
 	/**
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return string
333 333
 	 */
334
-	public static function get_tooltip( $id, $group = '' ) {
335
-		return self::get_text( array(
334
+	public static function get_tooltip($id, $group = '') {
335
+		return self::get_text(array(
336 336
 			'id' => "{$id}_tooltip",
337 337
 			'group' => $group,
338 338
 			'type' => 'tooltip',
339
-		) );
339
+		));
340 340
 	}
341 341
 
342 342
 	/**
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 	 *
350 350
 	 * @return string
351 351
 	 */
352
-	public static function get_text( $args = array() ) {
352
+	public static function get_text($args = array()) {
353 353
 		$text = '';
354 354
 
355 355
 		// Bailout.
356
-		if ( empty( $args ) ) {
356
+		if (empty($args)) {
357 357
 			return $text;
358 358
 		}
359 359
 
@@ -369,40 +369,40 @@  discard block
 block discarded – undo
369 369
 
370 370
 		// Check if text exist.
371 371
 		if (
372
-			empty( $args['id'] ) ||
373
-			( empty( $args['group'] ) && ! array_key_exists( $args['id'], self::$text_configs ) ) ||
374
-			( ! empty( $args['group'] ) && ! empty( self::$text_configs[ $args['group'] ] ) && ! array_key_exists( $args['id'], self::$text_configs[ $args['group'] ] ) )
372
+			empty($args['id']) ||
373
+			(empty($args['group']) && ! array_key_exists($args['id'], self::$text_configs)) ||
374
+			( ! empty($args['group']) && ! empty(self::$text_configs[$args['group']]) && ! array_key_exists($args['id'], self::$text_configs[$args['group']]))
375 375
 		) {
376 376
 			return $text;
377 377
 		}
378 378
 
379 379
 		// Get text value.
380 380
 		if (
381
-			! empty( $args['group'] ) &&
382
-			array_key_exists( $args['group'], self::$text_configs )
381
+			! empty($args['group']) &&
382
+			array_key_exists($args['group'], self::$text_configs)
383 383
 		) {
384
-			$text = self::$text_configs[ $args['group'] ][ $args['id'] ]['text'];
384
+			$text = self::$text_configs[$args['group']][$args['id']]['text'];
385 385
 
386 386
 			// Get translated text if exist.
387 387
 			if (
388
-				! empty( self::$text_translations ) &&
389
-				! empty( self::$text_translations[ $args['group'] ] ) &&
390
-				array_key_exists( $args['id'], self::$text_translations[ $args['group'] ] )
388
+				! empty(self::$text_translations) &&
389
+				! empty(self::$text_translations[$args['group']]) &&
390
+				array_key_exists($args['id'], self::$text_translations[$args['group']])
391 391
 			) {
392
-				$text = self::$text_translations[ $args['group'] ][ $args['id'] ];
392
+				$text = self::$text_translations[$args['group']][$args['id']];
393 393
 			}
394 394
 		} elseif (
395
-			empty( $args['group'] ) &&
396
-			array_key_exists( $args['id'], self::$text_configs )
395
+			empty($args['group']) &&
396
+			array_key_exists($args['id'], self::$text_configs)
397 397
 		) {
398
-			$text = self::$text_configs[ $args['id'] ]['text'];
398
+			$text = self::$text_configs[$args['id']]['text'];
399 399
 
400 400
 			// Get translated text if exist.
401 401
 			if (
402
-				! empty( self::$text_translations ) &&
403
-				array_key_exists( $args['id'], self::$text_translations )
402
+				! empty(self::$text_translations) &&
403
+				array_key_exists($args['id'], self::$text_translations)
404 404
 			) {
405
-				$text = self::$text_translations[ $args['id'] ];
405
+				$text = self::$text_translations[$args['id']];
406 406
 			}
407 407
 		}
408 408
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 		 *
412 412
 		 * @since 2.0
413 413
 		 */
414
-		$text = apply_filters( 'give_text', $text, $args, self::$text_configs, self::$text_translations );
414
+		$text = apply_filters('give_text', $text, $args, self::$text_configs, self::$text_translations);
415 415
 
416 416
 		return $text;
417 417
 	}
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +106 added lines, -110 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount, $payment_id );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount, $payment_id);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221 221
 		/* @var Give_Payment $payment */
222
-		foreach ( $payments as $payment ) {
223
-			$gateway = give_get_payment_gateway( $payment->ID );
222
+		foreach ($payments as $payment) {
223
+			$gateway = give_get_payment_gateway($payment->ID);
224 224
 
225 225
 			// Skip payment gateways.
226
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
226
+			if (in_array($gateway, $skip_payment_gateways)) {
227 227
 				continue;
228 228
 			}
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 }
235 235
 
236
-Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' );
236
+Give_Cron::add_weekly_event('give_mark_abandoned_donations');
237 237
 
238 238
 
239 239
 /**
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
  *
246 246
  * @return void
247 247
  */
248
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
248
+function give_refresh_thismonth_stat_transients($payment_ID) {
249 249
 	// Monthly stats.
250
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
250
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
251 251
 
252 252
 	// @todo: Refresh only range related stat cache
253 253
 	give_delete_donation_stats();
254 254
 }
255 255
 
256
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
256
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
257 257
 
258 258
 
259 259
 /**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return array
271 271
  */
272
-function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) {
272
+function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) {
273 273
 	// Bailout.
274 274
 	if (
275
-		'give_payment' !== get_post_type( $object_id ) ||
275
+		'give_payment' !== get_post_type($object_id) ||
276 276
 		'_give_payment_meta' !== $meta_key ||
277
-		! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' )
277
+		! give_has_upgrade_completed('v20_upgrades_payment_metadata')
278 278
 	) {
279 279
 		return $check;
280 280
 	}
@@ -282,73 +282,69 @@  discard block
 block discarded – undo
282 282
 	$cache_key = "_give_payment_meta_{$object_id}";
283 283
 
284 284
 	// Get already calculate payment meta from cache.
285
-	$payment_meta = Give_Cache::get_db_query( $cache_key );
285
+	$payment_meta = Give_Cache::get_db_query($cache_key);
286 286
 
287
-	if ( is_null( $payment_meta ) ) {
287
+	if (is_null($payment_meta)) {
288 288
 		// Remove filter.
289
-		remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 );
289
+		remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999);
290 290
 
291
-		$donation = new Give_Payment( $object_id );
291
+		$donation = new Give_Payment($object_id);
292 292
 
293 293
 		// Get all payment meta.
294
-		$payment_meta = give_get_meta( $object_id );
294
+		$payment_meta = give_get_meta($object_id);
295 295
 
296 296
 		// Set default value to array.
297
-		if ( empty( $payment_meta ) ) {
297
+		if (empty($payment_meta)) {
298 298
 			return $check;
299 299
 		}
300 300
 
301 301
 		// Convert all meta key value to string instead of array
302
-		array_walk( $payment_meta, function ( &$meta, $key ) {
303
-			$meta = current( $meta );
302
+		array_walk($payment_meta, function(&$meta, $key) {
303
+			$meta = current($meta);
304 304
 		} );
305 305
 
306 306
 		/**
307 307
 		 * Add backward compatibility to old meta keys.
308 308
 		 */
309 309
 		// Donation key.
310
-		$payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : '';
310
+		$payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : '';
311 311
 
312 312
 		// Donation form.
313
-		$payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : '';
313
+		$payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : '';
314 314
 
315 315
 		// Donor email.
316
-		$payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : '';
317
-		$payment_meta['email'] = ! empty( $payment_meta['email'] ) ?
318
-			$payment_meta['email'] :
319
-			Give()->donors->get_column( 'email', $donation->donor_id );
316
+		$payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : '';
317
+		$payment_meta['email'] = ! empty($payment_meta['email']) ?
318
+			$payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id);
320 319
 
321 320
 		// Form id.
322
-		$payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : '';
321
+		$payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : '';
323 322
 
324 323
 		// Price id.
325
-		$payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : '';
324
+		$payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : '';
326 325
 
327 326
 		// Date.
328
-		$payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : '';
329
-		$payment_meta['date'] = ! empty( $payment_meta['date'] ) ?
330
-			$payment_meta['date'] :
331
-			get_post_field( 'post_date', $object_id );
327
+		$payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : '';
328
+		$payment_meta['date'] = ! empty($payment_meta['date']) ?
329
+			$payment_meta['date'] : get_post_field('post_date', $object_id);
332 330
 
333 331
 
334 332
 		// Currency.
335
-		$payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : '';
333
+		$payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : '';
336 334
 
337 335
 		// Decode donor data.
338
-		$donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0;
339
-		$donor    = new Give_Donor( $donor_id );
336
+		$donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0;
337
+		$donor    = new Give_Donor($donor_id);
340 338
 
341 339
 		// Donor first name.
342
-		$donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : '';
343
-		$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
344
-			$donor_data['first_name'] :
345
-			$donor->get_first_name();
340
+		$donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : '';
341
+		$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
342
+			$donor_data['first_name'] : $donor->get_first_name();
346 343
 
347 344
 		// Donor last name.
348
-		$donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : '';
349
-		$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
350
-			$donor_data['last_name'] :
351
-			$donor->get_last_name();
345
+		$donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : '';
346
+		$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
347
+			$donor_data['last_name'] : $donor->get_last_name();
352 348
 
353 349
 		// Donor email.
354 350
 		$donor_data['email'] = $payment_meta['email'];
@@ -359,63 +355,63 @@  discard block
 block discarded – undo
359 355
 		$donor_data['address'] = false;
360 356
 
361 357
 		// Address1.
362
-		$address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : '';
363
-		if ( $address1 ) {
358
+		$address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : '';
359
+		if ($address1) {
364 360
 			$donor_data['address']['line1'] = $address1;
365 361
 		}
366 362
 
367 363
 		// Address2.
368
-		$address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : '';
369
-		if ( $address2 ) {
364
+		$address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : '';
365
+		if ($address2) {
370 366
 			$donor_data['address']['line2'] = $address2;
371 367
 		}
372 368
 
373 369
 		// City.
374
-		$city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : '';
375
-		if ( $city ) {
370
+		$city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : '';
371
+		if ($city) {
376 372
 			$donor_data['address']['city'] = $city;
377 373
 		}
378 374
 
379 375
 		// Zip.
380
-		$zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : '';
381
-		if ( $zip ) {
376
+		$zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : '';
377
+		if ($zip) {
382 378
 			$donor_data['address']['zip'] = $zip;
383 379
 		}
384 380
 
385 381
 		// State.
386
-		$state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : '';
387
-		if ( $state ) {
382
+		$state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : '';
383
+		if ($state) {
388 384
 			$donor_data['address']['state'] = $state;
389 385
 		}
390 386
 
391 387
 		// Country.
392
-		$country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : '';
393
-		if ( $country ) {
388
+		$country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : '';
389
+		if ($country) {
394 390
 			$donor_data['address']['country'] = $country;
395 391
 		}
396 392
 
397 393
 		$payment_meta['user_info'] = $donor_data;
398 394
 
399 395
 		// Add filter
400
-		add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
396
+		add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
401 397
 
402 398
 		// Set custom meta key into payment meta.
403
-		if ( ! empty( $payment_meta['_give_payment_meta'] ) ) {
404
-			$payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta );
399
+		if ( ! empty($payment_meta['_give_payment_meta'])) {
400
+			$payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta);
405 401
 		}
406 402
 
407 403
 		// Set cache.
408
-		Give_Cache::set_db_query( $cache_key, $payment_meta );
404
+		Give_Cache::set_db_query($cache_key, $payment_meta);
409 405
 	}
410 406
 
411
-	if ( $single ) {
407
+	if ($single) {
412 408
 		/**
413 409
 		 * Filter the payment meta
414 410
 		 * Add custom meta key to payment meta
415 411
 		 *
416 412
 		 * @since 2.0
417 413
 		 */
418
-		$new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key );
414
+		$new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key);
419 415
 
420 416
 		$payment_meta = $new_payment_meta;
421 417
 	}
@@ -423,7 +419,7 @@  discard block
 block discarded – undo
423 419
 	return $payment_meta;
424 420
 }
425 421
 
426
-add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
422
+add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
427 423
 
428 424
 /**
429 425
  * Add meta in payment that store page id and page url.
@@ -435,19 +431,19 @@  discard block
 block discarded – undo
435 431
  *
436 432
  * @param int $payment_id Payment id for which the meta value should be updated.
437 433
  */
438
-function give_payment_save_page_data( $payment_id ) {
439
-	$page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false );
434
+function give_payment_save_page_data($payment_id) {
435
+	$page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false);
440 436
 
441 437
 	// Check $page_url is not empty.
442
-	if ( $page_url ) {
443
-		update_post_meta( $payment_id, '_give_current_url', $page_url );
444
-		$page_id = url_to_postid( $page_url );
438
+	if ($page_url) {
439
+		update_post_meta($payment_id, '_give_current_url', $page_url);
440
+		$page_id = url_to_postid($page_url);
445 441
 		// Check $page_id is not empty.
446
-		if ( $page_id ) {
447
-			update_post_meta( $payment_id, '_give_current_page_id', $page_id );
442
+		if ($page_id) {
443
+			update_post_meta($payment_id, '_give_current_page_id', $page_id);
448 444
 		}
449 445
 	}
450 446
 }
451 447
 
452 448
 // Fire when payment is save.
453
-add_action( 'give_insert_payment', 'give_payment_save_page_data' );
454 449
\ No newline at end of file
450
+add_action('give_insert_payment', 'give_payment_save_page_data');
455 451
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => __( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => __( 'PayPal', 'give' ),
27
+			'admin_label'    => __('PayPal Standard', 'give'),
28
+			'checkout_label' => __('PayPal', 'give'),
29 29
 		),
30 30
 		'manual' => array(
31
-			'admin_label'    => __( 'Test Donation', 'give' ),
32
-			'checkout_label' => __( 'Test Donation', 'give' )
31
+			'admin_label'    => __('Test Donation', 'give'),
32
+			'checkout_label' => __('Test Donation', 'give')
33 33
 		),
34 34
 	);
35 35
 
36
-	return apply_filters( 'give_payment_gateways', $gateways );
36
+	return apply_filters('give_payment_gateways', $gateways);
37 37
 
38 38
 }
39 39
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array $gateway_list All the available gateways
48 48
  */
49
-function give_get_enabled_payment_gateways( $form_id = 0 ) {
49
+function give_get_enabled_payment_gateways($form_id = 0) {
50 50
 
51 51
 	$gateways = give_get_payment_gateways();
52 52
 
53
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
53
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
54 54
 
55 55
 	$gateway_list = array();
56 56
 
57
-	foreach ( $gateways as $key => $gateway ) {
58
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
59
-			$gateway_list[ $key ] = $gateway;
57
+	foreach ($gateways as $key => $gateway) {
58
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
59
+			$gateway_list[$key] = $gateway;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Set order of payment gateway in list.
64
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
64
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
65 65
 
66
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id );
66
+	return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id);
67 67
 }
68 68
 
69 69
 /**
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @return boolean true if enabled, false otherwise
77 77
  */
78
-function give_is_gateway_active( $gateway ) {
78
+function give_is_gateway_active($gateway) {
79 79
 	$gateways = give_get_enabled_payment_gateways();
80 80
 
81
-	$ret = array_key_exists( $gateway, $gateways );
81
+	$ret = array_key_exists($gateway, $gateways);
82 82
 
83
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
83
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
84 84
 }
85 85
 
86 86
 /**
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string Gateway ID
94 94
  */
95
-function give_get_default_gateway( $form_id ) {
95
+function give_get_default_gateway($form_id) {
96 96
 
97
-	$enabled_gateways = array_keys( give_get_enabled_payment_gateways() );
97
+	$enabled_gateways = array_keys(give_get_enabled_payment_gateways());
98 98
 	$default_gateway  = give_get_option('default_gateway');
99
-	$default          = ! empty( $default_gateway ) && give_is_gateway_active( $default_gateway ) ? $default_gateway : $enabled_gateways[0];
100
-	$form_default     = give_get_meta( $form_id, '_give_default_gateway', true );
99
+	$default          = ! empty($default_gateway) && give_is_gateway_active($default_gateway) ? $default_gateway : $enabled_gateways[0];
100
+	$form_default     = give_get_meta($form_id, '_give_default_gateway', true);
101 101
 
102 102
 	// Single Form settings varies compared to the Global default settings.
103 103
 	if (
104
-		! empty( $form_default ) &&
104
+		! empty($form_default) &&
105 105
 		$form_id !== null &&
106 106
 		$default !== $form_default &&
107 107
 		'global' !== $form_default &&
108
-		give_is_gateway_active( $form_default )
108
+		give_is_gateway_active($form_default)
109 109
 	) {
110 110
 		$default = $form_default;
111 111
 	}
112 112
 
113
-	return apply_filters( 'give_default_gateway', $default );
113
+	return apply_filters('give_default_gateway', $default);
114 114
 }
115 115
 
116 116
 /**
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
  *
123 123
  * @return string Gateway admin label
124 124
  */
125
-function give_get_gateway_admin_label( $gateway ) {
125
+function give_get_gateway_admin_label($gateway) {
126 126
 	$gateways = give_get_payment_gateways();
127
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
127
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
128 128
 
129
-	if ( $gateway == 'manual' ) {
130
-		$label = __( 'Test Donation', 'give' );
129
+	if ($gateway == 'manual') {
130
+		$label = __('Test Donation', 'give');
131 131
 	}
132 132
 
133
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
133
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136 136
 /**
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
  *
143 143
  * @return string Checkout label for the gateway
144 144
  */
145
-function give_get_gateway_checkout_label( $gateway ) {
145
+function give_get_gateway_checkout_label($gateway) {
146 146
 	$gateways = give_get_payment_gateways();
147
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
147
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
148 148
 
149
-	if ( $gateway == 'manual' ) {
150
-		$label = __( 'Test Donation', 'give' );
149
+	if ($gateway == 'manual') {
150
+		$label = __('Test Donation', 'give');
151 151
 	}
152 152
 
153
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
153
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
154 154
 }
155 155
 
156 156
 /**
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
  *
163 163
  * @return array Options the gateway supports
164 164
  */
165
-function give_get_gateway_supports( $gateway ) {
165
+function give_get_gateway_supports($gateway) {
166 166
 	$gateways = give_get_enabled_payment_gateways();
167
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
167
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
168 168
 
169
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
169
+	return apply_filters('give_gateway_supports', $supports, $gateway);
170 170
 }
171 171
 
172 172
 /**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return void
181 181
  */
182
-function give_send_to_gateway( $gateway, $payment_data ) {
182
+function give_send_to_gateway($gateway, $payment_data) {
183 183
 
184
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
184
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
185 185
 
186 186
 	/**
187 187
 	 * Fires while loading payment gateway via AJAX.
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @param array $payment_data All the payment data to be sent to the gateway.
194 194
 	 */
195
-	do_action( "give_gateway_{$gateway}", $payment_data );
195
+	do_action("give_gateway_{$gateway}", $payment_data);
196 196
 }
197 197
 
198 198
 
@@ -206,34 +206,34 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return string $enabled_gateway The slug of the gateway
208 208
  */
209
-function give_get_chosen_gateway( $form_id ) {
209
+function give_get_chosen_gateway($form_id) {
210 210
 
211
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
211
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
212 212
 
213 213
 	// Back to check if 'form-id' is present.
214
-	if ( empty( $request_form_id ) ) {
215
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
214
+	if (empty($request_form_id)) {
215
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
216 216
 	}
217 217
 
218
-	$request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
218
+	$request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
219 219
 	$chosen               = false;
220 220
 
221 221
 	// If both 'payment-mode' and 'form-id' then set for only this form.
222
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
222
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
223 223
 		$chosen = $request_payment_mode;
224
-	} elseif ( empty( $request_form_id ) && $request_payment_mode ) {
224
+	} elseif (empty($request_form_id) && $request_payment_mode) {
225 225
 		// If no 'form-id' but there is 'payment-mode'.
226 226
 		$chosen = $request_payment_mode;
227 227
 	}
228 228
 
229 229
 	// Get the enable gateway based of chosen var.
230
-	if ( $chosen && give_is_gateway_active( $chosen ) ) {
231
-		$enabled_gateway = urldecode( $chosen );
230
+	if ($chosen && give_is_gateway_active($chosen)) {
231
+		$enabled_gateway = urldecode($chosen);
232 232
 	} else {
233
-		$enabled_gateway = give_get_default_gateway( $form_id );
233
+		$enabled_gateway = give_get_default_gateway($form_id);
234 234
 	}
235 235
 
236
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
236
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
237 237
 
238 238
 }
239 239
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return int             ID of the new log entry.
254 254
  */
255
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
256
-	return Give()->logs->add( $title, $message, $parent, $type );
255
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
256
+	return Give()->logs->add($title, $message, $parent, $type);
257 257
 }
258 258
 
259 259
 /**
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
  *
271 271
  * @return int ID of the new log entry
272 272
  */
273
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
274
-	$title = empty( $title ) ? esc_html__( 'Payment Error', 'give' ) : $title;
273
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
274
+	$title = empty($title) ? esc_html__('Payment Error', 'give') : $title;
275 275
 
276
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
276
+	return give_record_log($title, $message, $parent, 'gateway_error');
277 277
 }
278 278
 
279 279
 /**
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @return int
288 288
  */
289
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
289
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
290 290
 
291 291
 	$ret  = 0;
292 292
 	$args = array(
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 		'fields'      => 'ids',
299 299
 	);
300 300
 
301
-	$payments = new WP_Query( $args );
301
+	$payments = new WP_Query($args);
302 302
 
303
-	if ( $payments ) {
303
+	if ($payments) {
304 304
 		$ret = $payments->post_count;
305 305
 	}
306 306
 
@@ -317,27 +317,27 @@  discard block
 block discarded – undo
317 317
  *
318 318
  * @return array $gateways All the available gateways
319 319
  */
320
-function give_get_ordered_payment_gateways( $gateways ) {
320
+function give_get_ordered_payment_gateways($gateways) {
321 321
 
322 322
 	// Get gateways setting.
323
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
323
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
324 324
 
325 325
 	// Return from here if we do not have gateways setting.
326
-	if ( empty( $gateways_setting ) ) {
326
+	if (empty($gateways_setting)) {
327 327
 		return $gateways;
328 328
 	}
329 329
 
330 330
 	// Reverse array to order payment gateways.
331
-	$gateways_setting = array_reverse( $gateways_setting );
331
+	$gateways_setting = array_reverse($gateways_setting);
332 332
 
333 333
 	// Reorder gateways array
334
-	foreach ( $gateways_setting as $gateway_key => $value ) {
334
+	foreach ($gateways_setting as $gateway_key => $value) {
335 335
 
336
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
337
-		unset( $gateways[ $gateway_key ] );
336
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
337
+		unset($gateways[$gateway_key]);
338 338
 
339
-		if ( ! empty( $new_gateway_value ) ) {
340
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
339
+		if ( ! empty($new_gateway_value)) {
340
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
341 341
 		}
342 342
 	}
343 343
 
@@ -348,5 +348,5 @@  discard block
 block discarded – undo
348 348
 	 *
349 349
 	 * @param array $gateways All the available gateways
350 350
 	 */
351
-	return apply_filters( 'give_payment_gateways_order', $gateways );
351
+	return apply_filters('give_payment_gateways_order', $gateways);
352 352
 }
353 353
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/views/db-upgrades-complete-metabox.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <div id="give-db-updates" data-resume-update="0">
2 2
 	<div class="postbox-container">
3 3
 		<div class="postbox">
4
-			<h2 class="hndle"><?php esc_html_e( 'Database Updates', 'give' ); ?></h2>
4
+			<h2 class="hndle"><?php esc_html_e('Database Updates', 'give'); ?></h2>
5 5
 			<div class="inside">
6 6
 				<div class="progress-container">
7
-					<p class="update-message"><strong><?php esc_html_e( 'Updates Completed.', 'give' ) ?></strong></p>
7
+					<p class="update-message"><strong><?php esc_html_e('Updates Completed.', 'give') ?></strong></p>
8 8
 					<div class="progress-content">
9 9
 						<div class="notice-wrap give-clearfix">
10 10
 							<div class="notice notice-success is-dismissible inline">
11
-								<p><?php esc_html_e( 'Give database updates completed successfully. Thank you for updating to the latest version!', 'give' ) ?>
11
+								<p><?php esc_html_e('Give database updates completed successfully. Thank you for updating to the latest version!', 'give') ?>
12 12
 								</p>
13 13
 								<button type="button" class="notice-dismiss"></button>
14 14
 							</div>
@@ -20,4 +20,4 @@  discard block
 block discarded – undo
20 20
 		</div><!-- .postbox -->
21 21
 	</div>
22 22
 </div>
23
-<?php delete_option( 'give_show_db_upgrade_complete_notice' ); ?>
24 23
\ No newline at end of file
24
+<?php delete_option('give_show_db_upgrade_complete_notice'); ?>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function get_predefined_dates() {
95 95
 		$predefined = array(
96
-			'today'        => esc_html__( 'Today', 'give' ),
97
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
98
-			'this_week'    => esc_html__( 'This Week', 'give' ),
99
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
100
-			'this_month'   => esc_html__( 'This Month', 'give' ),
101
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
102
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
103
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
104
-			'this_year'    => esc_html__( 'This Year', 'give' ),
105
-			'last_year'    => esc_html__( 'Last Year', 'give' ),
96
+			'today'        => esc_html__('Today', 'give'),
97
+			'yesterday'    => esc_html__('Yesterday', 'give'),
98
+			'this_week'    => esc_html__('This Week', 'give'),
99
+			'last_week'    => esc_html__('Last Week', 'give'),
100
+			'this_month'   => esc_html__('This Month', 'give'),
101
+			'last_month'   => esc_html__('Last Month', 'give'),
102
+			'this_quarter' => esc_html__('This Quarter', 'give'),
103
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
104
+			'this_year'    => esc_html__('This Year', 'give'),
105
+			'last_year'    => esc_html__('Last Year', 'give'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
108
+		return apply_filters('give_stats_predefined_dates', $predefined);
109 109
 	}
110 110
 
111 111
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
124
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
125 125
 
126
-		if ( empty( $_start_date ) ) {
126
+		if (empty($_start_date)) {
127 127
 			$_start_date = 'this_month';
128 128
 		}
129 129
 
130
-		if ( empty( $_end_date ) ) {
130
+		if (empty($_end_date)) {
131 131
 			$_end_date = $_start_date;
132 132
 		}
133 133
 
134
-		$this->start_date = $this->convert_date( $_start_date );
135
-		$this->end_date   = $this->convert_date( $_end_date, true );
134
+		$this->start_date = $this->convert_date($_start_date);
135
+		$this->end_date   = $this->convert_date($_end_date, true);
136 136
 	}
137 137
 
138 138
 	/**
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
150 150
 	 */
151
-	public function convert_date( $date, $end_date = false ) {
151
+	public function convert_date($date, $end_date = false) {
152 152
 
153 153
 		$this->timestamp = false;
154 154
 		$second          = $end_date ? 59 : 0;
155 155
 		$minute          = $end_date ? 59 : 0;
156 156
 		$hour            = $end_date ? 23 : 0;
157 157
 		$day             = 1;
158
-		$month           = date( 'n', current_time( 'timestamp' ) );
159
-		$year            = date( 'Y', current_time( 'timestamp' ) );
158
+		$month           = date('n', current_time('timestamp'));
159
+		$year            = date('Y', current_time('timestamp'));
160 160
 
161
-		if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) {
161
+		if (array_key_exists((string) $date, $this->get_predefined_dates())) {
162 162
 
163 163
 			// This is a predefined date rate, such as last_week
164
-			switch ( $date ) {
164
+			switch ($date) {
165 165
 
166 166
 				case 'this_month' :
167 167
 
168
-					if ( $end_date ) {
168
+					if ($end_date) {
169 169
 
170
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
170
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
171 171
 						$hour   = 23;
172 172
 						$minute = 59;
173 173
 						$second = 59;
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 
178 178
 				case 'last_month' :
179 179
 
180
-					if ( $month == 1 ) {
180
+					if ($month == 1) {
181 181
 
182 182
 						$month = 12;
183
-						$year --;
183
+						$year--;
184 184
 
185 185
 					} else {
186 186
 
187
-						$month --;
187
+						$month--;
188 188
 
189 189
 					}
190 190
 
191
-					if ( $end_date ) {
192
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
191
+					if ($end_date) {
192
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
193 193
 					}
194 194
 
195 195
 					break;
196 196
 
197 197
 				case 'today' :
198 198
 
199
-					$day = date( 'd', current_time( 'timestamp' ) );
199
+					$day = date('d', current_time('timestamp'));
200 200
 
201
-					if ( $end_date ) {
201
+					if ($end_date) {
202 202
 						$hour   = 23;
203 203
 						$minute = 59;
204 204
 						$second = 59;
@@ -208,23 +208,23 @@  discard block
 block discarded – undo
208 208
 
209 209
 				case 'yesterday' :
210 210
 
211
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
211
+					$day = date('d', current_time('timestamp')) - 1;
212 212
 
213 213
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
214
-					if ( $day < 1 ) {
214
+					if ($day < 1) {
215 215
 
216 216
 						// If current month is 1
217
-						if ( 1 == $month ) {
217
+						if (1 == $month) {
218 218
 
219 219
 							$year -= 1; // Today is January 1, so skip back to last day of December
220 220
 							$month = 12;
221
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
221
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
222 222
 
223 223
 						} else {
224 224
 
225 225
 							// Go back one month and get the last day of the month
226 226
 							$month -= 1;
227
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
227
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
228 228
 
229 229
 						}
230 230
 					}
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
 				case 'this_week' :
235 235
 
236
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
-					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
236
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
237
+					$today              = date('j', current_time('timestamp')) * 60 * 60 * 24;
238 238
 
239
-					if ( $today <= $days_to_week_start ) {
239
+					if ($today <= $days_to_week_start) {
240 240
 
241
-						if ( $month > 1 ) {
241
+						if ($month > 1) {
242 242
 							$month -= 1;
243 243
 						} else {
244 244
 							$month = 12;
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 
247 247
 					}
248 248
 
249
-					if ( ! $end_date ) {
249
+					if ( ! $end_date) {
250 250
 
251 251
 						// Getting the start day
252 252
 
253
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
-						$day += get_option( 'start_of_week' );
253
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
254
+						$day += get_option('start_of_week');
255 255
 
256 256
 					} else {
257 257
 
258 258
 						// Getting the end day
259 259
 
260
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
-						$day += get_option( 'start_of_week' ) + 6;
260
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
261
+						$day += get_option('start_of_week') + 6;
262 262
 
263 263
 					}
264 264
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 
267 267
 				case 'last_week' :
268 268
 
269
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
-					$today              = date( 'j', current_time( 'timestamp' ) ) * 60 * 60 * 24;
269
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
270
+					$today              = date('j', current_time('timestamp')) * 60 * 60 * 24;
271 271
 
272
-					if ( $today <= $days_to_week_start ) {
272
+					if ($today <= $days_to_week_start) {
273 273
 
274
-						if ( $month > 1 ) {
274
+						if ($month > 1) {
275 275
 							$month -= 1;
276 276
 						} else {
277 277
 							$month = 12;
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 
280 280
 					}
281 281
 
282
-					if ( ! $end_date ) {
282
+					if ( ! $end_date) {
283 283
 
284 284
 						// Getting the start day
285 285
 
286
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
-						$day += get_option( 'start_of_week' );
286
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
287
+						$day += get_option('start_of_week');
288 288
 
289 289
 					} else {
290 290
 
291 291
 						// Getting the end day
292 292
 
293
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
-						$day += get_option( 'start_of_week' ) + 6;
293
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
294
+						$day += get_option('start_of_week') + 6;
295 295
 
296 296
 					}
297 297
 
@@ -299,39 +299,39 @@  discard block
 block discarded – undo
299 299
 
300 300
 				case 'this_quarter' :
301 301
 
302
-					$month_now = date( 'n', current_time( 'timestamp' ) );
302
+					$month_now = date('n', current_time('timestamp'));
303 303
 
304
-					if ( $month_now <= 3 ) {
304
+					if ($month_now <= 3) {
305 305
 
306
-						if ( ! $end_date ) {
306
+						if ( ! $end_date) {
307 307
 							$month = 1;
308 308
 						} else {
309 309
 							$month  = 3;
310
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
310
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
311 311
 							$hour   = 23;
312 312
 							$minute = 59;
313 313
 							$second = 59;
314 314
 						}
315 315
 
316
-					} else if ( $month_now <= 6 ) {
316
+					} else if ($month_now <= 6) {
317 317
 
318
-						if ( ! $end_date ) {
318
+						if ( ! $end_date) {
319 319
 							$month = 4;
320 320
 						} else {
321 321
 							$month  = 6;
322
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
322
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
323 323
 							$hour   = 23;
324 324
 							$minute = 59;
325 325
 							$second = 59;
326 326
 						}
327 327
 
328
-					} else if ( $month_now <= 9 ) {
328
+					} else if ($month_now <= 9) {
329 329
 
330
-						if ( ! $end_date ) {
330
+						if ( ! $end_date) {
331 331
 							$month = 7;
332 332
 						} else {
333 333
 							$month  = 9;
334
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
334
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
335 335
 							$hour   = 23;
336 336
 							$minute = 59;
337 337
 							$second = 59;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 
340 340
 					} else {
341 341
 
342
-						if ( ! $end_date ) {
342
+						if ( ! $end_date) {
343 343
 							$month = 10;
344 344
 						} else {
345 345
 							$month  = 12;
346
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
346
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
347 347
 							$hour   = 23;
348 348
 							$minute = 59;
349 349
 							$second = 59;
@@ -355,40 +355,40 @@  discard block
 block discarded – undo
355 355
 
356 356
 				case 'last_quarter' :
357 357
 
358
-					$month_now = date( 'n', current_time( 'timestamp' ) );
358
+					$month_now = date('n', current_time('timestamp'));
359 359
 
360
-					if ( $month_now <= 3 ) {
360
+					if ($month_now <= 3) {
361 361
 
362
-						if ( ! $end_date ) {
362
+						if ( ! $end_date) {
363 363
 							$month = 10;
364 364
 						} else {
365 365
 							$year -= 1;
366 366
 							$month  = 12;
367
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
367
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
368 368
 							$hour   = 23;
369 369
 							$minute = 59;
370 370
 							$second = 59;
371 371
 						}
372 372
 
373
-					} else if ( $month_now <= 6 ) {
373
+					} else if ($month_now <= 6) {
374 374
 
375
-						if ( ! $end_date ) {
375
+						if ( ! $end_date) {
376 376
 							$month = 1;
377 377
 						} else {
378 378
 							$month  = 3;
379
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
379
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
380 380
 							$hour   = 23;
381 381
 							$minute = 59;
382 382
 							$second = 59;
383 383
 						}
384 384
 
385
-					} else if ( $month_now <= 9 ) {
385
+					} else if ($month_now <= 9) {
386 386
 
387
-						if ( ! $end_date ) {
387
+						if ( ! $end_date) {
388 388
 							$month = 4;
389 389
 						} else {
390 390
 							$month  = 6;
391
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
391
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
392 392
 							$hour   = 23;
393 393
 							$minute = 59;
394 394
 							$second = 59;
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 
397 397
 					} else {
398 398
 
399
-						if ( ! $end_date ) {
399
+						if ( ! $end_date) {
400 400
 							$month = 7;
401 401
 						} else {
402 402
 							$month  = 9;
403
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
403
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
404 404
 							$hour   = 23;
405 405
 							$minute = 59;
406 406
 							$second = 59;
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 				case 'this_year' :
414 414
 
415
-					if ( ! $end_date ) {
415
+					if ( ! $end_date) {
416 416
 						$month = 1;
417 417
 					} else {
418 418
 						$month  = 12;
419
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
419
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
420 420
 						$hour   = 23;
421 421
 						$minute = 59;
422 422
 						$second = 59;
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				case 'last_year' :
428 428
 
429 429
 					$year -= 1;
430
-					if ( ! $end_date ) {
430
+					if ( ! $end_date) {
431 431
 						$month = 1;
432 432
 					} else {
433 433
 						$month  = 12;
434
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
434
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
435 435
 						$hour   = 23;
436 436
 						$minute = 59;
437 437
 						$second = 59;
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
 			}
443 443
 
444 444
 
445
-		} else if ( is_numeric( $date ) ) {
445
+		} else if (is_numeric($date)) {
446 446
 
447 447
 			// return $date unchanged since it is a timestamp
448 448
 			$this->timestamp = true;
449 449
 
450
-		} else if ( false !== strtotime( $date ) ) {
450
+		} else if (false !== strtotime($date)) {
451 451
 
452
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
453
-			$year  = date( 'Y', $date );
454
-			$month = date( 'm', $date );
455
-			$day   = date( 'd', $date );
452
+			$date  = strtotime($date, current_time('timestamp'));
453
+			$year  = date('Y', $date);
454
+			$month = date('m', $date);
455
+			$day   = date('d', $date);
456 456
 
457 457
 		} else {
458 458
 
459
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
459
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
460 460
 
461 461
 		}
462 462
 
463
-		if ( false === $this->timestamp ) {
463
+		if (false === $this->timestamp) {
464 464
 			// Create an exact timestamp
465
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
465
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
466 466
 		}
467 467
 
468
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
468
+		return apply_filters('give_stats_date', $date, $end_date, $this);
469 469
 
470 470
 	}
471 471
 
@@ -481,33 +481,33 @@  discard block
 block discarded – undo
481 481
 	 * 
482 482
 	 * @return string
483 483
 	 */
484
-	public function count_where( $where = '' ) {
484
+	public function count_where($where = '') {
485 485
 		// Only get payments in our date range
486 486
 
487 487
 		$start_where = '';
488 488
 		$end_where   = '';
489 489
 
490
-		if ( $this->start_date ) {
490
+		if ($this->start_date) {
491 491
 
492
-			if ( $this->timestamp ) {
492
+			if ($this->timestamp) {
493 493
 				$format = 'Y-m-d H:i:s';
494 494
 			} else {
495 495
 				$format = 'Y-m-d 00:00:00';
496 496
 			}
497 497
 
498
-			$start_date  = date( $format, $this->start_date );
498
+			$start_date  = date($format, $this->start_date);
499 499
 			$start_where = " AND p.post_date >= '{$start_date}'";
500 500
 		}
501 501
 
502
-		if ( $this->end_date ) {
502
+		if ($this->end_date) {
503 503
 
504
-			if ( $this->timestamp ) {
504
+			if ($this->timestamp) {
505 505
 				$format = 'Y-m-d H:i:s';
506 506
 			} else {
507 507
 				$format = 'Y-m-d 23:59:59';
508 508
 			}
509 509
 
510
-			$end_date = date( $format, $this->end_date );
510
+			$end_date = date($format, $this->end_date);
511 511
 
512 512
 			$end_where = " AND p.post_date <= '{$end_date}'";
513 513
 		}
@@ -529,34 +529,34 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return string
531 531
 	 */
532
-	public function payments_where( $where = '' ) {
532
+	public function payments_where($where = '') {
533 533
 
534 534
 		global $wpdb;
535 535
 
536 536
 		$start_where = '';
537 537
 		$end_where   = '';
538 538
 
539
-		if ( ! is_wp_error( $this->start_date ) ) {
539
+		if ( ! is_wp_error($this->start_date)) {
540 540
 
541
-			if ( $this->timestamp ) {
541
+			if ($this->timestamp) {
542 542
 				$format = 'Y-m-d H:i:s';
543 543
 			} else {
544 544
 				$format = 'Y-m-d 00:00:00';
545 545
 			}
546 546
 
547
-			$start_date  = date( $format, $this->start_date );
547
+			$start_date  = date($format, $this->start_date);
548 548
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
549 549
 		}
550 550
 
551
-		if ( ! is_wp_error( $this->end_date ) ) {
551
+		if ( ! is_wp_error($this->end_date)) {
552 552
 
553
-			if ( $this->timestamp ) {
553
+			if ($this->timestamp) {
554 554
 				$format = 'Y-m-d H:i:s';
555 555
 			} else {
556 556
 				$format = 'Y-m-d 23:59:59';
557 557
 			}
558 558
 
559
-			$end_date = date( $format, $this->end_date );
559
+			$end_date = date($format, $this->end_date);
560 560
 
561 561
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
562 562
 		}
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 1 patch
Spacing   +137 added lines, -137 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
 
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 	 * @param  int|bool $_id   Post id. Default is false.
349 349
 	 * @param  array    $_args Arguments passed.
350 350
 	 */
351
-	public function __construct( $_id = false, $_args = array() ) {
351
+	public function __construct($_id = false, $_args = array()) {
352 352
 
353
-		$donation_form = WP_Post::get_instance( $_id );
353
+		$donation_form = WP_Post::get_instance($_id);
354 354
 
355
-		return $this->setup_donation_form( $donation_form );
355
+		return $this->setup_donation_form($donation_form);
356 356
 	}
357 357
 
358 358
 	/**
@@ -365,23 +365,23 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @return bool                   If the setup was successful or not.
367 367
 	 */
368
-	private function setup_donation_form( $donation_form ) {
368
+	private function setup_donation_form($donation_form) {
369 369
 
370
-		if ( ! is_object( $donation_form ) ) {
370
+		if ( ! is_object($donation_form)) {
371 371
 			return false;
372 372
 		}
373 373
 
374
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
374
+		if ( ! is_a($donation_form, 'WP_Post')) {
375 375
 			return false;
376 376
 		}
377 377
 
378
-		if ( 'give_forms' !== $donation_form->post_type ) {
378
+		if ('give_forms' !== $donation_form->post_type) {
379 379
 			return false;
380 380
 		}
381 381
 
382
-		foreach ( $donation_form as $key => $value ) {
382
+		foreach ($donation_form as $key => $value) {
383 383
 
384
-			switch ( $key ) {
384
+			switch ($key) {
385 385
 
386 386
 				default:
387 387
 					$this->$key = $value;
@@ -405,16 +405,16 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @return mixed
407 407
 	 */
408
-	public function __get( $key ) {
408
+	public function __get($key) {
409 409
 
410
-		if ( method_exists( $this, 'get_' . $key ) ) {
410
+		if (method_exists($this, 'get_'.$key)) {
411 411
 
412
-			return call_user_func( array( $this, 'get_' . $key ) );
412
+			return call_user_func(array($this, 'get_'.$key));
413 413
 
414 414
 		} else {
415 415
 
416 416
 			/* translators: %s: property key */
417
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
417
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
418 418
 
419 419
 		}
420 420
 
@@ -430,30 +430,30 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @return bool|int    False if data isn't passed and class not instantiated for creation, or New Form ID.
432 432
 	 */
433
-	public function create( $data = array() ) {
433
+	public function create($data = array()) {
434 434
 
435
-		if ( $this->id != 0 ) {
435
+		if ($this->id != 0) {
436 436
 			return false;
437 437
 		}
438 438
 
439 439
 		$defaults = array(
440 440
 			'post_type'   => 'give_forms',
441 441
 			'post_status' => 'draft',
442
-			'post_title'  => __( 'New Donation Form', 'give' ),
442
+			'post_title'  => __('New Donation Form', 'give'),
443 443
 		);
444 444
 
445
-		$args = wp_parse_args( $data, $defaults );
445
+		$args = wp_parse_args($data, $defaults);
446 446
 
447 447
 		/**
448 448
 		 * Fired before a donation form is created
449 449
 		 *
450 450
 		 * @param array $args The post object arguments used for creation.
451 451
 		 */
452
-		do_action( 'give_form_pre_create', $args );
452
+		do_action('give_form_pre_create', $args);
453 453
 
454
-		$id = wp_insert_post( $args, true );
454
+		$id = wp_insert_post($args, true);
455 455
 
456
-		$donation_form = WP_Post::get_instance( $id );
456
+		$donation_form = WP_Post::get_instance($id);
457 457
 
458 458
 		/**
459 459
 		 * Fired after a donation form is created
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 		 * @param int   $id   The post ID of the created item.
462 462
 		 * @param array $args The post object arguments used for creation.
463 463
 		 */
464
-		do_action( 'give_form_post_create', $id, $args );
464
+		do_action('give_form_post_create', $id, $args);
465 465
 
466
-		return $this->setup_donation_form( $donation_form );
466
+		return $this->setup_donation_form($donation_form);
467 467
 
468 468
 	}
469 469
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 * @return string Donation form name.
489 489
 	 */
490 490
 	public function get_name() {
491
-		return get_the_title( $this->ID );
491
+		return get_the_title($this->ID);
492 492
 	}
493 493
 
494 494
 	/**
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	 */
502 502
 	public function get_price() {
503 503
 
504
-		if ( ! isset( $this->price ) ) {
504
+		if ( ! isset($this->price)) {
505 505
 
506 506
 			$this->price = give_maybe_sanitize_amount(
507 507
 				give_get_meta(
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 				)
512 512
 			);
513 513
 
514
-			if ( ! $this->price ) {
514
+			if ( ! $this->price) {
515 515
 				$this->price = 0;
516 516
 			}
517 517
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 		 * @param string     $price The donation form price.
526 526
 		 * @param string|int $id    The form ID.
527 527
 		 */
528
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
528
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
529 529
 	}
530 530
 
531 531
 	/**
@@ -538,22 +538,22 @@  discard block
 block discarded – undo
538 538
 	 */
539 539
 	public function get_minimum_price() {
540 540
 
541
-		if ( ! isset( $this->minimum_price ) ) {
541
+		if ( ! isset($this->minimum_price)) {
542 542
 
543
-			$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_range_minimum', true );
543
+			$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_range_minimum', true);
544 544
 
545 545
 			// Give backward < 2.1
546
-			if ( empty( $this->minimum_price ) ) {
547
-				$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true );
546
+			if (empty($this->minimum_price)) {
547
+				$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true);
548 548
 			}
549 549
 
550
-			if ( ! $this->is_custom_price_mode() ) {
551
-				$this->minimum_price = give_get_lowest_price_option( $this->ID );
550
+			if ( ! $this->is_custom_price_mode()) {
551
+				$this->minimum_price = give_get_lowest_price_option($this->ID);
552 552
 			}
553 553
 
554 554
 		}
555 555
 
556
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
556
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
557 557
 	}
558 558
 
559 559
 	/**
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	public function get_maximum_price() {
568 568
 
569
-		if ( ! isset( $this->maximum_price ) ) {
570
-			$this->maximum_price = give_get_meta( $this->ID, '_give_custom_amount_range_maximum', true, 999999.99 );
569
+		if ( ! isset($this->maximum_price)) {
570
+			$this->maximum_price = give_get_meta($this->ID, '_give_custom_amount_range_maximum', true, 999999.99);
571 571
 
572
-			if ( ! $this->is_custom_price_mode() ) {
573
-				$this->maximum_price = give_get_highest_price_option( $this->ID );
572
+			if ( ! $this->is_custom_price_mode()) {
573
+				$this->maximum_price = give_get_highest_price_option($this->ID);
574 574
 			}
575 575
 		}
576 576
 
577
-		return apply_filters( 'give_get_set_maximum_price', $this->maximum_price, $this->ID );
577
+		return apply_filters('give_get_set_maximum_price', $this->maximum_price, $this->ID);
578 578
 	}
579 579
 
580 580
 	/**
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 	 */
588 588
 	public function get_prices() {
589 589
 
590
-		if ( ! isset( $this->prices ) ) {
590
+		if ( ! isset($this->prices)) {
591 591
 
592
-			$this->prices = give_get_meta( $this->ID, '_give_donation_levels', true );
592
+			$this->prices = give_get_meta($this->ID, '_give_donation_levels', true);
593 593
 
594 594
 		}
595 595
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		 * @param array      $prices The array of mulit-level prices.
602 602
 		 * @param int|string $ID     The ID of the form.
603 603
 		 */
604
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
604
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
605 605
 
606 606
 	}
607 607
 
@@ -615,18 +615,18 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @return array|null
617 617
 	 */
618
-	public function get_level_info( $price_id ) {
618
+	public function get_level_info($price_id) {
619 619
 		$level_info = array();
620 620
 
621 621
 		// Bailout.
622
-		if ( 'multi' !== $this->get_type() ) {
622
+		if ('multi' !== $this->get_type()) {
623 623
 			return null;
624
-		} elseif ( ! ( $levels = $this->get_prices() ) ) {
624
+		} elseif ( ! ($levels = $this->get_prices())) {
625 625
 			return $level_info;
626 626
 		}
627 627
 
628
-		foreach ( $levels as $level ) {
629
-			if ( $price_id === $level['_give_id']['level_id'] ) {
628
+		foreach ($levels as $level) {
629
+			if ($price_id === $level['_give_id']['level_id']) {
630 630
 				$level_info = $level;
631 631
 				break;
632 632
 			}
@@ -646,25 +646,25 @@  discard block
 block discarded – undo
646 646
 	 */
647 647
 	public function get_goal() {
648 648
 
649
-		if ( ! isset( $this->goal ) ) {
649
+		if ( ! isset($this->goal)) {
650 650
 
651
-			$goal_format = give_get_form_goal_format( $this->ID );
651
+			$goal_format = give_get_form_goal_format($this->ID);
652 652
 
653
-			if ( 'donation' === $goal_format ) {
654
-				$this->goal = give_get_meta( $this->ID, '_give_number_of_donation_goal', true );
655
-			} elseif ( 'donors' === $goal_format ) {
656
-				$this->goal = give_get_meta( $this->ID, '_give_number_of_donor_goal', true );
653
+			if ('donation' === $goal_format) {
654
+				$this->goal = give_get_meta($this->ID, '_give_number_of_donation_goal', true);
655
+			} elseif ('donors' === $goal_format) {
656
+				$this->goal = give_get_meta($this->ID, '_give_number_of_donor_goal', true);
657 657
 			} else {
658
-				$this->goal = give_get_meta( $this->ID, '_give_set_goal', true );
658
+				$this->goal = give_get_meta($this->ID, '_give_set_goal', true);
659 659
 			}
660 660
 
661
-			if ( ! $this->goal ) {
661
+			if ( ! $this->goal) {
662 662
 				$this->goal = 0;
663 663
 			}
664 664
 
665 665
 		}
666 666
 
667
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
667
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
668 668
 
669 669
 	}
670 670
 
@@ -678,10 +678,10 @@  discard block
 block discarded – undo
678 678
 	 */
679 679
 	public function is_single_price_mode() {
680 680
 
681
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
681
+		$option = give_get_meta($this->ID, '_give_price_option', true);
682 682
 		$ret    = 0;
683 683
 
684
-		if ( empty( $option ) || $option === 'set' ) {
684
+		if (empty($option) || $option === 'set') {
685 685
 			$ret = 1;
686 686
 		}
687 687
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 		 * @param bool       $ret Is donation form in single price mode?
694 694
 		 * @param int|string $ID  The ID of the donation form.
695 695
 		 */
696
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
696
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
697 697
 
698 698
 	}
699 699
 
@@ -707,10 +707,10 @@  discard block
 block discarded – undo
707 707
 	 */
708 708
 	public function is_custom_price_mode() {
709 709
 
710
-		$option = give_get_meta( $this->ID, '_give_custom_amount', true );
710
+		$option = give_get_meta($this->ID, '_give_custom_amount', true);
711 711
 		$ret    = 0;
712 712
 
713
-		if ( give_is_setting_enabled( $option ) ) {
713
+		if (give_is_setting_enabled($option)) {
714 714
 			$ret = 1;
715 715
 		}
716 716
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		 * @param bool       $ret Is donation form in custom price mode?
723 723
 		 * @param int|string $ID  The ID of the donation form.
724 724
 		 */
725
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
725
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
726 726
 
727 727
 	}
728 728
 
@@ -736,20 +736,20 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @return bool
738 738
 	 */
739
-	public function is_custom_price( $amount ) {
739
+	public function is_custom_price($amount) {
740 740
 		$result = false;
741
-		$amount = give_maybe_sanitize_amount( $amount );
741
+		$amount = give_maybe_sanitize_amount($amount);
742 742
 
743
-		if ( $this->is_custom_price_mode() ) {
743
+		if ($this->is_custom_price_mode()) {
744 744
 
745
-			if ( 'set' === $this->get_type() ) {
746
-				if ( $amount !== $this->get_price() ) {
745
+			if ('set' === $this->get_type()) {
746
+				if ($amount !== $this->get_price()) {
747 747
 					$result = true;
748 748
 				}
749 749
 
750
-			} elseif ( 'multi' === $this->get_type() ) {
751
-				$level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) );
752
-				$result        = ! in_array( $amount, $level_amounts );
750
+			} elseif ('multi' === $this->get_type()) {
751
+				$level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount'));
752
+				$result        = ! in_array($amount, $level_amounts);
753 753
 			}
754 754
 		}
755 755
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 		 *
763 763
 		 * @since 1.8.18
764 764
 		 */
765
-		return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID );
765
+		return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID);
766 766
 	}
767 767
 
768 768
 	/**
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
 	 */
778 778
 	public function has_variable_prices() {
779 779
 
780
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
780
+		$option = give_get_meta($this->ID, '_give_price_option', true);
781 781
 		$ret    = 0;
782 782
 
783
-		if ( $option === 'multi' ) {
783
+		if ($option === 'multi') {
784 784
 			$ret = 1;
785 785
 		}
786 786
 
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		 * @param bool       $ret Does donation form have variable prices?
791 791
 		 * @param int|string $ID  The ID of the donation form.
792 792
 		 */
793
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
793
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
794 794
 
795 795
 	}
796 796
 
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
 	 */
805 805
 	public function get_type() {
806 806
 
807
-		if ( ! isset( $this->type ) ) {
807
+		if ( ! isset($this->type)) {
808 808
 
809
-			$this->type = give_get_meta( $this->ID, '_give_price_option', true );
809
+			$this->type = give_get_meta($this->ID, '_give_price_option', true);
810 810
 
811
-			if ( empty( $this->type ) ) {
811
+			if (empty($this->type)) {
812 812
 				$this->type = 'set';
813 813
 			}
814 814
 
815 815
 		}
816 816
 
817
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
817
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
818 818
 
819 819
 	}
820 820
 
@@ -830,23 +830,23 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @return string
832 832
 	 */
833
-	public function get_form_classes( $args ) {
833
+	public function get_form_classes($args) {
834 834
 
835
-		$float_labels_option = give_is_float_labels_enabled( $args )
835
+		$float_labels_option = give_is_float_labels_enabled($args)
836 836
 			? 'float-labels-enabled'
837 837
 			: '';
838 838
 
839
-		$form_classes_array = apply_filters( 'give_form_classes', array(
839
+		$form_classes_array = apply_filters('give_form_classes', array(
840 840
 			'give-form',
841
-			'give-form-' . $this->ID,
842
-			'give-form-type-' . $this->get_type(),
841
+			'give-form-'.$this->ID,
842
+			'give-form-type-'.$this->get_type(),
843 843
 			$float_labels_option,
844
-		), $this->ID, $args );
844
+		), $this->ID, $args);
845 845
 
846 846
 		// Remove empty class names.
847
-		$form_classes_array = array_filter( $form_classes_array );
847
+		$form_classes_array = array_filter($form_classes_array);
848 848
 
849
-		return implode( ' ', $form_classes_array );
849
+		return implode(' ', $form_classes_array);
850 850
 
851 851
 	}
852 852
 
@@ -861,22 +861,22 @@  discard block
 block discarded – undo
861 861
 	 *
862 862
 	 * @return string
863 863
 	 */
864
-	public function get_form_wrap_classes( $args ) {
864
+	public function get_form_wrap_classes($args) {
865 865
 		$custom_class = array(
866 866
 			'give-form-wrap',
867 867
 		);
868 868
 
869
-		if ( $this->is_close_donation_form() ) {
869
+		if ($this->is_close_donation_form()) {
870 870
 			$custom_class[] = 'give-form-closed';
871 871
 		} else {
872
-			$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
872
+			$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
873 873
 				? $args['display_style']
874
-				: give_get_meta( $this->ID, '_give_payment_display', true );
874
+				: give_get_meta($this->ID, '_give_payment_display', true);
875 875
 
876 876
 			$custom_class[] = "give-display-{$display_option}";
877 877
 
878 878
 			// If admin want to show only button for form then user inbuilt modal functionality.
879
-			if ( 'button' === $display_option ) {
879
+			if ('button' === $display_option) {
880 880
 				$custom_class[] = 'give-display-button-only';
881 881
 			}
882 882
 		}
@@ -887,10 +887,10 @@  discard block
 block discarded – undo
887 887
 		 *
888 888
 		 * @since 1.0
889 889
 		 */
890
-		$form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args );
890
+		$form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args);
891 891
 
892 892
 
893
-		return implode( ' ', $form_wrap_classes_array );
893
+		return implode(' ', $form_wrap_classes_array);
894 894
 
895 895
 	}
896 896
 
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 	public function is_set_type_donation_form() {
906 906
 		$form_type = $this->get_type();
907 907
 
908
-		return ( 'set' === $form_type ? true : false );
908
+		return ('set' === $form_type ? true : false);
909 909
 	}
910 910
 
911 911
 	/**
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 	public function is_multi_type_donation_form() {
920 920
 		$form_type = $this->get_type();
921 921
 
922
-		return ( 'multi' === $form_type ? true : false );
922
+		return ('multi' === $form_type ? true : false);
923 923
 
924 924
 	}
925 925
 
@@ -933,15 +933,15 @@  discard block
 block discarded – undo
933 933
 	 */
934 934
 	public function get_sales() {
935 935
 
936
-		if ( ! isset( $this->sales ) ) {
936
+		if ( ! isset($this->sales)) {
937 937
 
938
-			if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) {
939
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
938
+			if ('' == give_get_meta($this->ID, '_give_form_sales', true)) {
939
+				add_post_meta($this->ID, '_give_form_sales', 0);
940 940
 			} // End if
941 941
 
942
-			$this->sales = give_get_meta( $this->ID, '_give_form_sales', true );
942
+			$this->sales = give_get_meta($this->ID, '_give_form_sales', true);
943 943
 
944
-			if ( $this->sales < 0 ) {
944
+			if ($this->sales < 0) {
945 945
 				// Never let sales be less than zero.
946 946
 				$this->sales = 0;
947 947
 			}
@@ -962,13 +962,13 @@  discard block
 block discarded – undo
962 962
 	 *
963 963
 	 * @return int|false     New number of total sales.
964 964
 	 */
965
-	public function increase_sales( $quantity = 1 ) {
965
+	public function increase_sales($quantity = 1) {
966 966
 
967
-		$sales       = give_get_form_sales_stats( $this->ID );
968
-		$quantity    = absint( $quantity );
967
+		$sales       = give_get_form_sales_stats($this->ID);
968
+		$quantity    = absint($quantity);
969 969
 		$total_sales = $sales + $quantity;
970 970
 
971
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
971
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
972 972
 
973 973
 			$this->sales = $total_sales;
974 974
 
@@ -989,17 +989,17 @@  discard block
 block discarded – undo
989 989
 	 *
990 990
 	 * @return int|false     New number of total sales.
991 991
 	 */
992
-	public function decrease_sales( $quantity = 1 ) {
992
+	public function decrease_sales($quantity = 1) {
993 993
 
994
-		$sales = give_get_form_sales_stats( $this->ID );
994
+		$sales = give_get_form_sales_stats($this->ID);
995 995
 
996 996
 		// Only decrease if not already zero
997
-		if ( $sales > 0 ) {
997
+		if ($sales > 0) {
998 998
 
999
-			$quantity    = absint( $quantity );
999
+			$quantity    = absint($quantity);
1000 1000
 			$total_sales = $sales - $quantity;
1001 1001
 
1002
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
1002
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
1003 1003
 
1004 1004
 				$this->sales = $sales;
1005 1005
 
@@ -1023,15 +1023,15 @@  discard block
 block discarded – undo
1023 1023
 	 */
1024 1024
 	public function get_earnings() {
1025 1025
 
1026
-		if ( ! isset( $this->earnings ) ) {
1026
+		if ( ! isset($this->earnings)) {
1027 1027
 
1028
-			if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) {
1029
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
1028
+			if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) {
1029
+				add_post_meta($this->ID, '_give_form_earnings', 0);
1030 1030
 			}
1031 1031
 
1032
-			$this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true );
1032
+			$this->earnings = give_get_meta($this->ID, '_give_form_earnings', true);
1033 1033
 
1034
-			if ( $this->earnings < 0 ) {
1034
+			if ($this->earnings < 0) {
1035 1035
 				// Never let earnings be less than zero
1036 1036
 				$this->earnings = 0;
1037 1037
 			}
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
 	 *
1056 1056
 	 * @return float|false
1057 1057
 	 */
1058
-	public function increase_earnings( $amount = 0, $payment_id = 0 ) {
1058
+	public function increase_earnings($amount = 0, $payment_id = 0) {
1059 1059
 
1060
-		$earnings   = give_get_form_earnings_stats( $this->ID );
1060
+		$earnings = give_get_form_earnings_stats($this->ID);
1061 1061
 
1062 1062
 		/**
1063 1063
 		 * Modify the earning amount when increasing.
@@ -1068,11 +1068,11 @@  discard block
 block discarded – undo
1068 1068
 		 * @param int   $form_id    Donation form ID.
1069 1069
 		 * @param int   $payment_id Donation ID.
1070 1070
 		 */
1071
-		$amount = apply_filters( 'give_increase_form_earnings_amount', $amount, $this->ID, $payment_id );
1071
+		$amount = apply_filters('give_increase_form_earnings_amount', $amount, $this->ID, $payment_id);
1072 1072
 
1073 1073
 		$new_amount = $earnings + (float) $amount;
1074 1074
 
1075
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1075
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
1076 1076
 
1077 1077
 			$this->earnings = $new_amount;
1078 1078
 
@@ -1095,11 +1095,11 @@  discard block
 block discarded – undo
1095 1095
 	 *
1096 1096
 	 * @return float|false
1097 1097
 	 */
1098
-	public function decrease_earnings( $amount, $payment_id = 0 ) {
1098
+	public function decrease_earnings($amount, $payment_id = 0) {
1099 1099
 
1100
-		$earnings = give_get_form_earnings_stats( $this->ID );
1100
+		$earnings = give_get_form_earnings_stats($this->ID);
1101 1101
 
1102
-		if ( $earnings > 0 ) {
1102
+		if ($earnings > 0) {
1103 1103
 
1104 1104
 			/**
1105 1105
 			 * Modify the earning value when decreasing it.
@@ -1110,12 +1110,12 @@  discard block
 block discarded – undo
1110 1110
 			 * @param int   $form_id    Donation Form ID.
1111 1111
 			 * @param int   $payment_id Donation ID.
1112 1112
 			 */
1113
-			$amount = apply_filters( 'give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id );
1113
+			$amount = apply_filters('give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id);
1114 1114
 
1115 1115
 			// Only decrease if greater than zero
1116 1116
 			$new_amount = $earnings - (float) $amount;
1117 1117
 
1118
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1118
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
1119 1119
 				$this->earnings = $new_amount;
1120 1120
 
1121 1121
 				return $this->earnings;
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
 	 * @return bool
1142 1142
 	 */
1143 1143
 	public function is_close_donation_form() {
1144
-		$is_closed = ( 'closed' === give_get_meta( $this->ID, '_give_form_status', true, 'open' ) );
1144
+		$is_closed = ('closed' === give_get_meta($this->ID, '_give_form_status', true, 'open'));
1145 1145
 
1146 1146
 		// If manual upgrade not completed, proceed with backward compatible code.
1147
-		if ( ! give_has_upgrade_completed( 'v210_verify_form_status_upgrades' ) ) {
1147
+		if ( ! give_has_upgrade_completed('v210_verify_form_status_upgrades')) {
1148 1148
 
1149 1149
 			// Check for backward compatibility.
1150 1150
 			$is_closed = $this->bc_210_is_close_donation_form();
@@ -1174,17 +1174,17 @@  discard block
 block discarded – undo
1174 1174
 	 *
1175 1175
 	 * @return bool                            The result of the update query.
1176 1176
 	 */
1177
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
1177
+	private function update_meta($meta_key = '', $meta_value = '') {
1178 1178
 
1179 1179
 		/* @var WPDB $wpdb */
1180 1180
 		global $wpdb;
1181 1181
 
1182 1182
 		// Bailout.
1183
-		if ( empty( $meta_key ) ) {
1183
+		if (empty($meta_key)) {
1184 1184
 			return false;
1185 1185
 		}
1186 1186
 
1187
-		if ( give_update_meta( $this->ID, $meta_key, $meta_value ) ) {
1187
+		if (give_update_meta($this->ID, $meta_key, $meta_value)) {
1188 1188
 			return true;
1189 1189
 		}
1190 1190
 
@@ -1201,33 +1201,33 @@  discard block
 block discarded – undo
1201 1201
 	private function bc_210_is_close_donation_form() {
1202 1202
 
1203 1203
 		$close_form      = false;
1204
-		$is_goal_enabled = give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true, 'disabled' ) );
1204
+		$is_goal_enabled = give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true, 'disabled'));
1205 1205
 
1206 1206
 		// Proceed, if the form goal is enabled.
1207
-		if ( $is_goal_enabled ) {
1207
+		if ($is_goal_enabled) {
1208 1208
 
1209
-			$close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true, 'disabled' ) );
1209
+			$close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true, 'disabled'));
1210 1210
 
1211 1211
 			// Proceed, if close form when goal achieved option is enabled.
1212
-			if ( $close_form_when_goal_achieved ) {
1212
+			if ($close_form_when_goal_achieved) {
1213 1213
 
1214
-				$form        = new Give_Donate_Form( $this->ID );
1215
-				$goal_format = give_get_form_goal_format( $this->ID );
1214
+				$form        = new Give_Donate_Form($this->ID);
1215
+				$goal_format = give_get_form_goal_format($this->ID);
1216 1216
 
1217 1217
 				// Verify whether the form is closed or not after processing data based on goal format.
1218
-				switch ( $goal_format ) {
1218
+				switch ($goal_format) {
1219 1219
 					case 'donation':
1220 1220
 						$closed = $form->get_goal() <= $form->get_sales();
1221 1221
 						break;
1222 1222
 					case 'donors':
1223
-						$closed = $form->get_goal() <= give_get_form_donor_count( $this->ID );
1223
+						$closed = $form->get_goal() <= give_get_form_donor_count($this->ID);
1224 1224
 						break;
1225 1225
 					default :
1226 1226
 						$closed = $form->get_goal() <= $form->get_earnings();
1227 1227
 						break;
1228 1228
 				}
1229 1229
 
1230
-				if ( $closed ) {
1230
+				if ($closed) {
1231 1231
 					$close_form = true;
1232 1232
 				}
1233 1233
 
Please login to merge, or discard this patch.
includes/class-give-db-donor-meta.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		/* @var WPDB $wpdb */
54 54
 		global $wpdb;
55 55
 
56
-		$wpdb->donormeta   = $this->table_name = $wpdb->prefix . 'give_donormeta';
56
+		$wpdb->donormeta   = $this->table_name = $wpdb->prefix.'give_donormeta';
57 57
 		$this->primary_key = 'meta_id';
58 58
 		$this->version     = '1.0';
59 59
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 		global $wpdb;
93 93
 
94 94
 		if (
95
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
96
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s","{$wpdb->prefix}give_customermeta" ) )
95
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
96
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customermeta"))
97 97
 		) {
98 98
 			$wpdb->donormeta = $this->table_name = "{$wpdb->prefix}give_customermeta";
99 99
 			$this->meta_type = 'customer';
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return bool
114 114
 	 */
115
-	protected function is_valid_post_type( $ID ) {
115
+	protected function is_valid_post_type($ID) {
116 116
 		return $ID && true;
117 117
 	}
118 118
 
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @subcommand    logo
78 78
 	 */
79
-	public function ascii( $args, $assoc_args ) {
80
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/dist/images/give-ascii-logo.txt' ) );
79
+	public function ascii($args, $assoc_args) {
80
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/dist/images/give-ascii-logo.txt'));
81 81
 	}
82 82
 
83 83
 
@@ -102,54 +102,54 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @subcommand    details
104 104
 	 */
105
-	public function details( $args, $assoc_args ) {
105
+	public function details($args, $assoc_args) {
106 106
 
107 107
 		/**
108 108
 		 * Plugin Information
109 109
 		 */
110
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
110
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
111 111
 
112 112
 		/**
113 113
 		 * General Information.
114 114
 		 */
115
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
115
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
116 116
 
117
-		$success_page = give_get_option( 'success_page' );
118
-		$failure_page = give_get_option( 'failure_page' );
119
-		$history_page = give_get_option( 'history_page' );
117
+		$success_page = give_get_option('success_page');
118
+		$failure_page = give_get_option('failure_page');
119
+		$history_page = give_get_option('history_page');
120 120
 
121
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
122
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
123
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
124
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
121
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
122
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
123
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
124
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
125 125
 
126 126
 		/**
127 127
 		 * Currency Information.
128 128
 		 */
129
-		$default_gateway = give_get_option( 'default_gateway' );
129
+		$default_gateway = give_get_option('default_gateway');
130 130
 
131
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
131
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
132 132
 
133
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
134
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
135
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
136
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
137
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
138
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
139
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
133
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
134
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
135
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
136
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
137
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
138
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
139
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
140 140
 
141 141
 		// Payment gateways Information.
142
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
143
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
142
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
143
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
144 144
 
145
-		if ( ! empty( $gateways ) ) {
145
+		if ( ! empty($gateways)) {
146 146
 			self::$counter = 1;
147
-			foreach ( $gateways as $gateway ) {
148
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
149
-				self::$counter ++;
147
+			foreach ($gateways as $gateway) {
148
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
149
+				self::$counter++;
150 150
 			}
151 151
 		} else {
152
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
152
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
153 153
 		}
154 154
 	}
155 155
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @subcommand    forms
183 183
 	 */
184
-	public function forms( $args, $assoc_args ) {
184
+	public function forms($args, $assoc_args) {
185 185
 		global $wp_query;
186
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
187
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
186
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
187
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
188 188
 		$start   = time();
189 189
 
190 190
 		// Cache previous number query var.
191 191
 		$is_set_number = $cache_per_page = false;
192
-		if ( isset( $wp_query->query_vars['number'] ) ) {
192
+		if (isset($wp_query->query_vars['number'])) {
193 193
 			$cache_per_page = $wp_query->query_vars['number'];
194 194
 			$is_set_number  = true;
195 195
 		}
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
 		$wp_query->query_vars['number'] = $number;
199 199
 
200 200
 		// Get forms.
201
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
201
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
202 202
 
203 203
 		// Reset number query var.
204
-		if ( $is_set_number ) {
204
+		if ($is_set_number) {
205 205
 			$wp_query->query_vars['number'] = $cache_per_page;
206 206
 		}
207 207
 
208 208
 		// Bailout.
209
-		if ( array_key_exists( 'error', $forms ) ) {
209
+		if (array_key_exists('error', $forms)) {
210 210
 
211
-			WP_CLI::warning( $forms['error'] );
211
+			WP_CLI::warning($forms['error']);
212 212
 
213 213
 			return;
214
-		} elseif ( empty( $forms['forms'] ) ) {
214
+		} elseif (empty($forms['forms'])) {
215 215
 
216
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
216
+			WP_CLI::error(__('No forms found.', 'give'));
217 217
 
218 218
 			return;
219 219
 		}
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 		// Param to check if form typeis already showed or not.
222 222
 		$is_show_form_type = false;
223 223
 
224
-		if ( 1 === count( $forms ) && $form_id ) {
224
+		if (1 === count($forms) && $form_id) {
225 225
 			// Show single form.
226
-			foreach ( $forms['forms'][0] as $key => $info ) {
227
-				switch ( $key ) {
226
+			foreach ($forms['forms'][0] as $key => $info) {
227
+				switch ($key) {
228 228
 					case 'stats':
229
-						$this->color_main_heading( ucfirst( $key ) );
229
+						$this->color_main_heading(ucfirst($key));
230 230
 
231
-						foreach ( $info as $heading => $data ) {
232
-							$this->color_sub_heading( ucfirst( $heading ) );
233
-							switch ( $heading ) {
231
+						foreach ($info as $heading => $data) {
232
+							$this->color_sub_heading(ucfirst($heading));
233
+							switch ($heading) {
234 234
 								default:
235
-									foreach ( $data as $subheading => $subdata ) {
235
+									foreach ($data as $subheading => $subdata) {
236 236
 
237
-										switch ( $subheading ) {
237
+										switch ($subheading) {
238 238
 											case 'earnings':
239
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
239
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
240 240
 												break;
241 241
 											default:
242
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
242
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
243 243
 										}
244 244
 									}
245 245
 							}
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
 					case 'pricing':
250 250
 					case 'info':
251 251
 					default:
252
-						$this->color_main_heading( ucfirst( $key ) );
252
+						$this->color_main_heading(ucfirst($key));
253 253
 
254 254
 						// Show form type.
255
-						if ( ! $is_show_form_type ) {
256
-							$form              = new Give_Donate_Form( $form_id );
255
+						if ( ! $is_show_form_type) {
256
+							$form              = new Give_Donate_Form($form_id);
257 257
 							$is_show_form_type = true;
258 258
 
259
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
259
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
260 260
 						}
261 261
 
262
-						foreach ( $info as $heading => $data ) {
262
+						foreach ($info as $heading => $data) {
263 263
 
264
-							switch ( $heading ) {
264
+							switch ($heading) {
265 265
 								case 'id':
266
-									WP_CLI::log( $this->color_message( $heading, $data ) );
266
+									WP_CLI::log($this->color_message($heading, $data));
267 267
 									break;
268 268
 
269 269
 								default:
270
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
271
-									WP_CLI::log( $this->color_message( $heading, $data ) );
270
+									$data = empty($data) ? __('Not set', 'give') : $data;
271
+									WP_CLI::log($this->color_message($heading, $data));
272 272
 							}
273 273
 						}
274 274
 				}// End switch().
@@ -279,37 +279,37 @@  discard block
 block discarded – undo
279 279
 			$is_table_first_row_set = false;
280 280
 			$table_column_count     = 0;
281 281
 
282
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
282
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
283 283
 
284
-			foreach ( $forms['forms'] as $index => $form_data ) {
284
+			foreach ($forms['forms'] as $index => $form_data) {
285 285
 
286 286
 				// Default table data.
287 287
 				$table_first_row = array();
288 288
 				$table_row       = array();
289 289
 
290
-				foreach ( $form_data['info'] as $key => $form ) {
290
+				foreach ($form_data['info'] as $key => $form) {
291 291
 
292 292
 					// Do not show thumbnail, content and link in table.
293
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
293
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
294 294
 						continue;
295 295
 					}
296 296
 
297
-					if ( ! $is_table_first_row_set ) {
297
+					if ( ! $is_table_first_row_set) {
298 298
 						$table_first_row[] = $key;
299 299
 					}
300 300
 
301 301
 					$table_row[] = $form;
302 302
 
303
-					if ( 'status' === $key ) {
303
+					if ('status' === $key) {
304 304
 						// First array item will be an form id in our case.
305
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
305
+						$form = new Give_Donate_Form(absint($table_row[0]));
306 306
 
307 307
 						$table_row[] = $form->get_type();
308 308
 					}
309 309
 				}
310 310
 
311 311
 				// Set table first row.
312
-				if ( ! $is_table_first_row_set ) {
312
+				if ( ! $is_table_first_row_set) {
313 313
 
314 314
 					// Add extra column to table.
315 315
 					$table_first_row[] = 'type';
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 				$table_data[] = $table_row;
323 323
 			}// End foreach().
324 324
 
325
-			$this->display_table( $table_data );
325
+			$this->display_table($table_data);
326 326
 		}// End if().
327 327
 	}
328 328
 
@@ -375,59 +375,59 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @subcommand    donors
377 377
 	 */
378
-	public function donors( $args, $assoc_args ) {
378
+	public function donors($args, $assoc_args) {
379 379
 		global $wp_query;
380
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
381
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
382
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
383
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
384
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
385
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
386
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
380
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
381
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
382
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
383
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
384
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
385
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
386
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
387 387
 		$start    = time();
388 388
 
389
-		if ( $create ) {
390
-			if ( 80 < $create ) {
391
-				WP_CLI::warning( 'Currently we can only generate maximum 80 donors.', 'give' );
389
+		if ($create) {
390
+			if (80 < $create) {
391
+				WP_CLI::warning('Currently we can only generate maximum 80 donors.', 'give');
392 392
 				$create = 80;
393 393
 			}
394 394
 
395 395
 			$number = 1;
396 396
 
397
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
398
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
397
+			if (isset($assoc_args['email']) && ! is_email($email)) {
398
+				WP_CLI::warning('Wrong email address provided.', 'give');
399 399
 
400 400
 				return;
401 401
 			}
402 402
 
403 403
 			// Create one or more donors.
404
-			if ( ! $email ) {
404
+			if ( ! $email) {
405 405
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
406
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
406
+				$number = is_numeric($create) ? absint($create) : 1;
407 407
 			}
408 408
 
409
-			for ( $i = 0; $i < $number; $i ++ ) {
409
+			for ($i = 0; $i < $number; $i++) {
410 410
 				$name  = $name ? $name : $this->get_random_name();
411
-				$email = $email ? $email : $this->get_random_email( $name );
411
+				$email = $email ? $email : $this->get_random_email($name);
412 412
 
413 413
 				$args = array(
414 414
 					'email' => $email,
415 415
 					'name'  => $name,
416 416
 				);
417 417
 
418
-				$donor_id = Give()->donors->add( $args );
418
+				$donor_id = Give()->donors->add($args);
419 419
 
420
-				if ( $donor_id ) {
421
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $donor_id ) ) );
420
+				if ($donor_id) {
421
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $donor_id)));
422 422
 				} else {
423
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
423
+					WP_CLI::error(__('Failed to create donor', 'give'));
424 424
 				}
425 425
 
426 426
 				// Reset email and name to false so it is generated on the next loop (if creating donors).
427 427
 				$email = $name = false;
428 428
 			}
429 429
 
430
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
430
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
431 431
 
432 432
 		} else {
433 433
 			// Counter.
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 			 */
442 442
 			// Cache previous number query var.
443 443
 			$is_set_number = $cache_per_page = false;
444
-			if ( isset( $wp_query->query_vars['number'] ) ) {
444
+			if (isset($wp_query->query_vars['number'])) {
445 445
 				$cache_per_page = $wp_query->query_vars['number'];
446 446
 				$is_set_number  = true;
447 447
 			}
@@ -450,24 +450,24 @@  discard block
 block discarded – undo
450 450
 			$wp_query->query_vars['number'] = $number;
451 451
 
452 452
 			// Get donors.
453
-			if ( $form_id ) {
453
+			if ($form_id) {
454 454
 				// @TODO: Allow user to get a list of donors by donation status.
455
-				$donors = $this->get_donors_by_form_id( $form_id );
455
+				$donors = $this->get_donors_by_form_id($form_id);
456 456
 			} else {
457
-				$donors = $this->api->get_donors( $search );
457
+				$donors = $this->api->get_donors($search);
458 458
 			}
459 459
 
460 460
 			// Reset number query var.
461
-			if ( $is_set_number ) {
461
+			if ($is_set_number) {
462 462
 				$wp_query->query_vars['number'] = $cache_per_page;
463 463
 			}
464 464
 
465
-			if ( isset( $donors['error'] ) ) {
466
-				WP_CLI::error( $donors['error'] );
465
+			if (isset($donors['error'])) {
466
+				WP_CLI::error($donors['error']);
467 467
 			}
468 468
 
469
-			if ( empty( $donors ) ) {
470
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
469
+			if (empty($donors)) {
470
+				WP_CLI::error(__('No donors found.', 'give'));
471 471
 
472 472
 				return;
473 473
 			}
@@ -475,24 +475,24 @@  discard block
 block discarded – undo
475 475
 			$table_data             = array();
476 476
 			$is_table_first_row_set = false;
477 477
 
478
-			foreach ( $donors['donors'] as $donor_data ) {
478
+			foreach ($donors['donors'] as $donor_data) {
479 479
 				// Set default table row data.
480
-				$table_first_row = array( __( 's_no', 'give' ) );
481
-				$table_row       = array( self::$counter );
480
+				$table_first_row = array(__('s_no', 'give'));
481
+				$table_row       = array(self::$counter);
482 482
 
483
-				foreach ( $donor_data as $key => $donor ) {
484
-					switch ( $key ) {
483
+				foreach ($donor_data as $key => $donor) {
484
+					switch ($key) {
485 485
 						case 'stats':
486
-							foreach ( $donor as $heading => $data ) {
486
+							foreach ($donor as $heading => $data) {
487 487
 
488 488
 								// Get first row.
489
-								if ( ! $is_table_first_row_set ) {
489
+								if ( ! $is_table_first_row_set) {
490 490
 									$table_first_row[] = $heading;
491 491
 								}
492 492
 
493
-								switch ( $heading ) {
493
+								switch ($heading) {
494 494
 									case 'total_spent':
495
-										$table_row[] = give_currency_filter( $data );
495
+										$table_row[] = give_currency_filter($data);
496 496
 										break;
497 497
 
498 498
 									default:
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 
504 504
 						case 'info':
505 505
 						default:
506
-							foreach ( $donor as $heading => $data ) {
506
+							foreach ($donor as $heading => $data) {
507 507
 
508 508
 								// Get first row.
509
-								if ( ! $is_table_first_row_set ) {
509
+								if ( ! $is_table_first_row_set) {
510 510
 									$table_first_row[] = $heading;
511 511
 								}
512 512
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				}
517 517
 
518 518
 				// Add first row data to table data.
519
-				if ( ! $is_table_first_row_set ) {
519
+				if ( ! $is_table_first_row_set) {
520 520
 					$table_data[]           = $table_first_row;
521 521
 					$is_table_first_row_set = true;
522 522
 				}
@@ -525,44 +525,44 @@  discard block
 block discarded – undo
525 525
 				$table_data[] = $table_row;
526 526
 
527 527
 				// Increase counter.
528
-				self::$counter ++;
528
+				self::$counter++;
529 529
 			}// End foreach().
530 530
 
531
-			switch ( $format ) {
531
+			switch ($format) {
532 532
 				case 'json':
533 533
 					$table_column_name = $table_data[0];
534
-					unset( $table_data[0] );
534
+					unset($table_data[0]);
535 535
 
536 536
 					$new_table_data = array();
537
-					foreach ( $table_data as $index => $data ) {
538
-						foreach ( $data as $key => $value ) {
539
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
537
+					foreach ($table_data as $index => $data) {
538
+						foreach ($data as $key => $value) {
539
+							$new_table_data[$index][$table_column_name[$key]] = $value;
540 540
 						}
541 541
 					}
542 542
 
543
-					WP_CLI::log( json_encode( $new_table_data ) );
543
+					WP_CLI::log(json_encode($new_table_data));
544 544
 					break;
545 545
 
546 546
 				case 'csv':
547
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
548
-					$fp        = fopen( $file_path, 'w' );
547
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
548
+					$fp        = fopen($file_path, 'w');
549 549
 
550
-					if ( is_writable( $file_path ) ) {
551
-						foreach ( $table_data as $fields ) {
552
-							fputcsv( $fp, $fields );
550
+					if (is_writable($file_path)) {
551
+						foreach ($table_data as $fields) {
552
+							fputcsv($fp, $fields);
553 553
 						}
554 554
 
555
-						fclose( $fp );
555
+						fclose($fp);
556 556
 
557
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
557
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
558 558
 					} else {
559
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
559
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
560 560
 					}
561 561
 
562 562
 					break;
563 563
 
564 564
 				default:
565
-					$this->display_table( $table_data );
565
+					$this->display_table($table_data);
566 566
 			}// End switch().
567 567
 		}// End if().
568 568
 	}
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 	 *
593 593
 	 * @subcommand    donations
594 594
 	 */
595
-	public function donations( $args, $assoc_args ) {
595
+	public function donations($args, $assoc_args) {
596 596
 		global $wp_query;
597
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
597
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
598 598
 
599 599
 		// Cache previous number query var.
600 600
 		$is_set_number = $cache_per_page = false;
601
-		if ( isset( $wp_query->query_vars['number'] ) ) {
601
+		if (isset($wp_query->query_vars['number'])) {
602 602
 			$cache_per_page = $wp_query->query_vars['number'];
603 603
 			$is_set_number  = true;
604 604
 		}
@@ -610,46 +610,46 @@  discard block
 block discarded – undo
610 610
 		$donations = $this->api->get_recent_donations();
611 611
 
612 612
 		// Reset number query var.
613
-		if ( $is_set_number ) {
613
+		if ($is_set_number) {
614 614
 			$wp_query->query_vars['number'] = $cache_per_page;
615 615
 		}
616 616
 
617
-		if ( empty( $donations ) ) {
618
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
617
+		if (empty($donations)) {
618
+			WP_CLI::error(__('No donations found.', 'give'));
619 619
 
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		self::$counter = 1;
624 624
 
625
-		foreach ( $donations['donations'] as $key => $donation ) {
626
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
627
-			self::$counter ++;
625
+		foreach ($donations['donations'] as $key => $donation) {
626
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
627
+			self::$counter++;
628 628
 
629
-			foreach ( $donation as $column => $data ) {
629
+			foreach ($donation as $column => $data) {
630 630
 
631
-				if ( is_array( $data ) ) {
632
-					$this->color_sub_heading( $column );
633
-					foreach ( $data as $subcolumn => $subdata ) {
631
+				if (is_array($data)) {
632
+					$this->color_sub_heading($column);
633
+					foreach ($data as $subcolumn => $subdata) {
634 634
 
635 635
 						// Decode html codes.
636
-						switch ( $subcolumn ) {
636
+						switch ($subcolumn) {
637 637
 							case 'name':
638
-								$subdata = html_entity_decode( $subdata );
638
+								$subdata = html_entity_decode($subdata);
639 639
 								break;
640 640
 						}
641 641
 
642 642
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
643
-						if ( is_array( $subdata ) ) {
643
+						if (is_array($subdata)) {
644 644
 							continue;
645 645
 						}
646 646
 
647
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
647
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
648 648
 					}
649 649
 					continue;
650 650
 				}
651 651
 
652
-				WP_CLI::log( $this->color_message( $column, $data ) );
652
+				WP_CLI::log($this->color_message($column, $data));
653 653
 			}
654 654
 		}
655 655
 	}
@@ -689,27 +689,27 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return        void
691 691
 	 */
692
-	public function report( $args, $assoc_args ) {
692
+	public function report($args, $assoc_args) {
693 693
 		$stats      = new Give_Payment_Stats();
694
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
695
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
696
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
697
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
694
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
695
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
696
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
697
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
698 698
 
699
-		if ( ! empty( $date ) ) {
699
+		if ( ! empty($date)) {
700 700
 			$start_date = $date;
701 701
 			$end_date   = false;
702
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
702
+		} elseif (empty($date) && empty($start_date)) {
703 703
 			$start_date = 'this_month';
704 704
 			$end_date   = false;
705 705
 		}
706 706
 
707 707
 		// Get stats.
708
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
709
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
708
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
709
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
710 710
 
711
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings, array( 'decode_currency' => true ) ) ) );
712
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
711
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings, array('decode_currency' => true))));
712
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
713 713
 	}
714 714
 
715 715
 
@@ -736,27 +736,27 @@  discard block
 block discarded – undo
736 736
 	 *
737 737
 	 * @subcommand    cache
738 738
 	 */
739
-	public function cache( $args, $assoc_args ) {
740
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
739
+	public function cache($args, $assoc_args) {
740
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
741 741
 
742 742
 		// Bailout.
743
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
744
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
743
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
744
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
745 745
 
746 746
 			return;
747 747
 		}
748 748
 
749
-		switch ( $action ) {
749
+		switch ($action) {
750 750
 			case 'delete':
751 751
 				// Reset counter.
752 752
 				self::$counter = 1;
753 753
 
754
-				if ( $this->delete_stats_transients() ) {
754
+				if ($this->delete_stats_transients()) {
755 755
 					// Report .eading.
756
-					WP_CLI::success( 'Give cache deleted.' );
756
+					WP_CLI::success('Give cache deleted.');
757 757
 				} else {
758 758
 					// Report .eading.
759
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
759
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
760 760
 				}
761 761
 				break;
762 762
 		}
@@ -785,27 +785,27 @@  discard block
 block discarded – undo
785 785
 			ARRAY_A
786 786
 		);
787 787
 
788
-		if ( ! empty( $stat_option_names ) ) {
788
+		if ( ! empty($stat_option_names)) {
789 789
 
790
-			foreach ( $stat_option_names as $option_name ) {
790
+			foreach ($stat_option_names as $option_name) {
791 791
 				$error       = false;
792 792
 				$option_name = $option_name['option_name'];
793 793
 
794
-				switch ( true ) {
795
-					case ( false !== strpos( $option_name, 'transient' ) ):
796
-						$option_name = str_replace( '_transient_', '', $option_name );
797
-						$error       = delete_transient( $option_name );
794
+				switch (true) {
795
+					case (false !== strpos($option_name, 'transient')):
796
+						$option_name = str_replace('_transient_', '', $option_name);
797
+						$error       = delete_transient($option_name);
798 798
 						break;
799 799
 
800 800
 					default:
801
-						$error = delete_option( $option_name );
801
+						$error = delete_option($option_name);
802 802
 				}
803 803
 
804
-				if ( $error ) {
805
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
806
-					self::$counter ++;
804
+				if ($error) {
805
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
806
+					self::$counter++;
807 807
 				} else {
808
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
808
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
809 809
 				}
810 810
 			}
811 811
 
@@ -826,13 +826,13 @@  discard block
 block discarded – undo
826 826
 	 *
827 827
 	 * @return   string
828 828
 	 */
829
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
829
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
830 830
 		// Add colon.
831
-		if ( $colon ) {
832
-			$heading = $heading . ': ';
831
+		if ($colon) {
832
+			$heading = $heading.': ';
833 833
 		}
834 834
 
835
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
835
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
836 836
 	}
837 837
 
838 838
 
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @return    void
849 849
 	 */
850
-	private function color_main_heading( $heading, $color = 'g' ) {
851
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
850
+	private function color_main_heading($heading, $color = 'g') {
851
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
852 852
 	}
853 853
 
854 854
 	/**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	 *
862 862
 	 * @return    void
863 863
 	 */
864
-	private function color_sub_heading( $subheading ) {
865
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
864
+	private function color_sub_heading($subheading) {
865
+		WP_CLI::log("\n--->".$subheading.'', '', false);
866 866
 	}
867 867
 
868 868
 
@@ -876,17 +876,17 @@  discard block
 block discarded – undo
876 876
 	 *
877 877
 	 * @return    void
878 878
 	 */
879
-	private function display_table( $data ) {
879
+	private function display_table($data) {
880 880
 		$table = new \cli\Table();
881 881
 
882 882
 		// Set table header.
883
-		$table->setHeaders( $data[0] );
883
+		$table->setHeaders($data[0]);
884 884
 
885 885
 		// Remove table header.
886
-		unset( $data[0] );
886
+		unset($data[0]);
887 887
 
888 888
 		// Set table data.
889
-		$table->setRows( $data );
889
+		$table->setRows($data);
890 890
 
891 891
 		// Display table.
892 892
 		$table->display();
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 	 * @return array
904 904
 	 */
905 905
 
906
-	private function get_donors_by_form_id( $form_id ) {
906
+	private function get_donors_by_form_id($form_id) {
907 907
 		$donors = array();
908 908
 
909 909
 		$donations = new Give_Payments_Query(
910 910
 			array(
911
-				'give_forms' => array( $form_id ),
912
-				'number'     => - 1,
913
-				'status'     => array( 'publish' ),
911
+				'give_forms' => array($form_id),
912
+				'number'     => -1,
913
+				'status'     => array('publish'),
914 914
 			)
915 915
 		);
916 916
 
@@ -918,16 +918,16 @@  discard block
 block discarded – undo
918 918
 		$skip_donors = array();
919 919
 
920 920
 		/* @var Give_Payment|object $donation Payment object. */
921
-		foreach ( $donations as $donation ) {
921
+		foreach ($donations as $donation) {
922 922
 
923
-			if ( in_array( $donation->customer_id, $skip_donors, true ) ) {
923
+			if (in_array($donation->customer_id, $skip_donors, true)) {
924 924
 				continue;
925 925
 			}
926 926
 
927
-			if ( ! empty( $donors ) ) {
928
-				$donors['donors'][] = current( current( $this->api->get_donors( (int) $donation->customer_id ) ) );
927
+			if ( ! empty($donors)) {
928
+				$donors['donors'][] = current(current($this->api->get_donors((int) $donation->customer_id)));
929 929
 			} else {
930
-				$donors = array_merge( $donors, $this->api->get_donors( (int) $donation->customer_id ) );
930
+				$donors = array_merge($donors, $this->api->get_donors((int) $donation->customer_id));
931 931
 			}
932 932
 
933 933
 			$skip_donors[] = $donation->customer_id;
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 		);
973 973
 
974 974
 		// Generate a random forename.
975
-		$random_name = $names[ mt_rand( 0, sizeof( $names ) - 1 ) ];
975
+		$random_name = $names[mt_rand(0, sizeof($names) - 1)];
976 976
 
977 977
 		// Generate a random surname.
978
-		$random_surname = $surnames[ mt_rand( 0, sizeof( $surnames ) - 1 ) ];
978
+		$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)];
979 979
 
980 980
 		// Generate name.
981 981
 		$name = "{$random_name} {$random_surname}";
982 982
 
983
-		if ( in_array( $name, $this->new_donor_names ) ) {
983
+		if (in_array($name, $this->new_donor_names)) {
984 984
 			$name = $this->get_random_name();
985 985
 		}
986 986
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 	 *
1000 1000
 	 * @return string
1001 1001
 	 */
1002
-	private function get_random_email( $name ) {
1003
-		return implode( '.', explode( ' ', strtolower( $name ) ) ) . '@test.com';
1002
+	private function get_random_email($name) {
1003
+		return implode('.', explode(' ', strtolower($name))).'@test.com';
1004 1004
 	}
1005 1005
 
1006 1006
 	/**
@@ -1015,59 +1015,59 @@  discard block
 block discarded – undo
1015 1015
 	 * @when after_wp_load
1016 1016
 	 * @subcommand test-mode
1017 1017
 	 */
1018
-	public function test_mode( $args, $assoc ) {
1018
+	public function test_mode($args, $assoc) {
1019 1019
 
1020 1020
 		// Return if associative arguments are not specified.
1021
-		if ( empty( $assoc ) ) {
1022
-			WP_CLI::error( "--enable or --disable flag is missing." );
1021
+		if (empty($assoc)) {
1022
+			WP_CLI::error("--enable or --disable flag is missing.");
1023 1023
 			return;
1024 1024
 		}
1025 1025
 
1026
-		$enabled_gateways = give_get_option( 'gateways' );
1027
-		$default_gateway  = give_get_option( 'default_gateway' );
1026
+		$enabled_gateways = give_get_option('gateways');
1027
+		$default_gateway  = give_get_option('default_gateway');
1028 1028
 
1029 1029
 
1030 1030
 		// Enable Test Mode.
1031
-		if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'enable' ) ) {
1031
+		if (true === WP_CLI\Utils\get_flag_value($assoc, 'enable')) {
1032 1032
 
1033 1033
 			// Set `Test Mode` to `enabled`.
1034
-			give_update_option( 'test_mode', 'enabled' );
1034
+			give_update_option('test_mode', 'enabled');
1035 1035
 
1036 1036
 
1037 1037
 			// Enable `Test Donation` gateway.
1038 1038
 			$enabled_gateways['manual'] = "1";
1039
-			give_update_option( 'gateways', $enabled_gateways );
1039
+			give_update_option('gateways', $enabled_gateways);
1040 1040
 
1041 1041
 
1042 1042
 			// Set `Test Donation` as default gateway.
1043
-			add_option( 'give_test_mode_default_gateway', $default_gateway );
1044
-			give_update_option( 'default_gateway', 'manual' );
1043
+			add_option('give_test_mode_default_gateway', $default_gateway);
1044
+			give_update_option('default_gateway', 'manual');
1045 1045
 
1046 1046
 
1047 1047
 			// Show success message on completion.
1048
-			WP_CLI::success( 'Give Test mode enabled' );
1048
+			WP_CLI::success('Give Test mode enabled');
1049 1049
 		}
1050 1050
 
1051 1051
 		// Disable Test Mode.
1052
-		if ( true === WP_CLI\Utils\get_flag_value( $assoc, 'disable' ) ) {
1052
+		if (true === WP_CLI\Utils\get_flag_value($assoc, 'disable')) {
1053 1053
 
1054 1054
 			// Set `Test Mode` to `disabled`.
1055
-			give_update_option( 'test_mode', 'disabled' );
1055
+			give_update_option('test_mode', 'disabled');
1056 1056
 
1057 1057
 
1058 1058
 			// Disable `Test Donation` gateway.
1059
-			unset( $enabled_gateways['manual'] );
1060
-			give_update_option( 'gateways', $enabled_gateways );
1059
+			unset($enabled_gateways['manual']);
1060
+			give_update_option('gateways', $enabled_gateways);
1061 1061
 
1062 1062
 
1063 1063
 			// Backup `Default Gateway` setting for restore on test mode disable.
1064
-			$default_gateway_backup = get_option( 'give_test_mode_default_gateway' );
1065
-			give_update_option( 'default_gateway', $default_gateway_backup );
1066
-			delete_option( 'give_test_mode_default_gateway' );
1064
+			$default_gateway_backup = get_option('give_test_mode_default_gateway');
1065
+			give_update_option('default_gateway', $default_gateway_backup);
1066
+			delete_option('give_test_mode_default_gateway');
1067 1067
 
1068 1068
 
1069 1069
 			// Show success message on completion.
1070
-			WP_CLI::success( 'Give Test mode disabled' );
1070
+			WP_CLI::success('Give Test mode disabled');
1071 1071
 		}
1072 1072
 	}
1073 1073
 
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 	 *
1083 1083
 	 * @return boolean
1084 1084
 	 */
1085
-	private function is_git_repo( $repo_path ) {
1086
-		if ( is_dir( "{$repo_path}.git" ) ) {
1085
+	private function is_git_repo($repo_path) {
1086
+		if (is_dir("{$repo_path}.git")) {
1087 1087
 			return true;
1088 1088
 		}
1089 1089
 
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
 	 *
1101 1101
 	 * @return string
1102 1102
 	 */
1103
-	private function get_git_current_branch( $repo_path ) {
1103
+	private function get_git_current_branch($repo_path) {
1104 1104
 
1105
-		exec( "cd $repo_path && git branch | grep '\*'", $branch_names );
1105
+		exec("cd $repo_path && git branch | grep '\*'", $branch_names);
1106 1106
 
1107
-		$branch_name = trim( strtolower( str_replace( '* ', '', $branch_names[0] ) ) );
1107
+		$branch_name = trim(strtolower(str_replace('* ', '', $branch_names[0])));
1108 1108
 
1109 1109
 		return $branch_name;
1110 1110
 	}
@@ -1134,59 +1134,59 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @subcommand addon-update
1136 1136
 	 */
1137
-	public function addon_update( $pos, $assoc ) {
1137
+	public function addon_update($pos, $assoc) {
1138 1138
 
1139 1139
 		/**
1140 1140
 		 * Only 1 associative argument should be passed.
1141 1141
 		 * It can be either `--name` or `--exclude`
1142 1142
 		 */
1143
-		if ( count( $assoc ) > 1 ) {
1144
-			WP_CLI::error( __( 'Too many associative arguments.', 'give' ) );
1143
+		if (count($assoc) > 1) {
1144
+			WP_CLI::error(__('Too many associative arguments.', 'give'));
1145 1145
 		}
1146 1146
 
1147 1147
 		/**
1148 1148
 		 * Update a single Give addon.
1149 1149
 		 */
1150
-		if ( false !== ( $addon_name = WP_CLI\Utils\get_flag_value( $assoc, 'name', false ) ) ) {
1151
-			$give_addon_path = glob( WP_CONTENT_DIR . "/plugins/$addon_name/" , GLOB_ONLYDIR );
1150
+		if (false !== ($addon_name = WP_CLI\Utils\get_flag_value($assoc, 'name', false))) {
1151
+			$give_addon_path = glob(WP_CONTENT_DIR."/plugins/$addon_name/", GLOB_ONLYDIR);
1152 1152
 
1153 1153
 			/**
1154 1154
 			 * Display error if the plugin (addon) name entered does
1155 1155
 			 * not exist.
1156 1156
 			 */
1157
-			if ( empty( $give_addon_path ) ) {
1158
-				WP_CLI::error( sprintf( __( "The Give addon '%s' does not exist.", 'give' ), $addon_name ) );
1157
+			if (empty($give_addon_path)) {
1158
+				WP_CLI::error(sprintf(__("The Give addon '%s' does not exist.", 'give'), $addon_name));
1159 1159
 			}
1160 1160
 
1161 1161
 			/**
1162 1162
 			 * If the directory does not contain a Git
1163 1163
 			 * repository, then display error and halt.
1164 1164
 			 */
1165
-			if ( ! $this->is_git_repo( $give_addon_path[0] ) ) {
1166
-				WP_CLI::error( __( 'This is not a Git repo', 'give' ) );
1165
+			if ( ! $this->is_git_repo($give_addon_path[0])) {
1166
+				WP_CLI::error(__('This is not a Git repo', 'give'));
1167 1167
 			}
1168 1168
 
1169 1169
 			/**
1170 1170
 			 * Get the current branch name. This branch will be updated next.
1171 1171
 			 */
1172
-			$branch_name = $this->get_git_current_branch( $give_addon_path[0] );
1172
+			$branch_name = $this->get_git_current_branch($give_addon_path[0]);
1173 1173
 
1174 1174
 			/**
1175 1175
 			 * Take the latest pull of the current branch, i.e.;
1176 1176
 			 * sync it with origin.
1177 1177
 			 */
1178
-			passthru( "cd $give_addon_path[0] && git pull origin $branch_name", $return_var );
1178
+			passthru("cd $give_addon_path[0] && git pull origin $branch_name", $return_var);
1179 1179
 
1180 1180
 			/**
1181 1181
 			 * Show success/error messages depending on whether the
1182 1182
 			 * current branch of the addon was updated or not.
1183 1183
 			 */
1184
-			if ( 0 === $return_var ) {
1185
-				WP_CLI::success( sprintf( __( "The Give addon '%s' is up-to-date with origin." ), $addon_name ) );
1184
+			if (0 === $return_var) {
1185
+				WP_CLI::success(sprintf(__("The Give addon '%s' is up-to-date with origin."), $addon_name));
1186 1186
 
1187 1187
 				return;
1188
-			} elseif ( 1 === $return_var ) {
1189
-				WP_CLI::error( sprintf( __( "The Give addon '%s' was not updated." ), $addon_name ) );
1188
+			} elseif (1 === $return_var) {
1189
+				WP_CLI::error(sprintf(__("The Give addon '%s' was not updated."), $addon_name));
1190 1190
 			}
1191 1191
 		}
1192 1192
 
@@ -1194,34 +1194,34 @@  discard block
 block discarded – undo
1194 1194
 		 * Convert the comma-separated string of Give-addons in the
1195 1195
 		 * excluded list into array.
1196 1196
 		 */
1197
-		$addon_names = WP_CLI\Utils\get_flag_value( $assoc, 'exclude', array() );
1198
-		if ( ! empty( $addon_names ) ) {
1199
-			$addon_names = array_map( 'trim', explode( ',', $addon_names ) );
1197
+		$addon_names = WP_CLI\Utils\get_flag_value($assoc, 'exclude', array());
1198
+		if ( ! empty($addon_names)) {
1199
+			$addon_names = array_map('trim', explode(',', $addon_names));
1200 1200
 		}
1201 1201
 
1202 1202
 		/**
1203 1203
 		 * Get directory paths of all the addons including
1204 1204
 		 * Give Core.
1205 1205
 		 */
1206
-		$give_addon_directories = glob( WP_CONTENT_DIR . '/plugins/[gG]ive*/' , GLOB_ONLYDIR );
1206
+		$give_addon_directories = glob(WP_CONTENT_DIR.'/plugins/[gG]ive*/', GLOB_ONLYDIR);
1207 1207
 
1208
-		foreach ( $give_addon_directories as $repo ) {
1208
+		foreach ($give_addon_directories as $repo) {
1209 1209
 
1210 1210
 			/**
1211 1211
 			 * Extract the plugin/addon folder name
1212 1212
 			 * from the absolute path.
1213 1213
 			 */
1214
-			$plugin_name = basename( $repo );
1214
+			$plugin_name = basename($repo);
1215 1215
 
1216 1216
 			/**
1217 1217
 			 * If the Give addon directory does not contain
1218 1218
 			 * a Git repo, then continue.
1219 1219
 			 */
1220
-			if ( ! $this->is_git_repo( $repo ) ) {
1220
+			if ( ! $this->is_git_repo($repo)) {
1221 1221
 				WP_CLI::line(
1222 1222
 					sprintf(
1223
-						__( "%s: '%s' does not contain git repo.", 'give' ),
1224
-						WP_CLI::colorize( '%RError%n' ),
1223
+						__("%s: '%s' does not contain git repo.", 'give'),
1224
+						WP_CLI::colorize('%RError%n'),
1225 1225
 						$plugin_name
1226 1226
 					)
1227 1227
 				);
@@ -1232,34 +1232,34 @@  discard block
 block discarded – undo
1232 1232
 			/**
1233 1233
 			 * Continue if the Give addon name is in the exlusion list.
1234 1234
 			 */
1235
-			if ( in_array( $plugin_name, $addon_names, true ) ) {
1235
+			if (in_array($plugin_name, $addon_names, true)) {
1236 1236
 				continue;
1237 1237
 			}
1238 1238
 
1239 1239
 			/* Get the current branch name */
1240
-			$branch_name = $this->get_git_current_branch( $repo );
1240
+			$branch_name = $this->get_git_current_branch($repo);
1241 1241
 
1242 1242
 			/**
1243 1243
 			 * Show a colorized (CYAN) title for each addon/plugin
1244 1244
 			 * before a pull.
1245 1245
 			 */
1246
-			WP_CLI::line( WP_CLI::colorize( "> %CUpdating $plugin_name | $branch_name%n" ) );
1246
+			WP_CLI::line(WP_CLI::colorize("> %CUpdating $plugin_name | $branch_name%n"));
1247 1247
 
1248 1248
 			/**
1249 1249
 			 * Git pull from the current branch using
1250 1250
 			 * remote `origin`.
1251 1251
 			 */
1252
-			if ( ! empty( $branch_name ) ) {
1253
-				passthru( "cd $repo && git pull origin $branch_name", $return_var );
1252
+			if ( ! empty($branch_name)) {
1253
+				passthru("cd $repo && git pull origin $branch_name", $return_var);
1254 1254
 			}
1255 1255
 
1256 1256
 			$items[] = array(
1257 1257
 				'Give Addon' => $plugin_name,
1258 1258
 				'Branch'     => $branch_name,
1259 1259
 				'Remote'     => 'origin',
1260
-				'Status'     => ( 0 === $return_var )
1261
-					? __( 'Success', 'give' )
1262
-					: __( 'Failed', 'give' ),
1260
+				'Status'     => (0 === $return_var)
1261
+					? __('Success', 'give')
1262
+					: __('Failed', 'give'),
1263 1263
 			);
1264 1264
 
1265 1265
 			/**
Please login to merge, or discard this patch.