@@ -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 | function give_add_ons_page() { |
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | - <h1><?php esc_html_e( 'Give Add-ons', 'give' ); ?> |
|
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
28 | + <h1><?php esc_html_e('Give Add-ons', 'give'); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h1> |
32 | 32 | |
33 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
33 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
34 | 34 | <?php echo give_add_ons_get_feed(); ?> |
35 | 35 | </div> |
36 | 36 | <?php |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | function give_add_ons_get_feed() { |
49 | 49 | |
50 | 50 | $addons_debug = false; //set to true to debug |
51 | - $cache = get_transient( 'give_add_ons_feed' ); |
|
51 | + $cache = get_transient('give_add_ons_feed'); |
|
52 | 52 | |
53 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
54 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
53 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
54 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
55 | 55 | |
56 | - if ( ! is_wp_error( $feed ) ) { |
|
57 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
58 | - $cache = wp_remote_retrieve_body( $feed ); |
|
59 | - set_transient( 'give_add_ons_feed', $cache, 3600 ); |
|
56 | + if ( ! is_wp_error($feed)) { |
|
57 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
58 | + $cache = wp_remote_retrieve_body($feed); |
|
59 | + set_transient('give_add_ons_feed', $cache, 3600); |
|
60 | 60 | } |
61 | 61 | } else { |
62 | - $cache = '<div class="error"><p>' . esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>'; |
|
62 | + $cache = '<div class="error"><p>'.esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>'; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 1.3.0 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) or exit; |
|
11 | +defined('ABSPATH') or exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Class Give_Shortcode_Donation_Form_Goal |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct() { |
22 | 22 | |
23 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
24 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
23 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
24 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
25 | 25 | |
26 | - parent::__construct( 'give_goal' ); |
|
26 | + parent::__construct('give_goal'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | $create_form_link = sprintf( |
37 | 37 | /* translators: %s: create new form URL */ |
38 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
39 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
38 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
39 | + admin_url('post-new.php?post_type=give_forms') |
|
40 | 40 | ); |
41 | 41 | |
42 | 42 | return array( |
@@ -46,35 +46,35 @@ discard block |
||
46 | 46 | 'post_type' => 'give_forms', |
47 | 47 | ), |
48 | 48 | 'name' => 'id', |
49 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
50 | - 'placeholder' => esc_attr__( '- Select a Form -', 'give' ), |
|
49 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
50 | + 'placeholder' => esc_attr__('- Select a Form -', 'give'), |
|
51 | 51 | 'required' => array( |
52 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
53 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No donation forms found.', 'give' ), $create_form_link ), |
|
52 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
53 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No donation forms found.', 'give'), $create_form_link), |
|
54 | 54 | ), |
55 | 55 | ), |
56 | 56 | array( |
57 | 57 | 'type' => 'container', |
58 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
58 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
59 | 59 | ), |
60 | 60 | array( |
61 | 61 | 'type' => 'listbox', |
62 | 62 | 'name' => 'show_text', |
63 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
64 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
63 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
64 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
65 | 65 | 'options' => array( |
66 | - 'true' => esc_html__( 'Show', 'give' ), |
|
67 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
66 | + 'true' => esc_html__('Show', 'give'), |
|
67 | + 'false' => esc_html__('Hide', 'give'), |
|
68 | 68 | ), |
69 | 69 | ), |
70 | 70 | array( |
71 | 71 | 'type' => 'listbox', |
72 | 72 | 'name' => 'show_bar', |
73 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
74 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
73 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
74 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
75 | 75 | 'options' => array( |
76 | - 'true' => esc_html__( 'Show', 'give' ), |
|
77 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
76 | + 'true' => esc_html__('Show', 'give'), |
|
77 | + 'false' => esc_html__('Hide', 'give'), |
|
78 | 78 | ), |
79 | 79 | ), |
80 | 80 | ); |
@@ -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 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ) |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give') |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return mixed String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } else if ( is_email( $search ) ) { |
|
217 | + } else if (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | 'meta_query' => $this->get_meta_query() |
294 | 294 | ); |
295 | 295 | |
296 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
296 | + $logs = $give_logs->get_connected_logs($log_query); |
|
297 | 297 | |
298 | - if ( $logs ) { |
|
299 | - foreach ( $logs as $log ) { |
|
298 | + if ($logs) { |
|
299 | + foreach ($logs as $log) { |
|
300 | 300 | |
301 | 301 | $logs_data[] = array( |
302 | 302 | 'ID' => $log->ID, |
303 | - 'ip' => get_post_meta( $log->ID, '_give_log_request_ip', true ), |
|
303 | + 'ip' => get_post_meta($log->ID, '_give_log_request_ip', true), |
|
304 | 304 | 'date' => $log->post_date |
305 | 305 | ); |
306 | 306 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | $columns = $this->get_columns(); |
329 | 329 | $hidden = array(); // No hidden columns |
330 | 330 | $sortable = $this->get_sortable_columns(); |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | $this->items = $this->get_logs(); |
333 | - $total_items = $give_logs->get_log_count( 0, 'api_requests' ); |
|
333 | + $total_items = $give_logs->get_log_count(0, 'api_requests'); |
|
334 | 334 | |
335 | - $this->set_pagination_args( array( |
|
335 | + $this->set_pagination_args(array( |
|
336 | 336 | 'total_items' => $total_items, |
337 | 337 | 'per_page' => $this->per_page, |
338 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
338 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -54,50 +54,50 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | |
57 | - if ( $this->step == 1 ) { |
|
58 | - $this->delete_data( 'give_temp_recount_income' ); |
|
57 | + if ($this->step == 1) { |
|
58 | + $this->delete_data('give_temp_recount_income'); |
|
59 | 59 | } |
60 | 60 | |
61 | - $total = get_option( 'give_temp_recount_income', false ); |
|
61 | + $total = get_option('give_temp_recount_income', false); |
|
62 | 62 | |
63 | - if ( false === $total ) { |
|
63 | + if (false === $total) { |
|
64 | 64 | $total = (float) 0; |
65 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
65 | + $this->store_data('give_temp_recount_income', $total); |
|
66 | 66 | } |
67 | 67 | |
68 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
68 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
69 | 69 | |
70 | - $args = apply_filters( 'give_recount_income_args', array( |
|
70 | + $args = apply_filters('give_recount_income_args', array( |
|
71 | 71 | 'number' => $this->per_step, |
72 | 72 | 'page' => $this->step, |
73 | 73 | 'status' => $accepted_statuses, |
74 | 74 | 'fields' => 'ids' |
75 | - ) ); |
|
75 | + )); |
|
76 | 76 | |
77 | - $payments = give_get_payments( $args ); |
|
77 | + $payments = give_get_payments($args); |
|
78 | 78 | |
79 | - if ( ! empty( $payments ) ) { |
|
79 | + if ( ! empty($payments)) { |
|
80 | 80 | |
81 | - foreach ( $payments as $payment ) { |
|
81 | + foreach ($payments as $payment) { |
|
82 | 82 | |
83 | - $total += give_get_payment_amount( $payment ); |
|
83 | + $total += give_get_payment_amount($payment); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - if ( $total < 0 ) { |
|
87 | + if ($total < 0) { |
|
88 | 88 | $totals = 0; |
89 | 89 | } |
90 | 90 | |
91 | - $total = round( $total, give_currency_decimal_filter() ); |
|
91 | + $total = round($total, give_currency_decimal_filter()); |
|
92 | 92 | |
93 | - $this->store_data( 'give_temp_recount_income', $total ); |
|
93 | + $this->store_data('give_temp_recount_income', $total); |
|
94 | 94 | |
95 | 95 | return true; |
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | - update_option( 'give_income_total', $total ); |
|
100 | - set_transient( 'give_income_total', $total, 86400 ); |
|
99 | + update_option('give_income_total', $total); |
|
100 | + set_transient('give_income_total', $total, 86400); |
|
101 | 101 | |
102 | 102 | return false; |
103 | 103 | |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_percentage_complete() { |
113 | 113 | |
114 | - $total = $this->get_stored_data( 'give_recount_income_total' ); |
|
114 | + $total = $this->get_stored_data('give_recount_income_total'); |
|
115 | 115 | |
116 | - if ( false === $total ) { |
|
117 | - $args = apply_filters( 'give_recount_income_total_args', array() ); |
|
116 | + if (false === $total) { |
|
117 | + $args = apply_filters('give_recount_income_total_args', array()); |
|
118 | 118 | |
119 | - $counts = give_count_payments( $args ); |
|
120 | - $total = absint( $counts->publish ); |
|
121 | - $total = apply_filters( 'give_recount_store_income_total', $total ); |
|
119 | + $counts = give_count_payments($args); |
|
120 | + $total = absint($counts->publish); |
|
121 | + $total = apply_filters('give_recount_store_income_total', $total); |
|
122 | 122 | |
123 | - $this->store_data( 'give_recount_income_total', $total ); |
|
123 | + $this->store_data('give_recount_income_total', $total); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $percentage = 100; |
127 | 127 | |
128 | - if ( $total > 0 ) { |
|
129 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
128 | + if ($total > 0) { |
|
129 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( $percentage > 100 ) { |
|
132 | + if ($percentage > 100) { |
|
133 | 133 | $percentage = 100; |
134 | 134 | } |
135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param array $request The Form Data passed into the batch processing |
145 | 145 | */ |
146 | - public function set_properties( $request ) { |
|
146 | + public function set_properties($request) { |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -154,31 +154,31 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function process_step() { |
156 | 156 | |
157 | - if ( ! $this->can_export() ) { |
|
158 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
157 | + if ( ! $this->can_export()) { |
|
158 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $had_data = $this->get_data(); |
162 | 162 | |
163 | - if ( $had_data ) { |
|
163 | + if ($had_data) { |
|
164 | 164 | $this->done = false; |
165 | 165 | |
166 | 166 | return true; |
167 | 167 | } else { |
168 | - $this->delete_data( 'give_recount_income_total' ); |
|
169 | - $this->delete_data( 'give_temp_recount_income' ); |
|
168 | + $this->delete_data('give_recount_income_total'); |
|
169 | + $this->delete_data('give_temp_recount_income'); |
|
170 | 170 | $this->done = true; |
171 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
171 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
172 | 172 | |
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | 177 | public function headers() { |
178 | - ignore_user_abort( true ); |
|
178 | + ignore_user_abort(true); |
|
179 | 179 | |
180 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
181 | - set_time_limit( 0 ); |
|
180 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
181 | + set_time_limit(0); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return mixed Returns the data from the database |
208 | 208 | */ |
209 | - private function get_stored_data( $key ) { |
|
209 | + private function get_stored_data($key) { |
|
210 | 210 | global $wpdb; |
211 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
211 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
212 | 212 | |
213 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
213 | + return empty($value) ? false : maybe_unserialize($value); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - private function store_data( $key, $value ) { |
|
226 | + private function store_data($key, $value) { |
|
227 | 227 | global $wpdb; |
228 | 228 | |
229 | - $value = maybe_serialize( $value ); |
|
229 | + $value = maybe_serialize($value); |
|
230 | 230 | |
231 | 231 | $data = array( |
232 | 232 | 'option_name' => $key, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | '%s', |
241 | 241 | ); |
242 | 242 | |
243 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
243 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @return void |
254 | 254 | */ |
255 | - private function delete_data( $key ) { |
|
255 | + private function delete_data($key) { |
|
256 | 256 | global $wpdb; |
257 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
257 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
@@ -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,15 +23,15 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array $output Response messages |
25 | 25 | */ |
26 | -function give_edit_customer( $args ) { |
|
26 | +function give_edit_customer($args) { |
|
27 | 27 | |
28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( empty( $args ) ) { |
|
34 | + if (empty($args)) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
40 | 40 | $nonce = $args['_wpnonce']; |
41 | 41 | |
42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
43 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
43 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
44 | 44 | } |
45 | 45 | |
46 | - $customer = new Give_Customer( $customer_id ); |
|
47 | - if ( empty( $customer->id ) ) { |
|
46 | + $customer = new Give_Customer($customer_id); |
|
47 | + if (empty($customer->id)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | 'user_id' => 0 |
55 | 55 | ); |
56 | 56 | |
57 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
57 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
58 | 58 | |
59 | - if ( ! is_email( $customer_info['email'] ) ) { |
|
60 | - give_set_error( 'give-invalid-email', esc_html__( 'Please enter a valid email address.', 'give' ) ); |
|
59 | + if ( ! is_email($customer_info['email'])) { |
|
60 | + give_set_error('give-invalid-email', esc_html__('Please enter a valid email address.', 'give')); |
|
61 | 61 | } |
62 | 62 | |
63 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
63 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a customer |
66 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
66 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user |
71 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
72 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $customer_info['user_id']); |
|
72 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -78,53 +78,53 @@ discard block |
||
78 | 78 | // Record this for later |
79 | 79 | $previous_user_id = $customer->user_id; |
80 | 80 | |
81 | - if ( give_get_errors() ) { |
|
81 | + if (give_get_errors()) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Setup the customer address, if present |
86 | 86 | $address = array(); |
87 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
87 | + if (intval($customer_info['user_id']) > 0) { |
|
88 | 88 | |
89 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
89 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
90 | 90 | |
91 | - if ( false === $current_address ) { |
|
92 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
93 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
94 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
95 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
96 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
97 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
91 | + if (false === $current_address) { |
|
92 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
93 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
94 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
95 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
96 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
97 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
98 | 98 | } else { |
99 | - $current_address = wp_parse_args( $current_address, array( |
|
99 | + $current_address = wp_parse_args($current_address, array( |
|
100 | 100 | 'line1', |
101 | 101 | 'line2', |
102 | 102 | 'city', |
103 | 103 | 'zip', |
104 | 104 | 'state', |
105 | 105 | 'country' |
106 | - ) ); |
|
107 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
110 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
111 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
106 | + )); |
|
107 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
108 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
109 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
110 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
111 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
112 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Sanitize the inputs |
118 | 118 | $customer_data = array(); |
119 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
119 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
120 | 120 | $customer_data['email'] = $customer_info['email']; |
121 | 121 | $customer_data['user_id'] = $customer_info['user_id']; |
122 | 122 | |
123 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
124 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
123 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
124 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
125 | 125 | |
126 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
127 | - $address = array_map( 'sanitize_text_field', $address ); |
|
126 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
127 | + $address = array_map('sanitize_text_field', $address); |
|
128 | 128 | |
129 | 129 | |
130 | 130 | /** |
@@ -136,34 +136,34 @@ discard block |
||
136 | 136 | * @param array $customer_data The customer data. |
137 | 137 | * @param array $address The customer address. |
138 | 138 | */ |
139 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
139 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
140 | 140 | |
141 | 141 | $output = array(); |
142 | 142 | $previous_email = $customer->email; |
143 | 143 | |
144 | - if ( $customer->update( $customer_data ) ) { |
|
144 | + if ($customer->update($customer_data)) { |
|
145 | 145 | |
146 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
147 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
146 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
147 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Update some payment meta if we need to |
151 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
151 | + $payments_array = explode(',', $customer->payment_ids); |
|
152 | 152 | |
153 | - if ( $customer->email != $previous_email ) { |
|
154 | - foreach ( $payments_array as $payment_id ) { |
|
155 | - give_update_payment_meta( $payment_id, 'email', $customer->email ); |
|
153 | + if ($customer->email != $previous_email) { |
|
154 | + foreach ($payments_array as $payment_id) { |
|
155 | + give_update_payment_meta($payment_id, 'email', $customer->email); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - if ( $customer->user_id != $previous_user_id ) { |
|
160 | - foreach ( $payments_array as $payment_id ) { |
|
161 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
159 | + if ($customer->user_id != $previous_user_id) { |
|
160 | + foreach ($payments_array as $payment_id) { |
|
161 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | $output['success'] = true; |
166 | - $customer_data = array_merge( $customer_data, $address ); |
|
166 | + $customer_data = array_merge($customer_data, $address); |
|
167 | 167 | $output['customer_info'] = $customer_data; |
168 | 168 | |
169 | 169 | } else { |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param int $customer_id The ID of the customer. |
181 | 181 | * @param array $customer_data The customer data. |
182 | 182 | */ |
183 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
183 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
184 | 184 | |
185 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
186 | - header( 'Content-Type: application/json' ); |
|
187 | - echo json_encode( $output ); |
|
185 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
186 | + header('Content-Type: application/json'); |
|
187 | + echo json_encode($output); |
|
188 | 188 | wp_die(); |
189 | 189 | } |
190 | 190 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
195 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Save a customer note being added |
@@ -203,36 +203,36 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return int The Note ID that was saved, or 0 if nothing was saved |
205 | 205 | */ |
206 | -function give_customer_save_note( $args ) { |
|
206 | +function give_customer_save_note($args) { |
|
207 | 207 | |
208 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
208 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
209 | 209 | |
210 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
211 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
210 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
211 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
212 | 212 | } |
213 | 213 | |
214 | - if ( empty( $args ) ) { |
|
214 | + if (empty($args)) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
218 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
219 | 219 | $customer_id = (int) $args['customer_id']; |
220 | 220 | $nonce = $args['add_customer_note_nonce']; |
221 | 221 | |
222 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
223 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
222 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
223 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( empty( $customer_note ) ) { |
|
227 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
226 | + if (empty($customer_note)) { |
|
227 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( give_get_errors() ) { |
|
230 | + if (give_get_errors()) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | - $customer = new Give_Customer( $customer_id ); |
|
235 | - $new_note = $customer->add_note( $customer_note ); |
|
234 | + $customer = new Give_Customer($customer_id); |
|
235 | + $new_note = $customer->add_note($customer_note); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Fires before inserting customer note. |
@@ -242,22 +242,22 @@ discard block |
||
242 | 242 | * @param int $customer_id The ID of the customer. |
243 | 243 | * @param string $new_note Note content. |
244 | 244 | */ |
245 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
245 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
246 | 246 | |
247 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
247 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
248 | 248 | |
249 | 249 | ob_start(); |
250 | 250 | ?> |
251 | 251 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
252 | 252 | <span class="note-content-wrap"> |
253 | - <?php echo stripslashes( $new_note ); ?> |
|
253 | + <?php echo stripslashes($new_note); ?> |
|
254 | 254 | </span> |
255 | 255 | </div> |
256 | 256 | <?php |
257 | 257 | $output = ob_get_contents(); |
258 | 258 | ob_end_clean(); |
259 | 259 | |
260 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
260 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
261 | 261 | echo $output; |
262 | 262 | exit; |
263 | 263 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | } |
272 | 272 | |
273 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
273 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Delete a customer |
@@ -281,37 +281,37 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return int Whether it was a successful deletion |
283 | 283 | */ |
284 | -function give_customer_delete( $args ) { |
|
284 | +function give_customer_delete($args) { |
|
285 | 285 | |
286 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
286 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
287 | 287 | |
288 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
289 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
288 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
289 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
290 | 290 | } |
291 | 291 | |
292 | - if ( empty( $args ) ) { |
|
292 | + if (empty($args)) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | $customer_id = (int) $args['customer_id']; |
297 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
298 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
297 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
298 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
299 | 299 | $nonce = $args['_wpnonce']; |
300 | 300 | |
301 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
302 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
301 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
302 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
303 | 303 | } |
304 | 304 | |
305 | - if ( ! $confirm ) { |
|
306 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
305 | + if ( ! $confirm) { |
|
306 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
307 | 307 | } |
308 | 308 | |
309 | - if ( give_get_errors() ) { |
|
310 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
309 | + if (give_get_errors()) { |
|
310 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
311 | 311 | exit; |
312 | 312 | } |
313 | 313 | |
314 | - $customer = new Give_Customer( $customer_id ); |
|
314 | + $customer = new Give_Customer($customer_id); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Fires before deleting customer. |
@@ -322,55 +322,55 @@ discard block |
||
322 | 322 | * @param bool $confirm Delete confirmation. |
323 | 323 | * @param bool $remove_data Records delete confirmation. |
324 | 324 | */ |
325 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
325 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
326 | 326 | |
327 | 327 | $success = false; |
328 | 328 | |
329 | - if ( $customer->id > 0 ) { |
|
329 | + if ($customer->id > 0) { |
|
330 | 330 | |
331 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
332 | - $success = Give()->customers->delete( $customer->id ); |
|
331 | + $payments_array = explode(',', $customer->payment_ids); |
|
332 | + $success = Give()->customers->delete($customer->id); |
|
333 | 333 | |
334 | - if ( $success ) { |
|
334 | + if ($success) { |
|
335 | 335 | |
336 | - if ( $remove_data ) { |
|
336 | + if ($remove_data) { |
|
337 | 337 | |
338 | 338 | // Remove all payments, logs, etc |
339 | - foreach ( $payments_array as $payment_id ) { |
|
340 | - give_delete_purchase( $payment_id ); |
|
339 | + foreach ($payments_array as $payment_id) { |
|
340 | + give_delete_purchase($payment_id); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | } else { |
344 | 344 | |
345 | 345 | // Just set the payments to customer_id of 0 |
346 | - foreach ( $payments_array as $payment_id ) { |
|
347 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
346 | + foreach ($payments_array as $payment_id) { |
|
347 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
352 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
353 | 353 | |
354 | 354 | } else { |
355 | 355 | |
356 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
357 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
356 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
357 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
363 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
364 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
363 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
364 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | - wp_redirect( $redirect ); |
|
368 | + wp_redirect($redirect); |
|
369 | 369 | exit; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
373 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Disconnect a user ID from a donor |
@@ -381,27 +381,27 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return bool If the disconnect was successful |
383 | 383 | */ |
384 | -function give_disconnect_customer_user_id( $args ) { |
|
384 | +function give_disconnect_customer_user_id($args) { |
|
385 | 385 | |
386 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
386 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
387 | 387 | |
388 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
389 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
388 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
389 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
390 | 390 | } |
391 | 391 | |
392 | - if ( empty( $args ) ) { |
|
392 | + if (empty($args)) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $customer_id = (int) $args['customer_id']; |
397 | 397 | $nonce = $args['_wpnonce']; |
398 | 398 | |
399 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
400 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
399 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
400 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
401 | 401 | } |
402 | 402 | |
403 | - $customer = new Give_Customer( $customer_id ); |
|
404 | - if ( empty( $customer->id ) ) { |
|
403 | + $customer = new Give_Customer($customer_id); |
|
404 | + if (empty($customer->id)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * @param int $customer_id The ID of the customer. |
416 | 416 | * @param int $user_id The ID of the user. |
417 | 417 | */ |
418 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
418 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
419 | 419 | |
420 | - $customer_args = array( 'user_id' => 0 ); |
|
420 | + $customer_args = array('user_id' => 0); |
|
421 | 421 | |
422 | - if ( $customer->update( $customer_args ) ) { |
|
422 | + if ($customer->update($customer_args)) { |
|
423 | 423 | global $wpdb; |
424 | 424 | |
425 | - if ( ! empty( $customer->payment_ids ) ) { |
|
426 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
425 | + if ( ! empty($customer->payment_ids)) { |
|
426 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output['success'] = true; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } else { |
432 | 432 | |
433 | 433 | $output['success'] = false; |
434 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
434 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $customer_id The ID of the customer. |
443 | 443 | */ |
444 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
444 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
445 | 445 | |
446 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
447 | - header( 'Content-Type: application/json' ); |
|
448 | - echo json_encode( $output ); |
|
446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($output); |
|
449 | 449 | wp_die(); |
450 | 450 | } |
451 | 451 | |
@@ -453,4 +453,4 @@ discard block |
||
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
456 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 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 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_register_dashboard_widgets() { |
24 | - if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
25 | - wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' ); |
|
24 | + if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
25 | + wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget'); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 ); |
|
29 | +add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Sales Summary Dashboard Widget |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function give_dashboard_sales_widget() { |
40 | 40 | |
41 | - if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) { |
|
41 | + if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | $stats = new Give_Payment_Stats; ?> |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | <div class="give-dashboard-widget"> |
47 | 47 | |
48 | 48 | <div class="give-dashboard-today give-clearfix"> |
49 | - <h3 class="give-dashboard-date-today"><?php echo date( 'F j, Y' ); ?></h3> |
|
49 | + <h3 class="give-dashboard-date-today"><?php echo date('F j, Y'); ?></h3> |
|
50 | 50 | |
51 | 51 | <p class="give-dashboard-happy-day"><?php |
52 | 52 | printf( |
53 | 53 | /* translators: %s: day of the week */ |
54 | - esc_html__( 'Happy %s!', 'give' ), |
|
55 | - date( 'l', current_time( 'timestamp' ) ) |
|
54 | + esc_html__('Happy %s!', 'give'), |
|
55 | + date('l', current_time('timestamp')) |
|
56 | 56 | ); |
57 | 57 | ?></p> |
58 | 58 | |
59 | - <?php $earnings_today = $stats->get_earnings( 0, 'today', false ); ?> |
|
59 | + <?php $earnings_today = $stats->get_earnings(0, 'today', false); ?> |
|
60 | 60 | |
61 | - <p class="give-dashboard-today-earnings"><?php echo give_currency_filter( give_format_amount( $earnings_today ) ); ?></p> |
|
61 | + <p class="give-dashboard-today-earnings"><?php echo give_currency_filter(give_format_amount($earnings_today)); ?></p> |
|
62 | 62 | |
63 | 63 | <p class="give-orders-today"> |
64 | - <?php $donations_today = $stats->get_sales( 0, 'today', false ); ?> |
|
65 | - <?php echo give_format_amount( $donations_today, false ); ?> |
|
66 | - <span><?php echo _x( 'donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give' ); ?></span> |
|
64 | + <?php $donations_today = $stats->get_sales(0, 'today', false); ?> |
|
65 | + <?php echo give_format_amount($donations_today, false); ?> |
|
66 | + <span><?php echo _x('donations today', 'Displays in WP admin dashboard widget after the day\'s total donations', 'give'); ?></span> |
|
67 | 67 | </p> |
68 | 68 | |
69 | 69 | |
@@ -73,34 +73,34 @@ discard block |
||
73 | 73 | <table class="give-table-stats"> |
74 | 74 | <thead style="display: none;"> |
75 | 75 | <tr> |
76 | - <th><?php esc_html_e( 'This Week', 'give' ); ?></th> |
|
77 | - <th><?php esc_html_e( 'This Month', 'give' ); ?></th> |
|
78 | - <th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th> |
|
76 | + <th><?php esc_html_e('This Week', 'give'); ?></th> |
|
77 | + <th><?php esc_html_e('This Month', 'give'); ?></th> |
|
78 | + <th><?php esc_html_e('Past 30 Days', 'give'); ?></th> |
|
79 | 79 | </tr> |
80 | 80 | </thead> |
81 | 81 | <tbody> |
82 | 82 | <tr id="give-table-stats-tr-1"> |
83 | 83 | <td> |
84 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p> |
|
84 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p> |
|
85 | 85 | |
86 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p> |
|
86 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p> |
|
87 | 87 | </td> |
88 | 88 | <td> |
89 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p> |
|
89 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p> |
|
90 | 90 | |
91 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p> |
|
91 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p> |
|
92 | 92 | </td> |
93 | 93 | </tr> |
94 | 94 | <tr id="give-table-stats-tr-2"> |
95 | 95 | <td> |
96 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p> |
|
96 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p> |
|
97 | 97 | |
98 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p> |
|
98 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p> |
|
99 | 99 | </td> |
100 | 100 | <td> |
101 | - <p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p> |
|
101 | + <p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p> |
|
102 | 102 | |
103 | - <p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p> |
|
103 | + <p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p> |
|
104 | 104 | </td> |
105 | 105 | </tr> |
106 | 106 | </tbody> |
@@ -120,25 +120,25 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return array |
122 | 122 | */ |
123 | -function give_dashboard_at_a_glance_widget( $items ) { |
|
124 | - $num_posts = wp_count_posts( 'give_forms' ); |
|
123 | +function give_dashboard_at_a_glance_widget($items) { |
|
124 | + $num_posts = wp_count_posts('give_forms'); |
|
125 | 125 | |
126 | - if ( $num_posts && $num_posts->publish ) { |
|
126 | + if ($num_posts && $num_posts->publish) { |
|
127 | 127 | |
128 | 128 | $text = sprintf( |
129 | 129 | /* translators: 1: number of posts published 2: forms singular label 3: forms plural label */ |
130 | - _n( '%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give' ), |
|
130 | + _n('%1$s Give %2$s', '%1$s Give %3$s', $num_posts->publish, 'give'), |
|
131 | 131 | $num_posts->publish, |
132 | 132 | give_get_forms_label_singular(), |
133 | 133 | give_get_forms_label_plural() |
134 | 134 | ); |
135 | 135 | |
136 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
136 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
137 | 137 | |
138 | - if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
139 | - $text = sprintf( '<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text ); |
|
138 | + if (current_user_can('edit_give_forms', get_current_user_id())) { |
|
139 | + $text = sprintf('<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text); |
|
140 | 140 | } else { |
141 | - $text = sprintf( '<span class="give-forms-count">%1$s</span>', $text ); |
|
141 | + $text = sprintf('<span class="give-forms-count">%1$s</span>', $text); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $items[] = $text; |
@@ -147,4 +147,4 @@ discard block |
||
147 | 147 | return $items; |
148 | 148 | } |
149 | 149 | |
150 | -add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 ); |
|
150 | +add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 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 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return void |
25 | 25 | */ |
26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
26 | +function give_trigger_donation_receipt($payment_id) { |
|
27 | 27 | // Make sure we don't send a purchase receipt while editing a payment |
28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Send email |
33 | - give_email_donation_receipt( $payment_id ); |
|
33 | + give_email_donation_receipt($payment_id); |
|
34 | 34 | } |
35 | 35 | |
36 | -add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 ); |
|
36 | +add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Resend the Email Purchase Receipt. (This can be done from the Payment History page) |
@@ -44,29 +44,29 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return void |
46 | 46 | */ |
47 | -function give_resend_donation_receipt( $data ) { |
|
47 | +function give_resend_donation_receipt($data) { |
|
48 | 48 | |
49 | - $purchase_id = absint( $data['purchase_id'] ); |
|
49 | + $purchase_id = absint($data['purchase_id']); |
|
50 | 50 | |
51 | - if ( empty( $purchase_id ) ) { |
|
51 | + if (empty($purchase_id)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) { |
|
56 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
55 | + if ( ! current_user_can('edit_give_payments', $purchase_id)) { |
|
56 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
57 | 57 | } |
58 | 58 | |
59 | - give_email_donation_receipt( $purchase_id, false ); |
|
59 | + give_email_donation_receipt($purchase_id, false); |
|
60 | 60 | |
61 | - wp_redirect( add_query_arg( array( |
|
61 | + wp_redirect(add_query_arg(array( |
|
62 | 62 | 'give-message' => 'email_sent', |
63 | 63 | 'give-action' => false, |
64 | 64 | 'purchase_id' => false |
65 | - ) ) ); |
|
65 | + ))); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_email_links', 'give_resend_donation_receipt' ); |
|
69 | +add_action('give_email_links', 'give_resend_donation_receipt'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Trigger the sending of a Test Email |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return void |
79 | 79 | */ |
80 | -function give_send_test_email( $data ) { |
|
81 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) { |
|
80 | +function give_send_test_email($data) { |
|
81 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | give_email_test_donation_receipt(); |
87 | 87 | |
88 | 88 | // Remove the test email query arg |
89 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
89 | + wp_redirect(remove_query_arg('give_action')); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'give_send_test_email', 'give_send_test_email' ); |
|
93 | +add_action('give_send_test_email', 'give_send_test_email'); |
@@ -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 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function __construct() { |
99 | 99 | |
100 | 100 | // get it started |
101 | - add_action( 'init', array( $this, 'init' ) ); |
|
101 | + add_action('init', array($this, 'init')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function init() { |
115 | 115 | |
116 | - $is_enabled = give_get_option( 'email_access' ); |
|
116 | + $is_enabled = give_get_option('email_access'); |
|
117 | 117 | |
118 | 118 | //Non-logged in users only |
119 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
119 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | 123 | //Are db columns setup? |
124 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
125 | - if ( empty( $is_setup ) ) { |
|
124 | + $is_setup = give_get_option('email_access_installed'); |
|
125 | + if (empty($is_setup)) { |
|
126 | 126 | $this->create_columns(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Timeouts |
130 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
131 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
130 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
131 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
132 | 132 | |
133 | 133 | // Setup login |
134 | 134 | $this->check_for_token(); |
135 | 135 | |
136 | - if ( $this->token_exists ) { |
|
137 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
138 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
139 | - add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) ); |
|
136 | + if ($this->token_exists) { |
|
137 | + add_filter('give_can_view_receipt', '__return_true'); |
|
138 | + add_filter('give_user_pending_verification', '__return_false'); |
|
139 | + add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args')); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -150,25 +150,25 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public function can_send_email( $customer_id ) { |
|
153 | + public function can_send_email($customer_id) { |
|
154 | 154 | /* @var WPDB $wpdb */ |
155 | 155 | global $wpdb; |
156 | 156 | |
157 | 157 | // Prevent multiple emails within X minutes |
158 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
158 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
159 | 159 | |
160 | 160 | // Does a user row exist? |
161 | 161 | $exists = (int) $wpdb->get_var( |
162 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
162 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
163 | 163 | ); |
164 | 164 | |
165 | - if ( 0 < $exists ) { |
|
165 | + if (0 < $exists) { |
|
166 | 166 | $row_id = (int) $wpdb->get_var( |
167 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
167 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
168 | 168 | ); |
169 | 169 | |
170 | - if ( $row_id < 1 ) { |
|
171 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
170 | + if ($row_id < 1) { |
|
171 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
172 | 172 | |
173 | 173 | return false; |
174 | 174 | } |
@@ -188,34 +188,34 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public function send_email( $customer_id, $email ) { |
|
191 | + public function send_email($customer_id, $email) { |
|
192 | 192 | |
193 | - $verify_key = wp_generate_password( 20, false ); |
|
193 | + $verify_key = wp_generate_password(20, false); |
|
194 | 194 | |
195 | 195 | // Generate a new verify key |
196 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
196 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
197 | 197 | |
198 | 198 | // Get the purchase history URL |
199 | - $page_id = give_get_option( 'history_page' ); |
|
199 | + $page_id = give_get_option('history_page'); |
|
200 | 200 | |
201 | - $access_url = add_query_arg( array( |
|
201 | + $access_url = add_query_arg(array( |
|
202 | 202 | 'give_nl' => $verify_key, |
203 | - ), get_permalink( $page_id ) ); |
|
203 | + ), get_permalink($page_id)); |
|
204 | 204 | |
205 | 205 | //Nice subject and message |
206 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
206 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
207 | 207 | |
208 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
209 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
208 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
209 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
210 | 210 | $message .= "\n\n"; |
211 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
212 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
211 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
212 | + $message .= get_bloginfo('name')."\n"; |
|
213 | 213 | |
214 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
214 | + $message = apply_filters('give_email_access_token_message', $message); |
|
215 | 215 | |
216 | 216 | // Send the email |
217 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
218 | - Give()->emails->send( $email, $subject, $message ); |
|
217 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
218 | + Give()->emails->send($email, $subject, $message); |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
@@ -229,24 +229,24 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function check_for_token() { |
231 | 231 | |
232 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
232 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
233 | 233 | |
234 | 234 | // Check for cookie |
235 | - if ( empty( $token ) ) { |
|
236 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
235 | + if (empty($token)) { |
|
236 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
237 | 237 | } |
238 | 238 | |
239 | - if ( ! empty( $token ) ) { |
|
240 | - if ( ! $this->is_valid_token( $token ) ) { |
|
241 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
239 | + if ( ! empty($token)) { |
|
240 | + if ( ! $this->is_valid_token($token)) { |
|
241 | + if ( ! $this->is_valid_verify_key($token)) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | 246 | $this->token_exists = true; |
247 | 247 | // Set cookie |
248 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
249 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
248 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
249 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -260,18 +260,18 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return bool |
262 | 262 | */ |
263 | - public function is_valid_token( $token ) { |
|
263 | + public function is_valid_token($token) { |
|
264 | 264 | |
265 | 265 | global $wpdb; |
266 | 266 | |
267 | 267 | // Make sure token isn't expired |
268 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
268 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
269 | 269 | |
270 | 270 | $email = $wpdb->get_var( |
271 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
271 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
272 | 272 | ); |
273 | 273 | |
274 | - if ( ! empty( $email ) ) { |
|
274 | + if ( ! empty($email)) { |
|
275 | 275 | $this->token_email = $email; |
276 | 276 | $this->token = $token; |
277 | 277 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | //Set error only if email access form isn't being submitted |
282 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
283 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Your access token has expired. Please request a new one below:', 'give' ) ); |
|
282 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
283 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Your access token has expired. Please request a new one below:', 'give')); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return void |
302 | 302 | */ |
303 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
303 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
304 | 304 | global $wpdb; |
305 | 305 | |
306 | - $now = date( 'Y-m-d H:i:s' ); |
|
306 | + $now = date('Y-m-d H:i:s'); |
|
307 | 307 | |
308 | 308 | // Insert or update? |
309 | 309 | $row_id = (int) $wpdb->get_var( |
310 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
310 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
311 | 311 | ); |
312 | 312 | |
313 | 313 | // Update |
314 | - if ( ! empty( $row_id ) ) { |
|
314 | + if ( ! empty($row_id)) { |
|
315 | 315 | $wpdb->query( |
316 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
316 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
317 | 317 | ); |
318 | 318 | } // Insert |
319 | 319 | else { |
320 | 320 | $wpdb->query( |
321 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
321 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
322 | 322 | ); |
323 | 323 | } |
324 | 324 | } |
@@ -333,21 +333,21 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @return bool |
335 | 335 | */ |
336 | - public function is_valid_verify_key( $token ) { |
|
336 | + public function is_valid_verify_key($token) { |
|
337 | 337 | /* @var WPDB $wpdb */ |
338 | 338 | global $wpdb; |
339 | 339 | |
340 | 340 | // See if the verify_key exists |
341 | 341 | $row = $wpdb->get_row( |
342 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
342 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
343 | 343 | ); |
344 | 344 | |
345 | - $now = date( 'Y-m-d H:i:s' ); |
|
345 | + $now = date('Y-m-d H:i:s'); |
|
346 | 346 | |
347 | 347 | // Set token |
348 | - if ( ! empty( $row ) ) { |
|
348 | + if ( ! empty($row)) { |
|
349 | 349 | $wpdb->query( |
350 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
350 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
351 | 351 | ); |
352 | 352 | |
353 | 353 | $this->token_email = $row->email; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return mixed |
373 | 373 | */ |
374 | - public function users_purchases_args( $args ) { |
|
374 | + public function users_purchases_args($args) { |
|
375 | 375 | $args['user'] = $this->token_email; |
376 | 376 | |
377 | 377 | return $args; |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | global $wpdb; |
393 | 393 | |
394 | 394 | //Create columns in customers table |
395 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
395 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
396 | 396 | |
397 | 397 | //Columns added properly |
398 | - if ( $query ) { |
|
399 | - give_update_option( 'email_access_installed', 1 ); |
|
398 | + if ($query) { |
|
399 | + give_update_option('email_access_installed', 1); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | } |
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string Login form |
28 | 28 | */ |
29 | -function give_login_form( $login_redirect = '', $logout_redirect = '' ) { |
|
30 | - global $give_login_redirect, $give_logout_redirect;; |
|
29 | +function give_login_form($login_redirect = '', $logout_redirect = '') { |
|
30 | + global $give_login_redirect, $give_logout_redirect; ; |
|
31 | 31 | |
32 | - if ( empty( $login_redirect ) ) { |
|
32 | + if (empty($login_redirect)) { |
|
33 | 33 | $login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url()); |
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $logout_redirect ) ) { |
|
37 | - $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() ); |
|
36 | + if (empty($logout_redirect)) { |
|
37 | + $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $logout_redirect = add_query_arg( |
43 | 43 | array( |
44 | 44 | 'give_action' => 'user_logout', |
45 | - 'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ), |
|
46 | - 'give_logout_redirect' => urlencode( $logout_redirect ) |
|
45 | + 'give_logout_nonce' => wp_create_nonce('give-logout-nonce'), |
|
46 | + 'give_logout_redirect' => urlencode($logout_redirect) |
|
47 | 47 | ), |
48 | 48 | home_url('/') |
49 | 49 | ); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | ob_start(); |
55 | 55 | |
56 | - give_get_template_part( 'shortcode', 'login' ); |
|
56 | + give_get_template_part('shortcode', 'login'); |
|
57 | 57 | |
58 | - return apply_filters( 'give_login_form', ob_get_clean() ); |
|
58 | + return apply_filters('give_login_form', ob_get_clean()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string Register form |
71 | 71 | */ |
72 | -function give_register_form( $redirect = '' ) { |
|
72 | +function give_register_form($redirect = '') { |
|
73 | 73 | global $give_options, $give_register_redirect; |
74 | 74 | |
75 | - if ( empty( $redirect ) ) { |
|
75 | + if (empty($redirect)) { |
|
76 | 76 | $redirect = give_get_current_page_url(); |
77 | 77 | } |
78 | 78 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | |
81 | 81 | ob_start(); |
82 | 82 | |
83 | - if ( ! is_user_logged_in() ) { |
|
84 | - give_get_template_part( 'shortcode', 'register' ); |
|
83 | + if ( ! is_user_logged_in()) { |
|
84 | + give_get_template_part('shortcode', 'register'); |
|
85 | 85 | } |
86 | 86 | |
87 | - return apply_filters( 'give_register_form', ob_get_clean() ); |
|
87 | + return apply_filters('give_register_form', ob_get_clean()); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -96,34 +96,34 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return void |
98 | 98 | */ |
99 | -function give_process_login_form( $data ) { |
|
100 | - if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) { |
|
101 | - $user_data = get_user_by( 'login', $data['give_user_login'] ); |
|
102 | - if ( ! $user_data ) { |
|
103 | - $user_data = get_user_by( 'email', $data['give_user_login'] ); |
|
99 | +function give_process_login_form($data) { |
|
100 | + if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) { |
|
101 | + $user_data = get_user_by('login', $data['give_user_login']); |
|
102 | + if ( ! $user_data) { |
|
103 | + $user_data = get_user_by('email', $data['give_user_login']); |
|
104 | 104 | } |
105 | - if ( $user_data ) { |
|
105 | + if ($user_data) { |
|
106 | 106 | $user_ID = $user_data->ID; |
107 | 107 | $user_email = $user_data->user_email; |
108 | - if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_data->ID ) ) { |
|
109 | - give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] ); |
|
108 | + if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_data->ID)) { |
|
109 | + give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']); |
|
110 | 110 | } else { |
111 | - give_set_error( 'password_incorrect', esc_html__( 'The password you entered is incorrect.', 'give' ) ); |
|
111 | + give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give')); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
114 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
115 | 115 | } |
116 | 116 | // Check for errors and redirect if none present |
117 | 117 | $errors = give_get_errors(); |
118 | - if ( ! $errors ) { |
|
119 | - $redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID ); |
|
120 | - wp_redirect( $redirect ); |
|
118 | + if ( ! $errors) { |
|
119 | + $redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID); |
|
120 | + wp_redirect($redirect); |
|
121 | 121 | give_die(); |
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | -add_action( 'give_user_login', 'give_process_login_form' ); |
|
126 | +add_action('give_user_login', 'give_process_login_form'); |
|
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_process_user_logout( $data ) { |
|
139 | - if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) { |
|
138 | +function give_process_user_logout($data) { |
|
139 | + if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) { |
|
140 | 140 | |
141 | 141 | // Prevent occurring of any custom action on wp_logout. |
142 | - remove_all_actions( 'wp_logout' ); |
|
142 | + remove_all_actions('wp_logout'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Fires before processing user logout. |
146 | 146 | * |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - do_action( 'give_before_user_logout' ); |
|
149 | + do_action('give_before_user_logout'); |
|
150 | 150 | |
151 | 151 | // Logout user. |
152 | 152 | wp_logout(); |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @since 1.0 |
158 | 158 | */ |
159 | - do_action( 'give_after_user_logout' ); |
|
159 | + do_action('give_after_user_logout'); |
|
160 | 160 | |
161 | - wp_redirect( $data['give_logout_redirect'] ); |
|
161 | + wp_redirect($data['give_logout_redirect']); |
|
162 | 162 | give_die(); |
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | -add_action( 'give_user_logout', 'give_process_user_logout' ); |
|
166 | +add_action('give_user_logout', 'give_process_user_logout'); |
|
167 | 167 | |
168 | 168 | /** |
169 | 169 | * Log User In |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return void |
178 | 178 | */ |
179 | -function give_log_user_in( $user_id, $user_login, $user_pass ) { |
|
180 | - if ( $user_id < 1 ) { |
|
179 | +function give_log_user_in($user_id, $user_login, $user_pass) { |
|
180 | + if ($user_id < 1) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
184 | - wp_set_auth_cookie( $user_id ); |
|
185 | - wp_set_current_user( $user_id, $user_login ); |
|
184 | + wp_set_auth_cookie($user_id); |
|
185 | + wp_set_current_user($user_id, $user_login); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Fires after the user has successfully logged in. |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param string $user_login Username. |
193 | 193 | * @param WP_User $$user WP_User object of the logged-in user. |
194 | 194 | */ |
195 | - do_action( 'wp_login', $user_login, get_userdata( $user_id ) ); |
|
195 | + do_action('wp_login', $user_login, get_userdata($user_id)); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Fires after give user has successfully logged in. |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param string $user_login Username. |
204 | 204 | * @param string $user_pass User password. |
205 | 205 | */ |
206 | - do_action( 'give_log_user_in', $user_id, $user_login, $user_pass ); |
|
206 | + do_action('give_log_user_in', $user_id, $user_login, $user_pass); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return void |
218 | 218 | */ |
219 | -function give_process_register_form( $data ) { |
|
219 | +function give_process_register_form($data) { |
|
220 | 220 | |
221 | - if ( is_user_logged_in() ) { |
|
221 | + if (is_user_logged_in()) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - if ( empty( $_POST['give_register_submit'] ) ) { |
|
225 | + if (empty($_POST['give_register_submit'])) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -231,38 +231,38 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 1.0 |
233 | 233 | */ |
234 | - do_action( 'give_pre_process_register_form' ); |
|
234 | + do_action('give_pre_process_register_form'); |
|
235 | 235 | |
236 | - if ( empty( $data['give_user_login'] ) ) { |
|
237 | - give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) ); |
|
236 | + if (empty($data['give_user_login'])) { |
|
237 | + give_set_error('empty_username', esc_html__('Invalid username.', 'give')); |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( username_exists( $data['give_user_login'] ) ) { |
|
241 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
240 | + if (username_exists($data['give_user_login'])) { |
|
241 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
242 | 242 | } |
243 | 243 | |
244 | - if ( ! validate_username( $data['give_user_login'] ) ) { |
|
245 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
244 | + if ( ! validate_username($data['give_user_login'])) { |
|
245 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( email_exists( $data['give_user_email'] ) ) { |
|
249 | - give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) ); |
|
248 | + if (email_exists($data['give_user_email'])) { |
|
249 | + give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give')); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) { |
|
253 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
252 | + if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) { |
|
253 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) { |
|
257 | - give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) ); |
|
256 | + if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) { |
|
257 | + give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give')); |
|
258 | 258 | } |
259 | 259 | |
260 | - if ( empty( $_POST['give_user_pass'] ) ) { |
|
261 | - give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) ); |
|
260 | + if (empty($_POST['give_user_pass'])) { |
|
261 | + give_set_error('empty_password', esc_html__('Please enter a password.', 'give')); |
|
262 | 262 | } |
263 | 263 | |
264 | - if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) { |
|
265 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
264 | + if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) { |
|
265 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -270,26 +270,26 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_process_register_form' ); |
|
273 | + do_action('give_process_register_form'); |
|
274 | 274 | |
275 | 275 | // Check for errors and redirect if none present |
276 | 276 | $errors = give_get_errors(); |
277 | 277 | |
278 | - if ( empty( $errors ) ) { |
|
278 | + if (empty($errors)) { |
|
279 | 279 | |
280 | - $redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] ); |
|
280 | + $redirect = apply_filters('give_register_redirect', $data['give_redirect']); |
|
281 | 281 | |
282 | - give_register_and_login_new_user( array( |
|
282 | + give_register_and_login_new_user(array( |
|
283 | 283 | 'user_login' => $data['give_user_login'], |
284 | 284 | 'user_pass' => $data['give_user_pass'], |
285 | 285 | 'user_email' => $data['give_user_email'], |
286 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
287 | - 'role' => get_option( 'default_role' ) |
|
288 | - ) ); |
|
286 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
287 | + 'role' => get_option('default_role') |
|
288 | + )); |
|
289 | 289 | |
290 | - wp_redirect( $redirect ); |
|
290 | + wp_redirect($redirect); |
|
291 | 291 | give_die(); |
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | -add_action( 'give_user_register', 'give_process_register_form' ); |
|
296 | 295 | \ No newline at end of file |
296 | +add_action('give_user_register', 'give_process_register_form'); |
|
297 | 297 | \ No newline at end of file |