@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Exit if accessed directly. |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if ( ! defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @return void |
30 | 30 | */ |
31 | 31 | function give_reports_page() { |
32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
34 | 34 | $views = give_reports_default_views(); |
35 | 35 | ?> |
36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
39 | 39 | |
40 | 40 | <h2 class="nav-tab-wrapper"> |
41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
41 | + <?php foreach ($views as $tab => $label) { ?> |
|
42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
43 | 43 | 'tab' => $tab, |
44 | 44 | 'settings-updated' => false, |
45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
46 | 46 | <?php } ?> |
47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
49 | 49 | 'tab' => 'export', |
50 | 50 | 'settings-updated' => false, |
51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
52 | 52 | <?php } |
53 | 53 | /** |
54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @since 1.0 |
59 | 59 | */ |
60 | - do_action( 'give_reports_tabs' ); |
|
60 | + do_action('give_reports_tabs'); |
|
61 | 61 | ?> |
62 | 62 | </h2> |
63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0 |
69 | 69 | */ |
70 | - do_action( 'give_reports_page_top' ); |
|
70 | + do_action('give_reports_page_top'); |
|
71 | 71 | |
72 | 72 | // Set $active_tab prior to hook firing. |
73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
73 | + if (in_array($active_tab, array_keys($views))) { |
|
74 | 74 | $active_tab = 'reports'; |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.0 |
81 | 81 | */ |
82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
82 | + do_action("give_reports_tab_{$active_tab}"); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Fires after the report page. |
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - do_action( 'give_reports_page_bottom' ); |
|
89 | + do_action('give_reports_page_bottom'); |
|
90 | 90 | ?> |
91 | 91 | </div><!-- .wrap --> |
92 | 92 | <?php |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function give_reports_default_views() { |
102 | 102 | $views = array( |
103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
105 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
106 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
103 | + 'earnings' => esc_html__('Income', 'give'), |
|
104 | + 'forms' => esc_html__('Forms', 'give'), |
|
105 | + 'donors' => esc_html__('Donors', 'give'), |
|
106 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
107 | 107 | ); |
108 | 108 | |
109 | - $views = apply_filters( 'give_report_views', $views ); |
|
109 | + $views = apply_filters('give_report_views', $views); |
|
110 | 110 | |
111 | 111 | return $views; |
112 | 112 | } |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @since 1.0 |
122 | 122 | * @return string $view Report View |
123 | 123 | */ |
124 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
124 | +function give_get_reporting_view($default = 'earnings') { |
|
125 | 125 | |
126 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
126 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
127 | 127 | $view = $default; |
128 | 128 | } else { |
129 | 129 | $view = $_GET['view']; |
130 | 130 | } |
131 | 131 | |
132 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
132 | + return apply_filters('give_get_reporting_view', $view); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $current_view = 'earnings'; |
143 | 143 | $views = give_reports_default_views(); |
144 | 144 | |
145 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
145 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
146 | 146 | $current_view = $_GET['tab']; |
147 | 147 | } |
148 | 148 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - do_action( "give_reports_view_{$current_view}" ); |
|
154 | + do_action("give_reports_view_{$current_view}"); |
|
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
157 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Renders the Reports Page Views Drop Downs |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_report_views() { |
166 | 166 | $views = give_reports_default_views(); |
167 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
167 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
168 | 168 | /** |
169 | 169 | * Fires before the report page actions form. |
170 | 170 | * |
171 | 171 | * @since 1.0 |
172 | 172 | */ |
173 | - do_action( 'give_report_view_actions_before' ); |
|
173 | + do_action('give_report_view_actions_before'); |
|
174 | 174 | ?> |
175 | 175 | <form id="give-reports-filter" method="get"> |
176 | 176 | <select id="give-reports-view" name="view"> |
177 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
178 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
179 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
177 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
178 | + <?php foreach ($views as $view_id => $label) : ?> |
|
179 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
180 | 180 | <?php endforeach; ?> |
181 | 181 | </select> |
182 | 182 | |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @since 1.0 |
190 | 190 | */ |
191 | - do_action( 'give_report_view_actions' ); |
|
191 | + do_action('give_report_view_actions'); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <input type="hidden" name="post_type" value="give_forms"/> |
195 | 195 | <input type="hidden" name="page" value="give-reports"/> |
196 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
196 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
197 | 197 | </form> |
198 | 198 | <?php |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @since 1.0 |
203 | 203 | */ |
204 | - do_action( 'give_report_view_actions_after' ); |
|
204 | + do_action('give_report_view_actions_after'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function give_reports_forms_table() { |
216 | 216 | |
217 | - if ( isset( $_GET['form-id'] ) ) { |
|
217 | + if (isset($_GET['form-id'])) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
221 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
222 | 222 | |
223 | 223 | $give_table = new Give_Form_Reports_Table(); |
224 | 224 | $give_table->prepare_items(); |
225 | 225 | $give_table->display(); |
226 | 226 | } |
227 | 227 | |
228 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
228 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Renders the detailed report for a specific give form. |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @return void |
235 | 235 | */ |
236 | 236 | function give_reports_form_details() { |
237 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
237 | + if ( ! isset($_GET['form-id'])) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | <div class="tablenav top reports-forms-details-wrap"> |
242 | 242 | <div class="actions bulkactions"> |
243 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
243 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
247 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
247 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
250 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Renders the Reports Donors Table |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_reports_donors_table() { |
261 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
261 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
262 | 262 | |
263 | 263 | $give_table = new Give_Donor_Reports_Table(); |
264 | 264 | $give_table->prepare_items(); |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_logs_donors_table_top' ); |
|
273 | + do_action('give_logs_donors_table_top'); |
|
274 | 274 | ?> |
275 | 275 | <form id="give-donors-filter" method="get"> |
276 | 276 | <?php |
277 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
277 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
278 | 278 | $give_table->display(); |
279 | 279 | ?> |
280 | 280 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @since 1.0 |
289 | 289 | */ |
290 | - do_action( 'give_logs_donors_table_bottom' ); |
|
290 | + do_action('give_logs_donors_table_bottom'); |
|
291 | 291 | ?> |
292 | 292 | </div> |
293 | 293 | <?php |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
296 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | * @return void |
306 | 306 | */ |
307 | 307 | function give_reports_gateways_table() { |
308 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
308 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
309 | 309 | |
310 | 310 | $give_table = new Give_Gateway_Reports_Table(); |
311 | 311 | $give_table->prepare_items(); |
312 | 312 | $give_table->display(); |
313 | 313 | } |
314 | 314 | |
315 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
315 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /** |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | function give_reports_earnings() { |
325 | 325 | ?> |
326 | 326 | <div class="tablenav top reports-table-nav"> |
327 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3> |
|
327 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> |
|
328 | 328 | </div> |
329 | 329 | <?php |
330 | 330 | give_reports_graph(); |
331 | 331 | } |
332 | 332 | |
333 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
333 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
334 | 334 | |
335 | 335 | |
336 | 336 | /** |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | */ |
342 | 342 | function give_estimated_monthly_stats() { |
343 | 343 | |
344 | - $estimated = Give_Cache::get( 'give_estimated_monthly_stats', true ); |
|
344 | + $estimated = Give_Cache::get('give_estimated_monthly_stats', true); |
|
345 | 345 | |
346 | - if ( false === $estimated ) { |
|
346 | + if (false === $estimated) { |
|
347 | 347 | |
348 | 348 | $estimated = array( |
349 | 349 | 'earnings' => 0, |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | |
353 | 353 | $stats = new Give_Payment_Stats; |
354 | 354 | |
355 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
356 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
355 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
356 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
357 | 357 | |
358 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
359 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
360 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
361 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
358 | + $current_day = date('d', current_time('timestamp')); |
|
359 | + $current_month = date('n', current_time('timestamp')); |
|
360 | + $current_year = date('Y', current_time('timestamp')); |
|
361 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
362 | 362 | |
363 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
364 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
363 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
364 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
365 | 365 | |
366 | 366 | // Cache for one day |
367 | - Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true ); |
|
367 | + Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true); |
|
368 | 368 | } |
369 | 369 | |
370 | - return maybe_unserialize( $estimated ); |
|
370 | + return maybe_unserialize($estimated); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file. |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | public static function save() { |
87 | 87 | $current_tab = give_get_current_setting_tab(); |
88 | 88 | |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @since 1.8 |
102 | 102 | */ |
103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
104 | 104 | |
105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.8 |
115 | 115 | */ |
116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public static function add_message( $code, $message ) { |
|
130 | - self::$messages[ $code ] = $message; |
|
129 | + public static function add_message($code, $message) { |
|
130 | + self::$messages[$code] = $message; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public static function add_error( $code, $message ) { |
|
144 | - self::$errors[ $code ] = $message; |
|
143 | + public static function add_error($code, $message) { |
|
144 | + self::$errors[$code] = $message; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | $notice_html = ''; |
155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
156 | 156 | |
157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
159 | 159 | |
160 | - if ( 0 < count( self::$errors ) ) { |
|
161 | - foreach ( self::$errors as $code => $message ) { |
|
162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
160 | + if (0 < count(self::$errors)) { |
|
161 | + foreach (self::$errors as $code => $message) { |
|
162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - if ( 0 < count( self::$messages ) ) { |
|
167 | - foreach ( self::$messages as $code => $message ) { |
|
168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
166 | + if (0 < count(self::$messages)) { |
|
167 | + foreach (self::$messages as $code => $message) { |
|
168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
186 | 186 | |
187 | 187 | // Bailout: Exit if setting page is not defined. |
188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
188 | + if (empty(self::$setting_filter_prefix)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @since 1.8 |
200 | 200 | */ |
201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
202 | 202 | |
203 | 203 | $current_tab = give_get_current_setting_tab(); |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | self::get_settings_pages(); |
207 | 207 | |
208 | 208 | // Save settings if data has been posted. |
209 | - if ( ! empty( $_POST ) ) { |
|
209 | + if ( ! empty($_POST)) { |
|
210 | 210 | self::save(); |
211 | 211 | } |
212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @since 1.8 |
221 | 221 | */ |
222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
223 | 223 | |
224 | 224 | include 'views/html-admin-settings.php'; |
225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string|bool |
239 | 239 | */ |
240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
241 | 241 | // Bailout. |
242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
242 | + if (empty($option_name) && empty($field_id)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
247 | 247 | // Get field value if any. |
248 | - $option_value = get_option( $option_name ); |
|
248 | + $option_value = get_option($option_name); |
|
249 | 249 | |
250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
251 | - ? $option_value[ $field_id ] |
|
250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
251 | + ? $option_value[$field_id] |
|
252 | 252 | : $default; |
253 | 253 | } else { |
254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
256 | 256 | |
257 | 257 | // Get option value if any. |
258 | - $option_value = get_option( $option_name, $default ); |
|
258 | + $option_value = get_option($option_name, $default); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return void |
275 | 275 | */ |
276 | - public static function output_fields( $options, $option_name = '' ) { |
|
276 | + public static function output_fields($options, $option_name = '') { |
|
277 | 277 | $current_tab = give_get_current_setting_tab(); |
278 | 278 | |
279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
286 | 286 | 'table_html' => true, |
287 | 287 | ); |
288 | 288 | |
289 | - foreach ( $options as $value ) { |
|
290 | - if ( ! isset( $value['type'] ) ) { |
|
289 | + foreach ($options as $value) { |
|
290 | + if ( ! isset($value['type'])) { |
|
291 | 291 | continue; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Set title. |
295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
296 | 296 | |
297 | 297 | // Set default setting. |
298 | - $value = wp_parse_args( $value, $defaults ); |
|
298 | + $value = wp_parse_args($value, $defaults); |
|
299 | 299 | |
300 | 300 | // Colorpicker field. |
301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
303 | 303 | |
304 | 304 | |
305 | 305 | // Custom attribute handling. |
306 | 306 | $custom_attributes = array(); |
307 | 307 | |
308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Description handling. |
315 | - $description = self::get_field_description( $value ); |
|
315 | + $description = self::get_field_description($value); |
|
316 | 316 | |
317 | 317 | // Switch based on type. |
318 | - switch ( $value['type'] ) { |
|
318 | + switch ($value['type']) { |
|
319 | 319 | |
320 | 320 | // Section Titles |
321 | 321 | case 'title': |
322 | - if ( ! empty( $value['title'] ) ) { |
|
323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
322 | + if ( ! empty($value['title'])) { |
|
323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $value['desc'] ) ) { |
|
327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
326 | + if ( ! empty($value['desc'])) { |
|
327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( $value['table_html'] ) { |
|
331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
330 | + if ($value['table_html']) { |
|
331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( ! empty( $value['id'] ) ) { |
|
334 | + if ( ! empty($value['id'])) { |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @since 1.8 |
342 | 342 | */ |
343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | break; |
347 | 347 | |
348 | 348 | // Section Ends. |
349 | 349 | case 'sectionend': |
350 | - if ( ! empty( $value['id'] ) ) { |
|
350 | + if ( ! empty($value['id'])) { |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @since 1.8 |
358 | 358 | */ |
359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
360 | 360 | } |
361 | 361 | |
362 | - if ( $value['table_html'] ) { |
|
362 | + if ($value['table_html']) { |
|
363 | 363 | echo '</table>'; |
364 | 364 | } |
365 | 365 | |
366 | - if ( ! empty( $value['id'] ) ) { |
|
366 | + if ( ! empty($value['id'])) { |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @since 1.8 |
374 | 374 | */ |
375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | case 'password' : |
386 | 386 | |
387 | 387 | $type = $value['type']; |
388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
389 | 389 | |
390 | 390 | ?> |
391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
392 | 392 | <th scope="row" class="titledesc"> |
393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
394 | 394 | </th> |
395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
396 | 396 | <input |
397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
399 | - type="<?php echo esc_attr( $type ); ?>" |
|
400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
399 | + type="<?php echo esc_attr($type); ?>" |
|
400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
401 | + value="<?php echo esc_attr($option_value); ?>" |
|
402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
404 | 404 | /> <?php echo $description; ?> |
405 | 405 | </td> |
406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
409 | 409 | // Textarea. |
410 | 410 | case 'textarea': |
411 | 411 | |
412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
413 | 413 | |
414 | 414 | ?> |
415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
416 | 416 | <th scope="row" class="titledesc"> |
417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
418 | 418 | </th> |
419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
420 | 420 | <textarea |
421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
425 | 425 | rows="10" |
426 | 426 | cols="60" |
427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
429 | 429 | <?php echo $description; ?> |
430 | 430 | </td> |
431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
435 | 435 | case 'select' : |
436 | 436 | case 'multiselect' : |
437 | 437 | |
438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
439 | 439 | |
440 | 440 | ?> |
441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
442 | 442 | <th scope="row" class="titledesc"> |
443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
444 | 444 | </th> |
445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
446 | 446 | <select |
447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
448 | 448 | echo '[]'; |
449 | 449 | } ?>" |
450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
455 | 455 | > |
456 | 456 | |
457 | 457 | <?php |
458 | - if ( ! empty( $value['options'] ) ) { |
|
459 | - foreach ( $value['options'] as $key => $val ) { |
|
458 | + if ( ! empty($value['options'])) { |
|
459 | + foreach ($value['options'] as $key => $val) { |
|
460 | 460 | ?> |
461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
462 | 462 | |
463 | - if ( is_array( $option_value ) ) { |
|
464 | - selected( in_array( $key, $option_value ), true ); |
|
463 | + if (is_array($option_value)) { |
|
464 | + selected(in_array($key, $option_value), true); |
|
465 | 465 | } else { |
466 | - selected( $option_value, $key ); |
|
466 | + selected($option_value, $key); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
479 | 479 | |
480 | 480 | // Radio inputs. |
481 | 481 | case 'radio_inline' : |
482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
483 | 483 | case 'radio' : |
484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
485 | 485 | ?> |
486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
487 | 487 | <th scope="row" class="titledesc"> |
488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
489 | 489 | </th> |
490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
491 | 491 | <fieldset> |
492 | 492 | <ul> |
493 | 493 | <?php |
494 | - foreach ( $value['options'] as $key => $val ) { |
|
494 | + foreach ($value['options'] as $key => $val) { |
|
495 | 495 | ?> |
496 | 496 | <li> |
497 | 497 | <label><input |
498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
499 | 499 | value="<?php echo $key; ?>" |
500 | 500 | type="radio" |
501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
503 | - <?php checked( $key, $option_value ); ?> |
|
501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
503 | + <?php checked($key, $option_value); ?> |
|
504 | 504 | /> <?php echo $val ?></label> |
505 | 505 | </li> |
506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
514 | 514 | |
515 | 515 | // Checkbox input. |
516 | 516 | case 'checkbox' : |
517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
518 | 518 | ?> |
519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
520 | 520 | <th scope="row" class="titledesc"> |
521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
522 | 522 | </th> |
523 | 523 | <td class="give-forminp"> |
524 | 524 | <input |
525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
527 | 527 | type="checkbox" |
528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
529 | 529 | value="1" |
530 | - <?php checked( $option_value, 'on' ); ?> |
|
531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
530 | + <?php checked($option_value, 'on'); ?> |
|
531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
532 | 532 | /> |
533 | 533 | <?php echo $description; ?> |
534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
538 | 538 | |
539 | 539 | // Multi Checkbox input. |
540 | 540 | case 'multicheck' : |
541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
543 | 543 | ?> |
544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
545 | 545 | <th scope="row" class="titledesc"> |
546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
547 | 547 | </th> |
548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
549 | 549 | <fieldset> |
550 | 550 | <ul> |
551 | 551 | <?php |
552 | - foreach ( $value['options'] as $key => $val ) { |
|
552 | + foreach ($value['options'] as $key => $val) { |
|
553 | 553 | ?> |
554 | 554 | <li> |
555 | 555 | <label> |
556 | 556 | <input |
557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
558 | 558 | value="<?php echo $key; ?>" |
559 | 559 | type="checkbox" |
560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
562 | + <?php if (in_array($key, $option_value)) { |
|
563 | 563 | echo 'checked="checked"'; |
564 | 564 | } ?> |
565 | 565 | /> <?php echo $val ?> |
@@ -578,35 +578,35 @@ discard block |
||
578 | 578 | // File input field. |
579 | 579 | case 'file' : |
580 | 580 | case 'media' : |
581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
582 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
583 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
584 | - |
|
585 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
586 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
587 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
588 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
582 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
583 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
584 | + |
|
585 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
586 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
587 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
588 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
589 | 589 | ?> |
590 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
590 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
591 | 591 | <th scope="row" class="titledesc"> |
592 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
592 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
593 | 593 | </th> |
594 | 594 | <td class="give-forminp"> |
595 | 595 | <div class="give-field-wrap"> |
596 | 596 | <label for="<?php echo $value['id'] ?>"> |
597 | 597 | <input |
598 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
599 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
598 | + name="<?php echo esc_attr($value['id']); ?>" |
|
599 | + id="<?php echo esc_attr($value['id']); ?>" |
|
600 | 600 | type="text" |
601 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
601 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
602 | 602 | value="<?php echo $option_value; ?>" |
603 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
604 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
603 | + style="<?php echo esc_attr($value['css']); ?>" |
|
604 | + <?php echo implode(' ', $custom_attributes); ?> |
|
605 | 605 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
606 | 606 | <?php echo $description ?> |
607 | 607 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
608 | 608 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
609 | - <img src="<?php echo $preview_image_src ; ?>" alt=""> |
|
609 | + <img src="<?php echo $preview_image_src; ?>" alt=""> |
|
610 | 610 | </div> |
611 | 611 | </label> |
612 | 612 | </div> |
@@ -618,17 +618,17 @@ discard block |
||
618 | 618 | // WordPress Editor. |
619 | 619 | case 'wysiwyg' : |
620 | 620 | // Get option value. |
621 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
621 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
622 | 622 | |
623 | 623 | // Get editor settings. |
624 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
624 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
625 | 625 | ?> |
626 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
626 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
627 | 627 | <th scope="row" class="titledesc"> |
628 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
628 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
629 | 629 | </th> |
630 | 630 | <td class="give-forminp"> |
631 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
631 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
632 | 632 | <?php echo $description; ?> |
633 | 633 | </td> |
634 | 634 | </tr><?php |
@@ -637,9 +637,9 @@ discard block |
||
637 | 637 | // Custom: System setting field. |
638 | 638 | case 'system_info' : |
639 | 639 | ?> |
640 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
640 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
641 | 641 | <th scope="row" class="titledesc"> |
642 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
642 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
643 | 643 | </th> |
644 | 644 | <td class="give-forminp"> |
645 | 645 | <?php give_system_info_callback(); ?> |
@@ -650,14 +650,14 @@ discard block |
||
650 | 650 | |
651 | 651 | // Custom: Default gateways setting field. |
652 | 652 | case 'default_gateway' : |
653 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
653 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
654 | 654 | ?> |
655 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
655 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
656 | 656 | <th scope="row" class="titledesc"> |
657 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
657 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
658 | 658 | </th> |
659 | 659 | <td class="give-forminp"> |
660 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
660 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
661 | 661 | <?php echo $description; ?> |
662 | 662 | </td> |
663 | 663 | </tr><?php |
@@ -665,14 +665,14 @@ discard block |
||
665 | 665 | |
666 | 666 | // Custom: Enable gateways setting field. |
667 | 667 | case 'enabled_gateways' : |
668 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
668 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
669 | 669 | ?> |
670 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
670 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
671 | 671 | <th scope="row" class="titledesc"> |
672 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
672 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
673 | 673 | </th> |
674 | 674 | <td class="give-forminp"> |
675 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
675 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
676 | 676 | <?php echo $description; ?> |
677 | 677 | </td> |
678 | 678 | </tr><?php |
@@ -681,9 +681,9 @@ discard block |
||
681 | 681 | // Custom: Email preview buttons field. |
682 | 682 | case 'email_preview_buttons' : |
683 | 683 | ?> |
684 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
684 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
685 | 685 | <th scope="row" class="titledesc"> |
686 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
686 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
687 | 687 | </th> |
688 | 688 | <td class="give-forminp"> |
689 | 689 | <?php give_email_preview_buttons_callback(); ?> |
@@ -700,22 +700,22 @@ discard block |
||
700 | 700 | |
701 | 701 | // Custom: Gateway API key. |
702 | 702 | case 'api_key' : |
703 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
704 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
703 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
704 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
705 | 705 | ?> |
706 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
706 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
707 | 707 | <th scope="row" class="titledesc"> |
708 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
708 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
709 | 709 | </th> |
710 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
710 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
711 | 711 | <input |
712 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
713 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
714 | - type="<?php echo esc_attr( $type ); ?>" |
|
715 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
716 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
717 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
718 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
712 | + name="<?php echo esc_attr($value['id']); ?>" |
|
713 | + id="<?php echo esc_attr($value['id']); ?>" |
|
714 | + type="<?php echo esc_attr($type); ?>" |
|
715 | + style="<?php echo esc_attr($value['css']); ?>" |
|
716 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
717 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
718 | + <?php echo implode(' ', $custom_attributes); ?> |
|
719 | 719 | /> <?php echo $description; ?> |
720 | 720 | </td> |
721 | 721 | </tr><?php |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | // Custom: Log field. |
725 | 725 | case 'logs' : |
726 | 726 | |
727 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php'; |
|
727 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'; |
|
728 | 728 | |
729 | 729 | // Get current section. |
730 | 730 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @since 1.0 |
736 | 736 | */ |
737 | - do_action( "give_logs_view_{$current_section}" ); |
|
737 | + do_action("give_logs_view_{$current_section}"); |
|
738 | 738 | |
739 | 739 | echo $description; |
740 | 740 | break; |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | // Custom: Data field. |
743 | 743 | case 'data' : |
744 | 744 | |
745 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
745 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
746 | 746 | |
747 | 747 | echo $description; |
748 | 748 | break; |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | // Custom: Give Docs Link field type. |
751 | 751 | case 'give_docs_link' : |
752 | 752 | ?> |
753 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
753 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
754 | 754 | <td class="give-docs-link" colspan="2"> |
755 | 755 | <?php |
756 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
756 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
757 | 757 | . '" target="_blank">' |
758 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
758 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
759 | 759 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
760 | 760 | ?> |
761 | 761 | </td> |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | // You can add or handle your custom field action. |
767 | 767 | default: |
768 | 768 | // Get option value. |
769 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
770 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
769 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
770 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
771 | 771 | break; |
772 | 772 | } |
773 | 773 | } |
@@ -783,15 +783,15 @@ discard block |
||
783 | 783 | * |
784 | 784 | * @return string The HTML description of the field. |
785 | 785 | */ |
786 | - public static function get_field_description( $value ) { |
|
786 | + public static function get_field_description($value) { |
|
787 | 787 | $description = ''; |
788 | 788 | |
789 | 789 | // Support for both 'description' and 'desc' args. |
790 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
791 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
790 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
791 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
792 | 792 | |
793 | - if ( ! empty( $value ) ) { |
|
794 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
793 | + if ( ! empty($value)) { |
|
794 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | return $description; |
@@ -808,11 +808,11 @@ discard block |
||
808 | 808 | * |
809 | 809 | * @return array The description and tip as a 2 element array |
810 | 810 | */ |
811 | - public static function get_field_title( $value ) { |
|
812 | - $title = esc_html( $value['title'] ); |
|
811 | + public static function get_field_title($value) { |
|
812 | + $title = esc_html($value['title']); |
|
813 | 813 | |
814 | 814 | // If html tag detected then allow them to print. |
815 | - if ( strip_tags( $title ) ) { |
|
815 | + if (strip_tags($title)) { |
|
816 | 816 | $title = $value['title']; |
817 | 817 | } |
818 | 818 | |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | * |
832 | 832 | * @return bool |
833 | 833 | */ |
834 | - public static function save_fields( $options, $option_name = '' ) { |
|
835 | - if ( empty( $_POST ) ) { |
|
834 | + public static function save_fields($options, $option_name = '') { |
|
835 | + if (empty($_POST)) { |
|
836 | 836 | return false; |
837 | 837 | } |
838 | 838 | |
@@ -840,37 +840,37 @@ discard block |
||
840 | 840 | $update_options = array(); |
841 | 841 | |
842 | 842 | // Loop options and get values to save. |
843 | - foreach ( $options as $option ) { |
|
844 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
843 | + foreach ($options as $option) { |
|
844 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
845 | 845 | continue; |
846 | 846 | } |
847 | 847 | |
848 | 848 | // Get posted value. |
849 | - if ( strstr( $option['id'], '[' ) ) { |
|
850 | - parse_str( $option['id'], $option_name_array ); |
|
851 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
852 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
853 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
849 | + if (strstr($option['id'], '[')) { |
|
850 | + parse_str($option['id'], $option_name_array); |
|
851 | + $field_option_name = current(array_keys($option_name_array)); |
|
852 | + $setting_name = key($option_name_array[$field_option_name]); |
|
853 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
854 | 854 | } else { |
855 | 855 | $field_option_name = $option['id']; |
856 | 856 | $setting_name = ''; |
857 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
857 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | // Format the value based on option type. |
861 | - switch ( $option['type'] ) { |
|
861 | + switch ($option['type']) { |
|
862 | 862 | case 'checkbox' : |
863 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
863 | + $value = is_null($raw_value) ? '' : 'on'; |
|
864 | 864 | break; |
865 | 865 | case 'wysiwyg' : |
866 | 866 | case 'textarea' : |
867 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
867 | + $value = wp_kses_post(trim($raw_value)); |
|
868 | 868 | break; |
869 | 869 | case 'multiselect' : |
870 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
870 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
871 | 871 | break; |
872 | 872 | default : |
873 | - $value = give_clean( $raw_value ); |
|
873 | + $value = give_clean($raw_value); |
|
874 | 874 | break; |
875 | 875 | } |
876 | 876 | |
@@ -879,37 +879,37 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @since 1.8 |
881 | 881 | */ |
882 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
882 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
883 | 883 | |
884 | 884 | /** |
885 | 885 | * Sanitize the value of an option by option name. |
886 | 886 | * |
887 | 887 | * @since 1.8 |
888 | 888 | */ |
889 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
889 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
890 | 890 | |
891 | - if ( is_null( $value ) ) { |
|
891 | + if (is_null($value)) { |
|
892 | 892 | continue; |
893 | 893 | } |
894 | 894 | |
895 | 895 | // Check if option is an array and handle that differently to single values. |
896 | - if ( $field_option_name && $setting_name ) { |
|
897 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
898 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
896 | + if ($field_option_name && $setting_name) { |
|
897 | + if ( ! isset($update_options[$field_option_name])) { |
|
898 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
899 | 899 | } |
900 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
901 | - $update_options[ $field_option_name ] = array(); |
|
900 | + if ( ! is_array($update_options[$field_option_name])) { |
|
901 | + $update_options[$field_option_name] = array(); |
|
902 | 902 | } |
903 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
903 | + $update_options[$field_option_name][$setting_name] = $value; |
|
904 | 904 | } else { |
905 | - $update_options[ $field_option_name ] = $value; |
|
905 | + $update_options[$field_option_name] = $value; |
|
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
909 | 909 | // Save all options in our array or there own option name i.e. option id. |
910 | - if ( empty( $option_name ) ) { |
|
911 | - foreach ( $update_options as $name => $value ) { |
|
912 | - update_option( $name, $value ); |
|
910 | + if (empty($option_name)) { |
|
911 | + foreach ($update_options as $name => $value) { |
|
912 | + update_option($name, $value); |
|
913 | 913 | |
914 | 914 | /** |
915 | 915 | * Trigger action. |
@@ -918,13 +918,13 @@ discard block |
||
918 | 918 | * |
919 | 919 | * @since 1.8 |
920 | 920 | */ |
921 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
921 | + do_action("give_save_option_{$name}", $value, $name); |
|
922 | 922 | } |
923 | 923 | } else { |
924 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
925 | - $update_options = array_merge( $old_options, $update_options ); |
|
924 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
925 | + $update_options = array_merge($old_options, $update_options); |
|
926 | 926 | |
927 | - update_option( $option_name, $update_options ); |
|
927 | + update_option($option_name, $update_options); |
|
928 | 928 | |
929 | 929 | /** |
930 | 930 | * Trigger action. |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @since 1.8 |
935 | 935 | */ |
936 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
936 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | return true; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_donors_page() { |
26 | 26 | $default_views = give_donor_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_donor_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_donor_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_donors_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_donor_views', $views ); |
|
45 | + return apply_filters('give_donor_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
59 | + return apply_filters('give_donor_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_donors_list() { |
70 | - include dirname( __FILE__ ) . '/class-donor-table.php'; |
|
70 | + include dirname(__FILE__).'/class-donor-table.php'; |
|
71 | 71 | |
72 | 72 | $donors_table = new Give_Donor_List_Table(); |
73 | 73 | $donors_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $donors_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $donors_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $donors_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_donor_view( $view, $callbacks ) { |
|
116 | +function give_render_donor_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
120 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($donor_view_role)) { |
|
123 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $donor_id = (int) $_GET['id']; |
133 | - $donor = new Give_Donor( $donor_id ); |
|
133 | + $donor = new Give_Donor($donor_id); |
|
134 | 134 | |
135 | - if ( empty( $donor->id ) ) { |
|
136 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($donor->id)) { |
|
136 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
147 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $donor && $render ) : ?> |
|
153 | + <?php if ($donor && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $donor_tabs as $key => $tab ) : |
|
157 | + foreach ($donor_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
161 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-donor-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
172 | + <?php $callbacks[$view]($donor) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_donor_view( $donor ) { |
|
192 | +function give_donor_view($donor) { |
|
193 | 193 | |
194 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
194 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $donor The donor object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $donor ); |
|
203 | + do_action('give_donor_card_top', $donor); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
207 | 207 | |
208 | - <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
208 | + <form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="donor-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="donor-avatar"> |
215 | - <?php echo get_avatar( $donor->email ); ?> |
|
215 | + <?php echo get_avatar($donor->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="donor-name-wrap" class="left"> |
219 | 219 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
220 | - <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="donor-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
228 | - <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
228 | + <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User:', 'give'); ?></label></th> |
|
239 | 239 | <td> |
240 | 240 | <span class="donor-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -252,37 +252,37 @@ discard block |
||
252 | 252 | 'data' => $data_atts, |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $user_id ) ) { |
|
256 | - $userdata = get_userdata( $user_id ); |
|
255 | + if ( ! empty($user_id)) { |
|
256 | + $userdata = get_userdata($user_id); |
|
257 | 257 | $user_args['selected'] = $user_id; |
258 | 258 | } |
259 | 259 | |
260 | - echo Give()->html->ajax_user_search( $user_args ); |
|
260 | + echo Give()->html->ajax_user_search($user_args); |
|
261 | 261 | ?> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="donor-user-id info-item editable"> |
265 | - <?php if ( ! empty( $userdata ) ) { ?> |
|
266 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
265 | + <?php if ( ! empty($userdata)) { ?> |
|
266 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this donor record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($donor->user_id) && $donor->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="donor-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($donor->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '', |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="donor-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="donor-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="donor-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-donor" /> |
363 | - <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $donor The donor object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $donor ); |
|
379 | + do_action('give_donor_before_stats', $donor); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $donor->email ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($donor->email)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | // Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $donor->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($donor->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $donor The donor object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $donor ); |
|
408 | + do_action('give_donor_stats_list', $donor); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $donor The donor object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -431,46 +431,46 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $donor The donor object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $donor ); |
|
434 | + do_action('give_donor_before_tables', $donor); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($donor->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
463 | - 'email' => rawurlencode( $email ), |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
463 | + 'email' => rawurlencode($email), |
|
464 | 464 | 'give_action' => 'set_donor_primary_email', |
465 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
466 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
467 | - 'email' => rawurlencode( $email ), |
|
465 | + ), $base_url), 'give-set-donor-primary-email'); |
|
466 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
467 | + 'email' => rawurlencode($email), |
|
468 | 468 | 'give_action' => 'remove_donor_email', |
469 | - ), $base_url ), 'give-remove-donor-email' ); |
|
469 | + ), $base_url), 'give-remove-donor-email'); |
|
470 | 470 | ?> |
471 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
471 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
472 | 472 | | |
473 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
473 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
474 | 474 | <?php endif; ?> |
475 | 475 | </td> |
476 | 476 | </tr> |
@@ -480,59 +480,59 @@ discard block |
||
480 | 480 | <td colspan="2" class="add-donor-email-td"> |
481 | 481 | <div class="add-donor-email-wrapper"> |
482 | 482 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
483 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
484 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
485 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
486 | - <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
483 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
484 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
485 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
486 | + <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
487 | 487 | <span class="spinner"></span> |
488 | 488 | </div> |
489 | 489 | <div class="notice-wrap"></div> |
490 | 490 | </td> |
491 | 491 | </tr> |
492 | 492 | <?php } else { ?> |
493 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr> |
|
493 | + <tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr> |
|
494 | 494 | <?php }// End if(). |
495 | 495 | ?> |
496 | 496 | </tbody> |
497 | 497 | </table> |
498 | 498 | |
499 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
499 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
500 | 500 | <?php |
501 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
502 | - $payments = give_get_payments( array( |
|
501 | + $payment_ids = explode(',', $donor->payment_ids); |
|
502 | + $payments = give_get_payments(array( |
|
503 | 503 | 'post__in' => $payment_ids, |
504 | - ) ); |
|
505 | - $payments = array_slice( $payments, 0, 10 ); |
|
504 | + )); |
|
505 | + $payments = array_slice($payments, 0, 10); |
|
506 | 506 | ?> |
507 | 507 | <table class="wp-list-table widefat striped payments"> |
508 | 508 | <thead> |
509 | 509 | <tr> |
510 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
511 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
512 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
513 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
514 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
510 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
511 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
512 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
513 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
514 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
515 | 515 | </tr> |
516 | 516 | </thead> |
517 | 517 | <tbody> |
518 | - <?php if ( ! empty( $payments ) ) { ?> |
|
519 | - <?php foreach ( $payments as $payment ) : ?> |
|
518 | + <?php if ( ! empty($payments)) { ?> |
|
519 | + <?php foreach ($payments as $payment) : ?> |
|
520 | 520 | <tr> |
521 | 521 | <td><?php echo $payment->ID; ?></td> |
522 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
523 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
524 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
522 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
523 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
524 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
525 | 525 | <td> |
526 | 526 | <?php |
527 | 527 | printf( |
528 | 528 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
529 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
529 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
530 | 530 | sprintf( |
531 | 531 | /* translators: %s: Donation ID */ |
532 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
532 | + esc_attr__('View Donation %s.', 'give'), |
|
533 | 533 | $payment->ID |
534 | 534 | ), |
535 | - esc_html__( 'View Donation', 'give' ) |
|
535 | + esc_html__('View Donation', 'give') |
|
536 | 536 | ); |
537 | 537 | ?> |
538 | 538 | |
@@ -547,47 +547,47 @@ discard block |
||
547 | 547 | * @param object $donor The donor object being displayed. |
548 | 548 | * @param object $payment The payment object being displayed. |
549 | 549 | */ |
550 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
550 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
551 | 551 | ?> |
552 | 552 | </td> |
553 | 553 | </tr> |
554 | 554 | <?php endforeach; ?> |
555 | 555 | <?php } else { ?> |
556 | 556 | <tr> |
557 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
557 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
558 | 558 | </tr> |
559 | 559 | <?php }// End if(). |
560 | 560 | ?> |
561 | 561 | </tbody> |
562 | 562 | </table> |
563 | 563 | |
564 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
564 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
565 | 565 | <?php |
566 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
566 | + $donations = give_get_users_completed_donations($donor->email); |
|
567 | 567 | ?> |
568 | 568 | <table class="wp-list-table widefat striped donations"> |
569 | 569 | <thead> |
570 | 570 | <tr> |
571 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
572 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
571 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
572 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
573 | 573 | </tr> |
574 | 574 | </thead> |
575 | 575 | <tbody> |
576 | - <?php if ( ! empty( $donations ) ) { ?> |
|
577 | - <?php foreach ( $donations as $donation ) : ?> |
|
576 | + <?php if ( ! empty($donations)) { ?> |
|
577 | + <?php foreach ($donations as $donation) : ?> |
|
578 | 578 | <tr> |
579 | 579 | <td><?php echo $donation->post_title; ?></td> |
580 | 580 | <td> |
581 | 581 | <?php |
582 | 582 | printf( |
583 | 583 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
584 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
584 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: form name */ |
587 | - esc_attr__( 'View Form %s.', 'give' ), |
|
587 | + esc_attr__('View Form %s.', 'give'), |
|
588 | 588 | $donation->post_title |
589 | 589 | ), |
590 | - esc_html__( 'View Form', 'give' ) |
|
590 | + esc_html__('View Form', 'give') |
|
591 | 591 | ); |
592 | 592 | ?> |
593 | 593 | </td> |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | <?php endforeach; ?> |
596 | 596 | <?php } else { ?> |
597 | 597 | <tr> |
598 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
598 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
599 | 599 | </tr> |
600 | 600 | <?php } ?> |
601 | 601 | </tbody> |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @param object $donor The donor object being displayed. |
611 | 611 | */ |
612 | - do_action( 'give_donor_after_tables', $donor ); |
|
612 | + do_action('give_donor_after_tables', $donor); |
|
613 | 613 | ?> |
614 | 614 | |
615 | 615 | </div> |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @param object $donor The donor object being displayed. |
624 | 624 | */ |
625 | - do_action( 'give_donor_card_bottom', $donor ); |
|
625 | + do_action('give_donor_card_bottom', $donor); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -635,30 +635,30 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return void |
637 | 637 | */ |
638 | -function give_donor_notes_view( $donor ) { |
|
638 | +function give_donor_notes_view($donor) { |
|
639 | 639 | |
640 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
641 | - $paged = absint( $paged ); |
|
640 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
641 | + $paged = absint($paged); |
|
642 | 642 | $note_count = $donor->get_notes_count(); |
643 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
644 | - $total_pages = ceil( $note_count / $per_page ); |
|
645 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
643 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
644 | + $total_pages = ceil($note_count / $per_page); |
|
645 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
646 | 646 | ?> |
647 | 647 | |
648 | 648 | <div id="donor-notes-wrapper"> |
649 | 649 | <div class="donor-notes-header"> |
650 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
650 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
651 | 651 | </div> |
652 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
652 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
653 | 653 | |
654 | - <?php if ( 1 == $paged ) : ?> |
|
654 | + <?php if (1 == $paged) : ?> |
|
655 | 655 | <div style="display: block; margin-bottom: 55px;"> |
656 | - <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
656 | + <form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
657 | 657 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
658 | 658 | <br /> |
659 | 659 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
660 | 660 | <input type="hidden" name="give_action" value="add-donor-note" /> |
661 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
661 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
662 | 662 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
663 | 663 | </form> |
664 | 664 | </div> |
@@ -673,26 +673,26 @@ discard block |
||
673 | 673 | 'show_all' => true, |
674 | 674 | ); |
675 | 675 | |
676 | - echo paginate_links( $pagination_args ); |
|
676 | + echo paginate_links($pagination_args); |
|
677 | 677 | ?> |
678 | 678 | |
679 | 679 | <div id="give-donor-notes" class="postbox"> |
680 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
681 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
680 | + <?php if (count($donor_notes) > 0) { ?> |
|
681 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
682 | 682 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
683 | 683 | <span class="note-content-wrap"> |
684 | - <?php echo stripslashes( $note ); ?> |
|
684 | + <?php echo stripslashes($note); ?> |
|
685 | 685 | </span> |
686 | 686 | </div> |
687 | 687 | <?php endforeach; ?> |
688 | 688 | <?php } else { ?> |
689 | 689 | <div class="give-no-donor-notes"> |
690 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
690 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
691 | 691 | </div> |
692 | 692 | <?php } ?> |
693 | 693 | </div> |
694 | 694 | |
695 | - <?php echo paginate_links( $pagination_args ); ?> |
|
695 | + <?php echo paginate_links($pagination_args); ?> |
|
696 | 696 | |
697 | 697 | </div> |
698 | 698 | |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return void |
710 | 710 | */ |
711 | -function give_donor_delete_view( $donor ) { |
|
711 | +function give_donor_delete_view($donor) { |
|
712 | 712 | |
713 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
713 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Fires in donor delete screen, above the content. |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param object $donor The donor object being displayed. |
721 | 721 | */ |
722 | - do_action( 'give_donor_delete_top', $donor ); |
|
722 | + do_action('give_donor_delete_top', $donor); |
|
723 | 723 | ?> |
724 | 724 | |
725 | 725 | <div class="info-wrapper donor-section"> |
726 | 726 | |
727 | - <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
727 | + <form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
728 | 728 | |
729 | 729 | <div class="donor-notes-header"> |
730 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
730 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
731 | 731 | </div> |
732 | 732 | |
733 | 733 | |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | <span class="delete-donor-options"> |
737 | 737 | <p> |
738 | - <?php echo Give()->html->checkbox( array( |
|
738 | + <?php echo Give()->html->checkbox(array( |
|
739 | 739 | 'name' => 'give-donor-delete-confirm', |
740 | - ) ); ?> |
|
741 | - <label for="give-donor-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
740 | + )); ?> |
|
741 | + <label for="give-donor-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
742 | 742 | </p> |
743 | 743 | |
744 | 744 | <p> |
745 | - <?php echo Give()->html->checkbox( array( |
|
745 | + <?php echo Give()->html->checkbox(array( |
|
746 | 746 | 'name' => 'give-donor-delete-records', |
747 | 747 | 'options' => array( |
748 | 748 | 'disabled' => true, |
749 | 749 | ), |
750 | - ) ); ?> |
|
751 | - <label for="give-donor-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
750 | + )); ?> |
|
751 | + <label for="give-donor-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
752 | 752 | </p> |
753 | 753 | |
754 | 754 | <?php |
@@ -761,16 +761,16 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @param object $donor The donor object being displayed. |
763 | 763 | */ |
764 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
764 | + do_action('give_donor_delete_inputs', $donor); |
|
765 | 765 | ?> |
766 | 766 | </span> |
767 | 767 | |
768 | 768 | <span id="donor-edit-actions"> |
769 | 769 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
770 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
770 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
771 | 771 | <input type="hidden" name="give_action" value="delete-donor" /> |
772 | - <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
773 | - <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
772 | + <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
773 | + <a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
774 | 774 | </span> |
775 | 775 | |
776 | 776 | </div> |
@@ -786,5 +786,5 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @param object $donor The donor object being displayed. |
788 | 788 | */ |
789 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
789 | + do_action('give_donor_delete_bottom', $donor); |
|
790 | 790 | } |
@@ -10,7 +10,7 @@ discard block |
||
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 |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => esc_html__( 'Delete Donor', 'give' ), |
|
80 | + 'title' => esc_html__('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
@@ -12,13 +12,13 @@ discard block |
||
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 | |
19 | 19 | // Load WP_List_Table if not loaded |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
67 | - 'ajax' => false,// Does this table support ajax?. |
|
68 | - ) ); |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | + 'ajax' => false, // Does this table support ajax?. |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( |
|
96 | + <?php submit_button($text, 'button', false, false, array( |
|
97 | 97 | 'ID' => 'search-submit', |
98 | - ) ); ?> |
|
98 | + )); ?> |
|
99 | 99 | </p> |
100 | 100 | <?php |
101 | 101 | } |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name. |
113 | 113 | */ |
114 | - public function column_default( $donor, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($donor, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | |
117 | 117 | case 'num_donations' : |
118 | - $value = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . urlencode( $donor['id'] ) ) . '&status=publish' . ' ">' . esc_html( $donor['num_donations'] ) . '</a>'; |
|
118 | + $value = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.urlencode($donor['id'])).'&status=publish'.' ">'.esc_html($donor['num_donations']).'</a>'; |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'amount_spent' : |
122 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ] ) ); |
|
122 | + $value = give_currency_filter(give_format_amount($donor[$column_name])); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'date_created' : |
126 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
126 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | default: |
130 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
130 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] ); |
|
134 | + return apply_filters("give_report_column_{$column_name}", $value, $donor['id']); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function column_name( $donor ) { |
|
146 | - $name = '#' . $donor['id'] . ' '; |
|
147 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
148 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
149 | - $actions = $this->get_row_actions( $donor ); |
|
145 | + public function column_name($donor) { |
|
146 | + $name = '#'.$donor['id'].' '; |
|
147 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
148 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
149 | + $actions = $this->get_row_actions($donor); |
|
150 | 150 | |
151 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
151 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_columns() { |
162 | 162 | $columns = array( |
163 | - 'name' => __( 'Name', 'give' ), |
|
164 | - 'email' => __( 'Email', 'give' ), |
|
165 | - 'num_donations' => __( 'Donations', 'give' ), |
|
166 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
167 | - 'date_created' => __( 'Date Created', 'give' ), |
|
163 | + 'name' => __('Name', 'give'), |
|
164 | + 'email' => __('Email', 'give'), |
|
165 | + 'num_donations' => __('Donations', 'give'), |
|
166 | + 'amount_spent' => __('Total Donated', 'give'), |
|
167 | + 'date_created' => __('Date Created', 'give'), |
|
168 | 168 | ); |
169 | 169 | |
170 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
170 | + return apply_filters('give_list_donors_columns', $columns); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | public function get_sortable_columns() { |
182 | 182 | |
183 | 183 | $columns = array( |
184 | - 'date_created' => array( 'date_created', true ), |
|
185 | - 'name' => array( 'name', true ), |
|
186 | - 'num_donations' => array( 'purchase_count', false ), |
|
187 | - 'amount_spent' => array( 'purchase_value', false ), |
|
184 | + 'date_created' => array('date_created', true), |
|
185 | + 'name' => array('name', true), |
|
186 | + 'num_donations' => array('purchase_count', false), |
|
187 | + 'amount_spent' => array('purchase_value', false), |
|
188 | 188 | ); |
189 | 189 | |
190 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
190 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array An array of action links. |
202 | 202 | */ |
203 | - public function get_row_actions( $donor ) { |
|
203 | + public function get_row_actions($donor) { |
|
204 | 204 | |
205 | 205 | $actions = array( |
206 | 206 | |
207 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
207 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
208 | 208 | |
209 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
209 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
210 | 210 | |
211 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
211 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
212 | 212 | |
213 | 213 | ); |
214 | 214 | |
215 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
215 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @since 1.0 |
227 | 227 | * @return void |
228 | 228 | */ |
229 | - public function bulk_actions( $which = '' ) { |
|
229 | + public function bulk_actions($which = '') { |
|
230 | 230 | // These aren't really bulk actions but this outputs the markup in the right place. |
231 | 231 | } |
232 | 232 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return int Current page number. |
239 | 239 | */ |
240 | 240 | public function get_paged() { |
241 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
241 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return mixed string If search is present, false otherwise. |
250 | 250 | */ |
251 | 251 | public function get_search() { |
252 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
252 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | |
267 | 267 | // Get donor query. |
268 | 268 | $args = $this->get_donor_query(); |
269 | - $donors = Give()->donors->get_donors( $args ); |
|
269 | + $donors = Give()->donors->get_donors($args); |
|
270 | 270 | |
271 | - if ( $donors ) { |
|
271 | + if ($donors) { |
|
272 | 272 | |
273 | - foreach ( $donors as $donor ) { |
|
273 | + foreach ($donors as $donor) { |
|
274 | 274 | |
275 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
275 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
276 | 276 | |
277 | 277 | $data[] = array( |
278 | 278 | 'id' => $donor->id, |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
289 | + return apply_filters('give_donors_column_query_data', $data); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | $_donor_query = $this->get_donor_query(); |
301 | 301 | |
302 | 302 | $_donor_query['number'] = - 1; |
303 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
303 | + $donors = Give()->donors->get_donors($_donor_query); |
|
304 | 304 | |
305 | - return count( $donors ); |
|
305 | + return count($donors); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_donor_query() { |
316 | 316 | $paged = $this->get_paged(); |
317 | - $offset = $this->per_page * ( $paged - 1 ); |
|
317 | + $offset = $this->per_page * ($paged - 1); |
|
318 | 318 | $search = $this->get_search(); |
319 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
320 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
319 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
320 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
321 | 321 | |
322 | 322 | $args = array( |
323 | 323 | 'number' => $this->per_page, |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | 'orderby' => $orderby, |
327 | 327 | ); |
328 | 328 | |
329 | - if ( $search ) { |
|
330 | - if ( is_email( $search ) ) { |
|
329 | + if ($search) { |
|
330 | + if (is_email($search)) { |
|
331 | 331 | $args['email'] = $search; |
332 | - } elseif ( is_numeric( $search ) ) { |
|
332 | + } elseif (is_numeric($search)) { |
|
333 | 333 | $args['id'] = $search; |
334 | 334 | } else { |
335 | 335 | $args['name'] = $search; |
@@ -352,16 +352,16 @@ discard block |
||
352 | 352 | $hidden = array(); // No hidden columns. |
353 | 353 | $sortable = $this->get_sortable_columns(); |
354 | 354 | |
355 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
355 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
356 | 356 | |
357 | 357 | $this->items = $this->donor_data(); |
358 | 358 | |
359 | 359 | $this->total = $this->get_donor_count(); |
360 | 360 | |
361 | - $this->set_pagination_args( array( |
|
361 | + $this->set_pagination_args(array( |
|
362 | 362 | 'total_items' => $this->total, |
363 | 363 | 'per_page' => $this->per_page, |
364 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
365 | - ) ); |
|
364 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
365 | + )); |
|
366 | 366 | } |
367 | 367 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,48 +25,48 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | - if ( $did_upgrade ) { |
|
64 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
63 | + if ($did_upgrade) { |
|
64 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
69 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
68 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
69 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Display Upgrade Notices |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function give_show_upgrade_notices() { |
78 | 78 | // Don't show notices on the upgrades page. |
79 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
79 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
80 | 80 | return; |
81 | 81 | } |
82 | 82 | |
83 | - $give_version = get_option( 'give_version' ); |
|
83 | + $give_version = get_option('give_version'); |
|
84 | 84 | |
85 | - if ( ! $give_version ) { |
|
85 | + if ( ! $give_version) { |
|
86 | 86 | // 1.0 is the first version to use this option so we must add it. |
87 | 87 | $give_version = '1.0'; |
88 | 88 | } |
89 | 89 | |
90 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
90 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
91 | 91 | |
92 | 92 | /* |
93 | 93 | * NOTICE: |
@@ -100,64 +100,64 @@ discard block |
||
100 | 100 | // Resume updates. |
101 | 101 | // Check if we have a stalled upgrade. |
102 | 102 | $resume_upgrade = give_maybe_resume_upgrade(); |
103 | - if ( ! empty( $resume_upgrade ) ) { |
|
104 | - $resume_url = add_query_arg( give_maybe_resume_upgrade(), admin_url( 'index.php' ) ); |
|
103 | + if ( ! empty($resume_upgrade)) { |
|
104 | + $resume_url = add_query_arg(give_maybe_resume_upgrade(), admin_url('index.php')); |
|
105 | 105 | |
106 | - Give()->notices->register_notice( array( |
|
106 | + Give()->notices->register_notice(array( |
|
107 | 107 | 'id' => 'give-resume-updates', |
108 | 108 | 'type' => 'warning', |
109 | 109 | 'description' => sprintf( |
110 | - __( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ), |
|
111 | - esc_url( $resume_url ) |
|
110 | + __('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'), |
|
111 | + esc_url($resume_url) |
|
112 | 112 | ), |
113 | - ) ); |
|
113 | + )); |
|
114 | 114 | |
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // v1.3.2 Upgrades |
119 | - Give()->notices->register_notice( array( |
|
119 | + Give()->notices->register_notice(array( |
|
120 | 120 | 'id' => 'give-version-1-3-2-updates', |
121 | 121 | 'type' => 'warning', |
122 | 122 | 'description' => sprintf( |
123 | - '<p>' . __( 'Give 1.3.2 needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p>', |
|
124 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
123 | + '<p>'.__('Give 1.3.2 needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p>', |
|
124 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
125 | 125 | ), |
126 | - 'show' => ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ), |
|
127 | - ) ); |
|
126 | + 'show' => (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')), |
|
127 | + )); |
|
128 | 128 | |
129 | 129 | // v1.3.4 Upgrades //ensure the user has gone through 1.3.4. |
130 | - Give()->notices->register_notice( array( |
|
130 | + Give()->notices->register_notice(array( |
|
131 | 131 | 'id' => 'give-version-1-3-4-updates', |
132 | 132 | 'type' => 'warning', |
133 | 133 | 'description' => sprintf( |
134 | - '<p>' . __( 'Give 1.3.4 needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p>', |
|
135 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
134 | + '<p>'.__('Give 1.3.4 needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p>', |
|
135 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
136 | 136 | ), |
137 | - 'show' => ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ), |
|
138 | - ) ); |
|
137 | + 'show' => (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))), |
|
138 | + )); |
|
139 | 139 | |
140 | 140 | // v1.8 form metadata upgrades. |
141 | - Give()->notices->register_notice( array( |
|
141 | + Give()->notices->register_notice(array( |
|
142 | 142 | 'id' => 'give-version-1-8-updates', |
143 | 143 | 'type' => 'warning', |
144 | 144 | 'description' => sprintf( |
145 | - __( 'Give 1.8 needs to upgrade the form database, click <a class="give-upgrade-link" href="%s">here</a> to start the upgrade.', 'give' ), |
|
146 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) |
|
145 | + __('Give 1.8 needs to upgrade the form database, click <a class="give-upgrade-link" href="%s">here</a> to start the upgrade.', 'give'), |
|
146 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')) |
|
147 | 147 | ), |
148 | - 'show' => ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) |
|
149 | - ) ); |
|
148 | + 'show' => (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) |
|
149 | + )); |
|
150 | 150 | |
151 | 151 | // v1.8.9 Upgrades |
152 | - Give()->notices->register_notice( array( |
|
152 | + Give()->notices->register_notice(array( |
|
153 | 153 | 'id' => 'give-version-1-8-9-updates', |
154 | 154 | 'type' => 'warning', |
155 | 155 | 'description' => sprintf( |
156 | - __( 'Give 1.8.9 needs to update the donation form\'s meta fields within database, click <a href="%s">here</a> to start the upgrade.', 'give' ), |
|
157 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=v189_upgrades_levels_post_meta' ) ) |
|
156 | + __('Give 1.8.9 needs to update the donation form\'s meta fields within database, click <a href="%s">here</a> to start the upgrade.', 'give'), |
|
157 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=v189_upgrades_levels_post_meta')) |
|
158 | 158 | ), |
159 | - 'show' => ( version_compare( $give_version, '1.8.9', '<' ) || ( ! give_has_upgrade_completed( 'v189_upgrades_levels_post_meta' ) ) ), |
|
160 | - ) ); |
|
159 | + 'show' => (version_compare($give_version, '1.8.9', '<') || ( ! give_has_upgrade_completed('v189_upgrades_levels_post_meta'))), |
|
160 | + )); |
|
161 | 161 | |
162 | 162 | // End 'Stepped' upgrade process notices. |
163 | 163 | ?> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $upgrade_links.on('click', function (e) { |
169 | 169 | e.preventDefault(); |
170 | 170 | |
171 | - if (!window.confirm('<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>')) { |
|
171 | + if (!window.confirm('<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>')) { |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | <?php |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
184 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Triggers all upgrade functions |
@@ -193,29 +193,29 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function give_trigger_upgrades() { |
195 | 195 | |
196 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
197 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
196 | + if ( ! current_user_can('manage_give_settings')) { |
|
197 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
198 | 198 | 'response' => 403, |
199 | - ) ); |
|
199 | + )); |
|
200 | 200 | } |
201 | 201 | |
202 | - $give_version = get_option( 'give_version' ); |
|
202 | + $give_version = get_option('give_version'); |
|
203 | 203 | |
204 | - if ( ! $give_version ) { |
|
204 | + if ( ! $give_version) { |
|
205 | 205 | // 1.0 is the first version to use this option so we must add it. |
206 | 206 | $give_version = '1.0'; |
207 | - add_option( 'give_version', $give_version ); |
|
207 | + add_option('give_version', $give_version); |
|
208 | 208 | } |
209 | 209 | |
210 | - update_option( 'give_version', GIVE_VERSION ); |
|
211 | - delete_option( 'give_doing_upgrade' ); |
|
210 | + update_option('give_version', GIVE_VERSION); |
|
211 | + delete_option('give_doing_upgrade'); |
|
212 | 212 | |
213 | - if ( DOING_AJAX ) { |
|
214 | - die( 'complete' ); |
|
213 | + if (DOING_AJAX) { |
|
214 | + die('complete'); |
|
215 | 215 | } // End if(). |
216 | 216 | } |
217 | 217 | |
218 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
218 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Check if the upgrade routine has been run for a specific action |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return bool If the action has been added to the completed actions array |
228 | 228 | */ |
229 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
229 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
230 | 230 | |
231 | - if ( empty( $upgrade_action ) ) { |
|
231 | + if (empty($upgrade_action)) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
235 | 235 | $completed_upgrades = give_get_completed_upgrades(); |
236 | 236 | |
237 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
237 | + return in_array($upgrade_action, $completed_upgrades); |
|
238 | 238 | |
239 | 239 | } |
240 | 240 | |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
247 | 247 | */ |
248 | 248 | function give_maybe_resume_upgrade() { |
249 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
250 | - if ( empty( $doing_upgrade ) ) { |
|
249 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
250 | + if (empty($doing_upgrade)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return bool If the function was successfully added |
265 | 265 | */ |
266 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
266 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
267 | 267 | |
268 | - if ( empty( $upgrade_action ) ) { |
|
268 | + if (empty($upgrade_action)) { |
|
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | $completed_upgrades[] = $upgrade_action; |
274 | 274 | |
275 | 275 | // Remove any blanks, and only show uniques. |
276 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
276 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
277 | 277 | |
278 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
278 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function give_get_completed_upgrades() { |
288 | 288 | |
289 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
289 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
290 | 290 | |
291 | - if ( false === $completed_upgrades ) { |
|
291 | + if (false === $completed_upgrades) { |
|
292 | 292 | $completed_upgrades = array(); |
293 | 293 | } |
294 | 294 | |
@@ -305,31 +305,31 @@ discard block |
||
305 | 305 | */ |
306 | 306 | function give_v132_upgrade_give_payment_customer_id() { |
307 | 307 | global $wpdb; |
308 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
309 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
308 | + if ( ! current_user_can('manage_give_settings')) { |
|
309 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
310 | 310 | 'response' => 403, |
311 | - ) ); |
|
311 | + )); |
|
312 | 312 | } |
313 | 313 | |
314 | - ignore_user_abort( true ); |
|
314 | + ignore_user_abort(true); |
|
315 | 315 | |
316 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
317 | - @set_time_limit( 0 ); |
|
316 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
317 | + @set_time_limit(0); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // UPDATE DB METAKEYS. |
321 | 321 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
322 | - $query = $wpdb->query( $sql ); |
|
322 | + $query = $wpdb->query($sql); |
|
323 | 323 | |
324 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
325 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
326 | - delete_option( 'give_doing_upgrade' ); |
|
327 | - wp_redirect( admin_url() ); |
|
324 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
325 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
326 | + delete_option('give_doing_upgrade'); |
|
327 | + wp_redirect(admin_url()); |
|
328 | 328 | exit; |
329 | 329 | |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
332 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Upgrades the Offline Status |
@@ -342,16 +342,16 @@ discard block |
||
342 | 342 | |
343 | 343 | global $wpdb; |
344 | 344 | |
345 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
346 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
345 | + if ( ! current_user_can('manage_give_settings')) { |
|
346 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
347 | 347 | 'response' => 403, |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | } |
350 | 350 | |
351 | - ignore_user_abort( true ); |
|
351 | + ignore_user_abort(true); |
|
352 | 352 | |
353 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
354 | - @set_time_limit( 0 ); |
|
353 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
354 | + @set_time_limit(0); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | // Get abandoned offline payments. |
@@ -361,31 +361,31 @@ discard block |
||
361 | 361 | $where .= "AND ( p.post_status = 'abandoned' )"; |
362 | 362 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
363 | 363 | |
364 | - $sql = $select . $join . $where; |
|
365 | - $found_payments = $wpdb->get_col( $sql ); |
|
364 | + $sql = $select.$join.$where; |
|
365 | + $found_payments = $wpdb->get_col($sql); |
|
366 | 366 | |
367 | - foreach ( $found_payments as $payment ) { |
|
367 | + foreach ($found_payments as $payment) { |
|
368 | 368 | |
369 | 369 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
370 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
370 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
371 | 371 | |
372 | 372 | // 1450124863 = 12/10/2015 20:42:25. |
373 | - if ( $modified_time >= 1450124863 ) { |
|
373 | + if ($modified_time >= 1450124863) { |
|
374 | 374 | |
375 | - give_update_payment_status( $payment, 'pending' ); |
|
375 | + give_update_payment_status($payment, 'pending'); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
381 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
382 | - delete_option( 'give_doing_upgrade' ); |
|
383 | - wp_redirect( admin_url() ); |
|
380 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
381 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
382 | + delete_option('give_doing_upgrade'); |
|
383 | + wp_redirect(admin_url()); |
|
384 | 384 | exit; |
385 | 385 | |
386 | 386 | } |
387 | 387 | |
388 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
388 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
389 | 389 | |
390 | 390 | /** |
391 | 391 | * Cleanup User Roles |
@@ -396,17 +396,17 @@ discard block |
||
396 | 396 | */ |
397 | 397 | function give_v152_cleanup_users() { |
398 | 398 | |
399 | - $give_version = get_option( 'give_version' ); |
|
399 | + $give_version = get_option('give_version'); |
|
400 | 400 | |
401 | - if ( ! $give_version ) { |
|
401 | + if ( ! $give_version) { |
|
402 | 402 | // 1.0 is the first version to use this option so we must add it. |
403 | 403 | $give_version = '1.0'; |
404 | 404 | } |
405 | 405 | |
406 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
406 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
407 | 407 | |
408 | 408 | // v1.5.2 Upgrades |
409 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
409 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
410 | 410 | |
411 | 411 | // Delete all caps with "ss". |
412 | 412 | // Also delete all unused "campaign" roles. |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | ); |
454 | 454 | |
455 | 455 | global $wp_roles; |
456 | - foreach ( $delete_caps as $cap ) { |
|
457 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
458 | - $wp_roles->remove_cap( $role, $cap ); |
|
456 | + foreach ($delete_caps as $cap) { |
|
457 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
458 | + $wp_roles->remove_cap($role, $cap); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -465,15 +465,15 @@ discard block |
||
465 | 465 | $roles->add_caps(); |
466 | 466 | |
467 | 467 | // The Update Ran. |
468 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
469 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
470 | - delete_option( 'give_doing_upgrade' ); |
|
468 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
469 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
470 | + delete_option('give_doing_upgrade'); |
|
471 | 471 | |
472 | 472 | }// End if(). |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
476 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -516,53 +516,53 @@ discard block |
||
516 | 516 | |
517 | 517 | // Get addons license key. |
518 | 518 | $addons = array(); |
519 | - foreach ( $give_options as $key => $value ) { |
|
520 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
521 | - $addons[ $key ] = $value; |
|
519 | + foreach ($give_options as $key => $value) { |
|
520 | + if (false !== strpos($key, '_license_key')) { |
|
521 | + $addons[$key] = $value; |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | |
525 | 525 | // Bailout: We do not have any addon license data to upgrade. |
526 | - if ( empty( $addons ) ) { |
|
526 | + if (empty($addons)) { |
|
527 | 527 | return false; |
528 | 528 | } |
529 | 529 | |
530 | - foreach ( $addons as $key => $addon_license ) { |
|
530 | + foreach ($addons as $key => $addon_license) { |
|
531 | 531 | |
532 | 532 | // Get addon shortname. |
533 | - $shortname = str_replace( '_license_key', '', $key ); |
|
533 | + $shortname = str_replace('_license_key', '', $key); |
|
534 | 534 | |
535 | 535 | // Addon license option name. |
536 | - $addon_license_option_name = $shortname . '_license_active'; |
|
536 | + $addon_license_option_name = $shortname.'_license_active'; |
|
537 | 537 | |
538 | 538 | // bailout if license is empty. |
539 | - if ( empty( $addon_license ) ) { |
|
540 | - delete_option( $addon_license_option_name ); |
|
539 | + if (empty($addon_license)) { |
|
540 | + delete_option($addon_license_option_name); |
|
541 | 541 | continue; |
542 | 542 | } |
543 | 543 | |
544 | 544 | // Get addon name. |
545 | 545 | $addon_name = array(); |
546 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
547 | - foreach ( $addon_name_parts as $name_part ) { |
|
546 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
547 | + foreach ($addon_name_parts as $name_part) { |
|
548 | 548 | |
549 | 549 | // Fix addon name |
550 | - switch ( $name_part ) { |
|
550 | + switch ($name_part) { |
|
551 | 551 | case 'authorizenet' : |
552 | 552 | $name_part = 'authorize.net'; |
553 | 553 | break; |
554 | 554 | } |
555 | 555 | |
556 | - $addon_name[] = ucfirst( $name_part ); |
|
556 | + $addon_name[] = ucfirst($name_part); |
|
557 | 557 | } |
558 | 558 | |
559 | - $addon_name = implode( ' ', $addon_name ); |
|
559 | + $addon_name = implode(' ', $addon_name); |
|
560 | 560 | |
561 | 561 | // Data to send to the API |
562 | 562 | $api_params = array( |
563 | 563 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
564 | 564 | 'license' => $addon_license, |
565 | - 'item_name' => urlencode( $addon_name ), |
|
565 | + 'item_name' => urlencode($addon_name), |
|
566 | 566 | 'url' => home_url(), |
567 | 567 | ); |
568 | 568 | |
@@ -577,17 +577,17 @@ discard block |
||
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Make sure there are no errors. |
580 | - if ( is_wp_error( $response ) ) { |
|
581 | - delete_option( $addon_license_option_name ); |
|
580 | + if (is_wp_error($response)) { |
|
581 | + delete_option($addon_license_option_name); |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | 585 | // Tell WordPress to look for updates. |
586 | - set_site_transient( 'update_plugins', null ); |
|
586 | + set_site_transient('update_plugins', null); |
|
587 | 587 | |
588 | 588 | // Decode license data. |
589 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
590 | - update_option( $addon_license_option_name, $license_data ); |
|
589 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
590 | + update_option($addon_license_option_name, $license_data); |
|
591 | 591 | }// End foreach(). |
592 | 592 | } |
593 | 593 | |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | ); |
618 | 618 | |
619 | 619 | global $wp_roles; |
620 | - foreach ( $delete_caps as $cap ) { |
|
621 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
622 | - $wp_roles->remove_cap( $role, $cap ); |
|
620 | + foreach ($delete_caps as $cap) { |
|
621 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
622 | + $wp_roles->remove_cap($role, $cap); |
|
623 | 623 | } |
624 | 624 | } |
625 | 625 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | function give_v18_upgrades_core_setting() { |
654 | 654 | // Core settings which changes from checkbox to radio. |
655 | 655 | $core_setting_names = array_merge( |
656 | - array_keys( give_v18_renamed_core_settings() ), |
|
656 | + array_keys(give_v18_renamed_core_settings()), |
|
657 | 657 | array( |
658 | 658 | 'uninstall_on_delete', |
659 | 659 | 'scripts_footer', |
@@ -665,48 +665,48 @@ discard block |
||
665 | 665 | ); |
666 | 666 | |
667 | 667 | // Bailout: If not any setting define. |
668 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
668 | + if ($give_settings = get_option('give_settings')) { |
|
669 | 669 | |
670 | 670 | $setting_changed = false; |
671 | 671 | |
672 | 672 | // Loop: check each setting field. |
673 | - foreach ( $core_setting_names as $setting_name ) { |
|
673 | + foreach ($core_setting_names as $setting_name) { |
|
674 | 674 | // New setting name. |
675 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
675 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
676 | 676 | |
677 | 677 | // Continue: If setting already set. |
678 | 678 | if ( |
679 | - array_key_exists( $new_setting_name, $give_settings ) |
|
680 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
679 | + array_key_exists($new_setting_name, $give_settings) |
|
680 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
681 | 681 | ) { |
682 | 682 | continue; |
683 | 683 | } |
684 | 684 | |
685 | 685 | // Set checkbox value to radio value. |
686 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
686 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
687 | 687 | |
688 | 688 | // @see https://github.com/WordImpress/Give/issues/1063 |
689 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
689 | + if (false !== strpos($setting_name, 'disable_')) { |
|
690 | 690 | |
691 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
692 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
691 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
692 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
693 | 693 | |
694 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
694 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | // Tell bot to update core setting to db. |
698 | - if ( ! $setting_changed ) { |
|
698 | + if ( ! $setting_changed) { |
|
699 | 699 | $setting_changed = true; |
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | 703 | // Update setting only if they changed. |
704 | - if ( $setting_changed ) { |
|
705 | - update_option( 'give_settings', $give_settings ); |
|
704 | + if ($setting_changed) { |
|
705 | + update_option('give_settings', $give_settings); |
|
706 | 706 | } |
707 | 707 | }// End if(). |
708 | 708 | |
709 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
709 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
@@ -716,22 +716,22 @@ discard block |
||
716 | 716 | * @return void |
717 | 717 | */ |
718 | 718 | function give_v18_upgrades_form_metadata() { |
719 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
720 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
719 | + if ( ! current_user_can('manage_give_settings')) { |
|
720 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
721 | 721 | 'response' => 403, |
722 | - ) ); |
|
722 | + )); |
|
723 | 723 | } |
724 | 724 | |
725 | - ignore_user_abort( true ); |
|
725 | + ignore_user_abort(true); |
|
726 | 726 | |
727 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
728 | - @set_time_limit( 0 ); |
|
727 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
728 | + @set_time_limit(0); |
|
729 | 729 | } |
730 | 730 | |
731 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
731 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
732 | 732 | |
733 | 733 | // form query |
734 | - $forms = new WP_Query( array( |
|
734 | + $forms = new WP_Query(array( |
|
735 | 735 | 'paged' => $step, |
736 | 736 | 'status' => 'any', |
737 | 737 | 'order' => 'ASC', |
@@ -740,39 +740,39 @@ discard block |
||
740 | 740 | ) |
741 | 741 | ); |
742 | 742 | |
743 | - if ( $forms->have_posts() ) { |
|
744 | - while ( $forms->have_posts() ) { |
|
743 | + if ($forms->have_posts()) { |
|
744 | + while ($forms->have_posts()) { |
|
745 | 745 | $forms->the_post(); |
746 | 746 | |
747 | 747 | // Form content. |
748 | 748 | // Note in version 1.8 display content setting split into display content and content placement setting. |
749 | 749 | // You can delete _give_content_option in future |
750 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
751 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
752 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
753 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
750 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
751 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
752 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
753 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
754 | 754 | |
755 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
756 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
755 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
756 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | // "Disable" Guest Donation. Checkbox |
760 | 760 | // See: https://github.com/WordImpress/Give/issues/1470 |
761 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
762 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
763 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
761 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
762 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
763 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
764 | 764 | |
765 | 765 | // Offline Donations |
766 | 766 | // See: https://github.com/WordImpress/Give/issues/1579 |
767 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
768 | - if ( 'no' === $offline_donation ) { |
|
767 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
768 | + if ('no' === $offline_donation) { |
|
769 | 769 | $offline_donation_newval = 'global'; |
770 | - } elseif ( 'yes' === $offline_donation ) { |
|
770 | + } elseif ('yes' === $offline_donation) { |
|
771 | 771 | $offline_donation_newval = 'enabled'; |
772 | 772 | } else { |
773 | 773 | $offline_donation_newval = 'disabled'; |
774 | 774 | } |
775 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
775 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
776 | 776 | |
777 | 777 | // Convert yes/no setting field to enabled/disabled. |
778 | 778 | $form_radio_settings = array( |
@@ -792,15 +792,15 @@ discard block |
||
792 | 792 | '_give_offline_donation_enable_billing_fields_single', |
793 | 793 | ); |
794 | 794 | |
795 | - foreach ( $form_radio_settings as $meta_key ) { |
|
795 | + foreach ($form_radio_settings as $meta_key) { |
|
796 | 796 | // Get value. |
797 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
797 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
798 | 798 | |
799 | 799 | // Convert meta value only if it is in yes/no/none. |
800 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
800 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
801 | 801 | |
802 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
803 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
802 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
803 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | }// End while(). |
@@ -808,27 +808,27 @@ discard block |
||
808 | 808 | wp_reset_postdata(); |
809 | 809 | |
810 | 810 | // Forms found so upgrade them |
811 | - $step ++; |
|
812 | - $redirect = add_query_arg( array( |
|
811 | + $step++; |
|
812 | + $redirect = add_query_arg(array( |
|
813 | 813 | 'page' => 'give-upgrades', |
814 | 814 | 'give-upgrade' => 'give_v18_upgrades_form_metadata', |
815 | 815 | 'step' => $step, |
816 | - ), admin_url( 'index.php' ) ); |
|
817 | - wp_redirect( $redirect ); |
|
816 | + ), admin_url('index.php')); |
|
817 | + wp_redirect($redirect); |
|
818 | 818 | exit(); |
819 | 819 | |
820 | 820 | } else { |
821 | 821 | // No more forms found, finish up. |
822 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
823 | - delete_option( 'give_doing_upgrade' ); |
|
824 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
822 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
823 | + delete_option('give_doing_upgrade'); |
|
824 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
825 | 825 | |
826 | - wp_redirect( admin_url() ); |
|
826 | + wp_redirect(admin_url()); |
|
827 | 827 | exit; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | |
831 | -add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' ); |
|
831 | +add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata'); |
|
832 | 832 | |
833 | 833 | /** |
834 | 834 | * Get list of core setting renamed in version 1.8. |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | '_transient_give_stats_', |
875 | 875 | 'give_cache', |
876 | 876 | '_transient_give_add_ons_feed', |
877 | - '_transient__give_ajax_works' . |
|
877 | + '_transient__give_ajax_works'. |
|
878 | 878 | '_transient_give_total_api_keys', |
879 | 879 | '_transient_give_i18n_give_promo_hide', |
880 | 880 | '_transient_give_contributors', |
@@ -901,24 +901,24 @@ discard block |
||
901 | 901 | ARRAY_A |
902 | 902 | ); |
903 | 903 | |
904 | - if ( ! empty( $user_apikey_options ) ) { |
|
905 | - foreach ( $user_apikey_options as $user ) { |
|
906 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
907 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
908 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
904 | + if ( ! empty($user_apikey_options)) { |
|
905 | + foreach ($user_apikey_options as $user) { |
|
906 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
907 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
908 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | - if ( ! empty( $cached_options ) ) { |
|
913 | - foreach ( $cached_options as $option ) { |
|
914 | - switch ( true ) { |
|
915 | - case ( false !== strpos( $option, 'transient' ) ): |
|
916 | - $option = str_replace( '_transient_', '', $option ); |
|
917 | - delete_transient( $option ); |
|
912 | + if ( ! empty($cached_options)) { |
|
913 | + foreach ($cached_options as $option) { |
|
914 | + switch (true) { |
|
915 | + case (false !== strpos($option, 'transient')): |
|
916 | + $option = str_replace('_transient_', '', $option); |
|
917 | + delete_transient($option); |
|
918 | 918 | break; |
919 | 919 | |
920 | 920 | default: |
921 | - delete_option( $option ); |
|
921 | + delete_option($option); |
|
922 | 922 | } |
923 | 923 | } |
924 | 924 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | global $wp_roles; |
937 | 937 | |
938 | 938 | // Get the role object. |
939 | - $give_worker = get_role( 'give_worker' ); |
|
939 | + $give_worker = get_role('give_worker'); |
|
940 | 940 | |
941 | 941 | // A list of capabilities to add for give workers. |
942 | 942 | $caps_to_add = array( |
@@ -944,9 +944,9 @@ discard block |
||
944 | 944 | 'edit_pages', |
945 | 945 | ); |
946 | 946 | |
947 | - foreach ( $caps_to_add as $cap ) { |
|
947 | + foreach ($caps_to_add as $cap) { |
|
948 | 948 | // Add the capability. |
949 | - $give_worker->add_cap( $cap ); |
|
949 | + $give_worker->add_cap($cap); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | } |
@@ -960,22 +960,22 @@ discard block |
||
960 | 960 | */ |
961 | 961 | function give_v189_upgrades_levels_post_meta_callback() { |
962 | 962 | |
963 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
964 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
963 | + if ( ! current_user_can('manage_give_settings')) { |
|
964 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
965 | 965 | 'response' => 403, |
966 | - ) ); |
|
966 | + )); |
|
967 | 967 | } |
968 | 968 | |
969 | - ignore_user_abort( true ); |
|
969 | + ignore_user_abort(true); |
|
970 | 970 | |
971 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
972 | - @set_time_limit( 0 ); |
|
971 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
972 | + @set_time_limit(0); |
|
973 | 973 | } |
974 | 974 | |
975 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
975 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
976 | 976 | |
977 | 977 | // form query |
978 | - $donation_forms = new WP_Query( array( |
|
978 | + $donation_forms = new WP_Query(array( |
|
979 | 979 | 'paged' => $step, |
980 | 980 | 'status' => 'any', |
981 | 981 | 'order' => 'ASC', |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | |
987 | - if ( $donation_forms->have_posts() ) { |
|
988 | - while ( $donation_forms->have_posts() ) { |
|
987 | + if ($donation_forms->have_posts()) { |
|
988 | + while ($donation_forms->have_posts()) { |
|
989 | 989 | $donation_forms->the_post(); |
990 | 990 | $form_id = get_the_ID(); |
991 | 991 | |
@@ -993,41 +993,41 @@ discard block |
||
993 | 993 | update_post_meta( |
994 | 994 | $form_id, |
995 | 995 | '_give_set_price', |
996 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
996 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
997 | 997 | ); |
998 | 998 | |
999 | 999 | // Remove formatting from _give_custom_amount_minimum |
1000 | 1000 | update_post_meta( |
1001 | 1001 | $form_id, |
1002 | 1002 | '_give_custom_amount_minimum', |
1003 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
1003 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
1004 | 1004 | ); |
1005 | 1005 | |
1006 | 1006 | // Bailout. |
1007 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
1007 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
1008 | 1008 | continue; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
1011 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
1012 | 1012 | |
1013 | - if ( ! empty( $donation_levels ) ) { |
|
1013 | + if ( ! empty($donation_levels)) { |
|
1014 | 1014 | |
1015 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
1016 | - if( isset( $donation_level['_give_amount'] ) ) { |
|
1017 | - $donation_levels[$index]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
1015 | + foreach ($donation_levels as $index => $donation_level) { |
|
1016 | + if (isset($donation_level['_give_amount'])) { |
|
1017 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
1021 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
1022 | 1022 | |
1023 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
1023 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
1024 | 1024 | |
1025 | - $min_amount = min( $donation_levels_amounts ); |
|
1026 | - $max_amount = max( $donation_levels_amounts ); |
|
1025 | + $min_amount = min($donation_levels_amounts); |
|
1026 | + $max_amount = max($donation_levels_amounts); |
|
1027 | 1027 | |
1028 | 1028 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
1029 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
1030 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
1029 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
1030 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | } |
@@ -1036,27 +1036,27 @@ discard block |
||
1036 | 1036 | wp_reset_postdata(); |
1037 | 1037 | |
1038 | 1038 | // Forms found so upgrade them |
1039 | - $step ++; |
|
1040 | - $redirect = add_query_arg( array( |
|
1039 | + $step++; |
|
1040 | + $redirect = add_query_arg(array( |
|
1041 | 1041 | 'page' => 'give-upgrades', |
1042 | 1042 | 'give-upgrade' => 'v189_upgrades_levels_post_meta', |
1043 | 1043 | 'step' => $step, |
1044 | - ), admin_url( 'index.php' ) ); |
|
1045 | - wp_redirect( $redirect ); |
|
1044 | + ), admin_url('index.php')); |
|
1045 | + wp_redirect($redirect); |
|
1046 | 1046 | exit(); |
1047 | 1047 | } else { |
1048 | 1048 | // The Update Ran. |
1049 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
1050 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
1051 | - delete_option( 'give_doing_upgrade' ); |
|
1049 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
1050 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
1051 | + delete_option('give_doing_upgrade'); |
|
1052 | 1052 | |
1053 | - wp_redirect( admin_url() ); |
|
1053 | + wp_redirect(admin_url()); |
|
1054 | 1054 | exit; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | } |
1058 | 1058 | |
1059 | -add_action( 'give_v189_upgrades_levels_post_meta', 'give_v189_upgrades_levels_post_meta_callback' ); |
|
1059 | +add_action('give_v189_upgrades_levels_post_meta', 'give_v189_upgrades_levels_post_meta_callback'); |
|
1060 | 1060 | |
1061 | 1061 | |
1062 | 1062 | /** |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string Donations dropdown. |
37 | 37 | */ |
38 | - public function donations_dropdown( $args = array() ) { |
|
38 | + public function donations_dropdown($args = array()) { |
|
39 | 39 | |
40 | 40 | $defaults = array( |
41 | 41 | 'name' => 'donations', |
@@ -45,32 +45,32 @@ discard block |
||
45 | 45 | 'selected' => 0, |
46 | 46 | 'chosen' => false, |
47 | 47 | 'number' => 30, |
48 | - 'placeholder' => __( 'Select a donation', 'give' ), |
|
48 | + 'placeholder' => __('Select a donation', 'give'), |
|
49 | 49 | ); |
50 | 50 | |
51 | - $args = wp_parse_args( $args, $defaults ); |
|
51 | + $args = wp_parse_args($args, $defaults); |
|
52 | 52 | |
53 | - $payments = new Give_Payments_Query( array( |
|
53 | + $payments = new Give_Payments_Query(array( |
|
54 | 54 | 'number' => $args['number'], |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | $payments = $payments->get_payments(); |
58 | 58 | |
59 | 59 | $options = array(); |
60 | 60 | |
61 | 61 | // Provide nice human readable options. |
62 | - if ( $payments ) { |
|
62 | + if ($payments) { |
|
63 | 63 | $options[0] = $args['placeholder']; |
64 | - foreach ( $payments as $payment ) { |
|
64 | + foreach ($payments as $payment) { |
|
65 | 65 | |
66 | - $options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
66 | + $options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } else { |
70 | - $options[0] = __( 'No donations found.', 'give' ); |
|
70 | + $options[0] = __('No donations found.', 'give'); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output = $this->select( array( |
|
73 | + $output = $this->select(array( |
|
74 | 74 | 'name' => $args['name'], |
75 | 75 | 'selected' => $args['selected'], |
76 | 76 | 'id' => $args['id'], |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'select_atts' => $args['select_atts'], |
83 | 83 | 'show_option_all' => false, |
84 | 84 | 'show_option_none' => false, |
85 | - ) ); |
|
85 | + )); |
|
86 | 86 | |
87 | 87 | return $output; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return string Give forms dropdown. |
101 | 101 | */ |
102 | - public function forms_dropdown( $args = array() ) { |
|
102 | + public function forms_dropdown($args = array()) { |
|
103 | 103 | |
104 | 104 | $defaults = array( |
105 | 105 | 'name' => 'forms', |
@@ -109,39 +109,39 @@ discard block |
||
109 | 109 | 'selected' => 0, |
110 | 110 | 'chosen' => false, |
111 | 111 | 'number' => 30, |
112 | - 'placeholder' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
112 | + 'placeholder' => esc_attr__('Select a Donation Form', 'give'), |
|
113 | 113 | 'data' => array( |
114 | 114 | 'search-type' => 'form', |
115 | 115 | ), |
116 | 116 | ); |
117 | 117 | |
118 | - $args = wp_parse_args( $args, $defaults ); |
|
118 | + $args = wp_parse_args($args, $defaults); |
|
119 | 119 | |
120 | - $forms = get_posts( array( |
|
120 | + $forms = get_posts(array( |
|
121 | 121 | 'post_type' => 'give_forms', |
122 | 122 | 'orderby' => 'title', |
123 | 123 | 'order' => 'ASC', |
124 | 124 | 'posts_per_page' => $args['number'], |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $options = array(); |
128 | 128 | |
129 | 129 | // Ensure the selected. |
130 | - if ( false !== $args['selected'] && $args['selected'] !== 0 ) { |
|
131 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
130 | + if (false !== $args['selected'] && $args['selected'] !== 0) { |
|
131 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( $forms ) { |
|
134 | + if ($forms) { |
|
135 | 135 | $options[0] = $args['placeholder']; |
136 | - foreach ( $forms as $form ) { |
|
137 | - $form_title = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title; |
|
138 | - $options[ absint( $form->ID ) ] = esc_html( $form_title ); |
|
136 | + foreach ($forms as $form) { |
|
137 | + $form_title = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title; |
|
138 | + $options[absint($form->ID)] = esc_html($form_title); |
|
139 | 139 | } |
140 | 140 | } else { |
141 | - $options[0] = esc_html__( 'No forms found.', 'give' ); |
|
141 | + $options[0] = esc_html__('No forms found.', 'give'); |
|
142 | 142 | } |
143 | 143 | |
144 | - $output = $this->select( array( |
|
144 | + $output = $this->select(array( |
|
145 | 145 | 'name' => $args['name'], |
146 | 146 | 'selected' => $args['selected'], |
147 | 147 | 'id' => $args['id'], |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'show_option_all' => false, |
154 | 154 | 'show_option_none' => false, |
155 | 155 | 'data' => $args['data'], |
156 | - ) ); |
|
156 | + )); |
|
157 | 157 | |
158 | 158 | return $output; |
159 | 159 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string Donors dropdown. |
172 | 172 | */ |
173 | - public function donor_dropdown( $args = array() ) { |
|
173 | + public function donor_dropdown($args = array()) { |
|
174 | 174 | |
175 | 175 | $defaults = array( |
176 | 176 | 'name' => 'donors', |
@@ -179,57 +179,57 @@ discard block |
||
179 | 179 | 'multiple' => false, |
180 | 180 | 'selected' => 0, |
181 | 181 | 'chosen' => true, |
182 | - 'placeholder' => esc_attr__( 'Select a Donor', 'give' ), |
|
182 | + 'placeholder' => esc_attr__('Select a Donor', 'give'), |
|
183 | 183 | 'number' => 30, |
184 | 184 | 'data' => array( |
185 | 185 | 'search-type' => 'donor', |
186 | 186 | ), |
187 | 187 | ); |
188 | 188 | |
189 | - $args = wp_parse_args( $args, $defaults ); |
|
189 | + $args = wp_parse_args($args, $defaults); |
|
190 | 190 | |
191 | - $donors = Give()->donors->get_donors( array( |
|
191 | + $donors = Give()->donors->get_donors(array( |
|
192 | 192 | 'number' => $args['number'] |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | |
195 | 195 | $options = array(); |
196 | 196 | |
197 | - if ( $donors ) { |
|
198 | - $options[0] = esc_html__( 'No donor attached', 'give' ); |
|
199 | - foreach ( $donors as $donor ) { |
|
200 | - $options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
197 | + if ($donors) { |
|
198 | + $options[0] = esc_html__('No donor attached', 'give'); |
|
199 | + foreach ($donors as $donor) { |
|
200 | + $options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')'); |
|
201 | 201 | } |
202 | 202 | } else { |
203 | - $options[0] = esc_html__( 'No donors found.', 'give' ); |
|
203 | + $options[0] = esc_html__('No donors found.', 'give'); |
|
204 | 204 | } |
205 | 205 | |
206 | - if ( ! empty( $args['selected'] ) ) { |
|
206 | + if ( ! empty($args['selected'])) { |
|
207 | 207 | |
208 | 208 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed. |
209 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
209 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
210 | 210 | |
211 | - $donor = new Give_Donor( $args['selected'] ); |
|
211 | + $donor = new Give_Donor($args['selected']); |
|
212 | 212 | |
213 | - if ( $donor ) { |
|
213 | + if ($donor) { |
|
214 | 214 | |
215 | - $options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' ); |
|
215 | + $options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')'); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - $output = $this->select( array( |
|
221 | + $output = $this->select(array( |
|
222 | 222 | 'name' => $args['name'], |
223 | 223 | 'selected' => $args['selected'], |
224 | 224 | 'id' => $args['id'], |
225 | - 'class' => $args['class'] . ' give-customer-select', |
|
225 | + 'class' => $args['class'].' give-customer-select', |
|
226 | 226 | 'options' => $options, |
227 | 227 | 'multiple' => $args['multiple'], |
228 | 228 | 'chosen' => $args['chosen'], |
229 | 229 | 'show_option_all' => false, |
230 | 230 | 'show_option_none' => false, |
231 | 231 | 'data' => $args['data'], |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | |
234 | 234 | return $output; |
235 | 235 | } |
@@ -248,21 +248,21 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string Categories dropdown. |
250 | 250 | */ |
251 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) { |
|
252 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
251 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) { |
|
252 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
253 | 253 | $options = array(); |
254 | 254 | |
255 | - foreach ( $categories as $category ) { |
|
256 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
255 | + foreach ($categories as $category) { |
|
256 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
257 | 257 | } |
258 | 258 | |
259 | - $output = $this->select( wp_parse_args( $args, array( |
|
259 | + $output = $this->select(wp_parse_args($args, array( |
|
260 | 260 | 'name' => $name, |
261 | 261 | 'selected' => $selected, |
262 | 262 | 'options' => $options, |
263 | - 'show_option_all' => esc_html__( 'All Categories', 'give' ), |
|
263 | + 'show_option_all' => esc_html__('All Categories', 'give'), |
|
264 | 264 | 'show_option_none' => false, |
265 | - ) ) ); |
|
265 | + ))); |
|
266 | 266 | |
267 | 267 | return $output; |
268 | 268 | } |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string Tags dropdown. |
283 | 283 | */ |
284 | - public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) { |
|
285 | - $tags = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) ); |
|
284 | + public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) { |
|
285 | + $tags = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array())); |
|
286 | 286 | $options = array(); |
287 | 287 | |
288 | - foreach ( $tags as $tag ) { |
|
289 | - $options[ absint( $tag->term_id ) ] = esc_html( $tag->name ); |
|
288 | + foreach ($tags as $tag) { |
|
289 | + $options[absint($tag->term_id)] = esc_html($tag->name); |
|
290 | 290 | } |
291 | 291 | |
292 | - $output = $this->select( wp_parse_args( $args, array( |
|
292 | + $output = $this->select(wp_parse_args($args, array( |
|
293 | 293 | 'name' => $name, |
294 | 294 | 'selected' => $selected, |
295 | 295 | 'options' => $options, |
296 | - 'show_option_all' => esc_html__( 'All Tags', 'give' ), |
|
296 | + 'show_option_all' => esc_html__('All Tags', 'give'), |
|
297 | 297 | 'show_option_none' => false, |
298 | - ) ) ); |
|
298 | + ))); |
|
299 | 299 | |
300 | 300 | return $output; |
301 | 301 | } |
@@ -315,25 +315,25 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return string Years dropdown. |
317 | 317 | */ |
318 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
319 | - $current = date( 'Y' ); |
|
320 | - $start_year = $current - absint( $years_before ); |
|
321 | - $end_year = $current + absint( $years_after ); |
|
322 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
318 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
319 | + $current = date('Y'); |
|
320 | + $start_year = $current - absint($years_before); |
|
321 | + $end_year = $current + absint($years_after); |
|
322 | + $selected = empty($selected) ? date('Y') : $selected; |
|
323 | 323 | $options = array(); |
324 | 324 | |
325 | - while ( $start_year <= $end_year ) { |
|
326 | - $options[ absint( $start_year ) ] = $start_year; |
|
327 | - $start_year ++; |
|
325 | + while ($start_year <= $end_year) { |
|
326 | + $options[absint($start_year)] = $start_year; |
|
327 | + $start_year++; |
|
328 | 328 | } |
329 | 329 | |
330 | - $output = $this->select( array( |
|
330 | + $output = $this->select(array( |
|
331 | 331 | 'name' => $name, |
332 | 332 | 'selected' => $selected, |
333 | 333 | 'options' => $options, |
334 | 334 | 'show_option_all' => false, |
335 | 335 | 'show_option_none' => false, |
336 | - ) ); |
|
336 | + )); |
|
337 | 337 | |
338 | 338 | return $output; |
339 | 339 | } |
@@ -351,23 +351,23 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return string Months dropdown. |
353 | 353 | */ |
354 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
354 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
355 | 355 | $month = 1; |
356 | 356 | $options = array(); |
357 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
357 | + $selected = empty($selected) ? date('n') : $selected; |
|
358 | 358 | |
359 | - while ( $month <= 12 ) { |
|
360 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
361 | - $month ++; |
|
359 | + while ($month <= 12) { |
|
360 | + $options[absint($month)] = give_month_num_to_name($month); |
|
361 | + $month++; |
|
362 | 362 | } |
363 | 363 | |
364 | - $output = $this->select( array( |
|
364 | + $output = $this->select(array( |
|
365 | 365 | 'name' => $name, |
366 | 366 | 'selected' => $selected, |
367 | 367 | 'options' => $options, |
368 | 368 | 'show_option_all' => false, |
369 | 369 | 'show_option_none' => false, |
370 | - ) ); |
|
370 | + )); |
|
371 | 371 | |
372 | 372 | return $output; |
373 | 373 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return string The dropdown. |
386 | 386 | */ |
387 | - public function select( $args = array() ) { |
|
387 | + public function select($args = array()) { |
|
388 | 388 | $defaults = array( |
389 | 389 | 'options' => array(), |
390 | 390 | 'name' => null, |
@@ -395,67 +395,67 @@ discard block |
||
395 | 395 | 'placeholder' => null, |
396 | 396 | 'multiple' => false, |
397 | 397 | 'select_atts' => false, |
398 | - 'show_option_all' => __( 'All', 'give' ), |
|
399 | - 'show_option_none' => __( 'None', 'give' ), |
|
398 | + 'show_option_all' => __('All', 'give'), |
|
399 | + 'show_option_none' => __('None', 'give'), |
|
400 | 400 | 'data' => array(), |
401 | 401 | 'readonly' => false, |
402 | 402 | 'disabled' => false, |
403 | 403 | ); |
404 | 404 | |
405 | - $args = wp_parse_args( $args, $defaults ); |
|
405 | + $args = wp_parse_args($args, $defaults); |
|
406 | 406 | |
407 | 407 | $data_elements = ''; |
408 | - foreach ( $args['data'] as $key => $value ) { |
|
409 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
408 | + foreach ($args['data'] as $key => $value) { |
|
409 | + $data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"'; |
|
410 | 410 | } |
411 | 411 | |
412 | - if ( $args['multiple'] ) { |
|
412 | + if ($args['multiple']) { |
|
413 | 413 | $multiple = ' MULTIPLE'; |
414 | 414 | } else { |
415 | 415 | $multiple = ''; |
416 | 416 | } |
417 | 417 | |
418 | - if ( $args['chosen'] ) { |
|
418 | + if ($args['chosen']) { |
|
419 | 419 | $args['class'] .= ' give-select-chosen'; |
420 | 420 | } |
421 | 421 | |
422 | - if ( $args['placeholder'] ) { |
|
422 | + if ($args['placeholder']) { |
|
423 | 423 | $placeholder = $args['placeholder']; |
424 | 424 | } else { |
425 | 425 | $placeholder = ''; |
426 | 426 | } |
427 | 427 | |
428 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' ' . $args['select_atts'] . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
428 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' '.$args['select_atts'].' data-placeholder="'.$placeholder.'"'.$data_elements.'>'; |
|
429 | 429 | |
430 | - if ( $args['show_option_all'] ) { |
|
431 | - if ( $args['multiple'] ) { |
|
432 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
430 | + if ($args['show_option_all']) { |
|
431 | + if ($args['multiple']) { |
|
432 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
433 | 433 | } else { |
434 | - $selected = selected( $args['selected'], 0, false ); |
|
434 | + $selected = selected($args['selected'], 0, false); |
|
435 | 435 | } |
436 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
436 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
437 | 437 | } |
438 | 438 | |
439 | - if ( ! empty( $args['options'] ) ) { |
|
439 | + if ( ! empty($args['options'])) { |
|
440 | 440 | |
441 | - if ( $args['show_option_none'] ) { |
|
442 | - if ( $args['multiple'] ) { |
|
443 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
441 | + if ($args['show_option_none']) { |
|
442 | + if ($args['multiple']) { |
|
443 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
444 | 444 | } else { |
445 | - $selected = selected( $args['selected'], - 1, false ); |
|
445 | + $selected = selected($args['selected'], - 1, false); |
|
446 | 446 | } |
447 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
447 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
448 | 448 | } |
449 | 449 | |
450 | - foreach ( $args['options'] as $key => $option ) { |
|
450 | + foreach ($args['options'] as $key => $option) { |
|
451 | 451 | |
452 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
453 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
452 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
453 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
454 | 454 | } else { |
455 | - $selected = selected( $args['selected'], $key, false ); |
|
455 | + $selected = selected($args['selected'], $key, false); |
|
456 | 456 | } |
457 | 457 | |
458 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
458 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return string The checkbox. |
478 | 478 | */ |
479 | - public function checkbox( $args = array() ) { |
|
479 | + public function checkbox($args = array()) { |
|
480 | 480 | $defaults = array( |
481 | 481 | 'name' => null, |
482 | 482 | 'current' => null, |
@@ -487,16 +487,16 @@ discard block |
||
487 | 487 | ), |
488 | 488 | ); |
489 | 489 | |
490 | - $args = wp_parse_args( $args, $defaults ); |
|
490 | + $args = wp_parse_args($args, $defaults); |
|
491 | 491 | |
492 | 492 | $options = ''; |
493 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
493 | + if ( ! empty($args['options']['disabled'])) { |
|
494 | 494 | $options .= ' disabled="disabled"'; |
495 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
495 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
496 | 496 | $options .= ' readonly'; |
497 | 497 | } |
498 | 498 | |
499 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
499 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
500 | 500 | |
501 | 501 | return $output; |
502 | 502 | } |
@@ -513,22 +513,22 @@ discard block |
||
513 | 513 | * |
514 | 514 | * @return string The text field. |
515 | 515 | */ |
516 | - public function text( $args = array() ) { |
|
516 | + public function text($args = array()) { |
|
517 | 517 | // Backwards compatibility. |
518 | - if ( func_num_args() > 1 ) { |
|
518 | + if (func_num_args() > 1) { |
|
519 | 519 | $args = func_get_args(); |
520 | 520 | |
521 | 521 | $name = $args[0]; |
522 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
523 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
524 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
522 | + $value = isset($args[1]) ? $args[1] : ''; |
|
523 | + $label = isset($args[2]) ? $args[2] : ''; |
|
524 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $defaults = array( |
528 | - 'name' => isset( $name ) ? $name : 'text', |
|
529 | - 'value' => isset( $value ) ? $value : null, |
|
530 | - 'label' => isset( $label ) ? $label : null, |
|
531 | - 'desc' => isset( $desc ) ? $desc : null, |
|
528 | + 'name' => isset($name) ? $name : 'text', |
|
529 | + 'value' => isset($value) ? $value : null, |
|
530 | + 'label' => isset($label) ? $label : null, |
|
531 | + 'desc' => isset($desc) ? $desc : null, |
|
532 | 532 | 'placeholder' => '', |
533 | 533 | 'class' => 'regular-text', |
534 | 534 | 'disabled' => false, |
@@ -536,29 +536,29 @@ discard block |
||
536 | 536 | 'data' => false, |
537 | 537 | ); |
538 | 538 | |
539 | - $args = wp_parse_args( $args, $defaults ); |
|
539 | + $args = wp_parse_args($args, $defaults); |
|
540 | 540 | |
541 | 541 | $disabled = ''; |
542 | - if ( $args['disabled'] ) { |
|
542 | + if ($args['disabled']) { |
|
543 | 543 | $disabled = ' disabled="disabled"'; |
544 | 544 | } |
545 | 545 | |
546 | 546 | $data = ''; |
547 | - if ( ! empty( $args['data'] ) ) { |
|
548 | - foreach ( $args['data'] as $key => $value ) { |
|
549 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
547 | + if ( ! empty($args['data'])) { |
|
548 | + foreach ($args['data'] as $key => $value) { |
|
549 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
553 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
554 | 554 | |
555 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
555 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
556 | 556 | |
557 | - if ( ! empty( $args['desc'] ) ) { |
|
558 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
557 | + if ( ! empty($args['desc'])) { |
|
558 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
559 | 559 | } |
560 | 560 | |
561 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
561 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
562 | 562 | |
563 | 563 | $output .= '</span>'; |
564 | 564 | |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @return string The date picker. |
579 | 579 | */ |
580 | - public function date_field( $args = array() ) { |
|
580 | + public function date_field($args = array()) { |
|
581 | 581 | |
582 | - if ( empty( $args['class'] ) ) { |
|
582 | + if (empty($args['class'])) { |
|
583 | 583 | $args['class'] = 'give_datepicker'; |
584 | - } elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) { |
|
584 | + } elseif ( ! strpos($args['class'], 'give_datepicker')) { |
|
585 | 585 | $args['class'] .= ' give_datepicker'; |
586 | 586 | } |
587 | 587 | |
588 | - return $this->text( $args ); |
|
588 | + return $this->text($args); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * |
601 | 601 | * @return string The textarea. |
602 | 602 | */ |
603 | - public function textarea( $args = array() ) { |
|
603 | + public function textarea($args = array()) { |
|
604 | 604 | $defaults = array( |
605 | 605 | 'name' => 'textarea', |
606 | 606 | 'value' => null, |
@@ -610,21 +610,21 @@ discard block |
||
610 | 610 | 'disabled' => false, |
611 | 611 | ); |
612 | 612 | |
613 | - $args = wp_parse_args( $args, $defaults ); |
|
613 | + $args = wp_parse_args($args, $defaults); |
|
614 | 614 | |
615 | 615 | $disabled = ''; |
616 | - if ( $args['disabled'] ) { |
|
616 | + if ($args['disabled']) { |
|
617 | 617 | $disabled = ' disabled="disabled"'; |
618 | 618 | } |
619 | 619 | |
620 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
621 | 621 | |
622 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
622 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
623 | 623 | |
624 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
624 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
625 | 625 | |
626 | - if ( ! empty( $args['desc'] ) ) { |
|
627 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
626 | + if ( ! empty($args['desc'])) { |
|
627 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | $output .= '</span>'; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @return string The text field with ajax search. |
646 | 646 | */ |
647 | - public function ajax_user_search( $args = array() ) { |
|
647 | + public function ajax_user_search($args = array()) { |
|
648 | 648 | |
649 | 649 | $defaults = array( |
650 | 650 | 'name' => 'users', |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | 'chosen' => true, |
656 | 656 | 'number' => 30, |
657 | 657 | 'select_atts' => '', |
658 | - 'placeholder' => __( 'Select a user', 'give' ), |
|
658 | + 'placeholder' => __('Select a user', 'give'), |
|
659 | 659 | 'data' => array( |
660 | 660 | 'search-type' => 'user', |
661 | 661 | ), |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | 666 | // Set initial args. |
667 | 667 | $get_users_args = array( |
@@ -670,31 +670,31 @@ discard block |
||
670 | 670 | |
671 | 671 | // Ensure selected user is not included in initial query. |
672 | 672 | // This is because sites with many users, it's not a guarantee the selected user will be returned. |
673 | - if ( ! empty( $args['selected'] ) ) { |
|
673 | + if ( ! empty($args['selected'])) { |
|
674 | 674 | $get_users_args['exclude'] = $args['selected']; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // Initial users array. |
678 | - $users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args ); |
|
678 | + $users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args); |
|
679 | 679 | |
680 | 680 | // Now add the selected user to the $users array if the arg is present. |
681 | - if ( ! empty( $args['selected'] ) ) { |
|
682 | - $selected_user = apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );; |
|
683 | - $users = array_merge( $users, $selected_user ); |
|
681 | + if ( ! empty($args['selected'])) { |
|
682 | + $selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ; |
|
683 | + $users = array_merge($users, $selected_user); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | $options = array(); |
687 | 687 | |
688 | - if ( $users ) { |
|
688 | + if ($users) { |
|
689 | 689 | $options[0] = $args['placeholder']; |
690 | - foreach ( $users as $user ) { |
|
691 | - $options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' ); |
|
690 | + foreach ($users as $user) { |
|
691 | + $options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')'); |
|
692 | 692 | } |
693 | 693 | } else { |
694 | - $options[0] = __( 'No users found.', 'give' ); |
|
694 | + $options[0] = __('No users found.', 'give'); |
|
695 | 695 | } |
696 | 696 | |
697 | - $output = $this->select( array( |
|
697 | + $output = $this->select(array( |
|
698 | 698 | 'name' => $args['name'], |
699 | 699 | 'selected' => $args['selected'], |
700 | 700 | 'id' => $args['id'], |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | 'show_option_all' => false, |
708 | 708 | 'show_option_none' => false, |
709 | 709 | 'data' => $args['data'], |
710 | - ) ); |
|
710 | + )); |
|
711 | 711 | |
712 | 712 | return $output; |
713 | 713 |
@@ -10,7 +10,7 @@ discard block |
||
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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | 70 | 'labels' => array( |
71 | - 'name' => esc_html__( 'Logs', 'give' ), |
|
71 | + 'name' => esc_html__('Logs', 'give'), |
|
72 | 72 | ), |
73 | 73 | 'public' => false, |
74 | 74 | 'exclude_from_search' => true, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | 'query_var' => false, |
78 | 78 | 'rewrite' => false, |
79 | 79 | 'capability_type' => 'post', |
80 | - 'supports' => array( 'title', 'editor' ), |
|
80 | + 'supports' => array('title', 'editor'), |
|
81 | 81 | 'can_export' => true, |
82 | 82 | ); |
83 | 83 | |
84 | - register_post_type( 'give_log', $log_args ); |
|
84 | + register_post_type('give_log', $log_args); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function register_taxonomy() { |
98 | - register_taxonomy( 'give_log_type', 'give_log', array( |
|
98 | + register_taxonomy('give_log_type', 'give_log', array( |
|
99 | 99 | 'public' => false, |
100 | - ) ); |
|
100 | + )); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'api_request', |
118 | 118 | ); |
119 | 119 | |
120 | - return apply_filters( 'give_log_types', $terms ); |
|
120 | + return apply_filters('give_log_types', $terms); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool Whether log type is valid. |
134 | 134 | */ |
135 | - public function valid_type( $type ) { |
|
136 | - return in_array( $type, $this->log_types() ); |
|
135 | + public function valid_type($type) { |
|
136 | + return in_array($type, $this->log_types()); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return int Log ID. |
154 | 154 | */ |
155 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
155 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
156 | 156 | $log_data = array( |
157 | 157 | 'post_title' => $title, |
158 | 158 | 'post_content' => $message, |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'log_type' => $type, |
161 | 161 | ); |
162 | 162 | |
163 | - return $this->insert_log( $log_data ); |
|
163 | + return $this->insert_log($log_data); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return array An array of the connected logs. |
179 | 179 | */ |
180 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
181 | - return $this->get_connected_logs( array( |
|
180 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
181 | + return $this->get_connected_logs(array( |
|
182 | 182 | 'post_parent' => $object_id, |
183 | 183 | 'paged' => $paged, |
184 | 184 | 'log_type' => $type, |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return int The ID of the newly created log item. |
198 | 198 | */ |
199 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
199 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
200 | 200 | $defaults = array( |
201 | 201 | 'post_type' => 'give_log', |
202 | 202 | 'post_status' => 'publish', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'log_type' => false, |
206 | 206 | ); |
207 | 207 | |
208 | - $args = wp_parse_args( $log_data, $defaults ); |
|
208 | + $args = wp_parse_args($log_data, $defaults); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * Fires before inserting log entry. |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | * @param array $log_data Log entry data. |
216 | 216 | * @param array $log_meta Log entry meta. |
217 | 217 | */ |
218 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
218 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
219 | 219 | |
220 | 220 | // Store the log entry |
221 | - $log_id = wp_insert_post( $args ); |
|
221 | + $log_id = wp_insert_post($args); |
|
222 | 222 | |
223 | 223 | // Set the log type, if any |
224 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
225 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
224 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
225 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Set log meta, if any |
229 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
230 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
231 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
229 | + if ($log_id && ! empty($log_meta)) { |
|
230 | + foreach ((array) $log_meta as $key => $meta) { |
|
231 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param array $log_data Log entry data. |
242 | 242 | * @param array $log_meta Log entry meta. |
243 | 243 | */ |
244 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
244 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
245 | 245 | |
246 | 246 | return $log_id; |
247 | 247 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return bool|null True if successful, false otherwise. |
259 | 259 | */ |
260 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
260 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Fires before updating log entry. |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param array $log_data Log entry data. |
268 | 268 | * @param array $log_meta Log entry meta. |
269 | 269 | */ |
270 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
270 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
271 | 271 | |
272 | 272 | $defaults = array( |
273 | 273 | 'post_type' => 'give_log', |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | 'post_parent' => 0, |
276 | 276 | ); |
277 | 277 | |
278 | - $args = wp_parse_args( $log_data, $defaults ); |
|
278 | + $args = wp_parse_args($log_data, $defaults); |
|
279 | 279 | |
280 | 280 | // Store the log entry |
281 | - $log_id = wp_update_post( $args ); |
|
281 | + $log_id = wp_update_post($args); |
|
282 | 282 | |
283 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
284 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
285 | - if ( ! empty( $meta ) ) { |
|
286 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
283 | + if ($log_id && ! empty($log_meta)) { |
|
284 | + foreach ((array) $log_meta as $key => $meta) { |
|
285 | + if ( ! empty($meta)) { |
|
286 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param array $log_data Log entry data. |
298 | 298 | * @param array $log_meta Log entry meta. |
299 | 299 | */ |
300 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
300 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return array|false Array if logs were found, false otherwise. |
314 | 314 | */ |
315 | - public function get_connected_logs( $args = array() ) { |
|
315 | + public function get_connected_logs($args = array()) { |
|
316 | 316 | |
317 | 317 | $defaults = array( |
318 | 318 | 'post_type' => 'give_log', |
319 | 319 | 'posts_per_page' => 20, |
320 | 320 | 'post_status' => 'publish', |
321 | - 'paged' => get_query_var( 'paged' ), |
|
321 | + 'paged' => get_query_var('paged'), |
|
322 | 322 | 'log_type' => false, |
323 | 323 | 'date_query' => null |
324 | 324 | ); |
325 | 325 | |
326 | - $query_args = wp_parse_args( $args, $defaults ); |
|
326 | + $query_args = wp_parse_args($args, $defaults); |
|
327 | 327 | |
328 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
328 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
329 | 329 | $query_args['tax_query'] = array( |
330 | 330 | array( |
331 | 331 | 'taxonomy' => 'give_log_type', |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | // Retrieve logs based on specific timeframe |
339 | - if ( !empty ( $query_args['date_query'] ) && is_array( $query_args['date_query'] ) ) { |
|
340 | - if ( ! empty( $query_args['date_query']['start_date'] ) ) { |
|
341 | - $query_args['date_query']['after'] = array( |
|
342 | - 'year' => date( 'Y', strtotime( $query_args['date_query']['start_date'] ) ), |
|
343 | - 'month' => date( 'm', strtotime( $query_args['date_query']['start_date'] ) ), |
|
344 | - 'day' => date( 'd', strtotime( $query_args['date_query']['start_date'] ) ) |
|
339 | + if ( ! empty ($query_args['date_query']) && is_array($query_args['date_query'])) { |
|
340 | + if ( ! empty($query_args['date_query']['start_date'])) { |
|
341 | + $query_args['date_query']['after'] = array( |
|
342 | + 'year' => date('Y', strtotime($query_args['date_query']['start_date'])), |
|
343 | + 'month' => date('m', strtotime($query_args['date_query']['start_date'])), |
|
344 | + 'day' => date('d', strtotime($query_args['date_query']['start_date'])) |
|
345 | 345 | ); |
346 | 346 | } |
347 | 347 | |
348 | - if ( ! empty( $query_args['date_query']['end_date'] ) ) { |
|
349 | - $query_args['date_query']['before'] = array( |
|
350 | - 'year' => date( 'Y', strtotime( $query_args['date_query']['end_date'] ) ), |
|
351 | - 'month' => date( 'm', strtotime( $query_args['date_query']['end_date'] ) ), |
|
352 | - 'day' => date( 'd', strtotime( $query_args['date_query']['end_date'] ) ) |
|
348 | + if ( ! empty($query_args['date_query']['end_date'])) { |
|
349 | + $query_args['date_query']['before'] = array( |
|
350 | + 'year' => date('Y', strtotime($query_args['date_query']['end_date'])), |
|
351 | + 'month' => date('m', strtotime($query_args['date_query']['end_date'])), |
|
352 | + 'day' => date('d', strtotime($query_args['date_query']['end_date'])) |
|
353 | 353 | ); |
354 | 354 | } |
355 | 355 | $query_args['date_query']['inclusive'] = true; |
356 | 356 | } |
357 | 357 | |
358 | - $logs = get_posts( $query_args ); |
|
358 | + $logs = get_posts($query_args); |
|
359 | 359 | |
360 | - if ( $logs ) { |
|
360 | + if ($logs) { |
|
361 | 361 | return $logs; |
362 | 362 | } |
363 | 363 | |
@@ -380,20 +380,20 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return int Log count. |
382 | 382 | */ |
383 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
383 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
384 | 384 | |
385 | 385 | $query_args = array( |
386 | 386 | 'post_type' => 'give_log', |
387 | - 'posts_per_page' => - 1, |
|
387 | + 'posts_per_page' => -1, |
|
388 | 388 | 'post_status' => 'publish', |
389 | 389 | 'fields' => 'ids', |
390 | 390 | ); |
391 | 391 | |
392 | - if ( $object_id ) { |
|
392 | + if ($object_id) { |
|
393 | 393 | $query_args['post_parent'] = $object_id; |
394 | 394 | } |
395 | 395 | |
396 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
396 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
397 | 397 | $query_args['tax_query'] = array( |
398 | 398 | array( |
399 | 399 | 'taxonomy' => 'give_log_type', |
@@ -403,24 +403,24 @@ discard block |
||
403 | 403 | ); |
404 | 404 | } |
405 | 405 | |
406 | - if ( ! empty( $meta_query ) ) { |
|
406 | + if ( ! empty($meta_query)) { |
|
407 | 407 | $query_args['meta_query'] = $meta_query; |
408 | 408 | } |
409 | 409 | |
410 | - if ( ! empty( $date_query ) ) { |
|
410 | + if ( ! empty($date_query)) { |
|
411 | 411 | $query_args['date_query'] = $date_query; |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Get cache key for current query. |
415 | - $cache_key = Give_Cache::get_key( 'get_log_count', $query_args ); |
|
415 | + $cache_key = Give_Cache::get_key('get_log_count', $query_args); |
|
416 | 416 | |
417 | 417 | // check if cache already exist or not. |
418 | - if ( ! ( $logs_count = Give_Cache::get( $cache_key ) ) ) { |
|
419 | - $logs = new WP_Query( $query_args ); |
|
418 | + if ( ! ($logs_count = Give_Cache::get($cache_key))) { |
|
419 | + $logs = new WP_Query($query_args); |
|
420 | 420 | $logs_count = (int) $logs->post_count; |
421 | 421 | |
422 | 422 | // Cache results. |
423 | - Give_Cache::set( $cache_key, $logs_count ); |
|
423 | + Give_Cache::set($cache_key, $logs_count); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | return $logs_count; |
@@ -440,16 +440,16 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return void |
442 | 442 | */ |
443 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
443 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
444 | 444 | $query_args = array( |
445 | 445 | 'post_parent' => $object_id, |
446 | 446 | 'post_type' => 'give_log', |
447 | - 'posts_per_page' => - 1, |
|
447 | + 'posts_per_page' => -1, |
|
448 | 448 | 'post_status' => 'publish', |
449 | 449 | 'fields' => 'ids', |
450 | 450 | ); |
451 | 451 | |
452 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
452 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
453 | 453 | $query_args['tax_query'] = array( |
454 | 454 | array( |
455 | 455 | 'taxonomy' => 'give_log_type', |
@@ -459,15 +459,15 @@ discard block |
||
459 | 459 | ); |
460 | 460 | } |
461 | 461 | |
462 | - if ( ! empty( $meta_query ) ) { |
|
462 | + if ( ! empty($meta_query)) { |
|
463 | 463 | $query_args['meta_query'] = $meta_query; |
464 | 464 | } |
465 | 465 | |
466 | - $logs = get_posts( $query_args ); |
|
466 | + $logs = get_posts($query_args); |
|
467 | 467 | |
468 | - if ( $logs ) { |
|
469 | - foreach ( $logs as $log ) { |
|
470 | - wp_delete_post( $log, true ); |
|
468 | + if ($logs) { |
|
469 | + foreach ($logs as $log) { |
|
470 | + wp_delete_post($log, true); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @param int $post_id |
482 | 482 | */ |
483 | - public function background_process_delete_cache( $post_id ) { |
|
483 | + public function background_process_delete_cache($post_id) { |
|
484 | 484 | // Delete log cache immediately |
485 | - wp_schedule_single_event( time() - 5, 'give_delete_log_cache' ); |
|
485 | + wp_schedule_single_event(time() - 5, 'give_delete_log_cache'); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | ); |
511 | 511 | |
512 | 512 | // Bailout. |
513 | - if ( empty( $cache_option_names ) ) { |
|
513 | + if (empty($cache_option_names)) { |
|
514 | 514 | return false; |
515 | 515 | } |
516 | 516 | |
517 | - Give_Cache::delete( $cache_option_names ); |
|
517 | + Give_Cache::delete($cache_option_names); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int ID of the new log entry. |
538 | 538 | */ |
539 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
539 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
540 | 540 | /* @var Give_Logging $give_logs */ |
541 | 541 | global $give_logs; |
542 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
542 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
543 | 543 | |
544 | 544 | return $log; |
545 | 545 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return Give |
15 | 15 | */ |
16 | -function give_load_deprecated_properties( $instance ) { |
|
16 | +function give_load_deprecated_properties($instance) { |
|
17 | 17 | |
18 | 18 | // If a property is renamed then it gets placed below. |
19 | 19 | $instance->customers = new Give_DB_Customers(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | -add_action( 'give_init', 'give_load_deprecated_properties', 10, 1 ); |
|
26 | +add_action('give_init', 'give_load_deprecated_properties', 10, 1); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Give_DB_Customers Class (deprecated) |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return mixed |
54 | 54 | */ |
55 | - public function __call( $name, $arguments ) { |
|
55 | + public function __call($name, $arguments) { |
|
56 | 56 | $deprecated_function_arr = array( |
57 | 57 | 'get_customer_by', |
58 | 58 | 'give_update_customer_email_on_user_update', |
59 | 59 | 'get_customers', |
60 | 60 | ); |
61 | 61 | |
62 | - if ( in_array( $name, $deprecated_function_arr ) ) { |
|
63 | - switch ( $name ) { |
|
62 | + if (in_array($name, $deprecated_function_arr)) { |
|
63 | + switch ($name) { |
|
64 | 64 | case 'get_customers': |
65 | - $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); |
|
65 | + $args = ! empty($arguments[0]) ? $arguments[0] : array(); |
|
66 | 66 | |
67 | - return $this->get_donors( $args ); |
|
67 | + return $this->get_donors($args); |
|
68 | 68 | case 'get_customer_by': |
69 | - $field = ! empty( $arguments[0] ) ? $arguments[0] : 'id'; |
|
70 | - $donor_id = ! empty( $arguments[1] ) ? $arguments[1] : 0; |
|
69 | + $field = ! empty($arguments[0]) ? $arguments[0] : 'id'; |
|
70 | + $donor_id = ! empty($arguments[1]) ? $arguments[1] : 0; |
|
71 | 71 | |
72 | - return $this->get_donor_by( $field, $donor_id ); |
|
72 | + return $this->get_donor_by($field, $donor_id); |
|
73 | 73 | |
74 | 74 | case 'give_update_customer_email_on_user_update': |
75 | - $user_id = ! empty( $arguments[0] ) ? $arguments[0] : 0; |
|
76 | - $old_user_data = ! empty( $arguments[1] ) ? $arguments[1] : false; |
|
75 | + $user_id = ! empty($arguments[0]) ? $arguments[0] : 0; |
|
76 | + $old_user_data = ! empty($arguments[1]) ? $arguments[1] : false; |
|
77 | 77 | |
78 | - return $this->update_donor_email_on_user_update( $user_id, $old_user_data ); |
|
78 | + return $this->update_donor_email_on_user_update($user_id, $old_user_data); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @param bool $_id_or_email |
97 | 97 | * @param bool $by_user_id |
98 | 98 | */ |
99 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
100 | - parent::__construct( $_id_or_email, $by_user_id ); |
|
99 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
100 | + parent::__construct($_id_or_email, $by_user_id); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return mixed |
113 | 113 | */ |
114 | - public function __call( $name, $arguments ) { |
|
114 | + public function __call($name, $arguments) { |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /* @var WPDB $wpdb */ |
132 | 132 | global $wpdb; |
133 | 133 | |
134 | - $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
134 | + $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
135 | 135 | $this->primary_key = 'meta_id'; |
136 | 136 | $this->version = '1.0'; |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return mixed |
150 | 150 | */ |
151 | - public function __call( $name, $arguments ) { |
|
151 | + public function __call($name, $arguments) { |
|
152 | 152 | |
153 | 153 | } |
154 | 154 |