Completed
Pull Request — master (#1637)
by Ravinder
16:50
created
includes/admin/reporting/class-export.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return bool Whether we can export or not
38 38
 	 */
39 39
 	public function can_export() {
40
-		return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) );
40
+		return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports'));
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 	 * @return void
49 49
 	 */
50 50
 	public function headers() {
51
-		ignore_user_abort( true );
51
+		ignore_user_abort(true);
52 52
 
53
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
54
-			set_time_limit( 0 );
53
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
54
+			set_time_limit(0);
55 55
 		}
56 56
 
57 57
 		nocache_headers();
58
-		header( 'Content-Type: text/csv; charset=utf-8' );
59
-		header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' );
60
-		header( "Expires: 0" );
58
+		header('Content-Type: text/csv; charset=utf-8');
59
+		header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv');
60
+		header("Expires: 0");
61 61
 	}
62 62
 
63 63
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function csv_cols() {
71 71
 		$cols = array(
72
-			'id'   => esc_html__( 'ID', 'give' ),
73
-			'date' => esc_html__( 'Date', 'give' )
72
+			'id'   => esc_html__('ID', 'give'),
73
+			'date' => esc_html__('Date', 'give')
74 74
 		);
75 75
 
76 76
 		return $cols;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	public function get_csv_cols() {
87 87
 		$cols = $this->csv_cols();
88 88
 
89
-		return apply_filters( "give_export_csv_cols_{$this->export_type}", $cols );
89
+		return apply_filters("give_export_csv_cols_{$this->export_type}", $cols);
90 90
 	}
91 91
 
92 92
 	/**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	public function csv_cols_out() {
101 101
 		$cols = $this->get_csv_cols();
102 102
 		$i    = 1;
103
-		foreach ( $cols as $col_id => $column ) {
104
-			echo '"' . addslashes( $column ) . '"';
105
-			echo $i == count( $cols ) ? '' : ',';
106
-			$i ++;
103
+		foreach ($cols as $col_id => $column) {
104
+			echo '"'.addslashes($column).'"';
105
+			echo $i == count($cols) ? '' : ',';
106
+			$i++;
107 107
 		}
108 108
 		echo "\r\n";
109 109
 	}
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 		$data = array(
121 121
 			0 => array(
122 122
 				'id'   => '',
123
-				'data' => date( 'F j, Y' )
123
+				'data' => date('F j, Y')
124 124
 			),
125 125
 			1 => array(
126 126
 				'id'   => '',
127
-				'data' => date( 'F j, Y' )
127
+				'data' => date('F j, Y')
128 128
 			)
129 129
 		);
130 130
 
131
-		$data = apply_filters( 'give_export_get_data', $data );
132
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
131
+		$data = apply_filters('give_export_get_data', $data);
132
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
133 133
 
134 134
 		return $data;
135 135
 	}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		$cols = $this->get_csv_cols();
148 148
 
149 149
 		// Output each row
150
-		foreach ( $data as $row ) {
150
+		foreach ($data as $row) {
151 151
 			$i = 1;
152
-			foreach ( $row as $col_id => $column ) {
152
+			foreach ($row as $col_id => $column) {
153 153
 				// Make sure the column is valid
154
-				if ( array_key_exists( $col_id, $cols ) ) {
155
-					echo '"' . addslashes( $column ) . '"';
156
-					echo $i == count( $cols ) ? '' : ',';
157
-					$i ++;
154
+				if (array_key_exists($col_id, $cols)) {
155
+					echo '"'.addslashes($column).'"';
156
+					echo $i == count($cols) ? '' : ',';
157
+					$i++;
158 158
 				}
159 159
 			}
160 160
 			echo "\r\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @return void
174 174
 	 */
175 175
 	public function export() {
176
-		if ( ! $this->can_export() ) {
177
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
176
+		if ( ! $this->can_export()) {
177
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
178 178
 		}
179 179
 
180 180
 		// Set headers
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-forms.php 1 patch
Spacing   +53 added lines, -53 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
 
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	public function csv_cols() {
42 42
 
43 43
 		$cols = array(
44
-			'ID'                      => esc_html__( 'ID', 'give' ),
45
-			'post_name'               => esc_html__( 'Slug', 'give' ),
46
-			'post_title'              => esc_html__( 'Name', 'give' ),
47
-			'post_date'               => esc_html__( 'Date Created', 'give' ),
48
-			'post_author'             => esc_html__( 'Author', 'give' ),
49
-			'post_content'            => esc_html__( 'Description', 'give' ),
50
-			'post_excerpt'            => esc_html__( 'Excerpt', 'give' ),
51
-			'post_status'             => esc_html__( 'Status', 'give' ),
52
-			'categories'              => esc_html__( 'Categories', 'give' ),
53
-			'tags'                    => esc_html__( 'Tags', 'give' ),
54
-			'give_price'              => esc_html__( 'Price', 'give' ),
55
-			'_thumbnail_id'           => esc_html__( 'Featured Image', 'give' ),
56
-			'_give_form_sales'        => esc_html__( 'Donations', 'give' ),
57
-			'_give_download_earnings' => esc_html__( 'Income', 'give' ),
44
+			'ID'                      => esc_html__('ID', 'give'),
45
+			'post_name'               => esc_html__('Slug', 'give'),
46
+			'post_title'              => esc_html__('Name', 'give'),
47
+			'post_date'               => esc_html__('Date Created', 'give'),
48
+			'post_author'             => esc_html__('Author', 'give'),
49
+			'post_content'            => esc_html__('Description', 'give'),
50
+			'post_excerpt'            => esc_html__('Excerpt', 'give'),
51
+			'post_status'             => esc_html__('Status', 'give'),
52
+			'categories'              => esc_html__('Categories', 'give'),
53
+			'tags'                    => esc_html__('Tags', 'give'),
54
+			'give_price'              => esc_html__('Price', 'give'),
55
+			'_thumbnail_id'           => esc_html__('Featured Image', 'give'),
56
+			'_give_form_sales'        => esc_html__('Donations', 'give'),
57
+			'_give_download_earnings' => esc_html__('Income', 'give'),
58 58
 		);
59 59
 
60 60
 		return $cols;
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step
87 87
 		);
88 88
 
89
-		$downloads = new WP_Query( $args );
89
+		$downloads = new WP_Query($args);
90 90
 
91
-		if ( $downloads->posts ) {
92
-			foreach ( $downloads->posts as $download ) {
91
+		if ($downloads->posts) {
92
+			foreach ($downloads->posts as $download) {
93 93
 
94 94
 				$row = array();
95 95
 
96
-				foreach ( $this->csv_cols() as $key => $value ) {
96
+				foreach ($this->csv_cols() as $key => $value) {
97 97
 
98 98
 					// Setup default value
99
-					$row[ $key ] = '';
99
+					$row[$key] = '';
100 100
 
101
-					if ( in_array( $key, $meta ) ) {
101
+					if (in_array($key, $meta)) {
102 102
 
103
-						switch ( $key ) {
103
+						switch ($key) {
104 104
 
105 105
 							case '_thumbnail_id' :
106 106
 
107
-								$image_id    = get_post_thumbnail_id( $download->ID );
108
-								$row[ $key ] = wp_get_attachment_url( $image_id );
107
+								$image_id    = get_post_thumbnail_id($download->ID);
108
+								$row[$key] = wp_get_attachment_url($image_id);
109 109
 
110 110
 								break;
111 111
 
112 112
 							case 'give_price' :
113 113
 
114
-								if ( give_has_variable_prices( $download->ID ) ) {
114
+								if (give_has_variable_prices($download->ID)) {
115 115
 
116 116
 									$prices = array();
117
-									foreach ( give_get_variable_prices( $download->ID ) as $price ) {
118
-										$prices[] = $price['name'] . ': ' . $price['amount'];
117
+									foreach (give_get_variable_prices($download->ID) as $price) {
118
+										$prices[] = $price['name'].': '.$price['amount'];
119 119
 									}
120 120
 
121
-									$row[ $key ] = implode( ' | ', $prices );
121
+									$row[$key] = implode(' | ', $prices);
122 122
 
123 123
 								} else {
124 124
 
125
-									$row[ $key ] = give_get_download_price( $download->ID );
125
+									$row[$key] = give_get_download_price($download->ID);
126 126
 
127 127
 								}
128 128
 
@@ -132,54 +132,54 @@  discard block
 block discarded – undo
132 132
 
133 133
 
134 134
 								$files = array();
135
-								foreach ( give_get_download_files( $download->ID ) as $file ) {
135
+								foreach (give_get_download_files($download->ID) as $file) {
136 136
 									$files[] = $file['file'];
137 137
 								}
138 138
 
139
-								$row[ $key ] = implode( ' | ', $files );
139
+								$row[$key] = implode(' | ', $files);
140 140
 
141 141
 								break;
142 142
 
143 143
 							default :
144 144
 
145
-								$row[ $key ] = get_post_meta( $download->ID, $key, true );
145
+								$row[$key] = get_post_meta($download->ID, $key, true);
146 146
 
147 147
 								break;
148 148
 
149 149
 						}
150 150
 
151
-					} elseif ( isset( $download->$key ) ) {
151
+					} elseif (isset($download->$key)) {
152 152
 
153
-						switch ( $key ) {
153
+						switch ($key) {
154 154
 
155 155
 							case 'post_author' :
156 156
 
157
-								$row[ $key ] = get_the_author_meta( 'user_login', $download->post_author );
157
+								$row[$key] = get_the_author_meta('user_login', $download->post_author);
158 158
 
159 159
 								break;
160 160
 
161 161
 							default :
162 162
 
163
-								$row[ $key ] = $download->$key;
163
+								$row[$key] = $download->$key;
164 164
 
165 165
 								break;
166 166
 						}
167 167
 
168
-					} elseif ( 'tags' == $key ) {
168
+					} elseif ('tags' == $key) {
169 169
 
170
-						$terms = get_the_terms( $download->ID, 'download_tag' );
171
-						if ( $terms ) {
172
-							$terms       = wp_list_pluck( $terms, 'name' );
173
-							$row[ $key ] = implode( ' | ', $terms );
170
+						$terms = get_the_terms($download->ID, 'download_tag');
171
+						if ($terms) {
172
+							$terms       = wp_list_pluck($terms, 'name');
173
+							$row[$key] = implode(' | ', $terms);
174 174
 						}
175 175
 
176 176
 
177
-					} elseif ( 'categories' == $key ) {
177
+					} elseif ('categories' == $key) {
178 178
 
179
-						$terms = get_the_terms( $download->ID, 'download_category' );
180
-						if ( $terms ) {
181
-							$terms       = wp_list_pluck( $terms, 'name' );
182
-							$row[ $key ] = implode( ' | ', $terms );
179
+						$terms = get_the_terms($download->ID, 'download_category');
180
+						if ($terms) {
181
+							$terms       = wp_list_pluck($terms, 'name');
182
+							$row[$key] = implode(' | ', $terms);
183 183
 						}
184 184
 
185 185
 					}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 
191 191
 			}
192 192
 
193
-			$data = apply_filters( 'give_export_get_data', $data );
194
-			$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
193
+			$data = apply_filters('give_export_get_data', $data);
194
+			$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
195 195
 
196 196
 			return $data;
197 197
 		}
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$args = array(
212 212
 			'post_type'      => 'give_forms',
213
-			'posts_per_page' => - 1,
213
+			'posts_per_page' => -1,
214 214
 			'post_status'    => 'any',
215 215
 			'fields'         => 'ids',
216 216
 		);
217 217
 
218
-		$downloads  = new WP_Query( $args );
218
+		$downloads  = new WP_Query($args);
219 219
 		$total      = (int) $downloads->post_count;
220 220
 		$percentage = 100;
221 221
 
222
-		if ( $total > 0 ) {
223
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
222
+		if ($total > 0) {
223
+			$percentage = ((30 * $this->step) / $total) * 100;
224 224
 		}
225 225
 
226
-		if ( $percentage > 100 ) {
226
+		if ($percentage > 100) {
227 227
 			$percentage = 100;
228 228
 		}
229 229
 
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
19
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
18
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php';
19
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php';
20 20
 
21 21
 /**
22 22
  * Process batch exports via ajax
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_ajax_export() {
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	parse_str( $_POST['form'], $form );
31
+	parse_str($_POST['form'], $form);
32 32
 
33 33
 	$_REQUEST = $form = (array) $form;
34 34
 
35
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
36
-		die( '-2' );
35
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
36
+		die('-2');
37 37
 	}
38 38
 
39 39
 	/**
@@ -43,69 +43,69 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @param string $class Export class.
45 45
 	 */
46
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
46
+	do_action('give_batch_export_class_include', $form['give-export-class']);
47 47
 
48
-	$step   = absint( $_POST['step'] );
49
-	$class  = sanitize_text_field( $form['give-export-class'] );
48
+	$step   = absint($_POST['step']);
49
+	$class  = sanitize_text_field($form['give-export-class']);
50 50
 
51
-	$export = new $class( $step );
51
+	$export = new $class($step);
52 52
 
53
-	if ( ! $export->can_export() ) {
54
-		die( '-1' );
53
+	if ( ! $export->can_export()) {
54
+		die('-1');
55 55
 	}
56 56
 
57
-	if ( ! $export->is_writable ) {
57
+	if ( ! $export->is_writable) {
58 58
 		$json_args = array(
59 59
 			'error'   => true,
60
-			'message' => esc_html__( 'Export location or file not writable.', 'give' )
60
+			'message' => esc_html__('Export location or file not writable.', 'give')
61 61
 		);
62 62
 		echo json_encode($json_args);
63 63
 		exit;
64 64
 	}
65 65
 
66
-	$export->set_properties( $_REQUEST );
66
+	$export->set_properties($_REQUEST);
67 67
 
68 68
 	$export->pre_fetch();
69 69
 
70
-	$ret = $export->process_step( $step );
70
+	$ret = $export->process_step($step);
71 71
 
72 72
 	$percentage = $export->get_percentage_complete();
73 73
 
74
-	if ( $ret ) {
74
+	if ($ret) {
75 75
 
76 76
 		$step += 1;
77
-		echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) );
77
+		echo json_encode(array('step' => $step, 'percentage' => $percentage));
78 78
 		exit;
79 79
 
80
-	} elseif ( true === $export->is_empty ) {
80
+	} elseif (true === $export->is_empty) {
81 81
 
82
-		echo json_encode( array(
82
+		echo json_encode(array(
83 83
 			'error'   => true,
84
-			'message' => esc_html__( 'No data found for export parameters.', 'give' )
85
-		) );
84
+			'message' => esc_html__('No data found for export parameters.', 'give')
85
+		));
86 86
 		exit;
87 87
 
88
-	} elseif ( true === $export->done && true === $export->is_void ) {
88
+	} elseif (true === $export->done && true === $export->is_void) {
89 89
 
90
-		$message = ! empty( $export->message ) ? $export->message : esc_html__( 'Batch Processing Complete', 'give' );
91
-		echo json_encode( array( 'success' => true, 'message' => $message ) );
90
+		$message = ! empty($export->message) ? $export->message : esc_html__('Batch Processing Complete', 'give');
91
+		echo json_encode(array('success' => true, 'message' => $message));
92 92
 		exit;
93 93
 
94 94
 	} else {
95 95
 		
96
-		$args = array_merge( $_REQUEST, array(
96
+		$args = array_merge($_REQUEST, array(
97 97
 			'step'        => $step,
98 98
 			'class'       => $class,
99
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
99
+			'nonce'       => wp_create_nonce('give-batch-export'),
100 100
 			'give_action' => 'form_batch_export',
101
-		) );
101
+		));
102 102
 
103
-		$download_url = add_query_arg( $args, admin_url() );
103
+		$download_url = add_query_arg($args, admin_url());
104 104
 
105
-		echo json_encode( array( 'step' => 'done', 'url' => $download_url ) );
105
+		echo json_encode(array('step' => 'done', 'url' => $download_url));
106 106
 		exit;
107 107
 
108 108
 	}
109 109
 }
110 110
 
111
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
111
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.
includes/class-give-db.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 	 * @since  1.0
112 112
 	 * @access public
113 113
 	 *
114
-     * @param  int $column Column ID.
115
-     * @param  int $row_id Row ID.
116
-     *
117
-     * @return object
114
+	 * @param  int $column Column ID.
115
+	 * @param  int $row_id Row ID.
116
+	 *
117
+	 * @return object
118 118
 	 */
119 119
 	public function get_by( $column, $row_id ) {
120
-        /* @var WPDB $wpdb */
121
-        global $wpdb;
120
+		/* @var WPDB $wpdb */
121
+		global $wpdb;
122 122
 
123 123
 		$column = esc_sql( $column );
124 124
 		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @since  1.0
131 131
 	 * @access public
132
-     *
133
-     * @param  int $column Column ID.
134
-     * @param  int $row_id Row ID.
135
-     *
132
+	 *
133
+	 * @param  int $column Column ID.
134
+	 * @param  int $row_id Row ID.
135
+	 *
136 136
 	 * @return string      Column value.
137 137
 	 */
138 138
 	public function get_column( $column, $row_id ) {
139
-        /* @var WPDB $wpdb */
140
-        global $wpdb;
139
+		/* @var WPDB $wpdb */
140
+		global $wpdb;
141 141
 
142 142
 		$column = esc_sql( $column );
143 143
 		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
@@ -148,16 +148,16 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @since  1.0
150 150
 	 * @access public
151
-     *
152
-     * @param  int    $column       Column ID.
153
-     * @param  string $column_where Column name.
154
-     * @param  string $column_value Column value.
155
-     *
151
+	 *
152
+	 * @param  int    $column       Column ID.
153
+	 * @param  string $column_where Column name.
154
+	 * @param  string $column_value Column value.
155
+	 *
156 156
 	 * @return string
157 157
 	 */
158 158
 	public function get_column_by( $column, $column_where, $column_value ) {
159
-        /* @var WPDB $wpdb */
160
-        global $wpdb;
159
+		/* @var WPDB $wpdb */
160
+		global $wpdb;
161 161
 
162 162
 		$column_where = esc_sql( $column_where );
163 163
 		$column       = esc_sql( $column );
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @since  1.0
171 171
 	 * @access public
172
-     *
173
-     * @param  array  $data
174
-     * @param  string $type
175
-     *
172
+	 *
173
+	 * @param  array  $data
174
+	 * @param  string $type
175
+	 *
176 176
 	 * @return int
177 177
 	 */
178 178
 	public function insert( $data, $type = '' ) {
179
-        /* @var WPDB $wpdb */
180
-        global $wpdb;
179
+		/* @var WPDB $wpdb */
180
+		global $wpdb;
181 181
 
182 182
 		// Set default values.
183 183
 		$data = wp_parse_args( $data, $this->get_column_defaults() );
@@ -224,16 +224,16 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @since  1.0
226 226
 	 * @access public
227
-     *
228
-     * @param  int    $row_id Column ID
229
-     * @param  array  $data
230
-     * @param  string $where  Column value
231
-     *
227
+	 *
228
+	 * @param  int    $row_id Column ID
229
+	 * @param  array  $data
230
+	 * @param  string $where  Column value
231
+	 *
232 232
 	 * @return bool
233 233
 	 */
234 234
 	public function update( $row_id, $data = array(), $where = '' ) {
235
-        /* @var WPDB $wpdb */
236
-        global $wpdb;
235
+		/* @var WPDB $wpdb */
236
+		global $wpdb;
237 237
 
238 238
 		// Row ID must be positive integer
239 239
 		$row_id = absint( $row_id );
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since  1.0
273 273
 	 * @access public
274
-     *
275
-     * @param  int $row_id Column ID.
276
-     *
274
+	 *
275
+	 * @param  int $row_id Column ID.
276
+	 *
277 277
 	 * @return bool
278 278
 	 */
279 279
 	public function delete( $row_id = 0 ) {
280
-        /* @var WPDB $wpdb */
281
-        global $wpdb;
280
+		/* @var WPDB $wpdb */
281
+		global $wpdb;
282 282
 
283 283
 		// Row ID must be positive integer
284 284
 		$row_id = absint( $row_id );
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @since  1.3.2
301 301
 	 * @access public
302
-     *
302
+	 *
303 303
 	 * @param  string $table The table name.
304
-     *
304
+	 *
305 305
 	 * @return bool          If the table name exists.
306 306
 	 */
307 307
 	public function table_exists( $table ) {
308
-        /* @var WPDB $wpdb */
308
+		/* @var WPDB $wpdb */
309 309
 		global $wpdb;
310 310
 
311 311
 		$table = sanitize_text_field( $table );
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 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
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
105
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
106 106
 	}
107 107
 
108 108
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return object
118 118
 	 */
119
-	public function get_by( $column, $row_id ) {
119
+	public function get_by($column, $row_id) {
120 120
         /* @var WPDB $wpdb */
121 121
         global $wpdb;
122 122
 
123
-		$column = esc_sql( $column );
124
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
123
+		$column = esc_sql($column);
124
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      *
136 136
 	 * @return string      Column value.
137 137
 	 */
138
-	public function get_column( $column, $row_id ) {
138
+	public function get_column($column, $row_id) {
139 139
         /* @var WPDB $wpdb */
140 140
         global $wpdb;
141 141
 
142
-		$column = esc_sql( $column );
143
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
142
+		$column = esc_sql($column);
143
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
144 144
 	}
145 145
 
146 146
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      *
156 156
 	 * @return string
157 157
 	 */
158
-	public function get_column_by( $column, $column_where, $column_value ) {
158
+	public function get_column_by($column, $column_where, $column_value) {
159 159
         /* @var WPDB $wpdb */
160 160
         global $wpdb;
161 161
 
162
-		$column_where = esc_sql( $column_where );
163
-		$column       = esc_sql( $column );
164
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
162
+		$column_where = esc_sql($column_where);
163
+		$column       = esc_sql($column);
164
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
165 165
 	}
166 166
 
167 167
 	/**
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
      *
176 176
 	 * @return int
177 177
 	 */
178
-	public function insert( $data, $type = '' ) {
178
+	public function insert($data, $type = '') {
179 179
         /* @var WPDB $wpdb */
180 180
         global $wpdb;
181 181
 
182 182
 		// Set default values.
183
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
183
+		$data = wp_parse_args($data, $this->get_column_defaults());
184 184
 
185 185
 		/**
186 186
 		 * Fires before inserting data to the database.
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
 		 *
190 190
 		 * @param array $data
191 191
 		 */
192
-		do_action( "give_pre_insert_{$type}", $data );
192
+		do_action("give_pre_insert_{$type}", $data);
193 193
 
194 194
 		// Initialise column format array
195 195
 		$column_formats = $this->get_columns();
196 196
 
197 197
 		// Force fields to lower case
198
-		$data = array_change_key_case( $data );
198
+		$data = array_change_key_case($data);
199 199
 
200 200
 		// White list columns
201
-		$data = array_intersect_key( $data, $column_formats );
201
+		$data = array_intersect_key($data, $column_formats);
202 202
 
203 203
 		// Reorder $column_formats to match the order of columns given in $data
204
-		$data_keys      = array_keys( $data );
205
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
204
+		$data_keys      = array_keys($data);
205
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
206 206
 
207
-		$wpdb->insert( $this->table_name, $data, $column_formats );
207
+		$wpdb->insert($this->table_name, $data, $column_formats);
208 208
 
209 209
 		/**
210 210
 		 * Fires after inserting data to the database.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 * @param int   $insert_id
215 215
 		 * @param array $data
216 216
 		 */
217
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
217
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
218 218
 
219 219
 		return $wpdb->insert_id;
220 220
 	}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
      *
232 232
 	 * @return bool
233 233
 	 */
234
-	public function update( $row_id, $data = array(), $where = '' ) {
234
+	public function update($row_id, $data = array(), $where = '') {
235 235
         /* @var WPDB $wpdb */
236 236
         global $wpdb;
237 237
 
238 238
 		// Row ID must be positive integer
239
-		$row_id = absint( $row_id );
239
+		$row_id = absint($row_id);
240 240
 
241
-		if ( empty( $row_id ) ) {
241
+		if (empty($row_id)) {
242 242
 			return false;
243 243
 		}
244 244
 
245
-		if ( empty( $where ) ) {
245
+		if (empty($where)) {
246 246
 			$where = $this->primary_key;
247 247
 		}
248 248
 
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		$column_formats = $this->get_columns();
251 251
 
252 252
 		// Force fields to lower case
253
-		$data = array_change_key_case( $data );
253
+		$data = array_change_key_case($data);
254 254
 
255 255
 		// White list columns
256
-		$data = array_intersect_key( $data, $column_formats );
256
+		$data = array_intersect_key($data, $column_formats);
257 257
 
258 258
 		// Reorder $column_formats to match the order of columns given in $data
259
-		$data_keys      = array_keys( $data );
260
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
259
+		$data_keys      = array_keys($data);
260
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
261 261
 
262
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
262
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
263 263
 			return false;
264 264
 		}
265 265
 
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
      *
277 277
 	 * @return bool
278 278
 	 */
279
-	public function delete( $row_id = 0 ) {
279
+	public function delete($row_id = 0) {
280 280
         /* @var WPDB $wpdb */
281 281
         global $wpdb;
282 282
 
283 283
 		// Row ID must be positive integer
284
-		$row_id = absint( $row_id );
284
+		$row_id = absint($row_id);
285 285
 
286
-		if ( empty( $row_id ) ) {
286
+		if (empty($row_id)) {
287 287
 			return false;
288 288
 		}
289 289
 
290
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
290
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
291 291
 			return false;
292 292
 		}
293 293
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      *
305 305
 	 * @return bool          If the table name exists.
306 306
 	 */
307
-	public function table_exists( $table ) {
307
+	public function table_exists($table) {
308 308
         /* @var WPDB $wpdb */
309 309
 		global $wpdb;
310 310
 
311
-		$table = sanitize_text_field( $table );
311
+		$table = sanitize_text_field($table);
312 312
 
313
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
313
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
323 323
 	 */
324 324
 	public function installed() {
325
-		return $this->table_exists( $this->table_name );
325
+		return $this->table_exists($this->table_name);
326 326
 	}
327 327
 
328 328
 }
Please login to merge, or discard this patch.
includes/class-give-gravatars.php 1 patch
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -62,50 +62,50 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return bool If the gravatar exists or not
64 64
 	 */
65
-	public function validate_gravatar( $id_or_email ) {
65
+	public function validate_gravatar($id_or_email) {
66 66
 		//id or email code borrowed from wp-includes/pluggable.php
67 67
 		$email = '';
68
-		if ( is_numeric( $id_or_email ) ) {
68
+		if (is_numeric($id_or_email)) {
69 69
 			$id   = (int) $id_or_email;
70
-			$user = get_userdata( $id );
71
-			if ( $user ) {
70
+			$user = get_userdata($id);
71
+			if ($user) {
72 72
 				$email = $user->user_email;
73 73
 			}
74
-		} elseif ( is_object( $id_or_email ) ) {
74
+		} elseif (is_object($id_or_email)) {
75 75
 			// No avatar for pingbacks or trackbacks
76
-			$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
77
-			if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
76
+			$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
77
+			if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
78 78
 				return false;
79 79
 			}
80 80
 
81
-			if ( ! empty( $id_or_email->user_id ) ) {
81
+			if ( ! empty($id_or_email->user_id)) {
82 82
 				$id   = (int) $id_or_email->user_id;
83
-				$user = get_userdata( $id );
84
-				if ( $user ) {
83
+				$user = get_userdata($id);
84
+				if ($user) {
85 85
 					$email = $user->user_email;
86 86
 				}
87
-			} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
87
+			} elseif ( ! empty($id_or_email->comment_author_email)) {
88 88
 				$email = $id_or_email->comment_author_email;
89 89
 			}
90 90
 		} else {
91 91
 			$email = $id_or_email;
92 92
 		}
93 93
 
94
-		$hashkey = md5( strtolower( trim( $email ) ) );
95
-		$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
94
+		$hashkey = md5(strtolower(trim($email)));
95
+		$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
96 96
 
97
-		$data = wp_cache_get( $hashkey );
98
-		if ( false === $data ) {
99
-			$response = wp_remote_head( $uri );
100
-			if ( is_wp_error( $response ) ) {
97
+		$data = wp_cache_get($hashkey);
98
+		if (false === $data) {
99
+			$response = wp_remote_head($uri);
100
+			if (is_wp_error($response)) {
101 101
 				$data = 'not200';
102 102
 			} else {
103 103
 				$data = $response['response']['code'];
104 104
 			}
105
-			wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
105
+			wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
106 106
 
107 107
 		}
108
-		if ( $data == '200' ) {
108
+		if ($data == '200') {
109 109
 			return true;
110 110
 		} else {
111 111
 			return false;
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return array        IDs if logs, false otherwise
124 124
 	 */
125
-	public function get_log_ids( $form_id = '' ) {
125
+	public function get_log_ids($form_id = '') {
126 126
 
127 127
 		// get Give_Logging class
128 128
 		global $give_logs;
129 129
 
130 130
 		// get log for this form
131
-		$logs = $give_logs->get_logs( $form_id );
131
+		$logs = $give_logs->get_logs($form_id);
132 132
 
133
-		if ( $logs ) {
133
+		if ($logs) {
134 134
 			$log_ids = array();
135 135
 
136 136
 			// make an array with all the donor IDs
137
-			foreach ( $logs as $log ) {
137
+			foreach ($logs as $log) {
138 138
 				$log_ids[] = $log->ID;
139 139
 			}
140 140
 
@@ -155,51 +155,51 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return mixed
157 157
 	 */
158
-	public function get_payment_ids( $form_id = '' ) {
158
+	public function get_payment_ids($form_id = '') {
159 159
 
160 160
 		$give_options = give_get_settings();
161 161
 
162
-		$log_ids = $this->get_log_ids( $form_id );
162
+		$log_ids = $this->get_log_ids($form_id);
163 163
 
164
-		if ( $log_ids ) {
164
+		if ($log_ids) {
165 165
 
166 166
 			$payment_ids = array();
167 167
 
168
-			foreach ( $log_ids as $id ) {
168
+			foreach ($log_ids as $id) {
169 169
 				// get the payment ID for each corresponding log ID
170
-				$payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true );
170
+				$payment_ids[] = get_post_meta($id, '_give_log_payment_id', true);
171 171
 			}
172 172
 
173 173
 			// remove donors who have donated more than once so we can have unique avatars
174 174
 			$unique_emails = array();
175 175
 
176
-			foreach ( $payment_ids as $key => $id ) {
176
+			foreach ($payment_ids as $key => $id) {
177 177
 
178
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
178
+				$email = get_post_meta($id, '_give_payment_user_email', true);
179 179
 
180
-				if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) {
181
-					if ( ! $this->validate_gravatar( $email ) ) {
180
+				if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) {
181
+					if ( ! $this->validate_gravatar($email)) {
182 182
 						continue;
183 183
 					}
184 184
 				}
185 185
 
186
-				$unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true );
186
+				$unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true);
187 187
 
188 188
 			}
189 189
 
190 190
 			$unique_ids = array();
191 191
 
192 192
 			// strip duplicate emails
193
-			$unique_emails = array_unique( $unique_emails );
193
+			$unique_emails = array_unique($unique_emails);
194 194
 
195 195
 			// convert the unique IDs back into simple array
196
-			foreach ( $unique_emails as $id => $email ) {
196
+			foreach ($unique_emails as $id => $email) {
197 197
 				$unique_ids[] = $id;
198 198
 			}
199 199
 
200 200
 			// randomize the payment IDs if enabled
201
-			if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) {
202
-				shuffle( $unique_ids );
201
+			if (isset($give_options['give_donors_gravatars_random_gravatars'])) {
202
+				shuffle($unique_ids);
203 203
 			}
204 204
 
205 205
 			// return our unique IDs
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string
222 222
 	 */
223
-	public function gravatars( $form_id = false, $title = '' ) {
223
+	public function gravatars($form_id = false, $title = '') {
224 224
 
225 225
 		// unique $payment_ids 
226
-		$payment_ids = $this->get_payment_ids( $form_id );
226
+		$payment_ids = $this->get_payment_ids($form_id);
227 227
 
228 228
 		$give_options = give_get_settings();
229 229
 
230 230
 		// return if no ID
231
-		if ( ! $form_id ) {
231
+		if ( ! $form_id) {
232 232
 			return;
233 233
 		}
234 234
 
235 235
 		// minimum amount of donations before showing gravatars
236 236
 		// if the number of items in array is not greater or equal to the number specified, then exit
237
-		if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) {
238
-			if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) {
237
+		if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) {
238
+			if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) {
239 239
 				return;
240 240
 			}
241 241
 		}
@@ -246,51 +246,51 @@  discard block
 block discarded – undo
246 246
 		echo '<div id="give-purchase-gravatars">';
247 247
 
248 248
 
249
-		if ( isset ( $title ) ) {
249
+		if (isset ($title)) {
250 250
 
251
-			if ( $title ) {
252
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' );
253
-			} elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) {
254
-				echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' );
251
+			if ($title) {
252
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>');
253
+			} elseif (isset($give_options['give_donors_gravatars_heading'])) {
254
+				echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>');
255 255
 			}
256 256
 
257 257
 		}
258 258
 		echo '<ul class="give-purchase-gravatars-list">';
259 259
 		$i = 0;
260 260
 
261
-		if ( $payment_ids ) {
262
-			foreach ( $payment_ids as $id ) {
261
+		if ($payment_ids) {
262
+			foreach ($payment_ids as $id) {
263 263
 
264 264
 				// Give saves a blank option even when the control is turned off, hence the extra check
265
-				if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) {
265
+				if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) {
266 266
 					continue;
267 267
 				}
268 268
 
269 269
 				// get the payment meta
270
-				$payment_meta = get_post_meta( $id, '_give_payment_meta', true );
270
+				$payment_meta = get_post_meta($id, '_give_payment_meta', true);
271 271
 
272 272
 				// unserialize the payment meta
273
-				$user_info = maybe_unserialize( $payment_meta['user_info'] );
273
+				$user_info = maybe_unserialize($payment_meta['user_info']);
274 274
 
275 275
 				// get donor's first name
276 276
 				$name = $user_info['first_name'];
277 277
 
278 278
 				// get donor's email
279
-				$email = get_post_meta( $id, '_give_payment_user_email', true );
279
+				$email = get_post_meta($id, '_give_payment_user_email', true);
280 280
 
281 281
 				// set gravatar size and provide filter
282
-				$size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : '';
282
+				$size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : '';
283 283
 
284 284
 				// default image
285
-				$default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false );
285
+				$default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false);
286 286
 
287 287
 				// assemble output
288 288
 				$output .= '<li>';
289 289
 
290
-				$output .= get_avatar( $email, $size, $default_image, $name );
290
+				$output .= get_avatar($email, $size, $default_image, $name);
291 291
 				$output .= '</li>';
292 292
 
293
-				$i ++;
293
+				$i++;
294 294
 
295 295
 			} // end foreach
296 296
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		echo '</ul>';
300 300
 		echo '</div>';
301 301
 
302
-		return apply_filters( 'give_donors_gravatars', ob_get_clean() );
302
+		return apply_filters('give_donors_gravatars', ob_get_clean());
303 303
 	}
304 304
 
305 305
 	/**
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 * @return void
312 312
 	 */
313 313
 	public function register_widget() {
314
-		register_widget( 'Give_Donors_Gravatars_Widget' );
314
+		register_widget('Give_Donors_Gravatars_Widget');
315 315
 	}
316 316
 
317 317
 	/**
@@ -325,19 +325,19 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @return string
327 327
 	 */
328
-	public function shortcode( $atts, $content = null ) {
328
+	public function shortcode($atts, $content = null) {
329 329
 
330
-		$atts = shortcode_atts( array(
330
+		$atts = shortcode_atts(array(
331 331
 			'id'    => '',
332 332
 			'title' => ''
333
-		), $atts, 'give_donors_gravatars' );
333
+		), $atts, 'give_donors_gravatars');
334 334
 
335 335
 		// if no ID is passed on single give_forms pages, get the correct ID
336
-		if ( is_singular( 'give_forms' ) ) {
336
+		if (is_singular('give_forms')) {
337 337
 			$id = get_the_ID();
338 338
 		}
339 339
 
340
-		$content = $this->gravatars( $atts['id'], $atts['title'] );
340
+		$content = $this->gravatars($atts['id'], $atts['title']);
341 341
 
342 342
 		return $content;
343 343
 
@@ -353,56 +353,56 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @return array           Gravatar settings.
355 355
 	 */
356
-	public function settings( $settings ) {
356
+	public function settings($settings) {
357 357
 
358 358
 		$give_gravatar_settings = array(
359 359
 			array(
360
-				'name' => esc_html__( 'Donator Gravatars', 'give' ),
360
+				'name' => esc_html__('Donator Gravatars', 'give'),
361 361
 				'desc' => '<hr>',
362 362
 				'id'   => 'give_title',
363 363
 				'type' => 'give_title'
364 364
 			),
365 365
 			array(
366
-				'name' => esc_html__( 'Heading', 'give' ),
367
-				'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ),
366
+				'name' => esc_html__('Heading', 'give'),
367
+				'desc' => esc_html__('The heading to display above the Gravatars.', 'give'),
368 368
 				'type' => 'text',
369 369
 				'id'   => 'give_donors_gravatars_heading'
370 370
 			),
371 371
 			array(
372
-				'name'    => esc_html__( 'Gravatar Size', 'give' ),
373
-				'desc'    => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ),
372
+				'name'    => esc_html__('Gravatar Size', 'give'),
373
+				'desc'    => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'),
374 374
 				'type'    => 'text_small',
375 375
 				'id'      => 'give_donors_gravatars_gravatar_size',
376 376
 				'default' => '64'
377 377
 			),
378 378
 			array(
379
-				'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ),
380
-				'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ),
379
+				'name' => esc_html__('Minimum Unique Donations Required', 'give'),
380
+				'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'),
381 381
 				'type' => 'text_small',
382 382
 				'id'   => 'give_donors_gravatars_min_purchases_required',
383 383
 			),
384 384
 			array(
385
-				'name'    => esc_html__( 'Maximum Gravatars To Show', 'give' ),
386
-				'desc'    => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ),
385
+				'name'    => esc_html__('Maximum Gravatars To Show', 'give'),
386
+				'desc'    => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'),
387 387
 				'type'    => 'text',
388 388
 				'id'      => 'give_donors_gravatars_maximum_number',
389 389
 				'default' => '20',
390 390
 			),
391 391
 			array(
392
-				'name' => esc_html__( 'Gravatar Visibility', 'give' ),
393
-				'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ),
392
+				'name' => esc_html__('Gravatar Visibility', 'give'),
393
+				'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'),
394 394
 				'id'   => 'give_donors_gravatars_has_gravatar_account',
395 395
 				'type' => 'checkbox',
396 396
 			),
397 397
 			array(
398
-				'name' => esc_html__( 'Randomize Gravatars', 'give' ),
399
-				'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ),
398
+				'name' => esc_html__('Randomize Gravatars', 'give'),
399
+				'desc' => esc_html__('Randomize the Gravatars.', 'give'),
400 400
 				'id'   => 'give_donors_gravatars_random_gravatars',
401 401
 				'type' => 'checkbox',
402 402
 			),
403 403
 		);
404 404
 
405
-		return array_merge( $settings, $give_gravatar_settings );
405
+		return array_merge($settings, $give_gravatar_settings);
406 406
 	}
407 407
 
408 408
 }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		// widget settings
429 429
 		$widget_ops = array(
430 430
 			'classname'   => 'give-donors-gravatars',
431
-			'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ),
431
+			'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'),
432 432
 		);
433 433
 
434 434
 		// widget control settings
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		// create the widget
442 442
 		parent::__construct(
443 443
 			'give_donors_gravatars_widget',
444
-			esc_html__( 'Give Donors Gravatars', 'give' ),
444
+			esc_html__('Give Donors Gravatars', 'give'),
445 445
 			$widget_ops,
446 446
 			$control_ops
447 447
 		);
@@ -461,29 +461,29 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return void
463 463
 	 */
464
-	public function widget( $args, $instance ) {
464
+	public function widget($args, $instance) {
465 465
 
466 466
 		//@TODO: Don't extract it!!!
467
-		extract( $args );
467
+		extract($args);
468 468
 
469
-		if ( ! is_singular( 'give_forms' ) ) {
469
+		if ( ! is_singular('give_forms')) {
470 470
 			return;
471 471
 		}
472 472
 
473 473
 		// Variables from widget settings
474
-		$title = apply_filters( 'widget_title', $instance['title'] );
474
+		$title = apply_filters('widget_title', $instance['title']);
475 475
 
476 476
 		// Used by themes. Opens the widget
477 477
 		echo $before_widget;
478 478
 
479 479
 		// Display the widget title
480
-		if ( $title ) {
481
-			echo $before_title . $title . $after_title;
480
+		if ($title) {
481
+			echo $before_title.$title.$after_title;
482 482
 		}
483 483
 
484 484
 		$gravatars = new Give_Donors_Gravatars();
485 485
 
486
-		echo $gravatars->gravatars( get_the_ID(), null ); // remove title
486
+		echo $gravatars->gravatars(get_the_ID(), null); // remove title
487 487
 
488 488
 		// Used by themes. Closes the widget
489 489
 		echo $after_widget;
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 	 *
504 504
 	 * @return array Updated settings to save.
505 505
 	 */
506
-	public function update( $new_instance, $old_instance ) {
506
+	public function update($new_instance, $old_instance) {
507 507
 
508 508
 		$instance = $old_instance;
509 509
 
510
-		$instance['title'] = strip_tags( $new_instance['title'] );
510
+		$instance['title'] = strip_tags($new_instance['title']);
511 511
 
512 512
 		return $instance;
513 513
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @return void
527 527
 	 */
528
-	public function form( $instance ) {
528
+	public function form($instance) {
529 529
 
530 530
 		// Set up some default widget settings.
531 531
 		$defaults = array(
532 532
 			'title' => '',
533 533
 		);
534 534
 
535
-		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
535
+		$instance = wp_parse_args((array) $instance, $defaults); ?>
536 536
 
537 537
 		<!-- Title -->
538 538
 		<p>
539
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label>
540
-			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
539
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label>
540
+			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" />
541 541
 		</p>
542 542
 
543 543
 		<?php
Please login to merge, or discard this patch.
includes/api/class-give-api-v1.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 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
 
Please login to merge, or discard this patch.
includes/class-give-db-customer-meta.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 		/* @var WPDB $wpdb */
34 34
 		global $wpdb;
35 35
 
36
-		$this->table_name  = $wpdb->prefix . 'give_customermeta';
36
+		$this->table_name  = $wpdb->prefix.'give_customermeta';
37 37
 		$this->primary_key = 'meta_id';
38 38
 		$this->version     = '1.0';
39 39
 
40
-		add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 );
40
+		add_action('plugins_loaded', array($this, 'register_table'), 11);
41 41
 
42 42
 	}
43 43
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single is true.
87 87
 	 */
88
-	public function get_meta( $customer_id = 0, $meta_key = '', $single = false ) {
89
-		$customer_id = $this->sanitize_customer_id( $customer_id );
90
-		if ( false === $customer_id ) {
88
+	public function get_meta($customer_id = 0, $meta_key = '', $single = false) {
89
+		$customer_id = $this->sanitize_customer_id($customer_id);
90
+		if (false === $customer_id) {
91 91
 			return false;
92 92
 		}
93 93
 
94
-		return get_metadata( 'customer', $customer_id, $meta_key, $single );
94
+		return get_metadata('customer', $customer_id, $meta_key, $single);
95 95
 	}
96 96
 
97 97
 	/**
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return  bool                  False for failure. True for success.
111 111
 	 */
112
-	public function add_meta( $customer_id = 0, $meta_key = '', $meta_value, $unique = false ) {
113
-		$customer_id = $this->sanitize_customer_id( $customer_id );
114
-		if ( false === $customer_id ) {
112
+	public function add_meta($customer_id = 0, $meta_key = '', $meta_value, $unique = false) {
113
+		$customer_id = $this->sanitize_customer_id($customer_id);
114
+		if (false === $customer_id) {
115 115
 			return false;
116 116
 		}
117 117
 
118
-		return add_metadata( 'customer', $customer_id, $meta_key, $meta_value, $unique );
118
+		return add_metadata('customer', $customer_id, $meta_key, $meta_value, $unique);
119 119
 	}
120 120
 
121 121
 	/**
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return  bool                  False on failure, true if success.
140 140
 	 */
141
-	public function update_meta( $customer_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
142
-		$customer_id = $this->sanitize_customer_id( $customer_id );
143
-		if ( false === $customer_id ) {
141
+	public function update_meta($customer_id = 0, $meta_key = '', $meta_value, $prev_value = '') {
142
+		$customer_id = $this->sanitize_customer_id($customer_id);
143
+		if (false === $customer_id) {
144 144
 			return false;
145 145
 		}
146 146
 
147
-		return update_metadata( 'customer', $customer_id, $meta_key, $meta_value, $prev_value );
147
+		return update_metadata('customer', $customer_id, $meta_key, $meta_value, $prev_value);
148 148
 	}
149 149
 
150 150
 	/**
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return  bool                  False for failure. True for success.
167 167
 	 */
168
-	public function delete_meta( $customer_id = 0, $meta_key = '', $meta_value = '' ) {
169
-		return delete_metadata( 'customer', $customer_id, $meta_key, $meta_value );
168
+	public function delete_meta($customer_id = 0, $meta_key = '', $meta_value = '') {
169
+		return delete_metadata('customer', $customer_id, $meta_key, $meta_value);
170 170
 	}
171 171
 
172 172
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 */
180 180
 	public function create_table() {
181 181
 
182
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
182
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
183 183
 
184 184
 		$sql = "CREATE TABLE {$this->table_name} (
185 185
 			meta_id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 			KEY meta_key (meta_key)
192 192
 			) CHARACTER SET utf8 COLLATE utf8_general_ci;";
193 193
 
194
-		dbDelta( $sql );
194
+		dbDelta($sql);
195 195
 
196
-		update_option( $this->table_name . '_db_version', $this->version );
196
+		update_option($this->table_name.'_db_version', $this->version);
197 197
 	}
198 198
 
199 199
 	/**
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return int|bool                The normalized customer ID or false if it's found to not be valid.
208 208
 	 */
209
-	private function sanitize_customer_id( $customer_id ) {
210
-		if ( ! is_numeric( $customer_id ) ) {
209
+	private function sanitize_customer_id($customer_id) {
210
+		if ( ! is_numeric($customer_id)) {
211 211
 			return false;
212 212
 		}
213 213
 
214 214
 		$customer_id = (int) $customer_id;
215 215
 
216 216
 		// We were given a non positive number
217
-		if ( absint( $customer_id ) !== $customer_id ) {
217
+		if (absint($customer_id) !== $customer_id) {
218 218
 			return false;
219 219
 		}
220 220
 
221
-		if ( empty( $customer_id ) ) {
221
+		if (empty($customer_id)) {
222 222
 			return false;
223 223
 		}
224 224
 
225
-		return absint( $customer_id );
225
+		return absint($customer_id);
226 226
 
227 227
 	}
228 228
 
Please login to merge, or discard this patch.
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function get_predefined_dates() {
95 95
 		$predefined = array(
96
-			'today'        => esc_html__( 'Today', 'give' ),
97
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
98
-			'this_week'    => esc_html__( 'This Week', 'give' ),
99
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
100
-			'this_month'   => esc_html__( 'This Month', 'give' ),
101
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
102
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
103
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
104
-			'this_year'    => esc_html__( 'This Year', 'give' ),
105
-			'last_year'    => esc_html__( 'Last Year', 'give' )
96
+			'today'        => esc_html__('Today', 'give'),
97
+			'yesterday'    => esc_html__('Yesterday', 'give'),
98
+			'this_week'    => esc_html__('This Week', 'give'),
99
+			'last_week'    => esc_html__('Last Week', 'give'),
100
+			'this_month'   => esc_html__('This Month', 'give'),
101
+			'last_month'   => esc_html__('Last Month', 'give'),
102
+			'this_quarter' => esc_html__('This Quarter', 'give'),
103
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
104
+			'this_year'    => esc_html__('This Year', 'give'),
105
+			'last_year'    => esc_html__('Last Year', 'give')
106 106
 		);
107 107
 
108
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
108
+		return apply_filters('give_stats_predefined_dates', $predefined);
109 109
 	}
110 110
 
111 111
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
124
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
125 125
 
126
-		if ( empty( $_start_date ) ) {
126
+		if (empty($_start_date)) {
127 127
 			$_start_date = 'this_month';
128 128
 		}
129 129
 
130
-		if ( empty( $_end_date ) ) {
130
+		if (empty($_end_date)) {
131 131
 			$_end_date = $_start_date;
132 132
 		}
133 133
 
134
-		$this->start_date = $this->convert_date( $_start_date );
135
-		$this->end_date   = $this->convert_date( $_end_date, true );
134
+		$this->start_date = $this->convert_date($_start_date);
135
+		$this->end_date   = $this->convert_date($_end_date, true);
136 136
 	}
137 137
 
138 138
 	/**
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
150 150
 	 */
151
-	public function convert_date( $date, $end_date = false ) {
151
+	public function convert_date($date, $end_date = false) {
152 152
 
153 153
 		$this->timestamp = false;
154 154
 		$second          = $end_date ? 59 : 0;
155 155
 		$minute          = $end_date ? 59 : 0;
156 156
 		$hour            = $end_date ? 23 : 0;
157 157
 		$day             = 1;
158
-		$month           = date( 'n', current_time( 'timestamp' ) );
159
-		$year            = date( 'Y', current_time( 'timestamp' ) );
158
+		$month           = date('n', current_time('timestamp'));
159
+		$year            = date('Y', current_time('timestamp'));
160 160
 
161
-		if ( array_key_exists( $date, $this->get_predefined_dates() ) ) {
161
+		if (array_key_exists($date, $this->get_predefined_dates())) {
162 162
 
163 163
 			// This is a predefined date rate, such as last_week
164
-			switch ( $date ) {
164
+			switch ($date) {
165 165
 
166 166
 				case 'this_month' :
167 167
 
168
-					if ( $end_date ) {
168
+					if ($end_date) {
169 169
 
170
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
170
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
171 171
 						$hour   = 23;
172 172
 						$minute = 59;
173 173
 						$second = 59;
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 
178 178
 				case 'last_month' :
179 179
 
180
-					if ( $month == 1 ) {
180
+					if ($month == 1) {
181 181
 
182 182
 						$month = 12;
183
-						$year --;
183
+						$year--;
184 184
 
185 185
 					} else {
186 186
 
187
-						$month --;
187
+						$month--;
188 188
 
189 189
 					}
190 190
 
191
-					if ( $end_date ) {
192
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
191
+					if ($end_date) {
192
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
193 193
 					}
194 194
 
195 195
 					break;
196 196
 
197 197
 				case 'today' :
198 198
 
199
-					$day = date( 'd', current_time( 'timestamp' ) );
199
+					$day = date('d', current_time('timestamp'));
200 200
 
201
-					if ( $end_date ) {
201
+					if ($end_date) {
202 202
 						$hour   = 23;
203 203
 						$minute = 59;
204 204
 						$second = 59;
@@ -208,23 +208,23 @@  discard block
 block discarded – undo
208 208
 
209 209
 				case 'yesterday' :
210 210
 
211
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
211
+					$day = date('d', current_time('timestamp')) - 1;
212 212
 
213 213
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
214
-					if ( $day < 1 ) {
214
+					if ($day < 1) {
215 215
 
216 216
 						// If current month is 1
217
-						if ( 1 == $month ) {
217
+						if (1 == $month) {
218 218
 
219 219
 							$year -= 1; // Today is January 1, so skip back to last day of December
220 220
 							$month = 12;
221
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
221
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
222 222
 
223 223
 						} else {
224 224
 
225 225
 							// Go back one month and get the last day of the month
226 226
 							$month -= 1;
227
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
227
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
228 228
 
229 229
 						}
230 230
 					}
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
 				case 'this_week' :
235 235
 
236
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
236
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
237
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
238 238
 
239
-					if ( $today < $days_to_week_start ) {
239
+					if ($today < $days_to_week_start) {
240 240
 
241
-						if ( $month > 1 ) {
241
+						if ($month > 1) {
242 242
 							$month -= 1;
243 243
 						} else {
244 244
 							$month = 12;
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 
247 247
 					}
248 248
 
249
-					if ( ! $end_date ) {
249
+					if ( ! $end_date) {
250 250
 
251 251
 						// Getting the start day
252 252
 
253
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
-						$day += get_option( 'start_of_week' );
253
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
254
+						$day += get_option('start_of_week');
255 255
 
256 256
 					} else {
257 257
 
258 258
 						// Getting the end day
259 259
 
260
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
-						$day += get_option( 'start_of_week' ) + 6;
260
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
261
+						$day += get_option('start_of_week') + 6;
262 262
 
263 263
 					}
264 264
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 
267 267
 				case 'last_week' :
268 268
 
269
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
269
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
270
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
271 271
 
272
-					if ( $today < $days_to_week_start ) {
272
+					if ($today < $days_to_week_start) {
273 273
 
274
-						if ( $month > 1 ) {
274
+						if ($month > 1) {
275 275
 							$month -= 1;
276 276
 						} else {
277 277
 							$month = 12;
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 
280 280
 					}
281 281
 
282
-					if ( ! $end_date ) {
282
+					if ( ! $end_date) {
283 283
 
284 284
 						// Getting the start day
285 285
 
286
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
-						$day += get_option( 'start_of_week' );
286
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
287
+						$day += get_option('start_of_week');
288 288
 
289 289
 					} else {
290 290
 
291 291
 						// Getting the end day
292 292
 
293
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
-						$day += get_option( 'start_of_week' ) + 6;
293
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
294
+						$day += get_option('start_of_week') + 6;
295 295
 
296 296
 					}
297 297
 
@@ -299,39 +299,39 @@  discard block
 block discarded – undo
299 299
 
300 300
 				case 'this_quarter' :
301 301
 
302
-					$month_now = date( 'n', current_time( 'timestamp' ) );
302
+					$month_now = date('n', current_time('timestamp'));
303 303
 
304
-					if ( $month_now <= 3 ) {
304
+					if ($month_now <= 3) {
305 305
 
306
-						if ( ! $end_date ) {
306
+						if ( ! $end_date) {
307 307
 							$month = 1;
308 308
 						} else {
309 309
 							$month  = 3;
310
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
310
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
311 311
 							$hour   = 23;
312 312
 							$minute = 59;
313 313
 							$second = 59;
314 314
 						}
315 315
 
316
-					} else if ( $month_now <= 6 ) {
316
+					} else if ($month_now <= 6) {
317 317
 
318
-						if ( ! $end_date ) {
318
+						if ( ! $end_date) {
319 319
 							$month = 4;
320 320
 						} else {
321 321
 							$month  = 6;
322
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
322
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
323 323
 							$hour   = 23;
324 324
 							$minute = 59;
325 325
 							$second = 59;
326 326
 						}
327 327
 
328
-					} else if ( $month_now <= 9 ) {
328
+					} else if ($month_now <= 9) {
329 329
 
330
-						if ( ! $end_date ) {
330
+						if ( ! $end_date) {
331 331
 							$month = 7;
332 332
 						} else {
333 333
 							$month  = 9;
334
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
334
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
335 335
 							$hour   = 23;
336 336
 							$minute = 59;
337 337
 							$second = 59;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 
340 340
 					} else {
341 341
 
342
-						if ( ! $end_date ) {
342
+						if ( ! $end_date) {
343 343
 							$month = 10;
344 344
 						} else {
345 345
 							$month  = 12;
346
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
346
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
347 347
 							$hour   = 23;
348 348
 							$minute = 59;
349 349
 							$second = 59;
@@ -355,40 +355,40 @@  discard block
 block discarded – undo
355 355
 
356 356
 				case 'last_quarter' :
357 357
 
358
-					$month_now = date( 'n', current_time( 'timestamp' ) );
358
+					$month_now = date('n', current_time('timestamp'));
359 359
 
360
-					if ( $month_now <= 3 ) {
360
+					if ($month_now <= 3) {
361 361
 
362
-						if ( ! $end_date ) {
362
+						if ( ! $end_date) {
363 363
 							$month = 10;
364 364
 						} else {
365 365
 							$year -= 1;
366 366
 							$month  = 12;
367
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
367
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
368 368
 							$hour   = 23;
369 369
 							$minute = 59;
370 370
 							$second = 59;
371 371
 						}
372 372
 
373
-					} else if ( $month_now <= 6 ) {
373
+					} else if ($month_now <= 6) {
374 374
 
375
-						if ( ! $end_date ) {
375
+						if ( ! $end_date) {
376 376
 							$month = 1;
377 377
 						} else {
378 378
 							$month  = 3;
379
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
379
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
380 380
 							$hour   = 23;
381 381
 							$minute = 59;
382 382
 							$second = 59;
383 383
 						}
384 384
 
385
-					} else if ( $month_now <= 9 ) {
385
+					} else if ($month_now <= 9) {
386 386
 
387
-						if ( ! $end_date ) {
387
+						if ( ! $end_date) {
388 388
 							$month = 4;
389 389
 						} else {
390 390
 							$month  = 6;
391
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
391
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
392 392
 							$hour   = 23;
393 393
 							$minute = 59;
394 394
 							$second = 59;
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 
397 397
 					} else {
398 398
 
399
-						if ( ! $end_date ) {
399
+						if ( ! $end_date) {
400 400
 							$month = 7;
401 401
 						} else {
402 402
 							$month  = 9;
403
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
403
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
404 404
 							$hour   = 23;
405 405
 							$minute = 59;
406 406
 							$second = 59;
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 				case 'this_year' :
414 414
 
415
-					if ( ! $end_date ) {
415
+					if ( ! $end_date) {
416 416
 						$month = 1;
417 417
 					} else {
418 418
 						$month  = 12;
419
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
419
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
420 420
 						$hour   = 23;
421 421
 						$minute = 59;
422 422
 						$second = 59;
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				case 'last_year' :
428 428
 
429 429
 					$year -= 1;
430
-					if ( ! $end_date ) {
430
+					if ( ! $end_date) {
431 431
 						$month = 1;
432 432
 					} else {
433 433
 						$month  = 12;
434
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
434
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
435 435
 						$hour   = 23;
436 436
 						$minute = 59;
437 437
 						$second = 59;
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
 			}
443 443
 
444 444
 
445
-		} else if ( is_numeric( $date ) ) {
445
+		} else if (is_numeric($date)) {
446 446
 
447 447
 			// return $date unchanged since it is a timestamp
448 448
 			$this->timestamp = true;
449 449
 
450
-		} else if ( false !== strtotime( $date ) ) {
450
+		} else if (false !== strtotime($date)) {
451 451
 
452
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
453
-			$year  = date( 'Y', $date );
454
-			$month = date( 'm', $date );
455
-			$day   = date( 'd', $date );
452
+			$date  = strtotime($date, current_time('timestamp'));
453
+			$year  = date('Y', $date);
454
+			$month = date('m', $date);
455
+			$day   = date('d', $date);
456 456
 
457 457
 		} else {
458 458
 
459
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
459
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
460 460
 
461 461
 		}
462 462
 
463
-		if ( false === $this->timestamp ) {
463
+		if (false === $this->timestamp) {
464 464
 			// Create an exact timestamp
465
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
465
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
466 466
 		}
467 467
 
468
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
468
+		return apply_filters('give_stats_date', $date, $end_date, $this);
469 469
 
470 470
 	}
471 471
 
@@ -481,33 +481,33 @@  discard block
 block discarded – undo
481 481
 	 * 
482 482
 	 * @return string
483 483
 	 */
484
-	public function count_where( $where = '' ) {
484
+	public function count_where($where = '') {
485 485
 		// Only get payments in our date range
486 486
 
487 487
 		$start_where = '';
488 488
 		$end_where   = '';
489 489
 
490
-		if ( $this->start_date ) {
490
+		if ($this->start_date) {
491 491
 
492
-			if ( $this->timestamp ) {
492
+			if ($this->timestamp) {
493 493
 				$format = 'Y-m-d H:i:s';
494 494
 			} else {
495 495
 				$format = 'Y-m-d 00:00:00';
496 496
 			}
497 497
 
498
-			$start_date  = date( $format, $this->start_date );
498
+			$start_date  = date($format, $this->start_date);
499 499
 			$start_where = " AND p.post_date >= '{$start_date}'";
500 500
 		}
501 501
 
502
-		if ( $this->end_date ) {
502
+		if ($this->end_date) {
503 503
 
504
-			if ( $this->timestamp ) {
504
+			if ($this->timestamp) {
505 505
 				$format = 'Y-m-d H:i:s';
506 506
 			} else {
507 507
 				$format = 'Y-m-d 23:59:59';
508 508
 			}
509 509
 
510
-			$end_date = date( $format, $this->end_date );
510
+			$end_date = date($format, $this->end_date);
511 511
 
512 512
 			$end_where = " AND p.post_date <= '{$end_date}'";
513 513
 		}
@@ -529,34 +529,34 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return string
531 531
 	 */
532
-	public function payments_where( $where = '' ) {
532
+	public function payments_where($where = '') {
533 533
 
534 534
 		global $wpdb;
535 535
 
536 536
 		$start_where = '';
537 537
 		$end_where   = '';
538 538
 
539
-		if ( ! is_wp_error( $this->start_date ) ) {
539
+		if ( ! is_wp_error($this->start_date)) {
540 540
 
541
-			if ( $this->timestamp ) {
541
+			if ($this->timestamp) {
542 542
 				$format = 'Y-m-d H:i:s';
543 543
 			} else {
544 544
 				$format = 'Y-m-d 00:00:00';
545 545
 			}
546 546
 
547
-			$start_date  = date( $format, $this->start_date );
547
+			$start_date  = date($format, $this->start_date);
548 548
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
549 549
 		}
550 550
 
551
-		if ( ! is_wp_error( $this->end_date ) ) {
551
+		if ( ! is_wp_error($this->end_date)) {
552 552
 
553
-			if ( $this->timestamp ) {
553
+			if ($this->timestamp) {
554 554
 				$format = 'Y-m-d 00:00:00';
555 555
 			} else {
556 556
 				$format = 'Y-m-d 23:59:59';
557 557
 			}
558 558
 
559
-			$end_date = date( $format, $this->end_date );
559
+			$end_date = date($format, $this->end_date);
560 560
 
561 561
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
562 562
 		}
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @subcommand    logo
70 70
 	 */
71
-	public function ascii( $args, $assoc_args ) {
72
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
71
+	public function ascii($args, $assoc_args) {
72
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
73 73
 	}
74 74
 
75 75
 
@@ -94,54 +94,54 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @subcommand    details
96 96
 	 */
97
-	public function details( $args, $assoc_args ) {
97
+	public function details($args, $assoc_args) {
98 98
 
99 99
 		/**
100 100
 		 * Plugin Information
101 101
 		 */
102
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
102
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
103 103
 
104 104
 		/**
105 105
 		 * General Information.
106 106
 		 */
107
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
107
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
108 108
 
109
-		$success_page = give_get_option( 'success_page' );
110
-		$failure_page = give_get_option( 'failure_page' );
111
-		$history_page = give_get_option( 'history_page' );
109
+		$success_page = give_get_option('success_page');
110
+		$failure_page = give_get_option('failure_page');
111
+		$history_page = give_get_option('history_page');
112 112
 
113
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
114
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
115
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
116
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
113
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
114
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
115
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
116
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
117 117
 
118 118
 		/**
119 119
 		 * Currency Information.
120 120
 		 */
121
-		$default_gateway = give_get_option( 'default_gateway' );
121
+		$default_gateway = give_get_option('default_gateway');
122 122
 
123
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
123
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
124 124
 
125
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
126
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
127
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
128
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
129
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
130
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
131
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
125
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
126
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
127
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
128
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
129
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
130
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
131
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
132 132
 
133 133
 		// Payment gateways Information.
134
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
135
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
134
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
135
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
136 136
 
137
-		if ( ! empty( $gateways ) ) {
137
+		if ( ! empty($gateways)) {
138 138
 			self::$counter = 1;
139
-			foreach ( $gateways as $gateway ) {
140
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
141
-				self::$counter ++;
139
+			foreach ($gateways as $gateway) {
140
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
141
+				self::$counter++;
142 142
 			}
143 143
 		} else {
144
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
144
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
145 145
 		}
146 146
 	}
147 147
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @subcommand    forms
175 175
 	 */
176
-	public function forms( $args, $assoc_args ) {
176
+	public function forms($args, $assoc_args) {
177 177
 		global $wp_query;
178
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
179
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
178
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
179
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
180 180
 		$start   = time();
181 181
 
182 182
 		// Cache previous number query var.
183 183
 		$is_set_number = $cache_per_page = false;
184
-		if ( isset( $wp_query->query_vars['number'] ) ) {
184
+		if (isset($wp_query->query_vars['number'])) {
185 185
 			$cache_per_page = $wp_query->query_vars['number'];
186 186
 			$is_set_number  = true;
187 187
 		}
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 		$wp_query->query_vars['number'] = $number;
191 191
 
192 192
 		// Get forms.
193
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
193
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
194 194
 
195 195
 		// Reset number query var.
196
-		if ( $is_set_number ) {
196
+		if ($is_set_number) {
197 197
 			$wp_query->query_vars['number'] = $cache_per_page;
198 198
 		}
199 199
 
200 200
 		// Bailout.
201
-		if ( array_key_exists( 'error', $forms ) ) {
201
+		if (array_key_exists('error', $forms)) {
202 202
 
203
-			WP_CLI::warning( $forms['error'] );
203
+			WP_CLI::warning($forms['error']);
204 204
 
205 205
 			return;
206
-		} elseif ( empty( $forms['forms'] ) ) {
206
+		} elseif (empty($forms['forms'])) {
207 207
 
208
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
208
+			WP_CLI::error(__('No forms found.', 'give'));
209 209
 
210 210
 			return;
211 211
 		}
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		// Param to check if form typeis already showed or not.
214 214
 		$is_show_form_type = false;
215 215
 
216
-		if ( 1 === count( $forms ) && $form_id ) {
216
+		if (1 === count($forms) && $form_id) {
217 217
 			// Show single form.
218
-			foreach ( $forms['forms'][0] as $key => $info ) {
219
-				switch ( $key ) {
218
+			foreach ($forms['forms'][0] as $key => $info) {
219
+				switch ($key) {
220 220
 					case 'stats':
221
-						$this->color_main_heading( ucfirst( $key ) );
221
+						$this->color_main_heading(ucfirst($key));
222 222
 
223
-						foreach ( $info as $heading => $data ) {
224
-							$this->color_sub_heading( ucfirst( $heading ) );
225
-							switch ( $heading ) {
223
+						foreach ($info as $heading => $data) {
224
+							$this->color_sub_heading(ucfirst($heading));
225
+							switch ($heading) {
226 226
 								default:
227
-									foreach ( $data as $subheading => $subdata ) {
227
+									foreach ($data as $subheading => $subdata) {
228 228
 
229
-										switch ( $subheading ) {
229
+										switch ($subheading) {
230 230
 											case 'earnings':
231
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
231
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
232 232
 												break;
233 233
 											default:
234
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
234
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
235 235
 										}
236 236
 									}
237 237
 							}
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 					case 'pricing':
242 242
 					case 'info':
243 243
 					default:
244
-						$this->color_main_heading( ucfirst( $key ) );
244
+						$this->color_main_heading(ucfirst($key));
245 245
 
246 246
 						// Show form type.
247
-						if ( ! $is_show_form_type ) {
248
-							$form              = new Give_Donate_Form( $form_id );
247
+						if ( ! $is_show_form_type) {
248
+							$form              = new Give_Donate_Form($form_id);
249 249
 							$is_show_form_type = true;
250 250
 
251
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
251
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
252 252
 						}
253 253
 
254
-						foreach ( $info as $heading => $data ) {
254
+						foreach ($info as $heading => $data) {
255 255
 
256
-							switch ( $heading ) {
256
+							switch ($heading) {
257 257
 								case 'id':
258
-									WP_CLI::log( $this->color_message( $heading, $data ) );
258
+									WP_CLI::log($this->color_message($heading, $data));
259 259
 									break;
260 260
 
261 261
 								default:
262
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
263
-									WP_CLI::log( $this->color_message( $heading, $data ) );
262
+									$data = empty($data) ? __('Not set', 'give') : $data;
263
+									WP_CLI::log($this->color_message($heading, $data));
264 264
 							}
265 265
 						}
266 266
 				}
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 			$is_table_first_row_set = false;
272 272
 			$table_column_count     = 0;
273 273
 
274
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
274
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
275 275
 
276
-			foreach ( $forms['forms'] as $index => $form_data ) {
276
+			foreach ($forms['forms'] as $index => $form_data) {
277 277
 
278 278
 				// Default table data.
279 279
 				$table_first_row = array();
280 280
 				$table_row       = array();
281 281
 
282
-				foreach ( $form_data['info'] as $key => $form ) {
282
+				foreach ($form_data['info'] as $key => $form) {
283 283
 
284 284
 					// Do not show thumbnail, content and link in table.
285
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
285
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
286 286
 						continue;
287 287
 					}
288 288
 
289
-					if ( ! $is_table_first_row_set ) {
289
+					if ( ! $is_table_first_row_set) {
290 290
 						$table_first_row[] = $key;
291 291
 					}
292 292
 
293 293
 					$table_row[] = $form;
294 294
 
295
-					if ( 'status' === $key ) {
295
+					if ('status' === $key) {
296 296
 						// First array item will be an form id in our case.
297
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
297
+						$form = new Give_Donate_Form(absint($table_row[0]));
298 298
 
299 299
 						$table_row[] = $form->get_type();
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Set table first row.
304
-				if ( ! $is_table_first_row_set ) {
304
+				if ( ! $is_table_first_row_set) {
305 305
 
306 306
 					// Add extra column to table.
307 307
 					$table_first_row[] = 'type';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$table_data[] = $table_row;
315 315
 			}
316 316
 
317
-			$this->display_table( $table_data );
317
+			$this->display_table($table_data);
318 318
 		}
319 319
 	}
320 320
 
@@ -366,37 +366,37 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @subcommand    donors
368 368
 	 */
369
-	public function donors( $args, $assoc_args ) {
369
+	public function donors($args, $assoc_args) {
370 370
 		global $wp_query;
371
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
372
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
373
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
374
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
375
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
376
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
377
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
371
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
372
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
373
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
374
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
375
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
376
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
377
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
378 378
 		$start    = time();
379 379
 
380
-		if ( $create ) {
380
+		if ($create) {
381 381
 			$number = 1;
382 382
 
383
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
384
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
383
+			if (isset($assoc_args['email']) && ! is_email($email)) {
384
+				WP_CLI::warning('Wrong email address provided.', 'give');
385 385
 
386 386
 				return;
387 387
 			}
388 388
 
389 389
 			// Create one or more donors.
390
-			if ( ! $email ) {
390
+			if ( ! $email) {
391 391
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
392
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
392
+				$number = is_numeric($create) ? absint($create) : 1;
393 393
 			}
394 394
 
395
-			for ( $i = 0; $i < $number; $i ++ ) {
396
-				if ( ! $email ) {
395
+			for ($i = 0; $i < $number; $i++) {
396
+				if ( ! $email) {
397 397
 
398 398
 					// Generate fake email.
399
-					$email = 'customer-' . uniqid() . '@test.com';
399
+					$email = 'customer-'.uniqid().'@test.com';
400 400
 				}
401 401
 
402 402
 				$args = array(
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 					'name'  => $name,
405 405
 				);
406 406
 
407
-				$customer_id = Give()->customers->add( $args );
407
+				$customer_id = Give()->customers->add($args);
408 408
 
409
-				if ( $customer_id ) {
410
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) );
409
+				if ($customer_id) {
410
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id)));
411 411
 				} else {
412
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
412
+					WP_CLI::error(__('Failed to create donor', 'give'));
413 413
 				}
414 414
 
415 415
 				// Reset email to false so it is generated on the next loop (if creating donors).
416 416
 				$email = false;
417 417
 			}
418 418
 
419
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
419
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
420 420
 
421 421
 		} else {
422 422
 			// Counter.
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			 */
431 431
 			// Cache previous number query var.
432 432
 			$is_set_number = $cache_per_page = false;
433
-			if ( isset( $wp_query->query_vars['number'] ) ) {
433
+			if (isset($wp_query->query_vars['number'])) {
434 434
 				$cache_per_page = $wp_query->query_vars['number'];
435 435
 				$is_set_number  = true;
436 436
 			}
@@ -439,24 +439,24 @@  discard block
 block discarded – undo
439 439
 			$wp_query->query_vars['number'] = $number;
440 440
 
441 441
 			// Get donors.
442
-			if ( $form_id ) {
442
+			if ($form_id) {
443 443
 				// @TODO: Allow user to get a list of donors by donation status.
444
-				$donors = $this->get_donors_by_form_id( $form_id );
444
+				$donors = $this->get_donors_by_form_id($form_id);
445 445
 			} else {
446
-				$donors = $this->api->get_customers( $search );
446
+				$donors = $this->api->get_customers($search);
447 447
 			}
448 448
 
449 449
 			// Reset number query var.
450
-			if ( $is_set_number ) {
450
+			if ($is_set_number) {
451 451
 				$wp_query->query_vars['number'] = $cache_per_page;
452 452
 			}
453 453
 
454
-			if ( isset( $donors['error'] ) ) {
455
-				WP_CLI::error( $donors['error'] );
454
+			if (isset($donors['error'])) {
455
+				WP_CLI::error($donors['error']);
456 456
 			}
457 457
 
458
-			if ( empty( $donors ) ) {
459
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
458
+			if (empty($donors)) {
459
+				WP_CLI::error(__('No donors found.', 'give'));
460 460
 
461 461
 				return;
462 462
 			}
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
 			$table_data             = array();
465 465
 			$is_table_first_row_set = false;
466 466
 
467
-			foreach ( $donors['donors'] as $donor_data ) {
467
+			foreach ($donors['donors'] as $donor_data) {
468 468
 				// Set default table row data.
469
-				$table_first_row = array( __( 's_no', 'give' ) );
470
-				$table_row       = array( self::$counter );
469
+				$table_first_row = array(__('s_no', 'give'));
470
+				$table_row       = array(self::$counter);
471 471
 
472
-				foreach ( $donor_data as $key => $donor ) {
473
-					switch ( $key ) {
472
+				foreach ($donor_data as $key => $donor) {
473
+					switch ($key) {
474 474
 						case 'stats':
475
-							foreach ( $donor as $heading => $data ) {
475
+							foreach ($donor as $heading => $data) {
476 476
 
477 477
 								// Get first row.
478
-								if ( ! $is_table_first_row_set ) {
478
+								if ( ! $is_table_first_row_set) {
479 479
 									$table_first_row[] = $heading;
480 480
 								}
481 481
 
482
-								switch ( $heading ) {
482
+								switch ($heading) {
483 483
 									case 'total_spent':
484
-										$table_row[] = give_currency_filter( $data );
484
+										$table_row[] = give_currency_filter($data);
485 485
 										break;
486 486
 
487 487
 									default:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 						case 'info':
494 494
 						default:
495
-							foreach ( $donor as $heading => $data ) {
495
+							foreach ($donor as $heading => $data) {
496 496
 
497 497
 								// Get first row.
498
-								if ( ! $is_table_first_row_set ) {
498
+								if ( ! $is_table_first_row_set) {
499 499
 									$table_first_row[] = $heading;
500 500
 								}
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				}
506 506
 
507 507
 				// Add first row data to table data.
508
-				if ( ! $is_table_first_row_set ) {
508
+				if ( ! $is_table_first_row_set) {
509 509
 					$table_data[]           = $table_first_row;
510 510
 					$is_table_first_row_set = true;
511 511
 				}
@@ -514,44 +514,44 @@  discard block
 block discarded – undo
514 514
 				$table_data[] = $table_row;
515 515
 
516 516
 				// Increase counter.
517
-				self::$counter ++;
517
+				self::$counter++;
518 518
 			}
519 519
 
520
-			switch ( $format ) {
520
+			switch ($format) {
521 521
 				case 'json':
522 522
 					$table_column_name = $table_data[0];
523
-					unset( $table_data[0] );
523
+					unset($table_data[0]);
524 524
 
525 525
 					$new_table_data = array();
526
-					foreach ( $table_data as $index => $data ) {
527
-						foreach ( $data as $key => $value ) {
528
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
526
+					foreach ($table_data as $index => $data) {
527
+						foreach ($data as $key => $value) {
528
+							$new_table_data[$index][$table_column_name[$key]] = $value;
529 529
 						}
530 530
 					}
531 531
 
532
-					WP_CLI::log( json_encode( $new_table_data ) );
532
+					WP_CLI::log(json_encode($new_table_data));
533 533
 					break;
534 534
 
535 535
 				case 'csv':
536
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
537
-					$fp        = fopen( $file_path, 'w' );
536
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
537
+					$fp        = fopen($file_path, 'w');
538 538
 
539
-					if ( is_writable( $file_path ) ) {
540
-						foreach ( $table_data as $fields ) {
541
-							fputcsv( $fp, $fields );
539
+					if (is_writable($file_path)) {
540
+						foreach ($table_data as $fields) {
541
+							fputcsv($fp, $fields);
542 542
 						}
543 543
 
544
-						fclose( $fp );
544
+						fclose($fp);
545 545
 
546
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
546
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
547 547
 					} else {
548
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
548
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
549 549
 					}
550 550
 
551 551
 					break;
552 552
 
553 553
 				default:
554
-					$this->display_table( $table_data );
554
+					$this->display_table($table_data);
555 555
 			}
556 556
 		}
557 557
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @subcommand    donations
583 583
 	 */
584
-	public function donations( $args, $assoc_args ) {
584
+	public function donations($args, $assoc_args) {
585 585
 		global $wp_query;
586
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
586
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
587 587
 
588 588
 		// Cache previous number query var.
589 589
 		$is_set_number = $cache_per_page = false;
590
-		if ( isset( $wp_query->query_vars['number'] ) ) {
590
+		if (isset($wp_query->query_vars['number'])) {
591 591
 			$cache_per_page = $wp_query->query_vars['number'];
592 592
 			$is_set_number  = true;
593 593
 		}
@@ -599,46 +599,46 @@  discard block
 block discarded – undo
599 599
 		$donations = $this->api->get_recent_donations();
600 600
 
601 601
 		// Reset number query var.
602
-		if ( $is_set_number ) {
602
+		if ($is_set_number) {
603 603
 			$wp_query->query_vars['number'] = $cache_per_page;
604 604
 		}
605 605
 
606
-		if ( empty( $donations ) ) {
607
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
606
+		if (empty($donations)) {
607
+			WP_CLI::error(__('No donations found.', 'give'));
608 608
 
609 609
 			return;
610 610
 		}
611 611
 
612 612
 		self::$counter = 1;
613 613
 
614
-		foreach ( $donations['donations'] as $key => $donation ) {
615
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
616
-			self::$counter ++;
614
+		foreach ($donations['donations'] as $key => $donation) {
615
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
616
+			self::$counter++;
617 617
 
618
-			foreach ( $donation as $column => $data ) {
618
+			foreach ($donation as $column => $data) {
619 619
 
620
-				if ( is_array( $data ) ) {
621
-					$this->color_sub_heading( $column );
622
-					foreach ( $data as $subcolumn => $subdata ) {
620
+				if (is_array($data)) {
621
+					$this->color_sub_heading($column);
622
+					foreach ($data as $subcolumn => $subdata) {
623 623
 
624 624
 						// Decode html codes.
625
-						switch ( $subcolumn ) {
625
+						switch ($subcolumn) {
626 626
 							case 'name':
627
-								$subdata = html_entity_decode( $subdata );
627
+								$subdata = html_entity_decode($subdata);
628 628
 								break;
629 629
 						}
630 630
 
631 631
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
632
-						if ( is_array( $subdata ) ) {
632
+						if (is_array($subdata)) {
633 633
 							continue;
634 634
 						}
635 635
 
636
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
636
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
637 637
 					}
638 638
 					continue;
639 639
 				}
640 640
 
641
-				WP_CLI::log( $this->color_message( $column, $data ) );
641
+				WP_CLI::log($this->color_message($column, $data));
642 642
 			}
643 643
 		}
644 644
 	}
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return        void
679 679
 	 */
680
-	public function report( $args, $assoc_args ) {
680
+	public function report($args, $assoc_args) {
681 681
 		$stats      = new Give_Payment_Stats();
682
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
683
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
684
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
685
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
682
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
683
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
684
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
685
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
686 686
 
687
-		if ( ! empty( $date ) ) {
687
+		if ( ! empty($date)) {
688 688
 			$start_date = $date;
689 689
 			$end_date   = false;
690
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
690
+		} elseif (empty($date) && empty($start_date)) {
691 691
 			$start_date = 'this_month';
692 692
 			$end_date   = false;
693 693
 		}
694 694
 
695 695
 		// Get stats.
696
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
697
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
696
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
697
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
698 698
 
699
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
700
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
699
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
700
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
701 701
 	}
702 702
 
703 703
 
@@ -724,27 +724,27 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @subcommand    cache
726 726
 	 */
727
-	public function cache( $args, $assoc_args ) {
728
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
727
+	public function cache($args, $assoc_args) {
728
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
729 729
 
730 730
 		// Bailout.
731
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
732
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
731
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
732
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
733 733
 
734 734
 			return;
735 735
 		}
736 736
 
737
-		switch ( $action ) {
737
+		switch ($action) {
738 738
 			case 'delete' :
739 739
 				// Reset counter.
740 740
 				self::$counter = 1;
741 741
 
742
-				if ( $this->delete_stats_transients() ) {
742
+				if ($this->delete_stats_transients()) {
743 743
 					// Report .eading.
744
-					WP_CLI::success( 'Give cache deleted.' );
744
+					WP_CLI::success('Give cache deleted.');
745 745
 				} else {
746 746
 					// Report .eading.
747
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
747
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
748 748
 				}
749 749
 				break;
750 750
 		}
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 			ARRAY_A
774 774
 		);
775 775
 
776
-		if ( ! empty( $stat_option_names ) ) {
776
+		if ( ! empty($stat_option_names)) {
777 777
 
778
-			foreach ( $stat_option_names as $option_name ) {
778
+			foreach ($stat_option_names as $option_name) {
779 779
 				$error       = false;
780 780
 				$option_name = $option_name['option_name'];
781 781
 
782
-				switch ( true ) {
783
-					case ( false !== strpos( $option_name, 'transient' ) ):
784
-						$option_name = str_replace( '_transient_', '', $option_name );
785
-						$error       = delete_transient( $option_name );
782
+				switch (true) {
783
+					case (false !== strpos($option_name, 'transient')):
784
+						$option_name = str_replace('_transient_', '', $option_name);
785
+						$error       = delete_transient($option_name);
786 786
 						break;
787 787
 
788 788
 					default:
789
-						$error = delete_option( $option_name );
789
+						$error = delete_option($option_name);
790 790
 				}
791 791
 
792
-				if ( $error ) {
793
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
794
-					self::$counter ++;
792
+				if ($error) {
793
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
794
+					self::$counter++;
795 795
 				} else {
796
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
796
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
797 797
 				}
798 798
 			}
799 799
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return   string
816 816
 	 */
817
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
817
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
818 818
 		// Add colon.
819
-		if ( $colon ) {
820
-			$heading = $heading . ': ';
819
+		if ($colon) {
820
+			$heading = $heading.': ';
821 821
 		}
822 822
 
823
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
823
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
824 824
 	}
825 825
 
826 826
 
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return    void
837 837
 	 */
838
-	private function color_main_heading( $heading, $color = 'g' ) {
839
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
838
+	private function color_main_heading($heading, $color = 'g') {
839
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
840 840
 	}
841 841
 
842 842
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return    void
851 851
 	 */
852
-	private function color_sub_heading( $subheading ) {
853
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
852
+	private function color_sub_heading($subheading) {
853
+		WP_CLI::log("\n--->".$subheading.'', '', false);
854 854
 	}
855 855
 
856 856
 
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return    void
866 866
 	 */
867
-	private function display_table( $data ) {
867
+	private function display_table($data) {
868 868
 		$table = new \cli\Table();
869 869
 
870 870
 		// Set table header.
871
-		$table->setHeaders( $data[0] );
871
+		$table->setHeaders($data[0]);
872 872
 
873 873
 		// Remove table header.
874
-		unset( $data[0] );
874
+		unset($data[0]);
875 875
 
876 876
 		// Set table data.
877
-		$table->setRows( $data );
877
+		$table->setRows($data);
878 878
 
879 879
 		// Display table.
880 880
 		$table->display();
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 	 * @return array
892 892
 	 */
893 893
 
894
-	private function get_donors_by_form_id( $form_id ) {
894
+	private function get_donors_by_form_id($form_id) {
895 895
 		$donors = array();
896 896
 
897 897
 		$donations = new Give_Payments_Query(
898 898
 			array(
899
-				'give_forms' => array( $form_id ),
900
-				'number'     => - 1,
901
-				'status'     => array( 'publish' ),
899
+				'give_forms' => array($form_id),
900
+				'number'     => -1,
901
+				'status'     => array('publish'),
902 902
 			)
903 903
 		);
904 904
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		$skip_donors = array();
907 907
 
908 908
 		/* @var Give_Payment|object $donation Payment object. */
909
-		foreach ( $donations as $donation ) {
909
+		foreach ($donations as $donation) {
910 910
 
911
-			if ( in_array( $donation->customer_id, $skip_donors ) ) {
911
+			if (in_array($donation->customer_id, $skip_donors)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-			if ( ! empty( $donors ) ) {
916
-				$donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) );
915
+			if ( ! empty($donors)) {
916
+				$donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id)));
917 917
 			} else {
918
-				$donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) );
918
+				$donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id));
919 919
 			}
920 920
 
921 921
 			$skip_donors[] = $donation->customer_id;
Please login to merge, or discard this patch.