Completed
Pull Request — master (#507)
by Devin
12:54
created
includes/admin/forms/metabox.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Metabox Functions
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Forms
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * Metabox Functions
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Forms
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 // Exit if accessed directly
15 15
 if (!defined('ABSPATH')) {
16
-    exit;
16
+	exit;
17 17
 }
18 18
 
19 19
 /**
@@ -25,71 +25,71 @@  discard block
 block discarded – undo
25 25
 function give_test_ajax_works()
26 26
 {
27 27
 
28
-    // Check if the Airplane Mode plugin is installed
29
-    if (class_exists('Airplane_Mode_Core')) {
28
+	// Check if the Airplane Mode plugin is installed
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31
-        $airplane = Airplane_Mode_Core::getInstance();
31
+		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-        if (method_exists($airplane, 'enabled')) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-            if ($airplane->enabled()) {
36
-                return true;
37
-            }
35
+			if ($airplane->enabled()) {
36
+				return true;
37
+			}
38 38
 
39
-        } else {
39
+		} else {
40 40
 
41
-            if ($airplane->check_status() == 'on') {
42
-                return true;
43
-            }
44
-        }
45
-    }
41
+			if ($airplane->check_status() == 'on') {
42
+				return true;
43
+			}
44
+		}
45
+	}
46 46
 
47
-    add_filter('block_local_requests', '__return_false');
47
+	add_filter('block_local_requests', '__return_false');
48 48
 
49
-    if (get_transient('_give_ajax_works')) {
50
-        return true;
51
-    }
49
+	if (get_transient('_give_ajax_works')) {
50
+		return true;
51
+	}
52 52
 
53
-    $params = array(
54
-        'sslverify' => false,
55
-        'timeout' => 30,
56
-        'body' => array(
57
-            'action' => 'give_test_ajax'
58
-        )
59
-    );
53
+	$params = array(
54
+		'sslverify' => false,
55
+		'timeout' => 30,
56
+		'body' => array(
57
+			'action' => 'give_test_ajax'
58
+		)
59
+	);
60 60
 
61
-    $ajax = wp_remote_post(give_get_ajax_url(), $params);
62
-    $works = true;
61
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
62
+	$works = true;
63 63
 
64
-    if (is_wp_error($ajax)) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66
-        $works = false;
66
+		$works = false;
67 67
 
68
-    } else {
68
+	} else {
69 69
 
70
-        if (empty($ajax['response'])) {
71
-            $works = false;
72
-        }
70
+		if (empty($ajax['response'])) {
71
+			$works = false;
72
+		}
73 73
 
74
-        if (empty($ajax['response']['code']) || 200 !== (int)$ajax['response']['code']) {
75
-            $works = false;
76
-        }
74
+		if (empty($ajax['response']['code']) || 200 !== (int)$ajax['response']['code']) {
75
+			$works = false;
76
+		}
77 77
 
78
-        if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79
-            $works = false;
80
-        }
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79
+			$works = false;
80
+		}
81 81
 
82
-        if (!isset($ajax['body']) || 0 !== (int)$ajax['body']) {
83
-            $works = false;
84
-        }
82
+		if (!isset($ajax['body']) || 0 !== (int)$ajax['body']) {
83
+			$works = false;
84
+		}
85 85
 
86
-    }
86
+	}
87 87
 
88
-    if ($works) {
89
-        set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
90
-    }
88
+	if ($works) {
89
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
90
+	}
91 91
 
92
-    return $works;
92
+	return $works;
93 93
 }
94 94
 
95 95
 
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
  */
102 102
 function give_get_ajax_url()
103 103
 {
104
-    $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
105 105
 
106
-    $current_url = give_get_current_page_url();
107
-    $ajax_url = admin_url('admin-ajax.php', $scheme);
106
+	$current_url = give_get_current_page_url();
107
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
108 108
 
109
-    if (preg_match('/^https/', $current_url) && !preg_match('/^https/', $ajax_url)) {
110
-        $ajax_url = preg_replace('/^http/', 'https', $ajax_url);
111
-    }
109
+	if (preg_match('/^https/', $current_url) && !preg_match('/^https/', $ajax_url)) {
110
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
111
+	}
112 112
 
113
-    return apply_filters('give_ajax_url', $ajax_url);
113
+	return apply_filters('give_ajax_url', $ajax_url);
114 114
 }
115 115
 
116 116
 /**
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
  */
122 122
 function give_load_checkout_login_fields()
123 123
 {
124
-    do_action('give_purchase_form_login_fields');
125
-    give_die();
124
+	do_action('give_purchase_form_login_fields');
125
+	give_die();
126 126
 }
127 127
 
128 128
 add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
  */
136 136
 function give_load_checkout_fields()
137 137
 {
138
-    $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
139
-    do_action('give_purchase_form', $form_id);
140
-    give_die();
138
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
139
+	do_action('give_purchase_form', $form_id);
140
+	give_die();
141 141
 }
142 142
 
143 143
 add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
  */
152 152
 function give_ajax_get_form_title()
153 153
 {
154
-    if (isset($_POST['form_id'])) {
155
-        $title = get_the_title($_POST['form_id']);
156
-        if ($title) {
157
-            echo $title;
158
-        } else {
159
-            echo 'fail';
160
-        }
161
-    }
162
-    give_die();
154
+	if (isset($_POST['form_id'])) {
155
+		$title = get_the_title($_POST['form_id']);
156
+		if ($title) {
157
+			echo $title;
158
+		} else {
159
+			echo 'fail';
160
+		}
161
+	}
162
+	give_die();
163 163
 }
164 164
 
165 165
 add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
@@ -174,32 +174,32 @@  discard block
 block discarded – undo
174 174
 function give_ajax_get_states_field()
175 175
 {
176 176
 
177
-    if (empty($_POST['country'])) {
178
-        $_POST['country'] = give_get_country();
179
-    }
180
-    $states = give_get_states($_POST['country']);
177
+	if (empty($_POST['country'])) {
178
+		$_POST['country'] = give_get_country();
179
+	}
180
+	$states = give_get_states($_POST['country']);
181 181
 
182
-    if (!empty($states)) {
182
+	if (!empty($states)) {
183 183
 
184
-        $args = array(
185
-            'name' => $_POST['field_name'],
186
-            'id' => $_POST['field_name'],
187
-            'class' => $_POST['field_name'] . '  give-select',
188
-            'options' => give_get_states($_POST['country']),
189
-            'show_option_all' => false,
190
-            'show_option_none' => false
191
-        );
184
+		$args = array(
185
+			'name' => $_POST['field_name'],
186
+			'id' => $_POST['field_name'],
187
+			'class' => $_POST['field_name'] . '  give-select',
188
+			'options' => give_get_states($_POST['country']),
189
+			'show_option_all' => false,
190
+			'show_option_none' => false
191
+		);
192 192
 
193
-        $response = Give()->html->select($args);
193
+		$response = Give()->html->select($args);
194 194
 
195
-    } else {
195
+	} else {
196 196
 
197
-        $response = 'nostates';
198
-    }
197
+		$response = 'nostates';
198
+	}
199 199
 
200
-    echo $response;
200
+	echo $response;
201 201
 
202
-    give_die();
202
+	give_die();
203 203
 }
204 204
 
205 205
 add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
@@ -213,38 +213,38 @@  discard block
 block discarded – undo
213 213
  */
214 214
 function give_ajax_form_search()
215 215
 {
216
-    global $wpdb;
216
+	global $wpdb;
217 217
 
218
-    $search = esc_sql(sanitize_text_field($_GET['s']));
219
-    $results = array();
220
-    if (current_user_can('edit_give_forms')) {
221
-        $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
222
-    } else {
223
-        $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");
224
-    }
218
+	$search = esc_sql(sanitize_text_field($_GET['s']));
219
+	$results = array();
220
+	if (current_user_can('edit_give_forms')) {
221
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
222
+	} else {
223
+		$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");
224
+	}
225 225
 
226
-    if ($items) {
226
+	if ($items) {
227 227
 
228
-        foreach ($items as $item) {
228
+		foreach ($items as $item) {
229 229
 
230
-            $results[] = array(
231
-                'id' => $item->ID,
232
-                'name' => $item->post_title
233
-            );
234
-        }
230
+			$results[] = array(
231
+				'id' => $item->ID,
232
+				'name' => $item->post_title
233
+			);
234
+		}
235 235
 
236
-    } else {
236
+	} else {
237 237
 
238
-        $items[] = array(
239
-            'id' => 0,
240
-            'name' => __('No results found', 'give')
241
-        );
238
+		$items[] = array(
239
+			'id' => 0,
240
+			'name' => __('No results found', 'give')
241
+		);
242 242
 
243
-    }
243
+	}
244 244
 
245
-    echo json_encode($results);
245
+	echo json_encode($results);
246 246
 
247
-    give_die();
247
+	give_die();
248 248
 }
249 249
 
250 250
 add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
@@ -258,38 +258,38 @@  discard block
 block discarded – undo
258 258
  */
259 259
 function give_ajax_donor_search()
260 260
 {
261
-    global $wpdb;
261
+	global $wpdb;
262 262
 
263
-    $search = esc_sql(sanitize_text_field($_GET['s']));
264
-    $results = array();
265
-    if (!current_user_can('view_give_reports')) {
266
-        $donors = array();
267
-    } else {
268
-        $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
269
-    }
263
+	$search = esc_sql(sanitize_text_field($_GET['s']));
264
+	$results = array();
265
+	if (!current_user_can('view_give_reports')) {
266
+		$donors = array();
267
+	} else {
268
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
269
+	}
270 270
 
271
-    if ($donors) {
271
+	if ($donors) {
272 272
 
273
-        foreach ($donors as $donor) {
273
+		foreach ($donors as $donor) {
274 274
 
275
-            $results[] = array(
276
-                'id' => $donor->id,
277
-                'name' => $donor->name . '(' . $donor->email . ')'
278
-            );
279
-        }
275
+			$results[] = array(
276
+				'id' => $donor->id,
277
+				'name' => $donor->name . '(' . $donor->email . ')'
278
+			);
279
+		}
280 280
 
281
-    } else {
281
+	} else {
282 282
 
283
-        $donors[] = array(
284
-            'id' => 0,
285
-            'name' => __('No results found', 'give')
286
-        );
283
+		$donors[] = array(
284
+			'id' => 0,
285
+			'name' => __('No results found', 'give')
286
+		);
287 287
 
288
-    }
288
+	}
289 289
 
290
-    echo json_encode($results);
290
+	echo json_encode($results);
291 291
 
292
-    give_die();
292
+	give_die();
293 293
 }
294 294
 
295 295
 add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
@@ -304,30 +304,30 @@  discard block
 block discarded – undo
304 304
 function give_ajax_search_users()
305 305
 {
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']);
309
+		$search_query = trim($_POST['user_name']);
310 310
 
311
-        $found_users = get_users(array(
312
-                'number' => 9999,
313
-                'search' => $search_query . '*'
314
-            )
315
-        );
311
+		$found_users = get_users(array(
312
+				'number' => 9999,
313
+				'search' => $search_query . '*'
314
+			)
315
+		);
316 316
 
317
-        $user_list = '<ul>';
318
-        if ($found_users) {
319
-            foreach ($found_users as $user) {
320
-                $user_list .= '<li><a href="#" data-login="' . esc_attr($user->user_login) . '">' . esc_html($user->user_login) . '</a></li>';
321
-            }
322
-        } else {
323
-            $user_list .= '<li>' . __('No users found', 'give') . '</li>';
324
-        }
325
-        $user_list .= '</ul>';
317
+		$user_list = '<ul>';
318
+		if ($found_users) {
319
+			foreach ($found_users as $user) {
320
+				$user_list .= '<li><a href="#" data-login="' . esc_attr($user->user_login) . '">' . esc_html($user->user_login) . '</a></li>';
321
+			}
322
+		} else {
323
+			$user_list .= '<li>' . __('No users found', 'give') . '</li>';
324
+		}
325
+		$user_list .= '</ul>';
326 326
 
327
-        echo json_encode(array('results' => $user_list));
327
+		echo json_encode(array('results' => $user_list));
328 328
 
329
-    }
330
-    die();
329
+	}
330
+	die();
331 331
 }
332 332
 
333 333
 add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
334 334
\ No newline at end of file
Please login to merge, or discard this patch.