Completed
Push — master ( 3a38e3...ef1f70 )
by Devin
94:39 queued 74:43
created
includes/admin/forms/dashboard-columns.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	//Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => esc_html__( 'Name', 'give' ),
36
-		'form_category' => esc_html__( 'Categories', 'give' ),
37
-		'form_tag'      => esc_html__( 'Tags', 'give' ),
38
-		'price'         => esc_html__( 'Price', 'give' ),
39
-		'goal'          => esc_html__( 'Goal', 'give' ),
40
-		'donations'     => esc_html__( 'Donations', 'give' ),
41
-		'earnings'      => esc_html__( 'Income', 'give' ),
42
-		'shortcode'     => esc_html__( 'Shortcode', 'give' ),
43
-		'date'          => esc_html__( 'Date', 'give' )
35
+		'title'         => esc_html__('Name', 'give'),
36
+		'form_category' => esc_html__('Categories', 'give'),
37
+		'form_tag'      => esc_html__('Tags', 'give'),
38
+		'price'         => esc_html__('Price', 'give'),
39
+		'goal'          => esc_html__('Goal', 'give'),
40
+		'donations'     => esc_html__('Donations', 'give'),
41
+		'earnings'      => esc_html__('Income', 'give'),
42
+		'shortcode'     => esc_html__('Shortcode', 'give'),
43
+		'date'          => esc_html__('Date', 'give')
44 44
 	);
45 45
 
46 46
 	//Does the user want categories / tags?
47
-	if ( give_get_option( 'enable_categories' ) !== 'on' ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if (give_get_option('enable_categories') !== 'on') {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( give_get_option( 'enable_tags' ) !== 'on' ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if (give_get_option('enable_tags') !== 'on') {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,60 +66,60 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 		
72
-		switch ( $column_name ) {
72
+		switch ($column_name) {
73 73
 			case 'form_category':
74
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
74
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
75 75
 				break;
76 76
 			case 'form_tag':
77
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
77
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
78 78
 				break;
79 79
 			case 'price':
80
-				if ( give_has_variable_prices( $post_id ) ) {
81
-					echo give_price_range( $post_id );
80
+				if (give_has_variable_prices($post_id)) {
81
+					echo give_price_range($post_id);
82 82
 				} else {
83
-					echo give_price( $post_id, false );
84
-					echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />';
83
+					echo give_price($post_id, false);
84
+					echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />';
85 85
 				}
86 86
 				break;
87 87
 			case 'goal':
88
-				$goal_option = get_post_meta( $post_id, '_give_goal_option', true );
89
-				if ( ! empty( $goal_option ) && $goal_option === 'yes' ) {
90
-					echo give_goal( $post_id, false );
88
+				$goal_option = get_post_meta($post_id, '_give_goal_option', true);
89
+				if ( ! empty($goal_option) && $goal_option === 'yes') {
90
+					echo give_goal($post_id, false);
91 91
 				} else {
92
-					echo esc_html__( 'No Goal Set', 'give' );
92
+					echo esc_html__('No Goal Set', 'give');
93 93
 				}
94 94
 
95
-				echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />';
95
+				echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />';
96 96
 				break;
97 97
 			case 'donations':
98
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
99
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">';
100
-					echo give_get_form_sales_stats( $post_id );
98
+				if (current_user_can('view_give_form_stats', $post_id)) {
99
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">';
100
+					echo give_get_form_sales_stats($post_id);
101 101
 					echo '</a>';
102 102
 				} else {
103 103
 					echo '-';
104 104
 				}
105 105
 				break;
106 106
 			case 'earnings':
107
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
108
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">';
109
-					echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) );
107
+				if (current_user_can('view_give_form_stats', $post_id)) {
108
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">';
109
+					echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
110 110
 					echo '</a>';
111 111
 				} else {
112 112
 					echo '-';
113 113
 				}
114 114
 				break;
115 115
 			case 'shortcode':
116
-				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint( $post_id ) . '&#34;]">';
116
+				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;'.absint($post_id).'&#34;]">';
117 117
 				break;
118 118
 		}
119 119
 	}
120 120
 }
121 121
 
122
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
122
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
123 123
 
124 124
 /**
125 125
  * Registers the sortable columns in the list table
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
  *
131 131
  * @return array $columns Array of sortable columns
132 132
  */
133
-function give_sortable_form_columns( $columns ) {
133
+function give_sortable_form_columns($columns) {
134 134
 	$columns['price']    = 'price';
135 135
 	$columns['sales']    = 'sales';
136 136
 	$columns['earnings'] = 'earnings';
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	return $columns;
140 140
 }
141 141
 
142
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
142
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
143 143
 
144 144
 /**
145 145
  * Sorts Columns in the Forms List Table
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
  *
151 151
  * @return array $vars Array of all the sort variables
152 152
  */
153
-function give_sort_forms( $vars ) {
153
+function give_sort_forms($vars) {
154 154
 	// Check if we're viewing the "give_forms" post type
155
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
155
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
156 156
 		// Check if 'orderby' is set to "sales"
157
-		if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
157
+		if (isset($vars['orderby']) && 'sales' == $vars['orderby']) {
158 158
 			$vars = array_merge(
159 159
 				$vars,
160 160
 				array(
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 
167 167
 		// Check if "orderby" is set to "earnings"
168
-		if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
168
+		if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) {
169 169
 			$vars = array_merge(
170 170
 				$vars,
171 171
 				array(
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		}
177 177
 
178 178
 		// Check if "orderby" is set to "price"
179
-		if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
179
+		if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
180 180
 			$vars = array_merge(
181 181
 				$vars,
182 182
 				array(
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 
189 189
 		// Check if "orderby" is set to "goal"
190
-		if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) {
190
+		if (isset($vars['orderby']) && 'goal' == $vars['orderby']) {
191 191
 			$vars = array_merge(
192 192
 				$vars,
193 193
 				array(
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return array       Array of all sort variables
212 212
  */
213
-function give_filter_forms( $vars ) {
214
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
213
+function give_filter_forms($vars) {
214
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
215 215
 
216 216
 		// If an author ID was passed, use it
217
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
217
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
218 218
 
219 219
 			$author_id = $_REQUEST['author'];
220
-			if ( (int) $author_id !== get_current_user_id() ) {
220
+			if ((int) $author_id !== get_current_user_id()) {
221 221
 				// Tried to view the products of another person, sorry
222
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
222
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
223 223
 			}
224 224
 			$vars = array_merge(
225 225
 				$vars,
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
  * @return void
245 245
  */
246 246
 function give_forms_load() {
247
-	add_filter( 'request', 'give_sort_forms' );
248
-	add_filter( 'request', 'give_filter_forms' );
247
+	add_filter('request', 'give_sort_forms');
248
+	add_filter('request', 'give_filter_forms');
249 249
 }
250 250
 
251
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
251
+add_action('load-edit.php', 'give_forms_load', 9999);
252 252
 
253 253
 /**
254 254
  * Remove Forms Month Filter
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
  * @global      $typenow The post type we are viewing
263 263
  * @return array Empty array disables the dropdown
264 264
  */
265
-function give_remove_month_filter( $dates ) {
265
+function give_remove_month_filter($dates) {
266 266
 	global $typenow;
267 267
 
268
-	if ( $typenow == 'give_forms' ) {
268
+	if ($typenow == 'give_forms') {
269 269
 		$dates = array();
270 270
 	}
271 271
 
272 272
 	return $dates;
273 273
 }
274 274
 
275
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
275
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
276 276
 
277 277
 /**
278 278
  * Adds price field to Quick Edit options
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
  *
285 285
  * @return void
286 286
  */
287
-function give_price_field_quick_edit( $column_name, $post_type ) {
288
-	if ( $column_name != 'price' || $post_type != 'give_forms' ) {
287
+function give_price_field_quick_edit($column_name, $post_type) {
288
+	if ($column_name != 'price' || $post_type != 'give_forms') {
289 289
 		return;
290 290
 	}
291 291
 	?>
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 			<h4><?php 
295 295
 				printf(
296 296
 					/* translators: %s: forms singular label */
297
-					esc_html__( '%s Configuration', 'give' ),
297
+					esc_html__('%s Configuration', 'give'),
298 298
 					give_get_forms_label_singular()
299 299
 				);
300 300
 			?></h4>
301 301
 			<label>
302
-				<span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span>
302
+				<span class="title"><?php esc_html_e('Price', 'give'); ?></span>
303 303
 				<span class="input-text-wrap">
304 304
 					<input type="text" name="_give_regprice" class="text regprice" />
305 305
 				</span>
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	<?php
311 311
 }
312 312
 
313
-add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
314
-add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
313
+add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
314
+add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
315 315
 
316 316
 /**
317 317
  * Updates price when saving post
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
  *
323 323
  * @return void
324 324
  */
325
-function give_price_save_quick_edit( $post_id ) {
326
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
325
+function give_price_save_quick_edit($post_id) {
326
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
327 327
 		return;
328 328
 	}
329
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
329
+	if ( ! current_user_can('edit_post', $post_id)) {
330 330
 		return $post_id;
331 331
 	}
332
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
332
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
333 333
 		return $post_id;
334 334
 	}
335 335
 
336
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
337
-		update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) );
336
+	if (isset($_REQUEST['_give_regprice'])) {
337
+		update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice'])));
338 338
 	}
339 339
 }
340 340
 
341
-add_action( 'save_post', 'give_price_save_quick_edit' );
341
+add_action('save_post', 'give_price_save_quick_edit');
342 342
 
343 343
 /**
344 344
  * Process bulk edit actions via AJAX
@@ -348,18 +348,18 @@  discard block
 block discarded – undo
348 348
  */
349 349
 function give_save_bulk_edit() {
350 350
 
351
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
351
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
352 352
 
353
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
354
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
355
-		foreach ( $post_ids as $post_id ) {
353
+	if ( ! empty($post_ids) && is_array($post_ids)) {
354
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
355
+		foreach ($post_ids as $post_id) {
356 356
 
357
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
357
+			if ( ! current_user_can('edit_post', $post_id)) {
358 358
 				continue;
359 359
 			}
360 360
 
361
-			if ( ! empty( $price ) ) {
362
-				update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) );
361
+			if ( ! empty($price)) {
362
+				update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price));
363 363
 			}
364 364
 		}
365 365
 	}
@@ -367,4 +367,4 @@  discard block
 block discarded – undo
367 367
 	die();
368 368
 }
369 369
 
370
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
370
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.