@@ -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 | |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_payment_history_page() { |
27 | 27 | |
28 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
28 | + $give_payment = get_post_type_object('give_payment'); |
|
29 | 29 | |
30 | - if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) { |
|
31 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php'; |
|
30 | + if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) { |
|
31 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php'; |
|
32 | 32 | } else { |
33 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php'; |
|
33 | + require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php'; |
|
34 | 34 | $payments_table = new Give_Payment_History_Table(); |
35 | 35 | $payments_table->prepare_items(); |
36 | 36 | ?> |
@@ -44,17 +44,17 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_payments_page_top' ); |
|
47 | + do_action('give_payments_page_top'); |
|
48 | 48 | ?> |
49 | 49 | |
50 | - <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
50 | + <form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
51 | 51 | <input type="hidden" name="post_type" value="give_forms" /> |
52 | 52 | <input type="hidden" name="page" value="give-payment-history" /> |
53 | 53 | <?php $payments_table->views() ?> |
54 | 54 | <?php $payments_table->advanced_filters(); ?> |
55 | 55 | </form> |
56 | 56 | |
57 | - <form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"> |
|
57 | + <form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"> |
|
58 | 58 | <input type="hidden" name="post_type" value="give_forms" /> |
59 | 59 | <input type="hidden" name="page" value="give-payment-history" /> |
60 | 60 | <?php $payments_table->display() ?> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @since 1.7 |
68 | 68 | */ |
69 | - do_action( 'give_payments_page_bottom' ); |
|
69 | + do_action('give_payments_page_bottom'); |
|
70 | 70 | ?> |
71 | 71 | |
72 | 72 | </div> |
@@ -83,29 +83,29 @@ discard block |
||
83 | 83 | * @param $title |
84 | 84 | * @return string |
85 | 85 | */ |
86 | -function give_view_order_details_title( $admin_title, $title ) { |
|
86 | +function give_view_order_details_title($admin_title, $title) { |
|
87 | 87 | |
88 | - if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) { |
|
88 | + if ('give_forms_page_give-payment-history' != get_current_screen()->base) { |
|
89 | 89 | return $admin_title; |
90 | 90 | } |
91 | 91 | |
92 | - if( ! isset( $_GET['give-action'] ) ) { |
|
92 | + if ( ! isset($_GET['give-action'])) { |
|
93 | 93 | return $admin_title; |
94 | 94 | } |
95 | 95 | |
96 | - switch( $_GET['give-action'] ) : |
|
96 | + switch ($_GET['give-action']) : |
|
97 | 97 | |
98 | 98 | case 'view-payment-details' : |
99 | 99 | $title = sprintf( |
100 | 100 | /* translators: %s: admin title */ |
101 | - esc_html__( 'View Donation Details - %s', 'give' ), |
|
101 | + esc_html__('View Donation Details - %s', 'give'), |
|
102 | 102 | $admin_title |
103 | 103 | ); |
104 | 104 | break; |
105 | 105 | case 'edit-payment' : |
106 | 106 | $title = sprintf( |
107 | 107 | /* translators: %s: admin title */ |
108 | - esc_html__( 'Edit Donation - %s', 'give' ), |
|
108 | + esc_html__('Edit Donation - %s', 'give'), |
|
109 | 109 | $admin_title |
110 | 110 | ); |
111 | 111 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | return $title; |
118 | 118 | } |
119 | -add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 ); |
|
119 | +add_filter('admin_title', 'give_view_order_details_title', 10, 2); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen. |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | * @param $context |
129 | 129 | * @return string |
130 | 130 | */ |
131 | -function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) { |
|
131 | +function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) { |
|
132 | 132 | |
133 | - $post = get_post( $post_id ); |
|
133 | + $post = get_post($post_id); |
|
134 | 134 | |
135 | - if( ! $post ) { |
|
135 | + if ( ! $post) { |
|
136 | 136 | return $url; |
137 | 137 | } |
138 | 138 | |
139 | - if( 'give_payment' != $post->post_type ) { |
|
139 | + if ('give_payment' != $post->post_type) { |
|
140 | 140 | return $url; |
141 | 141 | } |
142 | 142 | |
143 | - $url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id ); |
|
143 | + $url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id); |
|
144 | 144 | |
145 | 145 | return $url; |
146 | 146 | } |
147 | -add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 ); |
|
147 | +add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3); |
@@ -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); |
@@ -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 |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | // Set parent defaults. |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
50 | 50 | 'ajax' => false // Does this table support ajax?. |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Column Name. |
64 | 64 | */ |
65 | - public function column_default( $item, $column_name ) { |
|
65 | + public function column_default($item, $column_name) { |
|
66 | 66 | |
67 | - switch ( $column_name ) { |
|
67 | + switch ($column_name) { |
|
68 | 68 | case 'ID' : |
69 | 69 | return $item['ID_label']; |
70 | 70 | case 'payment_id' : |
71 | - return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) ); |
|
71 | + return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id'])); |
|
72 | 72 | case 'gateway' : |
73 | - return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway']; |
|
73 | + return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway']; |
|
74 | 74 | case 'error' : |
75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
76 | 76 | default: |
77 | - return $item[ $column_name ]; |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function column_message( $item ) { ?> |
|
92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
91 | + public function column_message($item) { ?> |
|
92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
94 | 94 | <?php |
95 | 95 | |
96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
97 | 97 | |
98 | - $serialized = strpos( $log_message, '{"' ); |
|
98 | + $serialized = strpos($log_message, '{"'); |
|
99 | 99 | |
100 | 100 | // Check to see if the log message contains serialized information |
101 | - if ( $serialized !== false ) { |
|
102 | - $length = strlen( $log_message ) - $serialized; |
|
103 | - $intro = substr( $log_message, 0, - $length ); |
|
104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
101 | + if ($serialized !== false) { |
|
102 | + $length = strlen($log_message) - $serialized; |
|
103 | + $intro = substr($log_message, 0, - $length); |
|
104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
105 | 105 | |
106 | - echo wpautop( $intro ); |
|
107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
106 | + echo wpautop($intro); |
|
107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
109 | 109 | } else { |
110 | 110 | // No serialized data found |
111 | - echo wpautop( $log_message ); |
|
111 | + echo wpautop($log_message); |
|
112 | 112 | } |
113 | 113 | ?> |
114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function get_columns() { |
126 | 126 | $columns = array( |
127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
130 | - 'payment_id' => esc_html__( 'Donation ID', 'give' ), |
|
131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
128 | + 'error' => esc_html__('Error', 'give'), |
|
129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
130 | + 'payment_id' => esc_html__('Donation ID', 'give'), |
|
131 | + 'date' => esc_html__('Date', 'give'), |
|
132 | + 'message' => esc_html__('Details', 'give') |
|
133 | 133 | ); |
134 | 134 | |
135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return int Current page number |
144 | 144 | */ |
145 | 145 | public function get_paged() { |
146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @since 1.0 |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - public function bulk_actions( $which = '' ) { |
|
156 | + public function bulk_actions($which = '') { |
|
157 | 157 | give_log_views(); |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Prevent the queries from getting cached. |
173 | 173 | // Without this there are occasional memory issues for some installs. |
174 | - wp_suspend_cache_addition( true ); |
|
174 | + wp_suspend_cache_addition(true); |
|
175 | 175 | |
176 | 176 | $logs_data = array(); |
177 | 177 | $paged = $this->get_paged(); |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | 'posts_per_page' => $this->per_page, |
182 | 182 | ); |
183 | 183 | |
184 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
184 | + $logs = $give_logs->get_connected_logs($log_query); |
|
185 | 185 | |
186 | - if ( $logs ) { |
|
187 | - foreach ( $logs as $log ) { |
|
186 | + if ($logs) { |
|
187 | + foreach ($logs as $log) { |
|
188 | 188 | |
189 | 189 | $logs_data[] = array( |
190 | 190 | 'ID' => $log->ID, |
191 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
191 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
192 | 192 | 'payment_id' => $log->post_parent, |
193 | 193 | 'error' => 'error', |
194 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
194 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
195 | 195 | 'date' => $log->post_date |
196 | 196 | ); |
197 | 197 | } |
@@ -213,19 +213,19 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @param string $which |
215 | 215 | */ |
216 | - protected function display_tablenav( $which ) { |
|
217 | - if ( 'top' === $which ) { |
|
218 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
216 | + protected function display_tablenav($which) { |
|
217 | + if ('top' === $which) { |
|
218 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
219 | 219 | } |
220 | 220 | ?> |
221 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
221 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
222 | 222 | |
223 | 223 | <div class="alignleft actions bulkactions"> |
224 | - <?php $this->bulk_actions( $which ); ?> |
|
224 | + <?php $this->bulk_actions($which); ?> |
|
225 | 225 | </div> |
226 | 226 | <?php |
227 | - $this->extra_tablenav( $which ); |
|
228 | - $this->pagination( $which ); |
|
227 | + $this->extra_tablenav($which); |
|
228 | + $this->pagination($which); |
|
229 | 229 | ?> |
230 | 230 | |
231 | 231 | <br class="clear"/> |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | $columns = $this->get_columns(); |
253 | 253 | $hidden = array(); // No hidden columns |
254 | 254 | $sortable = $this->get_sortable_columns(); |
255 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
255 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
256 | 256 | $this->items = $this->get_logs(); |
257 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
257 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
258 | 258 | |
259 | - $this->set_pagination_args( array( |
|
259 | + $this->set_pagination_args(array( |
|
260 | 260 | 'total_items' => $total_items, |
261 | 261 | 'per_page' => $this->per_page, |
262 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
262 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | } |
@@ -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 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return mixed array if errors are present, false if none found |
26 | 26 | */ |
27 | 27 | function give_get_errors() { |
28 | - return Give()->session->get( 'give_errors' ); |
|
28 | + return Give()->session->get('give_errors'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return void |
44 | 44 | */ |
45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
46 | 46 | $errors = give_get_errors(); |
47 | - if ( ! $errors ) { |
|
47 | + if ( ! $errors) { |
|
48 | 48 | $errors = array(); |
49 | 49 | } |
50 | 50 | |
51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
52 | - $errors[ $error_id ] = array( |
|
51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
52 | + $errors[$error_id] = array( |
|
53 | 53 | 'message' => $error_message, |
54 | 54 | 'notice_args' => $notice_args, |
55 | 55 | ); |
56 | 56 | } else { |
57 | 57 | // Backward compatibility v<1.8.11. |
58 | - $errors[ $error_id ] = $error_message; |
|
58 | + $errors[$error_id] = $error_message; |
|
59 | 59 | } |
60 | 60 | |
61 | - Give()->session->set( 'give_errors', $errors ); |
|
61 | + Give()->session->set('give_errors', $errors); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return void |
70 | 70 | */ |
71 | 71 | function give_clear_errors() { |
72 | - Give()->session->set( 'give_errors', null ); |
|
72 | + Give()->session->set('give_errors', null); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return void |
84 | 84 | */ |
85 | -function give_unset_error( $error_id ) { |
|
85 | +function give_unset_error($error_id) { |
|
86 | 86 | $errors = give_get_errors(); |
87 | - if ( $errors ) { |
|
88 | - unset( $errors[ $error_id ] ); |
|
89 | - Give()->session->set( 'give_errors', $errors ); |
|
87 | + if ($errors) { |
|
88 | + unset($errors[$error_id]); |
|
89 | + Give()->session->set('give_errors', $errors); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return string |
98 | 98 | */ |
99 | 99 | function _give_die_handler() { |
100 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
100 | + if (defined('GIVE_UNIT_TESTS')) { |
|
101 | 101 | return '_give_die_handler'; |
102 | 102 | } else { |
103 | 103 | die(); |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return void |
119 | 119 | */ |
120 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
121 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
122 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
123 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
120 | +function give_die($message = '', $title = '', $status = 400) { |
|
121 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
122 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
123 | + wp_die($message, $title, array('response' => $status)); |
|
124 | 124 | } |
@@ -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 | |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @since 1.0 |
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | - add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 ); |
|
57 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
56 | + add_action('admin_notices', array($this, 'render_admin_notices'), 999); |
|
57 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
58 | 58 | |
59 | - add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 ); |
|
60 | - add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) ); |
|
61 | - add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) ); |
|
59 | + add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999); |
|
60 | + add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices')); |
|
61 | + add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - public function register_notice( $notice_args ) { |
|
74 | + public function register_notice($notice_args) { |
|
75 | 75 | // Bailout. |
76 | - if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) { |
|
76 | + if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | |
@@ -100,36 +100,36 @@ discard block |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | // Set extra dismiss links if any. |
103 | - if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) { |
|
103 | + if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) { |
|
104 | 104 | |
105 | - preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link ); |
|
105 | + preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link); |
|
106 | 106 | |
107 | - if ( ! empty( $extra_notice_dismiss_link ) ) { |
|
108 | - $extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 ); |
|
109 | - foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) { |
|
107 | + if ( ! empty($extra_notice_dismiss_link)) { |
|
108 | + $extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3); |
|
109 | + foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) { |
|
110 | 110 | // Create array og key ==> value by parsing query string created after renaming data attributes. |
111 | - $data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array( |
|
111 | + $data_attribute_query_str = str_replace(array('data-', '-', '"'), array( |
|
112 | 112 | '', |
113 | 113 | '_', |
114 | 114 | '', |
115 | - ), implode( '&', $extra_notice_dismiss_link ) ); |
|
115 | + ), implode('&', $extra_notice_dismiss_link)); |
|
116 | 116 | |
117 | - $notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str ); |
|
117 | + $notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | 122 | |
123 | - self::$notices[ $notice_args['id'] ] = $notice_args; |
|
123 | + self::$notices[$notice_args['id']] = $notice_args; |
|
124 | 124 | |
125 | 125 | // Auto set show param if not already set. |
126 | - if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) { |
|
127 | - self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true; |
|
126 | + if ( ! isset(self::$notices[$notice_args['id']]['show'])) { |
|
127 | + self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Auto set time interval for shortly. |
131 | - if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) { |
|
132 | - self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
131 | + if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) { |
|
132 | + self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | return true; |
@@ -143,44 +143,44 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function render_admin_notices() { |
145 | 145 | // Bailout. |
146 | - if ( empty( self::$notices ) ) { |
|
146 | + if (empty(self::$notices)) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $output = ''; |
151 | 151 | |
152 | - foreach ( self::$notices as $notice_id => $notice ) { |
|
152 | + foreach (self::$notices as $notice_id => $notice) { |
|
153 | 153 | // Check flag set to true to show notice. |
154 | - if ( ! $notice['show'] ) { |
|
154 | + if ( ! $notice['show']) { |
|
155 | 155 | continue; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Check if notice dismissible or not. |
159 | - if ( ! self::$has_auto_dismissible_notice ) { |
|
159 | + if ( ! self::$has_auto_dismissible_notice) { |
|
160 | 160 | self::$has_auto_dismissible_notice = $notice['auto_dismissible']; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Check if notice dismissible or not. |
164 | - if ( ! self::$has_dismiss_interval_notice ) { |
|
164 | + if ( ! self::$has_dismiss_interval_notice) { |
|
165 | 165 | self::$has_dismiss_interval_notice = $notice['dismiss_interval']; |
166 | 166 | } |
167 | 167 | |
168 | - $css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] ); |
|
168 | + $css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']); |
|
169 | 169 | |
170 | 170 | $css_class = "give-notice notice is-dismissible {$notice['type']} notice-{$notice['type']}"; |
171 | - $output .= sprintf( |
|
172 | - '<div id="%1$s" class="%2$s" data-auto-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s">' . " \n", |
|
171 | + $output .= sprintf( |
|
172 | + '<div id="%1$s" class="%2$s" data-auto-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s">'." \n", |
|
173 | 173 | $css_id, |
174 | 174 | $css_class, |
175 | 175 | $notice['auto_dismissible'], |
176 | 176 | $notice['dismissible_type'], |
177 | 177 | $notice['dismiss_interval'], |
178 | 178 | $notice['id'], |
179 | - empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ), |
|
179 | + empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"), |
|
180 | 180 | $notice['dismiss_interval_time'] |
181 | 181 | ); |
182 | 182 | |
183 | - $output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" ); |
|
183 | + $output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>"); |
|
184 | 184 | $output .= "</div> \n"; |
185 | 185 | } |
186 | 186 | |
@@ -198,18 +198,18 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @param int $form_id |
200 | 200 | */ |
201 | - public function render_frontend_notices( $form_id = 0 ) { |
|
201 | + public function render_frontend_notices($form_id = 0) { |
|
202 | 202 | $errors = give_get_errors(); |
203 | 203 | |
204 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
204 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
205 | 205 | |
206 | 206 | // Sanity checks first: Ensure that gateway returned errors display on the appropriate form. |
207 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
207 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - if ( $errors ) { |
|
212 | - self::print_frontend_errors( $errors ); |
|
211 | + if ($errors) { |
|
212 | + self::print_frontend_errors($errors); |
|
213 | 213 | |
214 | 214 | give_clear_errors(); |
215 | 215 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @access private |
223 | 223 | */ |
224 | 224 | private function print_js() { |
225 | - if ( self::$has_auto_dismissible_notice ) : |
|
225 | + if (self::$has_auto_dismissible_notice) : |
|
226 | 226 | ?> |
227 | 227 | <script> |
228 | 228 | jQuery(document).ready(function () { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | <?php |
239 | 239 | endif; |
240 | 240 | |
241 | - if ( self::$has_dismiss_interval_notice ) : |
|
241 | + if (self::$has_dismiss_interval_notice) : |
|
242 | 242 | ?> |
243 | 243 | <script> |
244 | 244 | jQuery(document).ready(function () { |
@@ -304,29 +304,29 @@ discard block |
||
304 | 304 | * @access public |
305 | 305 | */ |
306 | 306 | public function dismiss_notices() { |
307 | - $_post = give_clean( $_POST ); |
|
308 | - $notice_id = esc_attr( $_post['notice_id'] ); |
|
307 | + $_post = give_clean($_POST); |
|
308 | + $notice_id = esc_attr($_post['notice_id']); |
|
309 | 309 | |
310 | 310 | // Bailout. |
311 | 311 | if ( |
312 | - empty( $notice_id ) || |
|
313 | - empty( $_post['dismissible_type'] ) || |
|
314 | - empty( $_post['dismiss_interval'] ) || |
|
315 | - ! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' ) |
|
312 | + empty($notice_id) || |
|
313 | + empty($_post['dismissible_type']) || |
|
314 | + empty($_post['dismiss_interval']) || |
|
315 | + ! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce') |
|
316 | 316 | ) { |
317 | 317 | wp_send_json_error(); |
318 | 318 | } |
319 | 319 | |
320 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] ); |
|
321 | - if ( 'user' === $_post['dismissible_type'] ) { |
|
320 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']); |
|
321 | + if ('user' === $_post['dismissible_type']) { |
|
322 | 322 | $current_user = wp_get_current_user(); |
323 | - $notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID ); |
|
323 | + $notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID); |
|
324 | 324 | } |
325 | 325 | |
326 | - $notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null; |
|
326 | + $notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null; |
|
327 | 327 | |
328 | 328 | // Save option to hide notice. |
329 | - Give_Cache::set( $notice_key, true, $notice_dismiss_time, true ); |
|
329 | + Give_Cache::set($notice_key, true, $notice_dismiss_time, true); |
|
330 | 330 | |
331 | 331 | wp_send_json_success(); |
332 | 332 | } |
@@ -344,18 +344,18 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @return string |
346 | 346 | */ |
347 | - public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) { |
|
347 | + public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) { |
|
348 | 348 | $notice_key = "_give_notice_{$notice_id}"; |
349 | 349 | |
350 | - if ( ! empty( $dismiss_interval ) ) { |
|
350 | + if ( ! empty($dismiss_interval)) { |
|
351 | 351 | $notice_key .= "_{$dismiss_interval}"; |
352 | 352 | } |
353 | 353 | |
354 | - if ( $user_id ) { |
|
354 | + if ($user_id) { |
|
355 | 355 | $notice_key .= "_{$user_id}"; |
356 | 356 | } |
357 | 357 | |
358 | - $notice_key = sanitize_key( $notice_key ); |
|
358 | + $notice_key = sanitize_key($notice_key); |
|
359 | 359 | |
360 | 360 | return $notice_key; |
361 | 361 | } |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return string |
370 | 370 | */ |
371 | - public function get_dismiss_link( $notice_args ) { |
|
371 | + public function get_dismiss_link($notice_args) { |
|
372 | 372 | $notice_args = wp_parse_args( |
373 | 373 | $notice_args, |
374 | 374 | array( |
375 | - 'title' => __( 'Click here', 'give' ), |
|
375 | + 'title' => __('Click here', 'give'), |
|
376 | 376 | 'dismissible_type' => '', |
377 | 377 | 'dismiss_interval' => '', |
378 | 378 | 'dismiss_interval_time' => null, |
@@ -399,31 +399,31 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool|null |
401 | 401 | */ |
402 | - public function is_notice_dismissed( $notice ) { |
|
403 | - $notice_key = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] ); |
|
402 | + public function is_notice_dismissed($notice) { |
|
403 | + $notice_key = $this->get_notice_key($notice['id'], $notice['dismiss_interval']); |
|
404 | 404 | $is_notice_dismissed = false; |
405 | 405 | |
406 | - if ( 'user' === $notice['dismissible_type'] ) { |
|
406 | + if ('user' === $notice['dismissible_type']) { |
|
407 | 407 | $current_user = wp_get_current_user(); |
408 | - $notice_key = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID ); |
|
408 | + $notice_key = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID); |
|
409 | 409 | } |
410 | 410 | |
411 | - $notice_data = Give_Cache::get( $notice_key, true ); |
|
411 | + $notice_data = Give_Cache::get($notice_key, true); |
|
412 | 412 | |
413 | 413 | // Find notice dismiss link status if notice has extra dismissible links. |
414 | - if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) { |
|
414 | + if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) { |
|
415 | 415 | |
416 | - foreach ( $notice['extra_links'] as $extra_link ) { |
|
417 | - $new_notice_data = wp_parse_args( $extra_link, $notice ); |
|
418 | - unset( $new_notice_data['extra_links'] ); |
|
416 | + foreach ($notice['extra_links'] as $extra_link) { |
|
417 | + $new_notice_data = wp_parse_args($extra_link, $notice); |
|
418 | + unset($new_notice_data['extra_links']); |
|
419 | 419 | |
420 | - if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) { |
|
420 | + if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) { |
|
421 | 421 | return $is_notice_dismissed; |
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - $is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data ); |
|
426 | + $is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data); |
|
427 | 427 | |
428 | 428 | return $is_notice_dismissed; |
429 | 429 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * |
438 | 438 | * @param $errors |
439 | 439 | */ |
440 | - static function print_frontend_errors( $errors ) { |
|
441 | - if ( ! $errors ) { |
|
440 | + static function print_frontend_errors($errors) { |
|
441 | + if ( ! $errors) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
@@ -448,30 +448,30 @@ discard block |
||
448 | 448 | ); |
449 | 449 | |
450 | 450 | // Note: we will remove give_errors class in future. |
451 | - $classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) ); |
|
451 | + $classes = apply_filters('give_error_class', array('give_notices', 'give_errors')); |
|
452 | 452 | |
453 | - echo sprintf( '<div class="%s">', implode( ' ', $classes ) ); |
|
453 | + echo sprintf('<div class="%s">', implode(' ', $classes)); |
|
454 | 454 | |
455 | 455 | // Loop error codes and display errors. |
456 | - foreach ( $errors as $error_id => $error ) { |
|
456 | + foreach ($errors as $error_id => $error) { |
|
457 | 457 | // Backward compatibility v<1.8.11 |
458 | - if ( is_string( $error ) ) { |
|
458 | + if (is_string($error)) { |
|
459 | 459 | $error = array( |
460 | 460 | 'message' => $error, |
461 | 461 | 'notice_args' => array(), |
462 | 462 | ); |
463 | 463 | } |
464 | 464 | |
465 | - $notice_args = wp_parse_args( $error['notice_args'], $default_notice_args ); |
|
465 | + $notice_args = wp_parse_args($error['notice_args'], $default_notice_args); |
|
466 | 466 | |
467 | 467 | echo sprintf( |
468 | 468 | '<div class="give_error give_notice" id="give_error_%1$s" data-auto-dismissible="%2$d" data-dismiss-interval="%3$d"> |
469 | 469 | <p><strong>%4$s</strong>: %5$s</p> |
470 | 470 | </div>', |
471 | 471 | $error_id, |
472 | - absint( $notice_args['auto_dismissible'] ), |
|
473 | - absint( $notice_args['dismiss_interval'] ), |
|
474 | - esc_html__( 'Error', 'give' ), |
|
472 | + absint($notice_args['auto_dismissible']), |
|
473 | + absint($notice_args['dismiss_interval']), |
|
474 | + esc_html__('Error', 'give'), |
|
475 | 475 | $error['message'] |
476 | 476 | ); |
477 | 477 | } |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) { |
|
497 | - if ( empty( $message ) ) { |
|
496 | + static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) { |
|
497 | + if (empty($message)) { |
|
498 | 498 | return ''; |
499 | 499 | } |
500 | 500 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | 'dismiss_interval' => 5000, |
504 | 504 | ); |
505 | 505 | |
506 | - $notice_args = wp_parse_args( $notice_args, $default_notice_args ); |
|
506 | + $notice_args = wp_parse_args($notice_args, $default_notice_args); |
|
507 | 507 | |
508 | 508 | // Note: we will remove give_errors class in future. |
509 | 509 | $error = sprintf( |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | </p> |
514 | 514 | </div>', |
515 | 515 | $notice_type, |
516 | - absint( $notice_args['auto_dismissible'] ), |
|
517 | - absint( $notice_args['dismiss_interval'] ), |
|
516 | + absint($notice_args['auto_dismissible']), |
|
517 | + absint($notice_args['dismiss_interval']), |
|
518 | 518 | $message |
519 | 519 | ); |
520 | 520 | |
521 | - if ( ! $echo ) { |
|
521 | + if ( ! $echo) { |
|
522 | 522 | return $error; |
523 | 523 | } |
524 | 524 |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * |
144 | 144 | * @access public |
145 | 145 | * @since 1.0 |
146 | - * @return mixed string If search is present, false otherwise |
|
146 | + * @return string|false string If search is present, false otherwise |
|
147 | 147 | */ |
148 | 148 | public function get_search() { |
149 | 149 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -185,8 +185,8 @@ |
||
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | 187 | $value = '<a href="' . |
188 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
189 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
188 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
189 | + ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'amount_spent' : |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | global $status, $page; |
63 | 63 | |
64 | 64 | // Set parent defaults |
65 | - parent::__construct( array( |
|
66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
68 | - 'ajax' => false,// Does this table support ajax? |
|
69 | - ) ); |
|
65 | + parent::__construct(array( |
|
66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
68 | + 'ajax' => false, // Does this table support ajax? |
|
69 | + )); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return false |
85 | 85 | */ |
86 | - public function search_box( $text, $input_id ) { |
|
86 | + public function search_box($text, $input_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function give_search_box( $text, $input_id ) { |
|
102 | - $input_id = $input_id . '-search-input'; |
|
101 | + public function give_search_box($text, $input_id) { |
|
102 | + $input_id = $input_id.'-search-input'; |
|
103 | 103 | |
104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
106 | 106 | } |
107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
107 | + if ( ! empty($_REQUEST['order'])) { |
|
108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | <p class="search-box donor-search" role="search"> |
112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
115 | 115 | </p> |
116 | 116 | <?php |
117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $which |
126 | 126 | */ |
127 | - protected function display_tablenav( $which ) { |
|
127 | + protected function display_tablenav($which) { |
|
128 | 128 | |
129 | - if ( 'top' === $which ) { |
|
130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
129 | + if ('top' === $which) { |
|
130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
131 | 131 | } |
132 | 132 | ?> |
133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
134 | 134 | |
135 | - <?php if ( 'top' === $which ) { ?> |
|
135 | + <?php if ('top' === $which) { ?> |
|
136 | 136 | <h3 class="alignleft reports-earnings-title"> |
137 | - <span><?php esc_html_e( 'Donors Report', 'give' ); ?></span> |
|
137 | + <span><?php esc_html_e('Donors Report', 'give'); ?></span> |
|
138 | 138 | </h3> |
139 | 139 | <?php } ?> |
140 | 140 | |
141 | 141 | <div class="alignright tablenav-right"> |
142 | 142 | <div class="actions bulkactions"> |
143 | 143 | <?php |
144 | - if ( 'top' === $which ) { |
|
145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
144 | + if ('top' === $which) { |
|
145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
146 | 146 | } |
147 | 147 | |
148 | - $this->bulk_actions( $which ); ?> |
|
148 | + $this->bulk_actions($which); ?> |
|
149 | 149 | |
150 | 150 | </div> |
151 | 151 | <?php |
152 | - $this->extra_tablenav( $which ); |
|
153 | - $this->pagination( $which ); |
|
152 | + $this->extra_tablenav($which); |
|
153 | + $this->pagination($which); |
|
154 | 154 | ?> |
155 | 155 | </div> |
156 | 156 | |
@@ -172,33 +172,33 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string Column Name |
174 | 174 | */ |
175 | - public function column_default( $item, $column_name ) { |
|
175 | + public function column_default($item, $column_name) { |
|
176 | 176 | |
177 | - switch ( $column_name ) { |
|
177 | + switch ($column_name) { |
|
178 | 178 | |
179 | 179 | case 'name' : |
180 | - $name = '#' . $item['id'] . ' '; |
|
181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
180 | + $name = '#'.$item['id'].' '; |
|
181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | - $value = '<a href="' . |
|
188 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
189 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
187 | + $value = '<a href="'. |
|
188 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
189 | + ).'">'.esc_html($item['num_donations']).'</a>'; |
|
190 | 190 | break; |
191 | 191 | |
192 | 192 | case 'amount_spent' : |
193 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
193 | + $value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
194 | 194 | break; |
195 | 195 | |
196 | 196 | default: |
197 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
197 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
198 | 198 | break; |
199 | 199 | } |
200 | 200 | |
201 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
201 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function get_columns() { |
212 | 212 | $columns = array( |
213 | - 'name' => __( 'Name', 'give' ), |
|
214 | - 'email' => __( 'Email', 'give' ), |
|
215 | - 'num_donations' => __( 'Donations', 'give' ), |
|
216 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
213 | + 'name' => __('Name', 'give'), |
|
214 | + 'email' => __('Email', 'give'), |
|
215 | + 'num_donations' => __('Donations', 'give'), |
|
216 | + 'amount_spent' => __('Total Donated', 'give'), |
|
217 | 217 | ); |
218 | 218 | |
219 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
219 | + return apply_filters('give_report_donor_columns', $columns); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function get_sortable_columns() { |
231 | 231 | return array( |
232 | - 'id' => array( 'id', true ), |
|
233 | - 'name' => array( 'name', true ), |
|
234 | - 'num_donations' => array( 'purchase_count', false ), |
|
235 | - 'amount_spent' => array( 'purchase_value', false ), |
|
232 | + 'id' => array('id', true), |
|
233 | + 'name' => array('name', true), |
|
234 | + 'num_donations' => array('purchase_count', false), |
|
235 | + 'amount_spent' => array('purchase_value', false), |
|
236 | 236 | ); |
237 | 237 | } |
238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @since 1.0 |
244 | 244 | * @return void |
245 | 245 | */ |
246 | - public function bulk_actions( $which = '' ) { |
|
246 | + public function bulk_actions($which = '') { |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return int Current page number |
256 | 256 | */ |
257 | 257 | public function get_paged() { |
258 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
258 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @return mixed string If search is present, false otherwise |
267 | 267 | */ |
268 | 268 | public function get_search() { |
269 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
269 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -285,15 +285,15 @@ discard block |
||
285 | 285 | |
286 | 286 | // Get donor query. |
287 | 287 | $args = $this->get_donor_query(); |
288 | - $donors = Give()->donors->get_donors( $args ); |
|
288 | + $donors = Give()->donors->get_donors($args); |
|
289 | 289 | |
290 | - if ( $donors ) { |
|
290 | + if ($donors) { |
|
291 | 291 | |
292 | - $this->count = count( $donors ); |
|
292 | + $this->count = count($donors); |
|
293 | 293 | |
294 | - foreach ( $donors as $donor ) { |
|
294 | + foreach ($donors as $donor) { |
|
295 | 295 | |
296 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
296 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
297 | 297 | |
298 | 298 | $data[] = array( |
299 | 299 | 'id' => $donor->id, |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | |
322 | 322 | $_donor_query['number'] = -1; |
323 | 323 | $_donor_query['offset'] = 0; |
324 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
324 | + $donors = Give()->donors->get_donors($_donor_query); |
|
325 | 325 | |
326 | - return count( $donors ); |
|
326 | + return count($donors); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function get_donor_query() { |
337 | 337 | $paged = $this->get_paged(); |
338 | - $offset = $this->per_page * ( $paged - 1 ); |
|
338 | + $offset = $this->per_page * ($paged - 1); |
|
339 | 339 | $search = $this->get_search(); |
340 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
341 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
340 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
341 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
342 | 342 | |
343 | 343 | $args = array( |
344 | 344 | 'number' => $this->per_page, |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | 'orderby' => $orderby, |
348 | 348 | ); |
349 | 349 | |
350 | - if( $search ) { |
|
351 | - if ( is_email( $search ) ) { |
|
350 | + if ($search) { |
|
351 | + if (is_email($search)) { |
|
352 | 352 | $args['email'] = $search; |
353 | - } elseif ( is_numeric( $search ) ) { |
|
353 | + } elseif (is_numeric($search)) { |
|
354 | 354 | $args['id'] = $search; |
355 | 355 | } else { |
356 | 356 | $args['name'] = $search; |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | $hidden = array(); // No hidden columns |
378 | 378 | $sortable = $this->get_sortable_columns(); |
379 | 379 | |
380 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
380 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
381 | 381 | |
382 | 382 | $this->items = $this->reports_data(); |
383 | 383 | |
384 | 384 | $this->total = $this->get_donor_count(); |
385 | 385 | |
386 | - $this->set_pagination_args( array( |
|
386 | + $this->set_pagination_args(array( |
|
387 | 387 | 'total_items' => $this->total, |
388 | 388 | 'per_page' => $this->per_page, |
389 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
390 | - ) ); |
|
389 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
390 | + )); |
|
391 | 391 | } |
392 | 392 | } |
@@ -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; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Gateways_Report' ) ) : |
|
16 | +if ( ! class_exists('Give_Gateways_Report')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Gateways_Report. |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'gateways'; |
46 | - $this->label = esc_html__( 'Donation Methods', 'give' ); |
|
46 | + $this->label = esc_html__('Donation Methods', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
50 | - add_action( 'give_admin_field_report_gateways', array( $this, 'render_report_gateways_field' ), 10, 2 ); |
|
48 | + add_filter('give-reports_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-reports_settings_{$this->id}_page", array($this, 'output')); |
|
50 | + add_action('give_admin_field_report_gateways', array($this, 'render_report_gateways_field'), 10, 2); |
|
51 | 51 | |
52 | 52 | // Do not use main form for this tab. |
53 | - if( give_get_current_setting_tab() === $this->id ) { |
|
54 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
55 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
53 | + if (give_get_current_setting_tab() === $this->id) { |
|
54 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
55 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param array $pages Lst of pages. |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function add_settings_page( $pages ) { |
|
67 | - $pages[ $this->id ] = $this->label; |
|
66 | + public function add_settings_page($pages) { |
|
67 | + $pages[$this->id] = $this->label; |
|
68 | 68 | |
69 | 69 | return $pages; |
70 | 70 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param array $settings |
87 | 87 | */ |
88 | 88 | $settings = apply_filters( |
89 | - 'give_get_settings_' . $this->id, |
|
89 | + 'give_get_settings_'.$this->id, |
|
90 | 90 | array( |
91 | 91 | array( |
92 | 92 | 'id' => 'give_reports_gateways', |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ), |
96 | 96 | array( |
97 | 97 | 'id' => 'gateways', |
98 | - 'name' => esc_html__( 'Gateways', 'give' ), |
|
98 | + 'name' => esc_html__('Gateways', 'give'), |
|
99 | 99 | 'type' => 'report_gateways', |
100 | 100 | ), |
101 | 101 | array( |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function output() { |
120 | 120 | $settings = $this->get_settings(); |
121 | 121 | |
122 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
122 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param $field |
132 | 132 | * @param $option_value |
133 | 133 | */ |
134 | - public function render_report_gateways_field( $field, $option_value ) { |
|
135 | - do_action( 'give_reports_view_gateways'); |
|
134 | + public function render_report_gateways_field($field, $option_value) { |
|
135 | + do_action('give_reports_view_gateways'); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 |
@@ -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 | |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | * @param array $_data |
82 | 82 | * @param array $options |
83 | 83 | */ |
84 | - public function __construct( $_data, $options = array() ) { |
|
84 | + public function __construct($_data, $options = array()) { |
|
85 | 85 | |
86 | - $this->data = $_data; |
|
86 | + $this->data = $_data; |
|
87 | 87 | |
88 | 88 | // Generate unique ID |
89 | - $this->id = md5( rand() ); |
|
89 | + $this->id = md5(rand()); |
|
90 | 90 | |
91 | 91 | // Setup default options; |
92 | - $this->options = apply_filters( 'give_graph_args', array( |
|
92 | + $this->options = apply_filters('give_graph_args', array( |
|
93 | 93 | 'y_mode' => null, |
94 | 94 | 'x_mode' => null, |
95 | 95 | 'y_decimals' => 0, |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | 'lines' => false, |
108 | 108 | 'points' => true, |
109 | 109 | 'dataType' => array() |
110 | - ) ); |
|
110 | + )); |
|
111 | 111 | |
112 | - $this->options = wp_parse_args( $options, $this->options ); |
|
112 | + $this->options = wp_parse_args($options, $this->options); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @since 1.0 |
122 | 122 | */ |
123 | - public function set( $key, $value ) { |
|
124 | - $this->options[ $key ] = $value; |
|
123 | + public function set($key, $value) { |
|
124 | + $this->options[$key] = $value; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @since 1.0 |
133 | 133 | */ |
134 | - public function get( $key ) { |
|
135 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
134 | + public function get($key) { |
|
135 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @since 1.0 |
142 | 142 | */ |
143 | 143 | public function get_data() { |
144 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
144 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function load_scripts() { |
153 | 153 | // Use minified libraries if SCRIPT_DEBUG is turned off |
154 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
154 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
155 | 155 | |
156 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
157 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
156 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
157 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
158 | 158 | |
159 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
160 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
159 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
160 | + wp_enqueue_script('jquery-flot-time'); |
|
161 | 161 | |
162 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
163 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
162 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
163 | + wp_enqueue_script('jquery-flot-resize'); |
|
164 | 164 | |
165 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
166 | - wp_enqueue_script( 'jquery-flot' ); |
|
165 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
166 | + wp_enqueue_script('jquery-flot'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | [ |
191 | 191 | <?php |
192 | 192 | $order = 0; |
193 | - foreach( $this->get_data() as $label => $data ) : |
|
193 | + foreach ($this->get_data() as $label => $data) : |
|
194 | 194 | ?> |
195 | 195 | { |
196 | - label : "<?php echo esc_attr( $label ); ?>", |
|
197 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
198 | - dataType : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>', |
|
196 | + label : "<?php echo esc_attr($label); ?>", |
|
197 | + id : "<?php echo sanitize_key($label); ?>", |
|
198 | + dataType : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>', |
|
199 | 199 | // data format is: [ point on x, value on y ] |
200 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
200 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
201 | 201 | points: { |
202 | 202 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
203 | 203 | }, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | fill : true, |
213 | 213 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
214 | 214 | }, |
215 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
215 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
216 | 216 | yaxis : <?php echo $yaxis_count; ?> |
217 | 217 | <?php endif; ?> |
218 | 218 | |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | grid: { |
227 | 227 | show : true, |
228 | 228 | aboveData : false, |
229 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
230 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
231 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
232 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
229 | + color : "<?php echo $this->options['color']; ?>", |
|
230 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
231 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
232 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
233 | 233 | clickable : false, |
234 | 234 | hoverable : true |
235 | 235 | }, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | mode : "<?php echo $this->options['x_mode']; ?>", |
241 | 241 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
242 | 242 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
243 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
243 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
244 | 244 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
245 | 245 | <?php endif; ?> |
246 | 246 | }, |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | min : 0, |
250 | 250 | mode : "<?php echo $this->options['y_mode']; ?>", |
251 | 251 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
252 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
252 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
253 | 253 | tickDecimals: <?php echo $this->options['y_decimals']; ?> |
254 | 254 | <?php endif; ?> |
255 | 255 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param Give_Graph $this Graph object. |
322 | 322 | */ |
323 | - do_action( 'give_before_graph', $this ); |
|
323 | + do_action('give_before_graph', $this); |
|
324 | 324 | |
325 | 325 | // Build the graph. |
326 | 326 | echo $this->build_graph(); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param Give_Graph $this Graph object. |
334 | 334 | */ |
335 | - do_action( 'give_after_graph', $this ); |
|
335 | + do_action('give_after_graph', $this); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | } |