Completed
Branch master (34b06a)
by Devin
20:06
created
includes/admin/forms/metabox.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 					'row_classes'  => 'give-subfield',
76 76
 					'render_row_cb' 	=> 'give_cmb_amount_field_render_row_cb',
77 77
 					'sanitization_cb'   => 'give_sanitize_price_field_value',
78
-                    'attributes'   => array(
78
+					'attributes'   => array(
79 79
 						'placeholder' => give_format_decimal( '1.00' ),
80 80
 						'value'       => give_format_decimal( $price ),
81 81
 						'class'       => 'cmb-type-text-small give-money-field',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 							'before_field'      => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">' . give_currency_symbol() . '</span>' : '',
111 111
 							'after_field'       => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">' . give_currency_symbol() . '</span>' : '',
112 112
 							'sanitization_cb'   => 'give_sanitize_price_field_value',
113
-                            'attributes'        => array(
113
+							'attributes'        => array(
114 114
 								'placeholder' => give_format_decimal( '1.00' ),
115 115
 								'class'       => 'cmb-type-text-small give-money-field',
116 116
 							),
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-add_action( 'cmb2_init', 'give_single_forms_cmb2_metaboxes', 6 );
17
+add_action('cmb2_init', 'give_single_forms_cmb2_metaboxes', 6);
18 18
 
19 19
 /**
20 20
  * Define the metabox and field configurations.
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
 function give_single_forms_cmb2_metaboxes() {
23 23
 
24 24
 	$post_id               = give_get_admin_post_id();
25
-	$price                 = give_get_form_price( $post_id );
26
-	$custom_amount_minimum = give_get_form_minimum_price( $post_id );
27
-	$goal                  = give_get_form_goal( $post_id );
28
-	$variable_pricing      = give_has_variable_prices( $post_id );
29
-	$prices                = give_get_variable_prices( $post_id );
25
+	$price                 = give_get_form_price($post_id);
26
+	$custom_amount_minimum = give_get_form_minimum_price($post_id);
27
+	$goal                  = give_get_form_goal($post_id);
28
+	$variable_pricing      = give_has_variable_prices($post_id);
29
+	$prices                = give_get_variable_prices($post_id);
30 30
 
31 31
 	//No empty prices - min. 1.00 for new forms
32
-	if ( empty( $price ) && is_null( $post_id ) ) {
33
-		$price = esc_attr( give_format_amount( '1.00' ) );
32
+	if (empty($price) && is_null($post_id)) {
33
+		$price = esc_attr(give_format_amount('1.00'));
34 34
 	}
35 35
 
36 36
 	//Min. $1.00 for new forms
37
-	if ( empty( $custom_amount_minimum ) ) {
38
-		$custom_amount_minimum = esc_attr( give_format_amount( '1.00' ) );
37
+	if (empty($custom_amount_minimum)) {
38
+		$custom_amount_minimum = esc_attr(give_format_amount('1.00'));
39 39
 	}
40 40
 
41 41
 	// Start with an underscore to hide fields from custom fields list
@@ -47,327 +47,327 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * Repeatable Field Groups
49 49
 	 */
50
-	$meta_boxes['form_field_options'] = apply_filters( 'give_forms_field_options', array(
50
+	$meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array(
51 51
 		'id'           => 'form_field_options',
52
-		'title'        => esc_html__( 'Donation Options', 'give' ),
53
-		'object_types' => array( 'give_forms' ),
52
+		'title'        => esc_html__('Donation Options', 'give'),
53
+		'object_types' => array('give_forms'),
54 54
 		'context'      => 'normal',
55 55
 		'priority'     => 'high', //Show above Content WYSIWYG
56
-		'fields'       => apply_filters( 'give_forms_donation_form_metabox_fields', array(
56
+		'fields'       => apply_filters('give_forms_donation_form_metabox_fields', array(
57 57
 				//Donation Option
58 58
 				array(
59
-					'name'        => esc_html__( 'Donation Option', 'give' ),
60
-					'description' => esc_html__( 'Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ),
61
-					'id'          => $prefix . 'price_option',
59
+					'name'        => esc_html__('Donation Option', 'give'),
60
+					'description' => esc_html__('Would you like this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'),
61
+					'id'          => $prefix.'price_option',
62 62
 					'type'        => 'radio_inline',
63 63
 					'default'     => 'set',
64
-					'options'     => apply_filters( 'give_forms_price_options', array(
65
-						'set'   => esc_html__( 'Set Donation', 'give' ),
66
-						'multi' => esc_html__( 'Multi-level Donation', 'give' ),
67
-					) ),
64
+					'options'     => apply_filters('give_forms_price_options', array(
65
+						'set'   => esc_html__('Set Donation', 'give'),
66
+						'multi' => esc_html__('Multi-level Donation', 'give'),
67
+					)),
68 68
 				),
69 69
 				array(
70
-					'name'         => esc_html__( 'Set Donation', 'give' ),
71
-					'description'  => esc_html__( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ),
72
-					'id'           => $prefix . 'set_price',
70
+					'name'         => esc_html__('Set Donation', 'give'),
71
+					'description'  => esc_html__('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'),
72
+					'id'           => $prefix.'set_price',
73 73
 					'type'         => 'text_small',
74 74
 					'row_classes'  => 'give-subfield',
75 75
 					'render_row_cb' 	=> 'give_cmb_amount_field_render_row_cb',
76 76
 					'sanitization_cb'   => 'give_sanitize_price_field_value',
77 77
                     'attributes'   => array(
78
-						'placeholder' => give_format_decimal( '1.00' ),
79
-						'value'       => give_format_decimal( $price ),
78
+						'placeholder' => give_format_decimal('1.00'),
79
+						'value'       => give_format_decimal($price),
80 80
 						'class'       => 'cmb-type-text-small give-money-field',
81 81
 					),
82 82
 				),
83 83
 				//Donation levels: Header
84 84
 				array(
85
-					'id'   => $prefix . 'levels_header',
85
+					'id'   => $prefix.'levels_header',
86 86
 					'type' => 'levels_repeater_header',
87 87
 				),
88 88
 				//Donation Levels: Repeatable CMB2 Group
89 89
 				array(
90
-					'id'          => $prefix . 'donation_levels',
90
+					'id'          => $prefix.'donation_levels',
91 91
 					'type'        => 'group',
92 92
 					'row_classes' => 'give-subfield',
93 93
 					'options'     => array(
94
-						'add_button'    => esc_html__( 'Add Level', 'give' ),
94
+						'add_button'    => esc_html__('Add Level', 'give'),
95 95
 						'remove_button' => '<span class="dashicons dashicons-no"></span>',
96 96
 						'sortable'      => true, // beta
97 97
 					),
98 98
 					// Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
99
-					'fields'      => apply_filters( 'give_donation_levels_table_row', array(
99
+					'fields'      => apply_filters('give_donation_levels_table_row', array(
100 100
 						array(
101
-							'name' => esc_html__( 'ID', 'give' ),
102
-							'id'   => $prefix . 'id',
101
+							'name' => esc_html__('ID', 'give'),
102
+							'id'   => $prefix.'id',
103 103
 							'type' => 'levels_id',
104 104
 						),
105 105
 						array(
106
-							'name'              => esc_html__( 'Amount', 'give' ),
107
-							'id'                => $prefix . 'amount',
106
+							'name'              => esc_html__('Amount', 'give'),
107
+							'id'                => $prefix.'amount',
108 108
 							'type'              => 'text_small',
109
-							'before_field'      => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">' . give_currency_symbol() . '</span>' : '',
110
-							'after_field'       => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">' . give_currency_symbol() . '</span>' : '',
109
+							'before_field'      => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol  give-money-symbol-before">'.give_currency_symbol().'</span>' : '',
110
+							'after_field'       => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol  give-money-symbol-after">'.give_currency_symbol().'</span>' : '',
111 111
 							'sanitization_cb'   => 'give_sanitize_price_field_value',
112 112
                             'attributes'        => array(
113
-								'placeholder' => give_format_decimal( '1.00' ),
113
+								'placeholder' => give_format_decimal('1.00'),
114 114
 								'class'       => 'cmb-type-text-small give-money-field',
115 115
 							),
116 116
 							'before'       => 'give_format_admin_multilevel_amount',
117 117
 						),
118 118
 						array(
119
-							'name'       => esc_html__( 'Text', 'give' ),
120
-							'id'         => $prefix . 'text',
119
+							'name'       => esc_html__('Text', 'give'),
120
+							'id'         => $prefix.'text',
121 121
 							'type'       => 'text',
122 122
 							'attributes' => array(
123
-								'placeholder' => esc_html__( 'Donation Level', 'give' ),
123
+								'placeholder' => esc_html__('Donation Level', 'give'),
124 124
 								'class'       => 'give-multilevel-text-field',
125 125
 							),
126 126
 						),
127 127
 						array(
128
-							'name' => esc_html__( 'Default', 'give' ),
129
-							'id'   => $prefix . 'default',
128
+							'name' => esc_html__('Default', 'give'),
129
+							'id'   => $prefix.'default',
130 130
 							'type' => 'give_default_radio_inline'
131 131
 						),
132
-					) ),
132
+					)),
133 133
 				),
134 134
 				//Display Style
135 135
 				array(
136
-					'name'        => esc_html__( 'Display Style', 'give' ),
137
-					'description' => esc_html__( 'Set how the donations levels will display on the form.', 'give' ),
138
-					'id'          => $prefix . 'display_style',
136
+					'name'        => esc_html__('Display Style', 'give'),
137
+					'description' => esc_html__('Set how the donations levels will display on the form.', 'give'),
138
+					'id'          => $prefix.'display_style',
139 139
 					'type'        => 'radio_inline',
140 140
 					'default'     => 'buttons',
141 141
 					'options'     => array(
142
-						'buttons'  => esc_html__( 'Buttons', 'give' ),
143
-						'radios'   => esc_html__( 'Radios', 'give' ),
144
-						'dropdown' => esc_html__( 'Dropdown', 'give' ),
142
+						'buttons'  => esc_html__('Buttons', 'give'),
143
+						'radios'   => esc_html__('Radios', 'give'),
144
+						'dropdown' => esc_html__('Dropdown', 'give'),
145 145
 					),
146 146
 				),
147 147
 				//Custom Amount
148 148
 				array(
149
-					'name'        => esc_html__( 'Custom Amount', 'give' ),
150
-					'description' => esc_html__( 'Do you want the user to be able to input their own donation amount?', 'give' ),
151
-					'id'          => $prefix . 'custom_amount',
149
+					'name'        => esc_html__('Custom Amount', 'give'),
150
+					'description' => esc_html__('Do you want the user to be able to input their own donation amount?', 'give'),
151
+					'id'          => $prefix.'custom_amount',
152 152
 					'type'        => 'radio_inline',
153 153
 					'default'     => 'no',
154 154
 					'options'     => array(
155
-						'yes' => esc_html__( 'Yes', 'give' ),
156
-						'no'  => esc_html__( 'No', 'give' ),
155
+						'yes' => esc_html__('Yes', 'give'),
156
+						'no'  => esc_html__('No', 'give'),
157 157
 					),
158 158
 				),
159 159
 				array(
160
-					'name'              => esc_html__( 'Custom Amount Minimum', 'give' ),
161
-					'description'       => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ),
162
-					'id'                => $prefix . 'custom_amount_minimum',
160
+					'name'              => esc_html__('Custom Amount Minimum', 'give'),
161
+					'description'       => esc_html__('If you would like to set a minimum custom donation amount please enter it here.', 'give'),
162
+					'id'                => $prefix.'custom_amount_minimum',
163 163
 					'type'              => 'text_small',
164 164
 					'row_classes'       => 'give-subfield',
165 165
 					'render_row_cb'     => 'give_cmb_amount_field_render_row_cb',
166 166
 					'sanitization_cb'   => 'give_sanitize_price_field_value',
167 167
 					'attributes'   => array(
168 168
 						'placeholder' => give_format_decimal('1.00'),
169
-						'value'       => give_format_decimal( $custom_amount_minimum ),
169
+						'value'       => give_format_decimal($custom_amount_minimum),
170 170
 						'class'       => 'cmb-type-text-small give-money-field',
171 171
 					)
172 172
 				),
173 173
 				array(
174
-					'name'        => esc_html__( 'Custom Amount Text', 'give' ),
175
-					'description' => esc_html__( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ),
176
-					'id'          => $prefix . 'custom_amount_text',
174
+					'name'        => esc_html__('Custom Amount Text', 'give'),
175
+					'description' => esc_html__('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'),
176
+					'id'          => $prefix.'custom_amount_text',
177 177
 					'type'        => 'text',
178 178
 					'row_classes' => 'give-subfield',
179 179
 					'attributes'  => array(
180 180
 						'rows'        => 3,
181
-						'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ),
181
+						'placeholder' => esc_attr__('Give a Custom Amount', 'give'),
182 182
 					),
183 183
 				),
184 184
 				//Goals
185 185
 				array(
186
-					'name'        => esc_html__( 'Goal', 'give' ),
187
-					'description' => esc_html__( 'Do you want to set a donation goal for this form?', 'give' ),
188
-					'id'          => $prefix . 'goal_option',
186
+					'name'        => esc_html__('Goal', 'give'),
187
+					'description' => esc_html__('Do you want to set a donation goal for this form?', 'give'),
188
+					'id'          => $prefix.'goal_option',
189 189
 					'type'        => 'radio_inline',
190 190
 					'default'     => 'no',
191 191
 					'options'     => array(
192
-						'yes' => esc_html__( 'Yes', 'give' ),
193
-						'no'  => esc_html__( 'No', 'give' ),
192
+						'yes' => esc_html__('Yes', 'give'),
193
+						'no'  => esc_html__('No', 'give'),
194 194
 					),
195 195
 				),
196 196
 				array(
197
-					'name'              => esc_html__( 'Goal Amount', 'give' ),
198
-					'description'       => esc_html__( 'This is the monetary goal amount you want to reach for this donation form.', 'give' ),
199
-					'id'                => $prefix . 'set_goal',
197
+					'name'              => esc_html__('Goal Amount', 'give'),
198
+					'description'       => esc_html__('This is the monetary goal amount you want to reach for this donation form.', 'give'),
199
+					'id'                => $prefix.'set_goal',
200 200
 					'type'              => 'text_small',
201 201
 					'row_classes'       => 'give-subfield',
202 202
 					'render_row_cb' 	=> 'give_cmb_amount_field_render_row_cb',
203 203
 					'sanitization_cb'   => 'give_sanitize_price_field_value',
204 204
 					'attributes'        => array(
205
-						'placeholder' => give_format_decimal( '0.00' ),
206
-						'value'       => give_format_decimal( $goal ),
205
+						'placeholder' => give_format_decimal('0.00'),
206
+						'value'       => give_format_decimal($goal),
207 207
 						'class'       => 'cmb-type-text-small give-money-field',
208 208
 					),
209 209
 				),
210 210
 
211 211
 				array(
212
-					'name'        => esc_html__( 'Goal Format', 'give' ),
213
-					'description' => esc_html__( 'Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ),
214
-					'id'          => $prefix . 'goal_format',
212
+					'name'        => esc_html__('Goal Format', 'give'),
213
+					'description' => esc_html__('Would you like to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'),
214
+					'id'          => $prefix.'goal_format',
215 215
 					'type'        => 'radio_inline',
216 216
 					'default'     => 'amount',
217 217
 					'row_classes' => 'give-subfield',
218 218
 					'options'     => array(
219
-						'amount'     => esc_html__( 'Amount', 'give' ),
220
-						'percentage' => esc_html__( 'Percentage', 'give' ),
219
+						'amount'     => esc_html__('Amount', 'give'),
220
+						'percentage' => esc_html__('Percentage', 'give'),
221 221
 					),
222 222
 				),
223 223
 				array(
224
-					'name'        => esc_html__( 'Goal Progress Bar Color', 'give' ),
225
-					'id'          => $prefix . 'goal_color',
224
+					'name'        => esc_html__('Goal Progress Bar Color', 'give'),
225
+					'id'          => $prefix.'goal_color',
226 226
 					'type'        => 'colorpicker',
227 227
 					'row_classes' => 'give-subfield',
228 228
 					'default'     => '#2bc253',
229 229
 				),
230 230
 
231 231
 				array(
232
-					'name'        => esc_html__( 'Close Form when Goal Achieved', 'give' ),
233
-					'desc'        => esc_html__( 'Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
234
-					'id'          => $prefix . 'close_form_when_goal_achieved',
232
+					'name'        => esc_html__('Close Form when Goal Achieved', 'give'),
233
+					'desc'        => esc_html__('Would you like to close the donation forms and stop accepting donations once this goal has been met?', 'give'),
234
+					'id'          => $prefix.'close_form_when_goal_achieved',
235 235
 					'type'        => 'radio_inline',
236 236
 					'row_classes' => 'give-subfield',
237 237
 					'options'     => array(
238
-						'yes' => esc_html__( 'Yes', 'give' ),
239
-						'no'  => esc_html__( 'No', 'give' ),
238
+						'yes' => esc_html__('Yes', 'give'),
239
+						'no'  => esc_html__('No', 'give'),
240 240
 					),
241 241
 					'default'     => 'no',
242 242
 				),
243 243
 				array(
244
-					'name'        => esc_html__( 'Goal Achieved Message', 'give' ),
245
-					'desc'        => esc_html__( 'Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give' ),
246
-					'id'          => $prefix . 'form_goal_achieved_message',
244
+					'name'        => esc_html__('Goal Achieved Message', 'give'),
245
+					'desc'        => esc_html__('Would you like to display a custom message when the goal is closed? If none is provided the default message will be displayed', 'give'),
246
+					'id'          => $prefix.'form_goal_achieved_message',
247 247
 					'type'        => 'textarea',
248 248
 					'row_classes' => 'give-subfield',
249 249
 					'attributes'  => array(
250
-						'placeholder' => esc_attr__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
250
+						'placeholder' => esc_attr__('Thank you to all our donors, we have met our fundraising goal.', 'give'),
251 251
 					),
252 252
 				)
253 253
 			)
254 254
 		)
255
-	) );
255
+	));
256 256
 
257 257
 
258 258
 	/**
259 259
 	 * Content Field
260 260
 	 */
261
-	$meta_boxes['form_content_options'] = apply_filters( 'give_forms_content_options', array(
261
+	$meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array(
262 262
 		'id'           => 'form_content_options',
263
-		'title'        => esc_html__( 'Form Content', 'give' ),
264
-		'object_types' => array( 'give_forms' ),
263
+		'title'        => esc_html__('Form Content', 'give'),
264
+		'object_types' => array('give_forms'),
265 265
 		'context'      => 'normal',
266 266
 		'priority'     => 'high', //Show above Content WYSIWYG
267
-		'fields'       => apply_filters( 'give_forms_content_options_metabox_fields', array(
267
+		'fields'       => apply_filters('give_forms_content_options_metabox_fields', array(
268 268
 				//Donation Option
269 269
 				array(
270
-					'name'        => esc_html__( 'Display Content', 'give' ),
271
-					'description' => esc_html__( 'Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give' ),
272
-					'id'          => $prefix . 'content_option',
270
+					'name'        => esc_html__('Display Content', 'give'),
271
+					'description' => esc_html__('Do you want to display content? If you choose to display content, a WYSIWYG editor will appear which you will be able to enter content.', 'give'),
272
+					'id'          => $prefix.'content_option',
273 273
 					'type'        => 'select',
274
-					'options'     => apply_filters( 'give_forms_content_options_select', array(
275
-							'none'           => esc_html__( 'No Content', 'give' ),
276
-							'give_pre_form'  => esc_html__( 'Display content ABOVE the fields', 'give' ),
277
-							'give_post_form' => esc_html__( 'Display content BELOW the fields', 'give' ),
274
+					'options'     => apply_filters('give_forms_content_options_select', array(
275
+							'none'           => esc_html__('No Content', 'give'),
276
+							'give_pre_form'  => esc_html__('Display content ABOVE the fields', 'give'),
277
+							'give_post_form' => esc_html__('Display content BELOW the fields', 'give'),
278 278
 						)
279 279
 					),
280 280
 					'default'     => 'none',
281 281
 				),
282 282
 				array(
283
-					'name'        => esc_html__( 'Content', 'give' ),
284
-					'description' => esc_html__( 'This content will display on the single give form page.', 'give' ),
285
-					'id'          => $prefix . 'form_content',
283
+					'name'        => esc_html__('Content', 'give'),
284
+					'description' => esc_html__('This content will display on the single give form page.', 'give'),
285
+					'id'          => $prefix.'form_content',
286 286
 					'row_classes' => 'give-subfield',
287 287
 					'type'        => 'wysiwyg'
288 288
 				),
289 289
 			)
290 290
 		)
291
-	) );
291
+	));
292 292
 
293 293
 
294 294
 	/**
295 295
 	 * Display Options
296 296
 	 */
297
-	$meta_boxes['form_display_options'] = apply_filters( 'give_form_display_options', array(
297
+	$meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array(
298 298
 			'id'           => 'form_display_options',
299
-			'title'        => esc_html__( 'Form Display Options', 'give' ),
300
-			'object_types' => array( 'give_forms' ),
299
+			'title'        => esc_html__('Form Display Options', 'give'),
300
+			'object_types' => array('give_forms'),
301 301
 			'context'      => 'normal', //  'normal', 'advanced', or 'side'
302 302
 			'priority'     => 'high', //Show above Content WYSIWYG
303 303
 			'show_names'   => true, // Show field names on the left
304
-			'fields'       => apply_filters( 'give_forms_display_options_metabox_fields', array(
304
+			'fields'       => apply_filters('give_forms_display_options_metabox_fields', array(
305 305
 					array(
306
-						'name'    => esc_html__( 'Payment Fields', 'give' ),
307
-						'desc'    => esc_html__( 'How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give' ),
308
-						'id'      => $prefix . 'payment_display',
306
+						'name'    => esc_html__('Payment Fields', 'give'),
307
+						'desc'    => esc_html__('How would you like to display donation information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon click slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'),
308
+						'id'      => $prefix.'payment_display',
309 309
 						'type'    => 'select',
310 310
 						'options' => array(
311
-							'onpage' => esc_html__( 'Show on Page', 'give' ),
312
-							'reveal' => esc_html__( 'Reveal Upon Click', 'give' ),
313
-							'modal'  => esc_html__( 'Modal Window Upon Click', 'give' ),
311
+							'onpage' => esc_html__('Show on Page', 'give'),
312
+							'reveal' => esc_html__('Reveal Upon Click', 'give'),
313
+							'modal'  => esc_html__('Modal Window Upon Click', 'give'),
314 314
 						),
315 315
 						'default' => 'onpage',
316 316
 					),
317 317
 					array(
318
-						'id'          => $prefix . 'reveal_label',
319
-						'name'        => esc_html__( 'Reveal / Modal Open Text', 'give' ),
320
-						'desc'        => esc_html__( 'The button label for completing the donation.', 'give' ),
318
+						'id'          => $prefix.'reveal_label',
319
+						'name'        => esc_html__('Reveal / Modal Open Text', 'give'),
320
+						'desc'        => esc_html__('The button label for completing the donation.', 'give'),
321 321
 						'type'        => 'text_small',
322 322
 						'row_classes' => 'give-subfield',
323 323
 						'attributes'  => array(
324
-							'placeholder' => esc_attr__( 'Donate Now', 'give' ),
324
+							'placeholder' => esc_attr__('Donate Now', 'give'),
325 325
 						),
326 326
 					),
327 327
 					array(
328
-						'id'         => $prefix . 'checkout_label',
329
-						'name'       => esc_html__( 'Complete Donation Text', 'give' ),
330
-						'desc'       => esc_html__( 'The button label for completing the donation.', 'give' ),
328
+						'id'         => $prefix.'checkout_label',
329
+						'name'       => esc_html__('Complete Donation Text', 'give'),
330
+						'desc'       => esc_html__('The button label for completing the donation.', 'give'),
331 331
 						'type'       => 'text_small',
332 332
 						'attributes' => array(
333
-							'placeholder' => esc_html__( 'Donate Now', 'give' ),
333
+							'placeholder' => esc_html__('Donate Now', 'give'),
334 334
 						),
335 335
 					),
336 336
 					array(
337
-						'name' => esc_html__( 'Default Gateway', 'give' ),
338
-						'desc' => esc_html__( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ),
339
-						'id'   => $prefix . 'default_gateway',
337
+						'name' => esc_html__('Default Gateway', 'give'),
338
+						'desc' => esc_html__('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'),
339
+						'id'   => $prefix.'default_gateway',
340 340
 						'type' => 'default_gateway'
341 341
 					),
342 342
 					array(
343
-						'name' => esc_html__( 'Disable Guest Donations', 'give' ),
344
-						'desc' => esc_html__( 'Do you want to require users be logged-in to make donations?', 'give' ),
345
-						'id'   => $prefix . 'logged_in_only',
343
+						'name' => esc_html__('Disable Guest Donations', 'give'),
344
+						'desc' => esc_html__('Do you want to require users be logged-in to make donations?', 'give'),
345
+						'id'   => $prefix.'logged_in_only',
346 346
 						'type' => 'checkbox'
347 347
 					),
348 348
 					array(
349
-						'name'    => esc_html__( 'Register / Login Form', 'give' ),
350
-						'desc'    => esc_html__( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ),
351
-						'id'      => $prefix . 'show_register_form',
349
+						'name'    => esc_html__('Register / Login Form', 'give'),
350
+						'desc'    => esc_html__('Display the registration and login forms in the payment section for non-logged-in users.', 'give'),
351
+						'id'      => $prefix.'show_register_form',
352 352
 						'type'    => 'select',
353 353
 						'options' => array(
354
-							'both'         => esc_html__( 'Registration and Login Forms', 'give' ),
355
-							'registration' => esc_html__( 'Registration Form Only', 'give' ),
356
-							'login'        => esc_html__( 'Login Form Only', 'give' ),
357
-							'none'         => esc_html__( 'None', 'give' ),
354
+							'both'         => esc_html__('Registration and Login Forms', 'give'),
355
+							'registration' => esc_html__('Registration Form Only', 'give'),
356
+							'login'        => esc_html__('Login Form Only', 'give'),
357
+							'none'         => esc_html__('None', 'give'),
358 358
 						),
359 359
 						'default' => 'none',
360 360
 					),
361 361
 					array(
362
-						'name'    => esc_html__( 'Floating Labels', 'give' ),
362
+						'name'    => esc_html__('Floating Labels', 'give'),
363 363
 						/* translators: %s: forms https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels */
364
-						'desc'    => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' ) ),
365
-						'id'      => $prefix . 'form_floating_labels',
364
+						'desc'    => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels')),
365
+						'id'      => $prefix.'form_floating_labels',
366 366
 						'type'    => 'select',
367 367
 						'options' => array(
368
-							''         => esc_html__( 'Use the global setting', 'give' ),
369
-							'enabled'  => esc_html__( 'Enabled', 'give' ),
370
-							'disabled' => esc_html__( 'Disabled', 'give' ),
368
+							''         => esc_html__('Use the global setting', 'give'),
369
+							'enabled'  => esc_html__('Enabled', 'give'),
370
+							'disabled' => esc_html__('Disabled', 'give'),
371 371
 						),
372 372
 						'default' => 'none',
373 373
 					)
@@ -379,50 +379,50 @@  discard block
 block discarded – undo
379 379
 	/**
380 380
 	 * Terms & Conditions
381 381
 	 */
382
-	$meta_boxes['form_terms_options'] = apply_filters( 'give_forms_terms_options', array(
382
+	$meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array(
383 383
 		'id'           => 'form_terms_options',
384
-		'title'        => esc_html__( 'Terms and Conditions', 'give' ),
385
-		'object_types' => array( 'give_forms' ),
384
+		'title'        => esc_html__('Terms and Conditions', 'give'),
385
+		'object_types' => array('give_forms'),
386 386
 		'context'      => 'normal',
387 387
 		'priority'     => 'high', //Show above Content WYSIWYG
388
-		'fields'       => apply_filters( 'give_forms_terms_options_metabox_fields', array(
388
+		'fields'       => apply_filters('give_forms_terms_options_metabox_fields', array(
389 389
 				//Donation Option
390 390
 				array(
391
-					'name'        => esc_html__( 'Terms and Conditions', 'give' ),
392
-					'description' => esc_html__( 'Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give' ),
393
-					'id'          => $prefix . 'terms_option',
391
+					'name'        => esc_html__('Terms and Conditions', 'give'),
392
+					'description' => esc_html__('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'),
393
+					'id'          => $prefix.'terms_option',
394 394
 					'type'        => 'select',
395
-					'options'     => apply_filters( 'give_forms_content_options_select', array(
396
-							'none' => esc_html__( 'No', 'give' ),
397
-							'yes'  => esc_html__( 'Yes', 'give' ),
395
+					'options'     => apply_filters('give_forms_content_options_select', array(
396
+							'none' => esc_html__('No', 'give'),
397
+							'yes'  => esc_html__('Yes', 'give'),
398 398
 						)
399 399
 					),
400 400
 					'default'     => 'none',
401 401
 				),
402 402
 				array(
403
-					'id'          => $prefix . 'agree_label',
404
-					'name'        => esc_html__( 'Agree to Terms Label', 'give' ),
405
-					'desc'        => esc_html__( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ),
403
+					'id'          => $prefix.'agree_label',
404
+					'name'        => esc_html__('Agree to Terms Label', 'give'),
405
+					'desc'        => esc_html__('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'),
406 406
 					'type'        => 'text',
407 407
 					'row_classes' => 'give-subfield',
408 408
 					'size'        => 'regular',
409 409
 					'attributes'  => array(
410
-						'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ),
410
+						'placeholder' => esc_attr__('Agree to Terms?', 'give'),
411 411
 					),
412 412
 				),
413 413
 				array(
414
-					'id'          => $prefix . 'agree_text',
414
+					'id'          => $prefix.'agree_text',
415 415
 					'row_classes' => 'give-subfield',
416
-					'name'        => esc_html__( 'Agreement Text', 'give' ),
417
-					'desc'        => esc_html__( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
416
+					'name'        => esc_html__('Agreement Text', 'give'),
417
+					'desc'        => esc_html__('This is the actual text which the user will have to agree to in order to make a donation.', 'give'),
418 418
 					'type'        => 'wysiwyg'
419 419
 				),
420 420
 			)
421 421
 		)
422
-	) );
422
+	));
423 423
 
424
-	foreach ( $meta_boxes as $box ) {
425
-		$cmb = new_cmb2_box( $box );
424
+	foreach ($meta_boxes as $box) {
425
+		$cmb = new_cmb2_box($box);
426 426
 	}
427 427
 
428 428
 }
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 
436 436
 	<div class="table-container">
437 437
 		<div class="table-row">
438
-			<div class="table-cell col-amount"><?php esc_html_e( 'Amount', 'give' ); ?></div>
439
-			<div class="table-cell col-text"><?php esc_html_e( 'Text', 'give' ); ?></div>
440
-			<div class="table-cell col-default"><?php esc_html_e( 'Default', 'give' ); ?></div>
438
+			<div class="table-cell col-amount"><?php esc_html_e('Amount', 'give'); ?></div>
439
+			<div class="table-cell col-text"><?php esc_html_e('Text', 'give'); ?></div>
440
+			<div class="table-cell col-default"><?php esc_html_e('Default', 'give'); ?></div>
441 441
 			<?php
442 442
 			/**
443 443
 			 * Fires in repeatable donation levels table head.
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 			 *
450 450
 			 * @since 1.0
451 451
 			 */
452
-			do_action( 'give_donation_levels_table_head' );
452
+			do_action('give_donation_levels_table_head');
453 453
 			?>
454
-			<div class="table-cell col-sort"><?php esc_html_e( 'Sort', 'give' ); ?></div>
454
+			<div class="table-cell col-sort"><?php esc_html_e('Sort', 'give'); ?></div>
455 455
 
456 456
 		</div>
457 457
 	</div>
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	<?php
460 460
 }
461 461
 
462
-add_action( 'cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10 );
462
+add_action('cmb2_render_levels_repeater_header', 'give_cmb_render_levels_repeater_header', 10);
463 463
 
464 464
 
465 465
 /**
@@ -476,25 +476,25 @@  discard block
 block discarded – undo
476 476
  * @param $object_type
477 477
  * @param $field_type_object
478 478
  */
479
-function give_cmb_render_levels_id( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
479
+function give_cmb_render_levels_id($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
480 480
 
481
-	$escaped_value = ( isset( $escaped_value['level_id'] ) ? $escaped_value['level_id'] : '' );
481
+	$escaped_value = (isset($escaped_value['level_id']) ? $escaped_value['level_id'] : '');
482 482
 
483 483
 	$field_options_array = array(
484 484
 		'class' => 'give-hidden give-level-id-input',
485
-		'name'  => $field_type_object->_name( '[level_id]' ),
486
-		'id'    => $field_type_object->_id( '_level_id' ),
485
+		'name'  => $field_type_object->_name('[level_id]'),
486
+		'id'    => $field_type_object->_id('_level_id'),
487 487
 		'value' => $escaped_value,
488 488
 		'type'  => 'number',
489 489
 		'desc'  => '',
490 490
 	);
491 491
 
492
-	echo '<p class="give-level-id">' . $escaped_value . '</p>';
493
-	echo $field_type_object->input( $field_options_array );
492
+	echo '<p class="give-level-id">'.$escaped_value.'</p>';
493
+	echo $field_type_object->input($field_options_array);
494 494
 
495 495
 }
496 496
 
497
-add_action( 'cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5 );
497
+add_action('cmb2_render_levels_id', 'give_cmb_render_levels_id', 10, 5);
498 498
 
499 499
 
500 500
 /**
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
  * @param $object_type
507 507
  * @param $field_type_object
508 508
  */
509
-function give_cmb_give_default_radio_inline( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
510
-	echo '<input type="radio" class="cmb2-option donation-level-radio" name="' . $field_object->args['_name'] . '" id="' . $field_object->args['id'] . '" value="default" ' . checked( 'default', $escaped_value, false ) . '>';
511
-	echo '<label for="' . $field_object->args['id'] . '">' . esc_html__( 'Default', 'give' ) . '</label>';
509
+function give_cmb_give_default_radio_inline($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
510
+	echo '<input type="radio" class="cmb2-option donation-level-radio" name="'.$field_object->args['_name'].'" id="'.$field_object->args['id'].'" value="default" '.checked('default', $escaped_value, false).'>';
511
+	echo '<label for="'.$field_object->args['id'].'">'.esc_html__('Default', 'give').'</label>';
512 512
 
513 513
 }
514 514
 
515
-add_action( 'cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5 );
515
+add_action('cmb2_render_give_default_radio_inline', 'give_cmb_give_default_radio_inline', 10, 5);
516 516
 
517 517
 
518 518
 /**
@@ -522,20 +522,20 @@  discard block
 block discarded – undo
522 522
  */
523 523
 function give_add_shortcode_to_publish_metabox() {
524 524
 
525
-	if ( 'give_forms' !== get_post_type() ) {
525
+	if ('give_forms' !== get_post_type()) {
526 526
 		return false;
527 527
 	}
528 528
 
529 529
 	global $post;
530 530
 
531 531
 	//Only enqueue scripts for CPT on post type screen
532
-	if ( 'give_forms' === $post->post_type ) {
532
+	if ('give_forms' === $post->post_type) {
533 533
 		//Shortcode column with select all input
534
-		$shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' );
535
-		echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>';
534
+		$shortcode = htmlentities('[give_form id="'.$post->ID.'"]');
535
+		echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">'.esc_html__('Give Form Shortcode:', 'give').'</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="'.$shortcode.'"></div>';
536 536
 
537 537
 	}
538 538
 
539 539
 }
540 540
 
541
-add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' );
541
+add_action('post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox');
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html__( 'Default Template', 'give' ),
164
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
163
+			'default' => esc_html__('Default Template', 'give'),
164
+			'none'    => esc_html__('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,19 +205,19 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		$template = $this->get_template();
217 217
 
218 218
 		ob_start();
219 219
 
220
-		give_get_template_part( 'emails/header', $template, true );
220
+		give_get_template_part('emails/header', $template, true);
221 221
 
222 222
 		/**
223 223
 		 * Fires in the email head.
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 		 *
227 227
 		 * @param Give_Emails $this The email object.
228 228
 		 */
229
-		do_action( 'give_email_header', $this );
229
+		do_action('give_email_header', $this);
230 230
 
231
-		if ( has_action( 'give_email_template_' . $template ) ) {
231
+		if (has_action('give_email_template_'.$template)) {
232 232
 			/**
233 233
 			 * Fires in a specific email template.
234 234
 			 *
235 235
 			 * @since 1.0
236 236
 			 */
237
-			do_action( "give_email_template_{$template}" );
237
+			do_action("give_email_template_{$template}");
238 238
 		} else {
239
-			give_get_template_part( 'emails/body', $template, true );
239
+			give_get_template_part('emails/body', $template, true);
240 240
 		}
241 241
 
242 242
 		/**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 		 *
247 247
 		 * @param Give_Emails $this The email object.
248 248
 		 */
249
-		do_action( 'give_email_body', $this );
249
+		do_action('give_email_body', $this);
250 250
 
251
-		give_get_template_part( 'emails/footer', $template, true );
251
+		give_get_template_part('emails/footer', $template, true);
252 252
 
253 253
 		/**
254 254
 		 * Fires in the email footer.
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @param Give_Emails $this The email object.
259 259
 		 */
260
-		do_action( 'give_email_footer', $this );
260
+		do_action('give_email_footer', $this);
261 261
 
262 262
 		$body    = ob_get_clean();
263
-		$message = str_replace( '{email}', $message, $body );
263
+		$message = str_replace('{email}', $message, $body);
264 264
 
265
-		return apply_filters( 'give_email_message', $message, $this );
265
+		return apply_filters('give_email_message', $message, $this);
266 266
 	}
267 267
 
268 268
 	/**
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return bool
277 277
 	 */
278
-	public function send( $to, $subject, $message, $attachments = '' ) {
278
+	public function send($to, $subject, $message, $attachments = '') {
279 279
 
280
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
281
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
280
+		if ( ! did_action('init') && ! did_action('admin_init')) {
281
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
282 282
 
283 283
 			return false;
284 284
 		}
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 		 *
291 291
 		 * @param Give_Emails $this The email object.
292 292
 		 */
293
-		do_action( 'give_email_send_before', $this );
293
+		do_action('give_email_send_before', $this);
294 294
 
295
-		$subject = $this->parse_tags( $subject );
296
-		$message = $this->parse_tags( $message );
295
+		$subject = $this->parse_tags($subject);
296
+		$message = $this->parse_tags($message);
297 297
 
298
-		$message = $this->build_email( $message );
298
+		$message = $this->build_email($message);
299 299
 
300
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
300
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
301 301
 
302
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
302
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
303 303
 
304 304
 		/**
305 305
 		 * Fires after sending an email.
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		 *
309 309
 		 * @param Give_Emails $this The email object.
310 310
 		 */
311
-		do_action( 'give_email_send_after', $this );
311
+		do_action('give_email_send_after', $this);
312 312
 
313 313
 		return $sent;
314 314
 
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 	 * @since 1.0
321 321
 	 */
322 322
 	public function send_before() {
323
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
324
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
325
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
323
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
324
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
325
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
326 326
 	}
327 327
 
328 328
 	/**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 * @since 1.0
332 332
 	 */
333 333
 	public function send_after() {
334
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
335
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
336
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
334
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
335
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
336
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
337 337
 
338 338
 		// Reset heading to an empty string
339 339
 		$this->heading = '';
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @since 1.0
346 346
 	 */
347
-	public function text_to_html( $message ) {
347
+	public function text_to_html($message) {
348 348
 
349
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
350
-			$message = wpautop( $message );
349
+		if ('text/html' == $this->content_type || true === $this->html) {
350
+			$message = wpautop($message);
351 351
 		}
352 352
 
353 353
 		return $message;
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) {
23
+if (give_get_option('uninstall_on_delete') === 'on') {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' );
27
-	$give_post_types = array( 'give_forms', 'give_payment', 'give_log' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag', 'give_log_type');
27
+	$give_post_types = array('give_forms', 'give_payment', 'give_log');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -72,20 +72,20 @@  discard block
 block discarded – undo
72 72
 	Give()->roles->remove_caps();
73 73
 
74 74
 	// Delete the Roles.
75
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker' );
76
-	foreach ( $give_roles as $role ) {
77
-		remove_role( $role );
75
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker');
76
+	foreach ($give_roles as $role) {
77
+		remove_role($role);
78 78
 	}
79 79
 
80 80
 	// Remove all database tables.
81
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
81
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
84 84
 
85 85
 	// Cleanup Cron Events.
86
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
87
-	wp_clear_scheduled_hook( 'give_daily_cron' );
88
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
86
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
87
+	wp_clear_scheduled_hook('give_daily_cron');
88
+	wp_clear_scheduled_hook('give_weekly_cron');
89 89
 
90 90
 	// Get all options.
91 91
 	$give_option_names = $wpdb->get_results(
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
 		ARRAY_A
97 97
 	);
98 98
 
99
-	if ( ! empty( $give_option_names ) ) {
99
+	if ( ! empty($give_option_names)) {
100 100
 		// Convert option name to transient or option name.
101 101
 		$new_give_option_names = array();
102 102
 
103
-		foreach ( $give_option_names as $option ) {
104
-			$new_give_option_names[] = ( false !== strpos( $option['option_name'], '_transient_' ) )
105
-				? str_replace( '_transient_', '', $option['option_name'] )
103
+		foreach ($give_option_names as $option) {
104
+			$new_give_option_names[] = (false !== strpos($option['option_name'], '_transient_'))
105
+				? str_replace('_transient_', '', $option['option_name'])
106 106
 				: $option['option_name'];
107 107
 		}
108 108
 
109 109
 		$give_option_names = $new_give_option_names;
110 110
 
111 111
 		// Delete all the Plugin Options.
112
-		foreach ( $give_option_names as $option ) {
113
-			if ( false !== strpos( $option, '_transient_' ) ) {
114
-				delete_transient( $option );
112
+		foreach ($give_option_names as $option) {
113
+			if (false !== strpos($option, '_transient_')) {
114
+				delete_transient($option);
115 115
 			} else {
116
-				delete_option( $option );
116
+				delete_option($option);
117 117
 			}
118 118
 		}
119 119
 	}
Please login to merge, or discard this patch.
includes/formatting.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
  * @param $field_args
226 226
  * @param $field
227 227
  *
228
- * @return bool
228
+ * @return false|null
229 229
  */
230 230
 function give_format_admin_multilevel_amount( $field_args, $field ) {
231 231
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @param   array  $field_args
376 376
  * @param   object $field
377 377
  *
378
- * @return mixed
378
+ * @return string
379 379
  */
380 380
 function give_sanitize_thousand_separator( $value, $field_args, $field ){
381 381
     return stripslashes( $value );
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
  * @param   array  $field_args
409 409
  * @param   object $field
410 410
  *
411
- * @return  mixed
411
+ * @return  string
412 412
  */
413 413
 function give_sanitize_price_field_value( $value, $field_args, $field ){
414 414
     return give_sanitize_amount( $value );
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return mixed
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37
-	return give_get_option( 'thousands_separator', ',' );
37
+	return give_get_option('thousands_separator', ',');
38 38
 }
39 39
 
40 40
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return mixed
46 46
  */
47 47
 function give_get_price_decimal_separator() {
48
-	return give_get_option( 'decimal_separator', '.' );
48
+	return give_get_option('decimal_separator', '.');
49 49
 }
50 50
 
51 51
 /**
@@ -62,67 +62,67 @@  discard block
 block discarded – undo
62 62
  *
63 63
  * @return string $amount Newly sanitized amount
64 64
  */
65
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
65
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
66 66
 
67 67
 	// Bailout.
68
-	if ( empty( $number ) ) {
68
+	if (empty($number)) {
69 69
 		return $number;
70 70
 	}
71 71
 
72 72
 	// Remove slash from amount.
73 73
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
74 74
 	// To prevent notices and warning remove slash from amount/number.
75
-	$number = wp_unslash( $number );
75
+	$number = wp_unslash($number);
76 76
 
77 77
 	$thousand_separator = give_get_price_thousand_separator();
78 78
 
79 79
 	$locale   = localeconv();
80
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
80
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
81 81
 
82 82
 	// Remove locale from string
83
-	if ( ! is_float( $number ) ) {
84
-		$number = str_replace( $decimals, '.', $number );
83
+	if ( ! is_float($number)) {
84
+		$number = str_replace($decimals, '.', $number);
85 85
 	}
86 86
 
87 87
 	// Remove thousand amount formatting if amount has.
88 88
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
89 89
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
90
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
91
-		$number = str_replace( $thousand_separator, '', $number );
92
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
93
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
90
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
91
+		$number = str_replace($thousand_separator, '', $number);
92
+	} elseif (in_array($thousand_separator, $decimals)) {
93
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
94 94
 	}
95 95
 
96 96
 	// Remove non numeric entity before decimal separator.
97
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
97
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
98 98
 	$default_dp = give_get_price_decimals();
99 99
 
100 100
 	// Reset negative amount to zero.
101
-	if ( 0 > $number ) {
102
-		$number = number_format( 0, $default_dp, '.' );
101
+	if (0 > $number) {
102
+		$number = number_format(0, $default_dp, '.');
103 103
 	}
104 104
 
105 105
 	// If number does not have decimal then add number of decimals to it.
106 106
 	if (
107
-		false === strpos( $number, '.' )
108
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
107
+		false === strpos($number, '.')
108
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
109 109
 	) {
110
-		$number = number_format( $number, $default_dp, '.', '' );
110
+		$number = number_format($number, $default_dp, '.', '');
111 111
 	}
112 112
 
113 113
 	// Format number by custom number of decimals.
114
-	if ( false !== $dp ) {
115
-		$dp     = intval( empty( $dp ) ? $default_dp : $dp );
116
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
117
-		$number = number_format( floatval( $number ), $dp, '.', '' );
114
+	if (false !== $dp) {
115
+		$dp     = intval(empty($dp) ? $default_dp : $dp);
116
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
117
+		$number = number_format(floatval($number), $dp, '.', '');
118 118
 	}
119 119
 
120 120
 	// Trim zeros.
121
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
122
-		$number = rtrim( rtrim( $number, '0' ), '.' );
121
+	if ($trim_zeros && strstr($number, '.')) {
122
+		$number = rtrim(rtrim($number, '0'), '.');
123 123
 	}
124 124
 
125
-	return apply_filters( 'give_sanitize_amount', $number );
125
+	return apply_filters('give_sanitize_amount', $number);
126 126
 }
127 127
 
128 128
 /**
@@ -135,22 +135,22 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return string $amount   Newly formatted amount or Price Not Available
137 137
  */
138
-function give_format_amount( $amount, $decimals = true ) {
139
-	$thousands_sep = give_get_option( 'thousands_separator', ',' );
140
-	$decimal_sep   = give_get_option( 'decimal_separator', '.' );
138
+function give_format_amount($amount, $decimals = true) {
139
+	$thousands_sep = give_get_option('thousands_separator', ',');
140
+	$decimal_sep   = give_get_option('decimal_separator', '.');
141 141
 
142
-	if ( empty( $amount ) ) {
142
+	if (empty($amount)) {
143 143
 		$amount = 0;
144 144
 	} else {
145 145
 		// Sanitize amount before formatting.
146
-		$amount = give_sanitize_amount( $amount );
146
+		$amount = give_sanitize_amount($amount);
147 147
 	}
148 148
 
149 149
 	$decimals = $decimals ? give_get_price_decimals() : 0;
150 150
 
151
-	$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
151
+	$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
152 152
 
153
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep );
153
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep);
154 154
 }
155 155
 
156 156
 
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
  *
168 168
  * @return float|string  formatted amount number with large number names.
169 169
  */
170
-function give_human_format_large_amount( $amount ) {
170
+function give_human_format_large_amount($amount) {
171 171
 
172 172
 	// Get thousand separator.
173 173
 	$thousands_sep = give_get_price_thousand_separator();
174 174
 
175 175
 	// Sanitize amount.
176
-	$sanitize_amount = give_sanitize_amount( $amount );
176
+	$sanitize_amount = give_sanitize_amount($amount);
177 177
 
178 178
 	// Explode amount to calculate name of large numbers.
179
-	$amount_array = explode( $thousands_sep, $amount );
179
+	$amount_array = explode($thousands_sep, $amount);
180 180
 
181 181
 	// Calculate amount parts count.
182
-	$amount_count_parts = count( $amount_array );
182
+	$amount_count_parts = count($amount_array);
183 183
 
184 184
 	// Human format amount (default).
185 185
 	$human_format_amount = $amount;
186 186
 
187 187
 	// Calculate large number formatted amount.
188
-	if ( 4 < $amount_count_parts ) {
189
-		$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
190
-	} elseif ( 3 < $amount_count_parts ) {
191
-		$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
192
-	} elseif ( 2 < $amount_count_parts ) {
193
-		$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
188
+	if (4 < $amount_count_parts) {
189
+		$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
190
+	} elseif (3 < $amount_count_parts) {
191
+		$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
192
+	} elseif (2 < $amount_count_parts) {
193
+		$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
194 194
 	}
195 195
 
196
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
196
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
197 197
 }
198 198
 
199 199
 /**
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return string $amount Newly formatted amount or Price Not Available
208 208
  */
209
-function give_format_decimal( $amount, $dp = false ) {
209
+function give_format_decimal($amount, $dp = false) {
210 210
 	$decimal_separator = give_get_price_decimal_separator();
211
-	$formatted_amount  = give_sanitize_amount( $amount, $dp );
211
+	$formatted_amount  = give_sanitize_amount($amount, $dp);
212 212
 
213
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
214
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
213
+	if (false !== strpos($formatted_amount, '.')) {
214
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
215 215
 	}
216 216
 
217
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
217
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
218 218
 }
219 219
 
220 220
 
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
  *
229 229
  * @return bool
230 230
  */
231
-function give_format_admin_multilevel_amount( $field_args, $field ) {
231
+function give_format_admin_multilevel_amount($field_args, $field) {
232 232
 
233
-	if ( empty( $field->value ) ) {
233
+	if (empty($field->value)) {
234 234
 		return false;
235 235
 	}
236 236
 
237
-	$field->value = give_format_decimal( $field->value );
237
+	$field->value = give_format_decimal($field->value);
238 238
 }
239 239
 
240 240
 /**
@@ -247,24 +247,24 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return mixed|string|void
249 249
  */
250
-function give_currency_filter( $price = '', $currency = '' ) {
250
+function give_currency_filter($price = '', $currency = '') {
251 251
 
252
-	if ( empty( $currency ) ) {
252
+	if (empty($currency)) {
253 253
 		$currency = give_get_currency();
254 254
 	}
255 255
 
256
-	$position = give_get_option( 'currency_position', 'before' );
256
+	$position = give_get_option('currency_position', 'before');
257 257
 
258 258
 	$negative = $price < 0;
259 259
 
260
-	if ( $negative ) {
260
+	if ($negative) {
261 261
 		// Remove proceeding "-".
262
-		$price = substr( $price, 1 );
262
+		$price = substr($price, 1);
263 263
 	}
264 264
 
265
-	$symbol = give_currency_symbol( $currency );
265
+	$symbol = give_currency_symbol($currency);
266 266
 
267
-	switch ( $currency ):
267
+	switch ($currency):
268 268
 		case 'GBP' :
269 269
 		case 'BRL' :
270 270
 		case 'EUR' :
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
 		case 'MAD' :
294 294
 		case 'KRW' :
295 295
 		case 'ZAR' :
296
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
296
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
297 297
 			break;
298 298
 		case 'NOK' :
299
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
299
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
300 300
 			break;
301 301
 		default :
302
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
302
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
303 303
 			break;
304 304
 	endswitch;
305 305
 
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	 *           filter name will be give_usd_currency_filter_after
316 316
 	 *
317 317
 	 */
318
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
318
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
319 319
 
320
-	if ( $negative ) {
320
+	if ($negative) {
321 321
 		// Prepend the minus sign before the currency sign.
322
-		$formatted = '-' . $formatted;
322
+		$formatted = '-'.$formatted;
323 323
 	}
324 324
 
325 325
 	return $formatted;
@@ -335,22 +335,22 @@  discard block
 block discarded – undo
335 335
  */
336 336
 function give_currency_decimal_filter() {
337 337
 
338
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
338
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
339 339
 
340 340
 	// Set default number of decimals.
341 341
 	$decimals = give_get_price_decimals();
342 342
 
343
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
343
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
344 344
 
345 345
 
346 346
 	// Get number of decimals with backward compatibility ( version < 1.6 )
347
-	if ( 1 <= func_num_args() ) {
348
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
347
+	if (1 <= func_num_args()) {
348
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
349 349
 	}
350 350
 
351 351
 	$currency = give_get_currency();
352 352
 
353
-	switch ( $currency ) {
353
+	switch ($currency) {
354 354
 		case 'RIAL' :
355 355
 		case 'JPY' :
356 356
 		case 'TWD' :
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 			break;
361 361
 	}
362 362
 
363
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
363
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
364 364
 }
365 365
 
366
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
367
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
366
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
367
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
368 368
 
369 369
 /**
370 370
  * Sanitize thousand separator
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @return mixed
380 380
  */
381
-function give_sanitize_thousand_separator( $value, $field_args, $field ) {
382
-	return stripslashes( $value );
381
+function give_sanitize_thousand_separator($value, $field_args, $field) {
382
+	return stripslashes($value);
383 383
 }
384 384
 
385 385
 
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
  *
396 396
  * @return  mixed
397 397
  */
398
-function give_sanitize_number_decimals( $value, $field_args, $field ) {
399
-	return absint( $value );
398
+function give_sanitize_number_decimals($value, $field_args, $field) {
399
+	return absint($value);
400 400
 }
401 401
 
402 402
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @return  mixed
413 413
  */
414
-function give_sanitize_price_field_value( $value, $field_args, $field ) {
415
-	return give_sanitize_amount( $value );
414
+function give_sanitize_price_field_value($value, $field_args, $field) {
415
+	return give_sanitize_amount($value);
416 416
 }
417 417
 
418 418
 
@@ -426,29 +426,29 @@  discard block
 block discarded – undo
426 426
  *
427 427
  * @return void
428 428
  */
429
-function give_cmb_amount_field_render_row_cb( $field_args, $field ) {
429
+function give_cmb_amount_field_render_row_cb($field_args, $field) {
430 430
 
431 431
 	// Get args.
432
-	$id                = $field->args( 'id' );
433
-	$label             = $field->args( 'name' );
434
-	$name              = $field->args( '_name' );
435
-	$description       = $field->args( 'description' );
436
-	$attributes        = $field->args( 'attributes' );
432
+	$id                = $field->args('id');
433
+	$label             = $field->args('name');
434
+	$name              = $field->args('_name');
435
+	$description       = $field->args('description');
436
+	$attributes        = $field->args('attributes');
437 437
 	$attributes_string = '';
438 438
 	$row_class         = $field->row_classes();
439 439
 
440 440
 	// Get attributes.
441
-	if ( ! empty( $attributes ) ) {
442
-		foreach ( $attributes as $attribute_name => $attribute_val ) {
441
+	if ( ! empty($attributes)) {
442
+		foreach ($attributes as $attribute_name => $attribute_val) {
443 443
 			$attributes_string[] = "$attribute_name=\"$attribute_val\"";
444 444
 		}
445 445
 
446
-		$attributes_string = implode( ' ', $attributes_string );
446
+		$attributes_string = implode(' ', $attributes_string);
447 447
 	}
448 448
 
449 449
 	// Get row class.
450
-	if ( ! empty( $row_class ) && is_array( $row_class ) ) {
451
-		$row_class = implode( ' ', $row_class );
450
+	if ( ! empty($row_class) && is_array($row_class)) {
451
+		$row_class = implode(' ', $row_class);
452 452
 	}
453 453
 	?>
454 454
 	<div class="cmb-row <?php echo $row_class; ?>">
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
 			<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
457 457
 		</div>
458 458
 		<div class="cmb-td">
459
-			<?php echo( give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); ?>
459
+			<?php echo(give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); ?>
460 460
 			<input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" <?php echo $attributes_string ?>/>
461
-			<?php echo( give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); ?>
461
+			<?php echo(give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); ?>
462 462
 
463 463
 			<span class="cmb2-metabox-description"><?php echo $description; ?></span>
464 464
 		</div>
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  *
478 478
  * @return string                  Date format string
479 479
  */
480
-function give_date_format ( $date_context = '' ) {
480
+function give_date_format($date_context = '') {
481 481
 	/**
482 482
 	 * Filter the date context
483 483
 	 *
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 *    }
500 500
 	 */
501
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
501
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
502 502
 
503 503
 	// Set date format to default date format.
504 504
 	$date_format = get_option('date_format');
505 505
 
506 506
 
507 507
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
508
-	if( $date_context &&  ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
509
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
510
-			? $date_format_contexts[ $date_context ]
508
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
509
+		$date_format = ! empty($date_format_contexts[$date_context])
510
+			? $date_format_contexts[$date_context]
511 511
 			: $date_format;
512 512
 	}
513 513
 
514
-	return apply_filters( 'give_date_format', $date_format );
514
+	return apply_filters('give_date_format', $date_format);
515 515
 }
516 516
 
517 517
 /**
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
  *
525 525
  * @return string
526 526
  */
527
-function give_get_cache_key( $action, $query_args ) {
527
+function give_get_cache_key($action, $query_args) {
528 528
 	// Bailout.
529
-	if( ! is_array( $query_args ) || empty( $query_args ) ) {
529
+	if ( ! is_array($query_args) || empty($query_args)) {
530 530
 		return '';
531 531
 	}
532 532
 
533
-	return "give_cache_{$action}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
533
+	return "give_cache_{$action}_".substr(md5(serialize($query_args)), 0, 15);
534 534
 }
535 535
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -689,7 +689,7 @@
 block discarded – undo
689 689
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
690 690
 								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
691 691
 							);
692
-						}else{
692
+						} else{
693 693
 							$messages[$subscription['id']] = sprintf(
694 694
 								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
695 695
 								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		 * @access private
220 220
 		 * @since  1.0
221 221
 		 *
222
-		 * @return bool
222
+		 * @return false|null
223 223
 		 */
224 224
 		public function auto_updater() {
225 225
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		 * @access public
476 476
 		 * @since  1.7
477 477
 		 *
478
-		 * @return bool|void
478
+		 * @return false|null
479 479
 		 */
480 480
 		public function weekly_license_check() {
481 481
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		 * @access public
528 528
 		 * @since  1.7
529 529
 		 *
530
-		 * @return bool|void
530
+		 * @return false|null
531 531
 		 */
532 532
 		public function weekly_subscription_check() {
533 533
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 		 * @access private
608 608
 		 * @since  1.7
609 609
 		 *
610
-		 * @return bool|void
610
+		 * @return false|null
611 611
 		 */
612 612
 		private function __single_subscription_check() {
613 613
 			// Do not fire if license key is not set.
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 		 * @access private
803 803
 		 * @since  1.7
804 804
 		 *
805
-		 * @return void|bool
805
+		 * @return false|null
806 806
 		 */
807 807
 		private function __remove_license_key_from_subscriptions(){
808 808
 			$subscriptions = get_option( 'give_subscriptions', array() );
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @var    string
105 105
 		 */
106
-		private $api_url      = 'https://givewp.com/edd-sl-api/';
106
+		private $api_url = 'https://givewp.com/edd-sl-api/';
107 107
 
108 108
 		/**
109 109
 		 * Account URL
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @var null|string
115 115
 		 */
116
-		private $account_url  = 'https://givewp.com/my-account/';
116
+		private $account_url = 'https://givewp.com/my-account/';
117 117
 
118 118
 		/**
119 119
 		 * Ccheckout URL
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 		 * @param string  $_checkout_url
143 143
 		 * @param string  $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 			$give_options = give_get_settings();
147 147
 
148 148
 			$this->file           = $_file;
149 149
 			$this->item_name      = $_item_name;
150
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
150
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
151 151
 			$this->version        = $_version;
152
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
153
-			$this->license_data   = get_option( $this->item_shortname . '_license_active' );
152
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
153
+			$this->license_data   = get_option($this->item_shortname.'_license_active');
154 154
 			$this->author         = $_author;
155
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
156
-			$this->checkout_url   = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
157
-			$this->account_url    = is_null( $_account_url ) ? $this->account_url : $_account_url;
155
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
156
+			$this->checkout_url   = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
157
+			$this->account_url    = is_null($_account_url) ? $this->account_url : $_account_url;
158 158
 
159 159
 			// Setup hooks
160 160
 			$this->includes();
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		 * @return void
174 174
 		 */
175 175
 		private function includes() {
176
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
176
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
177 177
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
178 178
 			}
179 179
 		}
@@ -191,26 +191,26 @@  discard block
 block discarded – undo
191 191
 		private function hooks() {
192 192
 
193 193
 			// Register settings
194
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
194
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
195 195
 
196 196
 			// Activate license key on settings save
197
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
197
+			add_action('admin_init', array($this, 'activate_license'));
198 198
 
199 199
 			// Deactivate license key
200
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
200
+			add_action('admin_init', array($this, 'deactivate_license'));
201 201
 
202 202
 			// Updater
203
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
203
+			add_action('admin_init', array($this, 'auto_updater'), 0);
204 204
 
205
-			add_action( 'admin_notices', array( $this, 'notices' ) );
205
+			add_action('admin_notices', array($this, 'notices'));
206 206
 
207 207
 			// Check license weekly.
208
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
209
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
208
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
209
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
210 210
 
211 211
 			// Check subscription weekly.
212
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
213
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
212
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
213
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
214 214
 		}
215 215
 
216 216
 		/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 */
224 224
 		public function auto_updater() {
225 225
 
226
-			if ( ! $this->is_valid_license() ) {
226
+			if ( ! $this->is_valid_license()) {
227 227
 				return false;
228 228
 			}
229 229
 
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 		 *
253 253
 		 * @return array           License settings.
254 254
 		 */
255
-		public function settings( $settings ) {
255
+		public function settings($settings) {
256 256
 
257 257
 			$give_license_settings = array(
258 258
 				array(
259 259
 					'name'    => $this->item_name,
260
-					'id'      => $this->item_shortname . '_license_key',
260
+					'id'      => $this->item_shortname.'_license_key',
261 261
 					'desc'    => '',
262 262
 					'type'    => 'license_key',
263 263
 					'options' => array(
264
-						'license'       => get_option( $this->item_shortname . '_license_active' ),
264
+						'license'       => get_option($this->item_shortname.'_license_active'),
265 265
 						'shortname'     => $this->item_shortname,
266 266
 						'item_name'     => $this->item_name,
267 267
 						'api_url'       => $this->api_url,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				)
273 273
 			);
274 274
 
275
-			return array_merge( $settings, $give_license_settings );
275
+			return array_merge($settings, $give_license_settings);
276 276
 		}
277 277
 
278 278
 		/**
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @return array           License settings content.
289 289
 		 */
290
-		public function license_settings_content( $settings ) {
290
+		public function license_settings_content($settings) {
291 291
 
292 292
 			$give_license_settings = array(
293 293
 				array(
294
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
294
+					'name' => esc_html__('Add-on Licenses', 'give'),
295 295
 					'desc' => '<hr>',
296 296
 					'type' => 'give_title',
297 297
 					'id'   => 'give_title'
298 298
 				),
299 299
 			);
300 300
 
301
-			return array_merge( $settings, $give_license_settings );
301
+			return array_merge($settings, $give_license_settings);
302 302
 		}
303 303
 
304 304
 		/**
@@ -313,37 +313,37 @@  discard block
 block discarded – undo
313 313
 		 */
314 314
 		public function activate_license() {
315 315
 			// Bailout: Check if license key set of not.
316
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
316
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
317 317
 				return;
318 318
 			}
319 319
 
320 320
 			// Security check.
321
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
321
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
322 322
 
323
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
323
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
324 324
 
325 325
 			}
326 326
 
327 327
 			// Check if user have correct permissions.
328
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
328
+			if ( ! current_user_can('manage_give_settings')) {
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Allow third party addon developers to handle license activation.
333
-			if( $this->__is_third_party_addon() ){
334
-				do_action( 'give_activate_license', $this );
333
+			if ($this->__is_third_party_addon()) {
334
+				do_action('give_activate_license', $this);
335 335
 				return;
336 336
 			}
337 337
 
338 338
 			// Delete previous license setting if a empty license key submitted.
339
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
340
-				delete_option( $this->item_shortname . '_license_active' );
339
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
340
+				delete_option($this->item_shortname.'_license_active');
341 341
 				return;
342 342
 			}
343 343
 
344 344
 			// Do not simultaneously activate any addon if user want to deactivate any addon.
345
-			foreach ( $_POST as $key => $value ) {
346
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
345
+			foreach ($_POST as $key => $value) {
346
+				if (false !== strpos($key, 'license_key_deactivate')) {
347 347
 					// Don't activate a key when deactivating a different key
348 348
 					return;
349 349
 				}
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 
352 352
 
353 353
 			// Check if plugin previously installed.
354
-			if ( $this->is_valid_license() ) {
354
+			if ($this->is_valid_license()) {
355 355
 				return;
356 356
 			}
357 357
 
358 358
 			// Get license key.
359
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
359
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
360 360
 
361 361
 			// Bailout.
362
-			if( empty( $license ) ) {
362
+			if (empty($license)) {
363 363
 				return;
364 364
 			}
365 365
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$api_params = array(
371 371
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
372 372
 				'license'    => $license,
373
-				'item_name'  => urlencode( $this->item_name ),
373
+				'item_name'  => urlencode($this->item_name),
374 374
 				'url'        => home_url()
375 375
 			);
376 376
 
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 			);
386 386
 
387 387
 			// Make sure there are no errors
388
-			if ( is_wp_error( $response ) ) {
388
+			if (is_wp_error($response)) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Tell WordPress to look for updates
393
-			set_site_transient( 'update_plugins', null );
393
+			set_site_transient('update_plugins', null);
394 394
 
395 395
 			// Decode license data
396
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
397
-			update_option( $this->item_shortname . '_license_active', $license_data );
396
+			$license_data = json_decode(wp_remote_retrieve_body($response));
397
+			update_option($this->item_shortname.'_license_active', $license_data);
398 398
 
399 399
 			// Check subscription for license key and store this to db (if any).
400 400
 			$this->__single_subscription_check();
@@ -412,34 +412,34 @@  discard block
 block discarded – undo
412 412
 		 */
413 413
 		public function deactivate_license() {
414 414
 
415
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
415
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
416 416
 				return;
417 417
 			}
418 418
 
419
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
419
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
420 420
 
421
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
421
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
422 422
 
423 423
 			}
424 424
 
425
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
425
+			if ( ! current_user_can('manage_give_settings')) {
426 426
 				return;
427 427
 			}
428 428
 
429 429
 			// Allow third party addon developers to handle license deactivation.
430
-			if( $this->__is_third_party_addon() ){
431
-				do_action( 'give_deactivate_license', $this );
430
+			if ($this->__is_third_party_addon()) {
431
+				do_action('give_deactivate_license', $this);
432 432
 				return;
433 433
 			}
434 434
 
435 435
 			// Run on deactivate button press
436
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
436
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
437 437
 
438 438
 				// Data to send to the API
439 439
 				$api_params = array(
440 440
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
441 441
 					'license'    => $this->license,
442
-					'item_name'  => urlencode( $this->item_name ),
442
+					'item_name'  => urlencode($this->item_name),
443 443
 					'url'        => home_url()
444 444
 				);
445 445
 
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 				);
455 455
 
456 456
 				// Make sure there are no errors
457
-				if ( is_wp_error( $response ) ) {
457
+				if (is_wp_error($response)) {
458 458
 					return;
459 459
 				}
460 460
 
461 461
 				// Decode the license data
462
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
462
+				$license_data = json_decode(wp_remote_retrieve_body($response));
463 463
 
464 464
 				// Remove license data.
465
-				delete_option( $this->item_shortname . '_license_active' );
465
+				delete_option($this->item_shortname.'_license_active');
466 466
 
467 467
 				// Remove license key from subscriptions if exist.
468 468
 				$this->__remove_license_key_from_subscriptions();
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 		 */
480 480
 		public function weekly_license_check() {
481 481
 
482
-			if( ! empty( $_POST['give_settings'] ) ) {
482
+			if ( ! empty($_POST['give_settings'])) {
483 483
 				// Don't fire when saving settings
484 484
 				return false;
485 485
 			}
486 486
 
487
-			if( empty( $this->license ) ) {
487
+			if (empty($this->license)) {
488 488
 				return false;
489 489
 			}
490 490
 
491 491
 			// Allow third party addon developers to handle their license check.
492
-			if( $this->__is_third_party_addon() ){
493
-				do_action( 'give_weekly_license_check', $this );
492
+			if ($this->__is_third_party_addon()) {
493
+				do_action('give_weekly_license_check', $this);
494 494
 				return false;
495 495
 			}
496 496
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$api_params = array(
499 499
 				'edd_action'=> 'check_license',
500 500
 				'license' 	=> $this->license,
501
-				'item_name' => urlencode( $this->item_name ),
501
+				'item_name' => urlencode($this->item_name),
502 502
 				'url'       => home_url()
503 503
 			);
504 504
 
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 			);
514 514
 
515 515
 			// Make sure the response came back okay.
516
-			if ( is_wp_error( $response ) ) {
516
+			if (is_wp_error($response)) {
517 517
 				return false;
518 518
 			}
519 519
 
520
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
521
-			update_option( $this->item_shortname . '_license_active', $license_data );
520
+			$license_data = json_decode(wp_remote_retrieve_body($response));
521
+			update_option($this->item_shortname.'_license_active', $license_data);
522 522
 		}
523 523
 
524 524
 		/**
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
 		 */
532 532
 		public function weekly_subscription_check() {
533 533
 
534
-			if( ! empty( $_POST['give_settings'] ) ) {
534
+			if ( ! empty($_POST['give_settings'])) {
535 535
 				// Don't fire when saving settings
536 536
 				return false;
537 537
 			}
538 538
 
539 539
 			// Remove old subscription data.
540
-			if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){
541
-				delete_option( 'give_subscriptions' );
542
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) );
540
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
541
+				delete_option('give_subscriptions');
542
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
543 543
 			}
544 544
 
545
-			if( empty( $this->license ) ) {
545
+			if (empty($this->license)) {
546 546
 				return false;
547 547
 			}
548 548
 
549 549
 			// Allow third party addon developers to handle there subscription check.
550
-			if( $this->__is_third_party_addon() ){
551
-				do_action( 'give_weekly_subscription_check', $this );
550
+			if ($this->__is_third_party_addon()) {
551
+				do_action('give_weekly_subscription_check', $this);
552 552
 				return false;
553 553
 			}
554 554
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				// This is custom feature to check subscriptions.
563 563
 				'edd_action'=> 'check_subscription',
564 564
 				'license' 	=> $this->license,
565
-				'item_name' => urlencode( $this->item_name ),
565
+				'item_name' => urlencode($this->item_name),
566 566
 				'url'       => home_url()
567 567
 			);
568 568
 
@@ -577,27 +577,27 @@  discard block
 block discarded – undo
577 577
 			);
578 578
 
579 579
 			// Make sure the response came back okay.
580
-			if ( is_wp_error( $response ) ) {
580
+			if (is_wp_error($response)) {
581 581
 				return false;
582 582
 			}
583 583
 
584
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
584
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
585 585
 
586
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
587
-				$subscriptions = get_option( 'give_subscriptions', array() );
586
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
587
+				$subscriptions = get_option('give_subscriptions', array());
588 588
 
589 589
 				// Update subscription data only if subscription does not exist already.
590
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
591
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
592
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
590
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
591
+					$subscriptions[$subscription_data['id']] = $subscription_data;
592
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
593 593
 				}
594 594
 
595 595
 				// Store licenses for subscription.
596
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
597
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
596
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
597
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
598 598
 				}
599 599
 
600
-				update_option( 'give_subscriptions', $subscriptions );
600
+				update_option('give_subscriptions', $subscriptions);
601 601
 			}
602 602
 		}
603 603
 
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
 		 */
612 612
 		private function __single_subscription_check() {
613 613
 			// Do not fire if license key is not set.
614
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
614
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
615 615
 				return false;
616 616
 			}
617 617
 
618
-			if( empty( $this->license ) ) {
618
+			if (empty($this->license)) {
619 619
 				return false;
620 620
 			}
621 621
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 				// This is custom feature to check subscriptions.
627 627
 				'edd_action'=> 'check_subscription',
628 628
 				'license' 	=> $this->license,
629
-				'item_name' => urlencode( $this->item_name ),
629
+				'item_name' => urlencode($this->item_name),
630 630
 				'url'       => home_url()
631 631
 			);
632 632
 
@@ -641,27 +641,27 @@  discard block
 block discarded – undo
641 641
 			);
642 642
 
643 643
 			// Make sure the response came back okay.
644
-			if ( is_wp_error( $response ) ) {
644
+			if (is_wp_error($response)) {
645 645
 				return false;
646 646
 			}
647 647
 
648
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
648
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
649 649
 
650
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
651
-				$subscriptions = get_option( 'give_subscriptions', array() );
650
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
651
+				$subscriptions = get_option('give_subscriptions', array());
652 652
 
653 653
 				// Update subscription data only if subscription does not exist already.
654
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
655
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
656
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
654
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
655
+					$subscriptions[$subscription_data['id']] = $subscription_data;
656
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
657 657
 				}
658 658
 
659 659
 				// Store licenses for subscription.
660
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
661
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
660
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
661
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
662 662
 				}
663 663
 
664
-				update_option( 'give_subscriptions', $subscriptions );
664
+				update_option('give_subscriptions', $subscriptions);
665 665
 			}
666 666
 		}
667 667
 
@@ -679,87 +679,87 @@  discard block
 block discarded – undo
679 679
 			static $addon_license_key_in_subscriptions;
680 680
 
681 681
 			// Set default value.
682
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
682
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
683 683
 
684
-			if( empty( $this->license ) ) {
684
+			if (empty($this->license)) {
685 685
 				return;
686 686
 			}
687 687
 
688
-			if( ! current_user_can( 'manage_shop_settings' ) ) {
688
+			if ( ! current_user_can('manage_shop_settings')) {
689 689
 				return;
690 690
 			}
691 691
 
692 692
 			// Do not show licenses notices on license tab.
693
-			if( ! empty( $_GET['tab'] ) && 'licenses' === $_GET['tab'] ) {
693
+			if ( ! empty($_GET['tab']) && 'licenses' === $_GET['tab']) {
694 694
 				return;
695 695
 			}
696 696
 
697 697
 			$messages = array();
698 698
 
699 699
 			// Get subscriptions.
700
-			$subscriptions = get_option( 'give_subscriptions' );
700
+			$subscriptions = get_option('give_subscriptions');
701 701
 
702 702
 			// Show subscription messages.
703
-			if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
703
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
704 704
 
705
-				foreach ( $subscriptions as $subscription ) {
705
+				foreach ($subscriptions as $subscription) {
706 706
 					// Subscription expires timestamp.
707
-					$subscription_expires = strtotime( $subscription['expires'] );
707
+					$subscription_expires = strtotime($subscription['expires']);
708 708
 
709 709
 					// Start showing subscriptions message before one week of renewal date.
710
-					if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
710
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
711 711
 						continue;
712 712
 					}
713 713
 
714 714
 					// Check if subscription message already exist in messages.
715
-					if( array_key_exists( $subscription['id'], $messages ) ) {
715
+					if (array_key_exists($subscription['id'], $messages)) {
716 716
 						continue;
717 717
 					}
718 718
 
719
-					if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) {
719
+					if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) {
720 720
 
721
-						if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired.
721
+						if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired.
722 722
 							$messages[$subscription['id']] = sprintf(
723
-								__( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
724
-								urldecode( $subscription['invoice_url'] ),
723
+								__('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
724
+								urldecode($subscription['invoice_url']),
725 725
 								$subscription['payment_id'],
726 726
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
727
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
727
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
728 728
 							);
729
-						}else{
729
+						} else {
730 730
 							$messages[$subscription['id']] = sprintf(
731
-								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
732
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
733
-								urldecode( $subscription['invoice_url'] ),
731
+								__('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
732
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
733
+								urldecode($subscription['invoice_url']),
734 734
 								$subscription['payment_id'],
735 735
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
736
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
736
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
737 737
 							);
738 738
 						}
739 739
 					}
740 740
 
741 741
 					// Stop validation for these licencse keys.
742
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
742
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
743 743
 				}
744 744
 				$showed_subscriptions_message = true;
745 745
 			}
746 746
 
747 747
 			// Show non subscription addon messages.
748
-			if( ! in_array( $this->license, $addon_license_key_in_subscriptions ) && ! $this->__is_notice_dismissed( 'general' ) && ! $this->is_valid_license() && empty( $showed_invalid_message ) ) {
748
+			if ( ! in_array($this->license, $addon_license_key_in_subscriptions) && ! $this->__is_notice_dismissed('general') && ! $this->is_valid_license() && empty($showed_invalid_message)) {
749 749
 
750 750
 				$messages['general'] = sprintf(
751
-					__( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
752
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
751
+					__('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
752
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
753 753
 				);
754 754
 				$showed_invalid_message = true;
755 755
 
756 756
 			}
757 757
 
758 758
 			// Print messages.
759
-			if( ! empty( $messages ) ) {
760
-				foreach( $messages as $notice_id => $message ) {
761
-					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="' . esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ) . '">';
762
-					echo '<p>' . $message . '</p>';
759
+			if ( ! empty($messages)) {
760
+				foreach ($messages as $notice_id => $message) {
761
+					echo '<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="'.esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])).'">';
762
+					echo '<p>'.$message.'</p>';
763 763
 					echo '</div>';
764 764
 				}
765 765
 			}
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		 * @return bool
775 775
 		 */
776 776
 		public function is_valid_license() {
777
-			if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) &&  property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) {
777
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
778 778
 				return true;
779 779
 			}
780 780
 
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		 * @return bool
791 791
 		 */
792 792
 		private function __is_third_party_addon() {
793
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
793
+			return (false === strpos($this->api_url, 'givewp.com/'));
794 794
 		}
795 795
 
796 796
 		/**
@@ -804,26 +804,26 @@  discard block
 block discarded – undo
804 804
 		 *
805 805
 		 * @return void|bool
806 806
 		 */
807
-		private function __remove_license_key_from_subscriptions(){
808
-			$subscriptions = get_option( 'give_subscriptions', array() );
807
+		private function __remove_license_key_from_subscriptions() {
808
+			$subscriptions = get_option('give_subscriptions', array());
809 809
 
810 810
 			// Bailout.
811
-			if( empty( $this->license ) ) {
811
+			if (empty($this->license)) {
812 812
 				return false;
813 813
 			}
814 814
 
815
-			if( ! empty( $subscriptions ) ) {
816
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
817
-					$license_index = array_search( $this->license, $subscription['licenses'] );
818
-					if( false !== $license_index ) {
815
+			if ( ! empty($subscriptions)) {
816
+				foreach ($subscriptions as $subscription_id => $subscription) {
817
+					$license_index = array_search($this->license, $subscription['licenses']);
818
+					if (false !== $license_index) {
819 819
 						// Remove license key.
820
-						unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] );
820
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
821 821
 
822 822
 						// Rearrange license keys.
823
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
823
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
824 824
 
825 825
 						// Update subscription information.
826
-						update_option( 'give_subscriptions', $subscriptions );
826
+						update_option('give_subscriptions', $subscriptions);
827 827
 						break;
828 828
 					}
829 829
 				}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		 *
839 839
 		 * @return void
840 840
 		 */
841
-		private function __remove_license_notices_show_blocker(){
841
+		private function __remove_license_notices_show_blocker() {
842 842
 			global $wpdb;
843 843
 
844 844
 			// Delete permanent notice blocker.
@@ -876,18 +876,18 @@  discard block
 block discarded – undo
876 876
 		 *
877 877
 		 * @return bool
878 878
 		 */
879
-		private function __is_notice_dismissed( $notice_id ){
879
+		private function __is_notice_dismissed($notice_id) {
880 880
 			$current_user = wp_get_current_user();
881 881
 			$is_notice_dismissed = false;
882 882
 
883 883
 			// Ge is notice dismissed permanently.
884
-			$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
884
+			$already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
885 885
 				? $already_dismiss_notices
886 886
 				: array();
887 887
 
888 888
 
889
-			if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) {
890
-				$is_notice_dismissed =  true;
889
+			if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) {
890
+				$is_notice_dismissed = true;
891 891
 			}
892 892
 
893 893
 			return $is_notice_dismissed;
Please login to merge, or discard this patch.
includes/gateways/actions.php 1 patch
Spacing   +13 added lines, -13 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
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  * @return void
39 39
  */
40 40
 function give_load_ajax_gateway() {
41
-	if ( isset( $_POST['give_payment_mode'] ) ) {
41
+	if (isset($_POST['give_payment_mode'])) {
42 42
 		/**
43 43
 		 * Fire to render donation form.
44 44
 		 *
45 45
 		 * @since 1.7
46 46
 		 */
47
-		do_action( 'give_donation_form', $_POST['give_form_id'] );
47
+		do_action('give_donation_form', $_POST['give_form_id']);
48 48
 
49 49
 		exit();
50 50
 	}
51 51
 }
52 52
 
53
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
54
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
53
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
54
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
55 55
 
56 56
 /**
57 57
  * Sets an error on checkout if no gateways are enabled
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 function give_no_gateway_error() {
64 64
 	$gateways = give_get_enabled_payment_gateways();
65 65
 
66
-	if ( empty( $gateways ) ) {
67
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
66
+	if (empty($gateways)) {
67
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
68 68
 	} else {
69
-		give_unset_error( 'no_gateways' );
69
+		give_unset_error('no_gateways');
70 70
 	}
71 71
 }
72 72
 
73
-add_action( 'init', 'give_no_gateway_error' );
73
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +59 added lines, -59 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
 
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
55
-		if ( empty( $form_id ) ) {
55
+		if (empty($form_id)) {
56 56
 
57 57
 			// Global sale stats
58
-			add_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
58
+			add_filter('give_count_payments_where', array($this, 'count_where'));
59 59
 
60
-			if ( is_array( $status ) ) {
60
+			if (is_array($status)) {
61 61
 				$count = 0;
62
-				foreach ( $status as $payment_status ) {
62
+				foreach ($status as $payment_status) {
63 63
 					$count += give_count_payments()->$payment_status;
64 64
 				}
65 65
 			} else {
66 66
 				$count = give_count_payments()->$status;
67 67
 			}
68 68
 
69
-			remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) );
69
+			remove_filter('give_count_payments_where', array($this, 'count_where'));
70 70
 
71 71
 		} else {
72 72
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			// Product specific stats
76 76
 			global $give_logs;
77 77
 
78
-			add_filter( 'posts_where', array( $this, 'payments_where' ) );
78
+			add_filter('posts_where', array($this, 'payments_where'));
79 79
 
80
-			$count = $give_logs->get_log_count( $form_id, 'sale' );
80
+			$count = $give_logs->get_log_count($form_id, 'sale');
81 81
 
82
-			remove_filter( 'posts_where', array( $this, 'payments_where' ) );
82
+			remove_filter('posts_where', array($this, 'payments_where'));
83 83
 
84 84
 		}
85 85
 
@@ -101,31 +101,31 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return float|int                Total amount of donations based on the passed arguments.
103 103
 	 */
104
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
104
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
105 105
 
106 106
 		global $wpdb;
107 107
 
108
-		$this->setup_dates( $start_date, $end_date );
108
+		$this->setup_dates($start_date, $end_date);
109 109
 
110 110
 		// Make sure start date is valid
111
-		if ( is_wp_error( $this->start_date ) ) {
111
+		if (is_wp_error($this->start_date)) {
112 112
 			return $this->start_date;
113 113
 		}
114 114
 
115 115
 		// Make sure end date is valid
116
-		if ( is_wp_error( $this->end_date ) ) {
116
+		if (is_wp_error($this->end_date)) {
117 117
 			return $this->end_date;
118 118
 		}
119 119
 
120
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
120
+		add_filter('posts_where', array($this, 'payments_where'));
121 121
 
122
-		if ( empty( $form_id ) ) {
122
+		if (empty($form_id)) {
123 123
 
124 124
 			// Global earning stats
125 125
 			$args = array(
126 126
 				'post_type'              => 'give_payment',
127 127
 				'nopaging'               => true,
128
-				'post_status'            => array( 'publish' ),
128
+				'post_status'            => array('publish'),
129 129
 				'fields'                 => 'ids',
130 130
 				'update_post_term_cache' => false,
131 131
 				'suppress_filters'       => false,
@@ -137,24 +137,24 @@  discard block
 block discarded – undo
137 137
 			);
138 138
 
139 139
 			//Filter by Gateway ID meta_key
140
-			if ( $gateway_id !== false ) {
140
+			if ($gateway_id !== false) {
141 141
 				$args['meta_key']   = '_give_payment_gateway';
142 142
 				$args['meta_value'] = $gateway_id;
143 143
 			}
144 144
 
145
-			$args = apply_filters( 'give_stats_earnings_args', $args );
146
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
147
-			$earnings = get_transient( $key );
145
+			$args = apply_filters('give_stats_earnings_args', $args);
146
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
147
+			$earnings = get_transient($key);
148 148
 			
149
-			if ( false === $earnings ) {
150
-				$sales    = get_posts( $args );
149
+			if (false === $earnings) {
150
+				$sales    = get_posts($args);
151 151
 				$earnings = 0;
152
-				if ( $sales ) {
153
-					$sales = implode( ',', array_map('intval', $sales ) );
154
-					$earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" );
152
+				if ($sales) {
153
+					$sales = implode(',', array_map('intval', $sales));
154
+					$earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})");
155 155
 				}
156 156
 				// Cache the results for one hour
157
-				set_transient( $key, $earnings, HOUR_IN_SECONDS );
157
+				set_transient($key, $earnings, HOUR_IN_SECONDS);
158 158
 			}
159 159
 
160 160
 		} else {
@@ -174,37 +174,37 @@  discard block
 block discarded – undo
174 174
 				'give_transient_type' => 'give_earnings',
175 175
 				// This is not a valid query arg, but is used for cache keying
176 176
 			);
177
-			$args = apply_filters( 'give_stats_earnings_args', $args );
178
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
177
+			$args = apply_filters('give_stats_earnings_args', $args);
178
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
179 179
 			//Set transient for faster stats
180
-			$earnings = get_transient( $key );
180
+			$earnings = get_transient($key);
181 181
 
182
-			if ( false === $earnings ) {
182
+			if (false === $earnings) {
183 183
 
184 184
 				$this->timestamp = false;
185
-				$log_ids  = $give_logs->get_connected_logs( $args, 'sale' );
185
+				$log_ids  = $give_logs->get_connected_logs($args, 'sale');
186 186
 				$earnings = 0;
187 187
 
188
-				if ( $log_ids ) {
189
-					$log_ids     = implode( ',', array_map('intval', $log_ids ) );
190
-					$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" );
188
+				if ($log_ids) {
189
+					$log_ids     = implode(',', array_map('intval', $log_ids));
190
+					$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);");
191 191
 
192
-					foreach ( $payment_ids as $payment_id ) {
193
-						$earnings += give_get_payment_amount( $payment_id );
192
+					foreach ($payment_ids as $payment_id) {
193
+						$earnings += give_get_payment_amount($payment_id);
194 194
 					}
195 195
 					
196 196
 				}
197 197
 
198 198
 				// Cache the results for one hour
199
-				set_transient( $key, $earnings, 60 * 60 );
199
+				set_transient($key, $earnings, 60 * 60);
200 200
 			}
201 201
 		}
202 202
 
203 203
 		//remove our filter
204
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
204
+		remove_filter('posts_where', array($this, 'payments_where'));
205 205
 
206 206
 		//return earnings
207
-		return round( $earnings, give_currency_decimal_filter() );
207
+		return round($earnings, give_currency_decimal_filter());
208 208
 
209 209
 	}
210 210
 
@@ -221,29 +221,29 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return float|int                Total amount of donations based on the passed arguments.
223 223
 	 */
224
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
224
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
225 225
 
226
-		$this->setup_dates( $start_date, $end_date );
226
+		$this->setup_dates($start_date, $end_date);
227 227
 
228 228
 		// Make sure start date is valid
229
-		if ( is_wp_error( $this->start_date ) ) {
229
+		if (is_wp_error($this->start_date)) {
230 230
 			return $this->start_date;
231 231
 		}
232 232
 
233 233
 		// Make sure end date is valid
234
-		if ( is_wp_error( $this->end_date ) ) {
234
+		if (is_wp_error($this->end_date)) {
235 235
 			return $this->end_date;
236 236
 		}
237 237
 
238
-		add_filter( 'posts_where', array( $this, 'payments_where' ) );
238
+		add_filter('posts_where', array($this, 'payments_where'));
239 239
 
240
-		if ( empty( $form_id ) ) {
240
+		if (empty($form_id)) {
241 241
 
242 242
 			// Global earning stats
243 243
 			$args = array(
244 244
 				'post_type'              => 'give_payment',
245 245
 				'nopaging'               => true,
246
-				'post_status'            => array( 'publish' ),
246
+				'post_status'            => array('publish'),
247 247
 				'fields'                 => 'ids',
248 248
 				'update_post_term_cache' => false,
249 249
 				'suppress_filters'       => false,
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 			);
256 256
 
257 257
 			//Filter by Gateway ID meta_key
258
-			if ( $gateway_id !== false ) {
258
+			if ($gateway_id !== false) {
259 259
 				$args['meta_key']   = '_give_payment_gateway';
260 260
 				$args['meta_value'] = $gateway_id;
261 261
 			}
262 262
 
263
-			$args = apply_filters( 'give_stats_earnings_args', $args );
264
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
263
+			$args = apply_filters('give_stats_earnings_args', $args);
264
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
265 265
 
266 266
 		} else {
267 267
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 				'give_transient_type' => 'give_earnings',
281 281
 				// This is not a valid query arg, but is used for cache keying
282 282
 			);
283
-			$args = apply_filters( 'give_stats_earnings_args', $args );
284
-			$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
283
+			$args = apply_filters('give_stats_earnings_args', $args);
284
+			$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
285 285
 		}
286 286
 
287 287
 		//remove our filter
288
-		remove_filter( 'posts_where', array( $this, 'payments_where' ) );
288
+		remove_filter('posts_where', array($this, 'payments_where'));
289 289
 
290 290
 		//return earnings
291 291
 		return $key;
@@ -302,16 +302,16 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return array       Best selling forms
304 304
 	 */
305
-	public function get_best_selling( $number = 10 ) {
305
+	public function get_best_selling($number = 10) {
306 306
 
307 307
 		global $wpdb;
308 308
 
309
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
309
+		$give_forms = $wpdb->get_results($wpdb->prepare(
310 310
 			"SELECT post_id as form_id, max(meta_value) as sales
311 311
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
312 312
 				GROUP BY meta_value+0
313 313
 				DESC LIMIT %d;", $number
314
-		) );
314
+		));
315 315
 
316 316
 		return $give_forms;
317 317
 	}
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/class-batch-export-payments.php 1 patch
Spacing   +63 added lines, -63 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
 
@@ -39,30 +39,30 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function csv_cols() {
41 41
 		$cols = array(
42
-			'id'        => esc_html__( 'ID', 'give' ), // unaltered payment ID (use for querying).
43
-			'seq_id'    => esc_html__( 'Payment Number', 'give' ), // sequential payment ID.
44
-			'email'     => esc_html__( 'Email', 'give' ),
45
-			'first'     => esc_html__( 'First Name', 'give' ),
46
-			'last'      => esc_html__( 'Last Name', 'give' ),
47
-			'address1'  => esc_html__( 'Address 1', 'give' ),
48
-			'address2'  => esc_html__( 'Address 2', 'give' ),
49
-			'city'      => esc_html__( 'City', 'give' ),
50
-			'state'     => esc_html__( 'State', 'give' ),
51
-			'country'   => esc_html__( 'Country', 'give' ),
52
-			'zip'       => esc_html__( 'Zip / Postal Code', 'give' ),
53
-			'form_id'   => esc_html__( 'Form ID', 'give' ),
54
-			'form_name' => esc_html__( 'Form Name', 'give' ),
55
-			'amount'    => esc_html__( 'Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')',
56
-			'gateway'   => esc_html__( 'Payment Method', 'give' ),
57
-			'trans_id'  => esc_html__( 'Transaction ID', 'give' ),
58
-			'key'       => esc_html__( 'Key', 'give' ),
59
-			'date'      => esc_html__( 'Date', 'give' ),
60
-			'user'      => esc_html__( 'User', 'give' ),
61
-			'status'    => esc_html__( 'Status', 'give' )
42
+			'id'        => esc_html__('ID', 'give'), // unaltered payment ID (use for querying).
43
+			'seq_id'    => esc_html__('Payment Number', 'give'), // sequential payment ID.
44
+			'email'     => esc_html__('Email', 'give'),
45
+			'first'     => esc_html__('First Name', 'give'),
46
+			'last'      => esc_html__('Last Name', 'give'),
47
+			'address1'  => esc_html__('Address 1', 'give'),
48
+			'address2'  => esc_html__('Address 2', 'give'),
49
+			'city'      => esc_html__('City', 'give'),
50
+			'state'     => esc_html__('State', 'give'),
51
+			'country'   => esc_html__('Country', 'give'),
52
+			'zip'       => esc_html__('Zip / Postal Code', 'give'),
53
+			'form_id'   => esc_html__('Form ID', 'give'),
54
+			'form_name' => esc_html__('Form Name', 'give'),
55
+			'amount'    => esc_html__('Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')',
56
+			'gateway'   => esc_html__('Payment Method', 'give'),
57
+			'trans_id'  => esc_html__('Transaction ID', 'give'),
58
+			'key'       => esc_html__('Key', 'give'),
59
+			'date'      => esc_html__('Date', 'give'),
60
+			'user'      => esc_html__('User', 'give'),
61
+			'status'    => esc_html__('Status', 'give')
62 62
 		);
63 63
 
64
-		if ( ! give_get_option( 'enable_sequential' ) ) {
65
-			unset( $cols['seq_id'] );
64
+		if ( ! give_get_option('enable_sequential')) {
65
+			unset($cols['seq_id']);
66 66
 		}
67 67
 
68 68
 		return $cols;
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 			'status' => $this->status
88 88
 		);
89 89
 
90
-		if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
90
+		if ( ! empty($this->start) || ! empty($this->end)) {
91 91
 
92 92
 			$args['date_query'] = array(
93 93
 				array(
94
-					'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->start ) ),
95
-					'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->end ) ),
94
+					'after'     => date('Y-n-d 00:00:00', strtotime($this->start)),
95
+					'before'    => date('Y-n-d 23:59:59', strtotime($this->end)),
96 96
 					'inclusive' => true
97 97
 				)
98 98
 			);
@@ -101,52 +101,52 @@  discard block
 block discarded – undo
101 101
 
102 102
 		//echo json_encode($args ); exit;
103 103
 
104
-		$payments = give_get_payments( $args );
104
+		$payments = give_get_payments($args);
105 105
 
106
-		if ( $payments ) {
106
+		if ($payments) {
107 107
 
108
-			foreach ( $payments as $payment ) {
109
-				$payment_meta = give_get_payment_meta( $payment->ID );
110
-				$user_info    = give_get_payment_meta_user_info( $payment->ID );
111
-				$total        = give_get_payment_amount( $payment->ID );
112
-				$user_id      = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
108
+			foreach ($payments as $payment) {
109
+				$payment_meta = give_get_payment_meta($payment->ID);
110
+				$user_info    = give_get_payment_meta_user_info($payment->ID);
111
+				$total        = give_get_payment_amount($payment->ID);
112
+				$user_id      = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
113 113
 				$products     = '';
114 114
 				$skus         = '';
115 115
 
116
-				if ( is_numeric( $user_id ) ) {
117
-					$user = get_userdata( $user_id );
116
+				if (is_numeric($user_id)) {
117
+					$user = get_userdata($user_id);
118 118
 				} else {
119 119
 					$user = false;
120 120
 				}
121 121
 
122 122
 				$data[] = array(
123 123
 					'id'        => $payment->ID,
124
-					'seq_id'    => give_get_payment_number( $payment->ID ),
124
+					'seq_id'    => give_get_payment_number($payment->ID),
125 125
 					'email'     => $payment_meta['email'],
126 126
 					'first'     => $user_info['first_name'],
127 127
 					'last'      => $user_info['last_name'],
128
-					'address1'  => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '',
129
-					'address2'  => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '',
130
-					'city'      => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '',
131
-					'state'     => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '',
132
-					'country'   => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '',
133
-					'zip'       => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '',
134
-					'form_id'   => isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : '',
135
-					'form_name' => isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '',
128
+					'address1'  => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '',
129
+					'address2'  => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '',
130
+					'city'      => isset($user_info['address']['city']) ? $user_info['address']['city'] : '',
131
+					'state'     => isset($user_info['address']['state']) ? $user_info['address']['state'] : '',
132
+					'country'   => isset($user_info['address']['country']) ? $user_info['address']['country'] : '',
133
+					'zip'       => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '',
134
+					'form_id'   => isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '',
135
+					'form_name' => isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '',
136 136
 					'skus'      => $skus,
137
-					'amount'    => html_entity_decode( give_format_amount( $total ) ),
138
-					'gateway'   => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ),
139
-					'trans_id'  => give_get_payment_transaction_id( $payment->ID ),
137
+					'amount'    => html_entity_decode(give_format_amount($total)),
138
+					'gateway'   => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)),
139
+					'trans_id'  => give_get_payment_transaction_id($payment->ID),
140 140
 					'key'       => $payment_meta['key'],
141 141
 					'date'      => $payment->post_date,
142
-					'user'      => $user ? $user->display_name : __( 'guest', 'give' ),
143
-					'status'    => give_get_payment_status( $payment, true )
142
+					'user'      => $user ? $user->display_name : __('guest', 'give'),
143
+					'status'    => give_get_payment_status($payment, true)
144 144
 				);
145 145
 
146 146
 			}
147 147
 
148
-			$data = apply_filters( 'give_export_get_data', $data );
149
-			$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
148
+			$data = apply_filters('give_export_get_data', $data);
149
+			$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
150 150
 
151 151
 			return $data;
152 152
 
@@ -166,27 +166,27 @@  discard block
 block discarded – undo
166 166
 
167 167
 		$status = $this->status;
168 168
 		$args   = array(
169
-			'start-date' => date( 'n/d/Y', strtotime( $this->start ) ),
170
-			'end-date'   => date( 'n/d/Y', strtotime( $this->end ) ),
169
+			'start-date' => date('n/d/Y', strtotime($this->start)),
170
+			'end-date'   => date('n/d/Y', strtotime($this->end)),
171 171
 		);
172 172
 
173
-		if ( 'any' == $status ) {
173
+		if ('any' == $status) {
174 174
 
175
-			$total = array_sum( (array) give_count_payments( $args ) );
175
+			$total = array_sum((array) give_count_payments($args));
176 176
 
177 177
 		} else {
178 178
 
179
-			$total = give_count_payments( $args )->$status;
179
+			$total = give_count_payments($args)->$status;
180 180
 
181 181
 		}
182 182
 
183 183
 		$percentage = 100;
184 184
 
185
-		if ( $total > 0 ) {
186
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
185
+		if ($total > 0) {
186
+			$percentage = ((30 * $this->step) / $total) * 100;
187 187
 		}
188 188
 
189
-		if ( $percentage > 100 ) {
189
+		if ($percentage > 100) {
190 190
 			$percentage = 100;
191 191
 		}
192 192
 
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @param array $request The Form Data passed into the batch processing.
202 202
 	 */
203
-	public function set_properties( $request ) {
204
-		$this->start  = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : '';
205
-		$this->end    = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : '';
206
-		$this->status = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'complete';
203
+	public function set_properties($request) {
204
+		$this->start  = isset($request['start']) ? sanitize_text_field($request['start']) : '';
205
+		$this->end    = isset($request['end']) ? sanitize_text_field($request['end']) : '';
206
+		$this->status = isset($request['status']) ? sanitize_text_field($request['status']) : 'complete';
207 207
 	}
208 208
 }
Please login to merge, or discard this patch.