Completed
Pull Request — master (#1055)
by Rami
19:01
created
includes/scripts.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,106 +25,106 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	//Localize / PHP to AJAX vars
36
-	$localize_give_checkout = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_checkout = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
39
-		'currency_sign'       => give_currency_filter( '' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39
+		'currency_sign'       => give_currency_filter(''),
40 40
 		'currency_pos'        => give_get_currency_position(),
41 41
 		'thousands_separator' => give_get_price_thousand_separator(),
42 42
 		'decimal_separator'   => give_get_price_decimal_separator(),
43
-		'no_gateway'          => esc_html__( 'Please select a payment method.', 'give' ),
44
-		'bad_minimum'         => esc_html__( 'The minimum donation amount for this form is', 'give' ),
45
-		'general_loading'     => esc_html__( 'Loading...', 'give' ),
46
-		'purchase_loading'    => esc_html__( 'Please Wait...', 'give' ),
43
+		'no_gateway'          => esc_html__('Please select a payment method.', 'give'),
44
+		'bad_minimum'         => esc_html__('The minimum donation amount for this form is', 'give'),
45
+		'general_loading'     => esc_html__('Loading...', 'give'),
46
+		'purchase_loading'    => esc_html__('Please Wait...', 'give'),
47 47
 		'number_decimals'     => give_get_price_decimals(),
48 48
 		'give_version'        => GIVE_VERSION,
49 49
 		'form_translation'    => apply_filters(
50 50
 			'give_form_translation_js',
51 51
 			array(
52 52
 				// Field name               Validation message.
53
-				'payment-mode'           => esc_html__( 'Please select payment mode.', 'give' ),
54
-				'give_first'             => esc_html__( 'Please enter your first name.', 'give' ),
55
-				'give_email'             => esc_html__( 'Please enter a valid email address.', 'give' ),
56
-				'give_user_login'        => esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
57
-				'give_user_pass'         => esc_html__( 'Enter a password.', 'give' ),
58
-				'give_user_pass_confirm' => esc_html__( 'Enter a confirm password.', 'give' ),
53
+				'payment-mode'           => esc_html__('Please select payment mode.', 'give'),
54
+				'give_first'             => esc_html__('Please enter your first name.', 'give'),
55
+				'give_email'             => esc_html__('Please enter a valid email address.', 'give'),
56
+				'give_user_login'        => esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
57
+				'give_user_pass'         => esc_html__('Enter a password.', 'give'),
58
+				'give_user_pass_confirm' => esc_html__('Enter a confirm password.', 'give'),
59 59
 			)
60 60
 		)
61
-	) );
62
-	$localize_give_ajax     = apply_filters( 'give_global_ajax_vars', array(
61
+	));
62
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
63 63
 		'ajaxurl'         => give_get_ajax_url(),
64
-		'loading'         => esc_html__( 'Loading', 'give' ),
64
+		'loading'         => esc_html__('Loading', 'give'),
65 65
 		// General loading message
66
-		'select_option'   => esc_html__( 'Please select an option', 'give' ),
66
+		'select_option'   => esc_html__('Please select an option', 'give'),
67 67
 		// Variable pricing error with multi-donation option enabled
68
-		'default_gateway' => give_get_default_gateway( null ),
69
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
68
+		'default_gateway' => give_get_default_gateway(null),
69
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
70 70
 		'number_decimals' => give_get_price_decimals()
71
-	) );
71
+	));
72 72
 
73 73
 	//DEBUG is On
74
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
74
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
75 75
 
76
-		if ( give_is_cc_verify_enabled() ) {
77
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
78
-			wp_enqueue_script( 'give-cc-validator' );
76
+		if (give_is_cc_verify_enabled()) {
77
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
78
+			wp_enqueue_script('give-cc-validator');
79 79
 		}
80 80
 
81
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
82
-		wp_enqueue_script( 'give-float-labels' );
81
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
82
+		wp_enqueue_script('give-float-labels');
83 83
 
84
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
85
-		wp_enqueue_script( 'give-blockui' );
84
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
85
+		wp_enqueue_script('give-blockui');
86 86
 
87
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
88
-		wp_enqueue_script( 'give-qtip' );
87
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
88
+		wp_enqueue_script('give-qtip');
89 89
 
90
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
91
-		wp_enqueue_script( 'give-accounting' );
90
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
91
+		wp_enqueue_script('give-accounting');
92 92
 
93
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
94
-		wp_enqueue_script( 'give-magnific' );
93
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
94
+		wp_enqueue_script('give-magnific');
95 95
 
96
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
97
-		wp_enqueue_script( 'give-checkout-global' );
96
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
97
+		wp_enqueue_script('give-checkout-global');
98 98
 
99 99
 		//General scripts
100
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
101
-		wp_enqueue_script( 'give-scripts' );
100
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
101
+		wp_enqueue_script('give-scripts');
102 102
 
103 103
 		// Load AJAX scripts, if enabled
104
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
105
-		wp_enqueue_script( 'give-ajax' );
104
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
105
+		wp_enqueue_script('give-ajax');
106 106
 
107 107
 		//Localize / Pass AJAX vars from PHP
108
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
109
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
108
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
109
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
110 110
 
111 111
 
112 112
 	} else {
113 113
 
114 114
 		//DEBUG is OFF (one JS file to rule them all!)
115
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
116
-		wp_enqueue_script( 'give' );
115
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
116
+		wp_enqueue_script('give');
117 117
 
118 118
 		//Localize / Pass AJAX vars from PHP
119
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
120
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
119
+		wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
120
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
121 121
 
122 122
 	}
123 123
 
124 124
 
125 125
 }
126 126
 
127
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
127
+add_action('wp_enqueue_scripts', 'give_load_scripts');
128 128
 
129 129
 /**
130 130
  * Register styles.
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function give_register_styles() {
138 138
 
139
-	if ( give_get_option( 'disable_css', false ) ) {
139
+	if (give_get_option('disable_css', false)) {
140 140
 		return;
141 141
 	}
142 142
 
143
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
144
-	wp_enqueue_style( 'give-styles' );
143
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
144
+	wp_enqueue_style('give-styles');
145 145
 
146 146
 }
147 147
 
148
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
148
+add_action('wp_enqueue_scripts', 'give_register_styles');
149 149
 
150 150
 
151 151
 /**
@@ -157,42 +157,42 @@  discard block
 block discarded – undo
157 157
 function give_get_stylesheet_uri() {
158 158
 
159 159
 	// Use minified libraries if SCRIPT_DEBUG is turned off
160
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
160
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
161 161
 
162 162
 	// LTR or RTL files
163
-	$direction = ( is_rtl() ) ? '-rtl' : '';
163
+	$direction = (is_rtl()) ? '-rtl' : '';
164 164
 
165
-	$file          = 'give' . $direction . $suffix . '.css';
165
+	$file          = 'give'.$direction.$suffix.'.css';
166 166
 	$templates_dir = give_get_theme_template_dir_name();
167 167
 
168
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
169
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
170
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
171
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
172
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
168
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
169
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
170
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
171
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
172
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
173 173
 
174 174
 	$uri = false;
175 175
 
176 176
 	// Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory
177 177
 	// Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
178 178
 	// This allows users to copy just give.css to their theme
179
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
180
-		if ( ! empty( $nonmin ) ) {
181
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
179
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
180
+		if ( ! empty($nonmin)) {
181
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
182 182
 		} else {
183
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
183
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
184 184
 		}
185
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
186
-		if ( ! empty( $nonmin ) ) {
187
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
185
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
186
+		if ( ! empty($nonmin)) {
187
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
188 188
 		} else {
189
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
189
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
190 190
 		}
191
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
192
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
191
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
192
+		$uri = trailingslashit(give_get_templates_url()).$file;
193 193
 	}
194 194
 
195
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
195
+	return apply_filters('give_get_stylesheet_uri', $uri);
196 196
 
197 197
 }
198 198
 
@@ -209,70 +209,70 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @return void
211 211
  */
212
-function give_load_admin_scripts( $hook ) {
212
+function give_load_admin_scripts($hook) {
213 213
 
214 214
 	global $post, $post_type;
215 215
 
216 216
 	$give_options = give_get_settings();
217 217
 
218 218
 	//Directories of assets
219
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
220
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
221
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
219
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
220
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
221
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
222 222
 
223 223
 	// Use minified libraries if SCRIPT_DEBUG is turned off
224
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
224
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
225 225
 
226 226
 	// LTR or RTL files
227
-	$direction = ( is_rtl() ) ? '-rtl' : '';
227
+	$direction = (is_rtl()) ? '-rtl' : '';
228 228
 
229 229
 	//Global Admin:
230
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
231
-	wp_enqueue_style( 'give-admin-bar-notification' );
230
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
231
+	wp_enqueue_style('give-admin-bar-notification');
232 232
 
233 233
 	//Give Admin Only:
234
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
234
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
235 235
 		return;
236 236
 	}
237 237
 
238 238
 	//CSS
239
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
240
-	wp_enqueue_style( 'jquery-ui-css' );
241
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', GIVE_VERSION );
242
-	wp_enqueue_style( 'give-admin' );
243
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
244
-	wp_enqueue_style( 'jquery-chosen' );
245
-	wp_enqueue_style( 'thickbox' );
239
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
240
+	wp_enqueue_style('jquery-ui-css');
241
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', GIVE_VERSION);
242
+	wp_enqueue_style('give-admin');
243
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
244
+	wp_enqueue_style('jquery-chosen');
245
+	wp_enqueue_style('thickbox');
246 246
 
247 247
 	//JS
248
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
249
-	wp_enqueue_script( 'jquery-chosen' );
248
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
249
+	wp_enqueue_script('jquery-chosen');
250 250
 
251
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
252
-	wp_enqueue_script( 'give-accounting' );
251
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
252
+	wp_enqueue_script('give-accounting');
253 253
 
254
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
255
-	wp_enqueue_script( 'give-admin-scripts' );
254
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
255
+	wp_enqueue_script('give-admin-scripts');
256 256
 
257
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
258
-	wp_enqueue_script( 'jquery-flot' );
257
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
258
+	wp_enqueue_script('jquery-flot');
259 259
 
260
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
261
-	wp_enqueue_script( 'give-qtip' );
260
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
261
+	wp_enqueue_script('give-qtip');
262 262
 
263
-	wp_enqueue_script( 'jquery-ui-datepicker' );
264
-	wp_enqueue_script( 'thickbox' );
263
+	wp_enqueue_script('jquery-ui-datepicker');
264
+	wp_enqueue_script('thickbox');
265 265
 
266 266
 	// Forms CPT Script.
267
-	if ( $post_type === 'give_forms' ) {
268
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
269
-		wp_enqueue_script( 'give-admin-forms-scripts' );
267
+	if ($post_type === 'give_forms') {
268
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
269
+		wp_enqueue_script('give-admin-forms-scripts');
270 270
 	}
271 271
 
272 272
 	//Settings Scripts
273
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
274
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
275
-		wp_enqueue_script( 'give-admin-settings-scripts' );
273
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
274
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
275
+		wp_enqueue_script('give-admin-settings-scripts');
276 276
 	}
277 277
 
278 278
 	// Price Separators.
@@ -280,46 +280,46 @@  discard block
 block discarded – undo
280 280
 	$decimal_separator  = give_get_price_decimal_separator();
281 281
 
282 282
 	//Localize strings & variables for JS
283
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
284
-		'post_id'                 => isset( $post->ID ) ? $post->ID : null,
283
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
284
+		'post_id'                 => isset($post->ID) ? $post->ID : null,
285 285
 		'give_version'            => GIVE_VERSION,
286 286
 		'thousands_separator'     => $thousand_separator,
287 287
 		'decimal_separator'       => $decimal_separator,
288
-		'quick_edit_warning'      => esc_html__( 'Not available for variable priced forms.', 'give' ),
289
-		'delete_payment'          => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ),
290
-		'delete_payment_note'     => esc_html__( 'Are you sure you wish to delete this note?', 'give' ),
291
-		'revoke_api_key'          => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ),
292
-		'regenerate_api_key'      => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ),
293
-		'resend_receipt'          => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ),
294
-		'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ),
295
-		'delete_payment_download' => esc_html__( 'Are you sure you wish to delete this form?', 'give' ),
296
-		'one_price_min'           => esc_html__( 'You must have at least one price.', 'give' ),
297
-		'one_file_min'            => esc_html__( 'You must have at least one file.', 'give' ),
298
-		'one_field_min'           => esc_html__( 'You must have at least one field.', 'give' ),
299
-		'one_option'              => esc_html__( 'Choose a form', 'give' ),
300
-		'one_or_more_option'      => esc_html__( 'Choose one or more forms', 'give' ),
301
-		'numeric_item_price'      => esc_html__( 'Item price must be numeric.', 'give' ),
302
-		'numeric_quantity'        => esc_html__( 'Quantity must be numeric.', 'give' ),
303
-		'currency_sign'           => give_currency_filter( '' ),
304
-		'currency_pos'            => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
305
-		'currency_decimals'       => give_currency_decimal_filter( give_get_price_decimals() ),
306
-		'new_media_ui'            => apply_filters( 'give_use_35_media_ui', 1 ),
307
-		'remove_text'             => esc_html__( 'Remove', 'give' ),
308
-		'type_to_search'          => esc_html__( 'Type to search forms', 'give' ),
309
-		'batch_export_no_class'   => esc_html__( 'You must choose a method.', 'give' ),
310
-		'batch_export_no_reqs'    => esc_html__( 'Required fields not completed.', 'give' ),
311
-		'reset_stats_warn'        => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
312
-		'price_format_guide'      => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator )
313
-	) );
314
-
315
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
288
+		'quick_edit_warning'      => esc_html__('Not available for variable priced forms.', 'give'),
289
+		'delete_payment'          => esc_html__('Are you sure you wish to delete this payment?', 'give'),
290
+		'delete_payment_note'     => esc_html__('Are you sure you wish to delete this note?', 'give'),
291
+		'revoke_api_key'          => esc_html__('Are you sure you wish to revoke this API key?', 'give'),
292
+		'regenerate_api_key'      => esc_html__('Are you sure you wish to regenerate this API key?', 'give'),
293
+		'resend_receipt'          => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'),
294
+		'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'),
295
+		'delete_payment_download' => esc_html__('Are you sure you wish to delete this form?', 'give'),
296
+		'one_price_min'           => esc_html__('You must have at least one price.', 'give'),
297
+		'one_file_min'            => esc_html__('You must have at least one file.', 'give'),
298
+		'one_field_min'           => esc_html__('You must have at least one field.', 'give'),
299
+		'one_option'              => esc_html__('Choose a form', 'give'),
300
+		'one_or_more_option'      => esc_html__('Choose one or more forms', 'give'),
301
+		'numeric_item_price'      => esc_html__('Item price must be numeric.', 'give'),
302
+		'numeric_quantity'        => esc_html__('Quantity must be numeric.', 'give'),
303
+		'currency_sign'           => give_currency_filter(''),
304
+		'currency_pos'            => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
305
+		'currency_decimals'       => give_currency_decimal_filter(give_get_price_decimals()),
306
+		'new_media_ui'            => apply_filters('give_use_35_media_ui', 1),
307
+		'remove_text'             => esc_html__('Remove', 'give'),
308
+		'type_to_search'          => esc_html__('Type to search forms', 'give'),
309
+		'batch_export_no_class'   => esc_html__('You must choose a method.', 'give'),
310
+		'batch_export_no_reqs'    => esc_html__('Required fields not completed.', 'give'),
311
+		'reset_stats_warn'        => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
312
+		'price_format_guide'      => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator)
313
+	));
314
+
315
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
316 316
 		//call for new media manager
317 317
 		wp_enqueue_media();
318 318
 	}
319 319
 
320 320
 }
321 321
 
322
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
322
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
323 323
 
324 324
 /**
325 325
  * Admin Give Icon
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	?>
335 335
 	<style type="text/css" media="screen">
336 336
 
337
-		<?php if( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
337
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
338 338
 		@font-face {
339 339
 			font-family: 'give-icomoon';
340
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
340
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
345 345
 			font-weight: normal;
346 346
 			font-style: normal;
347 347
 		}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	<?php
361 361
 }
362 362
 
363
-add_action( 'admin_head', 'give_admin_icon' );
363
+add_action('admin_head', 'give_admin_icon');
364 364
 
365 365
 /**
366 366
  * Admin js code
@@ -390,4 +390,4 @@  discard block
 block discarded – undo
390 390
 	<?php
391 391
 }
392 392
 
393
-add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' );
393
+add_action('admin_head', 'give_admin_hide_notice_shortly_js');
Please login to merge, or discard this patch.
includes/gateways/paypal-standard.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.0
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @access private
22 22
  * @since  1.0
23 23
  */
24
-add_action( 'give_paypal_cc_form', '__return_false' );
24
+add_action('give_paypal_cc_form', '__return_false');
25 25
 
26 26
 /**
27 27
  * Process PayPal Purchase.
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_process_paypal_purchase( $purchase_data ) {
35
+function give_process_paypal_purchase($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 
41
-	$form_id  = intval( $purchase_data['post_data']['give-form-id'] );
42
-	$price_id = isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '';
41
+	$form_id  = intval($purchase_data['post_data']['give-form-id']);
42
+	$price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '';
43 43
 
44 44
 	// Collect payment data.
45 45
 	$payment_data = array(
@@ -57,69 +57,69 @@  discard block
 block discarded – undo
57 57
 	);
58 58
 
59 59
 	// Record the pending payment.
60
-	$payment = give_insert_payment( $payment_data );
60
+	$payment = give_insert_payment($payment_data);
61 61
 
62 62
 	// Check payment.
63
-	if ( ! $payment ) {
63
+	if ( ! $payment) {
64 64
 		// Record the error.
65 65
 		give_record_gateway_error(
66
-			esc_html__( 'Payment Error', 'give' ),
66
+			esc_html__('Payment Error', 'give'),
67 67
 			sprintf(
68 68
 			/* translators: %s: payment data */
69
-				esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ),
70
-				json_encode( $payment_data )
69
+				esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'),
70
+				json_encode($payment_data)
71 71
 			),
72 72
 			$payment
73 73
 		);
74 74
 		// Problems? Send back.
75
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
75
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
76 76
 
77 77
 	} else {
78 78
 
79 79
 		// Only send to PayPal if the pending payment is created successfully.
80
-		$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
80
+		$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
81 81
 
82 82
 		// Get the success url
83
-		$return_url = add_query_arg( array(
83
+		$return_url = add_query_arg(array(
84 84
 			'payment-confirmation' => 'paypal',
85 85
 			'payment-id'           => $payment
86 86
 
87
-		), get_permalink( give_get_option( 'success_page' ) ) );
87
+		), get_permalink(give_get_option('success_page')));
88 88
 
89 89
 		// Get the PayPal redirect uri
90
-		$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
90
+		$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
91 91
 
92 92
 		//Item name - pass level name if variable priced
93 93
 		$item_name = $purchase_data['post_data']['give-form-title'];
94 94
 
95 95
 		//Verify has variable prices
96
-		if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) {
96
+		if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) {
97 97
 
98
-			$item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] );
98
+			$item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']);
99 99
 
100
-			$price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] );
100
+			$price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']);
101 101
 
102 102
 			//Donation given doesn't match selected level (must be a custom amount)
103
-			if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) {
104
-				$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
103
+			if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) {
104
+				$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
105 105
 				//user custom amount text if any, fallback to default if not
106
-				$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
106
+				$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
107 107
 
108 108
 			} //Is there any donation level text?
109
-			elseif ( ! empty( $item_price_level_text ) ) {
110
-				$item_name .= ' - ' . $item_price_level_text;
109
+			elseif ( ! empty($item_price_level_text)) {
110
+				$item_name .= ' - '.$item_price_level_text;
111 111
 			}
112 112
 
113 113
 		} //Single donation: Custom Amount
114
-		elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) {
115
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
114
+		elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) {
115
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
116 116
 			//user custom amount text if any, fallback to default if not
117
-			$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
117
+			$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
118 118
 		}
119 119
 
120 120
 		// Setup PayPal arguments
121 121
 		$paypal_args = array(
122
-			'business'      => give_get_option( 'paypal_email', false ),
122
+			'business'      => give_get_option('paypal_email', false),
123 123
 			'first_name'    => $purchase_data['user_info']['first_name'],
124 124
 			'last_name'     => $purchase_data['user_info']['last_name'],
125 125
 			'email'         => $purchase_data['user_email'],
@@ -132,28 +132,28 @@  discard block
 block discarded – undo
132 132
 			'shipping'      => '0',
133 133
 			'no_note'       => '1',
134 134
 			'currency_code' => give_get_currency(),
135
-			'charset'       => get_bloginfo( 'charset' ),
135
+			'charset'       => get_bloginfo('charset'),
136 136
 			'custom'        => $payment,
137 137
 			'rm'            => '2',
138 138
 			'return'        => $return_url,
139
-			'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ),
139
+			'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment),
140 140
 			'notify_url'    => $listener_url,
141 141
 			'page_style'    => give_get_paypal_page_style(),
142
-			'cbt'           => get_bloginfo( 'name' ),
142
+			'cbt'           => get_bloginfo('name'),
143 143
 			'bn'            => 'givewp_SP'
144 144
 		);
145 145
 
146 146
 		//Add user address if present.
147
-		if ( ! empty( $purchase_data['user_info']['address'] ) ) {
148
-			$paypal_args['address1'] = isset( $purchase_data['user_info']['address']['line1'] ) ? $purchase_data['user_info']['address']['line1'] : '';
149
-			$paypal_args['address2'] = isset( $purchase_data['user_info']['address']['line2'] ) ? $purchase_data['user_info']['address']['line2'] : '';
150
-			$paypal_args['city']     = isset( $purchase_data['user_info']['address']['city'] ) ? $purchase_data['user_info']['address']['city'] : '';
151
-			$paypal_args['state']    = isset( $purchase_data['user_info']['address']['state'] ) ? $purchase_data['user_info']['address']['state'] : '';
152
-			$paypal_args['country']  = isset( $purchase_data['user_info']['address']['country'] ) ? $purchase_data['user_info']['address']['country'] : '';
147
+		if ( ! empty($purchase_data['user_info']['address'])) {
148
+			$paypal_args['address1'] = isset($purchase_data['user_info']['address']['line1']) ? $purchase_data['user_info']['address']['line1'] : '';
149
+			$paypal_args['address2'] = isset($purchase_data['user_info']['address']['line2']) ? $purchase_data['user_info']['address']['line2'] : '';
150
+			$paypal_args['city']     = isset($purchase_data['user_info']['address']['city']) ? $purchase_data['user_info']['address']['city'] : '';
151
+			$paypal_args['state']    = isset($purchase_data['user_info']['address']['state']) ? $purchase_data['user_info']['address']['state'] : '';
152
+			$paypal_args['country']  = isset($purchase_data['user_info']['address']['country']) ? $purchase_data['user_info']['address']['country'] : '';
153 153
 		}
154 154
 
155 155
 		//Donations or regular transactions?
156
-		if ( give_get_option( 'paypal_button_type' ) === 'standard' ) {
156
+		if (give_get_option('paypal_button_type') === 'standard') {
157 157
 			$paypal_extra_args = array(
158 158
 				'cmd' => '_xclick',
159 159
 			);
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 			);
164 164
 		}
165 165
 
166
-		$paypal_args = array_merge( $paypal_extra_args, $paypal_args );
167
-		$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data );
166
+		$paypal_args = array_merge($paypal_extra_args, $paypal_args);
167
+		$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data);
168 168
 
169 169
 		// Build query
170
-		$paypal_redirect .= http_build_query( $paypal_args );
170
+		$paypal_redirect .= http_build_query($paypal_args);
171 171
 
172 172
 		// Fix for some sites that encode the entities
173
-		$paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
173
+		$paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
174 174
 
175 175
 		// Redirect to PayPal
176
-		wp_redirect( $paypal_redirect );
176
+		wp_redirect($paypal_redirect);
177 177
 		exit;
178 178
 	}
179 179
 
180 180
 }
181 181
 
182
-add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' );
182
+add_action('give_gateway_paypal', 'give_process_paypal_purchase');
183 183
 
184 184
 /**
185 185
  * Listens for a PayPal IPN requests and then sends to the processing function
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
  */
190 190
 function give_listen_for_paypal_ipn() {
191 191
 	// Regular PayPal IPN
192
-	if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) {
192
+	if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') {
193 193
 		/**
194 194
 		 * Fires while verifying PayPal IPN
195 195
 		 *
196 196
 		 * @since 1.0
197 197
 		 */
198
-		do_action( 'give_verify_paypal_ipn' );
198
+		do_action('give_verify_paypal_ipn');
199 199
 	}
200 200
 }
201 201
 
202
-add_action( 'init', 'give_listen_for_paypal_ipn' );
202
+add_action('init', 'give_listen_for_paypal_ipn');
203 203
 
204 204
 /**
205 205
  * Process PayPal IPN
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 function give_process_paypal_ipn() {
211 211
 
212 212
 	// Check the request method is POST
213
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
213
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
214 214
 		return;
215 215
 	}
216 216
 
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
 	$post_data = '';
219 219
 
220 220
 	// Fallback just in case post_max_size is lower than needed
221
-	if ( ini_get( 'allow_url_fopen' ) ) {
222
-		$post_data = file_get_contents( 'php://input' );
221
+	if (ini_get('allow_url_fopen')) {
222
+		$post_data = file_get_contents('php://input');
223 223
 	} else {
224 224
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
225
-		ini_set( 'post_max_size', '12M' );
225
+		ini_set('post_max_size', '12M');
226 226
 	}
227 227
 	// Start the encoded data collection with notification command
228 228
 	$encoded_data = 'cmd=_notify-validate';
@@ -231,40 +231,40 @@  discard block
 block discarded – undo
231 231
 	$arg_separator = give_get_php_arg_separator_output();
232 232
 
233 233
 	// Verify there is a post_data
234
-	if ( $post_data || strlen( $post_data ) > 0 ) {
234
+	if ($post_data || strlen($post_data) > 0) {
235 235
 		// Append the data
236
-		$encoded_data .= $arg_separator . $post_data;
236
+		$encoded_data .= $arg_separator.$post_data;
237 237
 	} else {
238 238
 		// Check if POST is empty
239
-		if ( empty( $_POST ) ) {
239
+		if (empty($_POST)) {
240 240
 			// Nothing to do
241 241
 			return;
242 242
 		} else {
243 243
 			// Loop through each POST
244
-			foreach ( $_POST as $key => $value ) {
244
+			foreach ($_POST as $key => $value) {
245 245
 				// Encode the value and append the data
246
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
246
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
247 247
 			}
248 248
 		}
249 249
 	}
250 250
 
251 251
 	// Convert collected post data to an array
252
-	parse_str( $encoded_data, $encoded_data_array );
252
+	parse_str($encoded_data, $encoded_data_array);
253 253
 
254
-	foreach ( $encoded_data_array as $key => $value ) {
254
+	foreach ($encoded_data_array as $key => $value) {
255 255
 
256
-		if ( false !== strpos( $key, 'amp;' ) ) {
257
-			$new_key = str_replace( '&amp;', '&', $key );
258
-			$new_key = str_replace( 'amp;', '&', $new_key );
256
+		if (false !== strpos($key, 'amp;')) {
257
+			$new_key = str_replace('&amp;', '&', $key);
258
+			$new_key = str_replace('amp;', '&', $new_key);
259 259
 
260
-			unset( $encoded_data_array[ $key ] );
261
-			$encoded_data_array[ $new_key ] = $value;
260
+			unset($encoded_data_array[$key]);
261
+			$encoded_data_array[$new_key] = $value;
262 262
 		}
263 263
 
264 264
 	}
265 265
 
266 266
 	//Validate IPN request w/ PayPal if user hasn't disabled this security measure
267
-	if ( ! give_get_option( 'disable_paypal_verification' ) ) {
267
+	if ( ! give_get_option('disable_paypal_verification')) {
268 268
 
269 269
 		$remote_post_vars = array(
270 270
 			'method'      => 'POST',
@@ -284,28 +284,28 @@  discard block
 block discarded – undo
284 284
 		);
285 285
 
286 286
 		// Validate the IPN
287
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
287
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
288 288
 
289
-		if ( is_wp_error( $api_response ) ) {
289
+		if (is_wp_error($api_response)) {
290 290
 			give_record_gateway_error(
291
-				esc_html__( 'IPN Error', 'give' ),
291
+				esc_html__('IPN Error', 'give'),
292 292
 				sprintf(
293 293
 				/* translators: %s: Paypal IPN response */
294
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
295
-					json_encode( $api_response )
294
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
295
+					json_encode($api_response)
296 296
 				)
297 297
 			);
298 298
 
299 299
 			return; // Something went wrong
300 300
 		}
301 301
 
302
-		if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) {
302
+		if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) {
303 303
 			give_record_gateway_error(
304
-				esc_html__( 'IPN Error', 'give' ),
304
+				esc_html__('IPN Error', 'give'),
305 305
 				sprintf(
306 306
 				/* translators: %s: Paypal IPN response */
307
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
308
-					json_encode( $api_response )
307
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
308
+					json_encode($api_response)
309 309
 				)
310 310
 			);
311 311
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	}
316 316
 
317 317
 	// Check if $post_data_array has been populated
318
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
318
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
319 319
 		return;
320 320
 	}
321 321
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 		'payment_status' => ''
325 325
 	);
326 326
 
327
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
327
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
328 328
 
329
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
329
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
330 330
 	$txn_type = $encoded_data_array['txn_type'];
331 331
 
332
-	if ( has_action( 'give_paypal_' . $txn_type ) ) {
332
+	if (has_action('give_paypal_'.$txn_type)) {
333 333
 		/**
334 334
 		 * Fires while processing PayPal IPN $txn_type.
335 335
 		 *
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		 * @param array $encoded_data_array Encoded data.
341 341
 		 * @param int   $payment_id         Payment id.
342 342
 		 */
343
-		do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id );
343
+		do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id);
344 344
 	} else {
345 345
 		/**
346 346
 		 * Fires while process PayPal IPN.
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 		 * @param array $encoded_data_array Encoded data.
353 353
 		 * @param int   $payment_id         Payment id.
354 354
 		 */
355
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
355
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
356 356
 	}
357 357
 	exit;
358 358
 }
359 359
 
360
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
360
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
361 361
 
362 362
 /**
363 363
  * Process web accept (one time) payment IPNs.
@@ -368,224 +368,224 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return void
370 370
  */
371
-function give_process_paypal_web_accept_and_cart( $data, $payment_id ) {
371
+function give_process_paypal_web_accept_and_cart($data, $payment_id) {
372 372
 
373
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
373
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
374 374
 		return;
375 375
 	}
376 376
 
377
-	if ( empty( $payment_id ) ) {
377
+	if (empty($payment_id)) {
378 378
 		return;
379 379
 	}
380 380
 
381 381
 	// Collect payment details
382
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
382
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
383 383
 	$paypal_amount  = $data['mc_gross'];
384
-	$payment_status = strtolower( $data['payment_status'] );
385
-	$currency_code  = strtolower( $data['mc_currency'] );
386
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
387
-	$payment_meta   = give_get_payment_meta( $payment_id );
384
+	$payment_status = strtolower($data['payment_status']);
385
+	$currency_code  = strtolower($data['mc_currency']);
386
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
387
+	$payment_meta   = give_get_payment_meta($payment_id);
388 388
 
389 389
 
390
-	if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) {
390
+	if (give_get_payment_gateway($payment_id) != 'paypal') {
391 391
 		return; // this isn't a PayPal standard IPN
392 392
 	}
393 393
 
394 394
 	// Verify payment recipient
395
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) {
395
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) {
396 396
 
397 397
 		give_record_gateway_error(
398
-			esc_html__( 'IPN Error', 'give' ),
398
+			esc_html__('IPN Error', 'give'),
399 399
 			sprintf(
400 400
 			/* translators: %s: Paypal IPN response */
401
-				esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ),
402
-				json_encode( $data )
401
+				esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'),
402
+				json_encode($data)
403 403
 			),
404 404
 			$payment_id
405 405
 		);
406
-		give_update_payment_status( $payment_id, 'failed' );
407
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) );
406
+		give_update_payment_status($payment_id, 'failed');
407
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give'));
408 408
 
409 409
 		return;
410 410
 	}
411 411
 
412 412
 	// Verify payment currency.
413
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
413
+	if ($currency_code != strtolower($payment_meta['currency'])) {
414 414
 
415 415
 		give_record_gateway_error(
416
-			esc_html__( 'IPN Error', 'give' ),
416
+			esc_html__('IPN Error', 'give'),
417 417
 			sprintf(
418 418
 			/* translators: %s: Paypal IPN response */
419
-				esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ),
420
-				json_encode( $data )
419
+				esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'),
420
+				json_encode($data)
421 421
 			),
422 422
 			$payment_id
423 423
 		);
424
-		give_update_payment_status( $payment_id, 'failed' );
425
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
424
+		give_update_payment_status($payment_id, 'failed');
425
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give'));
426 426
 
427 427
 		return;
428 428
 	}
429 429
 
430
-	if ( ! give_get_payment_user_email( $payment_id ) ) {
430
+	if ( ! give_get_payment_user_email($payment_id)) {
431 431
 
432 432
 		// No email associated with the donation, so store from PayPal
433
-		give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] );
433
+		give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']);
434 434
 
435 435
 		// Setup and store the donors's details.
436 436
 		$address            = array();
437
-		$address['line1']   = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false;
438
-		$address['city']    = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false;
439
-		$address['state']   = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false;
440
-		$address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
441
-		$address['zip']     = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false;
437
+		$address['line1']   = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
438
+		$address['city']    = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
439
+		$address['state']   = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
440
+		$address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
441
+		$address['zip']     = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
442 442
 
443 443
 		$user_info = array(
444 444
 			'id'         => '-1',
445
-			'email'      => sanitize_text_field( $data['payer_email'] ),
446
-			'first_name' => sanitize_text_field( $data['first_name'] ),
447
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
445
+			'email'      => sanitize_text_field($data['payer_email']),
446
+			'first_name' => sanitize_text_field($data['first_name']),
447
+			'last_name'  => sanitize_text_field($data['last_name']),
448 448
 			'discount'   => '',
449 449
 			'address'    => $address
450 450
 		);
451 451
 
452 452
 		$payment_meta['user_info'] = $user_info;
453
-		give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta );
453
+		give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta);
454 454
 	}
455 455
 
456
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
456
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
457 457
 
458 458
 		// Process a refund
459
-		give_process_paypal_refund( $data, $payment_id );
459
+		give_process_paypal_refund($data, $payment_id);
460 460
 
461 461
 	} else {
462 462
 
463
-		if ( get_post_status( $payment_id ) == 'publish' ) {
463
+		if (get_post_status($payment_id) == 'publish') {
464 464
 			return; // Only complete payments once
465 465
 		}
466 466
 
467 467
 		// Retrieve the total donation amount (before PayPal)
468
-		$payment_amount = give_get_payment_amount( $payment_id );
468
+		$payment_amount = give_get_payment_amount($payment_id);
469 469
 
470
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
470
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
471 471
 			// The prices don't match
472 472
 			give_record_gateway_error(
473
-				esc_html__( 'IPN Error', 'give' ),
473
+				esc_html__('IPN Error', 'give'),
474 474
 				sprintf(
475 475
 				/* translators: %s: Paypal IPN response */
476
-					esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ),
477
-					json_encode( $data )
476
+					esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'),
477
+					json_encode($data)
478 478
 				),
479 479
 				$payment_id
480 480
 			);
481
-			give_update_payment_status( $payment_id, 'failed' );
482
-			give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
481
+			give_update_payment_status($payment_id, 'failed');
482
+			give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give'));
483 483
 
484 484
 			return;
485 485
 		}
486
-		if ( $purchase_key != give_get_payment_key( $payment_id ) ) {
486
+		if ($purchase_key != give_get_payment_key($payment_id)) {
487 487
 			// Keys don't match
488 488
 			give_record_gateway_error(
489
-				esc_html__( 'IPN Error', 'give' ),
489
+				esc_html__('IPN Error', 'give'),
490 490
 				sprintf(
491 491
 					/* translators: %s: Paypal IPN response */
492
-					esc_html__( 'Invalid key in IPN response. IPN data: %s', 'give' ),
493
-					json_encode( $data )
492
+					esc_html__('Invalid key in IPN response. IPN data: %s', 'give'),
493
+					json_encode($data)
494 494
 				),
495 495
 				$payment_id
496 496
 			);
497
-			give_update_payment_status( $payment_id, 'failed' );
498
-			give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid key in PayPal IPN.', 'give' ) );
497
+			give_update_payment_status($payment_id, 'failed');
498
+			give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid key in PayPal IPN.', 'give'));
499 499
 
500 500
 			return;
501 501
 		}
502 502
 
503
-		if ( $payment_status == 'completed' || give_is_test_mode() ) {
503
+		if ($payment_status == 'completed' || give_is_test_mode()) {
504 504
 			give_insert_payment_note(
505 505
 				$payment_id,
506 506
 				sprintf(
507 507
 				/* translators: %s: Paypal transaction ID */
508
-					esc_html__( 'PayPal Transaction ID: %s', 'give' ),
508
+					esc_html__('PayPal Transaction ID: %s', 'give'),
509 509
 					$data['txn_id']
510 510
 				)
511 511
 			);
512
-			give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
513
-			give_update_payment_status( $payment_id, 'publish' );
514
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
512
+			give_set_payment_transaction_id($payment_id, $data['txn_id']);
513
+			give_update_payment_status($payment_id, 'publish');
514
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
515 515
 
516 516
 			// Look for possible pending reasons, such as an echeck
517 517
 
518 518
 			$note = '';
519 519
 
520
-			switch ( strtolower( $data['pending_reason'] ) ) {
520
+			switch (strtolower($data['pending_reason'])) {
521 521
 
522 522
 				case 'echeck' :
523 523
 
524
-					$note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' );
524
+					$note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give');
525 525
 
526 526
 					break;
527 527
 
528 528
 				case 'address' :
529 529
 
530
-					$note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' );
530
+					$note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give');
531 531
 
532 532
 					break;
533 533
 
534 534
 				case 'intl' :
535 535
 
536
-					$note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' );
536
+					$note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give');
537 537
 
538 538
 					break;
539 539
 
540 540
 				case 'multi-currency' :
541 541
 
542
-					$note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' );
542
+					$note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give');
543 543
 
544 544
 					break;
545 545
 
546 546
 				case 'paymentreview' :
547 547
 				case 'regulatory_review' :
548 548
 
549
-					$note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' );
549
+					$note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give');
550 550
 
551 551
 					break;
552 552
 
553 553
 				case 'unilateral' :
554 554
 
555
-					$note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
555
+					$note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give');
556 556
 
557 557
 					break;
558 558
 
559 559
 				case 'upgrade' :
560 560
 
561
-					$note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' );
561
+					$note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give');
562 562
 
563 563
 					break;
564 564
 
565 565
 				case 'verify' :
566 566
 
567
-					$note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' );
567
+					$note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give');
568 568
 
569 569
 					break;
570 570
 
571 571
 				case 'other' :
572 572
 
573
-					$note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' );
573
+					$note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give');
574 574
 
575 575
 					break;
576 576
 
577 577
 			}
578 578
 
579
-			if ( ! empty( $note ) ) {
579
+			if ( ! empty($note)) {
580 580
 
581
-				give_insert_payment_note( $payment_id, $note );
581
+				give_insert_payment_note($payment_id, $note);
582 582
 
583 583
 			}
584 584
 		}
585 585
 	}
586 586
 }
587 587
 
588
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 );
588
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2);
589 589
 
590 590
 /**
591 591
  * Process PayPal IPN Refunds
@@ -596,28 +596,28 @@  discard block
 block discarded – undo
596 596
  *
597 597
  * @return void
598 598
  */
599
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
599
+function give_process_paypal_refund($data, $payment_id = 0) {
600 600
 
601 601
 	// Collect payment details
602 602
 
603
-	if ( empty( $payment_id ) ) {
603
+	if (empty($payment_id)) {
604 604
 		return;
605 605
 	}
606 606
 
607
-	if ( get_post_status( $payment_id ) == 'refunded' ) {
607
+	if (get_post_status($payment_id) == 'refunded') {
608 608
 		return; // Only refund payments once
609 609
 	}
610 610
 
611
-	$payment_amount = give_get_payment_amount( $payment_id );
611
+	$payment_amount = give_get_payment_amount($payment_id);
612 612
 	$refund_amount  = $data['payment_gross'] * - 1;
613 613
 
614
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
614
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
615 615
 
616 616
 		give_insert_payment_note(
617 617
 			$payment_id,
618 618
 			sprintf(
619 619
 			/* translators: %s: Paypal parent transaction ID */
620
-				esc_html__( 'Partial PayPal refund processed: %s', 'give' ),
620
+				esc_html__('Partial PayPal refund processed: %s', 'give'),
621 621
 				$data['parent_txn_id']
622 622
 			)
623 623
 		);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		$payment_id,
631 631
 		sprintf(
632 632
 			/* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
633
-			esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ),
633
+			esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'),
634 634
 			$data['parent_txn_id'],
635 635
 			$data['reason_code']
636 636
 		)
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
 		$payment_id,
640 640
 		sprintf(
641 641
 		/* translators: %s: Paypal transaction ID */
642
-			esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ),
642
+			esc_html__('PayPal Refund Transaction ID: %s', 'give'),
643 643
 			$data['txn_id']
644 644
 		)
645 645
 	);
646
-	give_update_payment_status( $payment_id, 'refunded' );
646
+	give_update_payment_status($payment_id, 'refunded');
647 647
 }
648 648
 
649 649
 /**
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
  *
656 656
  * @return string
657 657
  */
658
-function give_get_paypal_redirect( $ssl_check = false ) {
658
+function give_get_paypal_redirect($ssl_check = false) {
659 659
 
660
-	if ( is_ssl() || ! $ssl_check ) {
660
+	if (is_ssl() || ! $ssl_check) {
661 661
 		$protocal = 'https://';
662 662
 	} else {
663 663
 		$protocal = 'http://';
664 664
 	}
665 665
 
666 666
 	// Check the current payment mode
667
-	if ( give_is_test_mode() ) {
667
+	if (give_is_test_mode()) {
668 668
 		// Test mode
669
-		$paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr';
669
+		$paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr';
670 670
 	} else {
671 671
 		// Live mode
672
-		$paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr';
672
+		$paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr';
673 673
 	}
674 674
 
675
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
675
+	return apply_filters('give_paypal_uri', $paypal_uri);
676 676
 }
677 677
 
678 678
 /**
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
  * @return string
683 683
  */
684 684
 function give_get_paypal_page_style() {
685
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
685
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
686 686
 
687
-	return apply_filters( 'give_paypal_page_style', $page_style );
687
+	return apply_filters('give_paypal_page_style', $page_style);
688 688
 }
689 689
 
690 690
 /**
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
  * @return string
700 700
  *
701 701
  */
702
-function give_paypal_success_page_content( $content ) {
702
+function give_paypal_success_page_content($content) {
703 703
 
704
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
704
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
705 705
 		return $content;
706 706
 	}
707 707
 
708
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
708
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
709 709
 
710
-	if ( ! $payment_id ) {
710
+	if ( ! $payment_id) {
711 711
 		$session    = give_get_purchase_session();
712
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
712
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
713 713
 	}
714 714
 
715
-	$payment = get_post( $payment_id );
715
+	$payment = get_post($payment_id);
716 716
 
717
-	if ( $payment && 'pending' == $payment->post_status ) {
717
+	if ($payment && 'pending' == $payment->post_status) {
718 718
 
719 719
 		// Payment is still pending so show processing indicator to fix the Race Condition
720 720
 		ob_start();
721 721
 
722
-		give_get_template_part( 'payment', 'processing' );
722
+		give_get_template_part('payment', 'processing');
723 723
 
724 724
 		$content = ob_get_clean();
725 725
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 
730 730
 }
731 731
 
732
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
732
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
733 733
 
734 734
 /**
735 735
  * Given a Payment ID, extract the transaction ID
@@ -740,22 +740,22 @@  discard block
 block discarded – undo
740 740
  *
741 741
  * @return string                   Transaction ID
742 742
  */
743
-function give_paypal_get_payment_transaction_id( $payment_id ) {
743
+function give_paypal_get_payment_transaction_id($payment_id) {
744 744
 
745 745
 	$transaction_id = '';
746
-	$notes          = give_get_payment_notes( $payment_id );
746
+	$notes          = give_get_payment_notes($payment_id);
747 747
 
748
-	foreach ( $notes as $note ) {
749
-		if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
748
+	foreach ($notes as $note) {
749
+		if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
750 750
 			$transaction_id = $match[1];
751 751
 			continue;
752 752
 		}
753 753
 	}
754 754
 
755
-	return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id );
755
+	return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id);
756 756
 }
757 757
 
758
-add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 );
758
+add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1);
759 759
 
760 760
 /**
761 761
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
  *
768 768
  * @return string                 A link to the PayPal transaction details
769 769
  */
770
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
770
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
771 771
 
772 772
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
773
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
773
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
774 774
 
775
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
775
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
776 776
 
777 777
 }
778 778
 
779
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
779
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET or $_POST )
31
-	if(  doing_action( 'admin_init' ) && empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (doing_action('admin_init') && empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
49
-add_action( 'admin_init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49
+add_action('admin_init', 'give_get_actions');
50 50
 
51 51
 /**
52 52
  * Hooks Give actions, when present in the $_POST superglobal. Every give_action
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function give_post_actions() {
61 61
 
62
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
62
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
63 63
 
64 64
 
65 65
 	// Add backward compatibility to give-action param ( $_GET or $_POST )
66
-	if(  doing_action( 'admin_init' ) && empty( $_post_action ) ) {
67
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
66
+	if (doing_action('admin_init') && empty($_post_action)) {
67
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
68 68
 	}
69 69
 
70
-	if ( isset( $_post_action ) ) {
70
+	if (isset($_post_action)) {
71 71
 		/**
72 72
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
73 73
 		 *
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 		 *
76 76
 		 * @param array $_POST Array of HTTP POST variables.
77 77
 		 */
78
-		do_action( "give_{$_post_action}", $_POST );
78
+		do_action("give_{$_post_action}", $_POST);
79 79
 	}
80 80
 
81 81
 }
82 82
 
83
-add_action( 'init', 'give_post_actions' );
84
-add_action( 'admin_init', 'give_post_actions' );
83
+add_action('init', 'give_post_actions');
84
+add_action('admin_init', 'give_post_actions');
85 85
 
86 86
 /**
87 87
  * Connect WordPress user with Donor.
@@ -91,24 +91,24 @@  discard block
 block discarded – undo
91 91
  * @param  array $user_data User Data
92 92
  * @return void
93 93
  */
94
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
95
-	$donor = new Give_Customer( $user_data['user_email'] );
94
+function give_connect_donor_to_wpuser($user_id, $user_data) {
95
+	$donor = new Give_Customer($user_data['user_email']);
96 96
 
97 97
 	// Validate donor id and check if do nor is already connect to wp user or not.
98
-	if( $donor->id && ! $donor->user_id ) {
98
+	if ($donor->id && ! $donor->user_id) {
99 99
 
100 100
 		// Update donor user_id.
101
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
102
-			$donor_note    = __( sprintf( 'WordPress user #%d is connected to #%d', $user_id, $donor->id ), 'give' );
103
-			$donor->add_note( $donor_note );
101
+		if ($donor->update(array('user_id' => $user_id))) {
102
+			$donor_note = __(sprintf('WordPress user #%d is connected to #%d', $user_id, $donor->id), 'give');
103
+			$donor->add_note($donor_note);
104 104
 
105 105
 			// Update user_id meta in payments.
106
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
107
-				foreach ( $donations as $donation  ) {
108
-					update_post_meta( $donation, '_give_payment_user_id', $user_id );
106
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
107
+				foreach ($donations as $donation) {
108
+					update_post_meta($donation, '_give_payment_user_id', $user_id);
109 109
 				}
110 110
 			}
111 111
 		}
112 112
 	}
113 113
 }
114
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
114
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +95 added lines, -95 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
 
@@ -62,50 +62,50 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return bool If the gravatar exists or not
64 64
 	 */
65
-	public function validate_gravatar( $id_or_email ) {
65
+	public function validate_gravatar($id_or_email) {
66 66
 		//id or email code borrowed from wp-includes/pluggable.php
67 67
 		$email = '';
68
-		if ( is_numeric( $id_or_email ) ) {
68
+		if (is_numeric($id_or_email)) {
69 69
 			$id   = (int) $id_or_email;
70
-			$user = get_userdata( $id );
71
-			if ( $user ) {
70
+			$user = get_userdata($id);
71
+			if ($user) {
72 72
 				$email = $user->user_email;
73 73
 			}
74
-		} elseif ( is_object( $id_or_email ) ) {
74
+		} elseif (is_object($id_or_email)) {
75 75
 			// No avatar for pingbacks or trackbacks
76
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
77
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
76
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
77
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
78 78
 				return false;
79 79
 			}
80 80
 
81
-			if ( ! empty( $id_or_email->user_id ) ) {
81
+			if ( ! empty($id_or_email->user_id)) {
82 82
 				$id   = (int) $id_or_email->user_id;
83
-				$user = get_userdata( $id );
84
-				if ( $user ) {
83
+				$user = get_userdata($id);
84
+				if ($user) {
85 85
 					$email = $user->user_email;
86 86
 				}
87
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
87
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
88 88
 				$email = $id_or_email->comment_author_email;
89 89
 			}
90 90
 		} else {
91 91
 			$email = $id_or_email;
92 92
 		}
93 93
 
94
-		$hashkey = md5( strtolower( trim( $email ) ) );
95
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
94
+		$hashkey = md5(strtolower(trim($email)));
95
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
96 96
 
97
-		$data = wp_cache_get( $hashkey );
98
-		if ( false === $data ) {
99
-			$response = wp_remote_head( $uri );
100
-			if ( is_wp_error( $response ) ) {
97
+		$data = wp_cache_get($hashkey);
98
+		if (false === $data) {
99
+			$response = wp_remote_head($uri);
100
+			if (is_wp_error($response)) {
101 101
 				$data = 'not200';
102 102
 			} else {
103 103
 				$data = $response['response']['code'];
104 104
 			}
105
-			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
105
+			wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
106 106
 
107 107
 		}
108
-		if ( $data == '200' ) {
108
+		if ($data == '200') {
109 109
 			return true;
110 110
 		} else {
111 111
 			return false;
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return array        IDs if logs, false otherwise
124 124
 	 */
125
-	public function get_log_ids( $form_id = '' ) {
125
+	public function get_log_ids($form_id = '') {
126 126
 
127 127
 		// get Give_Logging class
128 128
 		global $give_logs;
129 129
 
130 130
 		// get log for this form
131
-		$logs = $give_logs->get_logs( $form_id );
131
+		$logs = $give_logs->get_logs($form_id);
132 132
 
133
-		if ( $logs ) {
133
+		if ($logs) {
134 134
 			$log_ids = array();
135 135
 
136 136
 			// make an array with all the donor IDs
137
-			foreach ( $logs as $log ) {
137
+			foreach ($logs as $log) {
138 138
 				$log_ids[] = $log->ID;
139 139
 			}
140 140
 
@@ -155,51 +155,51 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return mixed
157 157
 	 */
158
-	public function get_payment_ids( $form_id = '' ) {
158
+	public function get_payment_ids($form_id = '') {
159 159
 
160 160
 		$give_options = give_get_settings();
161 161
 
162
-		$log_ids = $this->get_log_ids( $form_id );
162
+		$log_ids = $this->get_log_ids($form_id);
163 163
 
164
-		if ( $log_ids ) {
164
+		if ($log_ids) {
165 165
 
166 166
 			$payment_ids = array();
167 167
 
168
-			foreach ( $log_ids as $id ) {
168
+			foreach ($log_ids as $id) {
169 169
 				// get the payment ID for each corresponding log ID
170
-				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true );
170
+				$payment_ids[] = get_post_meta($id, '_give_log_payment_id', true);
171 171
 			}
172 172
 
173 173
 			// remove donors who have donated more than once so we can have unique avatars
174 174
 			$unique_emails = array();
175 175
 
176
-			foreach ( $payment_ids as $key => $id ) {
176
+			foreach ($payment_ids as $key => $id) {
177 177
 
178
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
178
+				$email = get_post_meta($id, '_give_payment_user_email', true);
179 179
 
180
-				if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) {
181
-					if ( ! $this->validate_gravatar( $email ) ) {
180
+				if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) {
181
+					if ( ! $this->validate_gravatar($email)) {
182 182
 						continue;
183 183
 					}
184 184
 				}
185 185
 
186
-				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true );
186
+				$unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true);
187 187
 
188 188
 			}
189 189
 
190 190
 			$unique_ids = array();
191 191
 
192 192
 			// strip duplicate emails
193
-			$unique_emails = array_unique( $unique_emails );
193
+			$unique_emails = array_unique($unique_emails);
194 194
 
195 195
 			// convert the unique IDs back into simple array
196
-			foreach ( $unique_emails as $id => $email ) {
196
+			foreach ($unique_emails as $id => $email) {
197 197
 				$unique_ids[] = $id;
198 198
 			}
199 199
 
200 200
 			// randomize the payment IDs if enabled
201
-			if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) {
202
-				shuffle( $unique_ids );
201
+			if (isset($give_options['give_donors_gravatars_random_gravatars'])) {
202
+				shuffle($unique_ids);
203 203
 			}
204 204
 
205 205
 			// return our unique IDs
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string
222 222
 	 */
223
-	public function gravatars( $form_id = false, $title = '' ) {
223
+	public function gravatars($form_id = false, $title = '') {
224 224
 
225 225
 		// unique $payment_ids 
226
-		$payment_ids = $this->get_payment_ids( $form_id );
226
+		$payment_ids = $this->get_payment_ids($form_id);
227 227
 
228 228
 		$give_options = give_get_settings();
229 229
 
230 230
 		// return if no ID
231
-		if ( ! $form_id ) {
231
+		if ( ! $form_id) {
232 232
 			return;
233 233
 		}
234 234
 
235 235
 		// minimum amount of donations before showing gravatars
236 236
 		// if the number of items in array is not greater or equal to the number specified, then exit
237
-		if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) {
238
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) {
237
+		if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) {
238
+			if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) {
239 239
 				return;
240 240
 			}
241 241
 		}
@@ -246,51 +246,51 @@  discard block
 block discarded – undo
246 246
 		echo '<div id="give-purchase-gravatars">';
247 247
 
248 248
 
249
-		if ( isset ( $title ) ) {
249
+		if (isset ($title)) {
250 250
 
251
-			if ( $title ) {
252
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' );
253
-			} elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) {
254
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' );
251
+			if ($title) {
252
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>');
253
+			} elseif (isset($give_options['give_donors_gravatars_heading'])) {
254
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>');
255 255
 			}
256 256
 
257 257
 		}
258 258
 		echo '<ul class="give-purchase-gravatars-list">';
259 259
 		$i = 0;
260 260
 
261
-		if ( $payment_ids ) {
262
-			foreach ( $payment_ids as $id ) {
261
+		if ($payment_ids) {
262
+			foreach ($payment_ids as $id) {
263 263
 
264 264
 				// Give saves a blank option even when the control is turned off, hence the extra check
265
-				if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) {
265
+				if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) {
266 266
 					continue;
267 267
 				}
268 268
 
269 269
 				// get the payment meta
270
-				$payment_meta = get_post_meta( $id, '_give_payment_meta', true );
270
+				$payment_meta = get_post_meta($id, '_give_payment_meta', true);
271 271
 
272 272
 				// unserialize the payment meta
273
-				$user_info = maybe_unserialize( $payment_meta['user_info'] );
273
+				$user_info = maybe_unserialize($payment_meta['user_info']);
274 274
 
275 275
 				// get donor's first name
276 276
 				$name = $user_info['first_name'];
277 277
 
278 278
 				// get donor's email
279
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
279
+				$email = get_post_meta($id, '_give_payment_user_email', true);
280 280
 
281 281
 				// set gravatar size and provide filter
282
-				$size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : '';
282
+				$size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : '';
283 283
 
284 284
 				// default image
285
-				$default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false );
285
+				$default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false);
286 286
 
287 287
 				// assemble output
288 288
 				$output .= '<li>';
289 289
 
290
-				$output .= get_avatar( $email, $size, $default_image, $name );
290
+				$output .= get_avatar($email, $size, $default_image, $name);
291 291
 				$output .= '</li>';
292 292
 
293
-				$i ++;
293
+				$i++;
294 294
 
295 295
 			} // end foreach
296 296
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		echo '</ul>';
300 300
 		echo '</div>';
301 301
 
302
-		return apply_filters( 'give_donors_gravatars', ob_get_clean() );
302
+		return apply_filters('give_donors_gravatars', ob_get_clean());
303 303
 	}
304 304
 
305 305
 	/**
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 * @return void
312 312
 	 */
313 313
 	public function register_widget() {
314
-		register_widget( 'Give_Donors_Gravatars_Widget' );
314
+		register_widget('Give_Donors_Gravatars_Widget');
315 315
 	}
316 316
 
317 317
 	/**
@@ -327,19 +327,19 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @todo   Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars
329 329
 	 */
330
-	public function shortcode( $atts, $content = null ) {
330
+	public function shortcode($atts, $content = null) {
331 331
 
332
-		$atts = shortcode_atts( array(
332
+		$atts = shortcode_atts(array(
333 333
 			'id'    => '',
334 334
 			'title' => ''
335
-		), $atts, 'give_donors_gravatars' );
335
+		), $atts, 'give_donors_gravatars');
336 336
 
337 337
 		// if no ID is passed on single give_forms pages, get the correct ID
338
-		if ( is_singular( 'give_forms' ) ) {
338
+		if (is_singular('give_forms')) {
339 339
 			$id = get_the_ID();
340 340
 		}
341 341
 
342
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
342
+		$content = $this->gravatars($atts['id'], $atts['title']);
343 343
 
344 344
 		return $content;
345 345
 
@@ -355,56 +355,56 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return array           Gravatar settings.
357 357
 	 */
358
-	public function settings( $settings ) {
358
+	public function settings($settings) {
359 359
 
360 360
 		$give_gravatar_settings = array(
361 361
 			array(
362
-				'name' => esc_html__( 'Donator Gravatars', 'give' ),
362
+				'name' => esc_html__('Donator Gravatars', 'give'),
363 363
 				'desc' => '<hr>',
364 364
 				'id'   => 'give_title',
365 365
 				'type' => 'give_title'
366 366
 			),
367 367
 			array(
368
-				'name' => esc_html__( 'Heading', 'give' ),
369
-				'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ),
368
+				'name' => esc_html__('Heading', 'give'),
369
+				'desc' => esc_html__('The heading to display above the Gravatars.', 'give'),
370 370
 				'type' => 'text',
371 371
 				'id'   => 'give_donors_gravatars_heading'
372 372
 			),
373 373
 			array(
374
-				'name'    => esc_html__( 'Gravatar Size', 'give' ),
375
-				'desc'    => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ),
374
+				'name'    => esc_html__('Gravatar Size', 'give'),
375
+				'desc'    => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'),
376 376
 				'type'    => 'text_small',
377 377
 				'id'      => 'give_donors_gravatars_gravatar_size',
378 378
 				'default' => '64'
379 379
 			),
380 380
 			array(
381
-				'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ),
382
-				'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ),
381
+				'name' => esc_html__('Minimum Unique Donations Required', 'give'),
382
+				'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'),
383 383
 				'type' => 'text_small',
384 384
 				'id'   => 'give_donors_gravatars_min_purchases_required',
385 385
 			),
386 386
 			array(
387
-				'name'    => esc_html__( 'Maximum Gravatars To Show', 'give' ),
388
-				'desc'    => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
387
+				'name'    => esc_html__('Maximum Gravatars To Show', 'give'),
388
+				'desc'    => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
389 389
 				'type'    => 'text',
390 390
 				'id'      => 'give_donors_gravatars_maximum_number',
391 391
 				'default' => '20',
392 392
 			),
393 393
 			array(
394
-				'name' => esc_html__( 'Gravatar Visibility', 'give' ),
395
-				'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ),
394
+				'name' => esc_html__('Gravatar Visibility', 'give'),
395
+				'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'),
396 396
 				'id'   => 'give_donors_gravatars_has_gravatar_account',
397 397
 				'type' => 'checkbox',
398 398
 			),
399 399
 			array(
400
-				'name' => esc_html__( 'Randomize Gravatars', 'give' ),
401
-				'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ),
400
+				'name' => esc_html__('Randomize Gravatars', 'give'),
401
+				'desc' => esc_html__('Randomize the Gravatars.', 'give'),
402 402
 				'id'   => 'give_donors_gravatars_random_gravatars',
403 403
 				'type' => 'checkbox',
404 404
 			),
405 405
 		);
406 406
 
407
-		return array_merge( $settings, $give_gravatar_settings );
407
+		return array_merge($settings, $give_gravatar_settings);
408 408
 	}
409 409
 
410 410
 }
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 		// widget settings
431 431
 		$widget_ops = array(
432 432
 			'classname'   => 'give-donors-gravatars',
433
-			'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ),
433
+			'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'),
434 434
 		);
435 435
 
436 436
 		// widget control settings
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 		// create the widget
444 444
 		parent::__construct(
445 445
 			'give_donors_gravatars_widget',
446
-			esc_html__( 'Give Donors Gravatars', 'give' ),
446
+			esc_html__('Give Donors Gravatars', 'give'),
447 447
 			$widget_ops,
448 448
 			$control_ops
449 449
 		);
@@ -463,29 +463,29 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return void
465 465
 	 */
466
-	public function widget( $args, $instance ) {
466
+	public function widget($args, $instance) {
467 467
 
468 468
 		//@TODO: Don't extract it!!!
469
-		extract( $args );
469
+		extract($args);
470 470
 
471
-		if ( ! is_singular( 'give_forms' ) ) {
471
+		if ( ! is_singular('give_forms')) {
472 472
 			return;
473 473
 		}
474 474
 
475 475
 		// Variables from widget settings
476
-		$title = apply_filters( 'widget_title', $instance['title'] );
476
+		$title = apply_filters('widget_title', $instance['title']);
477 477
 
478 478
 		// Used by themes. Opens the widget
479 479
 		echo $before_widget;
480 480
 
481 481
 		// Display the widget title
482
-		if ( $title ) {
483
-			echo $before_title . $title . $after_title;
482
+		if ($title) {
483
+			echo $before_title.$title.$after_title;
484 484
 		}
485 485
 
486 486
 		$gravatars = new Give_Donors_Gravatars();
487 487
 
488
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
488
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
489 489
 
490 490
 		// Used by themes. Closes the widget
491 491
 		echo $after_widget;
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
 	 *
506 506
 	 * @return array Updated settings to save.
507 507
 	 */
508
-	public function update( $new_instance, $old_instance ) {
508
+	public function update($new_instance, $old_instance) {
509 509
 
510 510
 		$instance = $old_instance;
511 511
 
512
-		$instance['title'] = strip_tags( $new_instance['title'] );
512
+		$instance['title'] = strip_tags($new_instance['title']);
513 513
 
514 514
 		return $instance;
515 515
 
@@ -527,19 +527,19 @@  discard block
 block discarded – undo
527 527
 	 *
528 528
 	 * @return void
529 529
 	 */
530
-	public function form( $instance ) {
530
+	public function form($instance) {
531 531
 
532 532
 		// Set up some default widget settings.
533 533
 		$defaults = array(
534 534
 			'title' => '',
535 535
 		);
536 536
 
537
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
537
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
538 538
 
539 539
 		<!-- Title -->
540 540
 		<p>
541
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label>
542
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
541
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label>
542
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
543 543
 		</p>
544 544
 
545 545
 		<?php
Please login to merge, or discard this patch.
includes/admin/reporting/reports.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 // Exit if accessed directly
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
@@ -29,32 +29,32 @@  discard block
 block discarded – undo
29 29
  * @return void
30 30
  */
31 31
 function give_reports_page() {
32
-	$current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' );
33
-	$active_tab   = isset( $_GET['tab'] ) ? $_GET['tab'] : 'reports';
32
+	$current_page = admin_url('edit.php?post_type=give_forms&page=give-reports');
33
+	$active_tab   = isset($_GET['tab']) ? $_GET['tab'] : 'reports';
34 34
 	?>
35 35
 	<div class="wrap">
36 36
 
37 37
 		<h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1>
38 38
 
39 39
 		<h2 class="nav-tab-wrapper">
40
-			<a href="<?php echo esc_url( add_query_arg( array(
40
+			<a href="<?php echo esc_url(add_query_arg(array(
41 41
 				'tab'              => 'reports',
42 42
 				'settings-updated' => false
43
-			), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Reports', 'give' ); ?></a>
44
-			<?php if ( current_user_can( 'export_give_reports' ) ) { ?>
45
-				<a href="<?php echo esc_url( add_query_arg( array(
43
+			), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Reports', 'give'); ?></a>
44
+			<?php if (current_user_can('export_give_reports')) { ?>
45
+				<a href="<?php echo esc_url(add_query_arg(array(
46 46
 					'tab'              => 'export',
47 47
 					'settings-updated' => false
48
-				), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a>
48
+				), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a>
49 49
 			<?php } ?>
50
-			<a href="<?php echo esc_url( add_query_arg( array(
50
+			<a href="<?php echo esc_url(add_query_arg(array(
51 51
 				'tab'              => 'logs',
52 52
 				'settings-updated' => false
53
-			), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Logs', 'give' ); ?></a>
54
-			<a href="<?php echo esc_url( add_query_arg( array(
53
+			), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Logs', 'give'); ?></a>
54
+			<a href="<?php echo esc_url(add_query_arg(array(
55 55
 				'tab'              => 'tools',
56 56
 				'settings-updated' => false
57
-			), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Tools', 'give' ); ?></a>
57
+			), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Tools', 'give'); ?></a>
58 58
 			<?php
59 59
 			/**
60 60
 			 * Fires in the report tabs.
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			 *
64 64
 			 * @since 1.0
65 65
 			 */
66
-			do_action( 'give_reports_tabs' );
66
+			do_action('give_reports_tabs');
67 67
 			?>
68 68
 		</h2>
69 69
 
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 		 *
74 74
 		 * @since 1.0
75 75
 		 */
76
-		do_action( 'give_reports_page_top' );
76
+		do_action('give_reports_page_top');
77 77
 
78 78
 		/**
79 79
 		 * Fires the report page active tab.
80 80
 		 *
81 81
 		 * @since 1.0
82 82
 		 */
83
-		do_action( "give_reports_tab_{$active_tab}" );
83
+		do_action("give_reports_tab_{$active_tab}");
84 84
 
85 85
 		/**
86 86
 		 * Fires after the report page.
87 87
 		 *
88 88
 		 * @since 1.0
89 89
 		 */
90
-		do_action( 'give_reports_page_bottom' );
90
+		do_action('give_reports_page_bottom');
91 91
 		?>
92 92
 	</div><!-- .wrap -->
93 93
 	<?php
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
  */
102 102
 function give_reports_default_views() {
103 103
 	$views = array(
104
-		'earnings' => esc_html__( 'Income', 'give' ),
105
-		'forms'    => esc_html__( 'Forms', 'give' ),
106
-		'donors'   => esc_html__( 'Donors', 'give' ),
107
-		'gateways' => esc_html__( 'Payment Methods', 'give' )
104
+		'earnings' => esc_html__('Income', 'give'),
105
+		'forms'    => esc_html__('Forms', 'give'),
106
+		'donors'   => esc_html__('Donors', 'give'),
107
+		'gateways' => esc_html__('Payment Methods', 'give')
108 108
 	);
109 109
 
110
-	$views = apply_filters( 'give_report_views', $views );
110
+	$views = apply_filters('give_report_views', $views);
111 111
 
112 112
 	return $views;
113 113
 }
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
  * @return string $view Report View
124 124
  *
125 125
  */
126
-function give_get_reporting_view( $default = 'earnings' ) {
126
+function give_get_reporting_view($default = 'earnings') {
127 127
 
128
-	if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) {
128
+	if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) {
129 129
 		$view = $default;
130 130
 	} else {
131 131
 		$view = $_GET['view'];
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_get_reporting_view', $view );
134
+	return apply_filters('give_get_reporting_view', $view);
135 135
 }
136 136
 
137 137
 /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	$current_view = 'earnings';
145 145
 	$views        = give_reports_default_views();
146 146
 
147
-	if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) ) {
147
+	if (isset($_GET['view']) && array_key_exists($_GET['view'], $views)) {
148 148
 		$current_view = $_GET['view'];
149 149
 	}
150 150
 
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 *
154 154
 	 * @since 1.0
155 155
 	 */
156
-	do_action( "give_reports_view_{$current_view}" );
156
+	do_action("give_reports_view_{$current_view}");
157 157
 }
158 158
 
159
-add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' );
159
+add_action('give_reports_tab_reports', 'give_reports_tab_reports');
160 160
 
161 161
 /**
162 162
  * Renders the Reports Page Views Drop Downs
@@ -166,19 +166,19 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function give_report_views() {
168 168
 	$views        = give_reports_default_views();
169
-	$current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings';
169
+	$current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings';
170 170
 	/**
171 171
 	 * Fires before the report page actions form.
172 172
 	 *
173 173
 	 * @since 1.0
174 174
 	 */
175
-	do_action( 'give_report_view_actions_before' );
175
+	do_action('give_report_view_actions_before');
176 176
 	?>
177 177
 	<form id="give-reports-filter" method="get">
178 178
 		<select id="give-reports-view" name="view">
179
-			<option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option>
180
-			<?php foreach ( $views as $view_id => $label ) : ?>
181
-				<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>
179
+			<option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option>
180
+			<?php foreach ($views as $view_id => $label) : ?>
181
+				<option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>
182 182
 			<?php endforeach; ?>
183 183
 		</select>
184 184
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 		 *
191 191
 		 * @since 1.0
192 192
 		 */
193
-		do_action( 'give_report_view_actions' );
193
+		do_action('give_report_view_actions');
194 194
 		?>
195 195
 
196 196
 		<input type="hidden" name="post_type" value="give_forms"/>
197 197
 		<input type="hidden" name="page" value="give-reports"/>
198
-		<?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?>
198
+		<?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?>
199 199
 	</form>
200 200
 	<?php
201 201
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @since 1.0
205 205
 	 */
206
-	do_action( 'give_report_view_actions_after' );
206
+	do_action('give_report_view_actions_after');
207 207
 }
208 208
 
209 209
 /**
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
  */
217 217
 function give_reports_forms_table() {
218 218
 
219
-	if ( isset( $_GET['form-id'] ) ) {
219
+	if (isset($_GET['form-id'])) {
220 220
 		return;
221 221
 	}
222 222
 
223
-	include( dirname( __FILE__ ) . '/class-form-reports-table.php' );
223
+	include(dirname(__FILE__).'/class-form-reports-table.php');
224 224
 
225 225
 	$give_table = new Give_Form_Reports_Table();
226 226
 	$give_table->prepare_items();
227 227
 	$give_table->display();
228 228
 }
229 229
 
230
-add_action( 'give_reports_view_forms', 'give_reports_forms_table' );
230
+add_action('give_reports_view_forms', 'give_reports_forms_table');
231 231
 
232 232
 /**
233 233
  * Renders the detailed report for a specific give form
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
  * @return void
237 237
  */
238 238
 function give_reports_form_details() {
239
-	if ( ! isset( $_GET['form-id'] ) ) {
239
+	if ( ! isset($_GET['form-id'])) {
240 240
 		return;
241 241
 	}
242 242
 	?>
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 		<div class="actions bulkactions">
245 245
 			<?php give_report_views(); ?>
246 246
 			&nbsp;
247
-			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button>
247
+			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button>
248 248
 		</div>
249 249
 	</div>
250 250
 	<?php
251
-	give_reports_graph_of_form( absint( $_GET['form-id'] ) );
251
+	give_reports_graph_of_form(absint($_GET['form-id']));
252 252
 }
253 253
 
254
-add_action( 'give_reports_view_forms', 'give_reports_form_details' );
254
+add_action('give_reports_view_forms', 'give_reports_form_details');
255 255
 
256 256
 /**
257 257
  * Renders the Reports Donors Table
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
  * @return void
263 263
  */
264 264
 function give_reports_donors_table() {
265
-	include( dirname( __FILE__ ) . '/class-donor-reports-table.php' );
265
+	include(dirname(__FILE__).'/class-donor-reports-table.php');
266 266
 
267 267
 	$give_table = new Give_Donor_Reports_Table();
268 268
 	$give_table->prepare_items();
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 		 *
275 275
 		 * @since 1.0
276 276
 		 */
277
-		do_action( 'give_logs_donors_table_top' );
277
+		do_action('give_logs_donors_table_top');
278 278
 		?>
279
-		<form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=donors' ); ?>">
279
+		<form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&view=donors'); ?>">
280 280
 			<?php
281
-			$give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' );
281
+			$give_table->search_box(esc_html__('Search', 'give'), 'give-donors');
282 282
 			$give_table->display();
283 283
 			?>
284 284
 			<input type="hidden" name="post_type" value="give_forms"/>
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
 		 *
292 292
 		 * @since 1.0
293 293
 		 */
294
-		do_action( 'give_logs_donors_table_bottom' );
294
+		do_action('give_logs_donors_table_bottom');
295 295
 		?>
296 296
 	</div>
297 297
 	<?php
298 298
 }
299 299
 
300
-add_action( 'give_reports_view_donors', 'give_reports_donors_table' );
300
+add_action('give_reports_view_donors', 'give_reports_donors_table');
301 301
 
302 302
 
303 303
 /**
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
  * @return void
310 310
  */
311 311
 function give_reports_gateways_table() {
312
-	include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' );
312
+	include(dirname(__FILE__).'/class-gateways-reports-table.php');
313 313
 
314 314
 	$give_table = new Give_Gateawy_Reports_Table();
315 315
 	$give_table->prepare_items();
316 316
 	$give_table->display();
317 317
 }
318 318
 
319
-add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );
319
+add_action('give_reports_view_gateways', 'give_reports_gateways_table');
320 320
 
321 321
 
322 322
 /**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 function give_reports_earnings() {
329 329
 	?>
330 330
 	<div class="tablenav top reports-table-nav">
331
-		<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Over Time', 'give' ); ?></span></h3>
331
+		<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Over Time', 'give'); ?></span></h3>
332 332
 
333 333
 		<div class="alignright actions reports-views-wrap"><?php give_report_views(); ?></div>
334 334
 	</div>
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	give_reports_graph();
337 337
 }
338 338
 
339
-add_action( 'give_reports_view_earnings', 'give_reports_earnings' );
339
+add_action('give_reports_view_earnings', 'give_reports_earnings');
340 340
 
341 341
 
342 342
 /**
@@ -357,14 +357,14 @@  discard block
 block discarded – undo
357 357
 				 *
358 358
 				 * @since 1.0
359 359
 				 */
360
-				do_action( 'give_reports_tab_export_content_top' );
360
+				do_action('give_reports_tab_export_content_top');
361 361
 				?>
362 362
 
363 363
 				<table class="widefat export-options-table give-table">
364 364
 					<thead>
365 365
 					<tr>
366
-						<th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th>
367
-						<th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th>
366
+						<th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th>
367
+						<th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th>
368 368
 					</tr>
369 369
 					</thead>
370 370
 					<tbody>
@@ -376,41 +376,41 @@  discard block
 block discarded – undo
376 376
 					 *
377 377
 					 * @since 1.0
378 378
 					 */
379
-					do_action( 'give_reports_tab_export_table_top' );
379
+					do_action('give_reports_tab_export_table_top');
380 380
 					?>
381 381
 					<tr class="give-export-pdf-sales-earnings">
382 382
 						<td scope="row" class="row-title">
383
-							<h3><span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span></h3>
384
-							<p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p>
383
+							<h3><span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span></h3>
384
+							<p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p>
385 385
 						</td>
386 386
 						<td>
387
-							<a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"><?php esc_html_e( 'Generate PDF', 'give' ); ?></a>
387
+							<a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"><?php esc_html_e('Generate PDF', 'give'); ?></a>
388 388
 						</td>
389 389
 					</tr>
390 390
 					<tr class="alternate give-export-sales-earnings">
391 391
 						<td scope="row" class="row-title">
392
-							<h3><span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span></h3>
393
-							<p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p>
392
+							<h3><span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span></h3>
393
+							<p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p>
394 394
 						</td>
395 395
 						<td>
396 396
 							<form method="post">
397 397
 								<?php
398 398
 									printf(
399 399
 										/* translators: 1: start date dropdown 2: end date dropdown */
400
-										esc_html__( '%1$s to %2$s', 'give' ),
401
-										Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ),
402
-										Give()->html->year_dropdown( 'end_year' )   . ' ' . Give()->html->month_dropdown( 'end_month' )
400
+										esc_html__('%1$s to %2$s', 'give'),
401
+										Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'),
402
+										Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month')
403 403
 									);
404 404
 								?>
405 405
 								<input type="hidden" name="give-action" value="earnings_export"/>
406
-								<input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/>
406
+								<input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/>
407 407
 							</form>
408 408
 						</td>
409 409
 					</tr>
410 410
 					<tr class="give-export-payment-history">
411 411
 						<td scope="row" class="row-title">
412
-							<h3><span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span></h3>
413
-							<p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p>
412
+							<h3><span><?php esc_html_e('Export Donation History', 'give'); ?></span></h3>
413
+							<p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p>
414 414
 						</td>
415 415
 						<td>
416 416
 							<form id="give-export-payments" class="give-export-form" method="post">
@@ -418,29 +418,29 @@  discard block
 block discarded – undo
418 418
 								$args = array(
419 419
 									'id'          => 'give-payment-export-start',
420 420
 									'name'        => 'start',
421
-									'placeholder' => esc_attr__( 'Start date', 'give' )
421
+									'placeholder' => esc_attr__('Start date', 'give')
422 422
 								);
423
-								echo Give()->html->date_field( $args ); ?>
423
+								echo Give()->html->date_field($args); ?>
424 424
 								<?php
425 425
 								$args = array(
426 426
 									'id'          => 'give-payment-export-end',
427 427
 									'name'        => 'end',
428
-									'placeholder' => esc_attr__( 'End date', 'give' )
428
+									'placeholder' => esc_attr__('End date', 'give')
429 429
 								);
430
-								echo Give()->html->date_field( $args ); ?>
430
+								echo Give()->html->date_field($args); ?>
431 431
 								<select name="status">
432
-									<option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option>
432
+									<option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option>
433 433
 									<?php
434 434
 									$statuses = give_get_payment_statuses();
435
-									foreach ( $statuses as $status => $label ) {
436
-										echo '<option value="' . $status . '">' . $label . '</option>';
435
+									foreach ($statuses as $status => $label) {
436
+										echo '<option value="'.$status.'">'.$label.'</option>';
437 437
 									}
438 438
 									?>
439 439
 								</select>
440
-								<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
440
+								<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
441 441
 								<input type="hidden" name="give-export-class" value="Give_Batch_Payments_Export"/>
442 442
 								<span>
443
-									<input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/>
443
+									<input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/>
444 444
 									<span class="spinner"></span>
445 445
 								</span>
446 446
 							</form>
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
 					</tr>
449 449
 					<tr class="alternate give-export-donors">
450 450
 						<td scope="row" class="row-title">
451
-							<h3><span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span></h3>
452
-							<p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p>
451
+							<h3><span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span></h3>
452
+							<p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p>
453 453
 						</td>
454 454
 						<td>
455 455
 							<form method="post" id="give_donor_export" class="give-export-form">
@@ -460,44 +460,44 @@  discard block
 block discarded – undo
460 460
 										'id'     => 'give_customer_export_form',
461 461
 										'chosen' => true
462 462
 									);
463
-									echo Give()->html->forms_dropdown( $args ); ?>
463
+									echo Give()->html->forms_dropdown($args); ?>
464 464
 								
465
-								<input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/>
465
+								<input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/>
466 466
 
467 467
 								<div id="export-donor-options-wrap" class="give-clearfix">
468
-									<p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p>
468
+									<p><?php esc_html_e('Export Columns:', 'give'); ?></p>
469 469
 									<ul id="give-export-option-ul">
470 470
 										<li>
471
-											<label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?>
471
+											<label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?>
472 472
 											</label>
473 473
 										</li>
474 474
 										<li>
475
-											<label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?>
475
+											<label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e('Email', 'give'); ?>
476 476
 											</label>
477 477
 										</li>
478 478
 										<li>
479
-											<label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?>
479
+											<label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e('Address', 'give'); ?>
480 480
 											</label>
481 481
 										</li>
482 482
 										<li>
483
-											<label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?>
483
+											<label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?>
484 484
 											</label>
485 485
 										</li>
486 486
 										<li>
487
-											<label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?>
487
+											<label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?>
488 488
 											</label>
489 489
 										</li>
490 490
 										<li>
491
-											<label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?>
491
+											<label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?>
492 492
 											</label>
493 493
 										</li>
494 494
 										<li>
495
-											<label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?>
495
+											<label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?>
496 496
 											</label>
497 497
 										</li>
498 498
 									</ul>
499 499
 								</div>
500
-								<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
500
+								<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
501 501
 								<input type="hidden" name="give-export-class" value="Give_Batch_Customers_Export"/>
502 502
 								<input type="hidden" name="give-action" value="email_export"/>
503 503
 							</form>
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 					 *
512 512
 					 * @since 1.0
513 513
 					 */
514
-					do_action( 'give_reports_tab_export_table_bottom' );
514
+					do_action('give_reports_tab_export_table_bottom');
515 515
 					?>
516 516
 					</tbody>
517 517
 				</table>
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 				 *
523 523
 				 * @since 1.0
524 524
 				 */
525
-				do_action( 'give_reports_tab_export_content_bottom' );
525
+				do_action('give_reports_tab_export_content_bottom');
526 526
 				?>
527 527
 
528 528
 			</div>
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	<?php
534 534
 }
535 535
 
536
-add_action( 'give_reports_tab_export', 'give_reports_tab_export' );
536
+add_action('give_reports_tab_export', 'give_reports_tab_export');
537 537
 
538 538
 /**
539 539
  * Renders the Reports page
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
  */
544 544
 function give_reports_tab_logs() {
545 545
 
546
-	require( GIVE_PLUGIN_DIR . 'includes/admin/reporting/logs.php' );
546
+	require(GIVE_PLUGIN_DIR.'includes/admin/reporting/logs.php');
547 547
 
548 548
 	$current_view = 'sales';
549 549
 	$log_views    = give_log_default_views();
550 550
 
551
-	if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $log_views ) ) {
551
+	if (isset($_GET['view']) && array_key_exists($_GET['view'], $log_views)) {
552 552
 		$current_view = $_GET['view'];
553 553
 	}
554 554
 
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
 	 *
558 558
 	 * @since 1.0
559 559
 	 */
560
-	do_action( "give_logs_view_{$current_view}" );
560
+	do_action("give_logs_view_{$current_view}");
561 561
 }
562 562
 
563
-add_action( 'give_reports_tab_logs', 'give_reports_tab_logs' );
563
+add_action('give_reports_tab_logs', 'give_reports_tab_logs');
564 564
 
565 565
 /**
566 566
  * Retrieves estimated monthly earnings and sales
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
  */
571 571
 function give_estimated_monthly_stats() {
572 572
 
573
-	$estimated = get_transient( 'give_estimated_monthly_stats' );
573
+	$estimated = get_transient('give_estimated_monthly_stats');
574 574
 
575
-	if ( false === $estimated ) {
575
+	if (false === $estimated) {
576 576
 
577 577
 		$estimated = array(
578 578
 			'earnings' => 0,
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
 
582 582
 		$stats = new Give_Payment_Stats;
583 583
 
584
-		$to_date_earnings = $stats->get_earnings( 0, 'this_month' );
585
-		$to_date_sales    = $stats->get_sales( 0, 'this_month' );
584
+		$to_date_earnings = $stats->get_earnings(0, 'this_month');
585
+		$to_date_sales    = $stats->get_sales(0, 'this_month');
586 586
 
587
-		$current_day   = date( 'd', current_time( 'timestamp' ) );
588
-		$current_month = date( 'n', current_time( 'timestamp' ) );
589
-		$current_year  = date( 'Y', current_time( 'timestamp' ) );
590
-		$days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year );
587
+		$current_day   = date('d', current_time('timestamp'));
588
+		$current_month = date('n', current_time('timestamp'));
589
+		$current_year  = date('Y', current_time('timestamp'));
590
+		$days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year);
591 591
 
592
-		$estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month;
593
-		$estimated['sales']    = ( $to_date_sales / $current_day ) * $days_in_month;
592
+		$estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month;
593
+		$estimated['sales']    = ($to_date_sales / $current_day) * $days_in_month;
594 594
 
595 595
 		// Cache for one day
596
-		set_transient( 'give_estimated_monthly_stats', $estimated, 86400 );
596
+		set_transient('give_estimated_monthly_stats', $estimated, 86400);
597 597
 	}
598 598
 
599
-	return maybe_unserialize( $estimated );
599
+	return maybe_unserialize($estimated);
600 600
 }
Please login to merge, or discard this patch.
includes/admin/reporting/class-form-reports-table.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
55
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
53
+		parent::__construct(array(
54
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
55
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
56 56
 			'ajax'     => false                        // Does this table support ajax?
57
-		) );
57
+		));
58 58
 
59
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
59
+		add_action('give_report_view_actions', array($this, 'category_filter'));
60 60
 		$this->query();
61 61
 
62 62
 	}
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		switch ( $column_name ) {
75
+	public function column_default($item, $column_name) {
76
+		switch ($column_name) {
77 77
 			case 'earnings' :
78
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
78
+				return give_currency_filter(give_format_amount($item[$column_name]));
79 79
 			case 'average_sales' :
80
-				return round( $item[ $column_name ] );
80
+				return round($item[$column_name]);
81 81
 			case 'average_earnings' :
82
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
82
+				return give_currency_filter(give_format_amount($item[$column_name]));
83 83
 			case 'details' :
84
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>';
84
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>';
85 85
 			default:
86
-				return $item[ $column_name ];
86
+				return $item[$column_name];
87 87
 		}
88 88
 	}
89 89
 
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function get_columns() {
98 98
 		$columns = array(
99
-			'title'            => esc_html__( 'Form', 'give' ),
100
-			'sales'            => esc_html__( 'Donations', 'give' ),
101
-			'earnings'         => esc_html__( 'Income', 'give' ),
102
-			'average_sales'    => esc_html__( 'Monthly Average Donations', 'give' ),
103
-			'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ),
104
-			'details'          => esc_html__( 'Detailed Report', 'give' )
99
+			'title'            => esc_html__('Form', 'give'),
100
+			'sales'            => esc_html__('Donations', 'give'),
101
+			'earnings'         => esc_html__('Income', 'give'),
102
+			'average_sales'    => esc_html__('Monthly Average Donations', 'give'),
103
+			'average_earnings' => esc_html__('Monthly Average Income', 'give'),
104
+			'details'          => esc_html__('Detailed Report', 'give')
105 105
 		);
106 106
 
107 107
 		return $columns;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function get_sortable_columns() {
118 118
 		return array(
119
-			'title'    => array( 'title', true ),
120
-			'sales'    => array( 'sales', false ),
121
-			'earnings' => array( 'earnings', false ),
119
+			'title'    => array('title', true),
120
+			'sales'    => array('sales', false),
121
+			'earnings' => array('earnings', false),
122 122
 		);
123 123
 	}
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return int Current page number
131 131
 	 */
132 132
 	public function get_paged() {
133
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
133
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
134 134
 	}
135 135
 
136 136
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return int Category ID
143 143
 	 */
144 144
 	public function get_category() {
145
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
145
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
146 146
 	}
147 147
 
148 148
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function get_total_forms() {
157 157
 		$total  = 0;
158
-		$counts = wp_count_posts( 'give_forms', 'readable' );
159
-		foreach ( $counts as $status => $count ) {
158
+		$counts = wp_count_posts('give_forms', 'readable');
159
+		foreach ($counts as $status => $count) {
160 160
 			$total += $count;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @since  1.0
171 171
 	 * @return void
172 172
 	 */
173
-	public function bulk_actions( $which = '' ) {
173
+	public function bulk_actions($which = '') {
174 174
 		// These aren't really bulk actions but this outputs the markup in the right place
175 175
 		give_report_views();
176 176
 	}
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param string $which
185 185
 	 */
186
-	protected function display_tablenav( $which ) {
186
+	protected function display_tablenav($which) {
187 187
 
188
-		if ( 'top' == $which ) {
189
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
188
+		if ('top' == $which) {
189
+			wp_nonce_field('bulk-'.$this->_args['plural']);
190 190
 		}
191 191
 		?>
192
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
192
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
193 193
 
194
-			<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Donation Forms Report', 'give' ); ?></span></h3>
194
+			<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Donation Forms Report', 'give'); ?></span></h3>
195 195
 
196 196
 			<div class="alignright tablenav-right">
197 197
 				<div class="actions bulkactions">
198
-					<?php $this->bulk_actions( $which ); ?>
198
+					<?php $this->bulk_actions($which); ?>
199 199
 				</div>
200 200
 				<?php
201
-				$this->extra_tablenav( $which );
202
-				$this->pagination( $which );
201
+				$this->extra_tablenav($which);
202
+				$this->pagination($which);
203 203
 				?>
204 204
 			</div>
205 205
 
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function category_filter() {
221 221
 
222
-		$categories = get_terms( 'form_category' );
223
-		if ( $categories && ! is_wp_error( $categories ) ) {
224
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
222
+		$categories = get_terms('form_category');
223
+		if ($categories && ! is_wp_error($categories)) {
224
+			echo Give()->html->category_dropdown('category', $this->get_category());
225 225
 		}
226 226
 	}
227 227
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function query() {
237 237
 
238
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
239
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
238
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
239
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
240 240
 		$category = $this->get_category();
241 241
 
242 242
 		$args = array(
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			'suppress_filters' => true
250 250
 		);
251 251
 
252
-		if ( ! empty( $category ) ) {
252
+		if ( ! empty($category)) {
253 253
 			$args['tax_query'] = array(
254 254
 				array(
255 255
 					'taxonomy' => 'form_category',
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			);
259 259
 		}
260 260
 
261
-		switch ( $orderby ) :
261
+		switch ($orderby) :
262 262
 			case 'title' :
263 263
 				$args['orderby'] = 'title';
264 264
 				break;
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 				break;
275 275
 		endswitch;
276 276
 
277
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
277
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
278 278
 
279
-		$this->products = new WP_Query( $args );
279
+		$this->products = new WP_Query($args);
280 280
 
281 281
 	}
282 282
 
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$give_forms = $this->products->posts;
294 294
 
295
-		if ( $give_forms ) {
296
-			foreach ( $give_forms as $form ) {
295
+		if ($give_forms) {
296
+			foreach ($give_forms as $form) {
297 297
 				$reports_data[] = array(
298 298
 					'ID'               => $form,
299
-					'title'            => get_the_title( $form ),
300
-					'sales'            => give_get_form_sales_stats( $form ),
301
-					'earnings'         => give_get_form_earnings_stats( $form ),
302
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
303
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
299
+					'title'            => get_the_title($form),
300
+					'sales'            => give_get_form_sales_stats($form),
301
+					'earnings'         => give_get_form_earnings_stats($form),
302
+					'average_sales'    => give_get_average_monthly_form_sales($form),
303
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
304 304
 				);
305 305
 			}
306 306
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$sortable = $this->get_sortable_columns();
330 330
 
331
-		$this->_column_headers = array( $columns, $hidden, $sortable );
331
+		$this->_column_headers = array($columns, $hidden, $sortable);
332 332
 
333 333
 		$data = $this->reports_data();
334 334
 
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$this->items = $data;
338 338
 
339
-		$this->set_pagination_args( array(
339
+		$this->set_pagination_args(array(
340 340
 				'total_items' => $total_items,
341 341
 				'per_page'    => $this->per_page,
342
-				'total_pages' => ceil( $total_items / $this->per_page )
342
+				'total_pages' => ceil($total_items / $this->per_page)
343 343
 			)
344 344
 		);
345 345
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/pdf-reports.php 1 patch
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,82 +25,82 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @uses   give_pdf
27 27
  */
28
-function give_generate_pdf( $data ) {
28
+function give_generate_pdf($data) {
29 29
 
30
-	if ( ! current_user_can( 'view_give_reports' ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('view_give_reports')) {
31
+		wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) {
35
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
34
+	if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
35
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
36 36
 	}
37 37
 
38
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
39
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php';
38
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php';
39
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php';
40 40
 
41 41
 	$daterange = utf8_decode(
42 42
 		sprintf(
43 43
 		/* translators: 1: start date 2: end date */
44
-			esc_html__( '%1$s to %2$s', 'give' ),
45
-			date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ),
46
-			date_i18n( give_date_format() )
44
+			esc_html__('%1$s to %2$s', 'give'),
45
+			date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))),
46
+			date_i18n(give_date_format())
47 47
 		)
48 48
 	);
49 49
 
50 50
 	$pdf = new give_pdf();
51
-	$pdf->AddPage( 'L', 'A4' );
51
+	$pdf->AddPage('L', 'A4');
52 52
 
53
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
54
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
55
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
53
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
54
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
55
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
56 56
 
57
-	$pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 );
57
+	$pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8);
58 58
 
59
-	$pdf->SetMargins( 8, 8, 8 );
60
-	$pdf->SetX( 8 );
59
+	$pdf->SetMargins(8, 8, 8);
60
+	$pdf->SetX(8);
61 61
 
62
-	$pdf->SetFont( 'Helvetica', '', 16 );
63
-	$pdf->SetTextColor( 50, 50, 50 );
64
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
62
+	$pdf->SetFont('Helvetica', '', 16);
63
+	$pdf->SetTextColor(50, 50, 50);
64
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
65 65
 
66
-	$pdf->SetFont( 'Helvetica', '', 13 );
66
+	$pdf->SetFont('Helvetica', '', 13);
67 67
 	$pdf->Ln();
68
-	$pdf->SetTextColor( 150, 150, 150 );
69
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
68
+	$pdf->SetTextColor(150, 150, 150);
69
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
70 70
 	$pdf->Ln();
71
-	$pdf->SetTextColor( 50, 50, 50 );
72
-	$pdf->SetFont( 'Helvetica', '', 14 );
73
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
74
-	$pdf->SetFont( 'Helvetica', '', 12 );
71
+	$pdf->SetTextColor(50, 50, 50);
72
+	$pdf->SetFont('Helvetica', '', 14);
73
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
74
+	$pdf->SetFont('Helvetica', '', 12);
75 75
 
76
-	$pdf->SetFillColor( 238, 238, 238 );
77
-	$pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
78
-	$pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
79
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
80
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
81
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
82
-	$pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
76
+	$pdf->SetFillColor(238, 238, 238);
77
+	$pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
78
+	$pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
79
+	$pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
80
+	$pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
81
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
82
+	$pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
83 83
 
84
-	$year       = date( 'Y' );
85
-	$give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) );
84
+	$year       = date('Y');
85
+	$give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
86 86
 
87
-	if ( $give_forms ) {
88
-		$pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) );
87
+	if ($give_forms) {
88
+		$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
89 89
 
90
-		foreach ( $give_forms as $form ):
91
-			$pdf->SetFillColor( 255, 255, 255 );
90
+		foreach ($give_forms as $form):
91
+			$pdf->SetFillColor(255, 255, 255);
92 92
 
93 93
 			$title = $form->post_title;
94 94
 
95
-			if ( give_has_variable_prices( $form->ID ) ) {
95
+			if (give_has_variable_prices($form->ID)) {
96 96
 
97
-				$prices = give_get_variable_prices( $form->ID );
97
+				$prices = give_get_variable_prices($form->ID);
98 98
 
99 99
 				$first = $prices[0]['_give_amount'];
100
-				$last  = array_pop( $prices );
100
+				$last  = array_pop($prices);
101 101
 				$last  = $last['_give_amount'];
102 102
 
103
-				if ( $first < $last ) {
103
+				if ($first < $last) {
104 104
 					$min = $first;
105 105
 					$max = $last;
106 106
 				} else {
@@ -108,51 +108,51 @@  discard block
 block discarded – undo
108 108
 					$max = $first;
109 109
 				}
110 110
 
111
-				$price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) );
111
+				$price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max)));
112 112
 			} else {
113
-				$price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) );
113
+				$price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
114 114
 			}
115 115
 
116
-			$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
117
-			$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
116
+			$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
117
+			$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
118 118
 
119
-			$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
120
-			$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
119
+			$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
120
+			$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
121 121
 
122
-			$sales    = give_get_form_sales_stats( $form->ID );
123
-			$link     = get_permalink( $form->ID );
124
-			$earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) );
122
+			$sales    = give_get_form_sales_stats($form->ID);
123
+			$link     = get_permalink($form->ID);
124
+			$earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
125 125
 
126
-			if ( function_exists( 'iconv' ) ) {
126
+			if (function_exists('iconv')) {
127 127
 				// Ensure characters like euro; are properly converted.
128
-				$price    = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) );
129
-				$earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) );
128
+				$price    = iconv('UTF-8', 'windows-1252', utf8_encode($price));
129
+				$earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
130 130
 			}
131 131
 
132
-			$pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) );
132
+			$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
133 133
 		endforeach;
134 134
 	} else {
135
-		$pdf->SetWidths( array( 280 ) );
136
-		$title = utf8_decode( esc_html__( 'No forms found.', 'give' ) );
137
-		$pdf->Row( array( $title ) );
135
+		$pdf->SetWidths(array(280));
136
+		$title = utf8_decode(esc_html__('No forms found.', 'give'));
137
+		$pdf->Row(array($title));
138 138
 	}
139 139
 
140 140
 	$pdf->Ln();
141
-	$pdf->SetTextColor( 50, 50, 50 );
142
-	$pdf->SetFont( 'Helvetica', '', 14 );
143
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
144
-	$pdf->SetFont( 'Helvetica', '', 12 );
145
-
146
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
147
-	$image = str_replace( ' ', '%20', $image );
148
-
149
-	$pdf->SetX( 25 );
150
-	$pdf->Image( $image . '&file=.png' );
151
-	$pdf->Ln( 7 );
152
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
141
+	$pdf->SetTextColor(50, 50, 50);
142
+	$pdf->SetFont('Helvetica', '', 14);
143
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
144
+	$pdf->SetFont('Helvetica', '', 12);
145
+
146
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
147
+	$image = str_replace(' ', '%20', $image);
148
+
149
+	$pdf->SetX(25);
150
+	$pdf->Image($image.'&file=.png');
151
+	$pdf->Ln(7);
152
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
153 153
 }
154 154
 
155
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
155
+add_action('give_generate_pdf', 'give_generate_pdf');
156 156
 
157 157
 /**
158 158
  * Draws Chart for PDF Report.
@@ -169,38 +169,38 @@  discard block
 block discarded – undo
169 169
  * @return string $chart->getUrl() URL for the Google Chart
170 170
  */
171 171
 function give_draw_chart_image() {
172
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
173
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
174
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
172
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
173
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
174
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
175 175
 
176
-	$chart = new GoogleChart( 'lc', 900, 330 );
176
+	$chart = new GoogleChart('lc', 900, 330);
177 177
 
178 178
 	$i        = 1;
179 179
 	$earnings = "";
180 180
 	$sales    = "";
181 181
 
182
-	while ( $i <= 12 ) :
183
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
184
-		$sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
185
-		$i ++;
182
+	while ($i <= 12) :
183
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
184
+		$sales .= give_get_sales_by_date(null, $i, date('Y')).",";
185
+		$i++;
186 186
 	endwhile;
187 187
 
188
-	$earnings_array = explode( ",", $earnings );
189
-	$sales_array    = explode( ",", $sales );
188
+	$earnings_array = explode(",", $earnings);
189
+	$sales_array    = explode(",", $sales);
190 190
 
191 191
 	$i = 0;
192
-	while ( $i <= 11 ) {
193
-		if ( empty( $sales_array[ $i ] ) ) {
194
-			$sales_array[ $i ] = 0;
192
+	while ($i <= 11) {
193
+		if (empty($sales_array[$i])) {
194
+			$sales_array[$i] = 0;
195 195
 		}
196
-		$i ++;
196
+		$i++;
197 197
 	}
198 198
 
199 199
 	$min_earnings   = 0;
200
-	$max_earnings   = max( $earnings_array );
201
-	$earnings_scale = round( $max_earnings, - 1 );
200
+	$max_earnings   = max($earnings_array);
201
+	$earnings_scale = round($max_earnings, - 1);
202 202
 
203
-	$data = new GoogleChartData( array(
203
+	$data = new GoogleChartData(array(
204 204
 		$earnings_array[0],
205 205
 		$earnings_array[1],
206 206
 		$earnings_array[2],
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		$earnings_array[9],
214 214
 		$earnings_array[10],
215 215
 		$earnings_array[11]
216
-	) );
216
+	));
217 217
 
218
-	$data->setLegend( esc_html__( 'Income', 'give' ) );
219
-	$data->setColor( '1b58a3' );
220
-	$chart->addData( $data );
218
+	$data->setLegend(esc_html__('Income', 'give'));
219
+	$data->setColor('1b58a3');
220
+	$chart->addData($data);
221 221
 
222
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
223
-	$shape_marker->setColor( '000000' );
224
-	$shape_marker->setSize( 7 );
225
-	$shape_marker->setBorder( 2 );
226
-	$shape_marker->setData( $data );
227
-	$chart->addMarker( $shape_marker );
222
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
223
+	$shape_marker->setColor('000000');
224
+	$shape_marker->setSize(7);
225
+	$shape_marker->setBorder(2);
226
+	$shape_marker->setData($data);
227
+	$chart->addMarker($shape_marker);
228 228
 
229
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
230
-	$value_marker->setColor( '000000' );
231
-	$value_marker->setData( $data );
232
-	$chart->addMarker( $value_marker );
229
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
230
+	$value_marker->setColor('000000');
231
+	$value_marker->setData($data);
232
+	$chart->addMarker($value_marker);
233 233
 
234
-	$data = new GoogleChartData( array(
234
+	$data = new GoogleChartData(array(
235 235
 		$sales_array[0],
236 236
 		$sales_array[1],
237 237
 		$sales_array[2],
@@ -244,46 +244,46 @@  discard block
 block discarded – undo
244 244
 		$sales_array[9],
245 245
 		$sales_array[10],
246 246
 		$sales_array[11]
247
-	) );
248
-	$data->setLegend( esc_html__( 'Donations', 'give' ) );
249
-	$data->setColor( 'ff6c1c' );
250
-	$chart->addData( $data );
251
-
252
-	$chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
253
-
254
-	$chart->setScale( 0, $max_earnings );
255
-
256
-	$y_axis = new GoogleChartAxis( 'y' );
257
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
258
-	$chart->addAxis( $y_axis );
259
-
260
-	$x_axis = new GoogleChartAxis( 'x' );
261
-	$x_axis->setTickMarks( 5 );
262
-	$x_axis->setLabels( array(
263
-		esc_html__( 'Jan', 'give' ),
264
-		esc_html__( 'Feb', 'give' ),
265
-		esc_html__( 'Mar', 'give' ),
266
-		esc_html__( 'Apr', 'give' ),
267
-		esc_html__( 'May', 'give' ),
268
-		esc_html__( 'June', 'give' ),
269
-		esc_html__( 'July', 'give' ),
270
-		esc_html__( 'Aug', 'give' ),
271
-		esc_html__( 'Sept', 'give' ),
272
-		esc_html__( 'Oct', 'give' ),
273
-		esc_html__( 'Nov', 'give' ),
274
-		esc_html__( 'Dec', 'give' )
275
-	) );
276
-	$chart->addAxis( $x_axis );
277
-
278
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
279
-	$shape_marker->setSize( 6 );
280
-	$shape_marker->setBorder( 2 );
281
-	$shape_marker->setData( $data );
282
-	$chart->addMarker( $shape_marker );
283
-
284
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
285
-	$value_marker->setData( $data );
286
-	$chart->addMarker( $value_marker );
247
+	));
248
+	$data->setLegend(esc_html__('Donations', 'give'));
249
+	$data->setColor('ff6c1c');
250
+	$chart->addData($data);
251
+
252
+	$chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18);
253
+
254
+	$chart->setScale(0, $max_earnings);
255
+
256
+	$y_axis = new GoogleChartAxis('y');
257
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
258
+	$chart->addAxis($y_axis);
259
+
260
+	$x_axis = new GoogleChartAxis('x');
261
+	$x_axis->setTickMarks(5);
262
+	$x_axis->setLabels(array(
263
+		esc_html__('Jan', 'give'),
264
+		esc_html__('Feb', 'give'),
265
+		esc_html__('Mar', 'give'),
266
+		esc_html__('Apr', 'give'),
267
+		esc_html__('May', 'give'),
268
+		esc_html__('June', 'give'),
269
+		esc_html__('July', 'give'),
270
+		esc_html__('Aug', 'give'),
271
+		esc_html__('Sept', 'give'),
272
+		esc_html__('Oct', 'give'),
273
+		esc_html__('Nov', 'give'),
274
+		esc_html__('Dec', 'give')
275
+	));
276
+	$chart->addAxis($x_axis);
277
+
278
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
279
+	$shape_marker->setSize(6);
280
+	$shape_marker->setBorder(2);
281
+	$shape_marker->setData($data);
282
+	$chart->addMarker($shape_marker);
283
+
284
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
285
+	$value_marker->setData($data);
286
+	$chart->addMarker($value_marker);
287 287
 
288 288
 	return $chart->getUrl();
289 289
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_tools_recount_stats_display() {
24 24
 
25
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
25
+	if ( ! current_user_can('manage_give_settings')) {
26 26
 		return;
27 27
 	}
28 28
 
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @since 1.5
33 33
 	 */
34
-	do_action( 'give_tools_recount_stats_before' );
34
+	do_action('give_tools_recount_stats_before');
35 35
 	?>
36 36
 	<div id="poststuff">
37 37
 		<div class="postbox">
38 38
 
39
-			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2>
39
+			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2>
40 40
 
41 41
 			<div class="inside recount-stats-controls">
42
-				<p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p>
42
+				<p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p>
43 43
 				<form method="post" id="give-tools-recount-form" class="give-export-form">
44 44
 
45
-					<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
45
+					<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
46 46
 
47 47
 					<select name="give-export-class" id="recount-stats-type">
48
-						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option>
49
-						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option>
50
-						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option>
51
-						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option>
52
-						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option>
53
-						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option>
54
-						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option>
48
+						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option>
49
+						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option>
50
+						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option>
51
+						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option>
52
+						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option>
53
+						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option>
54
+						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option>
55 55
 						<?php
56 56
 						/**
57 57
 						 * Fires in the recount stats selectbox.
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 						 *
61 61
 						 * @since 1.5
62 62
 						 */
63
-						do_action( 'give_recount_tool_options' );
63
+						do_action('give_recount_tool_options');
64 64
 						?>
65 65
 					</select>
66 66
 
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 						<?php
69 69
 						$args = array(
70 70
 							'name'   => 'form_id',
71
-							'number' => - 1,
71
+							'number' => -1,
72 72
 							'chosen' => true,
73 73
 						);
74
-						echo Give()->html->forms_dropdown( $args );
74
+						echo Give()->html->forms_dropdown($args);
75 75
 						?>
76 76
 					</span>
77 77
 
78
-					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/>
78
+					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/>
79 79
 
80 80
 					<br/>
81 81
 
82 82
 					<span class="give-recount-stats-descriptions">
83
-						<span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span>
84
-						<span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span>
85
-						<span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span>
86
-						<span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span>
83
+						<span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span>
84
+						<span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span>
85
+						<span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span>
86
+						<span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span>
87 87
 						<?php
88 88
 						/**
89 89
 						 * Fires in the recount stats description area.
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 						 *
93 93
 						 * @since 1.5
94 94
 						 */
95
-						do_action( 'give_recount_tool_descriptions' );
95
+						do_action('give_recount_tool_descriptions');
96 96
 						?>
97
-						<span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span>
98
-						<span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span>
97
+						<span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span>
98
+						<span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span>
99 99
 					</span>
100 100
 
101 101
 					<span class="spinner"></span>
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 				 *
110 110
 				 * @since 1.5
111 111
 				 */
112
-				do_action( 'give_tools_recount_forms' );
112
+				do_action('give_tools_recount_forms');
113 113
 				?>
114 114
 			</div><!-- .inside -->
115 115
 		</div><!-- .postbox -->
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 1.5
122 122
 	 */
123
-	do_action( 'give_tools_recount_stats_after' );
123
+	do_action('give_tools_recount_stats_after');
124 124
 }
125 125
 
126
-add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' );
126
+add_action('give_reports_tab_tools', 'give_tools_recount_stats_display');
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 * @param $_step int The step to process
107 107
 	 * @since 1.5
108 108
 	 */
109
-	public function __construct( $_step = 1 ) {
109
+	public function __construct($_step = 1) {
110 110
 
111 111
 		$upload_dir       = wp_upload_dir();
112 112
 		$this->filetype   = '.csv';
113
-		$this->filename   = 'give-' . $this->export_type . $this->filetype;
114
-		$this->file       = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
113
+		$this->filename   = 'give-'.$this->export_type.$this->filetype;
114
+		$this->file       = trailingslashit($upload_dir['basedir']).$this->filename;
115 115
 
116
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
116
+		if ( ! is_writeable($upload_dir['basedir'])) {
117 117
 			$this->is_writable = false;
118 118
 		}
119 119
 
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function process_step() {
131 131
 
132
-		if ( ! $this->can_export() ) {
133
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
132
+		if ( ! $this->can_export()) {
133
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
134 134
 		}
135 135
 
136
-		if( $this->step < 2 ) {
136
+		if ($this->step < 2) {
137 137
 
138 138
 			// Make sure we start with a fresh file on step 1
139
-			@unlink( $this->file );
139
+			@unlink($this->file);
140 140
 			$this->print_csv_cols();
141 141
 		}
142 142
 
143 143
 		$rows = $this->print_csv_rows();
144 144
 
145
-		if( $rows ) {
145
+		if ($rows) {
146 146
 			return true;
147 147
 		} else {
148 148
 			return false;
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 		$col_data = '';
163 163
 		$cols = $this->get_csv_cols();
164 164
 		$i = 1;
165
-		foreach( $cols as $col_id => $column ) {
166
-			$col_data .= '"' . addslashes( $column ) . '"';
167
-			$col_data .= $i == count( $cols ) ? '' : ',';
165
+		foreach ($cols as $col_id => $column) {
166
+			$col_data .= '"'.addslashes($column).'"';
167
+			$col_data .= $i == count($cols) ? '' : ',';
168 168
 			$i++;
169 169
 		}
170 170
 		$col_data .= "\r\n";
171 171
 
172
-		$this->stash_step_data( $col_data );
172
+		$this->stash_step_data($col_data);
173 173
 
174 174
 		return $col_data;
175 175
 
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 		$data     = $this->get_data();
189 189
 		$cols     = $this->get_csv_cols();
190 190
 
191
-		if( $data ) {
191
+		if ($data) {
192 192
 
193 193
 			// Output each row
194
-			foreach ( $data as $row ) {
194
+			foreach ($data as $row) {
195 195
 				$i = 1;
196
-				foreach ( $row as $col_id => $column ) {
196
+				foreach ($row as $col_id => $column) {
197 197
 					// Make sure the column is valid
198
-					if ( array_key_exists( $col_id, $cols ) ) {
199
-						$row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
200
-						$row_data .= $i == count( $cols ) ? '' : ',';
198
+					if (array_key_exists($col_id, $cols)) {
199
+						$row_data .= '"'.addslashes(preg_replace("/\"/", "'", $column)).'"';
200
+						$row_data .= $i == count($cols) ? '' : ',';
201 201
 						$i++;
202 202
 					}
203 203
 				}
204 204
 				$row_data .= "\r\n";
205 205
 			}
206 206
 
207
-			$this->stash_step_data( $row_data );
207
+			$this->stash_step_data($row_data);
208 208
 
209 209
 			return $row_data;
210 210
 		}
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 
233 233
 		$file = '';
234 234
 
235
-		if ( @file_exists( $this->file ) ) {
235
+		if (@file_exists($this->file)) {
236 236
 
237
-			if ( ! is_writeable( $this->file ) ) {
237
+			if ( ! is_writeable($this->file)) {
238 238
 				$this->is_writable = false;
239 239
 			}
240 240
 
241
-			$file = @file_get_contents( $this->file );
241
+			$file = @file_get_contents($this->file);
242 242
 
243 243
 		} else {
244 244
 
245
-			@file_put_contents( $this->file, '' );
246
-			@chmod( $this->file, 0664 );
245
+			@file_put_contents($this->file, '');
246
+			@chmod($this->file, 0664);
247 247
 
248 248
 		}
249 249
 
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 	 * @param $data string The data to add to the file
258 258
 	 * @return void
259 259
 	 */
260
-	protected function stash_step_data( $data = '' ) {
260
+	protected function stash_step_data($data = '') {
261 261
 
262 262
 		$file = $this->get_file();
263 263
 		$file .= $data;
264
-		@file_put_contents( $this->file, $file );
264
+		@file_put_contents($this->file, $file);
265 265
 
266 266
 		// If we have no rows after this step, mark it as an empty export
267
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES);
267
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
268 268
 		$default_cols = $this->get_csv_cols();
269
-		$default_cols = empty( $default_cols ) ? 0 : 1;
269
+		$default_cols = empty($default_cols) ? 0 : 1;
270 270
 
271
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
271
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
272 272
 
273 273
 	}
274 274
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 		$file = $this->get_file();
288 288
 
289
-		@unlink( $this->file );
289
+		@unlink($this->file);
290 290
 
291 291
 		echo $file;
292 292
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @since 1.5
300 300
 	 * @param array $request The Form Data passed into the batch processing
301 301
 	 */
302
-	public function set_properties( $request ) {}
302
+	public function set_properties($request) {}
303 303
 
304 304
 	/**
305 305
 	 * Allow for prefetching of data for the remainder of the exporter
Please login to merge, or discard this patch.