@@ -89,7 +89,7 @@ |
||
89 | 89 | * Connect and Reconnect Donor with User profile. |
90 | 90 | * @todo $address is unnecessary param because we are store address to user. |
91 | 91 | * |
92 | - * @param object $donor Donor Object. |
|
92 | + * @param Give_Donor $donor Donor Object. |
|
93 | 93 | * @param array $donor_data Donor Post Variables. |
94 | 94 | * @param array $address Address Information. |
95 | 95 | * |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The altered list of views. |
25 | 25 | */ |
26 | -function give_register_default_donor_views( $views ) { |
|
26 | +function give_register_default_donor_views($views) { |
|
27 | 27 | |
28 | 28 | $default_views = array( |
29 | 29 | 'overview' => 'give_donor_view', |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | 'notes' => 'give_donor_notes_view', |
32 | 32 | ); |
33 | 33 | |
34 | - return array_merge( $views, $default_views ); |
|
34 | + return array_merge($views, $default_views); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 ); |
|
38 | +add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register a tab for the single donor view. |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return array The altered list of tabs |
48 | 48 | */ |
49 | -function give_register_default_donor_tabs( $tabs ) { |
|
49 | +function give_register_default_donor_tabs($tabs) { |
|
50 | 50 | |
51 | 51 | $default_tabs = array( |
52 | 52 | 'overview' => array( |
53 | 53 | 'dashicon' => 'dashicons-admin-users', |
54 | - 'title' => __( 'Donor Profile', 'give' ), |
|
54 | + 'title' => __('Donor Profile', 'give'), |
|
55 | 55 | ), |
56 | 56 | 'notes' => array( |
57 | 57 | 'dashicon' => 'dashicons-admin-comments', |
58 | - 'title' => __( 'Donor Notes', 'give' ), |
|
58 | + 'title' => __('Donor Notes', 'give'), |
|
59 | 59 | ), |
60 | 60 | ); |
61 | 61 | |
62 | - return array_merge( $tabs, $default_tabs ); |
|
62 | + return array_merge($tabs, $default_tabs); |
|
63 | 63 | } |
64 | 64 | |
65 | -add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 ); |
|
65 | +add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Register the Delete icon as late as possible so it's at the bottom. |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array The altered list of tabs, with 'delete' at the bottom. |
75 | 75 | */ |
76 | -function give_register_delete_donor_tab( $tabs ) { |
|
76 | +function give_register_delete_donor_tab($tabs) { |
|
77 | 77 | |
78 | 78 | $tabs['delete'] = array( |
79 | 79 | 'dashicon' => 'dashicons-trash', |
80 | - 'title' => __( 'Delete Donor', 'give' ), |
|
80 | + 'title' => __('Delete Donor', 'give'), |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | return $tabs; |
84 | 84 | } |
85 | 85 | |
86 | -add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 ); |
|
86 | +add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Connect and Reconnect Donor with User profile. |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array |
99 | 99 | */ |
100 | -function give_connect_user_donor_profile( $donor, $donor_data, $address ) { |
|
100 | +function give_connect_user_donor_profile($donor, $donor_data, $address) { |
|
101 | 101 | |
102 | 102 | $donor_id = $donor->id; |
103 | 103 | $previous_user_id = $donor->user_id; |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @since 1.0 |
113 | 113 | */ |
114 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
114 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
115 | 115 | |
116 | 116 | $output = array(); |
117 | 117 | |
118 | - if ( $donor->update( $donor_data ) ) { |
|
118 | + if ($donor->update($donor_data)) { |
|
119 | 119 | |
120 | 120 | // Create and Update Donor First Name and Last Name in Meta Fields. |
121 | - $donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] ); |
|
122 | - $donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] ); |
|
121 | + $donor->update_meta('_give_donor_first_name', $donor_data['first_name']); |
|
122 | + $donor->update_meta('_give_donor_last_name', $donor_data['last_name']); |
|
123 | 123 | |
124 | 124 | // Fetch disconnected user id, if exists. |
125 | - $disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true ); |
|
125 | + $disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true); |
|
126 | 126 | |
127 | 127 | // Flag User and Donor Disconnection. |
128 | - delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' ); |
|
128 | + delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected'); |
|
129 | 129 | |
130 | 130 | // Check whether the disconnected user id and the reconnected user id are same or not. |
131 | 131 | // If both are same then delete user id store in donor meta. |
132 | - if( $donor_data['user_id'] === $disconnected_user_id ) { |
|
133 | - delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' ); |
|
134 | - $donor->delete_meta( '_give_disconnected_user_id' ); |
|
132 | + if ($donor_data['user_id'] === $disconnected_user_id) { |
|
133 | + delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id'); |
|
134 | + $donor->delete_meta('_give_disconnected_user_id'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $output['success'] = true; |
138 | - $donor_data = array_merge( $donor_data, $address ); |
|
138 | + $donor_data = array_merge($donor_data, $address); |
|
139 | 139 | $output['customer_info'] = $donor_data; |
140 | 140 | |
141 | 141 | } else { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @since 1.0 |
154 | 154 | */ |
155 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
155 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | return $output; |
@@ -600,7 +600,7 @@ |
||
600 | 600 | * |
601 | 601 | * @param int $form_id |
602 | 602 | * |
603 | - * @return array|string |
|
603 | + * @return string |
|
604 | 604 | */ |
605 | 605 | public function get_preview_email_recipient( $form_id = null ) { |
606 | 606 | $recipients = $this->get_recipient( $form_id ); |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_Email_Notification' ) ) : |
|
19 | +if ( ! class_exists('Give_Email_Notification')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_Email_Notification |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @return Give_Email_Notification |
96 | 96 | */ |
97 | - public static function get_instance( $email_notification_id = '' ) { |
|
97 | + public static function get_instance($email_notification_id = '') { |
|
98 | 98 | $class = ''; |
99 | 99 | |
100 | - if ( ! empty( $email_notification_id ) ) { |
|
100 | + if ( ! empty($email_notification_id)) { |
|
101 | 101 | /* @var Give_Email_Notification $class */ |
102 | - foreach ( self::$singleton as $class ) { |
|
103 | - if ( $email_notification_id === $class->config['id'] ) { |
|
104 | - $class = get_class( $class ); |
|
102 | + foreach (self::$singleton as $class) { |
|
103 | + if ($email_notification_id === $class->config['id']) { |
|
104 | + $class = get_class($class); |
|
105 | 105 | break; |
106 | 106 | } |
107 | 107 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $class = get_called_class(); |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) { |
|
113 | - self::$singleton[ $class ] = new $class(); |
|
112 | + if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) { |
|
113 | + self::$singleton[$class] = new $class(); |
|
114 | 114 | } |
115 | 115 | |
116 | - return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null ); |
|
116 | + return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -124,35 +124,35 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param array $config |
126 | 126 | */ |
127 | - public function load( $config ) { |
|
127 | + public function load($config) { |
|
128 | 128 | // Set notification configuration. |
129 | - $this->config = wp_parse_args( $config, $this->config ); |
|
129 | + $this->config = wp_parse_args($config, $this->config); |
|
130 | 130 | |
131 | 131 | // Set email preview header status. |
132 | 132 | $this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false; |
133 | 133 | |
134 | 134 | // Set email content type |
135 | - $this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array( |
|
135 | + $this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array( |
|
136 | 136 | 'text/html', |
137 | 137 | 'text/plain', |
138 | - ) ) |
|
138 | + )) |
|
139 | 139 | ? Give()->emails->get_content_type() |
140 | 140 | : $this->config['content_type']; |
141 | - $this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] ); |
|
141 | + $this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']); |
|
142 | 142 | |
143 | 143 | // Set email template type. |
144 | - $this->config['email_template'] = empty( $this->config['email_template'] ) |
|
145 | - ? give_get_option( 'email_template' ) |
|
144 | + $this->config['email_template'] = empty($this->config['email_template']) |
|
145 | + ? give_get_option('email_template') |
|
146 | 146 | : $this->config['email_template']; |
147 | 147 | |
148 | 148 | // Set recipient group name. |
149 | - $this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] ) |
|
150 | - ? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' ) |
|
149 | + $this->config['recipient_group_name'] = empty($this->config['recipient_group_name']) |
|
150 | + ? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '') |
|
151 | 151 | : $this->config['recipient_group_name']; |
152 | 152 | |
153 | 153 | // Non notification status editable notice. |
154 | - $this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] ) |
|
155 | - ? __( 'You can not edit notification status from here.', 'give' ) |
|
154 | + $this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable']) |
|
155 | + ? __('You can not edit notification status from here.', 'give') |
|
156 | 156 | : $this->config['notices']['non-notification-status-editable']; |
157 | 157 | |
158 | 158 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param array Give_Email_Notification::config |
164 | 164 | * @param Give_Email_Notification $this |
165 | 165 | */ |
166 | - $this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this ); |
|
166 | + $this->config = apply_filters('give_email_api_notification_config', $this->config, $this); |
|
167 | 167 | |
168 | 168 | // Setup filters. |
169 | 169 | $this->setup_filters(); |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | private function setup_filters() { |
180 | 180 | // Apply filter only for current email notification section. |
181 | - if ( give_get_current_setting_section() === $this->config['id'] ) { |
|
181 | + if (give_get_current_setting_section() === $this->config['id']) { |
|
182 | 182 | // Initialize email context for email notification. |
183 | 183 | $this->config['email_tag_context'] = apply_filters( |
184 | 184 | "give_{$this->config['id']}_email_tag_context", |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Setup setting fields. |
191 | - if( $this->config['show_on_emails_setting_page'] ) { |
|
192 | - add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 ); |
|
191 | + if ($this->config['show_on_emails_setting_page']) { |
|
192 | + add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( $this->config['form_metabox_setting'] && ! empty( $this->config['form_metabox_id'] ) ) { |
|
195 | + if ($this->config['form_metabox_setting'] && ! empty($this->config['form_metabox_id'])) { |
|
196 | 196 | add_filter( |
197 | 197 | $this->config['form_metabox_id'], |
198 | - array( $this, 'add_metabox_setting_field' ), |
|
198 | + array($this, 'add_metabox_setting_field'), |
|
199 | 199 | 10, |
200 | 200 | 2 |
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
204 | - if( $this->config['has_recipient_field'] ) { |
|
204 | + if ($this->config['has_recipient_field']) { |
|
205 | 205 | add_action( |
206 | 206 | "give_save__give_{$this->config['id']}_recipient", |
207 | - array( $this, 'validate_form_recipient_field_value' ), |
|
207 | + array($this, 'validate_form_recipient_field_value'), |
|
208 | 208 | 10, |
209 | 209 | 3 |
210 | 210 | ); |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return array |
255 | 255 | */ |
256 | - public function add_section( $sections ) { |
|
257 | - $sections[ $this->config['id'] ] = $this->config['label']; |
|
256 | + public function add_section($sections) { |
|
257 | + $sections[$this->config['id']] = $this->config['label']; |
|
258 | 258 | |
259 | 259 | return $sections; |
260 | 260 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return bool |
270 | 270 | */ |
271 | - public function hide_section( $hide_section ) { |
|
271 | + public function hide_section($hide_section) { |
|
272 | 272 | $hide_section = true; |
273 | 273 | |
274 | 274 | return $hide_section; |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - public function add_setting_fields( $settings ) { |
|
288 | - if ( $this->config['id'] === give_get_current_setting_section() ) { |
|
287 | + public function add_setting_fields($settings) { |
|
288 | + if ($this->config['id'] === give_get_current_setting_section()) { |
|
289 | 289 | $settings = $this->get_setting_fields(); |
290 | 290 | } |
291 | 291 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return array |
305 | 305 | */ |
306 | - public function get_setting_fields( $form_id = null ) { |
|
307 | - return Give_Email_Setting_Field::get_setting_fields( $this, $form_id ); |
|
306 | + public function get_setting_fields($form_id = null) { |
|
307 | + return Give_Email_Setting_Field::get_setting_fields($this, $form_id); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @return array |
321 | 321 | */ |
322 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
322 | + public function add_metabox_setting_field($settings, $form_id) { |
|
323 | 323 | |
324 | - if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) { |
|
324 | + if (Give_Email_Notification_Util::is_email_notification_active($this)) { |
|
325 | 325 | $settings[] = array( |
326 | 326 | 'id' => $this->config['id'], |
327 | 327 | 'title' => $this->config['label'], |
328 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
328 | + 'fields' => $this->get_setting_fields($form_id), |
|
329 | 329 | ); |
330 | 330 | } |
331 | 331 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return array |
345 | 345 | */ |
346 | - public function get_extra_setting_fields( $form_id = null ) { |
|
346 | + public function get_extra_setting_fields($form_id = null) { |
|
347 | 347 | return array(); |
348 | 348 | } |
349 | 349 | |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return string|array |
362 | 362 | */ |
363 | - public function get_recipient( $form_id = null ) { |
|
364 | - if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) { |
|
363 | + public function get_recipient($form_id = null) { |
|
364 | + if (empty($this->recipient_email) && $this->config['has_recipient_field']) { |
|
365 | 365 | $this->recipient_email = Give_Email_Notification_Util::get_value( |
366 | 366 | $this, |
367 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient', |
|
367 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient', |
|
368 | 368 | $form_id |
369 | 369 | ); |
370 | 370 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @since 1.0 |
376 | 376 | * @deprecated 2.0 |
377 | 377 | */ |
378 | - $this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id ); |
|
378 | + $this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return bool |
407 | 407 | */ |
408 | - public function get_notification_status( $form_id = null ) { |
|
409 | - $notification_status = empty( $form_id ) |
|
410 | - ? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] ) |
|
411 | - : give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' ); |
|
408 | + public function get_notification_status($form_id = null) { |
|
409 | + $notification_status = empty($form_id) |
|
410 | + ? give_get_option("{$this->config['id']}_notification", $this->config['notification_status']) |
|
411 | + : give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global'); |
|
412 | 412 | |
413 | 413 | /** |
414 | 414 | * Filter the notification status. |
@@ -433,11 +433,11 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return string |
435 | 435 | */ |
436 | - function get_email_subject( $form_id = null ) { |
|
436 | + function get_email_subject($form_id = null) { |
|
437 | 437 | $subject = wp_strip_all_tags( |
438 | 438 | Give_Email_Notification_Util::get_value( |
439 | 439 | $this, |
440 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
440 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
441 | 441 | $form_id, |
442 | 442 | $this->config['default_email_subject'] |
443 | 443 | ) |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return string |
468 | 468 | */ |
469 | - public function get_email_message( $form_id = null ) { |
|
469 | + public function get_email_message($form_id = null) { |
|
470 | 470 | $message = Give_Email_Notification_Util::get_value( |
471 | 471 | $this, |
472 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
472 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
473 | 473 | $form_id, |
474 | 474 | $this->config['default_email_message'] |
475 | 475 | ); |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return string |
498 | 498 | */ |
499 | - public function get_email_header( $form_id = null ) { |
|
499 | + public function get_email_header($form_id = null) { |
|
500 | 500 | $header = Give_Email_Notification_Util::get_value( |
501 | 501 | $this, |
502 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_header', |
|
502 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_header', |
|
503 | 503 | $form_id, |
504 | 504 | $this->config['default_email_header'] |
505 | 505 | ); |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public function get_email_content_type( $form_id ) { |
|
530 | + public function get_email_content_type($form_id) { |
|
531 | 531 | $content_type = Give_Email_Notification_Util::get_value( |
532 | 532 | $this, |
533 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type', |
|
533 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type', |
|
534 | 534 | $form_id, |
535 | 535 | $this->config['content_type'] |
536 | 536 | ); |
@@ -558,15 +558,14 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string |
560 | 560 | */ |
561 | - public function get_email_template( $form_id ) { |
|
562 | - $email_template = give_get_meta( $form_id, '_give_email_template', true ); |
|
561 | + public function get_email_template($form_id) { |
|
562 | + $email_template = give_get_meta($form_id, '_give_email_template', true); |
|
563 | 563 | $email_template = Give_Email_Notification_Util::get_value( |
564 | 564 | $this, |
565 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template', |
|
565 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template', |
|
566 | 566 | $form_id, |
567 | - ! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ? |
|
568 | - $email_template : |
|
569 | - $this->config['email_template'] |
|
567 | + ! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ? |
|
568 | + $email_template : $this->config['email_template'] |
|
570 | 569 | ); |
571 | 570 | |
572 | 571 | /** |
@@ -593,34 +592,34 @@ discard block |
||
593 | 592 | * |
594 | 593 | * @return array |
595 | 594 | */ |
596 | - public function get_allowed_email_tags( $formatted = false ) { |
|
595 | + public function get_allowed_email_tags($formatted = false) { |
|
597 | 596 | // Get all email tags. |
598 | 597 | $email_tags = Give()->email_tags->get_tags(); |
599 | 598 | |
600 | 599 | // Skip if all email template tags context setup exit. |
601 | - if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) { |
|
602 | - if ( is_array( $this->config['email_tag_context'] ) ) { |
|
603 | - foreach ( $email_tags as $index => $email_tag ) { |
|
604 | - if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) { |
|
600 | + if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) { |
|
601 | + if (is_array($this->config['email_tag_context'])) { |
|
602 | + foreach ($email_tags as $index => $email_tag) { |
|
603 | + if (in_array($email_tag['context'], $this->config['email_tag_context'])) { |
|
605 | 604 | continue; |
606 | 605 | } |
607 | 606 | |
608 | - unset( $email_tags[ $index ] ); |
|
607 | + unset($email_tags[$index]); |
|
609 | 608 | } |
610 | 609 | } else { |
611 | - foreach ( $email_tags as $index => $email_tag ) { |
|
612 | - if ( $this->config['email_tag_context'] === $email_tag['context'] ) { |
|
610 | + foreach ($email_tags as $index => $email_tag) { |
|
611 | + if ($this->config['email_tag_context'] === $email_tag['context']) { |
|
613 | 612 | continue; |
614 | 613 | } |
615 | 614 | |
616 | - unset( $email_tags[ $index ] ); |
|
615 | + unset($email_tags[$index]); |
|
617 | 616 | } |
618 | 617 | } |
619 | 618 | } |
620 | 619 | |
621 | - if ( count( $email_tags ) && $formatted ) : ob_start() ?> |
|
620 | + if (count($email_tags) && $formatted) : ob_start() ?> |
|
622 | 621 | <ul class="give-email-tags-wrap"> |
623 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
622 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
624 | 623 | <li class="give_<?php echo $email_tag['tag']; ?>_tag"> |
625 | 624 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
626 | 625 | </li> |
@@ -643,8 +642,8 @@ discard block |
||
643 | 642 | * |
644 | 643 | * @return array|string |
645 | 644 | */ |
646 | - public function get_preview_email_recipient( $form_id = null ) { |
|
647 | - $recipients = $this->get_recipient( $form_id ); |
|
645 | + public function get_preview_email_recipient($form_id = null) { |
|
646 | + $recipients = $this->get_recipient($form_id); |
|
648 | 647 | |
649 | 648 | /** |
650 | 649 | * Filter the preview email recipients. |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | * @param string|array $recipients List of recipients. |
655 | 654 | * @param Give_Email_Notification $this |
656 | 655 | */ |
657 | - $recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id ); |
|
656 | + $recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id); |
|
658 | 657 | |
659 | 658 | return $recipients; |
660 | 659 | } |
@@ -669,13 +668,13 @@ discard block |
||
669 | 668 | * |
670 | 669 | * @return array |
671 | 670 | */ |
672 | - public function get_email_attachments( $form_id = null ) { |
|
671 | + public function get_email_attachments($form_id = null) { |
|
673 | 672 | /** |
674 | 673 | * Filter the attachment. |
675 | 674 | * |
676 | 675 | * @since 2.0 |
677 | 676 | */ |
678 | - return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id ); |
|
677 | + return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id); |
|
679 | 678 | } |
680 | 679 | |
681 | 680 | |
@@ -687,40 +686,40 @@ discard block |
||
687 | 686 | */ |
688 | 687 | public function send_preview_email() { |
689 | 688 | // Get form id |
690 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
689 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
691 | 690 | |
692 | 691 | // setup email data. |
693 | 692 | $this->setup_email_data(); |
694 | 693 | |
695 | 694 | $attachments = $this->get_email_attachments(); |
696 | - $message = $this->preview_email_template_tags( $this->get_email_message( $form_id ) ); |
|
697 | - $subject = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) ); |
|
698 | - $content_type = $this->get_email_content_type( $form_id ); |
|
695 | + $message = $this->preview_email_template_tags($this->get_email_message($form_id)); |
|
696 | + $subject = $this->preview_email_template_tags($this->get_email_subject($form_id)); |
|
697 | + $content_type = $this->get_email_content_type($form_id); |
|
699 | 698 | |
700 | 699 | // Setup email content type. |
701 | - Give()->emails->__set( 'content_type', $content_type ); |
|
702 | - Give()->emails->__set( 'html', true ); |
|
700 | + Give()->emails->__set('content_type', $content_type); |
|
701 | + Give()->emails->__set('html', true); |
|
703 | 702 | |
704 | 703 | // Setup email template |
705 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
704 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
706 | 705 | |
707 | 706 | // Set email header. |
708 | - Give()->emails->__set( 'heading', $this->preview_email_template_tags( $this->get_email_header( $form_id ) ) ); |
|
707 | + Give()->emails->__set('heading', $this->preview_email_template_tags($this->get_email_header($form_id))); |
|
709 | 708 | |
710 | 709 | // Format plain content type email. |
711 | - if ( 'text/plain' === $content_type ) { |
|
712 | - Give()->emails->__set( 'html', false ); |
|
713 | - Give()->emails->__set( 'template', 'none' ); |
|
714 | - $message = strip_tags( $message ); |
|
710 | + if ('text/plain' === $content_type) { |
|
711 | + Give()->emails->__set('html', false); |
|
712 | + Give()->emails->__set('template', 'none'); |
|
713 | + $message = strip_tags($message); |
|
715 | 714 | } |
716 | 715 | |
717 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
716 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
718 | 717 | Give()->emails->form_id = $form_id; |
719 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
720 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
718 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
719 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
721 | 720 | } |
722 | 721 | |
723 | - return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments ); |
|
722 | + return Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments); |
|
724 | 723 | } |
725 | 724 | |
726 | 725 | |
@@ -741,7 +740,7 @@ discard block |
||
741 | 740 | * |
742 | 741 | * @return bool |
743 | 742 | */ |
744 | - public function send_email_notification( $email_tag_args = array() ) { |
|
743 | + public function send_email_notification($email_tag_args = array()) { |
|
745 | 744 | // Add email content type email tags. |
746 | 745 | $email_tag_args['email_content_type'] = $this->config['content_type']; |
747 | 746 | |
@@ -750,16 +749,16 @@ discard block |
||
750 | 749 | * |
751 | 750 | * @since 2.0 |
752 | 751 | */ |
753 | - $email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this ); |
|
752 | + $email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this); |
|
754 | 753 | |
755 | 754 | // Get form id. |
756 | - $form_id = ! empty( $email_tag_args['form_id'] ) |
|
757 | - ? absint( $email_tag_args['form_id'] ) |
|
758 | - : ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null ); |
|
755 | + $form_id = ! empty($email_tag_args['form_id']) |
|
756 | + ? absint($email_tag_args['form_id']) |
|
757 | + : ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null); |
|
759 | 758 | |
760 | 759 | |
761 | 760 | // Do not send email if notification is disable. |
762 | - if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) { |
|
761 | + if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) { |
|
763 | 762 | return false; |
764 | 763 | } |
765 | 764 | |
@@ -768,44 +767,44 @@ discard block |
||
768 | 767 | * |
769 | 768 | * @since 2.0 |
770 | 769 | */ |
771 | - do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id ); |
|
770 | + do_action("give_{$this->config['id']}_email_send_before", $this, $form_id); |
|
772 | 771 | |
773 | 772 | $attachments = $this->get_email_attachments(); |
774 | - $message = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args ); |
|
775 | - $subject = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args ); |
|
776 | - $content_type = $this->get_email_content_type( $form_id ); |
|
773 | + $message = give_do_email_tags($this->get_email_message($form_id), $email_tag_args); |
|
774 | + $subject = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args); |
|
775 | + $content_type = $this->get_email_content_type($form_id); |
|
777 | 776 | |
778 | 777 | // Setup email content type. |
779 | - Give()->emails->__set( 'content_type', $content_type ); |
|
780 | - Give()->emails->__set( 'html', true ); |
|
778 | + Give()->emails->__set('content_type', $content_type); |
|
779 | + Give()->emails->__set('html', true); |
|
781 | 780 | |
782 | 781 | // Set email template. |
783 | - Give()->emails->__set( 'template', $this->get_email_template( $form_id ) ); |
|
782 | + Give()->emails->__set('template', $this->get_email_template($form_id)); |
|
784 | 783 | |
785 | 784 | // Set email header. |
786 | - Give()->emails->__set( 'heading', give_do_email_tags( $this->get_email_header( $form_id ), $email_tag_args ) ); |
|
785 | + Give()->emails->__set('heading', give_do_email_tags($this->get_email_header($form_id), $email_tag_args)); |
|
787 | 786 | |
788 | - if ( 'text/plain' === $content_type ) { |
|
789 | - Give()->emails->__set( 'html', false ); |
|
790 | - Give()->emails->__set( 'template', 'none' ); |
|
791 | - $message = strip_tags( $message ); |
|
787 | + if ('text/plain' === $content_type) { |
|
788 | + Give()->emails->__set('html', false); |
|
789 | + Give()->emails->__set('template', 'none'); |
|
790 | + $message = strip_tags($message); |
|
792 | 791 | } |
793 | 792 | |
794 | - if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) { |
|
793 | + if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) { |
|
795 | 794 | Give()->emails->form_id = $form_id; |
796 | - Give()->emails->from_name = give_get_meta( $form_id, '_give_from_name', true ); |
|
797 | - Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true ); |
|
795 | + Give()->emails->from_name = give_get_meta($form_id, '_give_from_name', true); |
|
796 | + Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true); |
|
798 | 797 | } |
799 | 798 | |
800 | 799 | // Send email. |
801 | - $email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments ); |
|
800 | + $email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments); |
|
802 | 801 | |
803 | 802 | /** |
804 | 803 | * Fire action after after email send. |
805 | 804 | * |
806 | 805 | * @since 2.0 |
807 | 806 | */ |
808 | - do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id ); |
|
807 | + do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id); |
|
809 | 808 | |
810 | 809 | return $email_status; |
811 | 810 | } |
@@ -820,67 +819,67 @@ discard block |
||
820 | 819 | * |
821 | 820 | * @return string |
822 | 821 | */ |
823 | - public function preview_email_template_tags( $message ) { |
|
822 | + public function preview_email_template_tags($message) { |
|
824 | 823 | // Set Payment. |
825 | - $payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' ); |
|
826 | - $payment = $payment_id ? new Give_Payment( $payment_id ) : new stdClass(); |
|
824 | + $payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id'); |
|
825 | + $payment = $payment_id ? new Give_Payment($payment_id) : new stdClass(); |
|
827 | 826 | |
828 | 827 | // Set donor. |
829 | 828 | $user_id = $payment_id |
830 | 829 | ? $payment->user_id |
831 | - : give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' ); |
|
830 | + : give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id'); |
|
832 | 831 | $user_id = $user_id ? $user_id : wp_get_current_user()->ID; |
833 | 832 | |
834 | 833 | // Set receipt. |
835 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
834 | + $receipt_id = strtolower(md5(uniqid())); |
|
836 | 835 | |
837 | - $receipt_link_url = esc_url( add_query_arg( array( |
|
836 | + $receipt_link_url = esc_url(add_query_arg(array( |
|
838 | 837 | 'payment_key' => $receipt_id, |
839 | - ), give_get_history_page_uri() ) ); |
|
838 | + ), give_get_history_page_uri())); |
|
840 | 839 | |
841 | 840 | $receipt_link = sprintf( |
842 | 841 | '<a href="%1$s">%2$s</a>', |
843 | 842 | $receipt_link_url, |
844 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
843 | + esc_html__('View the receipt in your browser »', 'give') |
|
845 | 844 | ); |
846 | 845 | |
847 | 846 | // Set default values for tags. |
848 | 847 | $this->config['preview_email_tags_values'] = wp_parse_args( |
849 | 848 | $this->config['preview_email_tags_values'], |
850 | 849 | array( |
851 | - 'name' => give_email_tag_first_name( array( |
|
850 | + 'name' => give_email_tag_first_name(array( |
|
852 | 851 | 'payment_id' => $payment_id, |
853 | 852 | 'user_id' => $user_id, |
854 | - ) ), |
|
855 | - 'fullname' => give_email_tag_fullname( array( |
|
853 | + )), |
|
854 | + 'fullname' => give_email_tag_fullname(array( |
|
856 | 855 | 'payment_id' => $payment_id, |
857 | 856 | 'user_id' => $user_id, |
858 | - ) ), |
|
859 | - 'username' => give_email_tag_username( array( |
|
857 | + )), |
|
858 | + 'username' => give_email_tag_username(array( |
|
860 | 859 | 'payment_id' => $payment_id, |
861 | 860 | 'user_id' => $user_id, |
862 | - ) ), |
|
863 | - 'user_email' => give_email_tag_user_email( array( |
|
861 | + )), |
|
862 | + 'user_email' => give_email_tag_user_email(array( |
|
864 | 863 | 'payment_id' => $payment_id, |
865 | 864 | 'user_id' => $user_id, |
866 | - ) ), |
|
867 | - 'payment_total' => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
868 | - 'amount' => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
869 | - 'price' => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ), |
|
870 | - 'payment_method' => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ), |
|
865 | + )), |
|
866 | + 'payment_total' => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
867 | + 'amount' => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
868 | + 'price' => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'), |
|
869 | + 'payment_method' => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'), |
|
871 | 870 | 'receipt_id' => $receipt_id, |
872 | - 'payment_id' => $payment_id ? $payment_id : rand( 2000, 2050 ), |
|
871 | + 'payment_id' => $payment_id ? $payment_id : rand(2000, 2050), |
|
873 | 872 | 'receipt_link_url' => $receipt_link_url, |
874 | 873 | 'receipt_link' => $receipt_link, |
875 | - 'date' => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ), |
|
876 | - 'donation' => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ), |
|
877 | - 'form_title' => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), |
|
878 | - 'sitename' => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ), |
|
874 | + 'date' => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')), |
|
875 | + 'donation' => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'), |
|
876 | + 'form_title' => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), |
|
877 | + 'sitename' => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'), |
|
879 | 878 | 'pdf_receipt' => sprintf( |
880 | 879 | '<a href="#">%s</a>', |
881 | - __( 'Download Receipt', 'give' ) |
|
880 | + __('Download Receipt', 'give') |
|
882 | 881 | ), |
883 | - 'billing_address' => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '', |
|
882 | + 'billing_address' => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '', |
|
884 | 883 | 'email_access_link' => sprintf( |
885 | 884 | '<a href="%1$s">%2$s</a>', |
886 | 885 | add_query_arg( |
@@ -889,20 +888,20 @@ discard block |
||
889 | 888 | ), |
890 | 889 | give_get_history_page_uri() |
891 | 890 | ), |
892 | - __( 'View your donation history »', 'give' ) |
|
891 | + __('View your donation history »', 'give') |
|
893 | 892 | ), |
894 | - 'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '', |
|
893 | + 'reset_password_link' => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '', |
|
895 | 894 | ) |
896 | 895 | ); |
897 | 896 | |
898 | 897 | // Decode tags. |
899 | - foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) { |
|
900 | - if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) { |
|
901 | - $message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message ); |
|
898 | + foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) { |
|
899 | + if (isset($this->config['preview_email_tags_values'][$preview_tag])) { |
|
900 | + $message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message); |
|
902 | 901 | } |
903 | 902 | } |
904 | 903 | |
905 | - return apply_filters( 'give_email_preview_template_tags', $message ); |
|
904 | + return apply_filters('give_email_preview_template_tags', $message); |
|
906 | 905 | } |
907 | 906 | |
908 | 907 | /** |
@@ -927,17 +926,17 @@ discard block |
||
927 | 926 | * @param $post_id |
928 | 927 | * |
929 | 928 | */ |
930 | - public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) { |
|
929 | + public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) { |
|
931 | 930 | // Get valid emails. |
932 | - $new_form_meta_value = array_filter( $form_meta_value, function ( $value ) { |
|
933 | - return ! empty( $value['email'] ) && is_email( $value['email'] ); |
|
931 | + $new_form_meta_value = array_filter($form_meta_value, function($value) { |
|
932 | + return ! empty($value['email']) && is_email($value['email']); |
|
934 | 933 | } ); |
935 | 934 | |
936 | 935 | // Remove duplicate emails from array. |
937 | 936 | $email_arr = array(); |
938 | - foreach ( $new_form_meta_value as $index => $email ) { |
|
939 | - if( in_array( $email['email'], $email_arr ) ) { |
|
940 | - unset( $new_form_meta_value[$index] ); |
|
937 | + foreach ($new_form_meta_value as $index => $email) { |
|
938 | + if (in_array($email['email'], $email_arr)) { |
|
939 | + unset($new_form_meta_value[$index]); |
|
941 | 940 | continue; |
942 | 941 | } |
943 | 942 | |
@@ -946,25 +945,25 @@ discard block |
||
946 | 945 | |
947 | 946 | $update = false; |
948 | 947 | |
949 | - if ( empty( $new_form_meta_value ) ) { |
|
948 | + if (empty($new_form_meta_value)) { |
|
950 | 949 | // Set default recipient. |
951 | 950 | $form_meta_value = array( |
952 | 951 | array( |
953 | - 'email' => get_bloginfo( 'admin_email' ) |
|
952 | + 'email' => get_bloginfo('admin_email') |
|
954 | 953 | ), |
955 | 954 | ); |
956 | 955 | |
957 | 956 | $update = true; |
958 | 957 | |
959 | - } elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) { |
|
958 | + } elseif (count($new_form_meta_value) !== count($form_meta_value)) { |
|
960 | 959 | // Filter recipient emails. |
961 | 960 | $form_meta_value = $new_form_meta_value; |
962 | 961 | |
963 | 962 | $update = true; |
964 | 963 | } |
965 | 964 | |
966 | - if( $update ) { |
|
967 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
965 | + if ($update) { |
|
966 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
968 | 967 | } |
969 | 968 | } |
970 | 969 | } |
@@ -120,7 +120,7 @@ |
||
120 | 120 | * @param string $email_preview_header |
121 | 121 | * @param Give_Donor_Register_Email $email |
122 | 122 | * |
123 | - * @return bool |
|
123 | + * @return string|null |
|
124 | 124 | */ |
125 | 125 | public function email_preview_header( $email_preview_header, $email ) { |
126 | 126 | // Bailout. |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if access directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -if ( ! class_exists( 'Give_Donor_Register_Email' ) ) : |
|
17 | +if ( ! class_exists('Give_Donor_Register_Email')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_Donor_Register_Email |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | * @since 2.0 |
32 | 32 | */ |
33 | 33 | public function init() { |
34 | - $this->load( array( |
|
34 | + $this->load(array( |
|
35 | 35 | 'id' => 'donor-register', |
36 | - 'label' => __( 'User Registration Information', 'give' ), |
|
37 | - 'description' => __( 'Sent to the donor when they register for an account on the site.', 'give' ), |
|
36 | + 'label' => __('User Registration Information', 'give'), |
|
37 | + 'description' => __('Sent to the donor when they register for an account on the site.', 'give'), |
|
38 | 38 | 'notification_status' => 'enabled', |
39 | 39 | 'email_tag_contex' => 'donor', |
40 | 40 | 'form_metabox_setting' => false, |
41 | - 'recipient_group_name' => __( 'Donor', 'give' ), |
|
42 | - 'email_tag_context' => array( 'donor', 'general' ), |
|
41 | + 'recipient_group_name' => __('Donor', 'give'), |
|
42 | + 'email_tag_context' => array('donor', 'general'), |
|
43 | 43 | 'default_email_subject' => sprintf( |
44 | 44 | /* translators: %s: site name */ |
45 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
46 | - get_bloginfo( 'name' ) |
|
45 | + esc_attr__('[%s] Your username and password', 'give'), |
|
46 | + get_bloginfo('name') |
|
47 | 47 | ), |
48 | 48 | 'default_email_message' => $this->get_default_email_message(), |
49 | - 'default_email_header' => __( 'New User Registration', 'give' ), |
|
50 | - ) ); |
|
49 | + 'default_email_header' => __('New User Registration', 'give'), |
|
50 | + )); |
|
51 | 51 | |
52 | 52 | // Setup action hook. |
53 | 53 | add_action( |
54 | 54 | "give_{$this->config['id']}_email_notification", |
55 | - array( $this, 'setup_email_notification' ), |
|
55 | + array($this, 'setup_email_notification'), |
|
56 | 56 | 10, |
57 | 57 | 2 |
58 | 58 | ); |
59 | 59 | |
60 | 60 | add_filter( |
61 | 61 | 'give_email_preview_header', |
62 | - array( $this, 'email_preview_header' ), |
|
62 | + array($this, 'email_preview_header'), |
|
63 | 63 | 10, |
64 | 64 | 2 |
65 | 65 | ); |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | * @return string |
75 | 75 | */ |
76 | 76 | function get_default_email_message() { |
77 | - $message = esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; |
|
77 | + $message = esc_attr__('Username: {username}', 'give')."\r\n\r\n"; |
|
78 | 78 | |
79 | - $message .= __( 'To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give' ) . "\r\n"; |
|
80 | - $message .= '{reset_password_link}' . "\r\n\r\n"; |
|
79 | + $message .= __('To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give')."\r\n"; |
|
80 | + $message .= '{reset_password_link}'."\r\n\r\n"; |
|
81 | 81 | |
82 | - $message .= __( 'After resetting password, Please login to your account with link below.', 'give' ) . "\r\n"; |
|
83 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
82 | + $message .= __('After resetting password, Please login to your account with link below.', 'give')."\r\n"; |
|
83 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Filter the default email message |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @since 2.0 |
100 | 100 | */ |
101 | 101 | public function setup_email_data() { |
102 | - Give()->emails->__set( 'heading', $this->get_email_header() ); |
|
102 | + Give()->emails->__set('heading', $this->get_email_header()); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function setup_email_notification( $user_id, $user_data ) { |
|
116 | + public function setup_email_notification($user_id, $user_data) { |
|
117 | 117 | $this->setup_email_data(); |
118 | 118 | |
119 | 119 | $this->recipient_email = $user_data['user_email']; |
120 | - $this->send_email_notification( array( |
|
120 | + $this->send_email_notification(array( |
|
121 | 121 | 'user_id' => $user_id, |
122 | - ) ); |
|
122 | + )); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -133,42 +133,42 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | - public function email_preview_header( $email_preview_header, $email ) { |
|
136 | + public function email_preview_header($email_preview_header, $email) { |
|
137 | 137 | // Bailout. |
138 | - if ( $this->config['id'] !== $email->config['id'] ) { |
|
138 | + if ($this->config['id'] !== $email->config['id']) { |
|
139 | 139 | return $email_preview_header; |
140 | 140 | } |
141 | 141 | |
142 | 142 | // Payment receipt switcher |
143 | - $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); |
|
143 | + $user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'); |
|
144 | 144 | |
145 | 145 | // Get payments. |
146 | 146 | $donors = new Give_API(); |
147 | - $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); |
|
147 | + $donors = give_check_variable($donors->get_donors(), 'empty', array(), 'donors'); |
|
148 | 148 | $options = array(); |
149 | 149 | |
150 | 150 | // Default option. |
151 | - $options[0] = esc_html__( 'No donor(s) found.', 'give' ); |
|
151 | + $options[0] = esc_html__('No donor(s) found.', 'give'); |
|
152 | 152 | |
153 | 153 | // Provide nice human readable options. |
154 | - if ( $donors ) { |
|
155 | - $options[0] = esc_html__( '- Select a donor -', 'give' ); |
|
156 | - foreach ( $donors as $donor ) { |
|
154 | + if ($donors) { |
|
155 | + $options[0] = esc_html__('- Select a donor -', 'give'); |
|
156 | + foreach ($donors as $donor) { |
|
157 | 157 | // Exclude customers for which wp user not exist. |
158 | - if ( ! $donor['info']['user_id'] ) { |
|
158 | + if ( ! $donor['info']['user_id']) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | - $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); |
|
161 | + $options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
165 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
166 | 166 | $query = $request_url_data['query']; |
167 | 167 | |
168 | 168 | // Remove user id query param if set from request url. |
169 | - $query = remove_query_arg( array( 'user_id' ), $query ); |
|
169 | + $query = remove_query_arg(array('user_id'), $query); |
|
170 | 170 | |
171 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
171 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
172 | 172 | ?> |
173 | 173 | |
174 | 174 | <!-- Start constructing HTML output.--> |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | </script> |
187 | 187 | |
188 | 188 | <label for="give_preview_email_user_id" style="font-size:12px;color:#333;margin:0 4px 0 0;"> |
189 | - <?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?> |
|
189 | + <?php echo esc_html__('Preview email with a donor:', 'give'); ?> |
|
190 | 190 | </label> |
191 | 191 | |
192 | 192 | <?php |
193 | 193 | // The select field with 100 latest transactions |
194 | - echo Give()->html->select( array( |
|
194 | + echo Give()->html->select(array( |
|
195 | 195 | 'name' => 'preview_email_user_id', |
196 | 196 | 'selected' => $user_id, |
197 | 197 | 'id' => 'give_preview_email_user_id', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'select_atts' => 'onchange="change_preview()"', |
202 | 202 | 'show_option_all' => false, |
203 | 203 | 'show_option_none' => false, |
204 | - ) ); |
|
204 | + )); |
|
205 | 205 | ?> |
206 | 206 | </div> |
207 | 207 | <?php |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 2.0 |
233 | 233 | * @access public |
234 | - * @return bool|null |
|
234 | + * @return false|null |
|
235 | 235 | */ |
236 | 236 | public function preview_email() { |
237 | 237 | // Bailout. |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @since 2.0 |
371 | 371 | * @access public |
372 | - * @return bool|null |
|
372 | + * @return false|null |
|
373 | 373 | */ |
374 | 374 | public function send_preview_email() { |
375 | 375 | // Bailout. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return static |
53 | 53 | */ |
54 | 54 | static function get_instance() { |
55 | - if ( null === static::$instance ) { |
|
55 | + if (null === static::$instance) { |
|
56 | 56 | self::$instance = new static(); |
57 | 57 | } |
58 | 58 | |
@@ -66,31 +66,31 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function init() { |
68 | 68 | // Load files. |
69 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/ajax-handler.php'; |
|
70 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-setting-field.php'; |
|
71 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/filters.php'; |
|
69 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/ajax-handler.php'; |
|
70 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-setting-field.php'; |
|
71 | + require_once GIVE_PLUGIN_DIR.'includes/admin/emails/filters.php'; |
|
72 | 72 | |
73 | 73 | // Load email notifications. |
74 | 74 | $this->add_emails_notifications(); |
75 | 75 | |
76 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_metabox_setting_fields' ), 10, 2 ); |
|
77 | - add_action( 'init', array( $this, 'preview_email' ) ); |
|
78 | - add_action( 'init', array( $this, 'send_preview_email' ) ); |
|
79 | - add_action( 'init', array( $this, 'validate_settings' ) ); |
|
76 | + add_filter('give_metabox_form_data_settings', array($this, 'add_metabox_setting_fields'), 10, 2); |
|
77 | + add_action('init', array($this, 'preview_email')); |
|
78 | + add_action('init', array($this, 'send_preview_email')); |
|
79 | + add_action('init', array($this, 'validate_settings')); |
|
80 | 80 | |
81 | 81 | /* @var Give_Email_Notification $email */ |
82 | - foreach ( $this->get_email_notifications() as $email ) { |
|
82 | + foreach ($this->get_email_notifications() as $email) { |
|
83 | 83 | // Setup email section. |
84 | - if( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email ) ) { |
|
85 | - add_filter( 'give_get_sections_emails', array( $email, 'add_section' ) ); |
|
86 | - add_filter( "give_hide_section_{$email->config['id']}_on_emails_page", array( $email, 'hide_section' ) ); |
|
84 | + if (Give_Email_Notification_Util::is_show_on_emails_setting_page($email)) { |
|
85 | + add_filter('give_get_sections_emails', array($email, 'add_section')); |
|
86 | + add_filter("give_hide_section_{$email->config['id']}_on_emails_page", array($email, 'hide_section')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Setup email preview. |
90 | - if ( Give_Email_Notification_Util::is_email_preview_has_header( $email ) ) { |
|
91 | - add_action( "give_{$email->config['id']}_email_preview", array( $this, 'email_preview_header' ) ); |
|
92 | - add_filter( "give_{$email->config['id']}_email_preview_data", array( $this, 'email_preview_data' ) ); |
|
93 | - add_filter( "give_{$email->config['id']}_email_preview_message", array( $this, 'email_preview_message' ), 1, 2 ); |
|
90 | + if (Give_Email_Notification_Util::is_email_preview_has_header($email)) { |
|
91 | + add_action("give_{$email->config['id']}_email_preview", array($this, 'email_preview_header')); |
|
92 | + add_filter("give_{$email->config['id']}_email_preview_data", array($this, 'email_preview_data')); |
|
93 | + add_filter("give_{$email->config['id']}_email_preview_message", array($this, 'email_preview_message'), 1, 2); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -107,63 +107,63 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return array |
109 | 109 | */ |
110 | - public function add_metabox_setting_fields( $settings, $post_id ) { |
|
110 | + public function add_metabox_setting_fields($settings, $post_id) { |
|
111 | 111 | $emails = $this->get_email_notifications(); |
112 | 112 | |
113 | 113 | // Bailout. |
114 | - if ( empty( $emails ) ) { |
|
114 | + if (empty($emails)) { |
|
115 | 115 | return $settings; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Email notification setting. |
119 | 119 | $settings['email_notification_options'] = array( |
120 | 120 | 'id' => 'email_notification_options', |
121 | - 'title' => __( 'Email Notifications', 'give' ), |
|
121 | + 'title' => __('Email Notifications', 'give'), |
|
122 | 122 | 'icon-html' => '<span class="dashicons dashicons-email-alt"></span>', |
123 | 123 | 'fields' => array( |
124 | 124 | array( |
125 | - 'name' => __( 'Email Options', 'give' ), |
|
125 | + 'name' => __('Email Options', 'give'), |
|
126 | 126 | 'id' => '_give_email_options', |
127 | 127 | 'type' => 'radio_inline', |
128 | 128 | 'default' => 'global', |
129 | 129 | 'options' => array( |
130 | - 'global' => __( 'Global Options' ), |
|
131 | - 'enabled' => __( 'Customize', 'give' ), |
|
130 | + 'global' => __('Global Options'), |
|
131 | + 'enabled' => __('Customize', 'give'), |
|
132 | 132 | ), |
133 | 133 | ), |
134 | 134 | array( |
135 | 135 | 'id' => '_give_email_template', |
136 | - 'name' => esc_html__( 'Email Template', 'give' ), |
|
137 | - 'desc' => esc_html__( 'Choose your template from the available registered template types.', 'give' ), |
|
136 | + 'name' => esc_html__('Email Template', 'give'), |
|
137 | + 'desc' => esc_html__('Choose your template from the available registered template types.', 'give'), |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'default' => 'default', |
140 | 140 | 'options' => give_get_email_templates(), |
141 | 141 | ), |
142 | 142 | array( |
143 | 143 | 'id' => '_give_email_logo', |
144 | - 'name' => esc_html__( 'Logo', 'give' ), |
|
145 | - 'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
144 | + 'name' => esc_html__('Logo', 'give'), |
|
145 | + 'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
146 | 146 | 'type' => 'file', |
147 | 147 | ), |
148 | 148 | array( |
149 | 149 | 'id' => '_give_from_name', |
150 | - 'name' => esc_html__( 'From Name', 'give' ), |
|
151 | - 'desc' => esc_html__( 'The name which appears in the "From" field in all Give donation emails.', 'give' ), |
|
152 | - 'default' => get_bloginfo( 'name' ), |
|
150 | + 'name' => esc_html__('From Name', 'give'), |
|
151 | + 'desc' => esc_html__('The name which appears in the "From" field in all Give donation emails.', 'give'), |
|
152 | + 'default' => get_bloginfo('name'), |
|
153 | 153 | 'type' => 'text', |
154 | 154 | ), |
155 | 155 | array( |
156 | 156 | 'id' => '_give_from_email', |
157 | - 'name' => esc_html__( 'From Email', 'give' ), |
|
158 | - 'desc' => esc_html__( 'Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ), |
|
159 | - 'default' => get_bloginfo( 'admin_email' ), |
|
157 | + 'name' => esc_html__('From Email', 'give'), |
|
158 | + 'desc' => esc_html__('Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give'), |
|
159 | + 'default' => get_bloginfo('admin_email'), |
|
160 | 160 | 'type' => 'text', |
161 | 161 | ), |
162 | 162 | array( |
163 | 163 | 'name' => 'email_notification_docs', |
164 | 164 | 'type' => 'docs_link', |
165 | 165 | 'url' => 'http://docs.givewp.com/email-notification', |
166 | - 'title' => __( 'Email Notification', 'give' ), |
|
166 | + 'title' => __('Email Notification', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @since 2.0 |
174 | 174 | */ |
175 | - 'sub-fields' => apply_filters( 'give_email_notification_options_metabox_fields', array(), $post_id ), |
|
175 | + 'sub-fields' => apply_filters('give_email_notification_options_metabox_fields', array(), $post_id), |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | return $settings; |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function add_emails_notifications() { |
188 | 188 | $this->emails = array( |
189 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donation-email.php', |
|
190 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donor-register-email.php', |
|
195 | - include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-access-email.php', |
|
189 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donation-email.php', |
|
190 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donation-receipt-email.php', |
|
191 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-offline-donation-email.php', |
|
192 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-offline-donation-instruction-email.php', |
|
193 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donor-register-email.php', |
|
194 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donor-register-email.php', |
|
195 | + include GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-access-email.php', |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | /** |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @since 2.0 |
202 | 202 | */ |
203 | - $this->emails = apply_filters( 'give_email_notifications', $this->emails, $this ); |
|
203 | + $this->emails = apply_filters('give_email_notifications', $this->emails, $this); |
|
204 | 204 | |
205 | 205 | // Bailout. |
206 | - if ( empty( $this->emails ) ) { |
|
206 | + if (empty($this->emails)) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Initiate email notifications. |
211 | - foreach ( $this->emails as $email ) { |
|
211 | + foreach ($this->emails as $email) { |
|
212 | 212 | $email->init(); |
213 | 213 | } |
214 | 214 | } |
@@ -235,41 +235,41 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function preview_email() { |
237 | 237 | // Bailout. |
238 | - if ( ! Give_Email_Notification_Util::can_preview_email() ) { |
|
238 | + if ( ! Give_Email_Notification_Util::can_preview_email()) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Security check. |
243 | - give_validate_nonce( $_GET['_wpnonce'], 'give-preview-email' ); |
|
243 | + give_validate_nonce($_GET['_wpnonce'], 'give-preview-email'); |
|
244 | 244 | |
245 | 245 | // Get email type. |
246 | - $email_type = isset( $_GET['email_type'] ) ? esc_attr( $_GET['email_type'] ) : ''; |
|
246 | + $email_type = isset($_GET['email_type']) ? esc_attr($_GET['email_type']) : ''; |
|
247 | 247 | |
248 | 248 | /* @var Give_Email_Notification $email */ |
249 | - foreach ( $this->get_email_notifications() as $email ) { |
|
250 | - if ( $email_type !== $email->config['id'] ) { |
|
249 | + foreach ($this->get_email_notifications() as $email) { |
|
250 | + if ($email_type !== $email->config['id']) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Set form id. |
255 | - $form_id = empty( $_GET['form_id'] ) ? null : absint( $_GET['form_id'] ); |
|
255 | + $form_id = empty($_GET['form_id']) ? null : absint($_GET['form_id']); |
|
256 | 256 | |
257 | 257 | // Call setup email data to apply filter and other thing to email. |
258 | 258 | $email->setup_email_data(); |
259 | 259 | |
260 | 260 | // Decode message. |
261 | - $email_message = $email->preview_email_template_tags( $email->get_email_message( $form_id ) ); |
|
261 | + $email_message = $email->preview_email_template_tags($email->get_email_message($form_id)); |
|
262 | 262 | |
263 | 263 | // Set email template. |
264 | - Give()->emails->html = true; |
|
265 | - Give()->emails->__set( 'template', $email->get_email_template( $form_id ) ); |
|
264 | + Give()->emails->html = true; |
|
265 | + Give()->emails->__set('template', $email->get_email_template($form_id)); |
|
266 | 266 | |
267 | - if ( 'text/plain' === $email->config['content_type'] ) { |
|
267 | + if ('text/plain' === $email->config['content_type']) { |
|
268 | 268 | // Give()->emails->__set( 'html', false ); |
269 | - Give()->emails->__set( 'template', 'none' ); |
|
269 | + Give()->emails->__set('template', 'none'); |
|
270 | 270 | } |
271 | 271 | |
272 | - if ( $email_message = Give()->emails->build_email( $email_message ) ) { |
|
272 | + if ($email_message = Give()->emails->build_email($email_message)) { |
|
273 | 273 | |
274 | 274 | /** |
275 | 275 | * Filter the email preview data |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param array |
280 | 280 | */ |
281 | - $email_preview_data = apply_filters( "give_{$email_type}_email_preview_data", array() ); |
|
281 | + $email_preview_data = apply_filters("give_{$email_type}_email_preview_data", array()); |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * Fire the give_{$email_type}_email_preview action |
285 | 285 | * |
286 | 286 | * @since 2.0 |
287 | 287 | */ |
288 | - do_action( "give_{$email_type}_email_preview", $email ); |
|
288 | + do_action("give_{$email_type}_email_preview", $email); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Filter the email message |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param array $email_preview_data |
297 | 297 | * @param Give_Email_Notification $email |
298 | 298 | */ |
299 | - echo apply_filters( "give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email ); |
|
299 | + echo apply_filters("give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email); |
|
300 | 300 | |
301 | 301 | exit(); |
302 | 302 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param Give_Email_Notification $email |
314 | 314 | */ |
315 | - public function email_preview_header( $email ) { |
|
315 | + public function email_preview_header($email) { |
|
316 | 316 | /** |
317 | 317 | * Filter the all email preview headers. |
318 | 318 | * |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param Give_Email_Notification $email |
322 | 322 | */ |
323 | - $email_preview_header = apply_filters( 'give_email_preview_header', give_get_preview_email_header(), $email ); |
|
323 | + $email_preview_header = apply_filters('give_email_preview_header', give_get_preview_email_header(), $email); |
|
324 | 324 | |
325 | 325 | echo $email_preview_header; |
326 | 326 | } |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return array |
337 | 337 | */ |
338 | - public function email_preview_data( $email_preview_data ) { |
|
339 | - $email_preview_data['payment_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ) ); |
|
340 | - $email_preview_data['user_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ) ); |
|
338 | + public function email_preview_data($email_preview_data) { |
|
339 | + $email_preview_data['payment_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id')); |
|
340 | + $email_preview_data['user_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'user_id')); |
|
341 | 341 | |
342 | 342 | return $email_preview_data; |
343 | 343 | } |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string |
355 | 355 | */ |
356 | - public function email_preview_message( $email_message, $email_preview_data ) { |
|
356 | + public function email_preview_message($email_message, $email_preview_data) { |
|
357 | 357 | if ( |
358 | - ! empty( $email_preview_data['payment_id'] ) |
|
359 | - || ! empty( $email_preview_data['user_id'] ) |
|
358 | + ! empty($email_preview_data['payment_id']) |
|
359 | + || ! empty($email_preview_data['user_id']) |
|
360 | 360 | ) { |
361 | - $email_message = give_do_email_tags( $email_message, $email_preview_data ); |
|
361 | + $email_message = give_do_email_tags($email_message, $email_preview_data); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | return $email_message; |
@@ -373,26 +373,26 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function send_preview_email() { |
375 | 375 | // Bailout. |
376 | - if ( ! Give_Email_Notification_Util::can_send_preview_email() ) { |
|
376 | + if ( ! Give_Email_Notification_Util::can_send_preview_email()) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | 380 | // Security check. |
381 | - give_validate_nonce( $_GET['_wpnonce'], 'give-send-preview-email' ); |
|
381 | + give_validate_nonce($_GET['_wpnonce'], 'give-send-preview-email'); |
|
382 | 382 | |
383 | 383 | // Get email type. |
384 | - $email_type = give_check_variable( give_clean( $_GET ), 'isset', '', 'email_type' ); |
|
384 | + $email_type = give_check_variable(give_clean($_GET), 'isset', '', 'email_type'); |
|
385 | 385 | |
386 | 386 | /* @var Give_Email_Notification $email */ |
387 | - foreach ( $this->get_email_notifications() as $email ) { |
|
388 | - if ( $email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview( $email ) ) { |
|
387 | + foreach ($this->get_email_notifications() as $email) { |
|
388 | + if ($email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview($email)) { |
|
389 | 389 | $email->send_preview_email(); |
390 | 390 | break; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Remove the test email query arg. |
395 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
395 | + wp_redirect(remove_query_arg('give_action')); |
|
396 | 396 | exit; |
397 | 397 | } |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @access public |
405 | 405 | */ |
406 | 406 | public function load() { |
407 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
407 | + add_action('init', array($this, 'init'), -1); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | if ( |
420 | 420 | ! Give_Admin_Settings::is_saving_settings() || |
421 | 421 | 'emails' !== give_get_current_setting_tab() || |
422 | - ! isset( $_GET['section'] ) |
|
422 | + ! isset($_GET['section']) |
|
423 | 423 | ) { |
424 | 424 | return; |
425 | 425 | } |
@@ -427,18 +427,18 @@ discard block |
||
427 | 427 | // Get email type. |
428 | 428 | $email_type = give_get_current_setting_section(); |
429 | 429 | |
430 | - if ( ! empty( $_POST["{$email_type}_recipient"] ) ) { |
|
431 | - $_POST["{$email_type}_recipient"] = array_unique( array_filter( $_POST["{$email_type}_recipient"] ) ); |
|
430 | + if ( ! empty($_POST["{$email_type}_recipient"])) { |
|
431 | + $_POST["{$email_type}_recipient"] = array_unique(array_filter($_POST["{$email_type}_recipient"])); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | 436 | // Helper class. |
437 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/abstract-email-notification.php'; |
|
438 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notification-util.php'; |
|
437 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/abstract-email-notification.php'; |
|
438 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notification-util.php'; |
|
439 | 439 | |
440 | 440 | // Add backward compatibility. |
441 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/backward-compatibility.php'; |
|
441 | +require_once GIVE_PLUGIN_DIR.'includes/admin/emails/backward-compatibility.php'; |
|
442 | 442 | |
443 | 443 | /** |
444 | 444 | * Initialize functionality. |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * Get donor email html. |
530 | 530 | * |
531 | - * @param object $payment Contains all the data of the payment. |
|
531 | + * @param Give_Payment $payment Contains all the data of the payment. |
|
532 | 532 | * |
533 | 533 | * @access public |
534 | 534 | * @since 1.0 |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * Get Row Actions |
558 | 558 | * |
559 | - * @param object $payment Payment Data. |
|
559 | + * @param Give_Payment $payment Payment Data. |
|
560 | 560 | * |
561 | 561 | * @since 1.6 |
562 | 562 | * |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | /** |
678 | 678 | * Get donor html. |
679 | 679 | * |
680 | - * @param object $payment Contains all the data of the payment. |
|
680 | + * @param Give_Payment $payment Contains all the data of the payment. |
|
681 | 681 | * |
682 | 682 | * @access public |
683 | 683 | * @since 1.0 |
@@ -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 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | // Set parent defaults. |
137 | 137 | parent::__construct( |
138 | 138 | array( |
139 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | - 'ajax' => false, // Does this table support ajax? |
|
139 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
140 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
141 | + 'ajax' => false, // Does this table support ajax? |
|
142 | 142 | ) |
143 | 143 | ); |
144 | 144 | |
145 | 145 | $this->process_bulk_action(); |
146 | 146 | $this->get_payment_counts(); |
147 | - $this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); |
|
147 | + $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,31 +153,31 @@ discard block |
||
153 | 153 | * @return void |
154 | 154 | */ |
155 | 155 | public function advanced_filters() { |
156 | - $start_date = isset( $_GET['start-date'] ) ? give_clean( $_GET['start-date'] ) : null; |
|
157 | - $end_date = isset( $_GET['end-date'] ) ? give_clean( $_GET['end-date'] ) : null; |
|
158 | - $status = isset( $_GET['status'] ) ? give_clean( $_GET['status'] ) : ''; |
|
159 | - $donor = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : ''; |
|
160 | - $search = isset( $_GET['s'] ) ? give_clean( $_GET['s'] ) : ''; |
|
161 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; |
|
156 | + $start_date = isset($_GET['start-date']) ? give_clean($_GET['start-date']) : null; |
|
157 | + $end_date = isset($_GET['end-date']) ? give_clean($_GET['end-date']) : null; |
|
158 | + $status = isset($_GET['status']) ? give_clean($_GET['status']) : ''; |
|
159 | + $donor = isset($_GET['donor']) ? absint($_GET['donor']) : ''; |
|
160 | + $search = isset($_GET['s']) ? give_clean($_GET['s']) : ''; |
|
161 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0; |
|
162 | 162 | ?> |
163 | 163 | <div id="give-payment-filters" class="give-filters"> |
164 | - <?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?> |
|
164 | + <?php $this->search_box(__('Search', 'give'), 'give-payments'); ?> |
|
165 | 165 | <div id="give-payment-date-filters"> |
166 | 166 | <div class="give-filter give-filter-half"> |
167 | 167 | <label for="start-date" |
168 | - class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label> |
|
168 | + class="give-start-date-label"><?php _e('Start Date', 'give'); ?></label> |
|
169 | 169 | <input type="text" id="start-date" name="start-date" class="give_datepicker" |
170 | 170 | value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/> |
171 | 171 | </div> |
172 | 172 | <div class="give-filter give-filter-half"> |
173 | - <label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label> |
|
173 | + <label for="end-date" class="give-end-date-label"><?php _e('End Date', 'give'); ?></label> |
|
174 | 174 | <input type="text" id="end-date" name="end-date" class="give_datepicker" |
175 | 175 | value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/> |
176 | 176 | </div> |
177 | 177 | </div> |
178 | 178 | <div id="give-payment-form-filter" class="give-filter"> |
179 | 179 | <label for="give-donation-forms-filter" |
180 | - class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label> |
|
180 | + class="give-donation-forms-filter-label"><?php _e('Form', 'give'); ?></label> |
|
181 | 181 | <?php |
182 | 182 | // Filter Donations by Donation Forms. |
183 | 183 | echo Give()->html->forms_dropdown( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'class' => 'give-donation-forms-filter', |
188 | 188 | 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection. |
189 | 189 | 'chosen' => true, |
190 | - 'number' => - 1, |
|
190 | + 'number' => -1, |
|
191 | 191 | ) |
192 | 192 | ); |
193 | 193 | ?> |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @since 1.8.18 |
201 | 201 | */ |
202 | - do_action( 'give_payment_table_advanced_filters' ); |
|
202 | + do_action('give_payment_table_advanced_filters'); |
|
203 | 203 | |
204 | 204 | |
205 | - if ( ! empty( $status ) ) { |
|
206 | - echo sprintf( '<input type="hidden" name="status" value="%s"/>', esc_attr( $status ) ); |
|
205 | + if ( ! empty($status)) { |
|
206 | + echo sprintf('<input type="hidden" name="status" value="%s"/>', esc_attr($status)); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( ! empty( $donor ) ) { |
|
210 | - echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $donor ) ); |
|
209 | + if ( ! empty($donor)) { |
|
210 | + echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($donor)); |
|
211 | 211 | } |
212 | 212 | ?> |
213 | 213 | |
214 | 214 | <div class="give-filter"> |
215 | - <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?> |
|
215 | + <?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?> |
|
216 | 216 | <?php |
217 | 217 | // Clear active filters button. |
218 | - if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : |
|
218 | + if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : |
|
219 | 219 | ?> |
220 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>" |
|
221 | - class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a> |
|
220 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>" |
|
221 | + class="button give-clear-filters-button"><?php _e('Clear Filters', 'give'); ?></a> |
|
222 | 222 | <?php endif; ?> |
223 | 223 | </div> |
224 | 224 | </div> |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function search_box( $text, $input_id ) { |
|
241 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
240 | + public function search_box($text, $input_id) { |
|
241 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $input_id = $input_id . '-search-input'; |
|
245 | + $input_id = $input_id.'-search-input'; |
|
246 | 246 | |
247 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
248 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
247 | + if ( ! empty($_REQUEST['orderby'])) { |
|
248 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
249 | 249 | } |
250 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
251 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
250 | + if ( ! empty($_REQUEST['order'])) { |
|
251 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
252 | 252 | } |
253 | 253 | ?> |
254 | 254 | <div class="give-filter give-filter-search" role="search"> |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @since 1.7 |
262 | 262 | */ |
263 | - do_action( 'give_payment_history_search' ); |
|
263 | + do_action('give_payment_history_search'); |
|
264 | 264 | ?> |
265 | 265 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
266 | 266 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
267 | - <?php submit_button( $text, 'button', false, false, array( |
|
267 | + <?php submit_button($text, 'button', false, false, array( |
|
268 | 268 | 'ID' => 'search-submit', |
269 | - ) ); ?><br/> |
|
269 | + )); ?><br/> |
|
270 | 270 | </div> |
271 | 271 | <?php |
272 | 272 | } |
@@ -281,48 +281,48 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function get_views() { |
283 | 283 | |
284 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
284 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
285 | 285 | $views = array(); |
286 | 286 | $tabs = array( |
287 | 287 | 'all' => array( |
288 | 288 | 'total_count', |
289 | - __( 'All', 'give' ), |
|
289 | + __('All', 'give'), |
|
290 | 290 | ), |
291 | 291 | 'publish' => array( |
292 | 292 | 'complete_count', |
293 | - __( 'Completed', 'give' ), |
|
293 | + __('Completed', 'give'), |
|
294 | 294 | ), |
295 | 295 | 'pending' => array( |
296 | 296 | 'pending_count', |
297 | - __( 'Pending', 'give' ), |
|
297 | + __('Pending', 'give'), |
|
298 | 298 | ), |
299 | 299 | 'processing' => array( |
300 | 300 | 'processing_count', |
301 | - __( 'Processing', 'give' ), |
|
301 | + __('Processing', 'give'), |
|
302 | 302 | ), |
303 | 303 | 'refunded' => array( |
304 | 304 | 'refunded_count', |
305 | - __( 'Refunded', 'give' ), |
|
305 | + __('Refunded', 'give'), |
|
306 | 306 | ), |
307 | 307 | 'revoked' => array( |
308 | 308 | 'revoked_count', |
309 | - __( 'Revoked', 'give' ), |
|
309 | + __('Revoked', 'give'), |
|
310 | 310 | ), |
311 | 311 | 'failed' => array( |
312 | 312 | 'failed_count', |
313 | - __( 'Failed', 'give' ), |
|
313 | + __('Failed', 'give'), |
|
314 | 314 | ), |
315 | 315 | 'cancelled' => array( |
316 | 316 | 'cancelled_count', |
317 | - __( 'Cancelled', 'give' ), |
|
317 | + __('Cancelled', 'give'), |
|
318 | 318 | ), |
319 | 319 | 'abandoned' => array( |
320 | 320 | 'abandoned_count', |
321 | - __( 'Abandoned', 'give' ), |
|
321 | + __('Abandoned', 'give'), |
|
322 | 322 | ), |
323 | 323 | 'preapproval' => array( |
324 | 324 | 'preapproval_count', |
325 | - __( 'Preapproval Pending', 'give' ), |
|
325 | + __('Preapproval Pending', 'give'), |
|
326 | 326 | ), |
327 | 327 | ); |
328 | 328 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @since 1.8.18 |
333 | 333 | */ |
334 | - $args = (array) apply_filters( 'give_payments_table_status_remove_query_arg', array( 'paged', '_wpnonce', '_wp_http_referer' ) ); |
|
334 | + $args = (array) apply_filters('give_payments_table_status_remove_query_arg', array('paged', '_wpnonce', '_wp_http_referer')); |
|
335 | 335 | |
336 | 336 | // Build URL. |
337 | - $staus_url = remove_query_arg( $args ); |
|
337 | + $staus_url = remove_query_arg($args); |
|
338 | 338 | |
339 | - foreach ( $tabs as $key => $tab ) { |
|
339 | + foreach ($tabs as $key => $tab) { |
|
340 | 340 | $count_key = $tab[0]; |
341 | 341 | $name = $tab[1]; |
342 | 342 | $count = $this->$count_key; |
@@ -351,16 +351,15 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @since 1.8.12 |
353 | 353 | */ |
354 | - if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) { |
|
354 | + if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) { |
|
355 | 355 | |
356 | 356 | $staus_url = 'all' === $key ? |
357 | - add_query_arg( array( 'status' => false ), $staus_url ) : |
|
358 | - add_query_arg( array( 'status' => $key ), $staus_url ); |
|
357 | + add_query_arg(array('status' => false), $staus_url) : add_query_arg(array('status' => $key), $staus_url); |
|
359 | 358 | |
360 | - $views[ $key ] = sprintf( |
|
359 | + $views[$key] = sprintf( |
|
361 | 360 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
362 | - esc_url( $staus_url ), |
|
363 | - ( ( 'all' === $key && empty( $current ) ) ) ? ' class="current"' : ( $current == $key ? 'class="current"' : '' ), |
|
361 | + esc_url($staus_url), |
|
362 | + (('all' === $key && empty($current))) ? ' class="current"' : ($current == $key ? 'class="current"' : ''), |
|
364 | 363 | $name, |
365 | 364 | $count |
366 | 365 | ); |
@@ -375,7 +374,7 @@ discard block |
||
375 | 374 | * @param array $views |
376 | 375 | * @param Give_Payment_History_Table |
377 | 376 | */ |
378 | - return apply_filters( 'give_payments_table_views', $views, $this ); |
|
377 | + return apply_filters('give_payments_table_views', $views, $this); |
|
379 | 378 | } |
380 | 379 | |
381 | 380 | /** |
@@ -389,18 +388,18 @@ discard block |
||
389 | 388 | public function get_columns() { |
390 | 389 | $columns = array( |
391 | 390 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
392 | - 'donation' => __( 'Donation', 'give' ), |
|
393 | - 'donation_form' => __( 'Donation Form', 'give' ), |
|
394 | - 'status' => __( 'Status', 'give' ), |
|
395 | - 'date' => __( 'Date', 'give' ), |
|
396 | - 'amount' => __( 'Amount', 'give' ), |
|
391 | + 'donation' => __('Donation', 'give'), |
|
392 | + 'donation_form' => __('Donation Form', 'give'), |
|
393 | + 'status' => __('Status', 'give'), |
|
394 | + 'date' => __('Date', 'give'), |
|
395 | + 'amount' => __('Amount', 'give'), |
|
397 | 396 | ); |
398 | 397 | |
399 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
400 | - $columns['details'] = __( 'Details', 'give' ); |
|
398 | + if (current_user_can('view_give_payments')) { |
|
399 | + $columns['details'] = __('Details', 'give'); |
|
401 | 400 | } |
402 | 401 | |
403 | - return apply_filters( 'give_payments_table_columns', $columns ); |
|
402 | + return apply_filters('give_payments_table_columns', $columns); |
|
404 | 403 | } |
405 | 404 | |
406 | 405 | /** |
@@ -413,14 +412,14 @@ discard block |
||
413 | 412 | */ |
414 | 413 | public function get_sortable_columns() { |
415 | 414 | $columns = array( |
416 | - 'donation' => array( 'ID', true ), |
|
417 | - 'donation_form' => array( 'donation_form', false ), |
|
418 | - 'status' => array( 'status', false ), |
|
419 | - 'amount' => array( 'amount', false ), |
|
420 | - 'date' => array( 'date', false ), |
|
415 | + 'donation' => array('ID', true), |
|
416 | + 'donation_form' => array('donation_form', false), |
|
417 | + 'status' => array('status', false), |
|
418 | + 'amount' => array('amount', false), |
|
419 | + 'date' => array('date', false), |
|
421 | 420 | ); |
422 | 421 | |
423 | - return apply_filters( 'give_payments_table_sortable_columns', $columns ); |
|
422 | + return apply_filters('give_payments_table_sortable_columns', $columns); |
|
424 | 423 | } |
425 | 424 | |
426 | 425 | /** |
@@ -446,43 +445,43 @@ discard block |
||
446 | 445 | * |
447 | 446 | * @return string Column Name |
448 | 447 | */ |
449 | - public function column_default( $payment, $column_name ) { |
|
448 | + public function column_default($payment, $column_name) { |
|
450 | 449 | |
451 | - $single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) ); |
|
452 | - $row_actions = $this->get_row_actions( $payment ); |
|
450 | + $single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details'))); |
|
451 | + $row_actions = $this->get_row_actions($payment); |
|
453 | 452 | $value = ''; |
454 | 453 | |
455 | - switch ( $column_name ) { |
|
454 | + switch ($column_name) { |
|
456 | 455 | case 'donation' : |
457 | - $serial_code = Give()->seq_donation_number->get_serial_code( $payment ); |
|
458 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
459 | - $value = Give()->tooltips->render_link( array( |
|
460 | - 'label' => sprintf( __( 'View Donation %s', 'give' ), $serial_code ), |
|
456 | + $serial_code = Give()->seq_donation_number->get_serial_code($payment); |
|
457 | + if (current_user_can('view_give_payments')) { |
|
458 | + $value = Give()->tooltips->render_link(array( |
|
459 | + 'label' => sprintf(__('View Donation %s', 'give'), $serial_code), |
|
461 | 460 | 'tag_content' => $serial_code, |
462 | 461 | 'link' => $single_donation_url, |
463 | - ) ); |
|
462 | + )); |
|
464 | 463 | } else { |
465 | 464 | $value = $serial_code; |
466 | 465 | } |
467 | 466 | |
468 | 467 | $value .= sprintf( |
469 | 468 | ' %1$s %2$s<br>', |
470 | - __( 'by', 'give' ), |
|
471 | - $this->get_donor( $payment ) |
|
469 | + __('by', 'give'), |
|
470 | + $this->get_donor($payment) |
|
472 | 471 | ); |
473 | 472 | |
474 | - $value .= $this->get_donor_email( $payment ); |
|
475 | - $value .= $this->row_actions( $row_actions ); |
|
473 | + $value .= $this->get_donor_email($payment); |
|
474 | + $value .= $this->row_actions($row_actions); |
|
476 | 475 | break; |
477 | 476 | |
478 | 477 | case 'amount': |
479 | - $value = give_donation_amount( $payment, true ); |
|
480 | - $value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) ); |
|
478 | + $value = give_donation_amount($payment, true); |
|
479 | + $value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway)); |
|
481 | 480 | break; |
482 | 481 | |
483 | 482 | case 'donation_form': |
484 | - $form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title; |
|
485 | - $value = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>'; |
|
483 | + $form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title; |
|
484 | + $value = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>'; |
|
486 | 485 | $level = give_get_donation_form_title( |
487 | 486 | $payment, |
488 | 487 | array( |
@@ -490,44 +489,44 @@ discard block |
||
490 | 489 | ) |
491 | 490 | ); |
492 | 491 | |
493 | - if ( ! empty( $level ) ) { |
|
492 | + if ( ! empty($level)) { |
|
494 | 493 | $value .= $level; |
495 | 494 | } |
496 | 495 | |
497 | 496 | break; |
498 | 497 | |
499 | 498 | case 'date': |
500 | - $date = strtotime( $payment->date ); |
|
501 | - $value = date_i18n( give_date_format(), $date ); |
|
499 | + $date = strtotime($payment->date); |
|
500 | + $value = date_i18n(give_date_format(), $date); |
|
502 | 501 | break; |
503 | 502 | |
504 | 503 | case 'status': |
505 | - $value = $this->get_payment_status( $payment ); |
|
504 | + $value = $this->get_payment_status($payment); |
|
506 | 505 | break; |
507 | 506 | |
508 | 507 | |
509 | 508 | case 'details' : |
510 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
511 | - $value = Give()->tooltips->render_link( array( |
|
512 | - 'label' => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ), |
|
509 | + if (current_user_can('view_give_payments')) { |
|
510 | + $value = Give()->tooltips->render_link(array( |
|
511 | + 'label' => sprintf(__('View Donation #%s', 'give'), $payment->ID), |
|
513 | 512 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
514 | 513 | 'link' => $single_donation_url, |
515 | 514 | 'attributes' => array( |
516 | 515 | 'class' => 'give-payment-details-link button button-small', |
517 | 516 | ), |
518 | - ) ); |
|
517 | + )); |
|
519 | 518 | |
520 | 519 | $value = "<div class=\"give-payment-details-link-wrap\">{$value}</div>"; |
521 | 520 | } |
522 | 521 | break; |
523 | 522 | |
524 | 523 | default: |
525 | - $value = isset( $payment->$column_name ) ? $payment->$column_name : ''; |
|
524 | + $value = isset($payment->$column_name) ? $payment->$column_name : ''; |
|
526 | 525 | break; |
527 | 526 | |
528 | 527 | }// End switch(). |
529 | 528 | |
530 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name ); |
|
529 | + return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name); |
|
531 | 530 | } |
532 | 531 | |
533 | 532 | /** |
@@ -540,22 +539,22 @@ discard block |
||
540 | 539 | * |
541 | 540 | * @return string Data shown in the Email column |
542 | 541 | */ |
543 | - public function get_donor_email( $payment ) { |
|
542 | + public function get_donor_email($payment) { |
|
544 | 543 | |
545 | - $email = give_get_payment_user_email( $payment->ID ); |
|
544 | + $email = give_get_payment_user_email($payment->ID); |
|
546 | 545 | |
547 | - if ( empty( $email ) ) { |
|
548 | - $email = __( '(unknown)', 'give' ); |
|
546 | + if (empty($email)) { |
|
547 | + $email = __('(unknown)', 'give'); |
|
549 | 548 | } |
550 | 549 | |
551 | 550 | |
552 | - $value = Give()->tooltips->render_link( array( |
|
551 | + $value = Give()->tooltips->render_link(array( |
|
553 | 552 | 'link' => "mailto:{$email}", |
554 | - 'label' => __( 'Email donor', 'give' ), |
|
553 | + 'label' => __('Email donor', 'give'), |
|
555 | 554 | 'tag_content' => $email, |
556 | - ) ); |
|
555 | + )); |
|
557 | 556 | |
558 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' ); |
|
557 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'email'); |
|
559 | 558 | } |
560 | 559 | |
561 | 560 | /** |
@@ -567,18 +566,18 @@ discard block |
||
567 | 566 | * |
568 | 567 | * @return array $actions |
569 | 568 | */ |
570 | - function get_row_actions( $payment ) { |
|
569 | + function get_row_actions($payment) { |
|
571 | 570 | |
572 | 571 | $actions = array(); |
573 | - $email = give_get_payment_user_email( $payment->ID ); |
|
572 | + $email = give_get_payment_user_email($payment->ID); |
|
574 | 573 | |
575 | 574 | // Add search term string back to base URL. |
576 | - $search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' ); |
|
577 | - if ( ! empty( $search_terms ) ) { |
|
578 | - $this->base_url = add_query_arg( 's', $search_terms, $this->base_url ); |
|
575 | + $search_terms = (isset($_GET['s']) ? trim($_GET['s']) : ''); |
|
576 | + if ( ! empty($search_terms)) { |
|
577 | + $this->base_url = add_query_arg('s', $search_terms, $this->base_url); |
|
579 | 578 | } |
580 | 579 | |
581 | - if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) { |
|
580 | + if (give_is_payment_complete($payment->ID) && ! empty($email)) { |
|
582 | 581 | |
583 | 582 | $actions['email_links'] = sprintf( |
584 | 583 | '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( |
@@ -588,12 +587,12 @@ discard block |
||
588 | 587 | 'purchase_id' => $payment->ID, |
589 | 588 | ), $this->base_url |
590 | 589 | ), 'give_payment_nonce' |
591 | - ), sprintf( __( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), __( 'Resend Receipt', 'give' ) |
|
590 | + ), sprintf(__('Resend Donation %s Receipt', 'give'), $payment->ID), __('Resend Receipt', 'give') |
|
592 | 591 | ); |
593 | 592 | |
594 | 593 | } |
595 | 594 | |
596 | - if ( current_user_can( 'view_give_payments' ) ) { |
|
595 | + if (current_user_can('view_give_payments')) { |
|
597 | 596 | $actions['delete'] = sprintf( |
598 | 597 | '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', |
599 | 598 | wp_nonce_url( |
@@ -603,11 +602,11 @@ discard block |
||
603 | 602 | 'purchase_id' => $payment->ID, |
604 | 603 | ), $this->base_url |
605 | 604 | ), 'give_donation_nonce' |
606 | - ), sprintf( __( 'Delete Donation %s', 'give' ), $payment->ID ), __( 'Delete', 'give' ) |
|
605 | + ), sprintf(__('Delete Donation %s', 'give'), $payment->ID), __('Delete', 'give') |
|
607 | 606 | ); |
608 | 607 | } |
609 | 608 | |
610 | - return apply_filters( 'give_payment_row_actions', $actions, $payment ); |
|
609 | + return apply_filters('give_payment_row_actions', $actions, $payment); |
|
611 | 610 | } |
612 | 611 | |
613 | 612 | |
@@ -621,30 +620,30 @@ discard block |
||
621 | 620 | * |
622 | 621 | * @return string Data shown in the Email column |
623 | 622 | */ |
624 | - function get_payment_status( $payment ) { |
|
623 | + function get_payment_status($payment) { |
|
625 | 624 | $value = sprintf( |
626 | 625 | '<div class="give-donation-status status-%1$s"><span class="give-donation-status-icon"></span> %2$s</div>', |
627 | 626 | $payment->status, |
628 | - give_get_payment_status( $payment, true ) |
|
627 | + give_get_payment_status($payment, true) |
|
629 | 628 | ); |
630 | 629 | |
631 | - if ( $payment->mode == 'test' ) { |
|
632 | - $value .= Give()->tooltips->render_span( array( |
|
633 | - 'label' => __( 'This donation was made in test mode.', 'give' ), |
|
634 | - 'tag_content' => __( 'Test', 'give' ), |
|
630 | + if ($payment->mode == 'test') { |
|
631 | + $value .= Give()->tooltips->render_span(array( |
|
632 | + 'label' => __('This donation was made in test mode.', 'give'), |
|
633 | + 'tag_content' => __('Test', 'give'), |
|
635 | 634 | 'attributes' => array( |
636 | 635 | 'class' => 'give-item-label give-item-label-orange give-test-mode-transactions-label', |
637 | 636 | ), |
638 | 637 | |
639 | 638 | |
640 | - ) ); |
|
639 | + )); |
|
641 | 640 | } |
642 | 641 | |
643 | - if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) { |
|
642 | + if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) { |
|
644 | 643 | $value .= sprintf( |
645 | 644 | ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="%1$s">%2$s</span>', |
646 | - __( 'This donation was imported.', 'give' ), |
|
647 | - __( 'Import', 'give' ) |
|
645 | + __('This donation was imported.', 'give'), |
|
646 | + __('Import', 'give') |
|
648 | 647 | ); |
649 | 648 | } |
650 | 649 | |
@@ -661,8 +660,8 @@ discard block |
||
661 | 660 | * |
662 | 661 | * @return string Displays a checkbox. |
663 | 662 | */ |
664 | - public function column_cb( $payment ) { |
|
665 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID ); |
|
663 | + public function column_cb($payment) { |
|
664 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID); |
|
666 | 665 | } |
667 | 666 | |
668 | 667 | /** |
@@ -675,8 +674,8 @@ discard block |
||
675 | 674 | * |
676 | 675 | * @return string Displays a checkbox. |
677 | 676 | */ |
678 | - public function get_payment_id( $payment ) { |
|
679 | - return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>'; |
|
677 | + public function get_payment_id($payment) { |
|
678 | + return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>'; |
|
680 | 679 | } |
681 | 680 | |
682 | 681 | /** |
@@ -689,32 +688,32 @@ discard block |
||
689 | 688 | * |
690 | 689 | * @return string Data shown in the User column |
691 | 690 | */ |
692 | - public function get_donor( $payment ) { |
|
691 | + public function get_donor($payment) { |
|
693 | 692 | |
694 | - $donor_id = give_get_payment_donor_id( $payment->ID ); |
|
695 | - $donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' ); |
|
696 | - $donor_name = give_get_donor_name_by( $donor_id, 'donor' ); |
|
693 | + $donor_id = give_get_payment_donor_id($payment->ID); |
|
694 | + $donor_billing_name = give_get_donor_name_by($payment->ID, 'donation'); |
|
695 | + $donor_name = give_get_donor_name_by($donor_id, 'donor'); |
|
697 | 696 | |
698 | 697 | $value = ''; |
699 | - if ( ! empty( $donor_id ) ) { |
|
698 | + if ( ! empty($donor_id)) { |
|
700 | 699 | |
701 | 700 | // Check whether the donor name and WP_User name is same or not. |
702 | - if ( sanitize_title( $donor_billing_name ) !== sanitize_title( $donor_name ) ) { |
|
703 | - $value .= $donor_billing_name . ' ('; |
|
701 | + if (sanitize_title($donor_billing_name) !== sanitize_title($donor_name)) { |
|
702 | + $value .= $donor_billing_name.' ('; |
|
704 | 703 | } |
705 | 704 | |
706 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>'; |
|
705 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>'; |
|
707 | 706 | |
708 | 707 | // Check whether the donor name and WP_User name is same or not. |
709 | - if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) { |
|
708 | + if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) { |
|
710 | 709 | $value .= ')'; |
711 | 710 | } |
712 | 711 | } else { |
713 | - $email = give_get_payment_user_email( $payment->ID ); |
|
714 | - $value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>'; |
|
712 | + $email = give_get_payment_user_email($payment->ID); |
|
713 | + $value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>'; |
|
715 | 714 | } |
716 | 715 | |
717 | - return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' ); |
|
716 | + return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor'); |
|
718 | 717 | } |
719 | 718 | |
720 | 719 | /** |
@@ -727,20 +726,20 @@ discard block |
||
727 | 726 | */ |
728 | 727 | public function get_bulk_actions() { |
729 | 728 | $actions = array( |
730 | - 'delete' => __( 'Delete', 'give' ), |
|
731 | - 'set-status-publish' => __( 'Set To Completed', 'give' ), |
|
732 | - 'set-status-pending' => __( 'Set To Pending', 'give' ), |
|
733 | - 'set-status-processing' => __( 'Set To Processing', 'give' ), |
|
734 | - 'set-status-refunded' => __( 'Set To Refunded', 'give' ), |
|
735 | - 'set-status-revoked' => __( 'Set To Revoked', 'give' ), |
|
736 | - 'set-status-failed' => __( 'Set To Failed', 'give' ), |
|
737 | - 'set-status-cancelled' => __( 'Set To Cancelled', 'give' ), |
|
738 | - 'set-status-abandoned' => __( 'Set To Abandoned', 'give' ), |
|
739 | - 'set-status-preapproval' => __( 'Set To Preapproval', 'give' ), |
|
740 | - 'resend-receipt' => __( 'Resend Email Receipts', 'give' ), |
|
729 | + 'delete' => __('Delete', 'give'), |
|
730 | + 'set-status-publish' => __('Set To Completed', 'give'), |
|
731 | + 'set-status-pending' => __('Set To Pending', 'give'), |
|
732 | + 'set-status-processing' => __('Set To Processing', 'give'), |
|
733 | + 'set-status-refunded' => __('Set To Refunded', 'give'), |
|
734 | + 'set-status-revoked' => __('Set To Revoked', 'give'), |
|
735 | + 'set-status-failed' => __('Set To Failed', 'give'), |
|
736 | + 'set-status-cancelled' => __('Set To Cancelled', 'give'), |
|
737 | + 'set-status-abandoned' => __('Set To Abandoned', 'give'), |
|
738 | + 'set-status-preapproval' => __('Set To Preapproval', 'give'), |
|
739 | + 'resend-receipt' => __('Resend Email Receipts', 'give'), |
|
741 | 740 | ); |
742 | 741 | |
743 | - return apply_filters( 'give_payments_table_bulk_actions', $actions ); |
|
742 | + return apply_filters('give_payments_table_bulk_actions', $actions); |
|
744 | 743 | } |
745 | 744 | |
746 | 745 | /** |
@@ -752,59 +751,59 @@ discard block |
||
752 | 751 | * @return void |
753 | 752 | */ |
754 | 753 | public function process_bulk_action() { |
755 | - $ids = isset( $_GET['payment'] ) ? $_GET['payment'] : false; |
|
754 | + $ids = isset($_GET['payment']) ? $_GET['payment'] : false; |
|
756 | 755 | $action = $this->current_action(); |
757 | 756 | |
758 | - if ( ! is_array( $ids ) ) { |
|
759 | - $ids = array( $ids ); |
|
757 | + if ( ! is_array($ids)) { |
|
758 | + $ids = array($ids); |
|
760 | 759 | } |
761 | 760 | |
762 | - if ( empty( $action ) ) { |
|
761 | + if (empty($action)) { |
|
763 | 762 | return; |
764 | 763 | } |
765 | 764 | |
766 | - foreach ( $ids as $id ) { |
|
765 | + foreach ($ids as $id) { |
|
767 | 766 | |
768 | 767 | // Detect when a bulk action is being triggered. |
769 | - switch ( $this->current_action() ) { |
|
768 | + switch ($this->current_action()) { |
|
770 | 769 | |
771 | 770 | case 'delete': |
772 | - give_delete_donation( $id ); |
|
771 | + give_delete_donation($id); |
|
773 | 772 | break; |
774 | 773 | |
775 | 774 | case 'set-status-publish': |
776 | - give_update_payment_status( $id, 'publish' ); |
|
775 | + give_update_payment_status($id, 'publish'); |
|
777 | 776 | break; |
778 | 777 | |
779 | 778 | case 'set-status-pending': |
780 | - give_update_payment_status( $id, 'pending' ); |
|
779 | + give_update_payment_status($id, 'pending'); |
|
781 | 780 | break; |
782 | 781 | |
783 | 782 | case 'set-status-processing': |
784 | - give_update_payment_status( $id, 'processing' ); |
|
783 | + give_update_payment_status($id, 'processing'); |
|
785 | 784 | break; |
786 | 785 | |
787 | 786 | case 'set-status-refunded': |
788 | - give_update_payment_status( $id, 'refunded' ); |
|
787 | + give_update_payment_status($id, 'refunded'); |
|
789 | 788 | break; |
790 | 789 | case 'set-status-revoked': |
791 | - give_update_payment_status( $id, 'revoked' ); |
|
790 | + give_update_payment_status($id, 'revoked'); |
|
792 | 791 | break; |
793 | 792 | |
794 | 793 | case 'set-status-failed': |
795 | - give_update_payment_status( $id, 'failed' ); |
|
794 | + give_update_payment_status($id, 'failed'); |
|
796 | 795 | break; |
797 | 796 | |
798 | 797 | case 'set-status-cancelled': |
799 | - give_update_payment_status( $id, 'cancelled' ); |
|
798 | + give_update_payment_status($id, 'cancelled'); |
|
800 | 799 | break; |
801 | 800 | |
802 | 801 | case 'set-status-abandoned': |
803 | - give_update_payment_status( $id, 'abandoned' ); |
|
802 | + give_update_payment_status($id, 'abandoned'); |
|
804 | 803 | break; |
805 | 804 | |
806 | 805 | case 'set-status-preapproval': |
807 | - give_update_payment_status( $id, 'preapproval' ); |
|
806 | + give_update_payment_status($id, 'preapproval'); |
|
808 | 807 | break; |
809 | 808 | |
810 | 809 | case 'resend-receipt': |
@@ -813,7 +812,7 @@ discard block |
||
813 | 812 | * |
814 | 813 | * @since 2.0 |
815 | 814 | */ |
816 | - do_action( 'give_donation-receipt_email_notification', $id ); |
|
815 | + do_action('give_donation-receipt_email_notification', $id); |
|
817 | 816 | break; |
818 | 817 | }// End switch(). |
819 | 818 | |
@@ -825,7 +824,7 @@ discard block |
||
825 | 824 | * |
826 | 825 | * @since 1.7 |
827 | 826 | */ |
828 | - do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() ); |
|
827 | + do_action('give_payments_table_do_bulk_action', $id, $this->current_action()); |
|
829 | 828 | }// End foreach(). |
830 | 829 | |
831 | 830 | } |
@@ -842,32 +841,32 @@ discard block |
||
842 | 841 | |
843 | 842 | $args = array(); |
844 | 843 | |
845 | - if ( isset( $_GET['user'] ) ) { |
|
846 | - $args['user'] = urldecode( $_GET['user'] ); |
|
847 | - } elseif ( isset( $_GET['donor'] ) ) { |
|
848 | - $args['donor'] = absint( $_GET['donor'] ); |
|
849 | - } elseif ( isset( $_GET['s'] ) ) { |
|
850 | - $is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false; |
|
851 | - if ( $is_user ) { |
|
852 | - $args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) ); |
|
853 | - unset( $args['s'] ); |
|
844 | + if (isset($_GET['user'])) { |
|
845 | + $args['user'] = urldecode($_GET['user']); |
|
846 | + } elseif (isset($_GET['donor'])) { |
|
847 | + $args['donor'] = absint($_GET['donor']); |
|
848 | + } elseif (isset($_GET['s'])) { |
|
849 | + $is_user = strpos($_GET['s'], strtolower('user:')) !== false; |
|
850 | + if ($is_user) { |
|
851 | + $args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s'])))); |
|
852 | + unset($args['s']); |
|
854 | 853 | } else { |
855 | - $args['s'] = sanitize_text_field( $_GET['s'] ); |
|
854 | + $args['s'] = sanitize_text_field($_GET['s']); |
|
856 | 855 | } |
857 | 856 | } |
858 | 857 | |
859 | - if ( ! empty( $_GET['start-date'] ) ) { |
|
860 | - $args['start-date'] = urldecode( $_GET['start-date'] ); |
|
858 | + if ( ! empty($_GET['start-date'])) { |
|
859 | + $args['start-date'] = urldecode($_GET['start-date']); |
|
861 | 860 | } |
862 | 861 | |
863 | - if ( ! empty( $_GET['end-date'] ) ) { |
|
864 | - $args['end-date'] = urldecode( $_GET['end-date'] ); |
|
862 | + if ( ! empty($_GET['end-date'])) { |
|
863 | + $args['end-date'] = urldecode($_GET['end-date']); |
|
865 | 864 | } |
866 | 865 | |
867 | - $args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
868 | - $args['gateway'] = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
866 | + $args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
867 | + $args['gateway'] = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
869 | 868 | |
870 | - $payment_count = give_count_payments( $args ); |
|
869 | + $payment_count = give_count_payments($args); |
|
871 | 870 | $this->complete_count = $payment_count->publish; |
872 | 871 | $this->pending_count = $payment_count->pending; |
873 | 872 | $this->processing_count = $payment_count->processing; |
@@ -878,7 +877,7 @@ discard block |
||
878 | 877 | $this->abandoned_count = $payment_count->abandoned; |
879 | 878 | $this->preapproval_count = $payment_count->preapproval; |
880 | 879 | |
881 | - foreach ( $payment_count as $count ) { |
|
880 | + foreach ($payment_count as $count) { |
|
882 | 881 | $this->total_count += $count; |
883 | 882 | } |
884 | 883 | |
@@ -896,25 +895,25 @@ discard block |
||
896 | 895 | public function payments_data() { |
897 | 896 | |
898 | 897 | $per_page = $this->per_page; |
899 | - $orderby = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID'; |
|
900 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
901 | - $user = isset( $_GET['user'] ) ? $_GET['user'] : null; |
|
902 | - $donor = isset( $_GET['donor'] ) ? $_GET['donor'] : null; |
|
903 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys(); |
|
904 | - $meta_key = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null; |
|
905 | - $year = isset( $_GET['year'] ) ? $_GET['year'] : null; |
|
906 | - $month = isset( $_GET['m'] ) ? $_GET['m'] : null; |
|
907 | - $day = isset( $_GET['day'] ) ? $_GET['day'] : null; |
|
908 | - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; |
|
909 | - $start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null; |
|
910 | - $end_date = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date; |
|
911 | - $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null; |
|
912 | - $gateway = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null; |
|
898 | + $orderby = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID'; |
|
899 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
900 | + $user = isset($_GET['user']) ? $_GET['user'] : null; |
|
901 | + $donor = isset($_GET['donor']) ? $_GET['donor'] : null; |
|
902 | + $status = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys(); |
|
903 | + $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; |
|
904 | + $year = isset($_GET['year']) ? $_GET['year'] : null; |
|
905 | + $month = isset($_GET['m']) ? $_GET['m'] : null; |
|
906 | + $day = isset($_GET['day']) ? $_GET['day'] : null; |
|
907 | + $search = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null; |
|
908 | + $start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null; |
|
909 | + $end_date = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date; |
|
910 | + $form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null; |
|
911 | + $gateway = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null; |
|
913 | 912 | |
914 | 913 | $args = array( |
915 | 914 | 'output' => 'payments', |
916 | 915 | 'number' => $per_page, |
917 | - 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null, |
|
916 | + 'page' => isset($_GET['paged']) ? $_GET['paged'] : null, |
|
918 | 917 | 'orderby' => $orderby, |
919 | 918 | 'order' => $order, |
920 | 919 | 'user' => $user, |
@@ -931,9 +930,9 @@ discard block |
||
931 | 930 | 'give_forms' => $form_id, |
932 | 931 | ); |
933 | 932 | |
934 | - if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) { |
|
933 | + if (is_string($search) && false !== strpos($search, 'txn:')) { |
|
935 | 934 | $args['search_in_notes'] = true; |
936 | - $args['s'] = trim( str_replace( 'txn:', '', $args['s'] ) ); |
|
935 | + $args['s'] = trim(str_replace('txn:', '', $args['s'])); |
|
937 | 936 | } |
938 | 937 | |
939 | 938 | /** |
@@ -941,9 +940,9 @@ discard block |
||
941 | 940 | * |
942 | 941 | * @since 1.8.18 |
943 | 942 | */ |
944 | - $args = (array) apply_filters( 'give_payment_table_payments_query', $args ); |
|
943 | + $args = (array) apply_filters('give_payment_table_payments_query', $args); |
|
945 | 944 | |
946 | - $p_query = new Give_Payments_Query( $args ); |
|
945 | + $p_query = new Give_Payments_Query($args); |
|
947 | 946 | |
948 | 947 | return $p_query->get_payments(); |
949 | 948 | |
@@ -964,17 +963,17 @@ discard block |
||
964 | 963 | */ |
965 | 964 | public function prepare_items() { |
966 | 965 | |
967 | - wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) ); |
|
966 | + wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's')); |
|
968 | 967 | |
969 | 968 | $columns = $this->get_columns(); |
970 | 969 | $hidden = array(); // No hidden columns. |
971 | 970 | $sortable = $this->get_sortable_columns(); |
972 | 971 | $data = $this->payments_data(); |
973 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
972 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
974 | 973 | |
975 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
974 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
976 | 975 | |
977 | - switch ( $status ) { |
|
976 | + switch ($status) { |
|
978 | 977 | case 'publish': |
979 | 978 | $total_items = $this->complete_count; |
980 | 979 | break; |
@@ -1007,8 +1006,8 @@ discard block |
||
1007 | 1006 | break; |
1008 | 1007 | default: |
1009 | 1008 | // Retrieve the count of the non-default-Give status. |
1010 | - $count = wp_count_posts( 'give_payment' ); |
|
1011 | - $total_items = isset( $count->{$status} ) ? $count->{$status} : 0; |
|
1009 | + $count = wp_count_posts('give_payment'); |
|
1010 | + $total_items = isset($count->{$status} ) ? $count->{$status} : 0; |
|
1012 | 1011 | break; |
1013 | 1012 | } |
1014 | 1013 | |
@@ -1019,7 +1018,7 @@ discard block |
||
1019 | 1018 | * |
1020 | 1019 | * @since 1.8.19 |
1021 | 1020 | */ |
1022 | - $total_items = (int) apply_filters( 'give_payment_table_pagination_total_count', $total_items, $this ); |
|
1021 | + $total_items = (int) apply_filters('give_payment_table_pagination_total_count', $total_items, $this); |
|
1023 | 1022 | |
1024 | 1023 | $this->set_pagination_args( |
1025 | 1024 | array( |
@@ -1027,7 +1026,7 @@ discard block |
||
1027 | 1026 | // We have to calculate the total number of items. |
1028 | 1027 | 'per_page' => $this->per_page, |
1029 | 1028 | // We have to determine how many items to show on a page. |
1030 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
1029 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
1031 | 1030 | // We have to calculate the total number of pages. |
1032 | 1031 | ) |
1033 | 1032 | ); |
@@ -187,7 +187,7 @@ |
||
187 | 187 | * @access public |
188 | 188 | * @since 1.0 |
189 | 189 | * |
190 | - * @return string|bool String if search is present, false otherwise |
|
190 | + * @return string|false String if search is present, false otherwise |
|
191 | 191 | */ |
192 | 192 | public function get_search() { |
193 | 193 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -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 |
|
51 | - 'ajax' => false,// Does this table support ajax? |
|
52 | - ) ); |
|
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 | + 'ajax' => false, // Does this table support ajax? |
|
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" role="search"> |
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 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_columns() { |
93 | 93 | $columns = array( |
94 | - 'ID' => __( 'Log ID', 'give' ), |
|
95 | - 'ip' => __( 'Request IP', 'give' ), |
|
96 | - 'date' => __( 'Date', 'give' ), |
|
97 | - 'details' => __( 'Request Details', 'give' ), |
|
94 | + 'ID' => __('Log ID', 'give'), |
|
95 | + 'ip' => __('Request IP', 'give'), |
|
96 | + 'date' => __('Date', 'give'), |
|
97 | + 'details' => __('Request Details', 'give'), |
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | return $columns; |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name |
113 | 113 | */ |
114 | - public function column_default( $item, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($item, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | default: |
117 | - return esc_attr( $item[ $column_name ] ); |
|
117 | + return esc_attr($item[$column_name]); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -128,52 +128,52 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return void |
130 | 130 | */ |
131 | - public function column_details( $item ) { |
|
132 | - echo Give()->tooltips->render_link( array( |
|
133 | - 'label' => __( 'View Request', 'give' ), |
|
131 | + public function column_details($item) { |
|
132 | + echo Give()->tooltips->render_link(array( |
|
133 | + 'label' => __('View Request', 'give'), |
|
134 | 134 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
135 | 135 | 'link' => "#TB_inline?width=640&inlineId=log-details-{$item['ID']}", |
136 | 136 | 'attributes' => array( |
137 | 137 | 'class' => 'thickbox give-error-log-details-link button button-small', |
138 | 138 | ), |
139 | - ) ); |
|
139 | + )); |
|
140 | 140 | ?> |
141 | 141 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
142 | 142 | <?php |
143 | 143 | // Print API Request. |
144 | 144 | echo sprintf( |
145 | 145 | '<p><strong>%1$s</strong></p><div>%2$s</div>', |
146 | - __( 'API Request:', 'give' ), |
|
147 | - Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_api_query', true ) |
|
146 | + __('API Request:', 'give'), |
|
147 | + Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_api_query', true) |
|
148 | 148 | ); |
149 | 149 | |
150 | 150 | // Print Log Content, if not empty. |
151 | - if ( ! empty( $item['log_content'] ) ) { |
|
151 | + if ( ! empty($item['log_content'])) { |
|
152 | 152 | echo sprintf( |
153 | 153 | '<p><strong>%1$s</strong></p><div>%2$s</div>', |
154 | - __( 'Error', 'give' ), |
|
155 | - esc_html( $item['log_content'] ) |
|
154 | + __('Error', 'give'), |
|
155 | + esc_html($item['log_content']) |
|
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Print User who requested data using API. |
160 | 160 | echo sprintf( |
161 | 161 | '<p><strong>%1$s</strong></p><div>%2$s</div>', |
162 | - __( 'API User:', 'give' ), |
|
163 | - Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_user', true ) |
|
162 | + __('API User:', 'give'), |
|
163 | + Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_user', true) |
|
164 | 164 | ); |
165 | 165 | |
166 | 166 | // Print the logged key used by API. |
167 | 167 | echo sprintf( |
168 | 168 | '<p><strong>%1$s</strong></p><div>%2$s</div>', |
169 | - __( 'API Key:', 'give' ), |
|
170 | - Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_key', true ) |
|
169 | + __('API Key:', 'give'), |
|
170 | + Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_key', true) |
|
171 | 171 | ); |
172 | 172 | |
173 | 173 | // Print the API Request Date. |
174 | 174 | echo sprintf( |
175 | 175 | '<p><strong>%1$s</strong></p><div>%2$s</div>', |
176 | - __( 'Request Date:', 'give' ), |
|
176 | + __('Request Date:', 'give'), |
|
177 | 177 | $item['log_date'] |
178 | 178 | ); |
179 | 179 | ?> |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return string|bool String if search is present, false otherwise |
191 | 191 | */ |
192 | 192 | public function get_search() { |
193 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
193 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -206,19 +206,19 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | <?php |
220 | - $this->extra_tablenav( $which ); |
|
221 | - $this->pagination( $which ); |
|
220 | + $this->extra_tablenav($which); |
|
221 | + $this->pagination($which); |
|
222 | 222 | ?> |
223 | 223 | |
224 | 224 | <br class="clear"/> |
@@ -241,40 +241,40 @@ discard block |
||
241 | 241 | $meta_query = array(); |
242 | 242 | $search = $this->get_search(); |
243 | 243 | |
244 | - if ( $search ) { |
|
245 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
244 | + if ($search) { |
|
245 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
246 | 246 | |
247 | 247 | // This is an IP address search. |
248 | 248 | $key = '_give_log_request_ip'; |
249 | 249 | |
250 | - } elseif ( is_email( $search ) ) { |
|
250 | + } elseif (is_email($search)) { |
|
251 | 251 | |
252 | 252 | // This is an email search. |
253 | - $userdata = get_user_by( 'email', $search ); |
|
253 | + $userdata = get_user_by('email', $search); |
|
254 | 254 | |
255 | - if ( $userdata ) { |
|
255 | + if ($userdata) { |
|
256 | 256 | $search = $userdata->ID; |
257 | 257 | } |
258 | 258 | |
259 | 259 | $key = '_give_log_user'; |
260 | 260 | |
261 | - } elseif ( 32 === strlen( $search ) ) { |
|
261 | + } elseif (32 === strlen($search)) { |
|
262 | 262 | |
263 | 263 | // Look for an API key. |
264 | 264 | $key = '_give_log_key'; |
265 | 265 | |
266 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
266 | + } elseif (stristr($search, 'token:')) { |
|
267 | 267 | |
268 | 268 | // Look for an API token. |
269 | - $search = str_ireplace( 'token:', '', $search ); |
|
269 | + $search = str_ireplace('token:', '', $search); |
|
270 | 270 | $key = '_give_log_token'; |
271 | 271 | |
272 | 272 | } else { |
273 | 273 | |
274 | 274 | // This is (probably) a user ID search. |
275 | - $userdata = get_userdata( $search ); |
|
275 | + $userdata = get_userdata($search); |
|
276 | 276 | |
277 | - if ( $userdata ) { |
|
277 | + if ($userdata) { |
|
278 | 278 | $search = $userdata->ID; |
279 | 279 | } |
280 | 280 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return int Current page number |
303 | 303 | */ |
304 | 304 | public function get_paged() { |
305 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
305 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - function bulk_actions( $which = '' ) { |
|
318 | + function bulk_actions($which = '') { |
|
319 | 319 | give_log_views(); |
320 | 320 | } |
321 | 321 | |
@@ -337,14 +337,14 @@ discard block |
||
337 | 337 | 'posts_per_page' => $this->per_page, |
338 | 338 | ); |
339 | 339 | |
340 | - $logs = Give()->logs->get_connected_logs( $log_query ); |
|
340 | + $logs = Give()->logs->get_connected_logs($log_query); |
|
341 | 341 | |
342 | - if ( $logs ) { |
|
343 | - foreach ( $logs as $log ) { |
|
342 | + if ($logs) { |
|
343 | + foreach ($logs as $log) { |
|
344 | 344 | |
345 | 345 | $logs_data[] = array( |
346 | 346 | 'ID' => $log->ID, |
347 | - 'ip' => Give()->logs->logmeta_db->get_meta( $log->ID, '_give_log_request_ip', true ), |
|
347 | + 'ip' => Give()->logs->logmeta_db->get_meta($log->ID, '_give_log_request_ip', true), |
|
348 | 348 | 'date' => $log->log_date, |
349 | 349 | 'log_content' => $log->log_content, |
350 | 350 | 'log_date' => $log->log_date, |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | $columns = $this->get_columns(); |
373 | 373 | $hidden = array(); // No hidden columns |
374 | 374 | $sortable = $this->get_sortable_columns(); |
375 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
375 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
376 | 376 | $this->items = $this->get_logs(); |
377 | - $total_items = Give()->logs->get_log_count( 0, 'api_request' ); |
|
377 | + $total_items = Give()->logs->get_log_count(0, 'api_request'); |
|
378 | 378 | |
379 | - $this->set_pagination_args( array( |
|
379 | + $this->set_pagination_args(array( |
|
380 | 380 | 'total_items' => $total_items, |
381 | 381 | 'per_page' => $this->per_page, |
382 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
382 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
383 | 383 | ) |
384 | 384 | ); |
385 | 385 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @param string $cache_key |
123 | 123 | * @param bool $custom_key |
124 | - * @param mixed $query_args |
|
124 | + * @param string $query_args |
|
125 | 125 | * |
126 | 126 | * @return mixed |
127 | 127 | */ |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @param bool $force If set to true then all cached values will be delete instead of only expired |
239 | 239 | * |
240 | - * @return bool |
|
240 | + * @return false|null |
|
241 | 241 | */ |
242 | 242 | public static function delete_all_expired( $force = false ) { |
243 | 243 | global $wpdb; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | * @since 2.0 |
670 | 670 | * @access private |
671 | 671 | * |
672 | - * @param $group |
|
672 | + * @param string $group |
|
673 | 673 | * |
674 | 674 | * @return mixed |
675 | 675 | */ |
@@ -722,9 +722,9 @@ |
||
722 | 722 | public static function flush_cache() { |
723 | 723 | if ( |
724 | 724 | ( Give_Admin_Settings::is_saving_settings() |
725 | - && isset( $_POST['cache'] ) |
|
726 | - && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
727 | - ) |
|
725 | + && isset( $_POST['cache'] ) |
|
726 | + && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
727 | + ) |
|
728 | 728 | || ( wp_doing_ajax() && 'give_cache_flush' === give_clean( $_GET['action'] ) ) |
729 | 729 | ) { |
730 | 730 | self::$instance->get_incrementer( true ); |
@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return static |
54 | 54 | */ |
55 | 55 | public static function get_instance() { |
56 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
56 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
57 | 57 | self::$instance = new Give_Cache(); |
58 | 58 | } |
59 | 59 | |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setup() { |
70 | 70 | // Currently enable cache only for backend. |
71 | - self::$instance->is_cache = ( defined( 'GIVE_CACHE' ) ? GIVE_CACHE : give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) ) && is_admin(); |
|
71 | + self::$instance->is_cache = (defined('GIVE_CACHE') ? GIVE_CACHE : give_is_setting_enabled(give_get_option('cache', 'enabled'))) && is_admin(); |
|
72 | 72 | |
73 | 73 | // weekly delete all expired cache. |
74 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
74 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
75 | 75 | |
76 | - add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) ); |
|
77 | - add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) ); |
|
78 | - add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 ); |
|
79 | - add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 ); |
|
76 | + add_action('save_post_give_forms', array($this, 'delete_form_related_cache')); |
|
77 | + add_action('save_post_give_payment', array($this, 'delete_payment_related_cache')); |
|
78 | + add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3); |
|
79 | + add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3); |
|
80 | 80 | |
81 | - add_action( 'give_save_settings_give_settings', array( __CLASS__, 'flush_cache' ) ); |
|
81 | + add_action('give_save_settings_give_settings', array(__CLASS__, 'flush_cache')); |
|
82 | 82 | |
83 | - add_action( 'wp', array( __CLASS__, 'prevent_caching' ) ); |
|
84 | - add_action( 'admin_notices', array( $this, '__notices' ) ); |
|
83 | + add_action('wp', array(__CLASS__, 'prevent_caching')); |
|
84 | + add_action('admin_notices', array($this, '__notices')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @credit WooCommerce |
93 | 93 | */ |
94 | 94 | public static function prevent_caching() { |
95 | - if ( ! is_blog_installed() ) { |
|
95 | + if ( ! is_blog_installed()) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | - $page_ids = array_filter( array( |
|
100 | - give_get_option( 'success_page' ), |
|
101 | - give_get_option( 'failure_page' ), |
|
102 | - give_get_option( 'history_page' ), |
|
103 | - ) ); |
|
99 | + $page_ids = array_filter(array( |
|
100 | + give_get_option('success_page'), |
|
101 | + give_get_option('failure_page'), |
|
102 | + give_get_option('history_page'), |
|
103 | + )); |
|
104 | 104 | |
105 | 105 | if ( |
106 | - is_page( $page_ids ) |
|
107 | - || is_singular( 'give_forms' ) |
|
106 | + is_page($page_ids) |
|
107 | + || is_singular('give_forms') |
|
108 | 108 | ) { |
109 | 109 | self::set_nocache_constants(); |
110 | 110 | nocache_headers(); |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return mixed |
124 | 124 | */ |
125 | - public static function set_nocache_constants( $return = true ) { |
|
126 | - give_maybe_define_constant( 'DONOTCACHEPAGE', true ); |
|
127 | - give_maybe_define_constant( 'DONOTCACHEOBJECT', true ); |
|
128 | - give_maybe_define_constant( 'DONOTCACHEDB', true ); |
|
125 | + public static function set_nocache_constants($return = true) { |
|
126 | + give_maybe_define_constant('DONOTCACHEPAGE', true); |
|
127 | + give_maybe_define_constant('DONOTCACHEOBJECT', true); |
|
128 | + give_maybe_define_constant('DONOTCACHEDB', true); |
|
129 | 129 | |
130 | 130 | return $return; |
131 | 131 | } |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | * @credit WooCommerce |
139 | 139 | */ |
140 | 140 | public function __notices() { |
141 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
141 | + if ( ! function_exists('w3tc_pgcache_flush') || ! function_exists('w3_instance')) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $config = w3_instance( 'W3_Config' ); |
|
146 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
147 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
145 | + $config = w3_instance('W3_Config'); |
|
146 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
147 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
148 | 148 | |
149 | - if ( $enabled && ! in_array( 'give', $settings, true ) ) { |
|
149 | + if ($enabled && ! in_array('give', $settings, true)) { |
|
150 | 150 | ?> |
151 | 151 | <div class="error"> |
152 | - <p><?php echo wp_kses_post( sprintf( __( 'In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give' ), '<code>give</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ) ); ?></p> |
|
152 | + <p><?php echo wp_kses_post(sprintf(__('In order for <strong>database caching</strong> to work with Give you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'give'), '<code>give</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache')))); ?></p> |
|
153 | 153 | </div> |
154 | 154 | <?php |
155 | 155 | } |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public static function get_key( $action, $query_args = null, $is_prefix = true ) { |
|
169 | + public static function get_key($action, $query_args = null, $is_prefix = true) { |
|
170 | 170 | // Bailout. |
171 | - if ( empty( $action ) ) { |
|
172 | - return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) ); |
|
171 | + if (empty($action)) { |
|
172 | + return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give')); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // Set cache key. |
176 | 176 | $cache_key = $is_prefix ? "give_cache_{$action}" : $action; |
177 | 177 | |
178 | 178 | // Bailout. |
179 | - if ( ! empty( $query_args ) ) { |
|
180 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
179 | + if ( ! empty($query_args)) { |
|
180 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @since 2.0 |
187 | 187 | */ |
188 | - return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args ); |
|
188 | + return apply_filters('give_get_cache_key', $cache_key, $action, $query_args); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -199,28 +199,28 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return mixed |
201 | 201 | */ |
202 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
203 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
204 | - if( empty( $cache_key ) ) { |
|
205 | - return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) ); |
|
206 | - }elseif ( ! $custom_key ) { |
|
207 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
202 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
203 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
204 | + if (empty($cache_key)) { |
|
205 | + return new WP_Error('give_empty_cache_key', __('Do not pass invalid empty cache key', 'give')); |
|
206 | + }elseif ( ! $custom_key) { |
|
207 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
208 | 208 | } |
209 | 209 | |
210 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
210 | + $cache_key = self::get_key($cache_key, $query_args); |
|
211 | 211 | } |
212 | 212 | |
213 | - $option = get_option( $cache_key ); |
|
213 | + $option = get_option($cache_key); |
|
214 | 214 | |
215 | 215 | // Backward compatibility (<1.8.7). |
216 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
216 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
217 | 217 | return $option; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Get current time. |
221 | - $current_time = current_time( 'timestamp', 1 ); |
|
221 | + $current_time = current_time('timestamp', 1); |
|
222 | 222 | |
223 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
223 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
224 | 224 | $option = $option['data']; |
225 | 225 | } else { |
226 | 226 | $option = false; |
@@ -242,23 +242,23 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return mixed |
244 | 244 | */ |
245 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
246 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
247 | - if ( ! $custom_key ) { |
|
248 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
245 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
246 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
247 | + if ( ! $custom_key) { |
|
248 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
249 | 249 | } |
250 | 250 | |
251 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
251 | + $cache_key = self::get_key($cache_key, $query_args); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $option_value = array( |
255 | 255 | 'data' => $data, |
256 | - 'expiration' => ! is_null( $expiration ) |
|
257 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
256 | + 'expiration' => ! is_null($expiration) |
|
257 | + ? ($expiration + current_time('timestamp', 1)) |
|
258 | 258 | : null, |
259 | 259 | ); |
260 | 260 | |
261 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
261 | + $result = update_option($cache_key, $option_value, 'no'); |
|
262 | 262 | |
263 | 263 | return $result; |
264 | 264 | } |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return bool|WP_Error |
276 | 276 | */ |
277 | - public static function delete( $cache_keys ) { |
|
277 | + public static function delete($cache_keys) { |
|
278 | 278 | $result = true; |
279 | 279 | $invalid_keys = array(); |
280 | 280 | |
281 | - if ( ! empty( $cache_keys ) ) { |
|
282 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
281 | + if ( ! empty($cache_keys)) { |
|
282 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
283 | 283 | |
284 | - foreach ( $cache_keys as $cache_key ) { |
|
285 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
284 | + foreach ($cache_keys as $cache_key) { |
|
285 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
286 | 286 | $invalid_keys[] = $cache_key; |
287 | 287 | $result = false; |
288 | 288 | } |
289 | 289 | |
290 | - delete_option( $cache_key ); |
|
290 | + delete_option($cache_key); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
294 | - if ( ! $result ) { |
|
294 | + if ( ! $result) { |
|
295 | 295 | $result = new WP_Error( |
296 | 296 | 'give_invalid_cache_key', |
297 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
297 | + __('Cache key format should be give_cache_*', 'give'), |
|
298 | 298 | $invalid_keys |
299 | 299 | ); |
300 | 300 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - public static function delete_all_expired( $force = false ) { |
|
318 | + public static function delete_all_expired($force = false) { |
|
319 | 319 | global $wpdb; |
320 | 320 | $options = $wpdb->get_results( |
321 | 321 | $wpdb->prepare( |
@@ -329,30 +329,30 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | // Bailout. |
332 | - if ( empty( $options ) ) { |
|
332 | + if (empty($options)) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | - $current_time = current_time( 'timestamp', 1 ); |
|
336 | + $current_time = current_time('timestamp', 1); |
|
337 | 337 | |
338 | 338 | // Delete log cache. |
339 | - foreach ( $options as $option ) { |
|
340 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
339 | + foreach ($options as $option) { |
|
340 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
341 | 341 | |
342 | 342 | if ( |
343 | 343 | ( |
344 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
345 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
346 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
347 | - || empty( $option['option_value']['expiration'] ) |
|
348 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
344 | + ! self::is_valid_cache_key($option['option_name']) |
|
345 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
346 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
347 | + || empty($option['option_value']['expiration']) |
|
348 | + || ($current_time < $option['option_value']['expiration']) |
|
349 | 349 | ) |
350 | 350 | && ! $force |
351 | 351 | ) { |
352 | 352 | continue; |
353 | 353 | } |
354 | 354 | |
355 | - self::delete( $option['option_name'] ); |
|
355 | + self::delete($option['option_name']); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @return array |
372 | 372 | */ |
373 | - public static function get_options_like( $option_name, $fields = false ) { |
|
373 | + public static function get_options_like($option_name, $fields = false) { |
|
374 | 374 | global $wpdb; |
375 | 375 | |
376 | 376 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
377 | 377 | |
378 | - if ( $fields ) { |
|
378 | + if ($fields) { |
|
379 | 379 | $options = $wpdb->get_results( |
380 | 380 | $wpdb->prepare( |
381 | 381 | "SELECT {$field_names } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | ); |
400 | 400 | } |
401 | 401 | |
402 | - if ( ! empty( $options ) && $fields ) { |
|
403 | - foreach ( $options as $index => $option ) { |
|
404 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
405 | - $options[ $index ] = $option; |
|
402 | + if ( ! empty($options) && $fields) { |
|
403 | + foreach ($options as $index => $option) { |
|
404 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
405 | + $options[$index] = $option; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool |
421 | 421 | */ |
422 | - public static function is_valid_cache_key( $cache_key ) { |
|
423 | - $is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
422 | + public static function is_valid_cache_key($cache_key) { |
|
423 | + $is_valid = (false !== strpos($cache_key, 'give_cache_')); |
|
424 | 424 | |
425 | 425 | |
426 | 426 | /** |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @since 2.0 |
430 | 430 | */ |
431 | - return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key ); |
|
431 | + return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed |
445 | 445 | */ |
446 | - public static function get_group( $id, $group = '' ) { |
|
446 | + public static function get_group($id, $group = '') { |
|
447 | 447 | $cached_data = null; |
448 | 448 | |
449 | 449 | // Bailout. |
450 | - if ( self::$instance->is_cache && ! empty( $id ) ) { |
|
451 | - $group = self::$instance->filter_group_name( $group ); |
|
450 | + if (self::$instance->is_cache && ! empty($id)) { |
|
451 | + $group = self::$instance->filter_group_name($group); |
|
452 | 452 | |
453 | - $cached_data = wp_cache_get( $id, $group ); |
|
453 | + $cached_data = wp_cache_get($id, $group); |
|
454 | 454 | $cached_data = false !== $cached_data ? $cached_data : null; |
455 | 455 | } |
456 | 456 | |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return bool |
472 | 472 | */ |
473 | - public static function set_group( $id, $data, $group = '', $expire = 0 ) { |
|
473 | + public static function set_group($id, $data, $group = '', $expire = 0) { |
|
474 | 474 | $status = false; |
475 | 475 | |
476 | 476 | // Bailout. |
477 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
477 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
478 | 478 | return $status; |
479 | 479 | } |
480 | 480 | |
481 | - $group = self::$instance->filter_group_name( $group ); |
|
481 | + $group = self::$instance->filter_group_name($group); |
|
482 | 482 | |
483 | - $status = wp_cache_set( $id, $data, $group, $expire ); |
|
483 | + $status = wp_cache_set($id, $data, $group, $expire); |
|
484 | 484 | |
485 | 485 | return $status; |
486 | 486 | } |
@@ -496,15 +496,15 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return bool |
498 | 498 | */ |
499 | - public static function set_db_query( $id, $data ) { |
|
499 | + public static function set_db_query($id, $data) { |
|
500 | 500 | $status = false; |
501 | 501 | |
502 | 502 | // Bailout. |
503 | - if ( ! self::$instance->is_cache || empty( $id ) ) { |
|
503 | + if ( ! self::$instance->is_cache || empty($id)) { |
|
504 | 504 | return $status; |
505 | 505 | } |
506 | 506 | |
507 | - return self::set_group( $id, $data, 'give-db-queries', 0 ); |
|
507 | + return self::set_group($id, $data, 'give-db-queries', 0); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return mixed |
519 | 519 | */ |
520 | - public static function get_db_query( $id ) { |
|
521 | - return self::get_group( $id, 'give-db-queries' ); |
|
520 | + public static function get_db_query($id) { |
|
521 | + return self::get_group($id, 'give-db-queries'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return bool |
535 | 535 | */ |
536 | - public static function delete_group( $ids, $group = '', $expire = 0 ) { |
|
536 | + public static function delete_group($ids, $group = '', $expire = 0) { |
|
537 | 537 | $status = false; |
538 | 538 | |
539 | 539 | // Bailout. |
540 | - if ( ! self::$instance->is_cache || empty( $ids ) ) { |
|
540 | + if ( ! self::$instance->is_cache || empty($ids)) { |
|
541 | 541 | return $status; |
542 | 542 | } |
543 | 543 | |
544 | 544 | $group_prefix = $group; |
545 | - $group = self::$instance->filter_group_name( $group ); |
|
545 | + $group = self::$instance->filter_group_name($group); |
|
546 | 546 | |
547 | 547 | // Delete single or multiple cache items from cache. |
548 | - if ( ! is_array( $ids ) ) { |
|
549 | - $status = wp_cache_delete( $ids, $group ); |
|
550 | - self::$instance->get_incrementer( true ); |
|
548 | + if ( ! is_array($ids)) { |
|
549 | + $status = wp_cache_delete($ids, $group); |
|
550 | + self::$instance->get_incrementer(true); |
|
551 | 551 | |
552 | 552 | /** |
553 | 553 | * Fire action when cache deleted for specific id. |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * @param string $group |
559 | 559 | * @param int $expire |
560 | 560 | */ |
561 | - do_action( "give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status ); |
|
561 | + do_action("give_deleted_{$group_prefix}_cache", $ids, $group, $expire, $status); |
|
562 | 562 | |
563 | 563 | } else { |
564 | - foreach ( $ids as $id ) { |
|
565 | - $status = wp_cache_delete( $id, $group ); |
|
566 | - self::$instance->get_incrementer( true ); |
|
564 | + foreach ($ids as $id) { |
|
565 | + $status = wp_cache_delete($id, $group); |
|
566 | + self::$instance->get_incrementer(true); |
|
567 | 567 | |
568 | 568 | /** |
569 | 569 | * Fire action when cache deleted for specific id . |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @param string $group |
575 | 575 | * @param int $expire |
576 | 576 | */ |
577 | - do_action( "give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status ); |
|
577 | + do_action("give_deleted_{$group_prefix}_cache", $id, $group, $expire, $status); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -591,15 +591,15 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @param int $form_id |
593 | 593 | */ |
594 | - public function delete_form_related_cache( $form_id ) { |
|
594 | + public function delete_form_related_cache($form_id) { |
|
595 | 595 | // If this is just a revision, don't send the email. |
596 | - if ( wp_is_post_revision( $form_id ) ) { |
|
596 | + if (wp_is_post_revision($form_id)) { |
|
597 | 597 | return; |
598 | 598 | } |
599 | 599 | |
600 | 600 | $donation_query = new Give_Payments_Query( |
601 | 601 | array( |
602 | - 'number' => - 1, |
|
602 | + 'number' => -1, |
|
603 | 603 | 'give_forms' => $form_id, |
604 | 604 | 'output' => '', |
605 | 605 | 'fields' => 'ids', |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | |
609 | 609 | $donations = $donation_query->get_payments(); |
610 | 610 | |
611 | - if ( ! empty( $donations ) ) { |
|
611 | + if ( ! empty($donations)) { |
|
612 | 612 | /* @var Give_Payment $donation */ |
613 | - foreach ( $donations as $donation_id ) { |
|
614 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
615 | - wp_cache_delete( give_get_payment_donor_id( $donation_id ), $this->filter_group_name( 'give-donors' ) ); |
|
613 | + foreach ($donations as $donation_id) { |
|
614 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
615 | + wp_cache_delete(give_get_payment_donor_id($donation_id), $this->filter_group_name('give-donors')); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | |
619 | - self::$instance->get_incrementer( true ); |
|
619 | + self::$instance->get_incrementer(true); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -628,19 +628,19 @@ discard block |
||
628 | 628 | * |
629 | 629 | * @param int $donation_id |
630 | 630 | */ |
631 | - public function delete_payment_related_cache( $donation_id ) { |
|
631 | + public function delete_payment_related_cache($donation_id) { |
|
632 | 632 | // If this is just a revision, don't send the email. |
633 | - if ( wp_is_post_revision( $donation_id ) ) { |
|
633 | + if (wp_is_post_revision($donation_id)) { |
|
634 | 634 | return; |
635 | 635 | } |
636 | 636 | |
637 | - if ( $donation_id && ( $donor_id = give_get_payment_donor_id( $donation_id ) ) ) { |
|
638 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
637 | + if ($donation_id && ($donor_id = give_get_payment_donor_id($donation_id))) { |
|
638 | + wp_cache_delete($donor_id, $this->filter_group_name('give-donors')); |
|
639 | 639 | } |
640 | 640 | |
641 | - wp_cache_delete( $donation_id, $this->filter_group_name( 'give-donations' ) ); |
|
641 | + wp_cache_delete($donation_id, $this->filter_group_name('give-donations')); |
|
642 | 642 | |
643 | - self::$instance->get_incrementer( true ); |
|
643 | + self::$instance->get_incrementer(true); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -654,18 +654,18 @@ discard block |
||
654 | 654 | * @param string $group |
655 | 655 | * @param int $expire |
656 | 656 | */ |
657 | - public function delete_donor_related_cache( $id, $group, $expire ) { |
|
658 | - $donation_ids = Give()->donors->get_column( 'payment_ids', $id ); |
|
657 | + public function delete_donor_related_cache($id, $group, $expire) { |
|
658 | + $donation_ids = Give()->donors->get_column('payment_ids', $id); |
|
659 | 659 | |
660 | - if ( ! empty( $donation_ids ) ) { |
|
661 | - $donation_ids = array_map( 'trim', (array) explode( ',', trim( $donation_ids ) ) ); |
|
660 | + if ( ! empty($donation_ids)) { |
|
661 | + $donation_ids = array_map('trim', (array) explode(',', trim($donation_ids))); |
|
662 | 662 | |
663 | - foreach ( $donation_ids as $donation ) { |
|
664 | - wp_cache_delete( $donation, $this->filter_group_name( 'give-donations' ) ); |
|
663 | + foreach ($donation_ids as $donation) { |
|
664 | + wp_cache_delete($donation, $this->filter_group_name('give-donations')); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | - self::$instance->get_incrementer( true ); |
|
668 | + self::$instance->get_incrementer(true); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -679,12 +679,12 @@ discard block |
||
679 | 679 | * @param string $group |
680 | 680 | * @param int $expire |
681 | 681 | */ |
682 | - public function delete_donations_related_cache( $id, $group, $expire ) { |
|
683 | - if ( $id && ( $donor_id = give_get_payment_donor_id( $id ) ) ) { |
|
684 | - wp_cache_delete( $donor_id, $this->filter_group_name( 'give-donors' ) ); |
|
682 | + public function delete_donations_related_cache($id, $group, $expire) { |
|
683 | + if ($id && ($donor_id = give_get_payment_donor_id($id))) { |
|
684 | + wp_cache_delete($donor_id, $this->filter_group_name('give-donors')); |
|
685 | 685 | } |
686 | 686 | |
687 | - self::$instance->get_incrementer( true ); |
|
687 | + self::$instance->get_incrementer(true); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -702,12 +702,12 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - public function get_incrementer( $refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries' ) { |
|
706 | - $incrementer_value = wp_cache_get( $incrementer_key ); |
|
705 | + public function get_incrementer($refresh = false, $incrementer_key = 'give-cache-incrementer-db-queries') { |
|
706 | + $incrementer_value = wp_cache_get($incrementer_key); |
|
707 | 707 | |
708 | - if ( false === $incrementer_value || true === $refresh ) { |
|
709 | - $incrementer_value = microtime( true ); |
|
710 | - wp_cache_set( $incrementer_key, $incrementer_value ); |
|
708 | + if (false === $incrementer_value || true === $refresh) { |
|
709 | + $incrementer_value = microtime(true); |
|
710 | + wp_cache_set($incrementer_key, $incrementer_value); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | return $incrementer_value; |
@@ -723,21 +723,21 @@ discard block |
||
723 | 723 | */ |
724 | 724 | public static function flush_cache() { |
725 | 725 | if ( |
726 | - ( Give_Admin_Settings::is_saving_settings() |
|
727 | - && isset( $_POST['cache'] ) |
|
728 | - && give_is_setting_enabled( give_clean( $_POST['cache'] ) ) |
|
726 | + (Give_Admin_Settings::is_saving_settings() |
|
727 | + && isset($_POST['cache']) |
|
728 | + && give_is_setting_enabled(give_clean($_POST['cache'])) |
|
729 | 729 | ) |
730 | - || ( wp_doing_ajax() && 'give_cache_flush' === give_clean( $_GET['action'] ) ) |
|
730 | + || (wp_doing_ajax() && 'give_cache_flush' === give_clean($_GET['action'])) |
|
731 | 731 | ) { |
732 | - self::$instance->get_incrementer( true ); |
|
733 | - self::$instance->get_incrementer( true, 'give-cache-incrementer' ); |
|
732 | + self::$instance->get_incrementer(true); |
|
733 | + self::$instance->get_incrementer(true, 'give-cache-incrementer'); |
|
734 | 734 | |
735 | 735 | /** |
736 | 736 | * Fire the action when all cache deleted. |
737 | 737 | * |
738 | 738 | * @since 2.1.0 |
739 | 739 | */ |
740 | - do_action( 'give_fluched_cache' ); |
|
740 | + do_action('give_fluched_cache'); |
|
741 | 741 | |
742 | 742 | return true; |
743 | 743 | } |
@@ -756,23 +756,23 @@ discard block |
||
756 | 756 | * |
757 | 757 | * @return mixed |
758 | 758 | */ |
759 | - private function filter_group_name( $group ) { |
|
759 | + private function filter_group_name($group) { |
|
760 | 760 | /** |
761 | 761 | * Filter the group name |
762 | 762 | * |
763 | 763 | * @since 2.1.0 |
764 | 764 | */ |
765 | - $filtered_group = apply_filters( 'give_cache_filter_group_name', '', $group ); |
|
765 | + $filtered_group = apply_filters('give_cache_filter_group_name', '', $group); |
|
766 | 766 | |
767 | - if ( empty( $filtered_group ) ) { |
|
767 | + if (empty($filtered_group)) { |
|
768 | 768 | |
769 | - switch ( $group ) { |
|
769 | + switch ($group) { |
|
770 | 770 | case 'give-db-queries': |
771 | 771 | $incrementer = self::$instance->get_incrementer(); |
772 | 772 | break; |
773 | 773 | |
774 | 774 | default: |
775 | - $incrementer = self::$instance->get_incrementer( false, 'give-cache-incrementer' ); |
|
775 | + $incrementer = self::$instance->get_incrementer(false, 'give-cache-incrementer'); |
|
776 | 776 | |
777 | 777 | } |
778 | 778 |
@@ -203,7 +203,7 @@ |
||
203 | 203 | if ( ! self::is_valid_cache_key( $cache_key ) ) { |
204 | 204 | if( empty( $cache_key ) ) { |
205 | 205 | return new WP_Error( 'give_empty_cache_key', __( 'Do not pass invalid empty cache key', 'give' ) ); |
206 | - }elseif ( ! $custom_key ) { |
|
206 | + } elseif ( ! $custom_key ) { |
|
207 | 207 | return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
208 | 208 | } |
209 | 209 |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * NOTE: This should not be called directly as it does not make necessary changes to |
208 | 208 | * the payment meta and logs. Use give_donor_delete() instead. |
209 | 209 | * |
210 | - * @param bool|string|int $_id_or_email ID or Email of Donor. |
|
210 | + * @param integer $_id_or_email ID or Email of Donor. |
|
211 | 211 | * |
212 | 212 | * @since 1.0 |
213 | 213 | * @access public |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @access public |
408 | 408 | * |
409 | 409 | * @param string $field ID or email. Default is 'id'. |
410 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
410 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
411 | 411 | * |
412 | 412 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
413 | 413 | */ |
@@ -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 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->bc_200_params(); |
43 | 43 | |
44 | 44 | // Set hooks and register table only if instance loading first time. |
45 | - if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) { |
|
45 | + if ( ! (Give()->donors instanceof Give_DB_Donors)) { |
|
46 | 46 | // Install table. |
47 | 47 | $this->register_table(); |
48 | 48 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'purchase_value' => 0.00, |
92 | 92 | 'purchase_count' => 0, |
93 | 93 | 'notes' => '', |
94 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
94 | + 'date_created' => date('Y-m-d H:i:s'), |
|
95 | 95 | 'token' => '', |
96 | 96 | 'verify_key' => '', |
97 | 97 | 'verify_throttle' => '', |
@@ -108,40 +108,40 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return int|bool |
110 | 110 | */ |
111 | - public function add( $data = array() ) { |
|
111 | + public function add($data = array()) { |
|
112 | 112 | |
113 | 113 | $defaults = array( |
114 | 114 | 'payment_ids' => '', |
115 | 115 | ); |
116 | 116 | |
117 | - $args = wp_parse_args( $data, $defaults ); |
|
117 | + $args = wp_parse_args($data, $defaults); |
|
118 | 118 | |
119 | - if ( empty( $args['email'] ) ) { |
|
119 | + if (empty($args['email'])) { |
|
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
124 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
123 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
124 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
125 | 125 | } |
126 | 126 | |
127 | - $donor = $this->get_donor_by( 'email', $args['email'] ); |
|
127 | + $donor = $this->get_donor_by('email', $args['email']); |
|
128 | 128 | |
129 | 129 | // update an existing donor. |
130 | - if ( $donor ) { |
|
130 | + if ($donor) { |
|
131 | 131 | |
132 | 132 | // Update the payment IDs attached to the donor |
133 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
133 | + if ( ! empty($args['payment_ids'])) { |
|
134 | 134 | |
135 | - if ( empty( $donor->payment_ids ) ) { |
|
135 | + if (empty($donor->payment_ids)) { |
|
136 | 136 | |
137 | 137 | $donor->payment_ids = $args['payment_ids']; |
138 | 138 | |
139 | 139 | } else { |
140 | 140 | |
141 | - $existing_ids = array_map( 'absint', explode( ',', $donor->payment_ids ) ); |
|
142 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
143 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
144 | - $donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
141 | + $existing_ids = array_map('absint', explode(',', $donor->payment_ids)); |
|
142 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
143 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
144 | + $donor->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | |
150 | 150 | } |
151 | 151 | |
152 | - $this->update( $donor->id, $args ); |
|
152 | + $this->update($donor->id, $args); |
|
153 | 153 | |
154 | 154 | return $donor->id; |
155 | 155 | |
156 | 156 | } else { |
157 | 157 | |
158 | - return $this->insert( $args, 'donor' ); |
|
158 | + return $this->insert($args, 'donor'); |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
175 | + public function update($row_id, $data = array(), $where = '') { |
|
176 | 176 | |
177 | - $status = parent::update( $row_id, $data, $where ); |
|
177 | + $status = parent::update($row_id, $data, $where); |
|
178 | 178 | |
179 | - if ( $status ) { |
|
180 | - Give_Cache::delete_group( $row_id, 'give-donors' ); |
|
179 | + if ($status) { |
|
180 | + Give_Cache::delete_group($row_id, 'give-donors'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $status; |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return int |
193 | 193 | */ |
194 | - public function insert( $data, $type = '' ) { |
|
195 | - $donor_id = parent::insert( $data, $type ); |
|
194 | + public function insert($data, $type = '') { |
|
195 | + $donor_id = parent::insert($data, $type); |
|
196 | 196 | |
197 | - if ( $donor_id ) { |
|
198 | - Give_Cache::delete_group( $donor_id, 'give-donors' ); |
|
197 | + if ($donor_id) { |
|
198 | + Give_Cache::delete_group($donor_id, 'give-donors'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return $donor_id; |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return bool|int |
216 | 216 | */ |
217 | - public function delete( $_id_or_email = false ) { |
|
217 | + public function delete($_id_or_email = false) { |
|
218 | 218 | |
219 | - if ( empty( $_id_or_email ) ) { |
|
219 | + if (empty($_id_or_email)) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
224 | - $donor = $this->get_donor_by( $column, $_id_or_email ); |
|
223 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
224 | + $donor = $this->get_donor_by($column, $_id_or_email); |
|
225 | 225 | |
226 | - if ( $donor->id > 0 ) { |
|
226 | + if ($donor->id > 0) { |
|
227 | 227 | |
228 | 228 | global $wpdb; |
229 | 229 | |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @since 1.8.14 |
234 | 234 | */ |
235 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
235 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
236 | 236 | |
237 | 237 | // Cache already deleted in delete_all_meta fn. |
238 | 238 | |
239 | - return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) ); |
|
239 | + return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d')); |
|
240 | 240 | |
241 | 241 | } else { |
242 | 242 | return false; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return bool|int |
259 | 259 | */ |
260 | - public function delete_by_user_id( $user_id = false ) { |
|
260 | + public function delete_by_user_id($user_id = false) { |
|
261 | 261 | global $wpdb; |
262 | 262 | |
263 | - if ( empty( $user_id ) ) { |
|
263 | + if (empty($user_id)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @since 1.8.14 |
271 | 271 | */ |
272 | - $donor = new Give_Donor( $user_id, true ); |
|
273 | - if ( ! empty( $donor->id ) ) { |
|
274 | - Give()->donor_meta->delete_all_meta( $donor->id ); |
|
272 | + $donor = new Give_Donor($user_id, true); |
|
273 | + if ( ! empty($donor->id)) { |
|
274 | + Give()->donor_meta->delete_all_meta($donor->id); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // Cache is already deleted in delete_all_meta fn. |
278 | 278 | |
279 | - return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) ); |
|
279 | + return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d')); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return bool True is exists, false otherwise. |
292 | 292 | */ |
293 | - public function exists( $value = '', $field = 'email' ) { |
|
293 | + public function exists($value = '', $field = 'email') { |
|
294 | 294 | |
295 | 295 | $columns = $this->get_columns(); |
296 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
296 | + if ( ! array_key_exists($field, $columns)) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
300 | + return (bool) $this->get_column_by('id', $field, $value); |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return bool |
314 | 314 | */ |
315 | - public function attach_payment( $donor_id = 0, $payment_id = 0 ) { |
|
315 | + public function attach_payment($donor_id = 0, $payment_id = 0) { |
|
316 | 316 | |
317 | - $donor = new Give_Donor( $donor_id ); |
|
317 | + $donor = new Give_Donor($donor_id); |
|
318 | 318 | |
319 | - if ( empty( $donor->id ) ) { |
|
319 | + if (empty($donor->id)) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Attach the payment, but don't increment stats, as this function previously did not |
324 | - return $donor->attach_payment( $payment_id, false ); |
|
324 | + return $donor->attach_payment($payment_id, false); |
|
325 | 325 | |
326 | 326 | } |
327 | 327 | |
@@ -336,16 +336,16 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return bool |
338 | 338 | */ |
339 | - public function remove_payment( $donor_id = 0, $payment_id = 0 ) { |
|
339 | + public function remove_payment($donor_id = 0, $payment_id = 0) { |
|
340 | 340 | |
341 | - $donor = new Give_Donor( $donor_id ); |
|
341 | + $donor = new Give_Donor($donor_id); |
|
342 | 342 | |
343 | - if ( ! $donor ) { |
|
343 | + if ( ! $donor) { |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Remove the payment, but don't decrease stats, as this function previously did not |
348 | - return $donor->remove_payment( $payment_id, false ); |
|
348 | + return $donor->remove_payment($payment_id, false); |
|
349 | 349 | |
350 | 350 | } |
351 | 351 | |
@@ -359,18 +359,18 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @return bool |
361 | 361 | */ |
362 | - public function increment_stats( $donor_id = 0, $amount = 0.00 ) { |
|
362 | + public function increment_stats($donor_id = 0, $amount = 0.00) { |
|
363 | 363 | |
364 | - $donor = new Give_Donor( $donor_id ); |
|
364 | + $donor = new Give_Donor($donor_id); |
|
365 | 365 | |
366 | - if ( empty( $donor->id ) ) { |
|
366 | + if (empty($donor->id)) { |
|
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $increased_count = $donor->increase_purchase_count(); |
371 | - $increased_value = $donor->increase_value( $amount ); |
|
371 | + $increased_value = $donor->increase_value($amount); |
|
372 | 372 | |
373 | - return ( $increased_count && $increased_value ) ? true : false; |
|
373 | + return ($increased_count && $increased_value) ? true : false; |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | |
@@ -385,18 +385,18 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return bool |
387 | 387 | */ |
388 | - public function decrement_stats( $donor_id = 0, $amount = 0.00 ) { |
|
388 | + public function decrement_stats($donor_id = 0, $amount = 0.00) { |
|
389 | 389 | |
390 | - $donor = new Give_Donor( $donor_id ); |
|
390 | + $donor = new Give_Donor($donor_id); |
|
391 | 391 | |
392 | - if ( ! $donor ) { |
|
392 | + if ( ! $donor) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | |
396 | 396 | $decreased_count = $donor->decrease_donation_count(); |
397 | - $decreased_value = $donor->decrease_value( $amount ); |
|
397 | + $decreased_value = $donor->decrease_value($amount); |
|
398 | 398 | |
399 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
399 | + return ($decreased_count && $decreased_value) ? true : false; |
|
400 | 400 | |
401 | 401 | } |
402 | 402 | |
@@ -411,44 +411,44 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return mixed Upon success, an object of the donor. Upon failure, NULL |
413 | 413 | */ |
414 | - public function get_donor_by( $field = 'id', $value = 0 ) { |
|
415 | - $value = sanitize_text_field( $value ); |
|
414 | + public function get_donor_by($field = 'id', $value = 0) { |
|
415 | + $value = sanitize_text_field($value); |
|
416 | 416 | |
417 | 417 | // Bailout. |
418 | - if ( empty( $field ) || empty( $value ) ) { |
|
418 | + if (empty($field) || empty($value)) { |
|
419 | 419 | return null; |
420 | 420 | } |
421 | 421 | |
422 | 422 | // Verify values. |
423 | - if ( 'id' === $field || 'user_id' === $field ) { |
|
423 | + if ('id' === $field || 'user_id' === $field) { |
|
424 | 424 | // Make sure the value is numeric to avoid casting objects, for example, |
425 | 425 | // to int 1. |
426 | - if ( ! is_numeric( $value ) ) { |
|
426 | + if ( ! is_numeric($value)) { |
|
427 | 427 | return false; |
428 | 428 | } |
429 | 429 | |
430 | - $value = absint( $value ); |
|
430 | + $value = absint($value); |
|
431 | 431 | |
432 | - if ( $value < 1 ) { |
|
432 | + if ($value < 1) { |
|
433 | 433 | return false; |
434 | 434 | } |
435 | 435 | |
436 | - } elseif ( 'email' === $field ) { |
|
436 | + } elseif ('email' === $field) { |
|
437 | 437 | |
438 | - if ( ! is_email( $value ) ) { |
|
438 | + if ( ! is_email($value)) { |
|
439 | 439 | return false; |
440 | 440 | } |
441 | 441 | |
442 | - $value = trim( $value ); |
|
442 | + $value = trim($value); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | // Bailout |
446 | - if ( ! $value ) { |
|
446 | + if ( ! $value) { |
|
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | |
450 | 450 | // Set query params. |
451 | - switch ( $field ) { |
|
451 | + switch ($field) { |
|
452 | 452 | case 'id': |
453 | 453 | $args['donor'] = $value; |
454 | 454 | break; |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | // Get donors. |
466 | - $donor = new Give_Donors_Query( $args ); |
|
466 | + $donor = new Give_Donors_Query($args); |
|
467 | 467 | |
468 | - if ( ! $donor = $donor->get_donors() ) { |
|
468 | + if ( ! $donor = $donor->get_donors()) { |
|
469 | 469 | // Look for donor from an additional email. |
470 | 470 | $args = array( |
471 | 471 | 'meta_query' => array( |
@@ -476,15 +476,15 @@ discard block |
||
476 | 476 | ), |
477 | 477 | ); |
478 | 478 | |
479 | - $donor = new Give_Donors_Query( $args ); |
|
479 | + $donor = new Give_Donors_Query($args); |
|
480 | 480 | $donor = $donor->get_donors(); |
481 | 481 | |
482 | - if ( empty( $donor ) ) { |
|
482 | + if (empty($donor)) { |
|
483 | 483 | return false; |
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | - return current( $donor ); |
|
487 | + return current($donor); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return array|object|null Donors array or object. Null if not found. |
499 | 499 | */ |
500 | - public function get_donors( $args = array() ) { |
|
501 | - $this->bc_1814_params( $args ); |
|
500 | + public function get_donors($args = array()) { |
|
501 | + $this->bc_1814_params($args); |
|
502 | 502 | |
503 | - $donors = new Give_Donors_Query( $args ); |
|
503 | + $donors = new Give_Donors_Query($args); |
|
504 | 504 | |
505 | 505 | return $donors->get_donors(); |
506 | 506 | |
@@ -517,21 +517,21 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return int Total number of donors. |
519 | 519 | */ |
520 | - public function count( $args = array() ) { |
|
521 | - $this->bc_1814_params( $args ); |
|
520 | + public function count($args = array()) { |
|
521 | + $this->bc_1814_params($args); |
|
522 | 522 | $args['count'] = true; |
523 | 523 | |
524 | - $cache_key = md5( 'give_donors_count' . serialize( $args ) ); |
|
525 | - $count = Give_Cache::get_group( $cache_key, 'donors' ); |
|
524 | + $cache_key = md5('give_donors_count'.serialize($args)); |
|
525 | + $count = Give_Cache::get_group($cache_key, 'donors'); |
|
526 | 526 | |
527 | - if ( is_null( $count ) ) { |
|
528 | - $donors = new Give_Donors_Query( $args ); |
|
527 | + if (is_null($count)) { |
|
528 | + $donors = new Give_Donors_Query($args); |
|
529 | 529 | $count = $donors->get_donors(); |
530 | 530 | |
531 | - Give_Cache::set_group( $cache_key, $count, 'donors', 3600 ); |
|
531 | + Give_Cache::set_group($cache_key, $count, 'donors', 3600); |
|
532 | 532 | } |
533 | 533 | |
534 | - return absint( $count ); |
|
534 | + return absint($count); |
|
535 | 535 | |
536 | 536 | } |
537 | 537 | |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function create_table() { |
547 | 547 | |
548 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
548 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
549 | 549 | |
550 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
550 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
551 | 551 | id bigint(20) NOT NULL AUTO_INCREMENT, |
552 | 552 | user_id bigint(20) NOT NULL, |
553 | 553 | email varchar(50) NOT NULL, |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | KEY user (user_id) |
566 | 566 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
567 | 567 | |
568 | - dbDelta( $sql ); |
|
568 | + dbDelta($sql); |
|
569 | 569 | |
570 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
570 | + update_option($this->table_name.'_db_version', $this->version); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | global $wpdb; |
583 | 583 | |
584 | 584 | if ( |
585 | - ! give_has_upgrade_completed( 'v20_rename_donor_tables' ) && |
|
586 | - $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) ) |
|
585 | + ! give_has_upgrade_completed('v20_rename_donor_tables') && |
|
586 | + $wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers")) |
|
587 | 587 | ) { |
588 | 588 | $wpdb->donors = $this->table_name = "{$wpdb->prefix}give_customers"; |
589 | 589 | } |
@@ -597,41 +597,41 @@ discard block |
||
597 | 597 | * |
598 | 598 | * @param $args |
599 | 599 | */ |
600 | - private function bc_1814_params( &$args ) { |
|
600 | + private function bc_1814_params(&$args) { |
|
601 | 601 | // Backward compatibility: user_id |
602 | - if ( ! empty( $args['user_id'] ) ) { |
|
602 | + if ( ! empty($args['user_id'])) { |
|
603 | 603 | $args['user'] = $args['user_id']; |
604 | 604 | } |
605 | 605 | |
606 | 606 | // Backward compatibility: id |
607 | - if ( ! empty( $args['id'] ) ) { |
|
607 | + if ( ! empty($args['id'])) { |
|
608 | 608 | $args['donor'] = $args['id']; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // Backward compatibility: name |
612 | - if ( ! empty( $args['name'] ) ) { |
|
612 | + if ( ! empty($args['name'])) { |
|
613 | 613 | $args['s'] = "name:{$args['name']}"; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // Backward compatibility: date |
617 | 617 | // Donors created for a specific date or in a date range. |
618 | - if ( ! empty( $args['date'] ) ) { |
|
618 | + if ( ! empty($args['date'])) { |
|
619 | 619 | |
620 | - if ( is_array( $args['date'] ) ) { |
|
620 | + if (is_array($args['date'])) { |
|
621 | 621 | |
622 | - if ( ! empty( $args['date']['start'] ) ) { |
|
623 | - $args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
622 | + if ( ! empty($args['date']['start'])) { |
|
623 | + $args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
624 | 624 | } |
625 | 625 | |
626 | - if ( ! empty( $args['date']['end'] ) ) { |
|
627 | - $args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
626 | + if ( ! empty($args['date']['end'])) { |
|
627 | + $args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | } else { |
631 | 631 | |
632 | - $args['date_query']['year'] = date( 'Y', strtotime( $args['date'] ) ); |
|
633 | - $args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) ); |
|
634 | - $args['date_query']['day'] = date( 'd', strtotime( $args['date'] ) ); |
|
632 | + $args['date_query']['year'] = date('Y', strtotime($args['date'])); |
|
633 | + $args['date_query']['month'] = date('m', strtotime($args['date'])); |
|
634 | + $args['date_query']['day'] = date('d', strtotime($args['date'])); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | } |
@@ -512,7 +512,7 @@ |
||
512 | 512 | * @since 1.7 |
513 | 513 | * @access public |
514 | 514 | * |
515 | - * @return bool |
|
515 | + * @return false|null |
|
516 | 516 | */ |
517 | 517 | public function delete_cache() { |
518 | 518 | // Add log related keys to delete. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * Setup properties |
54 | 54 | */ |
55 | 55 | |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs.php'; |
|
57 | - require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs-meta.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs.php'; |
|
57 | + require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs-meta.php'; |
|
58 | 58 | $this->log_db = new Give_DB_Logs(); |
59 | 59 | $this->logmeta_db = new Give_DB_Log_Meta(); |
60 | 60 | |
@@ -62,22 +62,22 @@ discard block |
||
62 | 62 | * Setup hooks. |
63 | 63 | */ |
64 | 64 | |
65 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) ); |
|
66 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) ); |
|
67 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) ); |
|
68 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) ); |
|
69 | - add_action( 'update_log_metadata', array( $this, 'bc_200_set_payment_as_log_parent' ), 10, 4 ); |
|
65 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
66 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
67 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
68 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
69 | + add_action('update_log_metadata', array($this, 'bc_200_set_payment_as_log_parent'), 10, 4); |
|
70 | 70 | |
71 | 71 | // Backward compatibility. |
72 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
72 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
73 | 73 | // Create the log post type |
74 | - add_action( 'init', array( $this, 'register_post_type' ), -2 ); |
|
74 | + add_action('init', array($this, 'register_post_type'), -2); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Create types taxonomy and default types |
78 | 78 | // @todo: remove this taxonomy, some addon use this taxonomy with there custom log post type for example: recurring |
79 | 79 | // Do not use this taxonomy with your log type because we will remove it in future releases. |
80 | - add_action( 'init', array( $this, 'register_taxonomy' ), -2 ); |
|
80 | + add_action('init', array($this, 'register_taxonomy'), -2); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /* Logs post type */ |
96 | 96 | $log_args = array( |
97 | 97 | 'labels' => array( |
98 | - 'name' => esc_html__( 'Logs', 'give' ), |
|
98 | + 'name' => esc_html__('Logs', 'give'), |
|
99 | 99 | ), |
100 | 100 | 'public' => false, |
101 | 101 | 'exclude_from_search' => true, |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | 'query_var' => false, |
105 | 105 | 'rewrite' => false, |
106 | 106 | 'capability_type' => 'post', |
107 | - 'supports' => array( 'title', 'editor' ), |
|
107 | + 'supports' => array('title', 'editor'), |
|
108 | 108 | 'can_export' => true, |
109 | 109 | ); |
110 | 110 | |
111 | - register_post_type( 'give_log', $log_args ); |
|
111 | + register_post_type('give_log', $log_args); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | * @return void |
123 | 123 | */ |
124 | 124 | public function register_taxonomy() { |
125 | - register_taxonomy( 'give_log_type', 'give_log', array( |
|
125 | + register_taxonomy('give_log_type', 'give_log', array( |
|
126 | 126 | 'public' => false, |
127 | - ) ); |
|
127 | + )); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'update', |
146 | 146 | ); |
147 | 147 | |
148 | - return apply_filters( 'give_log_types', $terms ); |
|
148 | + return apply_filters('give_log_types', $terms); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return bool Whether log type is valid. |
162 | 162 | */ |
163 | - public function valid_type( $type ) { |
|
164 | - return in_array( $type, $this->log_types() ); |
|
163 | + public function valid_type($type) { |
|
164 | + return in_array($type, $this->log_types()); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return int Log ID. |
182 | 182 | */ |
183 | - public function add( $title = '', $message = '', $parent = 0, $type = '' ) { |
|
183 | + public function add($title = '', $message = '', $parent = 0, $type = '') { |
|
184 | 184 | $log_data = array( |
185 | 185 | 'post_title' => $title, |
186 | 186 | 'post_content' => $message, |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | 'log_type' => $type, |
189 | 189 | ); |
190 | 190 | |
191 | - return $this->insert_log( $log_data ); |
|
191 | + return $this->insert_log($log_data); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return array An array of the connected logs. |
207 | 207 | */ |
208 | - public function get_logs( $object_id = 0, $type = '', $paged = null ) { |
|
209 | - return $this->get_connected_logs( array( |
|
208 | + public function get_logs($object_id = 0, $type = '', $paged = null) { |
|
209 | + return $this->get_connected_logs(array( |
|
210 | 210 | 'log_parent' => $object_id, |
211 | 211 | 'paged' => $paged, |
212 | 212 | 'log_type' => $type, |
213 | - ) ); |
|
213 | + )); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return int The ID of the newly created log item. |
226 | 226 | */ |
227 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
227 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
228 | 228 | $log_id = 0; |
229 | 229 | |
230 | 230 | $defaults = array( |
@@ -237,28 +237,28 @@ discard block |
||
237 | 237 | 'post_status' => 'publish', |
238 | 238 | ); |
239 | 239 | |
240 | - $args = wp_parse_args( $log_data, $defaults ); |
|
241 | - $this->bc_200_validate_params( $args, $log_meta ); |
|
240 | + $args = wp_parse_args($log_data, $defaults); |
|
241 | + $this->bc_200_validate_params($args, $log_meta); |
|
242 | 242 | |
243 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
243 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
244 | 244 | global $wpdb; |
245 | 245 | |
246 | 246 | // Backward Compatibility. |
247 | - if ( ! $wpdb->get_var( "SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1" ) ) { |
|
248 | - $latest_log_id = $wpdb->get_var( "SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1" ); |
|
249 | - $latest_log_id = empty( $latest_log_id ) ? 1 : ++ $latest_log_id; |
|
247 | + if ( ! $wpdb->get_var("SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1")) { |
|
248 | + $latest_log_id = $wpdb->get_var("SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1"); |
|
249 | + $latest_log_id = empty($latest_log_id) ? 1 : ++ $latest_log_id; |
|
250 | 250 | |
251 | 251 | $args['ID'] = $latest_log_id; |
252 | - $this->log_db->insert( $args ); |
|
252 | + $this->log_db->insert($args); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - $log_id = $this->log_db->add( $args ); |
|
256 | + $log_id = $this->log_db->add($args); |
|
257 | 257 | |
258 | 258 | // Set log meta, if any |
259 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
260 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
261 | - $this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
259 | + if ($log_id && ! empty($log_meta)) { |
|
260 | + foreach ((array) $log_meta as $key => $meta) { |
|
261 | + $this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return bool|null True if successful, false otherwise. |
282 | 282 | */ |
283 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
283 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
284 | 284 | $log_id = 0; |
285 | 285 | |
286 | 286 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @param array $log_data Log entry data. |
292 | 292 | * @param array $log_meta Log entry meta. |
293 | 293 | */ |
294 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
294 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
295 | 295 | |
296 | 296 | $defaults = array( |
297 | 297 | 'log_parent' => 0, |
@@ -301,28 +301,28 @@ discard block |
||
301 | 301 | 'post_status' => 'publish', |
302 | 302 | ); |
303 | 303 | |
304 | - $args = wp_parse_args( $log_data, $defaults ); |
|
305 | - $this->bc_200_validate_params( $args, $log_meta ); |
|
304 | + $args = wp_parse_args($log_data, $defaults); |
|
305 | + $this->bc_200_validate_params($args, $log_meta); |
|
306 | 306 | |
307 | 307 | // Store the log entry |
308 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
308 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
309 | 309 | // Backward compatibility. |
310 | - $log_id = wp_update_post( $args ); |
|
310 | + $log_id = wp_update_post($args); |
|
311 | 311 | |
312 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
313 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
314 | - if ( ! empty( $meta ) ) { |
|
315 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
312 | + if ($log_id && ! empty($log_meta)) { |
|
313 | + foreach ((array) $log_meta as $key => $meta) { |
|
314 | + if ( ! empty($meta)) { |
|
315 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | } |
319 | 319 | } else { |
320 | - $log_id = $this->log_db->add( $args ); |
|
320 | + $log_id = $this->log_db->add($args); |
|
321 | 321 | |
322 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
323 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
324 | - if ( ! empty( $meta ) ) { |
|
325 | - $this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
322 | + if ($log_id && ! empty($log_meta)) { |
|
323 | + foreach ((array) $log_meta as $key => $meta) { |
|
324 | + if ( ! empty($meta)) { |
|
325 | + $this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param array $log_data Log entry data. |
338 | 338 | * @param array $log_meta Log entry meta. |
339 | 339 | */ |
340 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
340 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -354,30 +354,30 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return array|false Array if logs were found, false otherwise. |
356 | 356 | */ |
357 | - public function get_connected_logs( $args = array() ) { |
|
357 | + public function get_connected_logs($args = array()) { |
|
358 | 358 | $logs = array(); |
359 | 359 | |
360 | - $defaults = array( |
|
360 | + $defaults = array( |
|
361 | 361 | 'number' => 20, |
362 | - 'paged' => get_query_var( 'paged' ), |
|
362 | + 'paged' => get_query_var('paged'), |
|
363 | 363 | 'log_type' => false, |
364 | 364 | |
365 | 365 | // Backward compatibility. |
366 | 366 | 'post_type' => 'give_log', |
367 | 367 | 'post_status' => 'publish', |
368 | 368 | ); |
369 | - $query_args = wp_parse_args( $args, $defaults ); |
|
370 | - $this->bc_200_validate_params( $query_args ); |
|
369 | + $query_args = wp_parse_args($args, $defaults); |
|
370 | + $this->bc_200_validate_params($query_args); |
|
371 | 371 | |
372 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
372 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
373 | 373 | // Backward compatibility. |
374 | - $logs = get_posts( $query_args ); |
|
375 | - $this->bc_200_add_new_properties( $logs ); |
|
374 | + $logs = get_posts($query_args); |
|
375 | + $this->bc_200_add_new_properties($logs); |
|
376 | 376 | } else { |
377 | - $logs = $this->log_db->get_logs( $query_args ); |
|
377 | + $logs = $this->log_db->get_logs($query_args); |
|
378 | 378 | } |
379 | 379 | |
380 | - return ( ! empty( $logs ) ? $logs : false ); |
|
380 | + return ( ! empty($logs) ? $logs : false); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -395,41 +395,41 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return int Log count. |
397 | 397 | */ |
398 | - public function get_log_count( $object_id = 0, $type = '', $meta_query = null, $date_query = null ) { |
|
398 | + public function get_log_count($object_id = 0, $type = '', $meta_query = null, $date_query = null) { |
|
399 | 399 | $logs_count = 0; |
400 | 400 | |
401 | 401 | $query_args = array( |
402 | - 'number' => - 1, |
|
402 | + 'number' => -1, |
|
403 | 403 | |
404 | 404 | // Backward comatibility. |
405 | 405 | 'post_type' => 'give_log', |
406 | 406 | 'post_status' => 'publish', |
407 | 407 | ); |
408 | 408 | |
409 | - if ( $object_id ) { |
|
409 | + if ($object_id) { |
|
410 | 410 | $query_args['log_parent'] = $object_id; |
411 | 411 | } |
412 | 412 | |
413 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
413 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
414 | 414 | $query_args['log_type'] = $type; |
415 | 415 | } |
416 | 416 | |
417 | - if ( ! empty( $meta_query ) ) { |
|
417 | + if ( ! empty($meta_query)) { |
|
418 | 418 | $query_args['meta_query'] = $meta_query; |
419 | 419 | } |
420 | 420 | |
421 | - if ( ! empty( $date_query ) ) { |
|
421 | + if ( ! empty($date_query)) { |
|
422 | 422 | $query_args['date_query'] = $date_query; |
423 | 423 | } |
424 | 424 | |
425 | - $this->bc_200_validate_params( $query_args ); |
|
425 | + $this->bc_200_validate_params($query_args); |
|
426 | 426 | |
427 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
427 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
428 | 428 | // Backward compatibility. |
429 | - $logs = new WP_Query( $query_args ); |
|
429 | + $logs = new WP_Query($query_args); |
|
430 | 430 | $logs_count = (int) $logs->post_count; |
431 | 431 | } else { |
432 | - $logs_count = $this->log_db->count( $query_args ); |
|
432 | + $logs_count = $this->log_db->count($query_args); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | return $logs_count; |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @return void |
451 | 451 | */ |
452 | - public function delete_logs( $object_id = 0, $type = '', $meta_query = null ) { |
|
452 | + public function delete_logs($object_id = 0, $type = '', $meta_query = null) { |
|
453 | 453 | $query_args = array( |
454 | 454 | 'log_parent' => $object_id, |
455 | - 'number' => - 1, |
|
455 | + 'number' => -1, |
|
456 | 456 | 'fields' => 'ID', |
457 | 457 | |
458 | 458 | // Backward compatibility. |
@@ -460,32 +460,32 @@ discard block |
||
460 | 460 | 'post_status' => 'publish', |
461 | 461 | ); |
462 | 462 | |
463 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
463 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
464 | 464 | $query_args['log_type'] = $type; |
465 | 465 | } |
466 | 466 | |
467 | - if ( ! empty( $meta_query ) ) { |
|
467 | + if ( ! empty($meta_query)) { |
|
468 | 468 | $query_args['meta_query'] = $meta_query; |
469 | 469 | } |
470 | 470 | |
471 | - $this->bc_200_validate_params( $query_args ); |
|
471 | + $this->bc_200_validate_params($query_args); |
|
472 | 472 | |
473 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
473 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
474 | 474 | // Backward compatibility. |
475 | - $logs = get_posts( $query_args ); |
|
475 | + $logs = get_posts($query_args); |
|
476 | 476 | |
477 | - if ( $logs ) { |
|
478 | - foreach ( $logs as $log ) { |
|
479 | - wp_delete_post( $log, true ); |
|
477 | + if ($logs) { |
|
478 | + foreach ($logs as $log) { |
|
479 | + wp_delete_post($log, true); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | } else { |
483 | - $logs = $this->log_db->get_logs( $query_args ); |
|
483 | + $logs = $this->log_db->get_logs($query_args); |
|
484 | 484 | |
485 | - if ( $logs ) { |
|
486 | - foreach ( $logs as $log ) { |
|
487 | - if ( $this->log_db->delete( $log->ID ) ) { |
|
488 | - $this->logmeta_db->delete_row( $log->ID ); |
|
485 | + if ($logs) { |
|
486 | + foreach ($logs as $log) { |
|
487 | + if ($this->log_db->delete($log->ID)) { |
|
488 | + $this->logmeta_db->delete_row($log->ID); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | } |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @param int $post_id |
504 | 504 | */ |
505 | - public function background_process_delete_cache( $post_id ) { |
|
505 | + public function background_process_delete_cache($post_id) { |
|
506 | 506 | // Delete log cache immediately |
507 | - wp_schedule_single_event( time() - 5, 'give_delete_log_cache' ); |
|
507 | + wp_schedule_single_event(time() - 5, 'give_delete_log_cache'); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -517,17 +517,17 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function delete_cache() { |
519 | 519 | // Add log related keys to delete. |
520 | - $cache_give_logs = Give_Cache::get_options_like( 'give_logs' ); |
|
521 | - $cache_give_log_count = Give_Cache::get_options_like( 'log_count' ); |
|
520 | + $cache_give_logs = Give_Cache::get_options_like('give_logs'); |
|
521 | + $cache_give_log_count = Give_Cache::get_options_like('log_count'); |
|
522 | 522 | |
523 | - $cache_option_names = array_merge( $cache_give_logs, $cache_give_log_count ); |
|
523 | + $cache_option_names = array_merge($cache_give_logs, $cache_give_log_count); |
|
524 | 524 | |
525 | 525 | // Bailout. |
526 | - if ( empty( $cache_option_names ) ) { |
|
526 | + if (empty($cache_option_names)) { |
|
527 | 527 | return false; |
528 | 528 | } |
529 | 529 | |
530 | - Give_Cache::delete( $cache_option_names ); |
|
530 | + Give_Cache::delete($cache_option_names); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param array $log_query |
540 | 540 | * @param array $log_meta |
541 | 541 | */ |
542 | - private function bc_200_validate_params( &$log_query, &$log_meta = array() ) { |
|
542 | + private function bc_200_validate_params(&$log_query, &$log_meta = array()) { |
|
543 | 543 | $query_params = array( |
544 | 544 | 'log_title' => 'post_title', |
545 | 545 | 'log_parent' => 'post_parent', |
@@ -551,41 +551,41 @@ discard block |
||
551 | 551 | 'meta_query' => 'meta_query', |
552 | 552 | ); |
553 | 553 | |
554 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
554 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
555 | 555 | // Set old params. |
556 | - foreach ( $query_params as $new_query_param => $old_query_param ) { |
|
556 | + foreach ($query_params as $new_query_param => $old_query_param) { |
|
557 | 557 | |
558 | - if ( isset( $log_query[ $old_query_param ] ) && empty( $log_query[ $new_query_param ] ) ) { |
|
559 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ]; |
|
558 | + if (isset($log_query[$old_query_param]) && empty($log_query[$new_query_param])) { |
|
559 | + $log_query[$new_query_param] = $log_query[$old_query_param]; |
|
560 | 560 | continue; |
561 | - } elseif ( ! isset( $log_query[ $new_query_param ] ) ) { |
|
561 | + } elseif ( ! isset($log_query[$new_query_param])) { |
|
562 | 562 | continue; |
563 | - } elseif( empty( $log_query[ $new_query_param ] ) ) { |
|
563 | + } elseif (empty($log_query[$new_query_param])) { |
|
564 | 564 | continue; |
565 | 565 | } |
566 | 566 | |
567 | - switch ( $new_query_param ) { |
|
567 | + switch ($new_query_param) { |
|
568 | 568 | case 'log_type': |
569 | 569 | $log_query['tax_query'] = array( |
570 | 570 | array( |
571 | 571 | 'taxonomy' => 'give_log_type', |
572 | 572 | 'field' => 'slug', |
573 | - 'terms' => $log_query[ $new_query_param ], |
|
573 | + 'terms' => $log_query[$new_query_param], |
|
574 | 574 | ), |
575 | 575 | ); |
576 | 576 | break; |
577 | 577 | |
578 | 578 | case 'meta_query': |
579 | - if( ! empty( $log_query['meta_query'] ) && empty( $log_query['post_parent'] ) ) { |
|
580 | - foreach ( $log_query['meta_query'] as $index => $meta_query ){ |
|
581 | - if( ! is_array( $meta_query ) || empty( $meta_query['key'] ) ) { |
|
579 | + if ( ! empty($log_query['meta_query']) && empty($log_query['post_parent'])) { |
|
580 | + foreach ($log_query['meta_query'] as $index => $meta_query) { |
|
581 | + if ( ! is_array($meta_query) || empty($meta_query['key'])) { |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | |
585 | - switch ( $meta_query['key'] ) { |
|
585 | + switch ($meta_query['key']) { |
|
586 | 586 | case '_give_log_form_id': |
587 | 587 | $log_query['post_parent'] = $meta_query['value']; |
588 | - unset( $log_query['meta_query'][$index] ); |
|
588 | + unset($log_query['meta_query'][$index]); |
|
589 | 589 | break; |
590 | 590 | } |
591 | 591 | } |
@@ -593,40 +593,40 @@ discard block |
||
593 | 593 | break; |
594 | 594 | |
595 | 595 | default: |
596 | - switch( $new_query_param ){ |
|
596 | + switch ($new_query_param) { |
|
597 | 597 | case 'log_parent': |
598 | 598 | $log_query['meta_query'][] = array( |
599 | 599 | 'key' => '_give_log_payment_id', |
600 | - 'value' => $log_query[ $new_query_param ] |
|
600 | + 'value' => $log_query[$new_query_param] |
|
601 | 601 | ); |
602 | 602 | |
603 | 603 | break; |
604 | 604 | |
605 | 605 | default: |
606 | - $log_query[ $old_query_param ] = $log_query[ $new_query_param ]; |
|
606 | + $log_query[$old_query_param] = $log_query[$new_query_param]; |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | } |
610 | 610 | } else { |
611 | 611 | // Set only old params. |
612 | - $query_params = array_flip( $query_params ); |
|
613 | - foreach ( $query_params as $old_query_param => $new_query_param ) { |
|
614 | - if ( isset( $log_query[ $new_query_param ] ) && empty( $log_query[ $old_query_param ] ) ) { |
|
615 | - $log_query[ $old_query_param ] = $log_query[ $new_query_param ]; |
|
612 | + $query_params = array_flip($query_params); |
|
613 | + foreach ($query_params as $old_query_param => $new_query_param) { |
|
614 | + if (isset($log_query[$new_query_param]) && empty($log_query[$old_query_param])) { |
|
615 | + $log_query[$old_query_param] = $log_query[$new_query_param]; |
|
616 | 616 | continue; |
617 | - } elseif ( ! isset( $log_query[ $old_query_param ] ) ) { |
|
617 | + } elseif ( ! isset($log_query[$old_query_param])) { |
|
618 | 618 | continue; |
619 | 619 | } |
620 | 620 | |
621 | - switch ( $old_query_param ) { |
|
621 | + switch ($old_query_param) { |
|
622 | 622 | case 'tax_query': |
623 | - if ( isset( $log_query[ $old_query_param ][0]['terms'] ) ) { |
|
624 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ][0]['terms']; |
|
623 | + if (isset($log_query[$old_query_param][0]['terms'])) { |
|
624 | + $log_query[$new_query_param] = $log_query[$old_query_param][0]['terms']; |
|
625 | 625 | } |
626 | 626 | break; |
627 | 627 | |
628 | 628 | default: |
629 | - $log_query[ $new_query_param ] = $log_query[ $old_query_param ]; |
|
629 | + $log_query[$new_query_param] = $log_query[$old_query_param]; |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | } |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @param array $logs |
642 | 642 | */ |
643 | - private function bc_200_add_new_properties( &$logs ) { |
|
644 | - if ( empty( $logs ) ) { |
|
643 | + private function bc_200_add_new_properties(&$logs) { |
|
644 | + if (empty($logs)) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | |
@@ -654,30 +654,30 @@ discard block |
||
654 | 654 | 'log_type' => 'give_log_type', |
655 | 655 | ); |
656 | 656 | |
657 | - if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) { |
|
658 | - foreach ( $logs as $index => $log ) { |
|
659 | - foreach ( $query_params as $new_query_param => $old_query_param ) { |
|
660 | - if ( ! property_exists( $log, $old_query_param ) ) { |
|
657 | + if ( ! give_has_upgrade_completed('v20_logs_upgrades')) { |
|
658 | + foreach ($logs as $index => $log) { |
|
659 | + foreach ($query_params as $new_query_param => $old_query_param) { |
|
660 | + if ( ! property_exists($log, $old_query_param)) { |
|
661 | 661 | /** |
662 | 662 | * Set unmatched properties. |
663 | 663 | */ |
664 | 664 | |
665 | 665 | // 1. log_type |
666 | - $term = get_the_terms( $log->ID, 'give_log_type' ); |
|
667 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
666 | + $term = get_the_terms($log->ID, 'give_log_type'); |
|
667 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
668 | 668 | |
669 | - $logs[ $index ]->{$new_query_param} = ! empty( $term ) ? $term->slug : ''; |
|
669 | + $logs[$index]->{$new_query_param} = ! empty($term) ? $term->slug : ''; |
|
670 | 670 | |
671 | 671 | continue; |
672 | 672 | } |
673 | 673 | |
674 | - switch ( $old_query_param ) { |
|
674 | + switch ($old_query_param) { |
|
675 | 675 | case 'post_parent': |
676 | - $logs[ $index ]->{$new_query_param} = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
676 | + $logs[$index]->{$new_query_param} = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
677 | 677 | break; |
678 | 678 | |
679 | 679 | default: |
680 | - $logs[ $index ]->{$new_query_param} = $log->{$old_query_param}; |
|
680 | + $logs[$index]->{$new_query_param} = $log->{$old_query_param}; |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | } |
@@ -697,10 +697,10 @@ discard block |
||
697 | 697 | * |
698 | 698 | * @return mixed |
699 | 699 | */ |
700 | - public function bc_200_set_payment_as_log_parent( $check, $log_id, $meta_key, $meta_value ) { |
|
700 | + public function bc_200_set_payment_as_log_parent($check, $log_id, $meta_key, $meta_value) { |
|
701 | 701 | global $wpdb; |
702 | 702 | $update_status = false; |
703 | - $post_type = get_post_type( $log_id ); |
|
703 | + $post_type = get_post_type($log_id); |
|
704 | 704 | |
705 | 705 | // Bailout. |
706 | 706 | if ( |
@@ -720,9 +720,9 @@ discard block |
||
720 | 720 | ) |
721 | 721 | ); |
722 | 722 | |
723 | - if ( $form_id ) { |
|
724 | - $this->logmeta_db->delete_meta( $log_id, '_give_log_payment_id' ); |
|
725 | - $this->logmeta_db->update_meta( $log_id, '_give_log_form_id', $form_id ); |
|
723 | + if ($form_id) { |
|
724 | + $this->logmeta_db->delete_meta($log_id, '_give_log_payment_id'); |
|
725 | + $this->logmeta_db->update_meta($log_id, '_give_log_form_id', $form_id); |
|
726 | 726 | |
727 | 727 | $update_status = $wpdb->update( |
728 | 728 | $this->log_db->table_name, |