@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return static |
52 | 52 | */ |
53 | 53 | public static function get_instance() { |
54 | - if ( null === static::$instance ) { |
|
54 | + if (null === static::$instance) { |
|
55 | 55 | self::$instance = new static(); |
56 | 56 | self::$instance->setup(); |
57 | 57 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @since 1.8.13 |
67 | 67 | */ |
68 | 68 | private function setup() { |
69 | - add_filter( 'cron_schedules', array( self::$instance, '__add_schedules' ) ); |
|
70 | - add_action( 'wp', array( self::$instance, '__schedule_events' ) ); |
|
69 | + add_filter('cron_schedules', array(self::$instance, '__add_schedules')); |
|
70 | + add_action('wp', array(self::$instance, '__schedule_events')); |
|
71 | 71 | |
72 | 72 | // Load async event only when cron is running. |
73 | - if( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
74 | - add_action( 'init', array( self::$instance, '__load_async_events' ) ); |
|
73 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
74 | + add_action('init', array(self::$instance, '__load_async_events')); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | * @since 1.8.13 |
83 | 83 | */ |
84 | 84 | public function __load_async_events() { |
85 | - $async_events = get_option( 'give_async_events', array() ); |
|
85 | + $async_events = get_option('give_async_events', array()); |
|
86 | 86 | |
87 | 87 | // Bailout. |
88 | - if ( empty( $async_events ) ) { |
|
88 | + if (empty($async_events)) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - foreach ( $async_events as $index => $event ) { |
|
92 | + foreach ($async_events as $index => $event) { |
|
93 | 93 | // Set cron name. |
94 | 94 | $cron_name = "give_async_scheduled_events_{$index}"; |
95 | 95 | |
96 | 96 | // Setup cron. |
97 | - wp_schedule_single_event( current_time( 'timestamp', 1 ), $cron_name, $event['params'] ); |
|
97 | + wp_schedule_single_event(current_time('timestamp', 1), $cron_name, $event['params']); |
|
98 | 98 | |
99 | 99 | // Add cron action. |
100 | - add_action( $cron_name, $event['callback'], 10, count( $event['params'] ) ); |
|
101 | - add_action( $cron_name, array( $this, '__delete_async_events' ), 9999, 0 ); |
|
100 | + add_action($cron_name, $event['callback'], 10, count($event['params'])); |
|
101 | + add_action($cron_name, array($this, '__delete_async_events'), 9999, 0); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @since 1.8.13 |
109 | 109 | */ |
110 | 110 | public function __delete_async_events() { |
111 | - $async_events = get_option( 'give_async_events', array() ); |
|
112 | - $cron_name_parts = explode( '_', current_action() ); |
|
113 | - $cron_id = end( $cron_name_parts ); |
|
111 | + $async_events = get_option('give_async_events', array()); |
|
112 | + $cron_name_parts = explode('_', current_action()); |
|
113 | + $cron_id = end($cron_name_parts); |
|
114 | 114 | |
115 | - if ( ! empty( $async_events[ $cron_id ] ) ) { |
|
116 | - unset( $async_events[ $cron_id ] ); |
|
117 | - update_option( 'give_async_events', $async_events ); |
|
115 | + if ( ! empty($async_events[$cron_id])) { |
|
116 | + unset($async_events[$cron_id]); |
|
117 | + update_option('give_async_events', $async_events); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array An array of non-default cron schedules. |
130 | 130 | */ |
131 | - public function __add_schedules( $schedules = array() ) { |
|
131 | + public function __add_schedules($schedules = array()) { |
|
132 | 132 | // Adds once weekly to the existing schedules. |
133 | 133 | $schedules['weekly'] = array( |
134 | 134 | 'interval' => 604800, |
135 | - 'display' => __( 'Once Weekly', 'give' ), |
|
135 | + 'display' => __('Once Weekly', 'give'), |
|
136 | 136 | ); |
137 | 137 | |
138 | 138 | return $schedules; |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | private function weekly_events() { |
163 | - if ( ! wp_next_scheduled( 'give_weekly_scheduled_events' ) ) { |
|
164 | - wp_schedule_event( current_time( 'timestamp' ), 'weekly', 'give_weekly_scheduled_events' ); |
|
163 | + if ( ! wp_next_scheduled('give_weekly_scheduled_events')) { |
|
164 | + wp_schedule_event(current_time('timestamp'), 'weekly', 'give_weekly_scheduled_events'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return void |
175 | 175 | */ |
176 | 176 | private function daily_events() { |
177 | - if ( ! wp_next_scheduled( 'give_daily_scheduled_events' ) ) { |
|
178 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'give_daily_scheduled_events' ); |
|
177 | + if ( ! wp_next_scheduled('give_daily_scheduled_events')) { |
|
178 | + wp_schedule_event(current_time('timestamp'), 'daily', 'give_daily_scheduled_events'); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public static function get_cron_action( $type = 'weekly' ) { |
|
193 | - switch ( $type ) { |
|
192 | + public static function get_cron_action($type = 'weekly') { |
|
193 | + switch ($type) { |
|
194 | 194 | case 'daily': |
195 | 195 | $cron_action = 'give_daily_scheduled_events'; |
196 | 196 | break; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | * @param $action |
213 | 213 | * @param string $type |
214 | 214 | */ |
215 | - private static function add_event( $action, $type = 'weekly' ) { |
|
216 | - $cron_event = self::get_cron_action( $type ); |
|
217 | - add_action( $cron_event, $action ); |
|
215 | + private static function add_event($action, $type = 'weekly') { |
|
216 | + $cron_event = self::get_cron_action($type); |
|
217 | + add_action($cron_event, $action); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @param $action |
227 | 227 | */ |
228 | - public static function add_weekly_event( $action ) { |
|
229 | - self::add_event( $action, 'weekly' ); |
|
228 | + public static function add_weekly_event($action) { |
|
229 | + self::add_event($action, 'weekly'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @param $action |
239 | 239 | */ |
240 | - public static function add_daily_event( $action ) { |
|
241 | - self::add_event( $action, 'daily' ); |
|
240 | + public static function add_daily_event($action) { |
|
241 | + self::add_event($action, 'daily'); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | * @param string $action |
252 | 252 | * @param array $args |
253 | 253 | */ |
254 | - public static function add_async_event( $action, $args = array() ) { |
|
254 | + public static function add_async_event($action, $args = array()) { |
|
255 | 255 | |
256 | 256 | // Cache async events. |
257 | - $async_events = get_option( 'give_async_events', array() ); |
|
258 | - $async_events[ uniqid() ] = array( |
|
257 | + $async_events = get_option('give_async_events', array()); |
|
258 | + $async_events[uniqid()] = array( |
|
259 | 259 | 'callback' => $action, |
260 | 260 | 'params' => $args, |
261 | 261 | ); |
262 | 262 | |
263 | 263 | |
264 | - update_option( 'give_async_events', $async_events ); |
|
264 | + update_option('give_async_events', $async_events); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return static |
44 | 44 | */ |
45 | 45 | public static function get_instance() { |
46 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) { |
|
46 | + if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) { |
|
47 | 47 | self::$instance = new Give_Cache(); |
48 | 48 | } |
49 | 49 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setup_hooks() { |
60 | 60 | // weekly delete all expired cache. |
61 | - Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) ); |
|
61 | + Give_Cron::add_weekly_event(array($this, 'delete_all_expired')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | * @return string |
73 | 73 | */ |
74 | 74 | |
75 | - public static function get_key( $action, $query_args = null ) { |
|
75 | + public static function get_key($action, $query_args = null) { |
|
76 | 76 | $cache_key = "give_cache_{$action}"; |
77 | 77 | |
78 | 78 | // Bailout. |
79 | - if ( ! empty( $query_args ) ) { |
|
80 | - $cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
79 | + if ( ! empty($query_args)) { |
|
80 | + $cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return $cache_key; |
@@ -95,26 +95,26 @@ discard block |
||
95 | 95 | * @return mixed |
96 | 96 | */ |
97 | 97 | |
98 | - public static function get( $cache_key, $custom_key = false, $query_args = array() ) { |
|
99 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
100 | - if ( ! $custom_key ) { |
|
101 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
98 | + public static function get($cache_key, $custom_key = false, $query_args = array()) { |
|
99 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
100 | + if ( ! $custom_key) { |
|
101 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
102 | 102 | } |
103 | 103 | |
104 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
104 | + $cache_key = self::get_key($cache_key, $query_args); |
|
105 | 105 | } |
106 | 106 | |
107 | - $option = get_option( $cache_key ); |
|
107 | + $option = get_option($cache_key); |
|
108 | 108 | |
109 | 109 | // Backward compatibility (<1.8.7). |
110 | - if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) { |
|
110 | + if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) { |
|
111 | 111 | return $option; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Get current time. |
115 | - $current_time = current_time( 'timestamp', 1 ); |
|
115 | + $current_time = current_time('timestamp', 1); |
|
116 | 116 | |
117 | - if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) { |
|
117 | + if (empty($option['expiration']) || ($current_time < $option['expiration'])) { |
|
118 | 118 | $option = $option['data']; |
119 | 119 | } else { |
120 | 120 | $option = false; |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | 139 | |
140 | - public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) { |
|
141 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
142 | - if ( ! $custom_key ) { |
|
143 | - return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) ); |
|
140 | + public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) { |
|
141 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
142 | + if ( ! $custom_key) { |
|
143 | + return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give')); |
|
144 | 144 | } |
145 | 145 | |
146 | - $cache_key = self::get_key( $cache_key, $query_args ); |
|
146 | + $cache_key = self::get_key($cache_key, $query_args); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $option_value = array( |
150 | 150 | 'data' => $data, |
151 | - 'expiration' => ! is_null( $expiration ) |
|
152 | - ? ( $expiration + current_time( 'timestamp', 1 ) ) |
|
151 | + 'expiration' => ! is_null($expiration) |
|
152 | + ? ($expiration + current_time('timestamp', 1)) |
|
153 | 153 | : null, |
154 | 154 | ); |
155 | 155 | |
156 | - $result = update_option( $cache_key, $option_value, 'no' ); |
|
156 | + $result = update_option($cache_key, $option_value, 'no'); |
|
157 | 157 | |
158 | 158 | return $result; |
159 | 159 | } |
@@ -168,27 +168,27 @@ discard block |
||
168 | 168 | * @return bool|WP_Error |
169 | 169 | */ |
170 | 170 | |
171 | - public static function delete( $cache_keys ) { |
|
171 | + public static function delete($cache_keys) { |
|
172 | 172 | $result = true; |
173 | 173 | $invalid_keys = array(); |
174 | 174 | |
175 | - if ( ! empty( $cache_keys ) ) { |
|
176 | - $cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys ); |
|
175 | + if ( ! empty($cache_keys)) { |
|
176 | + $cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys); |
|
177 | 177 | |
178 | - foreach ( $cache_keys as $cache_key ) { |
|
179 | - if ( ! self::is_valid_cache_key( $cache_key ) ) { |
|
178 | + foreach ($cache_keys as $cache_key) { |
|
179 | + if ( ! self::is_valid_cache_key($cache_key)) { |
|
180 | 180 | $invalid_keys[] = $cache_key; |
181 | 181 | $result = false; |
182 | 182 | } |
183 | 183 | |
184 | - delete_option( $cache_key ); |
|
184 | + delete_option($cache_key); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if( ! $result ) { |
|
188 | + if ( ! $result) { |
|
189 | 189 | $result = new WP_Error( |
190 | 190 | 'give_invalid_cache_key', |
191 | - __( 'Cache key format should be give_cache_*', 'give' ), |
|
191 | + __('Cache key format should be give_cache_*', 'give'), |
|
192 | 192 | $invalid_keys |
193 | 193 | ); |
194 | 194 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public static function delete_all_expired( $force = false ) { |
|
210 | + public static function delete_all_expired($force = false) { |
|
211 | 211 | global $wpdb; |
212 | 212 | $options = $wpdb->get_results( |
213 | 213 | $wpdb->prepare( |
@@ -221,30 +221,30 @@ discard block |
||
221 | 221 | ); |
222 | 222 | |
223 | 223 | // Bailout. |
224 | - if ( empty( $options ) ) { |
|
224 | + if (empty($options)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - $current_time = current_time( 'timestamp', 1 ); |
|
228 | + $current_time = current_time('timestamp', 1); |
|
229 | 229 | |
230 | 230 | // Delete log cache. |
231 | - foreach ( $options as $option ) { |
|
232 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
231 | + foreach ($options as $option) { |
|
232 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
233 | 233 | |
234 | 234 | if ( |
235 | 235 | ( |
236 | - ! self::is_valid_cache_key( $option['option_name'] ) |
|
237 | - || ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
238 | - || ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7). |
|
239 | - || empty( $option['option_value']['expiration'] ) |
|
240 | - || ( $current_time < $option['option_value']['expiration'] ) |
|
236 | + ! self::is_valid_cache_key($option['option_name']) |
|
237 | + || ! is_array($option['option_value']) // Backward compatibility (<1.8.7). |
|
238 | + || ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7). |
|
239 | + || empty($option['option_value']['expiration']) |
|
240 | + || ($current_time < $option['option_value']['expiration']) |
|
241 | 241 | ) |
242 | 242 | && ! $force |
243 | 243 | ) { |
244 | 244 | continue; |
245 | 245 | } |
246 | 246 | |
247 | - self::delete( $option['option_name'] ); |
|
247 | + self::delete($option['option_name']); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return array |
262 | 262 | */ |
263 | - public static function get_options_like( $option_name, $fields = false ) { |
|
263 | + public static function get_options_like($option_name, $fields = false) { |
|
264 | 264 | global $wpdb; |
265 | 265 | |
266 | - if ( empty( $option_name ) ) { |
|
266 | + if (empty($option_name)) { |
|
267 | 267 | return array(); |
268 | 268 | } |
269 | 269 | |
270 | 270 | $field_names = $fields ? 'option_name, option_value' : 'option_name'; |
271 | 271 | |
272 | - if ( $fields ) { |
|
272 | + if ($fields) { |
|
273 | 273 | $options = $wpdb->get_results( |
274 | 274 | $wpdb->prepare( |
275 | 275 | "SELECT {$field_names } |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | - if ( ! empty( $options ) && $fields ) { |
|
297 | - foreach ( $options as $index => $option ) { |
|
298 | - $option['option_value'] = maybe_unserialize( $option['option_value'] ); |
|
299 | - $options[ $index ] = $option; |
|
296 | + if ( ! empty($options) && $fields) { |
|
297 | + foreach ($options as $index => $option) { |
|
298 | + $option['option_value'] = maybe_unserialize($option['option_value']); |
|
299 | + $options[$index] = $option; |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @return bool|int |
315 | 315 | */ |
316 | - public static function is_valid_cache_key( $cache_key ) { |
|
317 | - return ( false !== strpos( $cache_key, 'give_cache_' ) ); |
|
316 | + public static function is_valid_cache_key($cache_key) { |
|
317 | + return (false !== strpos($cache_key, 'give_cache_')); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | give_setup_post_types(); |
62 | 62 | |
63 | 63 | // Add Upgraded From Option. |
64 | - $current_version = get_option( 'give_version' ); |
|
65 | - if ( $current_version ) { |
|
66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
64 | + $current_version = get_option('give_version'); |
|
65 | + if ($current_version) { |
|
66 | + update_option('give_version_upgraded_from', $current_version); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup some default options. |
70 | 70 | $options = array(); |
71 | 71 | |
72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
73 | - if ( empty( $current_version ) ) { |
|
74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
73 | + if (empty($current_version)) { |
|
74 | + $options = array_merge($options, give_get_default_settings()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Populate the default values. |
78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Run plugin upgrades. |
82 | 82 | * |
83 | 83 | * @since 1.8 |
84 | 84 | */ |
85 | - do_action( 'give_upgrades' ); |
|
85 | + do_action('give_upgrades'); |
|
86 | 86 | |
87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
88 | - update_option( 'give_version', GIVE_VERSION ); |
|
87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
88 | + update_option('give_version', GIVE_VERSION); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set api version, end point and refresh permalink. |
97 | 97 | $api = new Give_API(); |
98 | 98 | $api->add_endpoint(); |
99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
100 | 100 | |
101 | 101 | flush_rewrite_rules(); |
102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | 'v1813_update_donor_user_roles' |
126 | 126 | ); |
127 | 127 | |
128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
129 | - give_set_upgrade_complete( $upgrade ); |
|
128 | + foreach ($upgrade_routines as $upgrade) { |
|
129 | + give_set_upgrade_complete($upgrade); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Bail if activating from network, or bulk. |
134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Add the transient to redirect. |
139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
140 | 140 | |
141 | 141 | // Set 'Donation Form' meta box enabled by default. |
142 | 142 | give_nav_donation_metabox_enabled(); |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param int $site_id The Site ID. |
157 | 157 | * @param array $meta Blog Meta. |
158 | 158 | */ |
159 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
159 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
160 | 160 | |
161 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
161 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
162 | 162 | |
163 | - switch_to_blog( $blog_id ); |
|
163 | + switch_to_blog($blog_id); |
|
164 | 164 | give_install(); |
165 | 165 | restore_current_blog(); |
166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | } |
170 | 170 | |
171 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
171 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
172 | 172 | |
173 | 173 | |
174 | 174 | /** |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array The tables to drop. |
183 | 183 | */ |
184 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
184 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
185 | 185 | |
186 | - switch_to_blog( $blog_id ); |
|
186 | + switch_to_blog($blog_id); |
|
187 | 187 | $donors_db = new Give_DB_Donors(); |
188 | 188 | $donor_meta_db = new Give_DB_Donor_Meta(); |
189 | 189 | |
190 | - if ( $donors_db->installed() ) { |
|
190 | + if ($donors_db->installed()) { |
|
191 | 191 | $tables[] = $donors_db->table_name; |
192 | 192 | $tables[] = $donor_meta_db->table_name; |
193 | 193 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
200 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Post-installation |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function give_after_install() { |
211 | 211 | |
212 | - if ( ! is_admin() ) { |
|
212 | + if ( ! is_admin()) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
217 | - $give_table_check = get_option( '_give_table_check', false ); |
|
216 | + $give_options = Give_Cache::get('_give_installed', true); |
|
217 | + $give_table_check = get_option('_give_table_check', false); |
|
218 | 218 | |
219 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
219 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
220 | 220 | |
221 | - if ( ! @Give()->donor_meta->installed() ) { |
|
221 | + if ( ! @Give()->donor_meta->installed()) { |
|
222 | 222 | |
223 | 223 | // Create the donor meta database. |
224 | 224 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | - if ( ! @Give()->donors->installed() ) { |
|
229 | + if ( ! @Give()->donors->installed()) { |
|
230 | 230 | // Create the donor database. |
231 | 231 | // (this ensures it creates it on multisite instances where it is network activated). |
232 | 232 | @Give()->donors->create_table(); |
@@ -238,22 +238,22 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param array $give_options Give plugin options. |
240 | 240 | */ |
241 | - do_action( 'give_after_install', $give_options ); |
|
241 | + do_action('give_after_install', $give_options); |
|
242 | 242 | } |
243 | 243 | |
244 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
244 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Delete the transient |
249 | - if ( false !== $give_options ) { |
|
250 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
249 | + if (false !== $give_options) { |
|
250 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | -add_action( 'admin_init', 'give_after_install' ); |
|
256 | +add_action('admin_init', 'give_after_install'); |
|
257 | 257 | |
258 | 258 | |
259 | 259 | /** |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | |
269 | 269 | global $wp_roles; |
270 | 270 | |
271 | - if ( ! is_object( $wp_roles ) ) { |
|
271 | + if ( ! is_object($wp_roles)) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
275 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
275 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
276 | 276 | |
277 | 277 | // Create Give plugin roles |
278 | 278 | $roles = new Give_Roles(); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | } |
285 | 285 | |
286 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
286 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Default core setting values. |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | 'uninstall_on_delete' => 'disabled', |
322 | 322 | 'the_content_filter' => 'enabled', |
323 | 323 | 'scripts_footer' => 'disabled', |
324 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
324 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
325 | 325 | 'agreement_text' => give_get_default_agreement_text(), |
326 | 326 | |
327 | 327 | // Paypal IPN verification. |
328 | 328 | 'paypal_verification' => 'enabled', |
329 | 329 | |
330 | 330 | // Default is manual gateway. |
331 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
331 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
332 | 332 | 'default_gateway' => 'manual', |
333 | 333 | |
334 | 334 | // Offline gateway setup. |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function give_get_default_agreement_text() { |
358 | 358 | |
359 | - $org_name = get_bloginfo( 'name' ); |
|
359 | + $org_name = get_bloginfo('name'); |
|
360 | 360 | |
361 | 361 | $agreement = sprintf( |
362 | 362 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $org_name |
371 | 371 | ); |
372 | 372 | |
373 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
373 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -379,22 +379,22 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @since 1.8.11 |
381 | 381 | */ |
382 | -function give_create_pages(){ |
|
382 | +function give_create_pages() { |
|
383 | 383 | |
384 | 384 | // Bailout if pages already created. |
385 | - if( get_option( 'give_install_pages_created') ) { |
|
385 | + if (get_option('give_install_pages_created')) { |
|
386 | 386 | return false; |
387 | 387 | } |
388 | 388 | |
389 | 389 | $options = array(); |
390 | 390 | |
391 | 391 | // Checks if the Success Page option exists AND that the page exists. |
392 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
392 | + if ( ! get_post(give_get_option('success_page'))) { |
|
393 | 393 | |
394 | 394 | // Donation Confirmation (Success) Page |
395 | 395 | $success = wp_insert_post( |
396 | 396 | array( |
397 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
397 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
398 | 398 | 'post_content' => '[give_receipt]', |
399 | 399 | 'post_status' => 'publish', |
400 | 400 | 'post_author' => 1, |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | } |
409 | 409 | |
410 | 410 | // Checks if the Failure Page option exists AND that the page exists. |
411 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
411 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
412 | 412 | |
413 | 413 | // Failed Donation Page |
414 | 414 | $failed = wp_insert_post( |
415 | 415 | array( |
416 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
417 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
416 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
417 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
418 | 418 | 'post_status' => 'publish', |
419 | 419 | 'post_author' => 1, |
420 | 420 | 'post_type' => 'page', |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | // Checks if the History Page option exists AND that the page exists. |
429 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
429 | + if ( ! get_post(give_get_option('history_page'))) { |
|
430 | 430 | // Donation History Page |
431 | 431 | $history = wp_insert_post( |
432 | 432 | array( |
433 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
433 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
434 | 434 | 'post_content' => '[donation_history]', |
435 | 435 | 'post_status' => 'publish', |
436 | 436 | 'post_author' => 1, |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | $options['history_page'] = $history; |
443 | 443 | } |
444 | 444 | |
445 | - if( ! empty( $options ) ) { |
|
446 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
445 | + if ( ! empty($options)) { |
|
446 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
447 | 447 | } |
448 | 448 | |
449 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
449 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
450 | 450 | } |
451 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
451 | +add_action('admin_init', 'give_create_pages', -1); |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | 110 | // Setup the payment details. |
111 | 111 | $payment_data = array( |
112 | 112 | 'price' => $purchase_data['price'], |
113 | 113 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
114 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
115 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
114 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
115 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | 116 | 'date' => $purchase_data['date'], |
117 | 117 | 'user_email' => $purchase_data['user_email'], |
118 | 118 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | |
125 | 125 | |
126 | 126 | // record the pending payment |
127 | - $payment = give_insert_payment( $payment_data ); |
|
127 | + $payment = give_insert_payment($payment_data); |
|
128 | 128 | |
129 | - if ( $payment ) { |
|
130 | - give_offline_send_admin_notice( $payment ); |
|
131 | - give_offline_send_donor_instructions( $payment ); |
|
129 | + if ($payment) { |
|
130 | + give_offline_send_admin_notice($payment); |
|
131 | + give_offline_send_donor_instructions($payment); |
|
132 | 132 | give_send_to_success_page(); |
133 | 133 | } else { |
134 | 134 | // if errors are present, send the user back to the donation form so they can be corrected |
135 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
135 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
139 | 139 | |
140 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
140 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | /** |
@@ -150,59 +150,59 @@ discard block |
||
150 | 150 | * @since 1.0 |
151 | 151 | * @return void |
152 | 152 | */ |
153 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
153 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
154 | 154 | |
155 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
156 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
155 | + $payment_data = give_get_payment_meta($payment_id); |
|
156 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
157 | 157 | |
158 | 158 | //Customize email content depending on whether the single form has been customized |
159 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
159 | + $email_content = give_get_option('global_offline_donation_email'); |
|
160 | 160 | |
161 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
162 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
161 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
162 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
163 | 163 | } |
164 | 164 | |
165 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
165 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Filters the from name. |
169 | 169 | * |
170 | 170 | * @since 1.7 |
171 | 171 | */ |
172 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
172 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
173 | 173 | |
174 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
174 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Filters the from email. |
178 | 178 | * |
179 | 179 | * @since 1.7 |
180 | 180 | */ |
181 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
181 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
182 | 182 | |
183 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
183 | + $to_email = give_get_payment_user_email($payment_id); |
|
184 | 184 | |
185 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
186 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
187 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
185 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
186 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
187 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
188 | 188 | } |
189 | 189 | |
190 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
191 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
190 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
191 | + $subject = give_do_email_tags($subject, $payment_id); |
|
192 | 192 | |
193 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
194 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
193 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
194 | + $message = give_do_email_tags($email_content, $payment_id); |
|
195 | 195 | |
196 | 196 | $emails = Give()->emails; |
197 | 197 | |
198 | - $emails->__set( 'from_name', $from_name ); |
|
199 | - $emails->__set( 'from_email', $from_email ); |
|
200 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
198 | + $emails->__set('from_name', $from_name); |
|
199 | + $emails->__set('from_email', $from_email); |
|
200 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
201 | 201 | |
202 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
203 | - $emails->__set( 'headers', $headers ); |
|
202 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
203 | + $emails->__set('headers', $headers); |
|
204 | 204 | |
205 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
205 | + $emails->send($to_email, $subject, $message, $attachments); |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -219,54 +219,54 @@ discard block |
||
219 | 219 | * @return void |
220 | 220 | * |
221 | 221 | */ |
222 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
222 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
223 | 223 | |
224 | 224 | /* Send an email notification to the admin */ |
225 | 225 | $admin_email = give_get_admin_notice_emails(); |
226 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
226 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
227 | 227 | |
228 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
229 | - $user_data = get_userdata( $user_info['id'] ); |
|
228 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
229 | + $user_data = get_userdata($user_info['id']); |
|
230 | 230 | $name = $user_data->display_name; |
231 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
232 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
231 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
232 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
233 | 233 | } else { |
234 | 234 | $name = $user_info['email']; |
235 | 235 | } |
236 | 236 | |
237 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ), array( 'sanitize' => false ) ) ); |
|
237 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id), array('sanitize' => false))); |
|
238 | 238 | |
239 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
239 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
240 | 240 | |
241 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
242 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
243 | - $admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
241 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
242 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
243 | + $admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
244 | 244 | |
245 | 245 | |
246 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
247 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
246 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
247 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
248 | 248 | |
249 | 249 | $admin_message .= sprintf( |
250 | 250 | '<a href="%1$s">%2$s</a>', |
251 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
252 | - __( 'View Donation Details »', 'give' ) |
|
253 | - ) . "\n\n"; |
|
251 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
252 | + __('View Donation Details »', 'give') |
|
253 | + )."\n\n"; |
|
254 | 254 | |
255 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
256 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
255 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
256 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
257 | 257 | |
258 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
259 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
258 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
259 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
260 | 260 | |
261 | 261 | //Send Email |
262 | 262 | $emails = Give()->emails; |
263 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
263 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
264 | 264 | |
265 | - if ( ! empty( $admin_headers ) ) { |
|
266 | - $emails->__set( 'headers', $admin_headers ); |
|
265 | + if ( ! empty($admin_headers)) { |
|
266 | + $emails->__set('headers', $admin_headers); |
|
267 | 267 | } |
268 | 268 | |
269 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
269 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -278,20 +278,20 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return array |
280 | 280 | */ |
281 | -function give_offline_add_settings( $settings ) { |
|
281 | +function give_offline_add_settings($settings) { |
|
282 | 282 | |
283 | 283 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
284 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
284 | + if (in_array('offline', give_get_option('gateways'))) { |
|
285 | 285 | return $settings; |
286 | 286 | } |
287 | 287 | |
288 | 288 | //Vars |
289 | 289 | $prefix = '_give_'; |
290 | 290 | |
291 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
291 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
292 | 292 | |
293 | 293 | //this gateway isn't active |
294 | - if ( ! $is_gateway_active ) { |
|
294 | + if ( ! $is_gateway_active) { |
|
295 | 295 | //return settings and bounce |
296 | 296 | return $settings; |
297 | 297 | } |
@@ -300,34 +300,34 @@ discard block |
||
300 | 300 | $check_settings = array( |
301 | 301 | |
302 | 302 | array( |
303 | - 'name' => __( 'Offline Donations', 'give' ), |
|
304 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
305 | - 'id' => $prefix . 'customize_offline_donations', |
|
303 | + 'name' => __('Offline Donations', 'give'), |
|
304 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
305 | + 'id' => $prefix.'customize_offline_donations', |
|
306 | 306 | 'type' => 'radio_inline', |
307 | 307 | 'default' => 'global', |
308 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
309 | - 'global' => __( 'Global Option', 'give' ), |
|
310 | - 'enabled' => __( 'Customize', 'give' ), |
|
311 | - 'disabled' => __( 'Disable', 'give' ), |
|
308 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
309 | + 'global' => __('Global Option', 'give'), |
|
310 | + 'enabled' => __('Customize', 'give'), |
|
311 | + 'disabled' => __('Disable', 'give'), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | array( |
316 | - 'name' => __( 'Billing Fields', 'give' ), |
|
317 | - 'desc' => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
318 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
316 | + 'name' => __('Billing Fields', 'give'), |
|
317 | + 'desc' => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
318 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
319 | 319 | 'row_classes' => 'give-subfield give-hidden', |
320 | 320 | 'type' => 'radio_inline', |
321 | 321 | 'default' => 'disabled', |
322 | 322 | 'options' => array( |
323 | - 'enabled' => __( 'Enabled', 'give' ), |
|
324 | - 'disabled' => __( 'Disabled', 'give' ), |
|
323 | + 'enabled' => __('Enabled', 'give'), |
|
324 | + 'disabled' => __('Disabled', 'give'), |
|
325 | 325 | ), |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'id' => $prefix . 'offline_checkout_notes', |
|
329 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
330 | - 'desc' => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
328 | + 'id' => $prefix.'offline_checkout_notes', |
|
329 | + 'name' => __('Donation Instructions', 'give'), |
|
330 | + 'desc' => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
331 | 331 | 'default' => give_get_default_offline_donation_content(), |
332 | 332 | 'type' => 'wysiwyg', |
333 | 333 | 'row_classes' => 'give-subfield give-hidden', |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | ), |
337 | 337 | ), |
338 | 338 | array( |
339 | - 'id' => $prefix . 'offline_donation_subject', |
|
340 | - 'name' => __( 'Email Subject', 'give' ), |
|
341 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
342 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
339 | + 'id' => $prefix.'offline_donation_subject', |
|
340 | + 'name' => __('Email Subject', 'give'), |
|
341 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
342 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
343 | 343 | 'row_classes' => 'give-subfield give-hidden', |
344 | 344 | 'type' => 'text', |
345 | 345 | ), |
346 | 346 | array( |
347 | - 'id' => $prefix . 'offline_donation_email', |
|
348 | - 'name' => __( 'Email Instructions', 'give' ), |
|
349 | - 'desc' => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
347 | + 'id' => $prefix.'offline_donation_email', |
|
348 | + 'name' => __('Email Instructions', 'give'), |
|
349 | + 'desc' => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
350 | 350 | 'default' => give_get_default_offline_donation_email_content(), |
351 | 351 | 'type' => 'wysiwyg', |
352 | 352 | 'row_classes' => 'give-subfield give-hidden', |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | 'name' => 'offline_docs', |
359 | 359 | 'type' => 'docs_link', |
360 | 360 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
361 | - 'title' => __( 'Offline Donations', 'give' ), |
|
361 | + 'title' => __('Offline Donations', 'give'), |
|
362 | 362 | ), |
363 | 363 | ); |
364 | 364 | |
365 | - return array_merge( $settings, $check_settings ); |
|
365 | + return array_merge($settings, $check_settings); |
|
366 | 366 | } |
367 | 367 | |
368 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
368 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
369 | 369 | |
370 | 370 | |
371 | 371 | /** |
@@ -377,32 +377,32 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | 381 | |
382 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
382 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - __( 'Make a check payable to "%s"', 'give' ), |
|
387 | + __('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
402 | 402 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
403 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
403 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
404 | 404 | |
405 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
405 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -415,34 +415,34 @@ discard block |
||
415 | 415 | */ |
416 | 416 | function give_get_default_offline_donation_email_content() { |
417 | 417 | |
418 | - $sitename = get_bloginfo( 'sitename' ); |
|
419 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
420 | - $default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
418 | + $sitename = get_bloginfo('sitename'); |
|
419 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
420 | + $default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
421 | 421 | $default_text .= '<ol>'; |
422 | 422 | $default_text .= '<li>'; |
423 | 423 | $default_text .= sprintf( |
424 | 424 | /* translators: %s: site name */ |
425 | - __( 'Make a check payable to "%s"', 'give' ), |
|
425 | + __('Make a check payable to "%s"', 'give'), |
|
426 | 426 | $sitename |
427 | 427 | ); |
428 | 428 | $default_text .= '</li>'; |
429 | 429 | $default_text .= '<li>'; |
430 | 430 | $default_text .= sprintf( |
431 | 431 | /* translators: %s: site name */ |
432 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
432 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
433 | 433 | $sitename |
434 | 434 | ); |
435 | 435 | $default_text .= '</li>'; |
436 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
436 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
437 | 437 | $default_text .= '</ol>'; |
438 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
438 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
439 | 439 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
440 | 440 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
441 | - $default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
442 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
443 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
441 | + $default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
442 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
443 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
444 | 444 | |
445 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
445 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -456,17 +456,17 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string |
458 | 458 | */ |
459 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
460 | - $payment = new Give_Payment( $id ); |
|
459 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
460 | + $payment = new Give_Payment($id); |
|
461 | 461 | |
462 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
462 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
463 | 463 | return $notice; |
464 | 464 | } |
465 | 465 | |
466 | - return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
466 | + return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
467 | 467 | } |
468 | 468 | |
469 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
469 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Add offline payment instruction on payment receipt. |
@@ -477,26 +477,26 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @return mixed |
479 | 479 | */ |
480 | -function give_offline_payment_receipt_after( $payment ) { |
|
480 | +function give_offline_payment_receipt_after($payment) { |
|
481 | 481 | // Get payment object. |
482 | - $payment = new Give_Payment( $payment->ID ); |
|
482 | + $payment = new Give_Payment($payment->ID); |
|
483 | 483 | |
484 | 484 | // Bailout. |
485 | - if ( 'offline' !== $payment->gateway ) { |
|
485 | + if ('offline' !== $payment->gateway) { |
|
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | |
489 | 489 | ?> |
490 | 490 | <tr> |
491 | - <td scope="row"><strong><?php esc_html_e( 'Offline Donations Instructions', 'give' ); ?></strong></td> |
|
491 | + <td scope="row"><strong><?php esc_html_e('Offline Donations Instructions', 'give'); ?></strong></td> |
|
492 | 492 | <td> |
493 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
493 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
494 | 494 | </td> |
495 | 495 | </tr> |
496 | 496 | <?php |
497 | 497 | } |
498 | 498 | |
499 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
499 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Get offline payment instructions. |
@@ -508,27 +508,27 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string |
510 | 510 | */ |
511 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
511 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
512 | 512 | // Bailout. |
513 | - if ( ! $form_id ) { |
|
513 | + if ( ! $form_id) { |
|
514 | 514 | return ''; |
515 | 515 | } |
516 | 516 | |
517 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
518 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
519 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
517 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
518 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
519 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
520 | 520 | $offline_instructions = $global_offline_instruction; |
521 | 521 | |
522 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
522 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
523 | 523 | $offline_instructions = $post_offline_instructions; |
524 | 524 | } |
525 | 525 | |
526 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
526 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
527 | 527 | |
528 | 528 | /* translators: %s: form settings url */ |
529 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
529 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
530 | 530 | |
531 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
531 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -542,24 +542,24 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array |
544 | 544 | */ |
545 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
545 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
546 | 546 | if ( |
547 | 547 | // Show offline payment gateway if enable for new donation form. |
548 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
548 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
549 | 549 | && $form_id |
550 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( |
|
550 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array( |
|
551 | 551 | 'enabled', |
552 | 552 | 'global', |
553 | - ) ) |
|
553 | + )) |
|
554 | 554 | ) { |
555 | - unset( $gateway_list['offline'] ); |
|
555 | + unset($gateway_list['offline']); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | // Output. |
559 | 559 | return $gateway_list; |
560 | 560 | } |
561 | 561 | |
562 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
562 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
563 | 563 | |
564 | 564 | /** |
565 | 565 | * Set default gateway to global default payment gateway |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | * |
574 | 574 | * @return void |
575 | 575 | */ |
576 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
577 | - if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
578 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
576 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
577 | + if ( ! give_is_setting_enabled($meta_value) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) { |
|
578 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
582 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings); |
|
66 | 66 | } |
67 | 67 | } |
68 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
68 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'v1' => 'GIVE_API_V1', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach ( $this->get_versions() as $version => $class ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
144 | + foreach ($this->get_versions() as $version => $class) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
146 | 146 | } |
147 | 147 | |
148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
153 | - add_action( 'personal_options_update', array( $this, 'generate_api_key' ) ); |
|
154 | - add_action( 'edit_user_profile_update', array( $this, 'generate_api_key' ) ); |
|
155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
148 | + add_action('init', array($this, 'add_endpoint')); |
|
149 | + add_action('wp', array($this, 'process_query'), - 1); |
|
150 | + add_filter('query_vars', array($this, 'query_vars')); |
|
151 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
153 | + add_action('personal_options_update', array($this, 'generate_api_key')); |
|
154 | + add_action('edit_user_profile_update', array($this, 'generate_api_key')); |
|
155 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
156 | 156 | |
157 | 157 | // Setup a backwards compatibility check for user API Keys |
158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
158 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
159 | 159 | |
160 | 160 | // Determine if JSON_PRETTY_PRINT is available |
161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
161 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
162 | 162 | |
163 | 163 | // Allow API request logging to be turned off |
164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
164 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
165 | 165 | |
166 | 166 | // Setup Give_Payment_Stats instance |
167 | 167 | $this->stats = new Give_Payment_Stats(); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @since 1.1 |
177 | 177 | */ |
178 | 178 | public function add_endpoint() { |
179 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
179 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return string[] $vars New query vars |
191 | 191 | */ |
192 | - public function query_vars( $vars ) { |
|
192 | + public function query_vars($vars) { |
|
193 | 193 | |
194 | 194 | $vars[] = 'token'; |
195 | 195 | $vars[] = 'key'; |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function get_default_version() { |
242 | 242 | |
243 | - $version = get_option( 'give_default_api_version' ); |
|
243 | + $version = get_option('give_default_api_version'); |
|
244 | 244 | |
245 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
245 | + if (defined('GIVE_API_VERSION')) { |
|
246 | 246 | $version = GIVE_API_VERSION; |
247 | - } elseif ( ! $version ) { |
|
247 | + } elseif ( ! $version) { |
|
248 | 248 | $version = 'v1'; |
249 | 249 | } |
250 | 250 | |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | |
266 | 266 | $version = $wp_query->query_vars['give-api']; |
267 | 267 | |
268 | - if ( strpos( $version, '/' ) ) { |
|
268 | + if (strpos($version, '/')) { |
|
269 | 269 | |
270 | - $version = explode( '/', $version ); |
|
271 | - $version = strtolower( $version[0] ); |
|
270 | + $version = explode('/', $version); |
|
271 | + $version = strtolower($version[0]); |
|
272 | 272 | |
273 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
273 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
274 | 274 | |
275 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
275 | + if (array_key_exists($version, $this->versions)) { |
|
276 | 276 | |
277 | 277 | $this->queried_version = $version; |
278 | 278 | |
@@ -308,16 +308,16 @@ discard block |
||
308 | 308 | $this->override = false; |
309 | 309 | |
310 | 310 | // Make sure we have both user and api key |
311 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
311 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
312 | 312 | |
313 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
313 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
314 | 314 | $this->missing_auth(); |
315 | 315 | |
316 | 316 | return false; |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Retrieve the user by public API key and ensure they exist |
320 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
320 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
321 | 321 | |
322 | 322 | $this->invalid_key(); |
323 | 323 | |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | |
326 | 326 | } else { |
327 | 327 | |
328 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
329 | - $secret = $this->get_user_secret_key( $user ); |
|
330 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
328 | + $token = urldecode($wp_query->query_vars['token']); |
|
329 | + $secret = $this->get_user_secret_key($user); |
|
330 | + $public = urldecode($wp_query->query_vars['key']); |
|
331 | 331 | |
332 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
332 | + if (hash_equals(md5($secret.$public), $token)) { |
|
333 | 333 | $this->is_valid_request = true; |
334 | 334 | } else { |
335 | 335 | $this->invalid_auth(); |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | } |
341 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { |
|
341 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { |
|
342 | 342 | $this->is_valid_request = true; |
343 | - $wp_query->set( 'key', 'public' ); |
|
343 | + $wp_query->set('key', 'public'); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -356,25 +356,25 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @return bool if user ID is found, false otherwise |
358 | 358 | */ |
359 | - public function get_user( $key = '' ) { |
|
359 | + public function get_user($key = '') { |
|
360 | 360 | global $wpdb, $wp_query; |
361 | 361 | |
362 | - if ( empty( $key ) ) { |
|
363 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
362 | + if (empty($key)) { |
|
363 | + $key = urldecode($wp_query->query_vars['key']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $key ) ) { |
|
366 | + if (empty($key)) { |
|
367 | 367 | return false; |
368 | 368 | } |
369 | 369 | |
370 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
370 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
371 | 371 | |
372 | - if ( false === $user ) { |
|
373 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
374 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
372 | + if (false === $user) { |
|
373 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
374 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
375 | 375 | } |
376 | 376 | |
377 | - if ( $user != null ) { |
|
377 | + if ($user != null) { |
|
378 | 378 | $this->user_id = $user; |
379 | 379 | |
380 | 380 | return $user; |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return mixed|null|string |
392 | 392 | */ |
393 | - public function get_user_public_key( $user_id = 0 ) { |
|
393 | + public function get_user_public_key($user_id = 0) { |
|
394 | 394 | global $wpdb; |
395 | 395 | |
396 | - if ( empty( $user_id ) ) { |
|
396 | + if (empty($user_id)) { |
|
397 | 397 | return ''; |
398 | 398 | } |
399 | 399 | |
400 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
401 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
400 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
401 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
402 | 402 | |
403 | - if ( empty( $user_public_key ) ) { |
|
404 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
405 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
403 | + if (empty($user_public_key)) { |
|
404 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
405 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | return $user_public_key; |
@@ -415,19 +415,19 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @return mixed|null|string |
417 | 417 | */ |
418 | - public function get_user_secret_key( $user_id = 0 ) { |
|
418 | + public function get_user_secret_key($user_id = 0) { |
|
419 | 419 | global $wpdb; |
420 | 420 | |
421 | - if ( empty( $user_id ) ) { |
|
421 | + if (empty($user_id)) { |
|
422 | 422 | return ''; |
423 | 423 | } |
424 | 424 | |
425 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
426 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
425 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
426 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
427 | 427 | |
428 | - if ( empty( $user_secret_key ) ) { |
|
429 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
430 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
428 | + if (empty($user_secret_key)) { |
|
429 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
430 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | return $user_secret_key; |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | */ |
444 | 444 | private function missing_auth() { |
445 | 445 | $error = array(); |
446 | - $error['error'] = __( 'You must specify both a token and API key.', 'give' ); |
|
446 | + $error['error'] = __('You must specify both a token and API key.', 'give'); |
|
447 | 447 | |
448 | 448 | $this->data = $error; |
449 | - $this->output( 401 ); |
|
449 | + $this->output(401); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | */ |
461 | 461 | private function invalid_auth() { |
462 | 462 | $error = array(); |
463 | - $error['error'] = __( 'Your request could not be authenticated.', 'give' ); |
|
463 | + $error['error'] = __('Your request could not be authenticated.', 'give'); |
|
464 | 464 | |
465 | 465 | $this->data = $error; |
466 | - $this->output( 403 ); |
|
466 | + $this->output(403); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | */ |
478 | 478 | private function invalid_key() { |
479 | 479 | $error = array(); |
480 | - $error['error'] = __( 'Invalid API key.', 'give' ); |
|
480 | + $error['error'] = __('Invalid API key.', 'give'); |
|
481 | 481 | |
482 | 482 | $this->data = $error; |
483 | - $this->output( 403 ); |
|
483 | + $this->output(403); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | */ |
494 | 494 | private function invalid_version() { |
495 | 495 | $error = array(); |
496 | - $error['error'] = __( 'Invalid API version.', 'give' ); |
|
496 | + $error['error'] = __('Invalid API version.', 'give'); |
|
497 | 497 | |
498 | 498 | $this->data = $error; |
499 | - $this->output( 404 ); |
|
499 | + $this->output(404); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | global $wp_query; |
513 | 513 | |
514 | 514 | // Start logging how long the request takes for logging |
515 | - $before = microtime( true ); |
|
515 | + $before = microtime(true); |
|
516 | 516 | |
517 | 517 | // Check for give-api var. Get out if not present |
518 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
518 | + if (empty($wp_query->query_vars['give-api'])) { |
|
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
@@ -529,45 +529,45 @@ discard block |
||
529 | 529 | $this->validate_request(); |
530 | 530 | |
531 | 531 | // Only proceed if no errors have been noted |
532 | - if ( ! $this->is_valid_request ) { |
|
532 | + if ( ! $this->is_valid_request) { |
|
533 | 533 | return; |
534 | 534 | } |
535 | 535 | |
536 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
537 | - define( 'GIVE_DOING_API', true ); |
|
536 | + if ( ! defined('GIVE_DOING_API')) { |
|
537 | + define('GIVE_DOING_API', true); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $data = array(); |
541 | 541 | $this->routes = new $this->versions[$this->get_queried_version()]; |
542 | 542 | $this->routes->validate_request(); |
543 | 543 | |
544 | - switch ( $this->endpoint ) : |
|
544 | + switch ($this->endpoint) : |
|
545 | 545 | |
546 | 546 | case 'stats' : |
547 | 547 | |
548 | - $data = $this->routes->get_stats( array( |
|
549 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
550 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
551 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
552 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
553 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
554 | - ) ); |
|
548 | + $data = $this->routes->get_stats(array( |
|
549 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
550 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
551 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
552 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
553 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
554 | + )); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'forms' : |
559 | 559 | |
560 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
560 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
561 | 561 | |
562 | - $data = $this->routes->get_forms( $form ); |
|
562 | + $data = $this->routes->get_forms($form); |
|
563 | 563 | |
564 | 564 | break; |
565 | 565 | |
566 | 566 | case 'donors' : |
567 | 567 | |
568 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
568 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
569 | 569 | |
570 | - $data = $this->routes->get_donors( $donor ); |
|
570 | + $data = $this->routes->get_donors($donor); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
@@ -580,26 +580,26 @@ discard block |
||
580 | 580 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
581 | 581 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
582 | 582 | */ |
583 | - $data = $this->routes->get_recent_donations( array( |
|
584 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
585 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
586 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
587 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
588 | - ) ); |
|
583 | + $data = $this->routes->get_recent_donations(array( |
|
584 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
585 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
586 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
587 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
588 | + )); |
|
589 | 589 | |
590 | 590 | break; |
591 | 591 | |
592 | 592 | endswitch; |
593 | 593 | |
594 | 594 | // Allow extensions to setup their own return data |
595 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
595 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
596 | 596 | |
597 | - $after = microtime( true ); |
|
598 | - $request_time = ( $after - $before ); |
|
597 | + $after = microtime(true); |
|
598 | + $request_time = ($after - $before); |
|
599 | 599 | $this->data['request_speed'] = $request_time; |
600 | 600 | |
601 | 601 | // Log this API request, if enabled. We log it here because we have access to errors. |
602 | - $this->log_request( $this->data ); |
|
602 | + $this->log_request($this->data); |
|
603 | 603 | |
604 | 604 | // Send out data to the output function |
605 | 605 | $this->output(); |
@@ -629,25 +629,25 @@ discard block |
||
629 | 629 | global $wp_query; |
630 | 630 | |
631 | 631 | // Whitelist our query options |
632 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
632 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
633 | 633 | 'stats', |
634 | 634 | 'forms', |
635 | 635 | 'donors', |
636 | 636 | 'donations', |
637 | - ) ); |
|
637 | + )); |
|
638 | 638 | |
639 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
640 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
639 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
640 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
641 | 641 | |
642 | 642 | $error = array(); |
643 | 643 | |
644 | 644 | // Make sure our query is valid |
645 | - if ( ! in_array( $query, $accepted ) ) { |
|
646 | - $error['error'] = __( 'Invalid query.', 'give' ); |
|
645 | + if ( ! in_array($query, $accepted)) { |
|
646 | + $error['error'] = __('Invalid query.', 'give'); |
|
647 | 647 | |
648 | 648 | $this->data = $error; |
649 | 649 | // 400 is Bad Request |
650 | - $this->output( 400 ); |
|
650 | + $this->output(400); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | $this->endpoint = $query; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | public function get_paged() { |
665 | 665 | global $wp_query; |
666 | 666 | |
667 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
667 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | public function per_page() { |
680 | 680 | global $wp_query; |
681 | 681 | |
682 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
682 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
683 | 683 | |
684 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
684 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
685 | 685 | $per_page = 99999999; |
686 | 686 | } // End if(). |
687 | 687 | |
688 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
688 | + return apply_filters('give_api_results_per_page', $per_page); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array $dates |
700 | 700 | */ |
701 | - public function get_dates( $args = array() ) { |
|
701 | + public function get_dates($args = array()) { |
|
702 | 702 | $dates = array(); |
703 | 703 | |
704 | 704 | $defaults = array( |
@@ -709,60 +709,60 @@ discard block |
||
709 | 709 | 'enddate' => null, |
710 | 710 | ); |
711 | 711 | |
712 | - $args = wp_parse_args( $args, $defaults ); |
|
712 | + $args = wp_parse_args($args, $defaults); |
|
713 | 713 | |
714 | - $current_time = current_time( 'timestamp' ); |
|
714 | + $current_time = current_time('timestamp'); |
|
715 | 715 | |
716 | - if ( 'range' === $args['date'] ) { |
|
717 | - $startdate = strtotime( $args['startdate'] ); |
|
718 | - $enddate = strtotime( $args['enddate'] ); |
|
719 | - $dates['day_start'] = date( 'd', $startdate ); |
|
720 | - $dates['day_end'] = date( 'd', $enddate ); |
|
721 | - $dates['m_start'] = date( 'n', $startdate ); |
|
722 | - $dates['m_end'] = date( 'n', $enddate ); |
|
723 | - $dates['year'] = date( 'Y', $startdate ); |
|
724 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
716 | + if ('range' === $args['date']) { |
|
717 | + $startdate = strtotime($args['startdate']); |
|
718 | + $enddate = strtotime($args['enddate']); |
|
719 | + $dates['day_start'] = date('d', $startdate); |
|
720 | + $dates['day_end'] = date('d', $enddate); |
|
721 | + $dates['m_start'] = date('n', $startdate); |
|
722 | + $dates['m_end'] = date('n', $enddate); |
|
723 | + $dates['year'] = date('Y', $startdate); |
|
724 | + $dates['year_end'] = date('Y', $enddate); |
|
725 | 725 | } else { |
726 | 726 | // Modify dates based on predefined ranges |
727 | - switch ( $args['date'] ) : |
|
727 | + switch ($args['date']) : |
|
728 | 728 | |
729 | 729 | case 'this_month' : |
730 | 730 | $dates['day'] = null; |
731 | - $dates['m_start'] = date( 'n', $current_time ); |
|
732 | - $dates['m_end'] = date( 'n', $current_time ); |
|
733 | - $dates['year'] = date( 'Y', $current_time ); |
|
731 | + $dates['m_start'] = date('n', $current_time); |
|
732 | + $dates['m_end'] = date('n', $current_time); |
|
733 | + $dates['year'] = date('Y', $current_time); |
|
734 | 734 | break; |
735 | 735 | |
736 | 736 | case 'last_month' : |
737 | 737 | $dates['day'] = null; |
738 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
738 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
739 | 739 | $dates['m_end'] = $dates['m_start']; |
740 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
740 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
741 | 741 | break; |
742 | 742 | |
743 | 743 | case 'today' : |
744 | - $dates['day'] = date( 'd', $current_time ); |
|
745 | - $dates['m_start'] = date( 'n', $current_time ); |
|
746 | - $dates['m_end'] = date( 'n', $current_time ); |
|
747 | - $dates['year'] = date( 'Y', $current_time ); |
|
744 | + $dates['day'] = date('d', $current_time); |
|
745 | + $dates['m_start'] = date('n', $current_time); |
|
746 | + $dates['m_end'] = date('n', $current_time); |
|
747 | + $dates['year'] = date('Y', $current_time); |
|
748 | 748 | break; |
749 | 749 | |
750 | 750 | case 'yesterday' : |
751 | 751 | |
752 | - $year = date( 'Y', $current_time ); |
|
753 | - $month = date( 'n', $current_time ); |
|
754 | - $day = date( 'd', $current_time ); |
|
752 | + $year = date('Y', $current_time); |
|
753 | + $month = date('n', $current_time); |
|
754 | + $day = date('d', $current_time); |
|
755 | 755 | |
756 | - if ( $month == 1 && $day == 1 ) { |
|
756 | + if ($month == 1 && $day == 1) { |
|
757 | 757 | |
758 | - $year -= 1; |
|
758 | + $year -= 1; |
|
759 | 759 | $month = 12; |
760 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
760 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
761 | 761 | |
762 | - } elseif ( $month > 1 && $day == 1 ) { |
|
762 | + } elseif ($month > 1 && $day == 1) { |
|
763 | 763 | |
764 | 764 | $month -= 1; |
765 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
765 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
766 | 766 | |
767 | 767 | } else { |
768 | 768 | |
@@ -778,65 +778,65 @@ discard block |
||
778 | 778 | break; |
779 | 779 | |
780 | 780 | case 'this_quarter' : |
781 | - $month_now = date( 'n', $current_time ); |
|
781 | + $month_now = date('n', $current_time); |
|
782 | 782 | |
783 | 783 | $dates['day'] = null; |
784 | 784 | |
785 | - if ( $month_now <= 3 ) { |
|
785 | + if ($month_now <= 3) { |
|
786 | 786 | |
787 | 787 | $dates['m_start'] = 1; |
788 | 788 | $dates['m_end'] = 3; |
789 | - $dates['year'] = date( 'Y', $current_time ); |
|
789 | + $dates['year'] = date('Y', $current_time); |
|
790 | 790 | |
791 | - } elseif ( $month_now <= 6 ) { |
|
791 | + } elseif ($month_now <= 6) { |
|
792 | 792 | |
793 | 793 | $dates['m_start'] = 4; |
794 | 794 | $dates['m_end'] = 6; |
795 | - $dates['year'] = date( 'Y', $current_time ); |
|
795 | + $dates['year'] = date('Y', $current_time); |
|
796 | 796 | |
797 | - } elseif ( $month_now <= 9 ) { |
|
797 | + } elseif ($month_now <= 9) { |
|
798 | 798 | |
799 | 799 | $dates['m_start'] = 7; |
800 | 800 | $dates['m_end'] = 9; |
801 | - $dates['year'] = date( 'Y', $current_time ); |
|
801 | + $dates['year'] = date('Y', $current_time); |
|
802 | 802 | |
803 | 803 | } else { |
804 | 804 | |
805 | 805 | $dates['m_start'] = 10; |
806 | 806 | $dates['m_end'] = 12; |
807 | - $dates['year'] = date( 'Y', $current_time ); |
|
807 | + $dates['year'] = date('Y', $current_time); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | break; |
811 | 811 | |
812 | 812 | case 'last_quarter' : |
813 | - $month_now = date( 'n', $current_time ); |
|
813 | + $month_now = date('n', $current_time); |
|
814 | 814 | |
815 | 815 | $dates['day'] = null; |
816 | 816 | |
817 | - if ( $month_now <= 3 ) { |
|
817 | + if ($month_now <= 3) { |
|
818 | 818 | |
819 | 819 | $dates['m_start'] = 10; |
820 | 820 | $dates['m_end'] = 12; |
821 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
821 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
822 | 822 | |
823 | - } elseif ( $month_now <= 6 ) { |
|
823 | + } elseif ($month_now <= 6) { |
|
824 | 824 | |
825 | 825 | $dates['m_start'] = 1; |
826 | 826 | $dates['m_end'] = 3; |
827 | - $dates['year'] = date( 'Y', $current_time ); |
|
827 | + $dates['year'] = date('Y', $current_time); |
|
828 | 828 | |
829 | - } elseif ( $month_now <= 9 ) { |
|
829 | + } elseif ($month_now <= 9) { |
|
830 | 830 | |
831 | 831 | $dates['m_start'] = 4; |
832 | 832 | $dates['m_end'] = 6; |
833 | - $dates['year'] = date( 'Y', $current_time ); |
|
833 | + $dates['year'] = date('Y', $current_time); |
|
834 | 834 | |
835 | 835 | } else { |
836 | 836 | |
837 | 837 | $dates['m_start'] = 7; |
838 | 838 | $dates['m_end'] = 9; |
839 | - $dates['year'] = date( 'Y', $current_time ); |
|
839 | + $dates['year'] = date('Y', $current_time); |
|
840 | 840 | |
841 | 841 | } |
842 | 842 | break; |
@@ -845,14 +845,14 @@ discard block |
||
845 | 845 | $dates['day'] = null; |
846 | 846 | $dates['m_start'] = null; |
847 | 847 | $dates['m_end'] = null; |
848 | - $dates['year'] = date( 'Y', $current_time ); |
|
848 | + $dates['year'] = date('Y', $current_time); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | case 'last_year' : |
852 | 852 | $dates['day'] = null; |
853 | 853 | $dates['m_start'] = null; |
854 | 854 | $dates['m_end'] = null; |
855 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
855 | + $dates['year'] = date('Y', $current_time) - 1; |
|
856 | 856 | break; |
857 | 857 | |
858 | 858 | endswitch; |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | * |
866 | 866 | * @param array $dates The dates used for retrieving earnings. |
867 | 867 | */ |
868 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
868 | + return apply_filters('give_api_stat_dates', $dates); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
@@ -879,78 +879,78 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @return array $donors Multidimensional array of the donors. |
881 | 881 | */ |
882 | - public function get_donors( $donor = null ) { |
|
882 | + public function get_donors($donor = null) { |
|
883 | 883 | |
884 | 884 | $donors = array(); |
885 | 885 | $error = array(); |
886 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
886 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
887 | 887 | return $donors; |
888 | 888 | } |
889 | 889 | |
890 | 890 | $paged = $this->get_paged(); |
891 | 891 | $per_page = $this->per_page(); |
892 | - $offset = $per_page * ( $paged - 1 ); |
|
892 | + $offset = $per_page * ($paged - 1); |
|
893 | 893 | |
894 | - if ( is_numeric( $donor ) ) { |
|
894 | + if (is_numeric($donor)) { |
|
895 | 895 | $field = 'id'; |
896 | 896 | } else { |
897 | 897 | $field = 'email'; |
898 | 898 | } |
899 | 899 | |
900 | - $donor_query = Give()->donors->get_donors( array( |
|
900 | + $donor_query = Give()->donors->get_donors(array( |
|
901 | 901 | 'number' => $per_page, |
902 | 902 | 'offset' => $offset, |
903 | 903 | $field => $donor, |
904 | - ) ); |
|
904 | + )); |
|
905 | 905 | $donor_count = 0; |
906 | 906 | |
907 | - if ( $donor_query ) { |
|
907 | + if ($donor_query) { |
|
908 | 908 | |
909 | - foreach ( $donor_query as $donor_obj ) { |
|
909 | + foreach ($donor_query as $donor_obj) { |
|
910 | 910 | |
911 | - $names = explode( ' ', $donor_obj->name ); |
|
912 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
911 | + $names = explode(' ', $donor_obj->name); |
|
912 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
913 | 913 | $last_name = ''; |
914 | - if ( ! empty( $names[1] ) ) { |
|
915 | - unset( $names[0] ); |
|
916 | - $last_name = implode( ' ', $names ); |
|
914 | + if ( ! empty($names[1])) { |
|
915 | + unset($names[0]); |
|
916 | + $last_name = implode(' ', $names); |
|
917 | 917 | } |
918 | 918 | |
919 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; |
|
920 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; |
|
921 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; |
|
922 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; |
|
923 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; |
|
924 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; |
|
925 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; |
|
919 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; |
|
920 | + $donors['donors'][$donor_count]['info']['username'] = ''; |
|
921 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; |
|
922 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; |
|
923 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; |
|
924 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; |
|
925 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; |
|
926 | 926 | |
927 | - if ( ! empty( $donor_obj->user_id ) ) { |
|
927 | + if ( ! empty($donor_obj->user_id)) { |
|
928 | 928 | |
929 | - $user_data = get_userdata( $donor_obj->user_id ); |
|
929 | + $user_data = get_userdata($donor_obj->user_id); |
|
930 | 930 | |
931 | 931 | // Donor with registered account. |
932 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; |
|
933 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; |
|
934 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; |
|
932 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; |
|
933 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; |
|
934 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; |
|
935 | 935 | |
936 | 936 | } |
937 | 937 | |
938 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
939 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
938 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
939 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
940 | 940 | |
941 | - $donor_count ++; |
|
941 | + $donor_count++; |
|
942 | 942 | |
943 | 943 | } |
944 | - } elseif ( $donor ) { |
|
944 | + } elseif ($donor) { |
|
945 | 945 | |
946 | 946 | $error['error'] = sprintf( /* translators: %s: donor */ |
947 | - __( 'Donor %s not found.', 'give' ), $donor ); |
|
947 | + __('Donor %s not found.', 'give'), $donor ); |
|
948 | 948 | |
949 | 949 | return $error; |
950 | 950 | |
951 | 951 | } else { |
952 | 952 | |
953 | - $error['error'] = __( 'No donors found.', 'give' ); |
|
953 | + $error['error'] = __('No donors found.', 'give'); |
|
954 | 954 | |
955 | 955 | return $error; |
956 | 956 | |
@@ -969,37 +969,37 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return array $donors Multidimensional array of the forms. |
971 | 971 | */ |
972 | - public function get_forms( $form = null ) { |
|
972 | + public function get_forms($form = null) { |
|
973 | 973 | |
974 | 974 | $forms = array(); |
975 | 975 | $error = array(); |
976 | 976 | |
977 | - if ( $form == null ) { |
|
977 | + if ($form == null) { |
|
978 | 978 | $forms['forms'] = array(); |
979 | 979 | |
980 | - $form_list = get_posts( array( |
|
980 | + $form_list = get_posts(array( |
|
981 | 981 | 'post_type' => 'give_forms', |
982 | 982 | 'posts_per_page' => $this->per_page(), |
983 | 983 | 'suppress_filters' => true, |
984 | 984 | 'paged' => $this->get_paged(), |
985 | - ) ); |
|
985 | + )); |
|
986 | 986 | |
987 | - if ( $form_list ) { |
|
987 | + if ($form_list) { |
|
988 | 988 | $i = 0; |
989 | - foreach ( $form_list as $form_info ) { |
|
990 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
991 | - $i ++; |
|
989 | + foreach ($form_list as $form_info) { |
|
990 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
991 | + $i++; |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | } else { |
995 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
996 | - $form_info = get_post( $form ); |
|
995 | + if (get_post_type($form) == 'give_forms') { |
|
996 | + $form_info = get_post($form); |
|
997 | 997 | |
998 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
998 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
999 | 999 | |
1000 | 1000 | } else { |
1001 | 1001 | $error['error'] = sprintf( /* translators: %s: form */ |
1002 | - __( 'Form %s not found.', 'give' ), $form ); |
|
1002 | + __('Form %s not found.', 'give'), $form ); |
|
1003 | 1003 | |
1004 | 1004 | return $error; |
1005 | 1005 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @return array Array of post data to return back in the API. |
1019 | 1019 | */ |
1020 | - private function get_form_data( $form_info ) { |
|
1020 | + private function get_form_data($form_info) { |
|
1021 | 1021 | |
1022 | 1022 | $form = array(); |
1023 | 1023 | |
@@ -1027,60 +1027,60 @@ discard block |
||
1027 | 1027 | $form['info']['create_date'] = $form_info->post_date; |
1028 | 1028 | $form['info']['modified_date'] = $form_info->post_modified; |
1029 | 1029 | $form['info']['status'] = $form_info->post_status; |
1030 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1031 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); |
|
1032 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1030 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1031 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); |
|
1032 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1033 | 1033 | |
1034 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1035 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1036 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1034 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1035 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1036 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1037 | 1037 | } |
1038 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1039 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1038 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1039 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | // Check whether any goal is to be achieved for the donation form. |
1043 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); |
|
1044 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); |
|
1045 | - if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { |
|
1046 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); |
|
1047 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; |
|
1048 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; |
|
1049 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; |
|
1043 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); |
|
1044 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); |
|
1045 | + if (give_is_setting_enabled($goal_option) && $goal_amount) { |
|
1046 | + $total_income = give_get_form_earnings_stats($form_info->ID); |
|
1047 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; |
|
1048 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; |
|
1049 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1053 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1054 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1055 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1056 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1052 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1053 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1054 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1055 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1056 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $counter = 0; |
1060 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1061 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1062 | - $counter ++; |
|
1060 | + if (give_has_variable_prices($form_info->ID)) { |
|
1061 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1062 | + $counter++; |
|
1063 | 1063 | // multi-level item |
1064 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1065 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1064 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1065 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1066 | 1066 | |
1067 | 1067 | } |
1068 | 1068 | } else { |
1069 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1069 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1072 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1073 | 1073 | |
1074 | 1074 | /** |
1075 | 1075 | * Fires when generating API sensitive data. |
1076 | 1076 | * |
1077 | 1077 | * @since 1.1 |
1078 | 1078 | */ |
1079 | - do_action( 'give_api_sensitive_data' ); |
|
1079 | + do_action('give_api_sensitive_data'); |
|
1080 | 1080 | |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1083 | + return apply_filters('give_api_forms_form', $form); |
|
1084 | 1084 | |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return array |
1097 | 1097 | */ |
1098 | - public function get_stats( $args = array() ) { |
|
1098 | + public function get_stats($args = array()) { |
|
1099 | 1099 | $defaults = array( |
1100 | 1100 | 'type' => null, |
1101 | 1101 | 'form' => null, |
@@ -1104,9 +1104,9 @@ discard block |
||
1104 | 1104 | 'enddate' => null, |
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - $args = wp_parse_args( $args, $defaults ); |
|
1107 | + $args = wp_parse_args($args, $defaults); |
|
1108 | 1108 | |
1109 | - $dates = $this->get_dates( $args ); |
|
1109 | + $dates = $this->get_dates($args); |
|
1110 | 1110 | |
1111 | 1111 | $stats = array(); |
1112 | 1112 | $earnings = array( |
@@ -1117,40 +1117,40 @@ discard block |
||
1117 | 1117 | ); |
1118 | 1118 | $error = array(); |
1119 | 1119 | |
1120 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1120 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1121 | 1121 | return $stats; |
1122 | 1122 | } |
1123 | 1123 | |
1124 | - if ( $args['type'] == 'donations' ) { |
|
1124 | + if ($args['type'] == 'donations') { |
|
1125 | 1125 | |
1126 | - if ( $args['form'] == null ) { |
|
1127 | - if ( $args['date'] == null ) { |
|
1126 | + if ($args['form'] == null) { |
|
1127 | + if ($args['date'] == null) { |
|
1128 | 1128 | $donations = $this->get_default_sales_stats(); |
1129 | - } elseif ( $args['date'] === 'range' ) { |
|
1129 | + } elseif ($args['date'] === 'range') { |
|
1130 | 1130 | // Return donations for a date range. |
1131 | 1131 | // Ensure the end date is later than the start date. |
1132 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1133 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1132 | + if ($args['enddate'] < $args['startdate']) { |
|
1133 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // Ensure both the start and end date are specified |
1137 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1138 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1137 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1138 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | $total = 0; |
1142 | 1142 | |
1143 | 1143 | // Loop through the years |
1144 | 1144 | $y = $dates['year']; |
1145 | - while ( $y <= $dates['year_end'] ) : |
|
1145 | + while ($y <= $dates['year_end']) : |
|
1146 | 1146 | |
1147 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1147 | + if ($dates['year'] == $dates['year_end']) { |
|
1148 | 1148 | $month_start = $dates['m_start']; |
1149 | 1149 | $month_end = $dates['m_end']; |
1150 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1150 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1151 | 1151 | $month_start = $dates['m_start']; |
1152 | 1152 | $month_end = 12; |
1153 | - } elseif ( $y == $dates['year_end'] ) { |
|
1153 | + } elseif ($y == $dates['year_end']) { |
|
1154 | 1154 | $month_start = 1; |
1155 | 1155 | $month_end = $dates['m_end']; |
1156 | 1156 | } else { |
@@ -1159,116 +1159,116 @@ discard block |
||
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | $i = $month_start; |
1162 | - while ( $i <= $month_end ) : |
|
1162 | + while ($i <= $month_end) : |
|
1163 | 1163 | |
1164 | - if ( $i == $dates['m_start'] ) { |
|
1164 | + if ($i == $dates['m_start']) { |
|
1165 | 1165 | $d = $dates['day_start']; |
1166 | 1166 | } else { |
1167 | 1167 | $d = 1; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | - if ( $i == $dates['m_end'] ) { |
|
1170 | + if ($i == $dates['m_end']) { |
|
1171 | 1171 | $num_of_days = $dates['day_end']; |
1172 | 1172 | } else { |
1173 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1173 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | - while ( $d <= $num_of_days ) : |
|
1177 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1178 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1179 | - if ( ! isset( $donations['sales'][ $date_key ] ) ) { |
|
1180 | - $donations['sales'][ $date_key ] = 0; |
|
1176 | + while ($d <= $num_of_days) : |
|
1177 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1178 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1179 | + if ( ! isset($donations['sales'][$date_key])) { |
|
1180 | + $donations['sales'][$date_key] = 0; |
|
1181 | 1181 | } |
1182 | - $donations['sales'][ $date_key ] += $sale_count; |
|
1182 | + $donations['sales'][$date_key] += $sale_count; |
|
1183 | 1183 | $total += $sale_count; |
1184 | - $d ++; |
|
1184 | + $d++; |
|
1185 | 1185 | endwhile; |
1186 | - $i ++; |
|
1186 | + $i++; |
|
1187 | 1187 | endwhile; |
1188 | 1188 | |
1189 | - $y ++; |
|
1189 | + $y++; |
|
1190 | 1190 | endwhile; |
1191 | 1191 | |
1192 | 1192 | $donations['totals'] = $total; |
1193 | 1193 | } else { |
1194 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1194 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1195 | 1195 | $donations_count = 0; |
1196 | 1196 | |
1197 | 1197 | // Loop through the months |
1198 | 1198 | $month = $dates['m_start']; |
1199 | 1199 | |
1200 | - while ( $month <= $dates['m_end'] ) : |
|
1201 | - $donations_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1202 | - $month ++; |
|
1200 | + while ($month <= $dates['m_end']) : |
|
1201 | + $donations_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1202 | + $month++; |
|
1203 | 1203 | endwhile; |
1204 | 1204 | |
1205 | - $donations['donations'][ $args['date'] ] = $donations_count; |
|
1205 | + $donations['donations'][$args['date']] = $donations_count; |
|
1206 | 1206 | } else { |
1207 | - $donations['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1207 | + $donations['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1208 | 1208 | } |
1209 | 1209 | }// End if(). |
1210 | - } elseif ( $args['form'] == 'all' ) { |
|
1211 | - $forms = get_posts( array( |
|
1210 | + } elseif ($args['form'] == 'all') { |
|
1211 | + $forms = get_posts(array( |
|
1212 | 1212 | 'post_type' => 'give_forms', |
1213 | 1213 | 'nopaging' => true, |
1214 | - ) ); |
|
1215 | - $i = 0; |
|
1216 | - foreach ( $forms as $form_info ) { |
|
1217 | - $donations['donations'][ $i ] = array( |
|
1218 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), |
|
1214 | + )); |
|
1215 | + $i = 0; |
|
1216 | + foreach ($forms as $form_info) { |
|
1217 | + $donations['donations'][$i] = array( |
|
1218 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), |
|
1219 | 1219 | ); |
1220 | - $i ++; |
|
1220 | + $i++; |
|
1221 | 1221 | } |
1222 | 1222 | } else { |
1223 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1224 | - $form_info = get_post( $args['form'] ); |
|
1223 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1224 | + $form_info = get_post($args['form']); |
|
1225 | 1225 | $donations['donations'][0] = array( |
1226 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), |
|
1226 | + $form_info->post_name => give_get_form_sales_stats($args['form']), |
|
1227 | 1227 | ); |
1228 | 1228 | } else { |
1229 | 1229 | $error['error'] = sprintf( /* translators: %s: form */ |
1230 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1230 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1231 | 1231 | } |
1232 | 1232 | }// End if(). |
1233 | 1233 | |
1234 | - if ( ! empty( $error ) ) { |
|
1234 | + if ( ! empty($error)) { |
|
1235 | 1235 | return $error; |
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | return $donations; |
1239 | 1239 | |
1240 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1241 | - if ( $args['form'] == null ) { |
|
1242 | - if ( $args['date'] == null ) { |
|
1240 | + } elseif ($args['type'] == 'earnings') { |
|
1241 | + if ($args['form'] == null) { |
|
1242 | + if ($args['date'] == null) { |
|
1243 | 1243 | $earnings = $this->get_default_earnings_stats(); |
1244 | - } elseif ( $args['date'] === 'range' ) { |
|
1244 | + } elseif ($args['date'] === 'range') { |
|
1245 | 1245 | // Return sales for a date range |
1246 | 1246 | // Ensure the end date is later than the start date |
1247 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1248 | - $error['error'] = __( 'The end date must be later than the start date.', 'give' ); |
|
1247 | + if ($args['enddate'] < $args['startdate']) { |
|
1248 | + $error['error'] = __('The end date must be later than the start date.', 'give'); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // Ensure both the start and end date are specified |
1252 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1253 | - $error['error'] = __( 'Invalid or no date range specified.', 'give' ); |
|
1252 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1253 | + $error['error'] = __('Invalid or no date range specified.', 'give'); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | $total = (float) 0.00; |
1257 | 1257 | |
1258 | 1258 | // Loop through the years |
1259 | 1259 | $y = $dates['year']; |
1260 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1260 | + if ( ! isset($earnings['earnings'])) { |
|
1261 | 1261 | $earnings['earnings'] = array(); |
1262 | 1262 | } |
1263 | - while ( $y <= $dates['year_end'] ) : |
|
1263 | + while ($y <= $dates['year_end']) : |
|
1264 | 1264 | |
1265 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1265 | + if ($dates['year'] == $dates['year_end']) { |
|
1266 | 1266 | $month_start = $dates['m_start']; |
1267 | 1267 | $month_end = $dates['m_end']; |
1268 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1268 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1269 | 1269 | $month_start = $dates['m_start']; |
1270 | 1270 | $month_end = 12; |
1271 | - } elseif ( $y == $dates['year_end'] ) { |
|
1271 | + } elseif ($y == $dates['year_end']) { |
|
1272 | 1272 | $month_start = 1; |
1273 | 1273 | $month_end = $dates['m_end']; |
1274 | 1274 | } else { |
@@ -1277,94 +1277,94 @@ discard block |
||
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | $i = $month_start; |
1280 | - while ( $i <= $month_end ) : |
|
1280 | + while ($i <= $month_end) : |
|
1281 | 1281 | |
1282 | - if ( $i == $dates['m_start'] ) { |
|
1282 | + if ($i == $dates['m_start']) { |
|
1283 | 1283 | $d = $dates['day_start']; |
1284 | 1284 | } else { |
1285 | 1285 | $d = 1; |
1286 | 1286 | } |
1287 | 1287 | |
1288 | - if ( $i == $dates['m_end'] ) { |
|
1288 | + if ($i == $dates['m_end']) { |
|
1289 | 1289 | $num_of_days = $dates['day_end']; |
1290 | 1290 | } else { |
1291 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1291 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | - while ( $d <= $num_of_days ) : |
|
1295 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1296 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1297 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1298 | - $earnings['earnings'][ $date_key ] = 0; |
|
1294 | + while ($d <= $num_of_days) : |
|
1295 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1296 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1297 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1298 | + $earnings['earnings'][$date_key] = 0; |
|
1299 | 1299 | } |
1300 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1300 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1301 | 1301 | $total += $earnings_stat; |
1302 | - $d ++; |
|
1302 | + $d++; |
|
1303 | 1303 | endwhile; |
1304 | 1304 | |
1305 | - $i ++; |
|
1305 | + $i++; |
|
1306 | 1306 | endwhile; |
1307 | 1307 | |
1308 | - $y ++; |
|
1308 | + $y++; |
|
1309 | 1309 | endwhile; |
1310 | 1310 | |
1311 | 1311 | $earnings['totals'] = $total; |
1312 | 1312 | } else { |
1313 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1313 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1314 | 1314 | $earnings_count = (float) 0.00; |
1315 | 1315 | |
1316 | 1316 | // Loop through the months |
1317 | 1317 | $month = $dates['m_start']; |
1318 | 1318 | |
1319 | - while ( $month <= $dates['m_end'] ) : |
|
1320 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1321 | - $month ++; |
|
1319 | + while ($month <= $dates['m_end']) : |
|
1320 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1321 | + $month++; |
|
1322 | 1322 | endwhile; |
1323 | 1323 | |
1324 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1324 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1325 | 1325 | } else { |
1326 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1326 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1327 | 1327 | } |
1328 | 1328 | }// End if(). |
1329 | - } elseif ( $args['form'] == 'all' ) { |
|
1330 | - $forms = get_posts( array( |
|
1329 | + } elseif ($args['form'] == 'all') { |
|
1330 | + $forms = get_posts(array( |
|
1331 | 1331 | 'post_type' => 'give_forms', |
1332 | 1332 | 'nopaging' => true, |
1333 | - ) ); |
|
1333 | + )); |
|
1334 | 1334 | |
1335 | 1335 | $i = 0; |
1336 | - foreach ( $forms as $form_info ) { |
|
1337 | - $earnings['earnings'][ $i ] = array( |
|
1338 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), |
|
1336 | + foreach ($forms as $form_info) { |
|
1337 | + $earnings['earnings'][$i] = array( |
|
1338 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), |
|
1339 | 1339 | ); |
1340 | - $i ++; |
|
1340 | + $i++; |
|
1341 | 1341 | } |
1342 | 1342 | } else { |
1343 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1344 | - $form_info = get_post( $args['form'] ); |
|
1343 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1344 | + $form_info = get_post($args['form']); |
|
1345 | 1345 | $earnings['earnings'][0] = array( |
1346 | - $form_info->post_name => give_get_form_earnings_stats( $args['form'] ), |
|
1346 | + $form_info->post_name => give_get_form_earnings_stats($args['form']), |
|
1347 | 1347 | ); |
1348 | 1348 | } else { |
1349 | 1349 | $error['error'] = sprintf( /* translators: %s: form */ |
1350 | - __( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1350 | + __('Form %s not found.', 'give'), $args['form'] ); |
|
1351 | 1351 | } |
1352 | 1352 | }// End if(). |
1353 | 1353 | |
1354 | - if ( ! empty( $error ) ) { |
|
1354 | + if ( ! empty($error)) { |
|
1355 | 1355 | return $error; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | return $earnings; |
1359 | - } elseif ( $args['type'] == 'donors' ) { |
|
1359 | + } elseif ($args['type'] == 'donors') { |
|
1360 | 1360 | $donors = new Give_DB_Donors(); |
1361 | 1361 | $stats['donations']['total_donors'] = $donors->count(); |
1362 | 1362 | |
1363 | 1363 | return $stats; |
1364 | 1364 | |
1365 | - } elseif ( empty( $args['type'] ) ) { |
|
1366 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1367 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1365 | + } elseif (empty($args['type'])) { |
|
1366 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1367 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1368 | 1368 | |
1369 | 1369 | return array( |
1370 | 1370 | 'stats' => $stats, |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | * |
1383 | 1383 | * @return array |
1384 | 1384 | */ |
1385 | - public function get_recent_donations( $args = array() ) { |
|
1385 | + public function get_recent_donations($args = array()) { |
|
1386 | 1386 | global $wp_query; |
1387 | 1387 | |
1388 | 1388 | $defaults = array( |
@@ -1392,33 +1392,33 @@ discard block |
||
1392 | 1392 | 'enddate' => null, |
1393 | 1393 | ); |
1394 | 1394 | |
1395 | - $args = wp_parse_args( $args, $defaults ); |
|
1395 | + $args = wp_parse_args($args, $defaults); |
|
1396 | 1396 | |
1397 | 1397 | $donations = array(); |
1398 | 1398 | |
1399 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1399 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1400 | 1400 | return $donations; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1403 | + if (isset($wp_query->query_vars['id'])) { |
|
1404 | 1404 | $query = array(); |
1405 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1406 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1405 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1406 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1407 | 1407 | $query = array(); |
1408 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1409 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1410 | - $args = array( |
|
1408 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1409 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1410 | + $args = array( |
|
1411 | 1411 | 'fields' => 'ids', |
1412 | 1412 | 'meta_key' => '_give_payment_user_email', |
1413 | 1413 | 'meta_value' => $wp_query->query_vars['email'], |
1414 | 1414 | 'number' => $this->per_page(), |
1415 | 1415 | 'page' => $this->get_paged(), |
1416 | 1416 | ); |
1417 | - $query = give_get_payments( $args ); |
|
1418 | - } elseif ( isset( $wp_query->query_vars['date'] ) ) { |
|
1417 | + $query = give_get_payments($args); |
|
1418 | + } elseif (isset($wp_query->query_vars['date'])) { |
|
1419 | 1419 | |
1420 | - $current_time = current_time( 'timestamp' ); |
|
1421 | - $dates = $this->get_dates( $args ); |
|
1420 | + $current_time = current_time('timestamp'); |
|
1421 | + $dates = $this->get_dates($args); |
|
1422 | 1422 | $start_date = ''; |
1423 | 1423 | $end_date = ''; |
1424 | 1424 | |
@@ -1431,27 +1431,27 @@ discard block |
||
1431 | 1431 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1432 | 1432 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1433 | 1433 | */ |
1434 | - switch ( $wp_query->query_vars['date'] ) { |
|
1434 | + switch ($wp_query->query_vars['date']) { |
|
1435 | 1435 | |
1436 | 1436 | case 'today': |
1437 | 1437 | |
1438 | 1438 | // Set and Format Start and End Date to be date of today. |
1439 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); |
|
1439 | + $start_date = $end_date = date('Y/m/d', $current_time); |
|
1440 | 1440 | |
1441 | 1441 | break; |
1442 | 1442 | |
1443 | 1443 | case 'yesterday': |
1444 | 1444 | |
1445 | 1445 | // Set and Format Start and End Date to be date of yesterday. |
1446 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); |
|
1446 | + $start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); |
|
1447 | 1447 | |
1448 | 1448 | break; |
1449 | 1449 | |
1450 | 1450 | case 'range': |
1451 | 1451 | |
1452 | 1452 | // Format Start Date and End Date for filtering payment based on date range. |
1453 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; |
|
1454 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; |
|
1453 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; |
|
1454 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; |
|
1455 | 1455 | |
1456 | 1456 | break; |
1457 | 1457 | |
@@ -1465,22 +1465,22 @@ discard block |
||
1465 | 1465 | 'page' => $this->get_paged(), |
1466 | 1466 | ); |
1467 | 1467 | |
1468 | - $query = give_get_payments( $args ); |
|
1468 | + $query = give_get_payments($args); |
|
1469 | 1469 | } else { |
1470 | 1470 | $args = array( |
1471 | 1471 | 'fields' => 'ids', |
1472 | 1472 | 'number' => $this->per_page(), |
1473 | 1473 | 'page' => $this->get_paged(), |
1474 | 1474 | ); |
1475 | - $query = give_get_payments( $args ); |
|
1475 | + $query = give_get_payments($args); |
|
1476 | 1476 | }// End if(). |
1477 | 1477 | |
1478 | - if ( $query ) { |
|
1478 | + if ($query) { |
|
1479 | 1479 | $i = 0; |
1480 | - foreach ( $query as $payment ) { |
|
1480 | + foreach ($query as $payment) { |
|
1481 | 1481 | |
1482 | - if ( is_numeric( $payment ) ) { |
|
1483 | - $payment = new Give_Payment( $payment ); |
|
1482 | + if (is_numeric($payment)) { |
|
1483 | + $payment = new Give_Payment($payment); |
|
1484 | 1484 | $payment_meta = $payment->get_meta(); |
1485 | 1485 | $user_info = $payment->user_info; |
1486 | 1486 | } |
@@ -1488,41 +1488,41 @@ discard block |
||
1488 | 1488 | $payment_meta = $payment->get_meta(); |
1489 | 1489 | $user_info = $payment->user_info; |
1490 | 1490 | |
1491 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1492 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1493 | - |
|
1494 | - $donations['donations'][ $i ]['ID'] = $payment->number; |
|
1495 | - $donations['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1496 | - $donations['donations'][ $i ]['key'] = $payment->key; |
|
1497 | - $donations['donations'][ $i ]['total'] = $payment->total; |
|
1498 | - $donations['donations'][ $i ]['status'] = give_get_payment_status( $payment, true ); |
|
1499 | - $donations['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1500 | - $donations['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1501 | - $donations['donations'][ $i ]['fname'] = $first_name; |
|
1502 | - $donations['donations'][ $i ]['lname'] = $last_name; |
|
1503 | - $donations['donations'][ $i ]['email'] = $payment->email; |
|
1504 | - $donations['donations'][ $i ]['date'] = $payment->date; |
|
1505 | - |
|
1506 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1507 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1508 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1509 | - |
|
1510 | - $donations['donations'][ $i ]['form']['id'] = $form_id; |
|
1511 | - $donations['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1512 | - $donations['donations'][ $i ]['form']['price'] = $price; |
|
1513 | - |
|
1514 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1515 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1516 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1517 | - $donations['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1518 | - $donations['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1519 | - $donations['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1491 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1492 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1493 | + |
|
1494 | + $donations['donations'][$i]['ID'] = $payment->number; |
|
1495 | + $donations['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1496 | + $donations['donations'][$i]['key'] = $payment->key; |
|
1497 | + $donations['donations'][$i]['total'] = $payment->total; |
|
1498 | + $donations['donations'][$i]['status'] = give_get_payment_status($payment, true); |
|
1499 | + $donations['donations'][$i]['gateway'] = $payment->gateway; |
|
1500 | + $donations['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1501 | + $donations['donations'][$i]['fname'] = $first_name; |
|
1502 | + $donations['donations'][$i]['lname'] = $last_name; |
|
1503 | + $donations['donations'][$i]['email'] = $payment->email; |
|
1504 | + $donations['donations'][$i]['date'] = $payment->date; |
|
1505 | + |
|
1506 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1507 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1508 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1509 | + |
|
1510 | + $donations['donations'][$i]['form']['id'] = $form_id; |
|
1511 | + $donations['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1512 | + $donations['donations'][$i]['form']['price'] = $price; |
|
1513 | + |
|
1514 | + if (give_has_variable_prices($form_id)) { |
|
1515 | + if (isset($payment_meta['price_id'])) { |
|
1516 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1517 | + $donations['donations'][$i]['form']['price_name'] = $price_name; |
|
1518 | + $donations['donations'][$i]['form']['price_id'] = $price_id; |
|
1519 | + $donations['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1520 | 1520 | |
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | // Add custom meta to API |
1525 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1525 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1526 | 1526 | |
1527 | 1527 | $exceptions = array( |
1528 | 1528 | 'form_title', |
@@ -1535,19 +1535,19 @@ discard block |
||
1535 | 1535 | ); |
1536 | 1536 | |
1537 | 1537 | // Don't clutter up results with dupes |
1538 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1538 | + if (in_array($meta_key, $exceptions)) { |
|
1539 | 1539 | continue; |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - $donations['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1542 | + $donations['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1543 | 1543 | |
1544 | 1544 | } |
1545 | 1545 | |
1546 | - $i ++; |
|
1546 | + $i++; |
|
1547 | 1547 | }// End foreach(). |
1548 | 1548 | }// End if(). |
1549 | 1549 | |
1550 | - return apply_filters( 'give_api_donations_endpoint', $donations ); |
|
1550 | + return apply_filters('give_api_donations_endpoint', $donations); |
|
1551 | 1551 | } |
1552 | 1552 | |
1553 | 1553 | /** |
@@ -1563,9 +1563,9 @@ discard block |
||
1563 | 1563 | public function get_output_format() { |
1564 | 1564 | global $wp_query; |
1565 | 1565 | |
1566 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1566 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1567 | 1567 | |
1568 | - return apply_filters( 'give_api_output_format', $format ); |
|
1568 | + return apply_filters('give_api_output_format', $format); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | |
@@ -1582,8 +1582,8 @@ discard block |
||
1582 | 1582 | * |
1583 | 1583 | * @return void |
1584 | 1584 | */ |
1585 | - private function log_request( $data = array() ) { |
|
1586 | - if ( ! $this->log_requests ) { |
|
1585 | + private function log_request($data = array()) { |
|
1586 | + if ( ! $this->log_requests) { |
|
1587 | 1587 | return; |
1588 | 1588 | } |
1589 | 1589 | |
@@ -1599,36 +1599,36 @@ discard block |
||
1599 | 1599 | |
1600 | 1600 | $query = array( |
1601 | 1601 | 'give-api' => $wp_query->query_vars['give-api'], |
1602 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1603 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1604 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1605 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1606 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1607 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, |
|
1608 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1609 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1610 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1611 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1612 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1613 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1602 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1603 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1604 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1605 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1606 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1607 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, |
|
1608 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1609 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1610 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1611 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1612 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1613 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1614 | 1614 | ); |
1615 | 1615 | |
1616 | 1616 | $log_data = array( |
1617 | 1617 | 'log_type' => 'api_request', |
1618 | - 'post_excerpt' => http_build_query( $query ), |
|
1619 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1618 | + 'post_excerpt' => http_build_query($query), |
|
1619 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1620 | 1620 | ); |
1621 | 1621 | |
1622 | 1622 | $log_meta = array( |
1623 | 1623 | 'request_ip' => give_get_ip(), |
1624 | 1624 | 'user' => $this->user_id, |
1625 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1626 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1625 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1626 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1627 | 1627 | 'time' => $data['request_speed'], |
1628 | 1628 | 'version' => $this->get_queried_version(), |
1629 | 1629 | ); |
1630 | 1630 | |
1631 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
1631 | + $give_logs->insert_log($log_data, $log_meta); |
|
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | |
@@ -1652,11 +1652,11 @@ discard block |
||
1652 | 1652 | * |
1653 | 1653 | * @param int $status_code |
1654 | 1654 | */ |
1655 | - public function output( $status_code = 200 ) { |
|
1655 | + public function output($status_code = 200) { |
|
1656 | 1656 | |
1657 | 1657 | $format = $this->get_output_format(); |
1658 | 1658 | |
1659 | - status_header( $status_code ); |
|
1659 | + status_header($status_code); |
|
1660 | 1660 | |
1661 | 1661 | /** |
1662 | 1662 | * Fires before outputting the API. |
@@ -1667,25 +1667,25 @@ discard block |
||
1667 | 1667 | * @param Give_API $this The Give_API object. |
1668 | 1668 | * @param string $format Output format, XML or JSON. Default is JSON. |
1669 | 1669 | */ |
1670 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1670 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1671 | 1671 | |
1672 | - switch ( $format ) : |
|
1672 | + switch ($format) : |
|
1673 | 1673 | |
1674 | 1674 | case 'xml' : |
1675 | 1675 | |
1676 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1677 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1676 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1677 | + $xml = Array2XML::createXML('give', $this->data); |
|
1678 | 1678 | echo $xml->saveXML(); |
1679 | 1679 | |
1680 | 1680 | break; |
1681 | 1681 | |
1682 | 1682 | case 'json' : |
1683 | 1683 | |
1684 | - header( 'Content-Type: application/json' ); |
|
1685 | - if ( ! empty( $this->pretty_print ) ) { |
|
1686 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1684 | + header('Content-Type: application/json'); |
|
1685 | + if ( ! empty($this->pretty_print)) { |
|
1686 | + echo json_encode($this->data, $this->pretty_print); |
|
1687 | 1687 | } else { |
1688 | - echo json_encode( $this->data ); |
|
1688 | + echo json_encode($this->data); |
|
1689 | 1689 | } |
1690 | 1690 | |
1691 | 1691 | break; |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | * @param array $data Response data to return. |
1701 | 1701 | * @param Give_API $this The Give_API object. |
1702 | 1702 | */ |
1703 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1703 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1704 | 1704 | |
1705 | 1705 | break; |
1706 | 1706 | |
@@ -1715,7 +1715,7 @@ discard block |
||
1715 | 1715 | * @param Give_API $this The Give_API object. |
1716 | 1716 | * @param string $format Output format, XML or JSON. Default is JSON. |
1717 | 1717 | */ |
1718 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1718 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1719 | 1719 | |
1720 | 1720 | give_die(); |
1721 | 1721 | } |
@@ -1732,41 +1732,41 @@ discard block |
||
1732 | 1732 | * |
1733 | 1733 | * @return void |
1734 | 1734 | */ |
1735 | - function user_key_field( $user ) { |
|
1735 | + function user_key_field($user) { |
|
1736 | 1736 | |
1737 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1737 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1738 | 1738 | |
1739 | - $user = get_userdata( $user->ID ); |
|
1739 | + $user = get_userdata($user->ID); |
|
1740 | 1740 | ?> |
1741 | 1741 | <table class="form-table"> |
1742 | 1742 | <tbody> |
1743 | 1743 | <tr> |
1744 | 1744 | <th> |
1745 | - <?php _e( 'Give API Keys', 'give' ); ?> |
|
1745 | + <?php _e('Give API Keys', 'give'); ?> |
|
1746 | 1746 | </th> |
1747 | 1747 | <td> |
1748 | 1748 | <?php |
1749 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1750 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1749 | + $public_key = $this->get_user_public_key($user->ID); |
|
1750 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1751 | 1751 | ?> |
1752 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1752 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1753 | 1753 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" /> |
1754 | - <span class="description"><?php _e( 'Generate API Key', 'give' ); ?></span> |
|
1754 | + <span class="description"><?php _e('Generate API Key', 'give'); ?></span> |
|
1755 | 1755 | <?php } else { ?> |
1756 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Public key:', 'give' ); ?> |
|
1756 | + <strong style="display:inline-block; width: 125px;"><?php _e('Public key:', 'give'); ?> |
|
1757 | 1757 | </strong> |
1758 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>" /> |
|
1758 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>" /> |
|
1759 | 1759 | <br /> |
1760 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Secret key:', 'give' ); ?> |
|
1760 | + <strong style="display:inline-block; width: 125px;"><?php _e('Secret key:', 'give'); ?> |
|
1761 | 1761 | </strong> |
1762 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>" /> |
|
1762 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>" /> |
|
1763 | 1763 | <br /> |
1764 | - <strong style="display:inline-block; width: 125px;"><?php _e( 'Token:', 'give' ); ?> |
|
1764 | + <strong style="display:inline-block; width: 125px;"><?php _e('Token:', 'give'); ?> |
|
1765 | 1765 | </strong> |
1766 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>" /> |
|
1766 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>" /> |
|
1767 | 1767 | <br /> |
1768 | 1768 | <input name="give_revoke_api_key" type="checkbox" id="give_revoke_api_key" /> |
1769 | - <span class="description"><label for="give_revoke_api_key"><?php _e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1769 | + <span class="description"><label for="give_revoke_api_key"><?php _e('Revoke API Keys', 'give'); ?></label></span> |
|
1770 | 1770 | <?php } ?> |
1771 | 1771 | </td> |
1772 | 1772 | </tr> |
@@ -1785,61 +1785,61 @@ discard block |
||
1785 | 1785 | * |
1786 | 1786 | * @return void |
1787 | 1787 | */ |
1788 | - public function process_api_key( $args ) { |
|
1788 | + public function process_api_key($args) { |
|
1789 | 1789 | |
1790 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1791 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( |
|
1790 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1791 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( |
|
1792 | 1792 | 'response' => 403, |
1793 | - ) ); |
|
1793 | + )); |
|
1794 | 1794 | } |
1795 | 1795 | |
1796 | - if ( empty( $args['user_id'] ) ) { |
|
1797 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( |
|
1796 | + if (empty($args['user_id'])) { |
|
1797 | + wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( |
|
1798 | 1798 | 'response' => 401, |
1799 | - ) ); |
|
1799 | + )); |
|
1800 | 1800 | } |
1801 | 1801 | |
1802 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1803 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1802 | + if (is_numeric($args['user_id'])) { |
|
1803 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1804 | 1804 | } else { |
1805 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1805 | + $userdata = get_user_by('login', $args['user_id']); |
|
1806 | 1806 | $user_id = $userdata->ID; |
1807 | 1807 | } |
1808 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1808 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1809 | 1809 | |
1810 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1811 | - wp_die( sprintf( /* translators: %s: process */ |
|
1812 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1810 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1811 | + wp_die(sprintf( /* translators: %s: process */ |
|
1812 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1813 | 1813 | 'response' => 403, |
1814 | - ) ); |
|
1815 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1816 | - wp_die( sprintf( /* translators: %s: process */ |
|
1817 | - __( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), __( 'Error', 'give' ), array( |
|
1814 | + )); |
|
1815 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1816 | + wp_die(sprintf( /* translators: %s: process */ |
|
1817 | + __('You do not have permission to %s API keys for this user.', 'give'), $process ), __('Error', 'give'), array( |
|
1818 | 1818 | 'response' => 403, |
1819 | - ) ); |
|
1819 | + )); |
|
1820 | 1820 | } |
1821 | 1821 | |
1822 | - switch ( $process ) { |
|
1822 | + switch ($process) { |
|
1823 | 1823 | case 'generate': |
1824 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1825 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1826 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1824 | + if ($this->generate_api_key($user_id)) { |
|
1825 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1826 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1827 | 1827 | exit(); |
1828 | 1828 | } else { |
1829 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1829 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1830 | 1830 | exit(); |
1831 | 1831 | } |
1832 | 1832 | break; |
1833 | 1833 | case 'regenerate': |
1834 | - $this->generate_api_key( $user_id, true ); |
|
1835 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1836 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1834 | + $this->generate_api_key($user_id, true); |
|
1835 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1836 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1837 | 1837 | exit(); |
1838 | 1838 | break; |
1839 | 1839 | case 'revoke': |
1840 | - $this->revoke_api_key( $user_id ); |
|
1841 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1842 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1840 | + $this->revoke_api_key($user_id); |
|
1841 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1842 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1843 | 1843 | exit(); |
1844 | 1844 | break; |
1845 | 1845 | default; |
@@ -1858,59 +1858,59 @@ discard block |
||
1858 | 1858 | * |
1859 | 1859 | * @return boolean True if (re)generated successfully, false otherwise. |
1860 | 1860 | */ |
1861 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1861 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1862 | 1862 | |
1863 | 1863 | // Bail out, if user doesn't exists. |
1864 | - if ( empty( $user_id ) ) { |
|
1864 | + if (empty($user_id)) { |
|
1865 | 1865 | return false; |
1866 | 1866 | } |
1867 | 1867 | |
1868 | - $user = get_userdata( $user_id ); |
|
1868 | + $user = get_userdata($user_id); |
|
1869 | 1869 | |
1870 | 1870 | // Bail Out, if user object doesn't exists. |
1871 | - if ( ! $user ) { |
|
1871 | + if ( ! $user) { |
|
1872 | 1872 | return false; |
1873 | 1873 | } |
1874 | 1874 | |
1875 | 1875 | $new_public_key = ''; |
1876 | 1876 | $new_secret_key = ''; |
1877 | 1877 | |
1878 | - if( ! empty( $_POST['from'] ) && 'profile' === $_POST['from'] ) { |
|
1878 | + if ( ! empty($_POST['from']) && 'profile' === $_POST['from']) { |
|
1879 | 1879 | // For User Profile Page. |
1880 | - if( ! empty( $_POST['give_set_api_key'] ) ) { |
|
1880 | + if ( ! empty($_POST['give_set_api_key'])) { |
|
1881 | 1881 | // Generate API Key from User Profile page. |
1882 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1883 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1884 | - } elseif ( ! empty( $_POST['give_revoke_api_key'] ) ) { |
|
1882 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1883 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1884 | + } elseif ( ! empty($_POST['give_revoke_api_key'])) { |
|
1885 | 1885 | // Revoke API Key from User Profile page. |
1886 | - $this->revoke_api_key( $user->ID ); |
|
1886 | + $this->revoke_api_key($user->ID); |
|
1887 | 1887 | } else { |
1888 | 1888 | return false; |
1889 | 1889 | } |
1890 | 1890 | } else { |
1891 | 1891 | // For Tools > API page. |
1892 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1892 | + $public_key = $this->get_user_public_key($user_id); |
|
1893 | 1893 | |
1894 | - if ( empty( $public_key ) && ! $regenerate ) { |
|
1894 | + if (empty($public_key) && ! $regenerate) { |
|
1895 | 1895 | // Generating API for first time. |
1896 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1897 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1898 | - } elseif ( $public_key && $regenerate ) { |
|
1896 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1897 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1898 | + } elseif ($public_key && $regenerate) { |
|
1899 | 1899 | // API Key already exists and Regenerating API Key. |
1900 | - $this->revoke_api_key( $user->ID ); |
|
1901 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1902 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1903 | - } elseif ( ! empty( $public_key ) && ! $regenerate ) { |
|
1900 | + $this->revoke_api_key($user->ID); |
|
1901 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1902 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1903 | + } elseif ( ! empty($public_key) && ! $regenerate) { |
|
1904 | 1904 | // Doing nothing, when API Key exists but still try to generate again instead of regenerating. |
1905 | 1905 | return false; |
1906 | 1906 | } else { |
1907 | 1907 | // Revoke API Key. |
1908 | - $this->revoke_api_key( $user->ID ); |
|
1908 | + $this->revoke_api_key($user->ID); |
|
1909 | 1909 | } |
1910 | 1910 | } |
1911 | 1911 | |
1912 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1913 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1912 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1913 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1914 | 1914 | |
1915 | 1915 | return true; |
1916 | 1916 | } |
@@ -1925,26 +1925,26 @@ discard block |
||
1925 | 1925 | * |
1926 | 1926 | * @return bool |
1927 | 1927 | */ |
1928 | - public function revoke_api_key( $user_id = 0 ) { |
|
1928 | + public function revoke_api_key($user_id = 0) { |
|
1929 | 1929 | |
1930 | - if ( empty( $user_id ) ) { |
|
1930 | + if (empty($user_id)) { |
|
1931 | 1931 | return false; |
1932 | 1932 | } |
1933 | 1933 | |
1934 | - $user = get_userdata( $user_id ); |
|
1934 | + $user = get_userdata($user_id); |
|
1935 | 1935 | |
1936 | - if ( ! $user ) { |
|
1936 | + if ( ! $user) { |
|
1937 | 1937 | return false; |
1938 | 1938 | } |
1939 | 1939 | |
1940 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1941 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1942 | - if ( ! empty( $public_key ) ) { |
|
1943 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
1944 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
1945 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
1946 | - delete_user_meta( $user_id, $public_key ); |
|
1947 | - delete_user_meta( $user_id, $secret_key ); |
|
1940 | + $public_key = $this->get_user_public_key($user_id); |
|
1941 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1942 | + if ( ! empty($public_key)) { |
|
1943 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
1944 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
1945 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
1946 | + delete_user_meta($user_id, $public_key); |
|
1947 | + delete_user_meta($user_id, $secret_key); |
|
1948 | 1948 | } else { |
1949 | 1949 | return false; |
1950 | 1950 | } |
@@ -1966,9 +1966,9 @@ discard block |
||
1966 | 1966 | * |
1967 | 1967 | * @return string |
1968 | 1968 | */ |
1969 | - private function generate_public_key( $user_email = '' ) { |
|
1970 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1971 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1969 | + private function generate_public_key($user_email = '') { |
|
1970 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1971 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
1972 | 1972 | |
1973 | 1973 | return $public; |
1974 | 1974 | } |
@@ -1983,9 +1983,9 @@ discard block |
||
1983 | 1983 | * |
1984 | 1984 | * @return string |
1985 | 1985 | */ |
1986 | - private function generate_private_key( $user_id = 0 ) { |
|
1987 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1988 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
1986 | + private function generate_private_key($user_id = 0) { |
|
1987 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1988 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
1989 | 1989 | |
1990 | 1990 | return $secret; |
1991 | 1991 | } |
@@ -2000,8 +2000,8 @@ discard block |
||
2000 | 2000 | * |
2001 | 2001 | * @return string |
2002 | 2002 | */ |
2003 | - public function get_token( $user_id = 0 ) { |
|
2004 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
2003 | + public function get_token($user_id = 0) { |
|
2004 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
2005 | 2005 | } |
2006 | 2006 | |
2007 | 2007 | /** |
@@ -2015,9 +2015,9 @@ discard block |
||
2015 | 2015 | |
2016 | 2016 | // Default sales return |
2017 | 2017 | $donations = array(); |
2018 | - $donations['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
2019 | - $donations['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
2020 | - $donations['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
2018 | + $donations['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
2019 | + $donations['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
2020 | + $donations['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
2021 | 2021 | $donations['donations']['totals'] = give_get_total_donations(); |
2022 | 2022 | |
2023 | 2023 | return $donations; |
@@ -2034,9 +2034,9 @@ discard block |
||
2034 | 2034 | |
2035 | 2035 | // Default earnings return |
2036 | 2036 | $earnings = array(); |
2037 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
2038 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
2039 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
2037 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
2038 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
2039 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
2040 | 2040 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
2041 | 2041 | |
2042 | 2042 | return $earnings; |
@@ -2056,25 +2056,25 @@ discard block |
||
2056 | 2056 | * |
2057 | 2057 | * @return string The API key/secret for the user supplied |
2058 | 2058 | */ |
2059 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
2059 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
2060 | 2060 | |
2061 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
2061 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
2062 | 2062 | return $check; |
2063 | 2063 | } |
2064 | 2064 | |
2065 | 2065 | $return = $check; |
2066 | 2066 | |
2067 | - switch ( $meta_key ) { |
|
2067 | + switch ($meta_key) { |
|
2068 | 2068 | case 'give_user_public_key': |
2069 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
2069 | + $return = Give()->api->get_user_public_key($object_id); |
|
2070 | 2070 | break; |
2071 | 2071 | case 'give_user_secret_key': |
2072 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
2072 | + $return = Give()->api->get_user_secret_key($object_id); |
|
2073 | 2073 | break; |
2074 | 2074 | } |
2075 | 2075 | |
2076 | - if ( ! $single ) { |
|
2077 | - $return = array( $return ); |
|
2076 | + if ( ! $single) { |
|
2077 | + $return = array($return); |
|
2078 | 2078 | } |
2079 | 2079 | |
2080 | 2080 | return $return; |
@@ -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 | |
@@ -62,50 +62,50 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return bool If the gravatar exists or not |
64 | 64 | */ |
65 | - public function validate_gravatar( $id_or_email ) { |
|
65 | + public function validate_gravatar($id_or_email) { |
|
66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
67 | 67 | $email = ''; |
68 | - if ( is_numeric( $id_or_email ) ) { |
|
68 | + if (is_numeric($id_or_email)) { |
|
69 | 69 | $id = (int) $id_or_email; |
70 | - $user = get_userdata( $id ); |
|
71 | - if ( $user ) { |
|
70 | + $user = get_userdata($id); |
|
71 | + if ($user) { |
|
72 | 72 | $email = $user->user_email; |
73 | 73 | } |
74 | - } elseif ( is_object( $id_or_email ) ) { |
|
74 | + } elseif (is_object($id_or_email)) { |
|
75 | 75 | // No avatar for pingbacks or trackbacks |
76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
81 | + if ( ! empty($id_or_email->user_id)) { |
|
82 | 82 | $id = (int) $id_or_email->user_id; |
83 | - $user = get_userdata( $id ); |
|
84 | - if ( $user ) { |
|
83 | + $user = get_userdata($id); |
|
84 | + if ($user) { |
|
85 | 85 | $email = $user->user_email; |
86 | 86 | } |
87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
88 | 88 | $email = $id_or_email->comment_author_email; |
89 | 89 | } |
90 | 90 | } else { |
91 | 91 | $email = $id_or_email; |
92 | 92 | } |
93 | 93 | |
94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
94 | + $hashkey = md5(strtolower(trim($email))); |
|
95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
96 | 96 | |
97 | - $data = wp_cache_get( $hashkey ); |
|
98 | - if ( false === $data ) { |
|
99 | - $response = wp_remote_head( $uri ); |
|
100 | - if ( is_wp_error( $response ) ) { |
|
97 | + $data = wp_cache_get($hashkey); |
|
98 | + if (false === $data) { |
|
99 | + $response = wp_remote_head($uri); |
|
100 | + if (is_wp_error($response)) { |
|
101 | 101 | $data = 'not200'; |
102 | 102 | } else { |
103 | 103 | $data = $response['response']['code']; |
104 | 104 | } |
105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
106 | 106 | |
107 | 107 | } |
108 | - if ( $data == '200' ) { |
|
108 | + if ($data == '200') { |
|
109 | 109 | return true; |
110 | 110 | } else { |
111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array IDs if logs, false otherwise |
124 | 124 | */ |
125 | - public function get_log_ids( $form_id = '' ) { |
|
125 | + public function get_log_ids($form_id = '') { |
|
126 | 126 | |
127 | 127 | // get Give_Logging class |
128 | 128 | global $give_logs; |
129 | 129 | |
130 | 130 | // get log for this form |
131 | - $logs = $give_logs->get_logs( $form_id ); |
|
131 | + $logs = $give_logs->get_logs($form_id); |
|
132 | 132 | |
133 | - if ( $logs ) { |
|
133 | + if ($logs) { |
|
134 | 134 | $log_ids = array(); |
135 | 135 | |
136 | 136 | // make an array with all the donor IDs |
137 | - foreach ( $logs as $log ) { |
|
137 | + foreach ($logs as $log) { |
|
138 | 138 | $log_ids[] = $log->ID; |
139 | 139 | } |
140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | - public function get_payment_ids( $form_id = '' ) { |
|
158 | + public function get_payment_ids($form_id = '') { |
|
159 | 159 | |
160 | 160 | $give_options = give_get_settings(); |
161 | 161 | |
162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
162 | + $log_ids = $this->get_log_ids($form_id); |
|
163 | 163 | |
164 | - if ( $log_ids ) { |
|
164 | + if ($log_ids) { |
|
165 | 165 | |
166 | 166 | $payment_ids = array(); |
167 | 167 | |
168 | - foreach ( $log_ids as $id ) { |
|
168 | + foreach ($log_ids as $id) { |
|
169 | 169 | // get the payment ID for each corresponding log ID |
170 | - $payment_ids[] = give_get_meta( $id, '_give_log_payment_id', true ); |
|
170 | + $payment_ids[] = give_get_meta($id, '_give_log_payment_id', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
174 | 174 | $unique_emails = array(); |
175 | 175 | |
176 | - foreach ( $payment_ids as $key => $id ) { |
|
176 | + foreach ($payment_ids as $key => $id) { |
|
177 | 177 | |
178 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
178 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
179 | 179 | |
180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
181 | + if ( ! $this->validate_gravatar($email)) { |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - $unique_emails[ $id ] = give_get_meta( $id, '_give_payment_user_email', true ); |
|
186 | + $unique_emails[$id] = give_get_meta($id, '_give_payment_user_email', true); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $unique_ids = array(); |
191 | 191 | |
192 | 192 | // strip duplicate emails |
193 | - $unique_emails = array_unique( $unique_emails ); |
|
193 | + $unique_emails = array_unique($unique_emails); |
|
194 | 194 | |
195 | 195 | // convert the unique IDs back into simple array |
196 | - foreach ( $unique_emails as $id => $email ) { |
|
196 | + foreach ($unique_emails as $id => $email) { |
|
197 | 197 | $unique_ids[] = $id; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // randomize the payment IDs if enabled |
201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
202 | - shuffle( $unique_ids ); |
|
201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
202 | + shuffle($unique_ids); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
223 | + public function gravatars($form_id = false, $title = '') { |
|
224 | 224 | |
225 | 225 | // unique $payment_ids |
226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
227 | 227 | |
228 | 228 | $give_options = give_get_settings(); |
229 | 229 | |
230 | 230 | // return if no ID |
231 | - if ( ! $form_id ) { |
|
231 | + if ( ! $form_id) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | 235 | // minimum amount of donations before showing gravatars |
236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | } |
@@ -246,28 +246,28 @@ discard block |
||
246 | 246 | echo '<div id="give-purchase-gravatars">'; |
247 | 247 | |
248 | 248 | |
249 | - if ( isset ( $title ) ) { |
|
249 | + if (isset ($title)) { |
|
250 | 250 | |
251 | - if ( $title ) { |
|
252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
251 | + if ($title) { |
|
252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | } |
258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
259 | 259 | $i = 0; |
260 | 260 | |
261 | - if ( $payment_ids ) { |
|
262 | - foreach ( $payment_ids as $id ) { |
|
261 | + if ($payment_ids) { |
|
262 | + foreach ($payment_ids as $id) { |
|
263 | 263 | |
264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // get the payment meta |
270 | - $payment_meta = give_get_meta( $id, '_give_payment_meta', true ); |
|
270 | + $payment_meta = give_get_meta($id, '_give_payment_meta', true); |
|
271 | 271 | |
272 | 272 | $user_info = $payment_meta['user_info']; |
273 | 273 | |
@@ -275,21 +275,21 @@ discard block |
||
275 | 275 | $name = $user_info['first_name']; |
276 | 276 | |
277 | 277 | // get donor's email |
278 | - $email = give_get_meta( $id, '_give_payment_user_email', true ); |
|
278 | + $email = give_get_meta($id, '_give_payment_user_email', true); |
|
279 | 279 | |
280 | 280 | // set gravatar size and provide filter |
281 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
281 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
282 | 282 | |
283 | 283 | // default image |
284 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
284 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
285 | 285 | |
286 | 286 | // assemble output |
287 | 287 | $output .= '<li>'; |
288 | 288 | |
289 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
289 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
290 | 290 | $output .= '</li>'; |
291 | 291 | |
292 | - $i ++; |
|
292 | + $i++; |
|
293 | 293 | |
294 | 294 | } // end foreach |
295 | 295 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | echo '</ul>'; |
299 | 299 | echo '</div>'; |
300 | 300 | |
301 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
301 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function register_widget() { |
313 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
313 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public function shortcode( $atts, $content = null ) { |
|
327 | + public function shortcode($atts, $content = null) { |
|
328 | 328 | |
329 | - $atts = shortcode_atts( array( |
|
329 | + $atts = shortcode_atts(array( |
|
330 | 330 | 'id' => '', |
331 | 331 | 'title' => '' |
332 | - ), $atts, 'give_donors_gravatars' ); |
|
332 | + ), $atts, 'give_donors_gravatars'); |
|
333 | 333 | |
334 | 334 | // if no ID is passed on single give_forms pages, get the correct ID |
335 | - if ( is_singular( 'give_forms' ) ) { |
|
335 | + if (is_singular('give_forms')) { |
|
336 | 336 | $id = get_the_ID(); |
337 | 337 | } |
338 | 338 | |
339 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
339 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
340 | 340 | |
341 | 341 | return $content; |
342 | 342 | |
@@ -352,56 +352,56 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return array Gravatar settings. |
354 | 354 | */ |
355 | - public function settings( $settings ) { |
|
355 | + public function settings($settings) { |
|
356 | 356 | |
357 | 357 | $give_gravatar_settings = array( |
358 | 358 | array( |
359 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
359 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
360 | 360 | 'desc' => '<hr>', |
361 | 361 | 'id' => 'give_title', |
362 | 362 | 'type' => 'give_title' |
363 | 363 | ), |
364 | 364 | array( |
365 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
366 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
365 | + 'name' => esc_html__('Heading', 'give'), |
|
366 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
367 | 367 | 'type' => 'text', |
368 | 368 | 'id' => 'give_donors_gravatars_heading' |
369 | 369 | ), |
370 | 370 | array( |
371 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
372 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
371 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
372 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
373 | 373 | 'type' => 'text_small', |
374 | 374 | 'id' => 'give_donors_gravatars_gravatar_size', |
375 | 375 | 'default' => '64' |
376 | 376 | ), |
377 | 377 | array( |
378 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
379 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
378 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
379 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
380 | 380 | 'type' => 'text_small', |
381 | 381 | 'id' => 'give_donors_gravatars_min_purchases_required', |
382 | 382 | ), |
383 | 383 | array( |
384 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
385 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
384 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
385 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
386 | 386 | 'type' => 'text', |
387 | 387 | 'id' => 'give_donors_gravatars_maximum_number', |
388 | 388 | 'default' => '20', |
389 | 389 | ), |
390 | 390 | array( |
391 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
392 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
391 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
392 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
393 | 393 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
394 | 394 | 'type' => 'checkbox', |
395 | 395 | ), |
396 | 396 | array( |
397 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
398 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
397 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
398 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
399 | 399 | 'id' => 'give_donors_gravatars_random_gravatars', |
400 | 400 | 'type' => 'checkbox', |
401 | 401 | ), |
402 | 402 | ); |
403 | 403 | |
404 | - return array_merge( $settings, $give_gravatar_settings ); |
|
404 | + return array_merge($settings, $give_gravatar_settings); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // widget settings |
428 | 428 | $widget_ops = array( |
429 | 429 | 'classname' => 'give-donors-gravatars', |
430 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
430 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
431 | 431 | ); |
432 | 432 | |
433 | 433 | // widget control settings |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | // create the widget |
441 | 441 | parent::__construct( |
442 | 442 | 'give_donors_gravatars_widget', |
443 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
443 | + esc_html__('Give Donors Gravatars', 'give'), |
|
444 | 444 | $widget_ops, |
445 | 445 | $control_ops |
446 | 446 | ); |
@@ -460,29 +460,29 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return void |
462 | 462 | */ |
463 | - public function widget( $args, $instance ) { |
|
463 | + public function widget($args, $instance) { |
|
464 | 464 | |
465 | 465 | //@TODO: Don't extract it!!! |
466 | - extract( $args ); |
|
466 | + extract($args); |
|
467 | 467 | |
468 | - if ( ! is_singular( 'give_forms' ) ) { |
|
468 | + if ( ! is_singular('give_forms')) { |
|
469 | 469 | return; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // Variables from widget settings |
473 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
473 | + $title = apply_filters('widget_title', $instance['title']); |
|
474 | 474 | |
475 | 475 | // Used by themes. Opens the widget |
476 | 476 | echo $before_widget; |
477 | 477 | |
478 | 478 | // Display the widget title |
479 | - if ( $title ) { |
|
480 | - echo $before_title . $title . $after_title; |
|
479 | + if ($title) { |
|
480 | + echo $before_title.$title.$after_title; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $gravatars = new Give_Donors_Gravatars(); |
484 | 484 | |
485 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
485 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
486 | 486 | |
487 | 487 | // Used by themes. Closes the widget |
488 | 488 | echo $after_widget; |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array Updated settings to save. |
504 | 504 | */ |
505 | - public function update( $new_instance, $old_instance ) { |
|
505 | + public function update($new_instance, $old_instance) { |
|
506 | 506 | |
507 | 507 | $instance = $old_instance; |
508 | 508 | |
509 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
509 | + $instance['title'] = strip_tags($new_instance['title']); |
|
510 | 510 | |
511 | 511 | return $instance; |
512 | 512 | |
@@ -524,19 +524,19 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @return void |
526 | 526 | */ |
527 | - public function form( $instance ) { |
|
527 | + public function form($instance) { |
|
528 | 528 | |
529 | 529 | // Set up some default widget settings. |
530 | 530 | $defaults = array( |
531 | 531 | 'title' => '', |
532 | 532 | ); |
533 | 533 | |
534 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
534 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
535 | 535 | |
536 | 536 | <!-- Title --> |
537 | 537 | <p> |
538 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
539 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
538 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
539 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
540 | 540 | </p> |
541 | 541 | |
542 | 542 | <?php |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function add_roles() { |
52 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
52 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
53 | 53 | 'read' => true, |
54 | 54 | 'edit_posts' => true, |
55 | 55 | 'delete_posts' => true, |
@@ -78,25 +78,25 @@ discard block |
||
78 | 78 | 'publish_posts' => true, |
79 | 79 | 'read_private_pages' => true, |
80 | 80 | 'read_private_posts' => true, |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | |
83 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
83 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
84 | 84 | 'read' => true, |
85 | 85 | 'edit_posts' => false, |
86 | 86 | 'delete_posts' => false |
87 | - ) ); |
|
87 | + )); |
|
88 | 88 | |
89 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
89 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
90 | 90 | 'read' => true, |
91 | 91 | 'edit_posts' => true, |
92 | 92 | 'edit_pages' => true, |
93 | 93 | 'upload_files' => true, |
94 | 94 | 'delete_posts' => false, |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
97 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
98 | 98 | 'read' => true, |
99 | - ) ); |
|
99 | + )); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -115,38 +115,38 @@ discard block |
||
115 | 115 | public function add_caps() { |
116 | 116 | global $wp_roles; |
117 | 117 | |
118 | - if ( class_exists( 'WP_Roles' ) ) { |
|
119 | - if ( ! isset( $wp_roles ) ) { |
|
118 | + if (class_exists('WP_Roles')) { |
|
119 | + if ( ! isset($wp_roles)) { |
|
120 | 120 | $wp_roles = new WP_Roles(); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - if ( is_object( $wp_roles ) ) { |
|
125 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
126 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
127 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
124 | + if (is_object($wp_roles)) { |
|
125 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
126 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
127 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
129 | 129 | |
130 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
131 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
132 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
133 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
130 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
131 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
132 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
133 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
134 | 134 | |
135 | 135 | // Add the main post type capabilities. |
136 | 136 | $capabilities = $this->get_core_caps(); |
137 | - foreach ( $capabilities as $cap_group ) { |
|
138 | - foreach ( $cap_group as $cap ) { |
|
139 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
140 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
141 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
137 | + foreach ($capabilities as $cap_group) { |
|
138 | + foreach ($cap_group as $cap) { |
|
139 | + $wp_roles->add_cap('administrator', $cap); |
|
140 | + $wp_roles->add_cap('give_manager', $cap); |
|
141 | + $wp_roles->add_cap('give_worker', $cap); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
146 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
147 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
148 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
149 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
145 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
146 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
147 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
148 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
149 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | } |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | public function get_core_caps() { |
165 | 165 | $capabilities = array(); |
166 | 166 | |
167 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
167 | + $capability_types = array('give_form', 'give_payment'); |
|
168 | 168 | |
169 | - foreach ( $capability_types as $capability_type ) { |
|
170 | - $capabilities[ $capability_type ] = array( |
|
169 | + foreach ($capability_types as $capability_type) { |
|
170 | + $capabilities[$capability_type] = array( |
|
171 | 171 | // Post type. |
172 | 172 | "edit_{$capability_type}", |
173 | 173 | "read_{$capability_type}", |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return array $caps Meta capabilities. |
215 | 215 | */ |
216 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
216 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
217 | 217 | |
218 | - switch ( $cap ) { |
|
218 | + switch ($cap) { |
|
219 | 219 | |
220 | 220 | case 'view_give_form_stats' : |
221 | 221 | |
222 | - if ( empty( $args[0] ) ) { |
|
222 | + if (empty($args[0])) { |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
226 | - $form = get_post( $args[0] ); |
|
227 | - if ( empty( $form ) ) { |
|
226 | + $form = get_post($args[0]); |
|
227 | + if (empty($form)) { |
|
228 | 228 | break; |
229 | 229 | } |
230 | 230 | |
231 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
231 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
232 | 232 | $caps = array(); |
233 | 233 | } |
234 | 234 | |
@@ -255,41 +255,41 @@ discard block |
||
255 | 255 | |
256 | 256 | global $wp_roles; |
257 | 257 | |
258 | - if ( class_exists( 'WP_Roles' ) ) { |
|
259 | - if ( ! isset( $wp_roles ) ) { |
|
258 | + if (class_exists('WP_Roles')) { |
|
259 | + if ( ! isset($wp_roles)) { |
|
260 | 260 | $wp_roles = new WP_Roles(); |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( is_object( $wp_roles ) ) { |
|
264 | + if (is_object($wp_roles)) { |
|
265 | 265 | // Give Manager Capabilities. |
266 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
267 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
268 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
269 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
266 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
267 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
268 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
269 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
270 | 270 | |
271 | 271 | // Site Administrator Capabilities. |
272 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
273 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
274 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
275 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
272 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
273 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
274 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
275 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
276 | 276 | |
277 | 277 | // Remove the Main Post Type Capabilities. |
278 | 278 | $capabilities = $this->get_core_caps(); |
279 | 279 | |
280 | - foreach ( $capabilities as $cap_group ) { |
|
281 | - foreach ( $cap_group as $cap ) { |
|
282 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
283 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
284 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
280 | + foreach ($capabilities as $cap_group) { |
|
281 | + foreach ($cap_group as $cap) { |
|
282 | + $wp_roles->remove_cap('give_manager', $cap); |
|
283 | + $wp_roles->remove_cap('administrator', $cap); |
|
284 | + $wp_roles->remove_cap('give_worker', $cap); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | 288 | /** Give Accountant Capabilities */ |
289 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
290 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
291 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
292 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
289 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
290 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
291 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
292 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | } |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /* @var WPDB $wpdb */ |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
36 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
37 | 37 | $this->primary_key = 'meta_id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
73 | 73 | */ |
74 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
75 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
76 | - if ( false === $donor_id ) { |
|
74 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
75 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
76 | + if (false === $donor_id) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | |
80 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
80 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool False for failure. True for success. |
97 | 97 | */ |
98 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
99 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
100 | - if ( false === $donor_id ) { |
|
98 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
99 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
100 | + if (false === $donor_id) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
104 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool False on failure, true if success. |
126 | 126 | */ |
127 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
128 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
129 | - if ( false === $donor_id ) { |
|
127 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
128 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
129 | + if (false === $donor_id) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
133 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return bool False for failure. True for success. |
153 | 153 | */ |
154 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
155 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
154 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
155 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return bool False for failure. True for success. |
167 | 167 | */ |
168 | - public function delete_all_meta( $donor_id = 0 ) { |
|
168 | + public function delete_all_meta($donor_id = 0) { |
|
169 | 169 | global $wpdb; |
170 | - $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
170 | + $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function create_table() { |
182 | 182 | |
183 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
183 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
184 | 184 | |
185 | 185 | $sql = "CREATE TABLE {$this->table_name} ( |
186 | 186 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | KEY meta_key (meta_key) |
193 | 193 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
194 | 194 | |
195 | - dbDelta( $sql ); |
|
195 | + dbDelta($sql); |
|
196 | 196 | |
197 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
197 | + update_option($this->table_name.'_db_version', $this->version); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -207,23 +207,23 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
209 | 209 | */ |
210 | - private function sanitize_donor_id( $donor_id ) { |
|
211 | - if ( ! is_numeric( $donor_id ) ) { |
|
210 | + private function sanitize_donor_id($donor_id) { |
|
211 | + if ( ! is_numeric($donor_id)) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | 215 | $donor_id = (int) $donor_id; |
216 | 216 | |
217 | 217 | // We were given a non positive number. |
218 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
218 | + if (absint($donor_id) !== $donor_id) { |
|
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
222 | - if ( empty( $donor_id ) ) { |
|
222 | + if (empty($donor_id)) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - return absint( $donor_id ); |
|
226 | + return absint($donor_id); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 |