@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -defined( 'ABSPATH' ) or exit; |
|
13 | +defined('ABSPATH') or exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give Form widget |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct() |
33 | 33 | { |
34 | - $this->self = get_class( $this ); |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ) |
|
55 | + public function admin_widget_scripts($hook) |
|
56 | 56 | { |
57 | 57 | // Directories of assets |
58 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
59 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
60 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
58 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
59 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
60 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
61 | 61 | |
62 | 62 | // Use minified libraries if SCRIPT_DEBUG is turned off |
63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
64 | 64 | |
65 | 65 | // Widget Script |
66 | - if ( $hook == 'widgets.php' ) { |
|
66 | + if ($hook == 'widgets.php') { |
|
67 | 67 | |
68 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
68 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
69 | 69 | |
70 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
70 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
71 | 71 | |
72 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
72 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -80,24 +80,24 @@ discard block |
||
80 | 80 | * before_widget, and after_widget. |
81 | 81 | * @param array $instance The settings for the particular instance of the widget. |
82 | 82 | */ |
83 | - public function widget( $args, $instance ) |
|
83 | + public function widget($args, $instance) |
|
84 | 84 | { |
85 | - extract( $args ); |
|
85 | + extract($args); |
|
86 | 86 | |
87 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
88 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
87 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
88 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
89 | 89 | |
90 | 90 | echo $before_widget; |
91 | 91 | |
92 | - do_action( 'give_before_forms_widget' ); |
|
92 | + do_action('give_before_forms_widget'); |
|
93 | 93 | |
94 | - echo $title ? $before_title . $title . $after_title : ''; |
|
94 | + echo $title ? $before_title.$title.$after_title : ''; |
|
95 | 95 | |
96 | - give_get_donation_form( $instance ); |
|
96 | + give_get_donation_form($instance); |
|
97 | 97 | |
98 | 98 | echo $after_widget; |
99 | 99 | |
100 | - do_action( 'give_after_forms_widget' ); |
|
100 | + do_action('give_after_forms_widget'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function form( $instance ) |
|
110 | + public function form($instance) |
|
111 | 111 | { |
112 | 112 | $defaults = array( |
113 | 113 | 'title' => '', |
@@ -115,61 +115,61 @@ discard block |
||
115 | 115 | 'float_labels' => '', |
116 | 116 | ); |
117 | 117 | |
118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
119 | 119 | |
120 | - extract( $instance ); |
|
120 | + extract($instance); |
|
121 | 121 | |
122 | 122 | // Query Give Forms |
123 | 123 | |
124 | 124 | $args = array( |
125 | 125 | 'post_type' => 'give_forms', |
126 | - 'posts_per_page' => - 1, |
|
126 | + 'posts_per_page' => -1, |
|
127 | 127 | 'post_status' => 'publish', |
128 | 128 | ); |
129 | 129 | |
130 | - $give_forms = get_posts( $args ); |
|
130 | + $give_forms = get_posts($args); |
|
131 | 131 | |
132 | 132 | // Widget: Title |
133 | 133 | |
134 | 134 | ?><p> |
135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $title ); ?>" /><br> |
|
137 | - <small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($title); ?>" /><br> |
|
137 | + <small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
138 | 138 | </p><?php |
139 | 139 | |
140 | 140 | // Widget: Give Form |
141 | 141 | |
142 | 142 | ?><p> |
143 | - <label for="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"><?php |
|
143 | + <label for="<?php esc_attr_e($this->get_field_id('id')); ?>"><?php |
|
144 | 144 | printf( |
145 | 145 | /* translators: %s: form singular label */ |
146 | - esc_html( 'Give %s:', 'give' ), |
|
146 | + esc_html('Give %s:', 'give'), |
|
147 | 147 | give_get_forms_label_singular() |
148 | 148 | ); |
149 | 149 | ?></label> |
150 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'id' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"> |
|
151 | - <option value="current"><?php esc_html_e( '— Select —', 'give' ); ?></option> |
|
152 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
153 | - <option <?php selected( absint( $id ), $give_form->ID ); ?> value="<?php esc_attr_e( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
150 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('id')); ?>" id="<?php esc_attr_e($this->get_field_id('id')); ?>"> |
|
151 | + <option value="current"><?php esc_html_e('— Select —', 'give'); ?></option> |
|
152 | + <?php foreach ($give_forms as $give_form) { ?> |
|
153 | + <option <?php selected(absint($id), $give_form->ID); ?> value="<?php esc_attr_e($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
154 | 154 | <?php } ?> |
155 | 155 | </select><br> |
156 | - <small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
156 | + <small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
157 | 157 | </p><?php |
158 | 158 | |
159 | 159 | // Widget: Floating Labels |
160 | 160 | |
161 | 161 | ?><p> |
162 | - <label for="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label> |
|
163 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
164 | - <option value="" <?php selected( esc_attr( $float_labels ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
165 | - <option value="enabled" <?php selected( esc_attr( $float_labels ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option> |
|
166 | - <option value="disabled" <?php selected( esc_attr( $float_labels ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option> |
|
162 | + <label for="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label> |
|
163 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('float_labels')); ?>" id="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"> |
|
164 | + <option value="" <?php selected(esc_attr($float_labels), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option> |
|
165 | + <option value="enabled" <?php selected(esc_attr($float_labels), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option> |
|
166 | + <option value="disabled" <?php selected(esc_attr($float_labels), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option> |
|
167 | 167 | </select><br> |
168 | 168 | <small><?php |
169 | 169 | printf( |
170 | 170 | /* translators: %s: http://bradfrost.com/blog/post/float-label-pattern/ */ |
171 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
172 | - esc_url( 'http://bradfrost.com/blog/post/float-label-pattern/' ) |
|
171 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
172 | + esc_url('http://bradfrost.com/blog/post/float-label-pattern/') |
|
173 | 173 | ); |
174 | 174 | ?></small> |
175 | 175 | </p><?php |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function widget_init() |
184 | 184 | { |
185 | - register_widget( $this->self ); |
|
185 | + register_widget($this->self); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - public function update( $new_instance, $old_instance ) |
|
196 | + public function update($new_instance, $old_instance) |
|
197 | 197 | { |
198 | 198 | $this->flush_widget_cache(); |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function flush_widget_cache() |
209 | 209 | { |
210 | - wp_cache_delete( $this->self, 'widget' ); |
|
210 | + wp_cache_delete($this->self, 'widget'); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function get_predefined_dates() { |
78 | 78 | $predefined = array( |
79 | - 'today' => esc_html( 'Today', 'give' ), |
|
80 | - 'yesterday' => esc_html( 'Yesterday', 'give' ), |
|
81 | - 'this_week' => esc_html( 'This Week', 'give' ), |
|
82 | - 'last_week' => esc_html( 'Last Week', 'give' ), |
|
83 | - 'this_month' => esc_html( 'This Month', 'give' ), |
|
84 | - 'last_month' => esc_html( 'Last Month', 'give' ), |
|
85 | - 'this_quarter' => esc_html( 'This Quarter', 'give' ), |
|
86 | - 'last_quarter' => esc_html( 'Last Quarter', 'give' ), |
|
87 | - 'this_year' => esc_html( 'This Year', 'give' ), |
|
88 | - 'last_year' => esc_html( 'Last Year', 'give' ) |
|
79 | + 'today' => esc_html('Today', 'give'), |
|
80 | + 'yesterday' => esc_html('Yesterday', 'give'), |
|
81 | + 'this_week' => esc_html('This Week', 'give'), |
|
82 | + 'last_week' => esc_html('Last Week', 'give'), |
|
83 | + 'this_month' => esc_html('This Month', 'give'), |
|
84 | + 'last_month' => esc_html('Last Month', 'give'), |
|
85 | + 'this_quarter' => esc_html('This Quarter', 'give'), |
|
86 | + 'last_quarter' => esc_html('Last Quarter', 'give'), |
|
87 | + 'this_year' => esc_html('This Year', 'give'), |
|
88 | + 'last_year' => esc_html('Last Year', 'give') |
|
89 | 89 | ); |
90 | 90 | |
91 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
91 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
107 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
108 | 108 | |
109 | - if ( empty( $_start_date ) ) { |
|
109 | + if (empty($_start_date)) { |
|
110 | 110 | $_start_date = 'this_month'; |
111 | 111 | } |
112 | 112 | |
113 | - if ( empty( $_end_date ) ) { |
|
113 | + if (empty($_end_date)) { |
|
114 | 114 | $_end_date = $_start_date; |
115 | 115 | } |
116 | 116 | |
117 | - $this->start_date = $this->convert_date( $_start_date ); |
|
118 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
117 | + $this->start_date = $this->convert_date($_start_date); |
|
118 | + $this->end_date = $this->convert_date($_end_date, true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,26 +125,26 @@ discard block |
||
125 | 125 | * @since 1.0 |
126 | 126 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned |
127 | 127 | */ |
128 | - public function convert_date( $date, $end_date = false ) { |
|
128 | + public function convert_date($date, $end_date = false) { |
|
129 | 129 | |
130 | 130 | $this->timestamp = false; |
131 | 131 | $second = $end_date ? 59 : 0; |
132 | 132 | $minute = $end_date ? 59 : 0; |
133 | 133 | $hour = $end_date ? 23 : 0; |
134 | 134 | $day = 1; |
135 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
136 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
135 | + $month = date('n', current_time('timestamp')); |
|
136 | + $year = date('Y', current_time('timestamp')); |
|
137 | 137 | |
138 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
138 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
139 | 139 | |
140 | 140 | // This is a predefined date rate, such as last_week |
141 | - switch ( $date ) { |
|
141 | + switch ($date) { |
|
142 | 142 | |
143 | 143 | case 'this_month' : |
144 | 144 | |
145 | - if ( $end_date ) { |
|
145 | + if ($end_date) { |
|
146 | 146 | |
147 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
147 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
148 | 148 | $hour = 23; |
149 | 149 | $minute = 59; |
150 | 150 | $second = 59; |
@@ -154,28 +154,28 @@ discard block |
||
154 | 154 | |
155 | 155 | case 'last_month' : |
156 | 156 | |
157 | - if ( $month == 1 ) { |
|
157 | + if ($month == 1) { |
|
158 | 158 | |
159 | 159 | $month = 12; |
160 | - $year --; |
|
160 | + $year--; |
|
161 | 161 | |
162 | 162 | } else { |
163 | 163 | |
164 | - $month --; |
|
164 | + $month--; |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | - if ( $end_date ) { |
|
169 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
168 | + if ($end_date) { |
|
169 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | break; |
173 | 173 | |
174 | 174 | case 'today' : |
175 | 175 | |
176 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
176 | + $day = date('d', current_time('timestamp')); |
|
177 | 177 | |
178 | - if ( $end_date ) { |
|
178 | + if ($end_date) { |
|
179 | 179 | $hour = 23; |
180 | 180 | $minute = 59; |
181 | 181 | $second = 59; |
@@ -185,23 +185,23 @@ discard block |
||
185 | 185 | |
186 | 186 | case 'yesterday' : |
187 | 187 | |
188 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
188 | + $day = date('d', current_time('timestamp')) - 1; |
|
189 | 189 | |
190 | 190 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
191 | - if ( $day < 1 ) { |
|
191 | + if ($day < 1) { |
|
192 | 192 | |
193 | 193 | // If current month is 1 |
194 | - if ( 1 == $month ) { |
|
194 | + if (1 == $month) { |
|
195 | 195 | |
196 | 196 | $year -= 1; // Today is January 1, so skip back to last day of December |
197 | 197 | $month = 12; |
198 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
198 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
199 | 199 | |
200 | 200 | } else { |
201 | 201 | |
202 | 202 | // Go back one month and get the last day of the month |
203 | 203 | $month -= 1; |
204 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
204 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | |
211 | 211 | case 'this_week' : |
212 | 212 | |
213 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
214 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
213 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
214 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
215 | 215 | |
216 | - if ( $today < $days_to_week_start ) { |
|
216 | + if ($today < $days_to_week_start) { |
|
217 | 217 | |
218 | - if ( $month > 1 ) { |
|
218 | + if ($month > 1) { |
|
219 | 219 | $month -= 1; |
220 | 220 | } else { |
221 | 221 | $month = 12; |
@@ -223,19 +223,19 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! $end_date ) { |
|
226 | + if ( ! $end_date) { |
|
227 | 227 | |
228 | 228 | // Getting the start day |
229 | 229 | |
230 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
231 | - $day += get_option( 'start_of_week' ); |
|
230 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
231 | + $day += get_option('start_of_week'); |
|
232 | 232 | |
233 | 233 | } else { |
234 | 234 | |
235 | 235 | // Getting the end day |
236 | 236 | |
237 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
238 | - $day += get_option( 'start_of_week' ) + 6; |
|
237 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
238 | + $day += get_option('start_of_week') + 6; |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | |
244 | 244 | case 'last_week' : |
245 | 245 | |
246 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
247 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
246 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
247 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
248 | 248 | |
249 | - if ( $today < $days_to_week_start ) { |
|
249 | + if ($today < $days_to_week_start) { |
|
250 | 250 | |
251 | - if ( $month > 1 ) { |
|
251 | + if ($month > 1) { |
|
252 | 252 | $month -= 1; |
253 | 253 | } else { |
254 | 254 | $month = 12; |
@@ -256,19 +256,19 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $end_date ) { |
|
259 | + if ( ! $end_date) { |
|
260 | 260 | |
261 | 261 | // Getting the start day |
262 | 262 | |
263 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
264 | - $day += get_option( 'start_of_week' ); |
|
263 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
264 | + $day += get_option('start_of_week'); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
268 | 268 | // Getting the end day |
269 | 269 | |
270 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
271 | - $day += get_option( 'start_of_week' ) + 6; |
|
270 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
271 | + $day += get_option('start_of_week') + 6; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -276,39 +276,39 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'this_quarter' : |
278 | 278 | |
279 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
279 | + $month_now = date('n', current_time('timestamp')); |
|
280 | 280 | |
281 | - if ( $month_now <= 3 ) { |
|
281 | + if ($month_now <= 3) { |
|
282 | 282 | |
283 | - if ( ! $end_date ) { |
|
283 | + if ( ! $end_date) { |
|
284 | 284 | $month = 1; |
285 | 285 | } else { |
286 | 286 | $month = 3; |
287 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
287 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
288 | 288 | $hour = 23; |
289 | 289 | $minute = 59; |
290 | 290 | $second = 59; |
291 | 291 | } |
292 | 292 | |
293 | - } else if ( $month_now <= 6 ) { |
|
293 | + } else if ($month_now <= 6) { |
|
294 | 294 | |
295 | - if ( ! $end_date ) { |
|
295 | + if ( ! $end_date) { |
|
296 | 296 | $month = 4; |
297 | 297 | } else { |
298 | 298 | $month = 6; |
299 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
299 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
300 | 300 | $hour = 23; |
301 | 301 | $minute = 59; |
302 | 302 | $second = 59; |
303 | 303 | } |
304 | 304 | |
305 | - } else if ( $month_now <= 9 ) { |
|
305 | + } else if ($month_now <= 9) { |
|
306 | 306 | |
307 | - if ( ! $end_date ) { |
|
307 | + if ( ! $end_date) { |
|
308 | 308 | $month = 7; |
309 | 309 | } else { |
310 | 310 | $month = 9; |
311 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
311 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
312 | 312 | $hour = 23; |
313 | 313 | $minute = 59; |
314 | 314 | $second = 59; |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | |
317 | 317 | } else { |
318 | 318 | |
319 | - if ( ! $end_date ) { |
|
319 | + if ( ! $end_date) { |
|
320 | 320 | $month = 10; |
321 | 321 | } else { |
322 | 322 | $month = 12; |
323 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
323 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
324 | 324 | $hour = 23; |
325 | 325 | $minute = 59; |
326 | 326 | $second = 59; |
@@ -332,40 +332,40 @@ discard block |
||
332 | 332 | |
333 | 333 | case 'last_quarter' : |
334 | 334 | |
335 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
335 | + $month_now = date('n', current_time('timestamp')); |
|
336 | 336 | |
337 | - if ( $month_now <= 3 ) { |
|
337 | + if ($month_now <= 3) { |
|
338 | 338 | |
339 | - if ( ! $end_date ) { |
|
339 | + if ( ! $end_date) { |
|
340 | 340 | $month = 10; |
341 | 341 | } else { |
342 | 342 | $year -= 1; |
343 | 343 | $month = 12; |
344 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
344 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
345 | 345 | $hour = 23; |
346 | 346 | $minute = 59; |
347 | 347 | $second = 59; |
348 | 348 | } |
349 | 349 | |
350 | - } else if ( $month_now <= 6 ) { |
|
350 | + } else if ($month_now <= 6) { |
|
351 | 351 | |
352 | - if ( ! $end_date ) { |
|
352 | + if ( ! $end_date) { |
|
353 | 353 | $month = 1; |
354 | 354 | } else { |
355 | 355 | $month = 3; |
356 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
356 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
357 | 357 | $hour = 23; |
358 | 358 | $minute = 59; |
359 | 359 | $second = 59; |
360 | 360 | } |
361 | 361 | |
362 | - } else if ( $month_now <= 9 ) { |
|
362 | + } else if ($month_now <= 9) { |
|
363 | 363 | |
364 | - if ( ! $end_date ) { |
|
364 | + if ( ! $end_date) { |
|
365 | 365 | $month = 4; |
366 | 366 | } else { |
367 | 367 | $month = 6; |
368 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
368 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
369 | 369 | $hour = 23; |
370 | 370 | $minute = 59; |
371 | 371 | $second = 59; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - if ( ! $end_date ) { |
|
376 | + if ( ! $end_date) { |
|
377 | 377 | $month = 7; |
378 | 378 | } else { |
379 | 379 | $month = 9; |
380 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
380 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
381 | 381 | $hour = 23; |
382 | 382 | $minute = 59; |
383 | 383 | $second = 59; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | |
390 | 390 | case 'this_year' : |
391 | 391 | |
392 | - if ( ! $end_date ) { |
|
392 | + if ( ! $end_date) { |
|
393 | 393 | $month = 1; |
394 | 394 | } else { |
395 | 395 | $month = 12; |
396 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
396 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
397 | 397 | $hour = 23; |
398 | 398 | $minute = 59; |
399 | 399 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | case 'last_year' : |
405 | 405 | |
406 | 406 | $year -= 1; |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | - } else if ( is_numeric( $date ) ) { |
|
422 | + } else if (is_numeric($date)) { |
|
423 | 423 | |
424 | 424 | // return $date unchanged since it is a timestamp |
425 | 425 | $this->timestamp = true; |
426 | 426 | |
427 | - } else if ( false !== strtotime( $date ) ) { |
|
427 | + } else if (false !== strtotime($date)) { |
|
428 | 428 | |
429 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
430 | - $year = date( 'Y', $date ); |
|
431 | - $month = date( 'm', $date ); |
|
432 | - $day = date( 'd', $date ); |
|
429 | + $date = strtotime($date, current_time('timestamp')); |
|
430 | + $year = date('Y', $date); |
|
431 | + $month = date('m', $date); |
|
432 | + $day = date('d', $date); |
|
433 | 433 | |
434 | 434 | } else { |
435 | 435 | |
436 | - return new WP_Error( 'invalid_date', esc_html( 'Improper date provided.', 'give' ) ); |
|
436 | + return new WP_Error('invalid_date', esc_html('Improper date provided.', 'give')); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | - if ( false === $this->timestamp ) { |
|
440 | + if (false === $this->timestamp) { |
|
441 | 441 | // Create an exact timestamp |
442 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
442 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
443 | 443 | } |
444 | 444 | |
445 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
445 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | * @since 1.0 |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function count_where( $where = '' ) { |
|
456 | + public function count_where($where = '') { |
|
457 | 457 | // Only get payments in our date range |
458 | 458 | |
459 | 459 | $start_where = ''; |
460 | 460 | $end_where = ''; |
461 | 461 | |
462 | - if ( $this->start_date ) { |
|
462 | + if ($this->start_date) { |
|
463 | 463 | |
464 | - if ( $this->timestamp ) { |
|
464 | + if ($this->timestamp) { |
|
465 | 465 | $format = 'Y-m-d H:i:s'; |
466 | 466 | } else { |
467 | 467 | $format = 'Y-m-d 00:00:00'; |
468 | 468 | } |
469 | 469 | |
470 | - $start_date = date( $format, $this->start_date ); |
|
470 | + $start_date = date($format, $this->start_date); |
|
471 | 471 | $start_where = " AND p.post_date >= '{$start_date}'"; |
472 | 472 | } |
473 | 473 | |
474 | - if ( $this->end_date ) { |
|
474 | + if ($this->end_date) { |
|
475 | 475 | |
476 | - if ( $this->timestamp ) { |
|
476 | + if ($this->timestamp) { |
|
477 | 477 | $format = 'Y-m-d H:i:s'; |
478 | 478 | } else { |
479 | 479 | $format = 'Y-m-d 23:59:59'; |
480 | 480 | } |
481 | 481 | |
482 | - $end_date = date( $format, $this->end_date ); |
|
482 | + $end_date = date($format, $this->end_date); |
|
483 | 483 | |
484 | 484 | $end_where = " AND p.post_date <= '{$end_date}'"; |
485 | 485 | } |
@@ -499,34 +499,34 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public function payments_where( $where = '' ) { |
|
502 | + public function payments_where($where = '') { |
|
503 | 503 | |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | 506 | $start_where = ''; |
507 | 507 | $end_where = ''; |
508 | 508 | |
509 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
509 | + if ( ! is_wp_error($this->start_date)) { |
|
510 | 510 | |
511 | - if ( $this->timestamp ) { |
|
511 | + if ($this->timestamp) { |
|
512 | 512 | $format = 'Y-m-d H:i:s'; |
513 | 513 | } else { |
514 | 514 | $format = 'Y-m-d 00:00:00'; |
515 | 515 | } |
516 | 516 | |
517 | - $start_date = date( $format, $this->start_date ); |
|
517 | + $start_date = date($format, $this->start_date); |
|
518 | 518 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
521 | + if ( ! is_wp_error($this->end_date)) { |
|
522 | 522 | |
523 | - if ( $this->timestamp ) { |
|
523 | + if ($this->timestamp) { |
|
524 | 524 | $format = 'Y-m-d 00:00:00'; |
525 | 525 | } else { |
526 | 526 | $format = 'Y-m-d 23:59:59'; |
527 | 527 | } |
528 | 528 | |
529 | - $end_date = date( $format, $this->end_date ); |
|
529 | + $end_date = date($format, $this->end_date); |
|
530 | 530 | |
531 | 531 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
532 | 532 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | function give_is_test_mode() { |
25 | 25 | global $give_options; |
26 | 26 | |
27 | - $ret = ! empty( $give_options['test_mode'] ); |
|
27 | + $ret = ! empty($give_options['test_mode']); |
|
28 | 28 | |
29 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
29 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function give_get_currency() { |
39 | 39 | global $give_options; |
40 | - $currency = isset( $give_options['currency'] ) ? $give_options['currency'] : 'USD'; |
|
40 | + $currency = isset($give_options['currency']) ? $give_options['currency'] : 'USD'; |
|
41 | 41 | |
42 | - return apply_filters( 'give_currency', $currency ); |
|
42 | + return apply_filters('give_currency', $currency); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function give_get_currency_position() { |
53 | 53 | global $give_options; |
54 | - $currency_pos = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
54 | + $currency_pos = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
55 | 55 | |
56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
56 | + return apply_filters('give_currency_position', $currency_pos); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | |
67 | 67 | function give_get_currencies() { |
68 | 68 | $currencies = array( |
69 | - 'USD' => esc_html( 'US Dollars ($)', 'give' ), |
|
70 | - 'EUR' => esc_html( 'Euros (€)', 'give' ), |
|
71 | - 'GBP' => esc_html( 'Pounds Sterling (£)', 'give' ), |
|
72 | - 'AUD' => esc_html( 'Australian Dollars ($)', 'give' ), |
|
73 | - 'BRL' => esc_html( 'Brazilian Real (R$)', 'give' ), |
|
74 | - 'CAD' => esc_html( 'Canadian Dollars ($)', 'give' ), |
|
75 | - 'CZK' => esc_html( 'Czech Koruna (Kč)', 'give' ), |
|
76 | - 'DKK' => esc_html( 'Danish Krone (kr)', 'give' ), |
|
77 | - 'HKD' => esc_html( 'Hong Kong Dollar ($)', 'give' ), |
|
78 | - 'HUF' => esc_html( 'Hungarian Forint (Ft)', 'give' ), |
|
79 | - 'ILS' => esc_html( 'Israeli Shekel (₪)', 'give' ), |
|
80 | - 'JPY' => esc_html( 'Japanese Yen (¥)', 'give' ), |
|
81 | - 'MYR' => esc_html( 'Malaysian Ringgits (RM)', 'give' ), |
|
82 | - 'MXN' => esc_html( 'Mexican Peso ($)', 'give' ), |
|
83 | - 'MAD' => esc_html( 'Moroccan Dirham (.د.م)', 'give' ), |
|
84 | - 'NZD' => esc_html( 'New Zealand Dollar ($)', 'give' ), |
|
85 | - 'NOK' => esc_html( 'Norwegian Krone (Kr.)', 'give' ), |
|
86 | - 'PHP' => esc_html( 'Philippine Pesos (₱)', 'give' ), |
|
87 | - 'PLN' => esc_html( 'Polish Zloty (zł)', 'give' ), |
|
88 | - 'SGD' => esc_html( 'Singapore Dollar ($)', 'give' ), |
|
89 | - 'KRW' => esc_html( 'South Korean Won (₩)', 'give' ), |
|
90 | - 'ZAR' => esc_html( 'South African Rand (R)', 'give' ), |
|
91 | - 'SEK' => esc_html( 'Swedish Krona (kr)', 'give' ), |
|
92 | - 'CHF' => esc_html( 'Swiss Franc (CHF)', 'give' ), |
|
93 | - 'TWD' => esc_html( 'Taiwan New Dollars (NT$)', 'give' ), |
|
94 | - 'THB' => esc_html( 'Thai Baht (฿)', 'give' ), |
|
95 | - 'INR' => esc_html( 'Indian Rupee (₹)', 'give' ), |
|
96 | - 'TRY' => esc_html( 'Turkish Lira (₺)', 'give' ), |
|
97 | - 'RIAL' => esc_html( 'Iranian Rial (﷼)', 'give' ), |
|
98 | - 'RUB' => esc_html( 'Russian Rubles (руб)', 'give' ) |
|
69 | + 'USD' => esc_html('US Dollars ($)', 'give'), |
|
70 | + 'EUR' => esc_html('Euros (€)', 'give'), |
|
71 | + 'GBP' => esc_html('Pounds Sterling (£)', 'give'), |
|
72 | + 'AUD' => esc_html('Australian Dollars ($)', 'give'), |
|
73 | + 'BRL' => esc_html('Brazilian Real (R$)', 'give'), |
|
74 | + 'CAD' => esc_html('Canadian Dollars ($)', 'give'), |
|
75 | + 'CZK' => esc_html('Czech Koruna (Kč)', 'give'), |
|
76 | + 'DKK' => esc_html('Danish Krone (kr)', 'give'), |
|
77 | + 'HKD' => esc_html('Hong Kong Dollar ($)', 'give'), |
|
78 | + 'HUF' => esc_html('Hungarian Forint (Ft)', 'give'), |
|
79 | + 'ILS' => esc_html('Israeli Shekel (₪)', 'give'), |
|
80 | + 'JPY' => esc_html('Japanese Yen (¥)', 'give'), |
|
81 | + 'MYR' => esc_html('Malaysian Ringgits (RM)', 'give'), |
|
82 | + 'MXN' => esc_html('Mexican Peso ($)', 'give'), |
|
83 | + 'MAD' => esc_html('Moroccan Dirham (.د.م)', 'give'), |
|
84 | + 'NZD' => esc_html('New Zealand Dollar ($)', 'give'), |
|
85 | + 'NOK' => esc_html('Norwegian Krone (Kr.)', 'give'), |
|
86 | + 'PHP' => esc_html('Philippine Pesos (₱)', 'give'), |
|
87 | + 'PLN' => esc_html('Polish Zloty (zł)', 'give'), |
|
88 | + 'SGD' => esc_html('Singapore Dollar ($)', 'give'), |
|
89 | + 'KRW' => esc_html('South Korean Won (₩)', 'give'), |
|
90 | + 'ZAR' => esc_html('South African Rand (R)', 'give'), |
|
91 | + 'SEK' => esc_html('Swedish Krona (kr)', 'give'), |
|
92 | + 'CHF' => esc_html('Swiss Franc (CHF)', 'give'), |
|
93 | + 'TWD' => esc_html('Taiwan New Dollars (NT$)', 'give'), |
|
94 | + 'THB' => esc_html('Thai Baht (฿)', 'give'), |
|
95 | + 'INR' => esc_html('Indian Rupee (₹)', 'give'), |
|
96 | + 'TRY' => esc_html('Turkish Lira (₺)', 'give'), |
|
97 | + 'RIAL' => esc_html('Iranian Rial (﷼)', 'give'), |
|
98 | + 'RUB' => esc_html('Russian Rubles (руб)', 'give') |
|
99 | 99 | ); |
100 | 100 | |
101 | - return apply_filters( 'give_currencies', $currencies ); |
|
101 | + return apply_filters('give_currencies', $currencies); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string The symbol to use for the currency |
115 | 115 | */ |
116 | -function give_currency_symbol( $currency = '' ) { |
|
116 | +function give_currency_symbol($currency = '') { |
|
117 | 117 | |
118 | - if ( empty( $currency ) ) { |
|
118 | + if (empty($currency)) { |
|
119 | 119 | $currency = give_get_currency(); |
120 | 120 | } |
121 | - switch ( $currency ) : |
|
121 | + switch ($currency) : |
|
122 | 122 | case 'GBP' : |
123 | 123 | $symbol = '£'; |
124 | 124 | break; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | endswitch; |
198 | 198 | |
199 | 199 | |
200 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
200 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function give_get_current_page_url() { |
211 | 211 | |
212 | - if ( is_front_page() ) { |
|
213 | - $current_url = home_url( '/' ); |
|
212 | + if (is_front_page()) { |
|
213 | + $current_url = home_url('/'); |
|
214 | 214 | } else { |
215 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . untrailingslashit( $_SERVER['REQUEST_URI'] ) ); |
|
215 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].untrailingslashit($_SERVER['REQUEST_URI'])); |
|
216 | 216 | } |
217 | 217 | |
218 | - return apply_filters( 'give_get_current_page_url', esc_url( $current_url ) ); |
|
218 | + return apply_filters('give_get_current_page_url', esc_url($current_url)); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | */ |
237 | 237 | $gateways = give_get_enabled_payment_gateways(); |
238 | 238 | |
239 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
239 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
240 | 240 | $ret = true; |
241 | - } else if ( count( $gateways ) == 1 ) { |
|
241 | + } else if (count($gateways) == 1) { |
|
242 | 242 | $ret = false; |
243 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
243 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
244 | 244 | $ret = false; |
245 | 245 | } |
246 | 246 | |
247 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
247 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | function give_get_timezone_id() { |
257 | 257 | |
258 | 258 | // if site timezone string exists, return it |
259 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
259 | + if ($timezone = get_option('timezone_string')) { |
|
260 | 260 | return $timezone; |
261 | 261 | } |
262 | 262 | |
263 | 263 | // get UTC offset, if it isn't set return UTC |
264 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
264 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
265 | 265 | return 'UTC'; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // attempt to guess the timezone string from the UTC offset |
269 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
269 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
270 | 270 | |
271 | 271 | // last try, guess timezone string manually |
272 | - if ( $timezone === false ) { |
|
272 | + if ($timezone === false) { |
|
273 | 273 | |
274 | - $is_dst = date( 'I' ); |
|
274 | + $is_dst = date('I'); |
|
275 | 275 | |
276 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
277 | - foreach ( $abbr as $city ) { |
|
278 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
276 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
277 | + foreach ($abbr as $city) { |
|
278 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
279 | 279 | return $city['timezone_id']; |
280 | 280 | } |
281 | 281 | } |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | |
300 | 300 | $ip = '127.0.0.1'; |
301 | 301 | |
302 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
302 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
303 | 303 | //check ip from share internet |
304 | 304 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
305 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
305 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
306 | 306 | //to check ip is pass from proxy |
307 | 307 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
308 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
308 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
309 | 309 | $ip = $_SERVER['REMOTE_ADDR']; |
310 | 310 | } |
311 | 311 | |
312 | - return apply_filters( 'give_get_ip', $ip ); |
|
312 | + return apply_filters('give_get_ip', $ip); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @uses Give()->session->set() |
326 | 326 | */ |
327 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
328 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
329 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
327 | +function give_set_purchase_session($purchase_data = array()) { |
|
328 | + Give()->session->set('give_purchase', $purchase_data); |
|
329 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * @return mixed array | false |
341 | 341 | */ |
342 | 342 | function give_get_purchase_session() { |
343 | - return Give()->session->get( 'give_purchase' ); |
|
343 | + return Give()->session->get('give_purchase'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return string |
357 | 357 | */ |
358 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
358 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
359 | 359 | $summary = ''; |
360 | 360 | |
361 | - if ( $email ) { |
|
362 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
361 | + if ($email) { |
|
362 | + $summary .= $purchase_data['user_email'].' - '; |
|
363 | 363 | } |
364 | 364 | |
365 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
365 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
366 | 366 | |
367 | 367 | return $summary; |
368 | 368 | } |
@@ -379,31 +379,31 @@ discard block |
||
379 | 379 | function give_get_host() { |
380 | 380 | $host = false; |
381 | 381 | |
382 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
382 | + if (defined('WPE_APIKEY')) { |
|
383 | 383 | $host = 'WP Engine'; |
384 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
384 | + } elseif (defined('PAGELYBIN')) { |
|
385 | 385 | $host = 'Pagely'; |
386 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
386 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
387 | 387 | $host = 'ICDSoft'; |
388 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
388 | + } elseif (DB_HOST == 'mysqlv5') { |
|
389 | 389 | $host = 'NetworkSolutions'; |
390 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
390 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
391 | 391 | $host = 'iPage'; |
392 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
392 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
393 | 393 | $host = 'IPower'; |
394 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
394 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
395 | 395 | $host = 'MediaTemple Grid'; |
396 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
396 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
397 | 397 | $host = 'pair Networks'; |
398 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
398 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
399 | 399 | $host = 'Rackspace Cloud'; |
400 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
400 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
401 | 401 | $host = 'SysFix.eu Power Hosting'; |
402 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
402 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
403 | 403 | $host = 'Flywheel'; |
404 | 404 | } else { |
405 | 405 | // Adding a general fallback for data gathering |
406 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
406 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $host; |
@@ -419,67 +419,67 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @return bool true if host matches, false if not |
421 | 421 | */ |
422 | -function give_is_host( $host = false ) { |
|
422 | +function give_is_host($host = false) { |
|
423 | 423 | |
424 | 424 | $return = false; |
425 | 425 | |
426 | - if ( $host ) { |
|
427 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
426 | + if ($host) { |
|
427 | + $host = str_replace(' ', '', strtolower($host)); |
|
428 | 428 | |
429 | - switch ( $host ) { |
|
429 | + switch ($host) { |
|
430 | 430 | case 'wpengine': |
431 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
431 | + if (defined('WPE_APIKEY')) { |
|
432 | 432 | $return = true; |
433 | 433 | } |
434 | 434 | break; |
435 | 435 | case 'pagely': |
436 | - if ( defined( 'PAGELYBIN' ) ) { |
|
436 | + if (defined('PAGELYBIN')) { |
|
437 | 437 | $return = true; |
438 | 438 | } |
439 | 439 | break; |
440 | 440 | case 'icdsoft': |
441 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
441 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
442 | 442 | $return = true; |
443 | 443 | } |
444 | 444 | break; |
445 | 445 | case 'networksolutions': |
446 | - if ( DB_HOST == 'mysqlv5' ) { |
|
446 | + if (DB_HOST == 'mysqlv5') { |
|
447 | 447 | $return = true; |
448 | 448 | } |
449 | 449 | break; |
450 | 450 | case 'ipage': |
451 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
451 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
452 | 452 | $return = true; |
453 | 453 | } |
454 | 454 | break; |
455 | 455 | case 'ipower': |
456 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
456 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
457 | 457 | $return = true; |
458 | 458 | } |
459 | 459 | break; |
460 | 460 | case 'mediatemplegrid': |
461 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
461 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
462 | 462 | $return = true; |
463 | 463 | } |
464 | 464 | break; |
465 | 465 | case 'pairnetworks': |
466 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
466 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
467 | 467 | $return = true; |
468 | 468 | } |
469 | 469 | break; |
470 | 470 | case 'rackspacecloud': |
471 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
471 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
472 | 472 | $return = true; |
473 | 473 | } |
474 | 474 | break; |
475 | 475 | case 'sysfix.eu': |
476 | 476 | case 'sysfix.eupowerhosting': |
477 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
477 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
478 | 478 | $return = true; |
479 | 479 | } |
480 | 480 | break; |
481 | 481 | case 'flywheel': |
482 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
482 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
483 | 483 | $return = true; |
484 | 484 | } |
485 | 485 | break; |
@@ -512,20 +512,20 @@ discard block |
||
512 | 512 | * @param string $replacement Optional. The function that should have been called |
513 | 513 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function |
514 | 514 | */ |
515 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
516 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
515 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
516 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
517 | 517 | |
518 | - $show_errors = current_user_can( 'manage_options' ); |
|
518 | + $show_errors = current_user_can('manage_options'); |
|
519 | 519 | |
520 | 520 | // Allow plugin to filter the output error trigger |
521 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
522 | - if ( ! is_null( $replacement ) ) { |
|
523 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
524 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
521 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
522 | + if ( ! is_null($replacement)) { |
|
523 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
524 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
525 | 525 | // Alternatively we could dump this to a file. |
526 | 526 | } else { |
527 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
528 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
527 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
528 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
529 | 529 | // Alternatively we could dump this to a file. |
530 | 530 | } |
531 | 531 | } |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @return string $post_id |
540 | 540 | */ |
541 | 541 | function give_get_admin_post_id() { |
542 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
543 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
542 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
543 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
544 | 544 | $post_id = $_POST['post_id']; |
545 | 545 | } |
546 | 546 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * @return string Arg separator output |
555 | 555 | */ |
556 | 556 | function give_get_php_arg_separator_output() { |
557 | - return ini_get( 'arg_separator.output' ); |
|
557 | + return ini_get('arg_separator.output'); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -569,10 +569,10 @@ discard block |
||
569 | 569 | * |
570 | 570 | * @return string Short month name |
571 | 571 | */ |
572 | -function give_month_num_to_name( $n ) { |
|
573 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
572 | +function give_month_num_to_name($n) { |
|
573 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
574 | 574 | |
575 | - return date_i18n( "M", $timestamp ); |
|
575 | + return date_i18n("M", $timestamp); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @return bool Whether or not function is disabled. |
587 | 587 | */ |
588 | -function give_is_func_disabled( $function ) { |
|
589 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
588 | +function give_is_func_disabled($function) { |
|
589 | + $disabled = explode(',', ini_get('disable_functions')); |
|
590 | 590 | |
591 | - return in_array( $function, $disabled ); |
|
591 | + return in_array($function, $disabled); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | |
604 | 604 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
605 | 605 | <div class="give-newsletter-confirmation"> |
606 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
606 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
607 | 607 | </div> |
608 | 608 | |
609 | 609 | <table class="form-table give-newsletter-form"> |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * |
700 | 700 | * @return mixed |
701 | 701 | */ |
702 | -function give_svg_icons( $icon ) { |
|
702 | +function give_svg_icons($icon) { |
|
703 | 703 | |
704 | 704 | // Store your SVGs in an associative array |
705 | 705 | $svgs = array( |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | ); |
712 | 712 | |
713 | 713 | // Return the chosen icon's SVG string |
714 | - return $svgs[ $icon ]; |
|
714 | + return $svgs[$icon]; |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -723,15 +723,15 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed |
725 | 725 | */ |
726 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
727 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
726 | +function modify_nav_menu_meta_box_object($post_type) { |
|
727 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
728 | 728 | $post_type->labels->name = 'Donation Forms'; |
729 | 729 | } |
730 | 730 | |
731 | 731 | return $post_type; |
732 | 732 | } |
733 | 733 | |
734 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
734 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
735 | 735 | |
736 | 736 | |
737 | 737 | /** |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * @license http://opensource.org/licenses/MIT MIT |
745 | 745 | */ |
746 | 746 | |
747 | -if ( ! function_exists( 'array_column' ) ) { |
|
747 | +if ( ! function_exists('array_column')) { |
|
748 | 748 | /** |
749 | 749 | * Returns the values from a single column of the input array, identified by |
750 | 750 | * the $columnKey. |
@@ -763,56 +763,56 @@ discard block |
||
763 | 763 | * |
764 | 764 | * @return array |
765 | 765 | */ |
766 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
766 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
767 | 767 | // Using func_get_args() in order to check for proper number of |
768 | 768 | // parameters and trigger errors exactly as the built-in array_column() |
769 | 769 | // does in PHP 5.5. |
770 | 770 | $argc = func_num_args(); |
771 | 771 | $params = func_get_args(); |
772 | 772 | |
773 | - if ( $argc < 2 ) { |
|
774 | - trigger_error( "array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING ); |
|
773 | + if ($argc < 2) { |
|
774 | + trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); |
|
775 | 775 | |
776 | 776 | return null; |
777 | 777 | } |
778 | 778 | |
779 | - if ( ! is_array( $params[0] ) ) { |
|
779 | + if ( ! is_array($params[0])) { |
|
780 | 780 | trigger_error( |
781 | - 'array_column() expects parameter 1 to be array, ' . gettype( $params[0] ) . ' given', |
|
781 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given', |
|
782 | 782 | E_USER_WARNING |
783 | 783 | ); |
784 | 784 | |
785 | 785 | return null; |
786 | 786 | } |
787 | 787 | |
788 | - if ( ! is_int( $params[1] ) |
|
789 | - && ! is_float( $params[1] ) |
|
790 | - && ! is_string( $params[1] ) |
|
788 | + if ( ! is_int($params[1]) |
|
789 | + && ! is_float($params[1]) |
|
790 | + && ! is_string($params[1]) |
|
791 | 791 | && $params[1] !== null |
792 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
792 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
793 | 793 | ) { |
794 | - trigger_error( 'array_column(): The column key should be either a string or an integer', E_USER_WARNING ); |
|
794 | + trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); |
|
795 | 795 | |
796 | 796 | return false; |
797 | 797 | } |
798 | 798 | |
799 | - if ( isset( $params[2] ) |
|
800 | - && ! is_int( $params[2] ) |
|
801 | - && ! is_float( $params[2] ) |
|
802 | - && ! is_string( $params[2] ) |
|
803 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
799 | + if (isset($params[2]) |
|
800 | + && ! is_int($params[2]) |
|
801 | + && ! is_float($params[2]) |
|
802 | + && ! is_string($params[2]) |
|
803 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
804 | 804 | ) { |
805 | - trigger_error( 'array_column(): The index key should be either a string or an integer', E_USER_WARNING ); |
|
805 | + trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); |
|
806 | 806 | |
807 | 807 | return false; |
808 | 808 | } |
809 | 809 | |
810 | 810 | $paramsInput = $params[0]; |
811 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
811 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
812 | 812 | |
813 | 813 | $paramsIndexKey = null; |
814 | - if ( isset( $params[2] ) ) { |
|
815 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
814 | + if (isset($params[2])) { |
|
815 | + if (is_float($params[2]) || is_int($params[2])) { |
|
816 | 816 | $paramsIndexKey = (int) $params[2]; |
817 | 817 | } else { |
818 | 818 | $paramsIndexKey = (string) $params[2]; |
@@ -821,26 +821,26 @@ discard block |
||
821 | 821 | |
822 | 822 | $resultArray = array(); |
823 | 823 | |
824 | - foreach ( $paramsInput as $row ) { |
|
824 | + foreach ($paramsInput as $row) { |
|
825 | 825 | $key = $value = null; |
826 | 826 | $keySet = $valueSet = false; |
827 | 827 | |
828 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
828 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
829 | 829 | $keySet = true; |
830 | - $key = (string) $row[ $paramsIndexKey ]; |
|
830 | + $key = (string) $row[$paramsIndexKey]; |
|
831 | 831 | } |
832 | 832 | |
833 | - if ( $paramsColumnKey === null ) { |
|
833 | + if ($paramsColumnKey === null) { |
|
834 | 834 | $valueSet = true; |
835 | 835 | $value = $row; |
836 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
836 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
837 | 837 | $valueSet = true; |
838 | - $value = $row[ $paramsColumnKey ]; |
|
838 | + $value = $row[$paramsColumnKey]; |
|
839 | 839 | } |
840 | 840 | |
841 | - if ( $valueSet ) { |
|
842 | - if ( $keySet ) { |
|
843 | - $resultArray[ $key ] = $value; |
|
841 | + if ($valueSet) { |
|
842 | + if ($keySet) { |
|
843 | + $resultArray[$key] = $value; |
|
844 | 844 | } else { |
845 | 845 | $resultArray[] = $value; |
846 | 846 | } |
@@ -862,40 +862,40 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @return bool Whether the receipt is visible or not. |
864 | 864 | */ |
865 | -function give_can_view_receipt( $payment_key = '' ) { |
|
865 | +function give_can_view_receipt($payment_key = '') { |
|
866 | 866 | |
867 | 867 | $return = false; |
868 | 868 | |
869 | - if ( empty( $payment_key ) ) { |
|
869 | + if (empty($payment_key)) { |
|
870 | 870 | return $return; |
871 | 871 | } |
872 | 872 | |
873 | 873 | global $give_receipt_args; |
874 | 874 | |
875 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
875 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
876 | 876 | |
877 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
877 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
878 | 878 | |
879 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
879 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
880 | 880 | |
881 | - if ( is_user_logged_in() ) { |
|
882 | - if ( $user_id === (int) get_current_user_id() ) { |
|
881 | + if (is_user_logged_in()) { |
|
882 | + if ($user_id === (int) get_current_user_id()) { |
|
883 | 883 | $return = true; |
884 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
884 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
885 | 885 | $return = true; |
886 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
886 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
887 | 887 | $return = true; |
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | 891 | $session = give_get_purchase_session(); |
892 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
893 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
892 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
893 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
894 | 894 | $return = true; |
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
898 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
899 | 899 | |
900 | 900 | } |
901 | 901 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | * |
905 | 905 | * @description: Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
906 | 906 | */ |
907 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
907 | +if ( ! function_exists('cal_days_in_month')) { |
|
908 | 908 | /** |
909 | 909 | * cal_days_in_month |
910 | 910 | * |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | * |
915 | 915 | * @return bool|string |
916 | 916 | */ |
917 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
918 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
917 | + function cal_days_in_month($calendar, $month, $year) { |
|
918 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
919 | 919 | } |
920 | 920 | } |
@@ -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 | |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | 32 | // Create the log post type |
33 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
33 | + add_action('init', array($this, 'register_post_type'), 1); |
|
34 | 34 | |
35 | 35 | // Create types taxonomy and default types |
36 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
36 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function register_post_type() { |
48 | 48 | /* Logs post type */ |
49 | 49 | $log_args = array( |
50 | - 'labels' => array( 'name' => esc_html( 'Logs', 'give' ) ), |
|
50 | + 'labels' => array('name' => esc_html('Logs', 'give')), |
|
51 | 51 | 'public' => false, |
52 | 52 | 'exclude_from_search' => true, |
53 | 53 | 'publicly_queryable' => false, |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | 'query_var' => false, |
56 | 56 | 'rewrite' => false, |
57 | 57 | 'capability_type' => 'post', |
58 | - 'supports' => array( 'title', 'editor' ), |
|
58 | + 'supports' => array('title', 'editor'), |
|
59 | 59 | 'can_export' => true |
60 | 60 | ); |
61 | 61 | |
62 | - register_post_type( 'give_log', $log_args ); |
|
62 | + register_post_type('give_log', $log_args); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public function register_taxonomy() { |
75 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
75 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'api_request' |
92 | 92 | ); |
93 | 93 | |
94 | - return apply_filters( 'give_log_types', $terms ); |
|
94 | + return apply_filters('give_log_types', $terms); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool Whether log type is valid |
109 | 109 | */ |
110 | - function valid_type( $type ) { |
|
111 | - return in_array( $type, $this->log_types() ); |
|
110 | + function valid_type($type) { |
|
111 | + return in_array($type, $this->log_types()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return int Log ID |
130 | 130 | */ |
131 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
131 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
132 | 132 | $log_data = array( |
133 | 133 | 'post_title' => $title, |
134 | 134 | 'post_content' => $message, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'log_type' => $type |
137 | 137 | ); |
138 | 138 | |
139 | - return $this->insert_log( $log_data ); |
|
139 | + return $this->insert_log($log_data); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array Array of the connected logs |
154 | 154 | */ |
155 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
156 | - return $this->get_connected_logs( array( |
|
155 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
156 | + return $this->get_connected_logs(array( |
|
157 | 157 | 'post_parent' => $object_id, |
158 | 158 | 'paged' => $paged, |
159 | 159 | 'log_type' => $type |
160 | - ) ); |
|
160 | + )); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return int The ID of the newly created log item |
174 | 174 | */ |
175 | - function insert_log( $log_data = array(), $log_meta = array() ) { |
|
175 | + function insert_log($log_data = array(), $log_meta = array()) { |
|
176 | 176 | $defaults = array( |
177 | 177 | 'post_type' => 'give_log', |
178 | 178 | 'post_status' => 'publish', |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | 'log_type' => false |
182 | 182 | ); |
183 | 183 | |
184 | - $args = wp_parse_args( $log_data, $defaults ); |
|
184 | + $args = wp_parse_args($log_data, $defaults); |
|
185 | 185 | |
186 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
186 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
187 | 187 | |
188 | 188 | // Store the log entry |
189 | - $log_id = wp_insert_post( $args ); |
|
189 | + $log_id = wp_insert_post($args); |
|
190 | 190 | |
191 | 191 | // Set the log type, if any |
192 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
193 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
192 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
193 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // Set log meta, if any |
197 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
198 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
199 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
197 | + if ($log_id && ! empty($log_meta)) { |
|
198 | + foreach ((array) $log_meta as $key => $meta) { |
|
199 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
203 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
204 | 204 | |
205 | 205 | return $log_id; |
206 | 206 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return bool True if successful, false otherwise |
218 | 218 | */ |
219 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
219 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
220 | 220 | |
221 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
221 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
222 | 222 | |
223 | 223 | $defaults = array( |
224 | 224 | 'post_type' => 'give_log', |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | 'post_parent' => 0 |
227 | 227 | ); |
228 | 228 | |
229 | - $args = wp_parse_args( $log_data, $defaults ); |
|
229 | + $args = wp_parse_args($log_data, $defaults); |
|
230 | 230 | |
231 | 231 | // Store the log entry |
232 | - $log_id = wp_update_post( $args ); |
|
232 | + $log_id = wp_update_post($args); |
|
233 | 233 | |
234 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
235 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
236 | - if ( ! empty( $meta ) ) { |
|
237 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
234 | + if ($log_id && ! empty($log_meta)) { |
|
235 | + foreach ((array) $log_meta as $key => $meta) { |
|
236 | + if ( ! empty($meta)) { |
|
237 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
242 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed array if logs were found, false otherwise |
256 | 256 | */ |
257 | - public function get_connected_logs( $args = array() ) { |
|
257 | + public function get_connected_logs($args = array()) { |
|
258 | 258 | |
259 | 259 | $defaults = array( |
260 | 260 | 'post_type' => 'give_log', |
261 | 261 | 'posts_per_page' => 20, |
262 | 262 | 'post_status' => 'publish', |
263 | - 'paged' => get_query_var( 'paged' ), |
|
263 | + 'paged' => get_query_var('paged'), |
|
264 | 264 | 'log_type' => false |
265 | 265 | ); |
266 | 266 | |
267 | - $query_args = wp_parse_args( $args, $defaults ); |
|
267 | + $query_args = wp_parse_args($args, $defaults); |
|
268 | 268 | |
269 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
269 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
270 | 270 | $query_args['tax_query'] = array( |
271 | 271 | array( |
272 | 272 | 'taxonomy' => 'give_log_type', |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | ); |
277 | 277 | } |
278 | 278 | |
279 | - $logs = get_posts( $query_args ); |
|
279 | + $logs = get_posts($query_args); |
|
280 | 280 | |
281 | - if ( $logs ) { |
|
281 | + if ($logs) { |
|
282 | 282 | return $logs; |
283 | 283 | } |
284 | 284 | |
@@ -299,17 +299,17 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return int Log count |
301 | 301 | */ |
302 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
302 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
303 | 303 | |
304 | 304 | $query_args = array( |
305 | 305 | 'post_parent' => $object_id, |
306 | 306 | 'post_type' => 'give_log', |
307 | - 'posts_per_page' => - 1, |
|
307 | + 'posts_per_page' => -1, |
|
308 | 308 | 'post_status' => 'publish', |
309 | 309 | 'fields' => 'ids', |
310 | 310 | ); |
311 | 311 | |
312 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
312 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
313 | 313 | $query_args['tax_query'] = array( |
314 | 314 | array( |
315 | 315 | 'taxonomy' => 'give_log_type', |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | ); |
320 | 320 | } |
321 | 321 | |
322 | - if ( ! empty( $meta_query ) ) { |
|
322 | + if ( ! empty($meta_query)) { |
|
323 | 323 | $query_args['meta_query'] = $meta_query; |
324 | 324 | } |
325 | 325 | |
326 | - if ( ! empty( $date_query ) ) { |
|
326 | + if ( ! empty($date_query)) { |
|
327 | 327 | $query_args['date_query'] = $date_query; |
328 | 328 | } |
329 | 329 | |
330 | - $logs = new WP_Query( $query_args ); |
|
330 | + $logs = new WP_Query($query_args); |
|
331 | 331 | |
332 | 332 | return (int) $logs->post_count; |
333 | 333 | } |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return void |
347 | 347 | */ |
348 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
348 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
349 | 349 | $query_args = array( |
350 | 350 | 'post_parent' => $object_id, |
351 | 351 | 'post_type' => 'give_log', |
352 | - 'posts_per_page' => - 1, |
|
352 | + 'posts_per_page' => -1, |
|
353 | 353 | 'post_status' => 'publish', |
354 | 354 | 'fields' => 'ids' |
355 | 355 | ); |
356 | 356 | |
357 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
357 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
358 | 358 | $query_args['tax_query'] = array( |
359 | 359 | array( |
360 | 360 | 'taxonomy' => 'give_log_type', |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | ); |
365 | 365 | } |
366 | 366 | |
367 | - if ( ! empty( $meta_query ) ) { |
|
367 | + if ( ! empty($meta_query)) { |
|
368 | 368 | $query_args['meta_query'] = $meta_query; |
369 | 369 | } |
370 | 370 | |
371 | - $logs = get_posts( $query_args ); |
|
371 | + $logs = get_posts($query_args); |
|
372 | 372 | |
373 | - if ( $logs ) { |
|
374 | - foreach ( $logs as $log ) { |
|
375 | - wp_delete_post( $log, true ); |
|
373 | + if ($logs) { |
|
374 | + foreach ($logs as $log) { |
|
375 | + wp_delete_post($log, true); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return mixed ID of the new log entry |
402 | 402 | */ |
403 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
403 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
404 | 404 | global $give_logs; |
405 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
405 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
406 | 406 | |
407 | 407 | return $log; |
408 | 408 | } |
409 | 409 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @since 1.4 |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) or exit; |
|
13 | +defined('ABSPATH') or exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class Give_Email_Access |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | function __construct() { |
31 | 31 | |
32 | 32 | // get it started |
33 | - add_action( 'init', array( $this, 'init' ) ); |
|
33 | + add_action('init', array($this, 'init')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function init() { |
41 | 41 | |
42 | - $is_enabled = give_get_option( 'email_access' ); |
|
42 | + $is_enabled = give_get_option('email_access'); |
|
43 | 43 | |
44 | 44 | //Non-logged in users only |
45 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
45 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | 49 | //Are db columns setup? |
50 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
51 | - if ( empty( $is_setup ) ) { |
|
50 | + $is_setup = give_get_option('email_access_installed'); |
|
51 | + if (empty($is_setup)) { |
|
52 | 52 | $this->create_columns(); |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Timeouts |
56 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
57 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
56 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
57 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
58 | 58 | |
59 | 59 | // Setup login |
60 | 60 | $this->check_for_token(); |
61 | 61 | |
62 | - if ( $this->token_exists ) { |
|
63 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
64 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
65 | - add_filter( 'give_get_users_purchases_args', array( $this, 'users_purchases_args' ) ); |
|
62 | + if ($this->token_exists) { |
|
63 | + add_filter('give_can_view_receipt', '__return_true'); |
|
64 | + add_filter('give_user_pending_verification', '__return_false'); |
|
65 | + add_filter('give_get_users_purchases_args', array($this, 'users_purchases_args')); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool |
75 | 75 | */ |
76 | - function can_send_email( $customer_id ) { |
|
76 | + function can_send_email($customer_id) { |
|
77 | 77 | global $wpdb; |
78 | 78 | |
79 | 79 | // Prevent multiple emails within X minutes |
80 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
80 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
81 | 81 | |
82 | 82 | // Does a user row exist? |
83 | 83 | $exists = (int) $wpdb->get_var( |
84 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
84 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
85 | 85 | ); |
86 | 86 | |
87 | - if ( 0 < $exists ) { |
|
87 | + if (0 < $exists) { |
|
88 | 88 | $row_id = (int) $wpdb->get_var( |
89 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
89 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
90 | 90 | ); |
91 | 91 | |
92 | - if ( $row_id < 1 ) { |
|
93 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
92 | + if ($row_id < 1) { |
|
93 | + give_set_error('give_email_access_attempts_exhausted', esc_html('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
94 | 94 | |
95 | 95 | return false; |
96 | 96 | } |
@@ -106,38 +106,38 @@ discard block |
||
106 | 106 | * @param $customer_id |
107 | 107 | * @param $email |
108 | 108 | */ |
109 | - function send_email( $customer_id, $email ) { |
|
109 | + function send_email($customer_id, $email) { |
|
110 | 110 | |
111 | - $verify_key = wp_generate_password( 20, false ); |
|
111 | + $verify_key = wp_generate_password(20, false); |
|
112 | 112 | |
113 | 113 | // Generate a new verify key |
114 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
114 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
115 | 115 | |
116 | 116 | // Get the purchase history URL |
117 | - $page_id = give_get_option( 'history_page' ); |
|
117 | + $page_id = give_get_option('history_page'); |
|
118 | 118 | |
119 | - $access_url = add_query_arg( array( |
|
119 | + $access_url = add_query_arg(array( |
|
120 | 120 | 'give_nl' => $verify_key, |
121 | - ), get_permalink( $page_id ) ); |
|
121 | + ), get_permalink($page_id)); |
|
122 | 122 | |
123 | 123 | //Nice subject and message |
124 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
124 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
125 | 125 | |
126 | - $message = esc_html( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
126 | + $message = esc_html('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
127 | 127 | |
128 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html( 'Access My Donation Details', 'give' ) . ' »</a>'; |
|
128 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html('Access My Donation Details', 'give').' »</a>'; |
|
129 | 129 | |
130 | 130 | $message .= "\n\n"; |
131 | 131 | $message .= "\n\n"; |
132 | - $message .= esc_html( 'Sincerely,', 'give' ); |
|
133 | - $message .= "\n" . get_bloginfo( 'name' ) . "\n"; |
|
132 | + $message .= esc_html('Sincerely,', 'give'); |
|
133 | + $message .= "\n".get_bloginfo('name')."\n"; |
|
134 | 134 | |
135 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
135 | + $message = apply_filters('give_email_access_token_message', $message); |
|
136 | 136 | |
137 | 137 | |
138 | 138 | // Send the email |
139 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html( 'Your Access Link', 'give' ) ) ); |
|
140 | - Give()->emails->send( $email, $subject, $message ); |
|
139 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html('Your Access Link', 'give'))); |
|
140 | + Give()->emails->send($email, $subject, $message); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -147,24 +147,24 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function check_for_token() { |
149 | 149 | |
150 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
150 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
151 | 151 | |
152 | 152 | // Check for cookie |
153 | - if ( empty( $token ) ) { |
|
154 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
153 | + if (empty($token)) { |
|
154 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
155 | 155 | } |
156 | 156 | |
157 | - if ( ! empty( $token ) ) { |
|
158 | - if ( ! $this->is_valid_token( $token ) ) { |
|
159 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
157 | + if ( ! empty($token)) { |
|
158 | + if ( ! $this->is_valid_token($token)) { |
|
159 | + if ( ! $this->is_valid_verify_key($token)) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | 164 | $this->token_exists = true; |
165 | 165 | // Set cookie |
166 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
167 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
166 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
167 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool |
177 | 177 | */ |
178 | - function is_valid_token( $token ) { |
|
178 | + function is_valid_token($token) { |
|
179 | 179 | |
180 | 180 | global $wpdb; |
181 | 181 | |
182 | 182 | // Make sure token isn't expired |
183 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
183 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
184 | 184 | |
185 | 185 | $email = $wpdb->get_var( |
186 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
186 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
187 | 187 | ); |
188 | 188 | |
189 | - if ( ! empty( $email ) ) { |
|
189 | + if ( ! empty($email)) { |
|
190 | 190 | $this->token_email = $email; |
191 | 191 | $this->token = $token; |
192 | 192 | |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | //Set error only if email access form isn't being submitted |
197 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
198 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give' ) ); |
|
197 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
198 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', 'Sorry, your access token has expired. Please request a new one below:', 'give')); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -210,25 +210,25 @@ discard block |
||
210 | 210 | * @param $email |
211 | 211 | * @param $verify_key |
212 | 212 | */ |
213 | - function set_verify_key( $customer_id, $email, $verify_key ) { |
|
213 | + function set_verify_key($customer_id, $email, $verify_key) { |
|
214 | 214 | global $wpdb; |
215 | 215 | |
216 | - $now = date( 'Y-m-d H:i:s' ); |
|
216 | + $now = date('Y-m-d H:i:s'); |
|
217 | 217 | |
218 | 218 | // Insert or update? |
219 | 219 | $row_id = (int) $wpdb->get_var( |
220 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
220 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
221 | 221 | ); |
222 | 222 | |
223 | 223 | // Update |
224 | - if ( ! empty( $row_id ) ) { |
|
224 | + if ( ! empty($row_id)) { |
|
225 | 225 | $wpdb->query( |
226 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
226 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
227 | 227 | ); |
228 | 228 | } // Insert |
229 | 229 | else { |
230 | 230 | $wpdb->query( |
231 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
231 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
232 | 232 | ); |
233 | 233 | } |
234 | 234 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return bool |
242 | 242 | */ |
243 | - function is_valid_verify_key( $token ) { |
|
243 | + function is_valid_verify_key($token) { |
|
244 | 244 | global $wpdb; |
245 | 245 | |
246 | 246 | // See if the verify_key exists |
247 | 247 | $row = $wpdb->get_row( |
248 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
248 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
249 | 249 | ); |
250 | 250 | |
251 | - $now = date( 'Y-m-d H:i:s' ); |
|
251 | + $now = date('Y-m-d H:i:s'); |
|
252 | 252 | |
253 | 253 | // Set token |
254 | - if ( ! empty( $row ) ) { |
|
254 | + if ( ! empty($row)) { |
|
255 | 255 | $wpdb->query( |
256 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
256 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
257 | 257 | ); |
258 | 258 | |
259 | 259 | $this->token_email = $row->email; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return mixed |
274 | 274 | */ |
275 | - function users_purchases_args( $args ) { |
|
275 | + function users_purchases_args($args) { |
|
276 | 276 | $args['user'] = $this->token_email; |
277 | 277 | |
278 | 278 | return $args; |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | global $wpdb; |
290 | 290 | |
291 | 291 | //Create columns in customers table |
292 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
292 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
293 | 293 | |
294 | 294 | //Columns added properly |
295 | - if ( $query ) { |
|
296 | - give_update_option( 'email_access_installed', 1 ); |
|
295 | + if ($query) { |
|
296 | + give_update_option('email_access_installed', 1); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | - $email_access = give_get_option( 'email_access' ); |
|
28 | + $email_access = give_get_option('email_access'); |
|
29 | 29 | |
30 | 30 | //Is user logged in? Does a session exist? Does an email-access token exist? |
31 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
31 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
32 | 32 | ob_start(); |
33 | - give_get_template_part( 'history', 'donations' ); |
|
33 | + give_get_template_part('history', 'donations'); |
|
34 | 34 | |
35 | 35 | return ob_get_clean(); |
36 | 36 | } //Is Email-based access enabled? |
37 | - elseif ( $email_access == 'on' ) { |
|
37 | + elseif ($email_access == 'on') { |
|
38 | 38 | |
39 | 39 | ob_start(); |
40 | - give_get_template_part( 'email', 'login-form' ); |
|
40 | + give_get_template_part('email', 'login-form'); |
|
41 | 41 | |
42 | 42 | return ob_get_clean(); |
43 | 43 | } else { |
44 | - $message = esc_html( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
45 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
44 | + $message = esc_html('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
45 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
49 | +add_shortcode('donation_history', 'give_donation_history'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Donation Form Shortcode |
@@ -60,53 +60,53 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | -function give_form_shortcode( $atts, $content = null ) { |
|
64 | - $atts = shortcode_atts( array( |
|
63 | +function give_form_shortcode($atts, $content = null) { |
|
64 | + $atts = shortcode_atts(array( |
|
65 | 65 | 'id' => '', |
66 | 66 | 'show_title' => true, |
67 | 67 | 'show_goal' => true, |
68 | 68 | 'show_content' => '', |
69 | 69 | 'float_labels' => '', |
70 | 70 | 'display_style' => '', |
71 | - ), $atts, 'give_form' ); |
|
71 | + ), $atts, 'give_form'); |
|
72 | 72 | |
73 | - foreach ( $atts as $key => $value ) { |
|
73 | + foreach ($atts as $key => $value) { |
|
74 | 74 | //convert shortcode_atts values to booleans |
75 | - if ( $key == 'show_title' ) { |
|
76 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
77 | - } elseif ( $key == 'show_goal' ) { |
|
78 | - $atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN ); |
|
75 | + if ($key == 'show_title') { |
|
76 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
77 | + } elseif ($key == 'show_goal') { |
|
78 | + $atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | //validate show_content value |
82 | - if ( $key == 'show_content' ) { |
|
83 | - if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) { |
|
84 | - $atts[ $key ] = ''; |
|
85 | - } else if ( $value == 'above' ) { |
|
86 | - $atts[ $key ] = 'give_pre_form'; |
|
87 | - } else if ( $value == 'below' ) { |
|
88 | - $atts[ $key ] = 'give_post_form'; |
|
82 | + if ($key == 'show_content') { |
|
83 | + if ( ! in_array($value, array('none', 'above', 'below'))) { |
|
84 | + $atts[$key] = ''; |
|
85 | + } else if ($value == 'above') { |
|
86 | + $atts[$key] = 'give_pre_form'; |
|
87 | + } else if ($value == 'below') { |
|
88 | + $atts[$key] = 'give_post_form'; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | //validate display_style and float_labels value |
93 | - if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) ) |
|
94 | - || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) ) |
|
93 | + if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal'))) |
|
94 | + || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled'))) |
|
95 | 95 | ) { |
96 | 96 | |
97 | - $atts[ $key ] = ''; |
|
97 | + $atts[$key] = ''; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | //get the Give Form |
102 | 102 | ob_start(); |
103 | - give_get_donation_form( $atts ); |
|
103 | + give_get_donation_form($atts); |
|
104 | 104 | $final_output = ob_get_clean(); |
105 | 105 | |
106 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
106 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
107 | 107 | } |
108 | 108 | |
109 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
109 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Donation Form Goal Shortcode |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function give_goal_shortcode( $atts, $content = null ) { |
|
124 | - $atts = shortcode_atts( array( |
|
123 | +function give_goal_shortcode($atts, $content = null) { |
|
124 | + $atts = shortcode_atts(array( |
|
125 | 125 | 'id' => '', |
126 | 126 | 'show_text' => true, |
127 | 127 | 'show_bar' => true, |
128 | - ), $atts, 'give_goal' ); |
|
128 | + ), $atts, 'give_goal'); |
|
129 | 129 | |
130 | 130 | |
131 | 131 | //get the Give Form |
132 | 132 | ob_start(); |
133 | 133 | |
134 | 134 | //Sanity check 1: ensure there is an ID Provided |
135 | - if ( empty( $atts['id'] ) ) { |
|
136 | - give_output_error( esc_html( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true ); |
|
135 | + if (empty($atts['id'])) { |
|
136 | + give_output_error(esc_html('Error: No Donation form ID for the shortcode provided.', 'give'), true); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //Sanity check 2: Check that this form even has Goals enabled |
140 | - $goal_option = get_post_meta( $atts['id'], '_give_goal_option', true ); |
|
141 | - if ( empty( $goal_option ) || $goal_option !== 'yes' ) { |
|
142 | - give_output_error( esc_html( 'Error: This form does not have Goals enabled.', 'give' ), true ); |
|
140 | + $goal_option = get_post_meta($atts['id'], '_give_goal_option', true); |
|
141 | + if (empty($goal_option) || $goal_option !== 'yes') { |
|
142 | + give_output_error(esc_html('Error: This form does not have Goals enabled.', 'give'), true); |
|
143 | 143 | } else { |
144 | 144 | //Passed all sanity checks: output Goal |
145 | - give_show_goal_progress( $atts['id'], $atts ); |
|
145 | + give_show_goal_progress($atts['id'], $atts); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $final_output = ob_get_clean(); |
149 | 149 | |
150 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
150 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
151 | 151 | } |
152 | 152 | |
153 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
153 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | /** |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * @uses give_login_form() |
168 | 168 | * @return string |
169 | 169 | */ |
170 | -function give_login_form_shortcode( $atts, $content = null ) { |
|
171 | - $atts = shortcode_atts( array( |
|
170 | +function give_login_form_shortcode($atts, $content = null) { |
|
171 | + $atts = shortcode_atts(array( |
|
172 | 172 | 'redirect' => '', |
173 | - ), $atts, 'give_login' ); |
|
173 | + ), $atts, 'give_login'); |
|
174 | 174 | |
175 | - return give_login_form( $atts['redirect'] ); |
|
175 | + return give_login_form($atts['redirect']); |
|
176 | 176 | } |
177 | 177 | |
178 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
178 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Register Shortcode |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | * @uses give_register_form() |
191 | 191 | * @return string |
192 | 192 | */ |
193 | -function give_register_form_shortcode( $atts, $content = null ) { |
|
194 | - $atts = shortcode_atts( array( |
|
193 | +function give_register_form_shortcode($atts, $content = null) { |
|
194 | + $atts = shortcode_atts(array( |
|
195 | 195 | 'redirect' => '', |
196 | - ), $atts, 'give_register' ); |
|
196 | + ), $atts, 'give_register'); |
|
197 | 197 | |
198 | - return give_register_form( $atts['redirect'] ); |
|
198 | + return give_register_form($atts['redirect']); |
|
199 | 199 | } |
200 | 200 | |
201 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
201 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
202 | 202 | |
203 | 203 | |
204 | 204 | /** |
@@ -213,62 +213,62 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return string |
215 | 215 | */ |
216 | -function give_receipt_shortcode( $atts, $content = null ) { |
|
216 | +function give_receipt_shortcode($atts, $content = null) { |
|
217 | 217 | |
218 | 218 | global $give_receipt_args, $payment; |
219 | 219 | |
220 | - $give_receipt_args = shortcode_atts( array( |
|
221 | - 'error' => esc_html( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ), |
|
220 | + $give_receipt_args = shortcode_atts(array( |
|
221 | + 'error' => esc_html('Sorry, you are missing the payment key to view this donation receipt.', 'give'), |
|
222 | 222 | 'price' => true, |
223 | 223 | 'donor' => true, |
224 | 224 | 'date' => true, |
225 | 225 | 'payment_key' => false, |
226 | 226 | 'payment_method' => true, |
227 | 227 | 'payment_id' => true |
228 | - ), $atts, 'give_receipt' ); |
|
228 | + ), $atts, 'give_receipt'); |
|
229 | 229 | |
230 | 230 | //set $session var |
231 | 231 | $session = give_get_purchase_session(); |
232 | 232 | |
233 | 233 | //set payment key var |
234 | - if ( isset( $_GET['payment_key'] ) ) { |
|
235 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
236 | - } elseif ( $session ) { |
|
234 | + if (isset($_GET['payment_key'])) { |
|
235 | + $payment_key = urldecode($_GET['payment_key']); |
|
236 | + } elseif ($session) { |
|
237 | 237 | $payment_key = $session['purchase_key']; |
238 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
238 | + } elseif ($give_receipt_args['payment_key']) { |
|
239 | 239 | $payment_key = $give_receipt_args['payment_key']; |
240 | 240 | } |
241 | 241 | |
242 | - $email_access = give_get_option( 'email_access' ); |
|
242 | + $email_access = give_get_option('email_access'); |
|
243 | 243 | |
244 | 244 | // No payment_key found & Email Access is Turned on: |
245 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
245 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
246 | 246 | |
247 | 247 | ob_start(); |
248 | 248 | |
249 | - give_get_template_part( 'email-login-form' ); |
|
249 | + give_get_template_part('email-login-form'); |
|
250 | 250 | |
251 | 251 | return ob_get_clean(); |
252 | 252 | |
253 | - } elseif ( ! isset( $payment_key ) ) { |
|
253 | + } elseif ( ! isset($payment_key)) { |
|
254 | 254 | |
255 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
255 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
260 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
259 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
260 | + $user_can_view = give_can_view_receipt($payment_key); |
|
261 | 261 | |
262 | 262 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt |
263 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
263 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
264 | 264 | |
265 | 265 | ob_start(); |
266 | 266 | |
267 | - give_get_template_part( 'email-login-form' ); |
|
267 | + give_get_template_part('email-login-form'); |
|
268 | 268 | |
269 | 269 | return ob_get_clean(); |
270 | 270 | |
271 | - } elseif ( ! $user_can_view ) { |
|
271 | + } elseif ( ! $user_can_view) { |
|
272 | 272 | |
273 | 273 | global $give_login_redirect; |
274 | 274 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | |
277 | 277 | ob_start(); |
278 | 278 | |
279 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html( 'You must be logged in to view this donation payment receipt.', 'give' ) ) ); |
|
279 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html('You must be logged in to view this donation payment receipt.', 'give'))); |
|
280 | 280 | |
281 | - give_get_template_part( 'shortcode', 'login' ); |
|
281 | + give_get_template_part('shortcode', 'login'); |
|
282 | 282 | |
283 | 283 | $login_form = ob_get_clean(); |
284 | 284 | |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * Or if user is logged in and the user can view sensitive shop data |
296 | 296 | * |
297 | 297 | */ |
298 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
299 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
298 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
299 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | ob_start(); |
303 | 303 | |
304 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
304 | + give_get_template_part('shortcode', 'receipt'); |
|
305 | 305 | |
306 | 306 | $display = ob_get_clean(); |
307 | 307 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | } |
312 | 312 | |
313 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
313 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
314 | 314 | |
315 | 315 | /** |
316 | 316 | * Profile Editor Shortcode |
@@ -330,18 +330,18 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return string Output generated from the profile editor |
332 | 332 | */ |
333 | -function give_profile_editor_shortcode( $atts, $content = null ) { |
|
333 | +function give_profile_editor_shortcode($atts, $content = null) { |
|
334 | 334 | |
335 | 335 | ob_start(); |
336 | 336 | |
337 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
337 | + give_get_template_part('shortcode', 'profile-editor'); |
|
338 | 338 | |
339 | 339 | $display = ob_get_clean(); |
340 | 340 | |
341 | 341 | return $display; |
342 | 342 | } |
343 | 343 | |
344 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
344 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * Process Profile Updater Form |
@@ -354,30 +354,30 @@ discard block |
||
354 | 354 | * |
355 | 355 | * @return false |
356 | 356 | */ |
357 | -function give_process_profile_editor_updates( $data ) { |
|
357 | +function give_process_profile_editor_updates($data) { |
|
358 | 358 | // Profile field change request |
359 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
359 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Nonce security |
364 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
364 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
365 | 365 | return false; |
366 | 366 | } |
367 | 367 | |
368 | 368 | $user_id = get_current_user_id(); |
369 | - $old_user_data = get_userdata( $user_id ); |
|
370 | - |
|
371 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
372 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
373 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
374 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
375 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
376 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
377 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
378 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
379 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
380 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
369 | + $old_user_data = get_userdata($user_id); |
|
370 | + |
|
371 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
372 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
373 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
374 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
375 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
376 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
377 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
378 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
379 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
380 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
381 | 381 | |
382 | 382 | $userdata = array( |
383 | 383 | 'ID' => $user_id, |
@@ -397,45 +397,45 @@ discard block |
||
397 | 397 | 'country' => $country |
398 | 398 | ); |
399 | 399 | |
400 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
400 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
401 | 401 | |
402 | 402 | // New password |
403 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
404 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
405 | - give_set_error( 'password_mismatch', esc_html( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
403 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
404 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
405 | + give_set_error('password_mismatch', esc_html('The passwords you entered do not match. Please try again.', 'give')); |
|
406 | 406 | } else { |
407 | 407 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | // Make sure the new email doesn't belong to another user |
412 | - if ( $email != $old_user_data->user_email ) { |
|
413 | - if ( email_exists( $email ) ) { |
|
414 | - give_set_error( 'email_exists', esc_html( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
412 | + if ($email != $old_user_data->user_email) { |
|
413 | + if (email_exists($email)) { |
|
414 | + give_set_error('email_exists', esc_html('The email you entered belongs to another user. Please use another.', 'give')); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | 418 | // Check for errors |
419 | 419 | $errors = give_get_errors(); |
420 | 420 | |
421 | - if ( $errors ) { |
|
421 | + if ($errors) { |
|
422 | 422 | // Send back to the profile editor if there are errors |
423 | - wp_redirect( $data['give_redirect'] ); |
|
423 | + wp_redirect($data['give_redirect']); |
|
424 | 424 | give_die(); |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Update the user |
428 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
429 | - $updated = wp_update_user( $userdata ); |
|
428 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
429 | + $updated = wp_update_user($userdata); |
|
430 | 430 | |
431 | - if ( $updated ) { |
|
432 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
433 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
431 | + if ($updated) { |
|
432 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
433 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
434 | 434 | give_die(); |
435 | 435 | } |
436 | 436 | |
437 | 437 | return false; |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
440 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
|
441 | 441 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => esc_html( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => esc_html( 'PayPal', 'give' ), |
|
29 | - 'supports' => array( 'buy_now' ) |
|
27 | + 'admin_label' => esc_html('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => esc_html('PayPal', 'give'), |
|
29 | + 'supports' => array('buy_now') |
|
30 | 30 | ), |
31 | 31 | 'manual' => array( |
32 | - 'admin_label' => esc_html( 'Test Payment', 'give' ), |
|
33 | - 'checkout_label' => esc_html( 'Test Payment', 'give' ) |
|
32 | + 'admin_label' => esc_html('Test Payment', 'give'), |
|
33 | + 'checkout_label' => esc_html('Test Payment', 'give') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | 36 | |
37 | - return apply_filters( 'give_payment_gateways', $gateways ); |
|
37 | + return apply_filters('give_payment_gateways', $gateways); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | |
49 | 49 | $gateways = give_get_payment_gateways(); |
50 | 50 | |
51 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
51 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
52 | 52 | |
53 | 53 | $gateway_list = array(); |
54 | 54 | |
55 | - foreach ( $gateways as $key => $gateway ) { |
|
56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
57 | - $gateway_list[ $key ] = $gateway; |
|
55 | + foreach ($gateways as $key => $gateway) { |
|
56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
57 | + $gateway_list[$key] = $gateway; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Set order of payment gateway in list. |
62 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
62 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
63 | 63 | |
64 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
64 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return boolean true if enabled, false otherwise |
75 | 75 | */ |
76 | -function give_is_gateway_active( $gateway ) { |
|
76 | +function give_is_gateway_active($gateway) { |
|
77 | 77 | $gateways = give_get_enabled_payment_gateways(); |
78 | 78 | |
79 | - $ret = array_key_exists( $gateway, $gateways ); |
|
79 | + $ret = array_key_exists($gateway, $gateways); |
|
80 | 80 | |
81 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
81 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string Gateway ID |
93 | 93 | */ |
94 | -function give_get_default_gateway( $form_id ) { |
|
94 | +function give_get_default_gateway($form_id) { |
|
95 | 95 | |
96 | 96 | global $give_options; |
97 | 97 | |
98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
100 | 100 | |
101 | 101 | //Single Form settings varies compared to the Global default settings |
102 | - if ( ! empty( $form_default ) && |
|
102 | + if ( ! empty($form_default) && |
|
103 | 103 | $form_id !== null && |
104 | 104 | $default !== $form_default && |
105 | 105 | $form_default !== 'global' && |
106 | - give_is_gateway_active( $form_default ) |
|
106 | + give_is_gateway_active($form_default) |
|
107 | 107 | ) { |
108 | 108 | $default = $form_default; |
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_default_gateway', $default ); |
|
111 | + return apply_filters('give_default_gateway', $default); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string Gateway admin label |
122 | 122 | */ |
123 | -function give_get_gateway_admin_label( $gateway ) { |
|
123 | +function give_get_gateway_admin_label($gateway) { |
|
124 | 124 | $gateways = give_get_enabled_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
127 | 127 | |
128 | - if ( $gateway == 'manual' && $payment ) { |
|
129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
130 | - $label = esc_html( 'Test Donation', 'give' ); |
|
128 | + if ($gateway == 'manual' && $payment) { |
|
129 | + if (give_get_payment_amount($payment) == 0) { |
|
130 | + $label = esc_html('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Checkout label for the gateway |
145 | 145 | */ |
146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
146 | +function give_get_gateway_checkout_label($gateway) { |
|
147 | 147 | $gateways = give_get_enabled_payment_gateways(); |
148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
149 | 149 | |
150 | - if ( $gateway == 'manual' ) { |
|
151 | - $label = esc_html( 'Test Donation', 'give' ); |
|
150 | + if ($gateway == 'manual') { |
|
151 | + $label = esc_html('Test Donation', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Options the gateway supports |
165 | 165 | */ |
166 | -function give_get_gateway_supports( $gateway ) { |
|
166 | +function give_get_gateway_supports($gateway) { |
|
167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
169 | 169 | |
170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return bool |
181 | 181 | */ |
182 | -function give_gateway_supports_buy_now( $gateway ) { |
|
183 | - $supports = give_get_gateway_supports( $gateway ); |
|
184 | - $ret = in_array( 'buy_now', $supports ); |
|
182 | +function give_gateway_supports_buy_now($gateway) { |
|
183 | + $supports = give_get_gateway_supports($gateway); |
|
184 | + $ret = in_array('buy_now', $supports); |
|
185 | 185 | |
186 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
186 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | $gateways = give_get_enabled_payment_gateways(); |
197 | 197 | $ret = false; |
198 | 198 | |
199 | - if ( $gateways ) { |
|
200 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
201 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
199 | + if ($gateways) { |
|
200 | + foreach ($gateways as $gateway_id => $gateway) { |
|
201 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
202 | 202 | $ret = true; |
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
208 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
221 | +function give_send_to_gateway($gateway, $payment_data) { |
|
222 | 222 | |
223 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
223 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
224 | 224 | |
225 | 225 | // $gateway must match the ID used when registering the gateway |
226 | - do_action( 'give_gateway_' . $gateway, $payment_data ); |
|
226 | + do_action('give_gateway_'.$gateway, $payment_data); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -240,32 +240,32 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string $enabled_gateway The slug of the gateway |
242 | 242 | */ |
243 | -function give_get_chosen_gateway( $form_id ) { |
|
243 | +function give_get_chosen_gateway($form_id) { |
|
244 | 244 | $gateways = give_get_enabled_payment_gateways(); |
245 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
246 | - if ( empty( $request_form_id ) ) { |
|
247 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
245 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
246 | + if (empty($request_form_id)) { |
|
247 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
248 | 248 | } |
249 | - $chosen = give_get_default_gateway( $form_id ); |
|
249 | + $chosen = give_get_default_gateway($form_id); |
|
250 | 250 | $enabled_gateway = ''; |
251 | 251 | |
252 | 252 | //Take into account request Form ID args |
253 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
253 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
254 | 254 | $chosen = $_REQUEST['payment-mode']; |
255 | 255 | } |
256 | 256 | |
257 | - if ( $chosen ) { |
|
258 | - $enabled_gateway = urldecode( $chosen ); |
|
259 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
260 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
257 | + if ($chosen) { |
|
258 | + $enabled_gateway = urldecode($chosen); |
|
259 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
260 | + foreach ($gateways as $gateway_id => $gateway): |
|
261 | 261 | $enabled_gateway = $gateway_id; |
262 | 262 | endforeach; |
263 | 263 | } else { |
264 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
264 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
268 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return int ID of the new log entry |
284 | 284 | */ |
285 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
286 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
285 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
286 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return int |
298 | 298 | */ |
299 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
299 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
300 | 300 | |
301 | 301 | $ret = 0; |
302 | 302 | $args = array( |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | 'fields' => 'ids' |
309 | 309 | ); |
310 | 310 | |
311 | - $payments = new WP_Query( $args ); |
|
311 | + $payments = new WP_Query($args); |
|
312 | 312 | |
313 | - if ( $payments ) { |
|
313 | + if ($payments) { |
|
314 | 314 | $ret = $payments->post_count; |
315 | 315 | } |
316 | 316 | |
@@ -327,27 +327,27 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return array $gateways All the available gateways |
329 | 329 | */ |
330 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
330 | +function give_get_ordered_payment_gateways($gateways) { |
|
331 | 331 | |
332 | 332 | // Get gateways setting. |
333 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
333 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
334 | 334 | |
335 | 335 | // Return from here if we do not have gateways setting. |
336 | - if ( empty( $gateways_setting ) ) { |
|
336 | + if (empty($gateways_setting)) { |
|
337 | 337 | return $gateways; |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Reverse array to order payment gateways. |
341 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
341 | + $gateways_setting = array_reverse($gateways_setting); |
|
342 | 342 | |
343 | 343 | // Reorder gateways array |
344 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
344 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
345 | 345 | |
346 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
347 | - unset( $gateways[ $gateway_key ] ); |
|
346 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
347 | + unset($gateways[$gateway_key]); |
|
348 | 348 | |
349 | - if(!empty($new_gateway_value)) { |
|
350 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
349 | + if ( ! empty($new_gateway_value)) { |
|
350 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -358,5 +358,5 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @param array $gateways All the available gateways |
360 | 360 | */ |
361 | - return apply_filters( 'give_payment_gateways_order', $gateways ); |
|
361 | + return apply_filters('give_payment_gateways_order', $gateways); |
|
362 | 362 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html( 'Nonce verification has failed.', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html('Nonce verification has failed.', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
43 | 43 | |
44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment |
60 | - $payment = give_insert_payment( $payment_data ); |
|
60 | + $payment = give_insert_payment($payment_data); |
|
61 | 61 | |
62 | 62 | // Check payment |
63 | - if ( ! $payment ) { |
|
63 | + if ( ! $payment) { |
|
64 | 64 | // Record the error |
65 | 65 | give_record_gateway_error( |
66 | - esc_html( 'Payment Error', 'give' ), |
|
66 | + esc_html('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment |
73 | 73 | ); |
74 | 74 | // Problems? send back |
75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
76 | 76 | } else { |
77 | 77 | // Only send to PayPal if the pending payment is created successfully |
78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
79 | 79 | |
80 | 80 | // Get the success url |
81 | - $return_url = add_query_arg( array( |
|
81 | + $return_url = add_query_arg(array( |
|
82 | 82 | 'payment-confirmation' => 'paypal', |
83 | 83 | 'payment-id' => $payment |
84 | 84 | |
85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
85 | + ), get_permalink(give_get_option('success_page'))); |
|
86 | 86 | |
87 | 87 | // Get the PayPal redirect uri |
88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
89 | 89 | |
90 | 90 | //Item name - pass level name if variable priced |
91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
92 | 92 | |
93 | 93 | //Verify has variable prices |
94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
95 | 95 | |
96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
97 | 97 | |
98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
103 | 103 | //user custom amount text if any, fallback to default if not |
104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html( 'Custom Amount', 'give' ) ); |
|
104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html('Custom Amount', 'give')); |
|
105 | 105 | |
106 | 106 | } //Is there any donation level text? |
107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
108 | - $item_name .= ' - ' . $item_price_level_text; |
|
107 | + elseif ( ! empty($item_price_level_text)) { |
|
108 | + $item_name .= ' - '.$item_price_level_text; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } //Single donation: Custom Amount |
112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
114 | 114 | //user custom amount text if any, fallback to default if not |
115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html( 'Custom Amount', 'give' ) ); |
|
115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html('Custom Amount', 'give')); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Setup PayPal arguments |
119 | 119 | $paypal_args = array( |
120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
120 | + 'business' => give_get_option('paypal_email', false), |
|
121 | 121 | 'email' => $purchase_data['user_email'], |
122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | 'shipping' => '0', |
129 | 129 | 'no_note' => '1', |
130 | 130 | 'currency_code' => give_get_currency(), |
131 | - 'charset' => get_bloginfo( 'charset' ), |
|
131 | + 'charset' => get_bloginfo('charset'), |
|
132 | 132 | 'custom' => $payment, |
133 | 133 | 'rm' => '2', |
134 | 134 | 'return' => $return_url, |
135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
136 | 136 | 'notify_url' => $listener_url, |
137 | 137 | 'page_style' => give_get_paypal_page_style(), |
138 | - 'cbt' => get_bloginfo( 'name' ), |
|
138 | + 'cbt' => get_bloginfo('name'), |
|
139 | 139 | 'bn' => 'givewp_SP' |
140 | 140 | ); |
141 | 141 | |
142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
147 | 147 | } |
148 | 148 | |
149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
150 | 150 | $paypal_extra_args = array( |
151 | 151 | 'cmd' => '_xclick', |
152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
161 | 161 | |
162 | 162 | // Build query |
163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
164 | 164 | |
165 | 165 | // Fix for some sites that encode the entities |
166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
167 | 167 | |
168 | 168 | // Redirect to PayPal |
169 | - wp_redirect( $paypal_redirect ); |
|
169 | + wp_redirect($paypal_redirect); |
|
170 | 170 | exit; |
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function give_listen_for_paypal_ipn() { |
184 | 184 | // Regular PayPal IPN |
185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
186 | - do_action( 'give_verify_paypal_ipn' ); |
|
185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
186 | + do_action('give_verify_paypal_ipn'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
190 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Process PayPal IPN |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | function give_process_paypal_ipn() { |
199 | 199 | |
200 | 200 | // Check the request method is POST |
201 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
201 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | $post_data = ''; |
207 | 207 | |
208 | 208 | // Fallback just in case post_max_size is lower than needed |
209 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
210 | - $post_data = file_get_contents( 'php://input' ); |
|
209 | + if (ini_get('allow_url_fopen')) { |
|
210 | + $post_data = file_get_contents('php://input'); |
|
211 | 211 | } else { |
212 | 212 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
213 | - ini_set( 'post_max_size', '12M' ); |
|
213 | + ini_set('post_max_size', '12M'); |
|
214 | 214 | } |
215 | 215 | // Start the encoded data collection with notification command |
216 | 216 | $encoded_data = 'cmd=_notify-validate'; |
@@ -219,40 +219,40 @@ discard block |
||
219 | 219 | $arg_separator = give_get_php_arg_separator_output(); |
220 | 220 | |
221 | 221 | // Verify there is a post_data |
222 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
222 | + if ($post_data || strlen($post_data) > 0) { |
|
223 | 223 | // Append the data |
224 | - $encoded_data .= $arg_separator . $post_data; |
|
224 | + $encoded_data .= $arg_separator.$post_data; |
|
225 | 225 | } else { |
226 | 226 | // Check if POST is empty |
227 | - if ( empty( $_POST ) ) { |
|
227 | + if (empty($_POST)) { |
|
228 | 228 | // Nothing to do |
229 | 229 | return; |
230 | 230 | } else { |
231 | 231 | // Loop through each POST |
232 | - foreach ( $_POST as $key => $value ) { |
|
232 | + foreach ($_POST as $key => $value) { |
|
233 | 233 | // Encode the value and append the data |
234 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
234 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Convert collected post data to an array |
240 | - parse_str( $encoded_data, $encoded_data_array ); |
|
240 | + parse_str($encoded_data, $encoded_data_array); |
|
241 | 241 | |
242 | - foreach ( $encoded_data_array as $key => $value ) { |
|
242 | + foreach ($encoded_data_array as $key => $value) { |
|
243 | 243 | |
244 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
245 | - $new_key = str_replace( '&', '&', $key ); |
|
246 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
244 | + if (false !== strpos($key, 'amp;')) { |
|
245 | + $new_key = str_replace('&', '&', $key); |
|
246 | + $new_key = str_replace('amp;', '&', $new_key); |
|
247 | 247 | |
248 | - unset( $encoded_data_array[ $key ] ); |
|
249 | - $encoded_data_array[ $new_key ] = $value; |
|
248 | + unset($encoded_data_array[$key]); |
|
249 | + $encoded_data_array[$new_key] = $value; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } |
253 | 253 | |
254 | 254 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
255 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
255 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
256 | 256 | |
257 | 257 | $remote_post_vars = array( |
258 | 258 | 'method' => 'POST', |
@@ -272,27 +272,27 @@ discard block |
||
272 | 272 | ); |
273 | 273 | |
274 | 274 | // Validate the IPN |
275 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
275 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
276 | 276 | |
277 | - if ( is_wp_error( $api_response ) ) { |
|
277 | + if (is_wp_error($api_response)) { |
|
278 | 278 | give_record_gateway_error( |
279 | - esc_html( 'IPN Error', 'give' ), |
|
279 | + esc_html('IPN Error', 'give'), |
|
280 | 280 | sprintf( |
281 | 281 | /* translators: %s: Paypal IPN response */ |
282 | - esc_html( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
283 | - json_encode( $api_response ) |
|
282 | + esc_html('Invalid IPN verification response. IPN data: %s', 'give'), |
|
283 | + json_encode($api_response) |
|
284 | 284 | ) |
285 | 285 | ); |
286 | 286 | return; // Something went wrong |
287 | 287 | } |
288 | 288 | |
289 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
289 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
290 | 290 | give_record_gateway_error( |
291 | - esc_html( 'IPN Error', 'give' ), |
|
291 | + esc_html('IPN Error', 'give'), |
|
292 | 292 | sprintf( |
293 | 293 | /* translators: %s: Paypal IPN response */ |
294 | - esc_html( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
295 | - json_encode( $api_response ) |
|
294 | + esc_html('Invalid IPN verification response. IPN data: %s', 'give'), |
|
295 | + json_encode($api_response) |
|
296 | 296 | ) |
297 | 297 | ); |
298 | 298 | return; // Response not okay |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | // Check if $post_data_array has been populated |
304 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
304 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | 'payment_status' => '' |
311 | 311 | ); |
312 | 312 | |
313 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
313 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
314 | 314 | |
315 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
315 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
316 | 316 | |
317 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
317 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
318 | 318 | // Allow PayPal IPN types to be processed separately |
319 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
319 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
320 | 320 | } else { |
321 | 321 | // Fallback to web accept just in case the txn_type isn't present |
322 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
322 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
323 | 323 | } |
324 | 324 | exit; |
325 | 325 | } |
326 | 326 | |
327 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
327 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Process web accept (one time) payment IPNs |
@@ -335,224 +335,224 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return void |
337 | 337 | */ |
338 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
338 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
339 | 339 | |
340 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
340 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Collect payment details |
349 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
349 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
350 | 350 | $paypal_amount = $data['mc_gross']; |
351 | - $payment_status = strtolower( $data['payment_status'] ); |
|
352 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
353 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
354 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
351 | + $payment_status = strtolower($data['payment_status']); |
|
352 | + $currency_code = strtolower($data['mc_currency']); |
|
353 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
354 | + $payment_meta = give_get_payment_meta($payment_id); |
|
355 | 355 | |
356 | 356 | |
357 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
357 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
358 | 358 | return; // this isn't a PayPal standard IPN |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Verify payment recipient |
362 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
362 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
363 | 363 | |
364 | 364 | give_record_gateway_error( |
365 | - esc_html( 'IPN Error', 'give' ), |
|
365 | + esc_html('IPN Error', 'give'), |
|
366 | 366 | sprintf( |
367 | 367 | /* translators: %s: Paypal IPN response */ |
368 | - esc_html( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
369 | - json_encode( $data ) |
|
368 | + esc_html('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
369 | + json_encode($data) |
|
370 | 370 | ), |
371 | 371 | $payment_id |
372 | 372 | ); |
373 | - give_update_payment_status( $payment_id, 'failed' ); |
|
374 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
373 | + give_update_payment_status($payment_id, 'failed'); |
|
374 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid PayPal business email.', 'give')); |
|
375 | 375 | |
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Verify payment currency |
380 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
380 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
381 | 381 | |
382 | 382 | give_record_gateway_error( |
383 | - esc_html( 'IPN Error', 'give' ), |
|
383 | + esc_html('IPN Error', 'give'), |
|
384 | 384 | sprintf( |
385 | 385 | /* translators: %s: Paypal IPN response */ |
386 | - esc_html( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
387 | - json_encode( $data ) |
|
386 | + esc_html('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
387 | + json_encode($data) |
|
388 | 388 | ), |
389 | 389 | $payment_id |
390 | 390 | ); |
391 | - give_update_payment_status( $payment_id, 'failed' ); |
|
392 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
391 | + give_update_payment_status($payment_id, 'failed'); |
|
392 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
393 | 393 | |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
397 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
398 | 398 | |
399 | 399 | // No email associated with purchase, so store from PayPal |
400 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
400 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
401 | 401 | |
402 | 402 | // Setup and store the donors's details |
403 | 403 | $address = array(); |
404 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
405 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
406 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
407 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
408 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
404 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
405 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
406 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
407 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
408 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
409 | 409 | |
410 | 410 | $user_info = array( |
411 | 411 | 'id' => '-1', |
412 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
413 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
414 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
412 | + 'email' => sanitize_text_field($data['payer_email']), |
|
413 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
414 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
415 | 415 | 'discount' => '', |
416 | 416 | 'address' => $address |
417 | 417 | ); |
418 | 418 | |
419 | 419 | $payment_meta['user_info'] = $user_info; |
420 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
420 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
423 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
424 | 424 | |
425 | 425 | // Process a refund |
426 | - give_process_paypal_refund( $data, $payment_id ); |
|
426 | + give_process_paypal_refund($data, $payment_id); |
|
427 | 427 | |
428 | 428 | } else { |
429 | 429 | |
430 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
430 | + if (get_post_status($payment_id) == 'publish') { |
|
431 | 431 | return; // Only complete payments once |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Retrieve the total purchase amount (before PayPal) |
435 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
435 | + $payment_amount = give_get_payment_amount($payment_id); |
|
436 | 436 | |
437 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
437 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
438 | 438 | // The prices don't match |
439 | 439 | give_record_gateway_error( |
440 | - esc_html( 'IPN Error', 'give' ), |
|
440 | + esc_html('IPN Error', 'give'), |
|
441 | 441 | sprintf( |
442 | 442 | /* translators: %s: Paypal IPN response */ |
443 | - esc_html( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
444 | - json_encode( $data ) |
|
443 | + esc_html('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
444 | + json_encode($data) |
|
445 | 445 | ), |
446 | 446 | $payment_id |
447 | 447 | ); |
448 | - give_update_payment_status( $payment_id, 'failed' ); |
|
449 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
448 | + give_update_payment_status($payment_id, 'failed'); |
|
449 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
450 | 450 | |
451 | 451 | return; |
452 | 452 | } |
453 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
453 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
454 | 454 | // Purchase keys don't match |
455 | 455 | give_record_gateway_error( |
456 | - esc_html( 'IPN Error', 'give' ), |
|
456 | + esc_html('IPN Error', 'give'), |
|
457 | 457 | sprintf( |
458 | 458 | /* translators: %s: Paypal IPN response */ |
459 | - esc_html( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
460 | - json_encode( $data ) |
|
459 | + esc_html('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
460 | + json_encode($data) |
|
461 | 461 | ), |
462 | 462 | $payment_id |
463 | 463 | ); |
464 | - give_update_payment_status( $payment_id, 'failed' ); |
|
465 | - give_insert_payment_note( $payment_id, esc_html( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
464 | + give_update_payment_status($payment_id, 'failed'); |
|
465 | + give_insert_payment_note($payment_id, esc_html('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
466 | 466 | |
467 | 467 | return; |
468 | 468 | } |
469 | 469 | |
470 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
470 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
471 | 471 | give_insert_payment_note( |
472 | 472 | $payment_id, |
473 | 473 | sprintf( |
474 | 474 | /* translators: %s: Paypal transaction ID */ |
475 | - esc_html( 'PayPal Transaction ID: %s', 'give' ), |
|
475 | + esc_html('PayPal Transaction ID: %s', 'give'), |
|
476 | 476 | $data['txn_id'] |
477 | 477 | ) |
478 | 478 | ); |
479 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
480 | - give_update_payment_status( $payment_id, 'publish' ); |
|
481 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
479 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
480 | + give_update_payment_status($payment_id, 'publish'); |
|
481 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
482 | 482 | |
483 | 483 | // Look for possible pending reasons, such as an echeck |
484 | 484 | |
485 | 485 | $note = ''; |
486 | 486 | |
487 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
487 | + switch (strtolower($data['pending_reason'])) { |
|
488 | 488 | |
489 | 489 | case 'echeck' : |
490 | 490 | |
491 | - $note = esc_html( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
491 | + $note = esc_html('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
492 | 492 | |
493 | 493 | break; |
494 | 494 | |
495 | 495 | case 'address' : |
496 | 496 | |
497 | - $note = esc_html( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
497 | + $note = esc_html('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
498 | 498 | |
499 | 499 | break; |
500 | 500 | |
501 | 501 | case 'intl' : |
502 | 502 | |
503 | - $note = esc_html( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
503 | + $note = esc_html('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
504 | 504 | |
505 | 505 | break; |
506 | 506 | |
507 | 507 | case 'multi-currency' : |
508 | 508 | |
509 | - $note = esc_html( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
509 | + $note = esc_html('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
510 | 510 | |
511 | 511 | break; |
512 | 512 | |
513 | 513 | case 'paymentreview' : |
514 | 514 | case 'regulatory_review' : |
515 | 515 | |
516 | - $note = esc_html( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
516 | + $note = esc_html('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
517 | 517 | |
518 | 518 | break; |
519 | 519 | |
520 | 520 | case 'unilateral' : |
521 | 521 | |
522 | - $note = esc_html( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
522 | + $note = esc_html('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
523 | 523 | |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'upgrade' : |
527 | 527 | |
528 | - $note = esc_html( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
528 | + $note = esc_html('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
529 | 529 | |
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'verify' : |
533 | 533 | |
534 | - $note = esc_html( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
534 | + $note = esc_html('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
535 | 535 | |
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'other' : |
539 | 539 | |
540 | - $note = esc_html( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
540 | + $note = esc_html('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
541 | 541 | |
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
545 | 545 | |
546 | - if ( ! empty( $note ) ) { |
|
546 | + if ( ! empty($note)) { |
|
547 | 547 | |
548 | - give_insert_payment_note( $payment_id, $note ); |
|
548 | + give_insert_payment_note($payment_id, $note); |
|
549 | 549 | |
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
555 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Process PayPal IPN Refunds |
@@ -563,28 +563,28 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return void |
565 | 565 | */ |
566 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
566 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
567 | 567 | |
568 | 568 | // Collect payment details |
569 | 569 | |
570 | - if ( empty( $payment_id ) ) { |
|
570 | + if (empty($payment_id)) { |
|
571 | 571 | return; |
572 | 572 | } |
573 | 573 | |
574 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
574 | + if (get_post_status($payment_id) == 'refunded') { |
|
575 | 575 | return; // Only refund payments once |
576 | 576 | } |
577 | 577 | |
578 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
578 | + $payment_amount = give_get_payment_amount($payment_id); |
|
579 | 579 | $refund_amount = $data['payment_gross'] * - 1; |
580 | 580 | |
581 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
581 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
582 | 582 | |
583 | 583 | give_insert_payment_note( |
584 | 584 | $payment_id, |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: Paypal parent transaction ID */ |
587 | - esc_html( 'Partial PayPal refund processed: %s', 'give' ), |
|
587 | + esc_html('Partial PayPal refund processed: %s', 'give'), |
|
588 | 588 | $data['parent_txn_id'] |
589 | 589 | ) |
590 | 590 | ); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $payment_id, |
598 | 598 | sprintf( |
599 | 599 | /* translators: %s: Paypal parent transaction ID */ |
600 | - esc_html( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
600 | + esc_html('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
601 | 601 | $data['parent_txn_id'], $data['reason_code'] |
602 | 602 | ) |
603 | 603 | ); |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | $payment_id, |
606 | 606 | sprintf( |
607 | 607 | /* translators: %s: Paypal transaction ID */ |
608 | - esc_html( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
608 | + esc_html('PayPal Refund Transaction ID: %s', 'give'), |
|
609 | 609 | $data['txn_id'] |
610 | 610 | ) |
611 | 611 | ); |
612 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
612 | + give_update_payment_status($payment_id, 'refunded'); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @return string |
623 | 623 | */ |
624 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
624 | +function give_get_paypal_redirect($ssl_check = false) { |
|
625 | 625 | |
626 | - if ( is_ssl() || ! $ssl_check ) { |
|
626 | + if (is_ssl() || ! $ssl_check) { |
|
627 | 627 | $protocal = 'https://'; |
628 | 628 | } else { |
629 | 629 | $protocal = 'http://'; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Check the current payment mode |
633 | - if ( give_is_test_mode() ) { |
|
633 | + if (give_is_test_mode()) { |
|
634 | 634 | // Test mode |
635 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
635 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
636 | 636 | } else { |
637 | 637 | // Live mode |
638 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
638 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
639 | 639 | } |
640 | 640 | |
641 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
641 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | * @return string |
649 | 649 | */ |
650 | 650 | function give_get_paypal_page_style() { |
651 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
652 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
651 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
652 | + return apply_filters('give_paypal_page_style', $page_style); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -664,27 +664,27 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | * |
666 | 666 | */ |
667 | -function give_paypal_success_page_content( $content ) { |
|
667 | +function give_paypal_success_page_content($content) { |
|
668 | 668 | |
669 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
669 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
670 | 670 | return $content; |
671 | 671 | } |
672 | 672 | |
673 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
673 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
674 | 674 | |
675 | - if ( ! $payment_id ) { |
|
675 | + if ( ! $payment_id) { |
|
676 | 676 | $session = give_get_purchase_session(); |
677 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
677 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
678 | 678 | } |
679 | 679 | |
680 | - $payment = get_post( $payment_id ); |
|
680 | + $payment = get_post($payment_id); |
|
681 | 681 | |
682 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
682 | + if ($payment && 'pending' == $payment->post_status) { |
|
683 | 683 | |
684 | 684 | // Payment is still pending so show processing indicator to fix the Race Condition |
685 | 685 | ob_start(); |
686 | 686 | |
687 | - give_get_template_part( 'payment', 'processing' ); |
|
687 | + give_get_template_part('payment', 'processing'); |
|
688 | 688 | |
689 | 689 | $content = ob_get_clean(); |
690 | 690 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | } |
696 | 696 | |
697 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
697 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
698 | 698 | |
699 | 699 | /** |
700 | 700 | * Given a Payment ID, extract the transaction ID |
@@ -705,22 +705,22 @@ discard block |
||
705 | 705 | * |
706 | 706 | * @return string Transaction ID |
707 | 707 | */ |
708 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
708 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
709 | 709 | |
710 | 710 | $transaction_id = ''; |
711 | - $notes = give_get_payment_notes( $payment_id ); |
|
711 | + $notes = give_get_payment_notes($payment_id); |
|
712 | 712 | |
713 | - foreach ( $notes as $note ) { |
|
714 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
713 | + foreach ($notes as $note) { |
|
714 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
715 | 715 | $transaction_id = $match[1]; |
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
720 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
721 | 721 | } |
722 | 722 | |
723 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
723 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
724 | 724 | |
725 | 725 | /** |
726 | 726 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @return string A link to the PayPal transaction details |
734 | 734 | */ |
735 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
735 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
736 | 736 | |
737 | 737 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
738 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
738 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
739 | 739 | |
740 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
740 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
741 | 741 | |
742 | 742 | } |
743 | 743 | |
744 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
744 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html( 'Nonce verification has failed', 'give' ), esc_html( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html('Nonce verification has failed', 'give'), esc_html('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html( 'Payment Error', 'give' ), |
|
62 | + esc_html('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |