Completed
Pull Request — master (#782)
by
unknown
20:41
created
includes/admin/admin-pages.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 	global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page;
30 30
 
31 31
 	//Payments
32
-	$give_payment       = get_post_type_object( 'give_payment' );
33
-	$give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' );
32
+	$give_payment       = get_post_type_object('give_payment');
33
+	$give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page');
34 34
 
35 35
 	//Donors
36
-	$give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' );
36
+	$give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page');
37 37
 
38 38
 	//Reports`
39
-	$give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donation Reports', 'give' ), esc_html__( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' );
39
+	$give_reports_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donation Reports', 'give'), esc_html__('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page');
40 40
 
41 41
 	//Settings
42
-	$give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Settings', 'give' ), esc_html__( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array(
42
+	$give_settings_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Settings', 'give'), esc_html__('Settings', 'give'), 'manage_give_settings', 'give-settings', array(
43 43
 		Give()->give_settings,
44 44
 		'admin_page_display'
45
-	) );
45
+	));
46 46
 
47 47
 	//Add-ons
48
-	$give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' );
48
+	$give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page');
49 49
 
50 50
 	//Upgrades
51
-	$give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' );
51
+	$give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen');
52 52
 
53 53
 
54 54
 }
55 55
 
56
-add_action( 'admin_menu', 'give_add_options_links', 10 );
56
+add_action('admin_menu', 'give_add_options_links', 10);
57 57
 
58 58
 /**
59 59
  *  Determines whether the current admin page is a Give admin page.
@@ -68,224 +68,224 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return bool True if Give admin page.
70 70
  */
71
-function give_is_admin_page( $passed_page = '', $passed_view = '' ) {
71
+function give_is_admin_page($passed_page = '', $passed_view = '') {
72 72
 
73 73
 	global $pagenow, $typenow;
74 74
 
75 75
 	$found     = false;
76
-	$post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false;
77
-	$action    = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false;
78
-	$taxonomy  = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false;
79
-	$page      = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
80
-	$view      = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false;
81
-	$tab       = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false;
76
+	$post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false;
77
+	$action    = isset($_GET['action']) ? strtolower($_GET['action']) : false;
78
+	$taxonomy  = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false;
79
+	$page      = isset($_GET['page']) ? strtolower($_GET['page']) : false;
80
+	$view      = isset($_GET['view']) ? strtolower($_GET['view']) : false;
81
+	$tab       = isset($_GET['tab']) ? strtolower($_GET['tab']) : false;
82 82
 
83
-	switch ( $passed_page ) {
83
+	switch ($passed_page) {
84 84
 		case 'give_forms':
85
-			switch ( $passed_view ) {
85
+			switch ($passed_view) {
86 86
 				case 'list-table':
87
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) {
87
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') {
88 88
 						$found = true;
89 89
 					}
90 90
 					break;
91 91
 				case 'edit':
92
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) {
92
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') {
93 93
 						$found = true;
94 94
 					}
95 95
 					break;
96 96
 				case 'new':
97
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) {
97
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') {
98 98
 						$found = true;
99 99
 					}
100 100
 					break;
101 101
 				default:
102
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) {
102
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) {
103 103
 						$found = true;
104 104
 					}
105 105
 					break;
106 106
 			}
107 107
 			break;
108 108
 		case 'categories':
109
-			switch ( $passed_view ) {
109
+			switch ($passed_view) {
110 110
 				case 'list-table':
111 111
 				case 'new':
112
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) {
112
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) {
113 113
 						$found = true;
114 114
 					}
115 115
 					break;
116 116
 				case 'edit':
117
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) {
117
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) {
118 118
 						$found = true;
119 119
 					}
120 120
 					break;
121 121
 				default:
122
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) {
122
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) {
123 123
 						$found = true;
124 124
 					}
125 125
 					break;
126 126
 			}
127 127
 			break;
128 128
 		case 'tags':
129
-			switch ( $passed_view ) {
129
+			switch ($passed_view) {
130 130
 				case 'list-table':
131 131
 				case 'new':
132
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) {
132
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) {
133 133
 						$found = true;
134 134
 					}
135 135
 					break;
136 136
 				case 'edit':
137
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) {
137
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) {
138 138
 						$found = true;
139 139
 					}
140 140
 					break;
141 141
 				default:
142
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) {
142
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) {
143 143
 						$found = true;
144 144
 					}
145 145
 					break;
146 146
 			}
147 147
 			break;
148 148
 		case 'payments':
149
-			switch ( $passed_view ) {
149
+			switch ($passed_view) {
150 150
 				case 'list-table':
151
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) {
151
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) {
152 152
 						$found = true;
153 153
 					}
154 154
 					break;
155 155
 				case 'edit':
156
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) {
156
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) {
157 157
 						$found = true;
158 158
 					}
159 159
 					break;
160 160
 				default:
161
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) {
161
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) {
162 162
 						$found = true;
163 163
 					}
164 164
 					break;
165 165
 			}
166 166
 			break;
167 167
 		case 'reports':
168
-			switch ( $passed_view ) {
168
+			switch ($passed_view) {
169 169
 				// If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ]
170 170
 				case 'earnings':
171
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) {
171
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) {
172 172
 						$found = true;
173 173
 					}
174 174
 					break;
175 175
 				case 'donors':
176
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) {
176
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) {
177 177
 						$found = true;
178 178
 					}
179 179
 					break;
180 180
 				case 'gateways':
181
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) {
181
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) {
182 182
 						$found = true;
183 183
 					}
184 184
 					break;
185 185
 				case 'export':
186
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) {
186
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) {
187 187
 						$found = true;
188 188
 					}
189 189
 					break;
190 190
 				case 'logs':
191
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) {
191
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) {
192 192
 						$found = true;
193 193
 					}
194 194
 					break;
195 195
 				default:
196
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
196
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
197 197
 						$found = true;
198 198
 					}
199 199
 					break;
200 200
 			}
201 201
 			break;
202 202
 		case 'settings':
203
-			switch ( $passed_view ) {
203
+			switch ($passed_view) {
204 204
 				case 'general':
205
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) {
205
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) {
206 206
 						$found = true;
207 207
 					}
208 208
 					break;
209 209
 				case 'gateways':
210
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) {
210
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) {
211 211
 						$found = true;
212 212
 					}
213 213
 					break;
214 214
 				case 'emails':
215
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) {
215
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) {
216 216
 						$found = true;
217 217
 					}
218 218
 					break;
219 219
 				case 'display':
220
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) {
220
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) {
221 221
 						$found = true;
222 222
 					}
223 223
 					break;
224 224
 				case 'licenses':
225
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) {
225
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) {
226 226
 						$found = true;
227 227
 					}
228 228
 					break;
229 229
 				case 'api':
230
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) {
230
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) {
231 231
 						$found = true;
232 232
 					}
233 233
 					break;
234 234
 				case 'advanced':
235
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) {
235
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) {
236 236
 						$found = true;
237 237
 					}
238 238
 					break;
239 239
 				case 'system_info':
240
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) {
240
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) {
241 241
 						$found = true;
242 242
 					}
243 243
 					break;
244 244
 				default:
245
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) {
245
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) {
246 246
 						$found = true;
247 247
 					}
248 248
 					break;
249 249
 			}
250 250
 			break;
251 251
 		case 'addons':
252
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) {
252
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) {
253 253
 				$found = true;
254 254
 			}
255 255
 			break;
256 256
 		case 'donors':
257
-			switch ( $passed_view ) {
257
+			switch ($passed_view) {
258 258
 				case 'list-table':
259
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) {
259
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) {
260 260
 						$found = true;
261 261
 					}
262 262
 					break;
263 263
 				case 'overview':
264
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) {
264
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) {
265 265
 						$found = true;
266 266
 					}
267 267
 					break;
268 268
 				case 'notes':
269
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) {
269
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) {
270 270
 						$found = true;
271 271
 					}
272 272
 					break;
273 273
 				default:
274
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) {
274
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) {
275 275
 						$found = true;
276 276
 					}
277 277
 					break;
278 278
 			}
279 279
 			break;
280 280
 		case 'reports':
281
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
281
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
282 282
 				$found = true;
283 283
 			}
284 284
 			break;
285 285
 		default:
286 286
 			global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page;
287 287
 
288
-			$admin_pages = apply_filters( 'give_admin_pages', array(
288
+			$admin_pages = apply_filters('give_admin_pages', array(
289 289
 				$give_payments_page,
290 290
 				$give_settings_page,
291 291
 				$give_reports_page,
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 				$give_upgrades_screen,
295 295
 				$give_settings_export,
296 296
 				$give_customers_page
297
-			) );
298
-			if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
297
+			));
298
+			if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) {
299 299
 				$found = true;
300
-				if ( 'give-upgrades' === $page ) {
300
+				if ('give-upgrades' === $page) {
301 301
 					$found = false;
302 302
 				}
303
-			} elseif ( in_array( $pagenow, $admin_pages ) ) {
303
+			} elseif (in_array($pagenow, $admin_pages)) {
304 304
 				$found = true;
305 305
 			}
306 306
 			break;
307 307
 	}
308 308
 
309
-	return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view );
309
+	return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view);
310 310
 
311 311
 }
312 312
\ No newline at end of file
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
  * @global $wp_version
25 25
  * @return void
26 26
  */
27
-function give_install( $network_wide = false ) {
27
+function give_install($network_wide = false) {
28 28
 
29 29
 	global $wpdb;
30 30
 
31
-	if ( is_multisite() && $network_wide ) {
31
+	if (is_multisite() && $network_wide) {
32 32
 
33
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
33
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
34 34
 
35
-			switch_to_blog( $blog_id );
35
+			switch_to_blog($blog_id);
36 36
 			give_run_install();
37 37
 			restore_current_blog();
38 38
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 }
48 48
 
49
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
49
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
50 50
 
51 51
 /**
52 52
  * Run the Give Install process
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 	give_setup_post_types();
63 63
 
64 64
 	// Clear the permalinks
65
-	flush_rewrite_rules( false );
65
+	flush_rewrite_rules(false);
66 66
 
67 67
 	// Add Upgraded From Option
68
-	$current_version = get_option( 'give_version' );
69
-	if ( $current_version ) {
70
-		update_option( 'give_version_upgraded_from', $current_version );
68
+	$current_version = get_option('give_version');
69
+	if ($current_version) {
70
+		update_option('give_version_upgraded_from', $current_version);
71 71
 	}
72 72
 
73 73
 	// Setup some default options
74 74
 	$options = array();
75 75
 
76 76
 	// Checks if the Success Page option exists AND that the page exists
77
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
77
+	if ( ! get_post(give_get_option('success_page'))) {
78 78
 
79 79
 		// Purchase Confirmation (Success) Page
80 80
 		$success = wp_insert_post(
81 81
 			array(
82
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
82
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
83 83
 				'post_content'   => '[give_receipt]',
84 84
 				'post_status'    => 'publish',
85 85
 				'post_author'    => 1,
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	// Checks if the Failure Page option exists AND that the page exists
96
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
96
+	if ( ! get_post(give_get_option('failure_page'))) {
97 97
 
98 98
 		// Failed Purchase Page
99 99
 		$failed = wp_insert_post(
100 100
 			array(
101
-				'post_title'     => esc_html__( 'Transaction Failed', 'give' ),
102
-				'post_content'   => esc_html__( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ),
101
+				'post_title'     => esc_html__('Transaction Failed', 'give'),
102
+				'post_content'   => esc_html__('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'),
103 103
 				'post_status'    => 'publish',
104 104
 				'post_author'    => 1,
105 105
 				'post_type'      => 'page',
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	// Checks if the History Page option exists AND that the page exists
114
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
114
+	if ( ! get_post(give_get_option('history_page'))) {
115 115
 		// Purchase History (History) Page
116 116
 		$history = wp_insert_post(
117 117
 			array(
118
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
118
+				'post_title'     => esc_html__('Donation History', 'give'),
119 119
 				'post_content'   => '[donation_history]',
120 120
 				'post_status'    => 'publish',
121 121
 				'post_author'    => 1,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency
131
-	if ( empty( $current_version ) ) {
131
+	if (empty($current_version)) {
132 132
 		$options['base_country']       = 'US';
133 133
 		$options['test_mode']          = 1;
134 134
 		$options['currency']           = 'USD';
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 	}
146 146
 
147 147
 	// Populate some default values
148
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
149
-	update_option( 'give_version', GIVE_VERSION );
148
+	update_option('give_settings', array_merge($give_options, $options));
149
+	update_option('give_version', GIVE_VERSION);
150 150
 
151 151
 	//Update Version Number
152
-	if ( $current_version ) {
153
-		update_option( 'give_version_upgraded_from', $current_version );
152
+	if ($current_version) {
153
+		update_option('give_version_upgraded_from', $current_version);
154 154
 	}
155 155
 
156 156
 	// Create Give roles
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	$roles->add_caps();
160 160
 
161 161
 	$api = new Give_API();
162
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
162
+	update_option('give_default_api_version', 'v'.$api->get_version());
163 163
 
164 164
 	// Create the customers database
165 165
 	@Give()->customers->create_table();
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	Give()->session->use_php_sessions();
169 169
 
170 170
 	// Add a temporary option to note that Give pages have been created
171
-	set_transient( '_give_installed', $options, 30 );
171
+	set_transient('_give_installed', $options, 30);
172 172
 	
173
-	if ( ! $current_version ) {
173
+	if ( ! $current_version) {
174 174
 
175
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
175
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
176 176
 
177 177
 		// When new upgrade routines are added, mark them as complete on fresh install
178 178
 		$upgrade_routines = array(
@@ -181,22 +181,22 @@  discard block
 block discarded – undo
181 181
 			'upgrade_give_offline_status'
182 182
 		);
183 183
 
184
-		foreach ( $upgrade_routines as $upgrade ) {
185
-			give_set_upgrade_complete( $upgrade );
184
+		foreach ($upgrade_routines as $upgrade) {
185
+			give_set_upgrade_complete($upgrade);
186 186
 		}
187 187
 	}
188 188
 
189 189
 	// Bail if activating from network, or bulk
190
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
190
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
191 191
 		return;
192 192
 	}
193 193
 
194 194
 	// Add the transient to redirect
195
-	set_transient( '_give_activation_redirect', true, 30 );
195
+	set_transient('_give_activation_redirect', true, 30);
196 196
 
197 197
 }
198 198
 
199
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
199
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
200 200
 
201 201
 /**
202 202
  * Network Activated New Site Setup
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
  * @param  int    $site_id The Site ID
213 213
  * @param  array  $meta    Blog Meta
214 214
  */
215
-function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
215
+function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
216 216
 
217
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
217
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
218 218
 
219
-		switch_to_blog( $blog_id );
219
+		switch_to_blog($blog_id);
220 220
 		give_install();
221 221
 		restore_current_blog();
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 }
226 226
 
227
-add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
227
+add_action('wpmu_new_blog', 'on_create_blog', 10, 6);
228 228
 
229 229
 
230 230
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  *
238 238
  * @return array          The tables to drop
239 239
  */
240
-function give_wpmu_drop_tables( $tables, $blog_id ) {
240
+function give_wpmu_drop_tables($tables, $blog_id) {
241 241
 
242
-	switch_to_blog( $blog_id );
242
+	switch_to_blog($blog_id);
243 243
 	$customers_db = new Give_DB_Customers();
244
-	if ( $customers_db->installed() ) {
244
+	if ($customers_db->installed()) {
245 245
 		$tables[] = $customers_db->table_name;
246 246
 	}
247 247
 	restore_current_blog();
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
 }
252 252
 
253
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
253
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
254 254
 
255 255
 /**
256 256
  * Post-installation
@@ -262,35 +262,35 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function give_after_install() {
264 264
 
265
-	if ( ! is_admin() ) {
265
+	if ( ! is_admin()) {
266 266
 		return;
267 267
 	}
268 268
 
269
-	$give_options     = get_transient( '_give_installed' );
270
-	$give_table_check = get_option( '_give_table_check', false );
269
+	$give_options     = get_transient('_give_installed');
270
+	$give_table_check = get_option('_give_table_check', false);
271 271
 
272
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
272
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
273 273
 
274
-		if ( ! @Give()->customers->installed() ) {
274
+		if ( ! @Give()->customers->installed()) {
275 275
 			// Create the customers database (this ensures it creates it on multisite instances where it is network activated)
276 276
 			@Give()->customers->create_table();
277 277
 
278
-			do_action( 'give_after_install', $give_options );
278
+			do_action('give_after_install', $give_options);
279 279
 		}
280 280
 
281
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
281
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
282 282
 
283 283
 	}
284 284
 
285 285
 	// Delete the transient
286
-	if ( false !== $give_options ) {
287
-		delete_transient( '_give_installed' );
286
+	if (false !== $give_options) {
287
+		delete_transient('_give_installed');
288 288
 	}
289 289
 
290 290
 
291 291
 }
292 292
 
293
-add_action( 'admin_init', 'give_after_install' );
293
+add_action('admin_init', 'give_after_install');
294 294
 
295 295
 
296 296
 /**
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 
306 306
 	global $wp_roles;
307 307
 
308
-	if ( ! is_object( $wp_roles ) ) {
308
+	if ( ! is_object($wp_roles)) {
309 309
 		return;
310 310
 	}
311 311
 
312
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
312
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
313 313
 
314 314
 		// Create Give plugin roles
315 315
 		$roles = new Give_Roles();
@@ -320,4 +320,4 @@  discard block
 block discarded – undo
320 320
 
321 321
 }
322 322
 
323
-add_action( 'admin_init', 'give_install_roles_on_network' );
324 323
\ No newline at end of file
324
+add_action('admin_init', 'give_install_roles_on_network');
325 325
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 	
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -51,45 +51,45 @@  discard block
 block discarded – undo
51 51
 	$price_id       = $payment->price_id;
52 52
 	$form_id        = $payment->form_id;
53 53
 
54
-	do_action( 'give_pre_complete_purchase', $payment_id );
54
+	do_action('give_pre_complete_purchase', $payment_id);
55 55
 
56 56
 	// Ensure these actions only run once, ever
57
-	if ( empty( $completed_date ) ) {
57
+	if (empty($completed_date)) {
58 58
 
59
-		give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date );
60
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
59
+		give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date);
60
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
61 61
 
62 62
 	}
63 63
 
64 64
 	// Increase the earnings for this form ID
65
-	give_increase_earnings( $form_id, $amount );
66
-	give_increase_purchase_count( $form_id );
65
+	give_increase_earnings($form_id, $amount);
66
+	give_increase_purchase_count($form_id);
67 67
 
68 68
 	// Clear the total earnings cache
69
-	delete_transient( 'give_earnings_total' );
69
+	delete_transient('give_earnings_total');
70 70
 	// Clear the This Month earnings (this_monththis_month is NOT a typo)
71
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
72
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
71
+	delete_transient(md5('give_earnings_this_monththis_month'));
72
+	delete_transient(md5('give_earnings_todaytoday'));
73 73
 	
74 74
 	// Increase the donor's purchase stats
75
-	$customer = new Give_Customer( $customer_id );
75
+	$customer = new Give_Customer($customer_id);
76 76
 	$customer->increase_purchase_count();
77
-	$customer->increase_value( $amount );
77
+	$customer->increase_value($amount);
78 78
 
79
-	give_increase_total_earnings( $amount );
79
+	give_increase_total_earnings($amount);
80 80
 
81 81
 	// Ensure this action only runs once ever
82
-	if ( empty( $completed_date ) ) {
82
+	if (empty($completed_date)) {
83 83
 
84 84
 		// Save the completed date
85
-		$payment->completed_date = current_time( 'mysql' );
85
+		$payment->completed_date = current_time('mysql');
86 86
 		$payment->save();
87
-		do_action( 'give_complete_purchase', $payment_id );
87
+		do_action('give_complete_purchase', $payment_id);
88 88
 	}
89 89
 
90 90
 }
91 91
 
92
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
92
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
93 93
 
94 94
 
95 95
 /**
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
  *
104 104
  * @return void
105 105
  */
106
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
106
+function give_record_status_change($payment_id, $new_status, $old_status) {
107 107
 
108 108
 	// Get the list of statuses so that status in the payment note can be translated
109 109
 	$stati      = give_get_payment_statuses();
110
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
111
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
110
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
111
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
112 112
 
113 113
 	$status_change = sprintf(
114 114
 		/* translators: 1: old status 2: new status */
115
-		esc_html__( 'Status changed from %1$s to %2$s.', 'give' ),
115
+		esc_html__('Status changed from %1$s to %2$s.', 'give'),
116 116
 		$old_status,
117 117
 		$new_status
118 118
 	);
119 119
 
120
-	give_insert_payment_note( $payment_id, $status_change );
120
+	give_insert_payment_note($payment_id, $status_change);
121 121
 }
122 122
 
123
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
123
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
124 124
 
125 125
 
126 126
 /**
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
  * @param $new_status the status of the payment, probably "publish"
134 134
  * @param $old_status the status of the payment prior to being marked as "complete", probably "pending"
135 135
  */
136
-function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) {
136
+function give_clear_user_history_cache($payment_id, $new_status, $old_status) {
137 137
 
138
-	$payment = new Give_Payment( $payment_id );
138
+	$payment = new Give_Payment($payment_id);
139 139
 
140
-	if ( ! empty( $payment->user_id ) ) {
141
-		delete_transient( 'give_user_' . $payment->user_id . '_purchases' );
140
+	if ( ! empty($payment->user_id)) {
141
+		delete_transient('give_user_'.$payment->user_id.'_purchases');
142 142
 	}
143 143
 
144 144
 }
145 145
 
146
-add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 );
146
+add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3);
147 147
 
148 148
 /**
149 149
  * Updates all old payments, prior to 1.2, with new
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
  *
158 158
  * @return void
159 159
  */
160
-function give_update_old_payments_with_totals( $data ) {
161
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
160
+function give_update_old_payments_with_totals($data) {
161
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
162 162
 		return;
163 163
 	}
164 164
 
165
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
165
+	if (get_option('give_payment_totals_upgraded')) {
166 166
 		return;
167 167
 	}
168 168
 
169
-	$payments = give_get_payments( array(
169
+	$payments = give_get_payments(array(
170 170
 		'offset' => 0,
171
-		'number' => - 1,
171
+		'number' => -1,
172 172
 		'mode'   => 'all'
173
-	) );
173
+	));
174 174
 
175
-	if ( $payments ) {
176
-		foreach ( $payments as $payment ) {
175
+	if ($payments) {
176
+		foreach ($payments as $payment) {
177 177
 
178
-			$payment = new Give_Payment( $payment->ID );
178
+			$payment = new Give_Payment($payment->ID);
179 179
 			$meta    = $payment->get_meta();
180 180
 
181 181
 			$payment->total = $meta['amount'];
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 	}
186 186
 
187
-	add_option( 'give_payment_totals_upgraded', 1 );
187
+	add_option('give_payment_totals_upgraded', 1);
188 188
 }
189 189
 
190
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
190
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
191 191
 
192 192
 /**
193 193
  * Updates week-old+ 'pending' orders to 'abandoned'
@@ -198,21 +198,21 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
212
-		foreach ( $payments as $payment ) {
213
-			$gateway = give_get_payment_gateway( $payment );
211
+	if ($payments) {
212
+		foreach ($payments as $payment) {
213
+			$gateway = give_get_payment_gateway($payment);
214 214
 			//Skip offline gateway payments
215
-			if ( $gateway == 'offline' ) {
215
+			if ($gateway == 'offline') {
216 216
 				continue;
217 217
 			}
218 218
 			$payment->status = 'abandoned';
@@ -221,4 +221,4 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 }
223 223
 
224
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
225 224
\ No newline at end of file
225
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
226 226
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-email-access.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @since       1.4
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) or exit;
13
+defined('ABSPATH') or exit;
14 14
 
15 15
 /**
16 16
  * Class Give_Email_Access
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	function __construct() {
31 31
 
32 32
 		// get it started
33
-		add_action( 'init', array( $this, 'init' ) );
33
+		add_action('init', array($this, 'init'));
34 34
 	}
35 35
 
36 36
 
@@ -39,30 +39,30 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	function init() {
41 41
 
42
-		$is_enabled = give_get_option( 'email_access' );
42
+		$is_enabled = give_get_option('email_access');
43 43
 
44 44
 		//Non-logged in users only
45
-		if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) {
45
+		if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) {
46 46
 			return;
47 47
 		}
48 48
 
49 49
 		//Are db columns setup?
50
-		$is_setup = give_get_option( 'email_access_installed' );
51
-		if ( empty( $is_setup ) ) {
50
+		$is_setup = give_get_option('email_access_installed');
51
+		if (empty($is_setup)) {
52 52
 			$this->create_columns();
53 53
 		}
54 54
 
55 55
 		// Timeouts
56
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
57
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
56
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
57
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
58 58
 
59 59
 		// Setup login
60 60
 		$this->check_for_token();
61 61
 
62
-		if ( $this->token_exists ) {
63
-			add_filter( 'give_can_view_receipt', '__return_true' );
64
-			add_filter( 'give_user_pending_verification', '__return_false' );
65
-			add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) );
62
+		if ($this->token_exists) {
63
+			add_filter('give_can_view_receipt', '__return_true');
64
+			add_filter('give_user_pending_verification', '__return_false');
65
+			add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args'));
66 66
 		}
67 67
 	}
68 68
 
@@ -73,24 +73,24 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return bool
75 75
 	 */
76
-	function can_send_email( $customer_id ) {
76
+	function can_send_email($customer_id) {
77 77
 		global $wpdb;
78 78
 
79 79
 		// Prevent multiple emails within X minutes
80
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
80
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
81 81
 
82 82
 		// Does a user row exist?
83 83
 		$exists = (int) $wpdb->get_var(
84
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
84
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
85 85
 		);
86 86
 
87
-		if ( 0 < $exists ) {
87
+		if (0 < $exists) {
88 88
 			$row_id = (int) $wpdb->get_var(
89
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
89
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
90 90
 			);
91 91
 
92
-			if ( $row_id < 1 ) {
93
-				give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
92
+			if ($row_id < 1) {
93
+				give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give'));
94 94
 
95 95
 				return false;
96 96
 			}
@@ -106,38 +106,38 @@  discard block
 block discarded – undo
106 106
 	 * @param $customer_id
107 107
 	 * @param $email
108 108
 	 */
109
-	function send_email( $customer_id, $email ) {
109
+	function send_email($customer_id, $email) {
110 110
 
111
-		$verify_key = wp_generate_password( 20, false );
111
+		$verify_key = wp_generate_password(20, false);
112 112
 
113 113
 		// Generate a new verify key
114
-		$this->set_verify_key( $customer_id, $email, $verify_key );
114
+		$this->set_verify_key($customer_id, $email, $verify_key);
115 115
 
116 116
 		// Get the purchase history URL
117
-		$page_id = give_get_option( 'history_page' );
117
+		$page_id = give_get_option('history_page');
118 118
 
119
-		$access_url = add_query_arg( array(
119
+		$access_url = add_query_arg(array(
120 120
 			'give_nl' => $verify_key,
121
-		), get_permalink( $page_id ) );
121
+		), get_permalink($page_id));
122 122
 
123 123
 		//Nice subject and message
124
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
124
+		$subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name')));
125 125
 
126
-		$message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n";
126
+		$message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n";
127 127
 
128
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details', 'give' ) . ' &raquo;</a>';
128
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details', 'give').' &raquo;</a>';
129 129
 
130 130
 		$message .= "\n\n";
131 131
 		$message .= "\n\n";
132
-		$message .= esc_html__( 'Sincerely,', 'give' );
133
-		$message .= "\n" . get_bloginfo( 'name' ) . "\n";
132
+		$message .= esc_html__('Sincerely,', 'give');
133
+		$message .= "\n".get_bloginfo('name')."\n";
134 134
 
135
-		$message = apply_filters( 'give_email_access_token_message', $message );
135
+		$message = apply_filters('give_email_access_token_message', $message);
136 136
 
137 137
 
138 138
 		// Send the email
139
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) );
140
-		Give()->emails->send( $email, $subject, $message );
139
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give')));
140
+		Give()->emails->send($email, $subject, $message);
141 141
 
142 142
 	}
143 143
 
@@ -147,24 +147,24 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	function check_for_token() {
149 149
 
150
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
150
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
151 151
 
152 152
 		// Check for cookie
153
-		if ( empty( $token ) ) {
154
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
153
+		if (empty($token)) {
154
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
155 155
 		}
156 156
 
157
-		if ( ! empty( $token ) ) {
158
-			if ( ! $this->is_valid_token( $token ) ) {
159
-				if ( ! $this->is_valid_verify_key( $token ) ) {
157
+		if ( ! empty($token)) {
158
+			if ( ! $this->is_valid_token($token)) {
159
+				if ( ! $this->is_valid_verify_key($token)) {
160 160
 					return;
161 161
 				}
162 162
 			}
163 163
 
164 164
 			$this->token_exists = true;
165 165
 			// Set cookie
166
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
167
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
166
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
167
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
168 168
 		}
169 169
 	}
170 170
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return bool
177 177
 	 */
178
-	function is_valid_token( $token ) {
178
+	function is_valid_token($token) {
179 179
 
180 180
 		global $wpdb;
181 181
 
182 182
 		// Make sure token isn't expired
183
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
183
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
184 184
 
185 185
 		$email = $wpdb->get_var(
186
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
186
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
187 187
 		);
188 188
 
189
-		if ( ! empty( $email ) ) {
189
+		if ( ! empty($email)) {
190 190
 			$this->token_email = $email;
191 191
 			$this->token       = $token;
192 192
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 		}
195 195
 
196 196
 		//Set error only if email access form isn't being submitted
197
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
198
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give' ) );
197
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
198
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give'));
199 199
 		}
200 200
 
201 201
 
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
 	 * @param $email
211 211
 	 * @param $verify_key
212 212
 	 */
213
-	function set_verify_key( $customer_id, $email, $verify_key ) {
213
+	function set_verify_key($customer_id, $email, $verify_key) {
214 214
 		global $wpdb;
215 215
 
216
-		$now = date( 'Y-m-d H:i:s' );
216
+		$now = date('Y-m-d H:i:s');
217 217
 
218 218
 		// Insert or update?
219 219
 		$row_id = (int) $wpdb->get_var(
220
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
220
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
221 221
 		);
222 222
 
223 223
 		// Update
224
-		if ( ! empty( $row_id ) ) {
224
+		if ( ! empty($row_id)) {
225 225
 			$wpdb->query(
226
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
226
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
227 227
 			);
228 228
 		} // Insert
229 229
 		else {
230 230
 			$wpdb->query(
231
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
231
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
232 232
 			);
233 233
 		}
234 234
 	}
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return bool
242 242
 	 */
243
-	function is_valid_verify_key( $token ) {
243
+	function is_valid_verify_key($token) {
244 244
 		global $wpdb;
245 245
 
246 246
 		// See if the verify_key exists
247 247
 		$row = $wpdb->get_row(
248
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
248
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
249 249
 		);
250 250
 
251
-		$now = date( 'Y-m-d H:i:s' );
251
+		$now = date('Y-m-d H:i:s');
252 252
 
253 253
 		// Set token
254
-		if ( ! empty( $row ) ) {
254
+		if ( ! empty($row)) {
255 255
 			$wpdb->query(
256
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
256
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
257 257
 			);
258 258
 
259 259
 			$this->token_email = $row->email;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return mixed
274 274
 	 */
275
-	function users_purchases_args( $args ) {
275
+	function users_purchases_args($args) {
276 276
 		$args['user'] = $this->token_email;
277 277
 
278 278
 		return $args;
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 		global $wpdb;
290 290
 
291 291
 		//Create columns in customers table
292
-		$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );
292
+		$query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
293 293
 
294 294
 		//Columns added properly
295
-		if ( $query ) {
296
-			give_update_option( 'email_access_installed', 1 );
295
+		if ($query) {
296
+			give_update_option('email_access_installed', 1);
297 297
 		}
298 298
 
299 299
 	}
Please login to merge, or discard this patch.
includes/emails/functions.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
 
@@ -26,39 +26,39 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
34
-	$from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34
+	$from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
35 35
 
36
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
37
-	$from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data );
36
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
37
+	$from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
38 38
 
39
-	$to_email = give_get_payment_user_email( $payment_id );
39
+	$to_email = give_get_payment_user_email($payment_id);
40 40
 
41
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
42
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
43
-	$subject = give_do_email_tags( $subject, $payment_id );
41
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
42
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
43
+	$subject = give_do_email_tags($subject, $payment_id);
44 44
 
45
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
46
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
45
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
46
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
47 47
 
48 48
 	$emails = Give()->emails;
49 49
 
50
-	$emails->__set( 'from_name', $from_name );
51
-	$emails->__set( 'from_email', $from_email );
52
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
50
+	$emails->__set('from_name', $from_name);
51
+	$emails->__set('from_email', $from_email);
52
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
53 53
 
54 54
 
55
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
56
-	$emails->__set( 'headers', $headers );
55
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
56
+	$emails->__set('headers', $headers);
57 57
 
58
-	$emails->send( $to_email, $subject, $message, $attachments );
58
+	$emails->send($to_email, $subject, $message, $attachments);
59 59
 
60
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
61
-		do_action( 'give_admin_sale_notice', $payment_id, $payment_data );
60
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
61
+		do_action('give_admin_sale_notice', $payment_id, $payment_data);
62 62
 	}
63 63
 }
64 64
 
@@ -71,29 +71,29 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function give_email_test_donation_receipt() {
73 73
 
74
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
75
-	$from_name = apply_filters( 'give_purchase_from_name', $from_name, 0, array() );
74
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
75
+	$from_name = apply_filters('give_purchase_from_name', $from_name, 0, array());
76 76
 
77
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
78
-	$from_email = apply_filters( 'give_purchase_from_address', $from_email, 0, array() );
77
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
78
+	$from_email = apply_filters('give_purchase_from_address', $from_email, 0, array());
79 79
 
80
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
81
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
82
-	$subject = give_do_email_tags( $subject, 0 );
80
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
81
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
82
+	$subject = give_do_email_tags($subject, 0);
83 83
 
84
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
84
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
85 85
 
86
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
86
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
87 87
 
88 88
 	$emails = Give()->emails;
89
-	$emails->__set( 'from_name', $from_name );
90
-	$emails->__set( 'from_email', $from_email );
91
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
89
+	$emails->__set('from_name', $from_name);
90
+	$emails->__set('from_email', $from_email);
91
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
92 92
 
93
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
94
-	$emails->__set( 'headers', $headers );
93
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
94
+	$emails->__set('headers', $headers);
95 95
 
96
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
96
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
97 97
 
98 98
 }
99 99
 
@@ -107,50 +107,50 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return void
109 109
  */
110
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
110
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
111 111
 
112
-	$payment_id = absint( $payment_id );
112
+	$payment_id = absint($payment_id);
113 113
 
114
-	if ( empty( $payment_id ) ) {
114
+	if (empty($payment_id)) {
115 115
 		return;
116 116
 	}
117 117
 
118
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
118
+	if ( ! give_get_payment_by('id', $payment_id)) {
119 119
 		return;
120 120
 	}
121 121
 
122
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
123
-	$from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data );
122
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
123
+	$from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data);
124 124
 
125
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
126
-	$from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data );
125
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
126
+	$from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data);
127 127
 
128 128
 	/* translators: %s: payment id */
129
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
130
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
131
-	$subject = give_do_email_tags( $subject, $payment_id );
129
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
130
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
131
+	$subject = give_do_email_tags($subject, $payment_id);
132 132
 
133
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
134
-	$headers .= "Reply-To: " . $from_email . "\r\n";
133
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
134
+	$headers .= "Reply-To: ".$from_email."\r\n";
135 135
 	//$headers  .= "MIME-Version: 1.0\r\n";
136 136
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
137
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
137
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
138 138
 
139
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
139
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
140 140
 
141
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
141
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
142 142
 
143 143
 	$emails = Give()->emails;
144
-	$emails->__set( 'from_name', $from_name );
145
-	$emails->__set( 'from_email', $from_email );
146
-	$emails->__set( 'headers', $headers );
147
-	$emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) );
144
+	$emails->__set('from_name', $from_name);
145
+	$emails->__set('from_email', $from_email);
146
+	$emails->__set('headers', $headers);
147
+	$emails->__set('heading', esc_html__('New Donation!', 'give'));
148 148
 
149
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
149
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
150 150
 
151 151
 }
152 152
 
153
-add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 );
153
+add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2);
154 154
 
155 155
 /**
156 156
  * Retrieves the emails for which admin notifications are sent to (these can be
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 function give_get_admin_notice_emails() {
164 164
 	global $give_options;
165 165
 
166
-	$emails = isset( $give_options['admin_notice_emails'] ) && strlen( trim( $give_options['admin_notice_emails'] ) ) > 0 ? $give_options['admin_notice_emails'] : get_bloginfo( 'admin_email' );
167
-	$emails = array_map( 'trim', explode( "\n", $emails ) );
166
+	$emails = isset($give_options['admin_notice_emails']) && strlen(trim($give_options['admin_notice_emails'])) > 0 ? $give_options['admin_notice_emails'] : get_bloginfo('admin_email');
167
+	$emails = array_map('trim', explode("\n", $emails));
168 168
 
169
-	return apply_filters( 'give_admin_notice_emails', $emails );
169
+	return apply_filters('give_admin_notice_emails', $emails);
170 170
 }
171 171
 
172 172
 /**
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return mixed
180 180
  */
181
-function give_admin_notices_disabled( $payment_id = 0 ) {
181
+function give_admin_notices_disabled($payment_id = 0) {
182 182
 
183
-	$retval = give_get_option( 'disable_admin_notices' );
183
+	$retval = give_get_option('disable_admin_notices');
184 184
 
185
-	return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id );
185
+	return apply_filters('give_admin_notices_disabled', $retval, $payment_id);
186 186
 }
187 187
 
188 188
 /**
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
  */
196 196
 function give_get_default_donation_notification_email() {
197 197
 
198
-	$default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n" . esc_html__( 'This email is to inform you that a new donation has been made on your website: ', 'give' ) . '<a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
199
-	$default_email_body .= '<strong>' . esc_html__( 'Donor: ', 'give' ) . '</strong> ' . ' {name}' . "\n";
200
-	$default_email_body .= '<strong>' . esc_html__( 'Donation: ', 'give' ) . '</strong> ' . ' {donation}' . "\n";
201
-	$default_email_body .= '<strong>' . esc_html__( 'Amount: ', 'give' ) . '</strong> ' . ' {price}' . "\n";
202
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method: ', 'give' ) . '</strong> ' . ' {payment_method}' . "\n\n";
203
-	$default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n" . '{sitename}';
198
+	$default_email_body = esc_html__('Hi there,', 'give')."\n\n".esc_html__('This email is to inform you that a new donation has been made on your website: ', 'give').'<a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
199
+	$default_email_body .= '<strong>'.esc_html__('Donor: ', 'give').'</strong> '.' {name}'."\n";
200
+	$default_email_body .= '<strong>'.esc_html__('Donation: ', 'give').'</strong> '.' {donation}'."\n";
201
+	$default_email_body .= '<strong>'.esc_html__('Amount: ', 'give').'</strong> '.' {price}'."\n";
202
+	$default_email_body .= '<strong>'.esc_html__('Payment Method: ', 'give').'</strong> '.' {payment_method}'."\n\n";
203
+	$default_email_body .= esc_html__('Thank you,', 'give')."\n\n".'{sitename}';
204 204
 
205
-	$custom_message = give_get_option( 'donation_notification' );
206
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
205
+	$custom_message = give_get_option('donation_notification');
206
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
207 207
 
208
-	return apply_filters( 'give_default_donation_notification_email', $message );
208
+	return apply_filters('give_default_donation_notification_email', $message);
209 209
 }
210 210
 
211 211
 
@@ -219,26 +219,26 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function give_get_default_donation_receipt_email() {
221 221
 
222
-	$default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n";
223
-	$default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
224
-	$default_email_body .= '<strong>' . esc_html__( 'Donor', 'give' ) . ':</strong> ' . '{fullname}' . "\n";
225
-	$default_email_body .= '<strong>' . esc_html__( 'Donation', 'give' ) . ':</strong> ' . '{donation}' . "\n";
226
-	$default_email_body .= '<strong>' . esc_html__( 'Donation Date', 'give' ) . ':</strong> ' . '{date}' . "\n";
227
-	$default_email_body .= '<strong>' . esc_html__( 'Amount', 'give' ) . ':</strong> ' . '{price}' . "\n";
228
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method', 'give' ) . ':</strong> ' . '{payment_method}' . "\n";
229
-	$default_email_body .= '<strong>' . esc_html__( 'Payment ID', 'give' ) . ':</strong> ' . '{payment_id}' . "\n";
230
-	$default_email_body .= '<strong>' . esc_html__( 'Receipt ID', 'give' ) . ':</strong> ' . '{receipt_id}' . "\n\n";
231
-	$default_email_body .= '{receipt_link}' . "\n\n";
222
+	$default_email_body = esc_html__('Dear', 'give')." {name},\n\n";
223
+	$default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
224
+	$default_email_body .= '<strong>'.esc_html__('Donor', 'give').':</strong> '.'{fullname}'."\n";
225
+	$default_email_body .= '<strong>'.esc_html__('Donation', 'give').':</strong> '.'{donation}'."\n";
226
+	$default_email_body .= '<strong>'.esc_html__('Donation Date', 'give').':</strong> '.'{date}'."\n";
227
+	$default_email_body .= '<strong>'.esc_html__('Amount', 'give').':</strong> '.'{price}'."\n";
228
+	$default_email_body .= '<strong>'.esc_html__('Payment Method', 'give').':</strong> '.'{payment_method}'."\n";
229
+	$default_email_body .= '<strong>'.esc_html__('Payment ID', 'give').':</strong> '.'{payment_id}'."\n";
230
+	$default_email_body .= '<strong>'.esc_html__('Receipt ID', 'give').':</strong> '.'{receipt_id}'."\n\n";
231
+	$default_email_body .= '{receipt_link}'."\n\n";
232 232
 
233 233
 	$default_email_body .= "\n\n";
234
-	$default_email_body .= esc_html__( 'Sincerely,', 'give' );
235
-	$default_email_body .= "\n" . '{sitename}' . "\n";
234
+	$default_email_body .= esc_html__('Sincerely,', 'give');
235
+	$default_email_body .= "\n".'{sitename}'."\n";
236 236
 
237
-	$custom_message = give_get_option( 'donation_receipt' );
237
+	$custom_message = give_get_option('donation_receipt');
238 238
 
239
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
239
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
240 240
 
241
-	return apply_filters( 'give_default_donation_receipt_email', $message );
241
+	return apply_filters('give_default_donation_receipt_email', $message);
242 242
 }
243 243
 
244 244
 /**
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
  *
251 251
  * @return array $email_names
252 252
  */
253
-function give_get_email_names( $user_info ) {
253
+function give_get_email_names($user_info) {
254 254
 	$email_names = array();
255
-	$user_info   = maybe_unserialize( $user_info );
255
+	$user_info   = maybe_unserialize($user_info);
256 256
 
257 257
 	$email_names['fullname'] = '';
258
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
259
-		$user_data               = get_userdata( $user_info['id'] );
258
+	if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
259
+		$user_data               = get_userdata($user_info['id']);
260 260
 		$email_names['name']     = $user_info['first_name'];
261
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
261
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
262 262
 		$email_names['username'] = $user_data->user_login;
263
-	} elseif ( isset( $user_info['first_name'] ) ) {
263
+	} elseif (isset($user_info['first_name'])) {
264 264
 		$email_names['name']     = $user_info['first_name'];
265
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
265
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
266 266
 		$email_names['username'] = $user_info['first_name'];
267 267
 	} else {
268 268
 		$email_names['name']     = $user_info['email'];
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 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
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html__( 'Default Template', 'give' ),
164
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
163
+			'default' => esc_html__('Default Template', 'give'),
164
+			'none'    => esc_html__('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,36 +205,36 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		ob_start();
217 217
 
218
-		give_get_template_part( 'emails/header', $this->get_template(), true );
218
+		give_get_template_part('emails/header', $this->get_template(), true);
219 219
 
220
-		do_action( 'give_email_header', $this );
220
+		do_action('give_email_header', $this);
221 221
 
222
-		if ( has_action( 'give_email_template_' . $this->get_template() ) ) {
223
-			do_action( 'give_email_template_' . $this->get_template() );
222
+		if (has_action('give_email_template_'.$this->get_template())) {
223
+			do_action('give_email_template_'.$this->get_template());
224 224
 		} else {
225
-			give_get_template_part( 'emails/body', $this->get_template(), true );
225
+			give_get_template_part('emails/body', $this->get_template(), true);
226 226
 		}
227 227
 
228
-		do_action( 'give_email_body', $this );
228
+		do_action('give_email_body', $this);
229 229
 
230
-		give_get_template_part( 'emails/footer', $this->get_template(), true );
230
+		give_get_template_part('emails/footer', $this->get_template(), true);
231 231
 
232
-		do_action( 'give_email_footer', $this );
232
+		do_action('give_email_footer', $this);
233 233
 
234 234
 		$body    = ob_get_clean();
235
-		$message = str_replace( '{email}', $message, $body );
235
+		$message = str_replace('{email}', $message, $body);
236 236
 
237
-		return apply_filters( 'give_email_message', $message, $this );
237
+		return apply_filters('give_email_message', $message, $this);
238 238
 	}
239 239
 
240 240
 	/**
@@ -247,26 +247,26 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool
249 249
 	 */
250
-	public function send( $to, $subject, $message, $attachments = '' ) {
250
+	public function send($to, $subject, $message, $attachments = '') {
251 251
 
252
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
253
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
252
+		if ( ! did_action('init') && ! did_action('admin_init')) {
253
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
254 254
 
255 255
 			return false;
256 256
 		}
257 257
 
258
-		do_action( 'give_email_send_before', $this );
258
+		do_action('give_email_send_before', $this);
259 259
 
260
-		$subject = $this->parse_tags( $subject );
261
-		$message = $this->parse_tags( $message );
260
+		$subject = $this->parse_tags($subject);
261
+		$message = $this->parse_tags($message);
262 262
 
263
-		$message = $this->build_email( $message );
263
+		$message = $this->build_email($message);
264 264
 
265
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
265
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
266 266
 
267
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
267
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
268 268
 
269
-		do_action( 'give_email_send_after', $this );
269
+		do_action('give_email_send_after', $this);
270 270
 
271 271
 		return $sent;
272 272
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0
279 279
 	 */
280 280
 	public function send_before() {
281
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
282
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
283
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
281
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
282
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
283
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
284 284
 	}
285 285
 
286 286
 	/**
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 	 * @since 1.0
290 290
 	 */
291 291
 	public function send_after() {
292
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
293
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
294
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
292
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
293
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
294
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
295 295
 
296 296
 		// Reset heading to an empty string
297 297
 		$this->heading = '';
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @since 1.0
304 304
 	 */
305
-	public function text_to_html( $message ) {
305
+	public function text_to_html($message) {
306 306
 
307
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
308
-			$message = wpautop( $message );
307
+		if ('text/html' == $this->content_type || true === $this->html) {
308
+			$message = wpautop($message);
309 309
 		}
310 310
 
311 311
 		return $message;
Please login to merge, or discard this patch.
includes/emails/actions.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return void
25 25
  */
26
-function give_trigger_donation_receipt( $payment_id ) {
26
+function give_trigger_donation_receipt($payment_id) {
27 27
 	// Make sure we don't send a purchase receipt while editing a payment
28
-	if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) {
28
+	if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) {
29 29
 		return;
30 30
 	}
31 31
 
32 32
 	// Send email
33
-	give_email_donation_receipt( $payment_id );
33
+	give_email_donation_receipt($payment_id);
34 34
 }
35 35
 
36
-add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 );
36
+add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1);
37 37
 
38 38
 /**
39 39
  * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return void
46 46
  */
47
-function give_resend_donation_receipt( $data ) {
47
+function give_resend_donation_receipt($data) {
48 48
 
49
-	$purchase_id = absint( $data['purchase_id'] );
49
+	$purchase_id = absint($data['purchase_id']);
50 50
 
51
-	if ( empty( $purchase_id ) ) {
51
+	if (empty($purchase_id)) {
52 52
 		return;
53 53
 	}
54 54
 
55
-	if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) {
56
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
55
+	if ( ! current_user_can('edit_give_payments', $purchase_id)) {
56
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
57 57
 	}
58 58
 
59
-	give_email_donation_receipt( $purchase_id, false );
59
+	give_email_donation_receipt($purchase_id, false);
60 60
 
61
-	wp_redirect( add_query_arg( array(
61
+	wp_redirect(add_query_arg(array(
62 62
 		'give-message' => 'email_sent',
63 63
 		'give-action'  => false,
64 64
 		'purchase_id'  => false
65
-	) ) );
65
+	)));
66 66
 	exit;
67 67
 }
68 68
 
69
-add_action( 'give_email_links', 'give_resend_donation_receipt' );
69
+add_action('give_email_links', 'give_resend_donation_receipt');
70 70
 
71 71
 /**
72 72
  * Trigger the sending of a Test Email
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
  *
78 78
  * @return void
79 79
  */
80
-function give_send_test_email( $data ) {
81
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) {
80
+function give_send_test_email($data) {
81
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) {
82 82
 		return;
83 83
 	}
84 84
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	give_email_test_donation_receipt();
87 87
 
88 88
 	// Remove the test email query arg
89
-	wp_redirect( remove_query_arg( 'give_action' ) );
89
+	wp_redirect(remove_query_arg('give_action'));
90 90
 	exit;
91 91
 }
92 92
 
93
-add_action( 'give_send_test_email', 'give_send_test_email' );
93
+add_action('give_send_test_email', 'give_send_test_email');
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +72 added lines, -72 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -54,40 +54,40 @@  discard block
 block discarded – undo
54 54
  *
55 55
  * @return string $message Fully formatted message
56 56
  */
57
-function give_email_preview_template_tags( $message ) {
57
+function give_email_preview_template_tags($message) {
58 58
 
59
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
59
+	$price = give_currency_filter(give_format_amount(10.50));
60 60
 
61 61
 	$gateway = 'PayPal';
62 62
 
63
-	$receipt_id = strtolower( md5( uniqid() ) );
63
+	$receipt_id = strtolower(md5(uniqid()));
64 64
 
65
-	$notes = esc_html__( 'These are some sample notes added to a donation.', 'give' );
65
+	$notes = esc_html__('These are some sample notes added to a donation.', 'give');
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69 69
 	$receipt_link = sprintf(
70 70
 		'<a href="%1$s">%2$s</a>',
71
-		esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ),
72
-		esc_html__( 'View the receipt in your browser', 'give' )
71
+		esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())),
72
+		esc_html__('View the receipt in your browser', 'give')
73 73
 	);
74 74
 
75 75
 	$user = wp_get_current_user();
76 76
 
77
-	$message = str_replace( '{name}', $user->display_name, $message );
78
-	$message = str_replace( '{fullname}', $user->display_name, $message );
79
-	$message = str_replace( '{username}', $user->user_login, $message );
80
-	$message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
81
-	$message = str_replace( '{price}', $price, $message );
82
-	$message = str_replace( '{donation}', 'Sample Donation Form Title', $message );
83
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
84
-	$message = str_replace( '{payment_method}', $gateway, $message );
85
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
86
-	$message = str_replace( '{product_notes}', $notes, $message );
87
-	$message = str_replace( '{payment_id}', $payment_id, $message );
88
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
89
-
90
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
77
+	$message = str_replace('{name}', $user->display_name, $message);
78
+	$message = str_replace('{fullname}', $user->display_name, $message);
79
+	$message = str_replace('{username}', $user->user_login, $message);
80
+	$message = str_replace('{date}', date(get_option('date_format'), current_time('timestamp')), $message);
81
+	$message = str_replace('{price}', $price, $message);
82
+	$message = str_replace('{donation}', 'Sample Donation Form Title', $message);
83
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
84
+	$message = str_replace('{payment_method}', $gateway, $message);
85
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
86
+	$message = str_replace('{product_notes}', $notes, $message);
87
+	$message = str_replace('{payment_id}', $payment_id, $message);
88
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
89
+
90
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
91 91
 }
92 92
 
93 93
 /**
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
  * @since  1.0
101 101
  * @return array|bool
102 102
  */
103
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
103
+add_filter('give_settings_emails', 'give_email_template_preview');
104 104
 
105
-function give_email_template_preview( $array ) {
105
+function give_email_template_preview($array) {
106 106
 
107
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
107
+	if ( ! current_user_can('manage_give_settings')) {
108 108
 		return false;
109 109
 	}
110 110
 	$custom_field = array(
111
-		'name' => esc_html__( 'Preview Email', 'give' ),
112
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
111
+		'name' => esc_html__('Preview Email', 'give'),
112
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
113 113
 		'id'   => 'give_email_preview_buttons',
114 114
 		'type' => 'email_preview_buttons'
115 115
 	);
116
-	array_splice( $array, 5, 0, array( $custom_field ) );
116
+	array_splice($array, 5, 0, array($custom_field));
117 117
 
118 118
 	return $array; // splice in at position 3;
119 119
 }
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 function give_email_preview_buttons_callback() {
130 130
 	ob_start();
131 131
 	?>
132
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e( 'Donation Receipt Preview', 'give' ); ?> "><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
133
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
132
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e('Donation Receipt Preview', 'give'); ?> "><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
133
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
134 134
 		'give_action'  => 'send_test_email',
135 135
 		'give-message' => 'sent-test-email'
136
-	) ), 'give-test-email' ); ?>" title="<?php esc_attr_e( 'This will send a demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
136
+	)), 'give-test-email'); ?>" title="<?php esc_attr_e('This will send a demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
137 137
 	<?php
138 138
 	echo ob_get_clean();
139 139
 }
@@ -146,27 +146,27 @@  discard block
 block discarded – undo
146 146
  */
147 147
 function give_display_email_template_preview() {
148 148
 
149
-	if ( empty( $_GET['give_action'] ) ) {
149
+	if (empty($_GET['give_action'])) {
150 150
 		return;
151 151
 	}
152 152
 
153
-	if ( 'preview_email' !== $_GET['give_action'] ) {
153
+	if ('preview_email' !== $_GET['give_action']) {
154 154
 		return;
155 155
 	}
156 156
 
157
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
157
+	if ( ! current_user_can('manage_give_settings')) {
158 158
 		return;
159 159
 	}
160 160
 
161
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
161
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
162 162
 
163
-	echo Give()->emails->build_email( give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ) );
163
+	echo Give()->emails->build_email(give_email_preview_template_tags(give_get_email_body_content(0, array())));
164 164
 
165 165
 	exit;
166 166
 
167 167
 }
168 168
 
169
-add_action( 'template_redirect', 'give_display_email_template_preview' );
169
+add_action('template_redirect', 'give_display_email_template_preview');
170 170
 
171 171
 /**
172 172
  * Email Template Body
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return string $email_body Body of the email
180 180
  */
181
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
181
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
182 182
 
183 183
 	global $give_options;
184 184
 
185 185
 	$default_email_body = give_get_default_donation_receipt_email();
186 186
 
187
-	$email = isset( $give_options['donation_receipt'] ) ? stripslashes( $give_options['donation_receipt'] ) : $default_email_body;
187
+	$email = isset($give_options['donation_receipt']) ? stripslashes($give_options['donation_receipt']) : $default_email_body;
188 188
 
189
-	$email_body = wpautop( $email );
189
+	$email_body = wpautop($email);
190 190
 
191
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
191
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
192 192
 
193
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
193
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
194 194
 }
195 195
 
196 196
 
@@ -206,41 +206,41 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return string $email_body Body of the email
208 208
  */
209
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
209
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
210 210
 	global $give_options;
211 211
 
212
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
213
-	$email     = give_get_payment_user_email( $payment_id );
212
+	$user_info = maybe_unserialize($payment_data['user_info']);
213
+	$email     = give_get_payment_user_email($payment_id);
214 214
 
215
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
216
-		$user_data = get_userdata( $user_info['id'] );
215
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
216
+		$user_data = get_userdata($user_info['id']);
217 217
 		$name      = $user_data->display_name;
218
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
219
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
218
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
219
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
220 220
 	} else {
221 221
 		$name = $email;
222 222
 	}
223 223
 
224
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
224
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
225 225
 
226
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n" . esc_html__( 'A donation has been made', 'give' ) . ".\n\n";
226
+	$default_email_body = esc_html__('Hello', 'give')."\n\n".esc_html__('A donation has been made', 'give').".\n\n";
227 227
 	$default_email_body .= sprintf(
228 228
 		/* translators: %s: form plural label */
229
-		esc_html__( '%s sold:', 'give' ),
229
+		esc_html__('%s sold:', 'give'),
230 230
 		give_get_forms_label_plural()
231
-	) . "\n\n";
231
+	)."\n\n";
232 232
 
233
-	$default_email_body .= esc_html__( 'Donor: ', 'give' ) . " " . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
234
-	$default_email_body .= esc_html__( 'Amount: ', 'give' ) . " " . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
235
-	$default_email_body .= esc_html__( 'Payment Method: ', 'give' ) . " " . $gateway . "\n\n";
233
+	$default_email_body .= esc_html__('Donor: ', 'give')." ".html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
234
+	$default_email_body .= esc_html__('Amount: ', 'give')." ".html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
235
+	$default_email_body .= esc_html__('Payment Method: ', 'give')." ".$gateway."\n\n";
236 236
 
237
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
237
+	$default_email_body .= esc_html__('Thank you', 'give');
238 238
 
239
-	$email = isset( $give_options['donation_notification'] ) ? stripslashes( $give_options['donation_notification'] ) : $default_email_body;
239
+	$email = isset($give_options['donation_notification']) ? stripslashes($give_options['donation_notification']) : $default_email_body;
240 240
 
241
-	$email_body = give_do_email_tags( $email, $payment_id );
241
+	$email_body = give_do_email_tags($email, $payment_id);
242 242
 
243
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
243
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
244 244
 }
245 245
 
246 246
 /**
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
  * @since  1.0
254 254
  */
255 255
 function give_render_receipt_in_browser() {
256
-	if ( ! isset( $_GET['payment_key'] ) ) {
257
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ) );
256
+	if ( ! isset($_GET['payment_key'])) {
257
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'));
258 258
 	}
259 259
 
260
-	$key = urlencode( $_GET['payment_key'] );
260
+	$key = urlencode($_GET['payment_key']);
261 261
 
262 262
 	ob_start();
263 263
 	//Disallows caching of the page
264
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
264
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
265 265
 	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
266 266
 	header("Cache-Control: post-check=0, pre-check=0", false);
267 267
 	header("Pragma: no-cache"); // HTTP/1.0
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	<!DOCTYPE html>
271 271
 	<html lang="en">
272 272
 		<head>
273
-			<title><?php esc_html_e( 'Donation Receipt', 'give' ); ?></title>
273
+			<title><?php esc_html_e('Donation Receipt', 'give'); ?></title>
274 274
 			<meta charset="utf-8" />
275 275
 
276 276
 			<!-- Further disallowing of caching of this page -->
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 
285 285
 			<?php wp_head(); ?>
286 286
 		</head>
287
-		<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
287
+		<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
288 288
 
289 289
 			<div id="give_receipt_wrapper">
290
-				<?php do_action( 'give_render_receipt_in_browser_before' ); ?>
291
-				<?php echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); ?>
292
-				<?php do_action( 'give_render_receipt_in_browser_after' ); ?>
290
+				<?php do_action('give_render_receipt_in_browser_before'); ?>
291
+				<?php echo do_shortcode('[give_receipt payment_key='.$key.']'); ?>
292
+				<?php do_action('give_render_receipt_in_browser_after'); ?>
293 293
 			</div>
294 294
 
295 295
 			<?php wp_footer(); ?>
@@ -300,4 +300,4 @@  discard block
 block discarded – undo
300 300
 	die();
301 301
 }
302 302
 
303
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
303
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +91 added lines, -91 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
 
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 function give_test_ajax_works() {
26 26
 
27 27
 	// Check if the Airplane Mode plugin is installed
28
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
28
+	if (class_exists('Airplane_Mode_Core')) {
29 29
 
30 30
 		$airplane = Airplane_Mode_Core::getInstance();
31 31
 
32
-		if ( method_exists( $airplane, 'enabled' ) ) {
32
+		if (method_exists($airplane, 'enabled')) {
33 33
 
34
-			if ( $airplane->enabled() ) {
34
+			if ($airplane->enabled()) {
35 35
 				return true;
36 36
 			}
37 37
 
38 38
 		} else {
39 39
 
40
-			if ( $airplane->check_status() == 'on' ) {
40
+			if ($airplane->check_status() == 'on') {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( get_transient( '_give_ajax_works' ) ) {
48
+	if (get_transient('_give_ajax_works')) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		)
58 58
 	);
59 59
 
60
-	$ajax  = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax  = wp_remote_post(give_get_ajax_url(), $params);
61 61
 	$works = true;
62 62
 
63
-	if ( is_wp_error( $ajax ) ) {
63
+	if (is_wp_error($ajax)) {
64 64
 
65 65
 		$works = false;
66 66
 
67 67
 	} else {
68 68
 
69
-		if ( empty( $ajax['response'] ) ) {
69
+		if (empty($ajax['response'])) {
70 70
 			$works = false;
71 71
 		}
72 72
 
73
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
73
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
74 74
 			$works = false;
75 75
 		}
76 76
 
77
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
77
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
78 78
 			$works = false;
79 79
 		}
80 80
 
81
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
81
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
82 82
 			$works = false;
83 83
 		}
84 84
 
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
87
+	if ($works) {
88
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
  * @return string
100 100
  */
101 101
 function give_get_ajax_url() {
102
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
102
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
103 103
 
104 104
 	$current_url = give_get_current_page_url();
105
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
105
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
106 106
 
107
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
108
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
107
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
108
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_ajax_url', $ajax_url );
111
+	return apply_filters('give_ajax_url', $ajax_url);
112 112
 }
113 113
 
114 114
 /**
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
  * @return void
119 119
  */
120 120
 function give_load_checkout_login_fields() {
121
-	do_action( 'give_purchase_form_login_fields' );
121
+	do_action('give_purchase_form_login_fields');
122 122
 	give_die();
123 123
 }
124 124
 
125
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
125
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
126 126
 
127 127
 /**
128 128
  * Load Checkout Fields
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
  * @return void
132 132
  */
133 133
 function give_load_checkout_fields() {
134
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
134
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
135 135
 
136 136
 	ob_start();
137 137
 
138
-	do_action( 'give_purchase_form_register_login_fields', $form_id );
138
+	do_action('give_purchase_form_register_login_fields', $form_id);
139 139
 
140 140
 	$fields = ob_get_clean();
141 141
 
142
-	wp_send_json( array(
143
-		'fields' => wp_json_encode( $fields ),
144
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
145
-	) );
142
+	wp_send_json(array(
143
+		'fields' => wp_json_encode($fields),
144
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
145
+	));
146 146
 }
147 147
 
148
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
149
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
148
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
149
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
150 150
 
151 151
 /**
152 152
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
  * @return void
156 156
  */
157 157
 function give_ajax_get_form_title() {
158
-	if ( isset( $_POST['form_id'] ) ) {
159
-		$title = get_the_title( $_POST['form_id'] );
160
-		if ( $title ) {
158
+	if (isset($_POST['form_id'])) {
159
+		$title = get_the_title($_POST['form_id']);
160
+		if ($title) {
161 161
 			echo $title;
162 162
 		} else {
163 163
 			echo 'fail';
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	give_die();
167 167
 }
168 168
 
169
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
170
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
169
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
170
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
171 171
 
172 172
 /**
173 173
  * Retrieve a states drop down
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function give_ajax_get_states_field() {
179 179
 
180
-	if ( empty( $_POST['country'] ) ) {
180
+	if (empty($_POST['country'])) {
181 181
 		$_POST['country'] = give_get_country();
182 182
 	}
183
-	$states = give_get_states( $_POST['country'] );
183
+	$states = give_get_states($_POST['country']);
184 184
 
185
-	if ( ! empty( $states ) ) {
185
+	if ( ! empty($states)) {
186 186
 
187 187
 		$args = array(
188 188
 			'name'             => $_POST['field_name'],
189 189
 			'id'               => $_POST['field_name'],
190
-			'class'            => $_POST['field_name'] . '  give-select',
191
-			'options'          => give_get_states( $_POST['country'] ),
190
+			'class'            => $_POST['field_name'].'  give-select',
191
+			'options'          => give_get_states($_POST['country']),
192 192
 			'show_option_all'  => false,
193 193
 			'show_option_none' => false
194 194
 		);
195 195
 
196
-		$response = Give()->html->select( $args );
196
+		$response = Give()->html->select($args);
197 197
 
198 198
 	} else {
199 199
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	give_die();
206 206
 }
207 207
 
208
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
209
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
208
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
209
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
210 210
 
211 211
 /**
212 212
  * Retrieve a states drop down
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 function give_ajax_form_search() {
218 218
 	global $wpdb;
219 219
 
220
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
220
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
221 221
 	$results = array();
222
-	if ( current_user_can( 'edit_give_forms' ) ) {
223
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
222
+	if (current_user_can('edit_give_forms')) {
223
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
224 224
 	} else {
225
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
225
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
226 226
 	}
227 227
 
228
-	if ( $items ) {
228
+	if ($items) {
229 229
 
230
-		foreach ( $items as $item ) {
230
+		foreach ($items as $item) {
231 231
 
232 232
 			$results[] = array(
233 233
 				'id'   => $item->ID,
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 
240 240
 		$items[] = array(
241 241
 			'id'   => 0,
242
-			'name' => esc_html__( 'No results found', 'give' )
242
+			'name' => esc_html__('No results found', 'give')
243 243
 		);
244 244
 
245 245
 	}
246 246
 
247
-	echo json_encode( $results );
247
+	echo json_encode($results);
248 248
 
249 249
 	give_die();
250 250
 }
251 251
 
252
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
253
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
252
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
253
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
254 254
 
255 255
 /**
256 256
  * Search the donors database via Ajax
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
 function give_ajax_donor_search() {
262 262
 	global $wpdb;
263 263
 
264
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
264
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
265 265
 	$results = array();
266
-	if ( ! current_user_can( 'view_give_reports' ) ) {
266
+	if ( ! current_user_can('view_give_reports')) {
267 267
 		$donors = array();
268 268
 	} else {
269
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
269
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
270 270
 	}
271 271
 
272
-	if ( $donors ) {
272
+	if ($donors) {
273 273
 
274
-		foreach ( $donors as $donor ) {
274
+		foreach ($donors as $donor) {
275 275
 
276 276
 			$results[] = array(
277 277
 				'id'   => $donor->id,
278
-				'name' => $donor->name . '(' . $donor->email . ')'
278
+				'name' => $donor->name.'('.$donor->email.')'
279 279
 			);
280 280
 		}
281 281
 
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$donors[] = array(
285 285
 			'id'   => 0,
286
-			'name' => esc_html__( 'No results found', 'give' )
286
+			'name' => esc_html__('No results found', 'give')
287 287
 		);
288 288
 
289 289
 	}
290 290
 
291
-	echo json_encode( $results );
291
+	echo json_encode($results);
292 292
 
293 293
 	give_die();
294 294
 }
295 295
 
296
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
296
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
297 297
 
298 298
 
299 299
 /**
@@ -304,42 +304,42 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function give_ajax_search_users() {
306 306
 
307
-	if ( current_user_can( 'manage_give_settings' ) ) {
307
+	if (current_user_can('manage_give_settings')) {
308 308
 
309
-		$search_query = trim( $_POST['user_name'] );
310
-		$exclude      = trim( $_POST['exclude'] );
309
+		$search_query = trim($_POST['user_name']);
310
+		$exclude      = trim($_POST['exclude']);
311 311
 
312 312
 		$get_users_args = array(
313 313
 			'number' => 9999,
314
-			'search' => $search_query . '*'
314
+			'search' => $search_query.'*'
315 315
 		);
316 316
 
317
-		if ( ! empty( $exclude ) ) {
318
-			$exclude_array             = explode( ',', $exclude );
317
+		if ( ! empty($exclude)) {
318
+			$exclude_array             = explode(',', $exclude);
319 319
 			$get_users_args['exclude'] = $exclude_array;
320 320
 		}
321 321
 
322
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
322
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
323 323
 
324
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
324
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
325 325
 
326 326
 		$user_list = '<ul>';
327
-		if ( $found_users ) {
328
-			foreach ( $found_users as $user ) {
329
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr__( $user->ID ) . '" data-login="' . esc_attr__( $user->user_login ) . '">' . esc_html__( $user->user_login ) . '</a></li>';
327
+		if ($found_users) {
328
+			foreach ($found_users as $user) {
329
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr__($user->ID).'" data-login="'.esc_attr__($user->user_login).'">'.esc_html__($user->user_login).'</a></li>';
330 330
 			}
331 331
 		} else {
332
-			$user_list .= '<li>' . esc_html__( 'No users found', 'give' ) . '</li>';
332
+			$user_list .= '<li>'.esc_html__('No users found', 'give').'</li>';
333 333
 		}
334 334
 		$user_list .= '</ul>';
335 335
 
336
-		echo json_encode( array( 'results' => $user_list ) );
336
+		echo json_encode(array('results' => $user_list));
337 337
 
338 338
 	}
339 339
 	die();
340 340
 }
341 341
 
342
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
342
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
343 343
 
344 344
 
345 345
 /**
@@ -350,32 +350,32 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function give_check_for_form_price_variations() {
352 352
 
353
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
354
-		die( '-1' );
353
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
354
+		die('-1');
355 355
 	}
356 356
 
357
-	$form_id = intval( $_POST['form_id'] );
358
-	$form    = get_post( $form_id );
357
+	$form_id = intval($_POST['form_id']);
358
+	$form    = get_post($form_id);
359 359
 
360
-	if ( 'give_forms' != $form->post_type ) {
361
-		die( '-2' );
360
+	if ('give_forms' != $form->post_type) {
361
+		die('-2');
362 362
 	}
363 363
 
364
-	if ( give_has_variable_prices( $form_id ) ) {
365
-		$variable_prices = give_get_variable_prices( $form_id );
364
+	if (give_has_variable_prices($form_id)) {
365
+		$variable_prices = give_get_variable_prices($form_id);
366 366
 
367
-		if ( $variable_prices ) {
367
+		if ($variable_prices) {
368 368
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
369 369
 
370
-			if ( isset( $_POST['all_prices'] ) ) {
371
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
370
+			if (isset($_POST['all_prices'])) {
371
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
372 372
 			}
373 373
 
374
-			foreach ( $variable_prices as $key => $price ) {
374
+			foreach ($variable_prices as $key => $price) {
375 375
 
376
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html__( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
376
+				$level_text = ! empty($price['_give_text']) ? esc_html__($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
377 377
 				
378
-				$ajax_response .= '<option value="' . esc_attr__( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
378
+				$ajax_response .= '<option value="'.esc_attr__($price['_give_id']['level_id']).'">'.$level_text.'</option>';
379 379
 			}
380 380
 			$ajax_response .= '</select>';
381 381
 			echo $ajax_response;
@@ -386,4 +386,4 @@  discard block
 block discarded – undo
386 386
 	give_die();
387 387
 }
388 388
 
389
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
389
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
Please login to merge, or discard this patch.