@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @since 1.0 |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
|
39 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
40 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
38 | + add_action('admin_menu', array($this, 'admin_menus')); |
|
39 | + add_action('admin_head', array($this, 'admin_head')); |
|
40 | + add_action('admin_init', array($this, 'welcome')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -49,45 +49,45 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function admin_menus() { |
52 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
52 | + list($display_version) = explode('-', GIVE_VERSION); |
|
53 | 53 | |
54 | 54 | // About Page |
55 | 55 | add_dashboard_page( |
56 | 56 | /* translators: %s: Give version */ |
57 | - sprintf( esc_html__( 'Welcome to Give %s', 'give' ), $display_version ), |
|
58 | - esc_html__( 'Welcome to Give', 'give' ), |
|
57 | + sprintf(esc_html__('Welcome to Give %s', 'give'), $display_version), |
|
58 | + esc_html__('Welcome to Give', 'give'), |
|
59 | 59 | $this->minimum_capability, |
60 | 60 | 'give-about', |
61 | - array( $this, 'about_screen' ) |
|
61 | + array($this, 'about_screen') |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | // Changelog Page |
65 | 65 | add_dashboard_page( |
66 | - esc_html__( 'Give Changelog', 'give' ), |
|
67 | - esc_html__( 'Give Changelog', 'give' ), |
|
66 | + esc_html__('Give Changelog', 'give'), |
|
67 | + esc_html__('Give Changelog', 'give'), |
|
68 | 68 | $this->minimum_capability, |
69 | 69 | 'give-changelog', |
70 | - array( $this, 'changelog_screen' ) |
|
70 | + array($this, 'changelog_screen') |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | // Getting Started Page |
74 | 74 | add_dashboard_page( |
75 | 75 | /* translators: %s: Give version */ |
76 | - sprintf( esc_html__( 'Give %s - Getting Started Guide', 'give' ), $display_version ), |
|
77 | - esc_html__( 'Getting started with Give', 'give' ), |
|
76 | + sprintf(esc_html__('Give %s - Getting Started Guide', 'give'), $display_version), |
|
77 | + esc_html__('Getting started with Give', 'give'), |
|
78 | 78 | $this->minimum_capability, |
79 | 79 | 'give-getting-started', |
80 | - array( $this, 'getting_started_screen' ) |
|
80 | + array($this, 'getting_started_screen') |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Credits Page |
84 | 84 | add_dashboard_page( |
85 | 85 | /* translators: %s: Give version */ |
86 | - sprintf( esc_html__( 'Give %s - Credits', 'give' ), $display_version ), |
|
87 | - esc_html__( 'The people that build Give', 'give' ), |
|
86 | + sprintf(esc_html__('Give %s - Credits', 'give'), $display_version), |
|
87 | + esc_html__('The people that build Give', 'give'), |
|
88 | 88 | $this->minimum_capability, |
89 | 89 | 'give-credits', |
90 | - array( $this, 'credits_screen' ) |
|
90 | + array($this, 'credits_screen') |
|
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function admin_head() { |
102 | 102 | |
103 | - remove_submenu_page( 'index.php', 'give-about' ); |
|
104 | - remove_submenu_page( 'index.php', 'give-changelog' ); |
|
105 | - remove_submenu_page( 'index.php', 'give-getting-started' ); |
|
106 | - remove_submenu_page( 'index.php', 'give-credits' ); |
|
103 | + remove_submenu_page('index.php', 'give-about'); |
|
104 | + remove_submenu_page('index.php', 'give-changelog'); |
|
105 | + remove_submenu_page('index.php', 'give-getting-started'); |
|
106 | + remove_submenu_page('index.php', 'give-credits'); |
|
107 | 107 | |
108 | 108 | // Badge for welcome page |
109 | - $badge_url = GIVE_PLUGIN_URL . 'assets/images/give-badge.png'; |
|
109 | + $badge_url = GIVE_PLUGIN_URL.'assets/images/give-badge.png'; |
|
110 | 110 | |
111 | 111 | ?> |
112 | 112 | <style type="text/css" media="screen"> |
@@ -186,20 +186,20 @@ discard block |
||
186 | 186 | * @return void |
187 | 187 | */ |
188 | 188 | public function tabs() { |
189 | - $selected = isset( $_GET['page'] ) ? $_GET['page'] : 'give-about'; |
|
189 | + $selected = isset($_GET['page']) ? $_GET['page'] : 'give-about'; |
|
190 | 190 | ?> |
191 | 191 | <h2 class="nav-tab-wrapper"> |
192 | - <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-about' ), 'index.php' ) ) ); ?>"> |
|
193 | - <?php esc_html_e( 'About Give', 'give' ); ?> |
|
192 | + <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-about'), 'index.php'))); ?>"> |
|
193 | + <?php esc_html_e('About Give', 'give'); ?> |
|
194 | 194 | </a> |
195 | - <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-getting-started' ), 'index.php' ) ) ); ?>"> |
|
196 | - <?php esc_html_e( 'Getting Started', 'give' ); ?> |
|
195 | + <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-getting-started'), 'index.php'))); ?>"> |
|
196 | + <?php esc_html_e('Getting Started', 'give'); ?> |
|
197 | 197 | </a> |
198 | - <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-credits' ), 'index.php' ) ) ); ?>"> |
|
199 | - <?php esc_html_e( 'Credits', 'give' ); ?> |
|
198 | + <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-credits'), 'index.php'))); ?>"> |
|
199 | + <?php esc_html_e('Credits', 'give'); ?> |
|
200 | 200 | </a> |
201 | - <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-addons' ) ); ?>"> |
|
202 | - <?php esc_html_e( 'Add-ons', 'give' ); ?> |
|
201 | + <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url('edit.php?post_type=give_forms&page=give-addons')); ?>"> |
|
202 | + <?php esc_html_e('Add-ons', 'give'); ?> |
|
203 | 203 | </a> |
204 | 204 | </h2> |
205 | 205 | <?php |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @return void |
214 | 214 | */ |
215 | 215 | public function about_screen() { |
216 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
216 | + list($display_version) = explode('-', GIVE_VERSION); |
|
217 | 217 | ?> |
218 | 218 | <div class="wrap about-wrap"> |
219 | 219 | <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1> |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | <p class="about-text"><?php |
224 | 224 | printf( |
225 | 225 | /* translators: %s: https://givewp.com/documenation/ */ |
226 | - __( 'Thank you for activating or updating to the latest version of Give! If you\'re a first time user, welcome! You\'re well on your way to empowering your cause. We encourage you to check out the <a href="%s" target="_blank">plugin documentation</a> and getting started guide below.', 'give' ), |
|
227 | - esc_url( 'https://givewp.com/documenation/' ) |
|
226 | + __('Thank you for activating or updating to the latest version of Give! If you\'re a first time user, welcome! You\'re well on your way to empowering your cause. We encourage you to check out the <a href="%s" target="_blank">plugin documentation</a> and getting started guide below.', 'give'), |
|
227 | + esc_url('https://givewp.com/documenation/') |
|
228 | 228 | ); |
229 | 229 | ?></p> |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | <div class="give-badge"><?php |
234 | 234 | printf( |
235 | 235 | /* translators: %s: Give version */ |
236 | - esc_html__( 'Version %s', 'give' ), |
|
236 | + esc_html__('Version %s', 'give'), |
|
237 | 237 | $display_version |
238 | 238 | ); |
239 | 239 | ?></div> |
@@ -243,16 +243,16 @@ discard block |
||
243 | 243 | <div class="feature-section clearfix introduction"> |
244 | 244 | |
245 | 245 | <div class="video feature-section-item"> |
246 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-form-mockup.png' ?>" alt="<?php esc_attr_e( 'A Give donation form', 'give' ); ?>"> |
|
246 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/give-form-mockup.png' ?>" alt="<?php esc_attr_e('A Give donation form', 'give'); ?>"> |
|
247 | 247 | </div> |
248 | 248 | |
249 | 249 | <div class="content feature-section-item last-feature"> |
250 | 250 | |
251 | - <h3><?php esc_html_e( 'Give - Democratizing Generosity', 'give' ); ?></h3> |
|
251 | + <h3><?php esc_html_e('Give - Democratizing Generosity', 'give'); ?></h3> |
|
252 | 252 | |
253 | - <p><?php esc_html_e( 'Give empowers you to easily accept donations and setup fundraising campaigns, directly within WordPress. We created Give to provide a better donation experience for you and your users. Robust, flexible, and intuitive, the plugin is built from the ground up to be the goto donation solution for WordPress. Create powerful donation forms, embed them throughout your website, start a campaign, and exceed your fundraising goals with Give. This plugin is actively developed and proudly supported by folks who are dedicated to helping you and your cause.', 'give' ); ?></p> |
|
253 | + <p><?php esc_html_e('Give empowers you to easily accept donations and setup fundraising campaigns, directly within WordPress. We created Give to provide a better donation experience for you and your users. Robust, flexible, and intuitive, the plugin is built from the ground up to be the goto donation solution for WordPress. Create powerful donation forms, embed them throughout your website, start a campaign, and exceed your fundraising goals with Give. This plugin is actively developed and proudly supported by folks who are dedicated to helping you and your cause.', 'give'); ?></p> |
|
254 | 254 | <a href="https://givewp.com" target="_blank" class="button-secondary"> |
255 | - <?php esc_html_e( 'Learn More', 'give' ); ?> |
|
255 | + <?php esc_html_e('Learn More', 'give'); ?> |
|
256 | 256 | <span class="dashicons dashicons-external"></span> |
257 | 257 | </a> |
258 | 258 | |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | <div class="content feature-section-item"> |
267 | 267 | |
268 | - <h3><?php esc_html_e( 'Getting to Know Give', 'give' ); ?></h3> |
|
268 | + <h3><?php esc_html_e('Getting to Know Give', 'give'); ?></h3> |
|
269 | 269 | |
270 | - <p><?php esc_html_e( 'Before you get started with Give we suggest you take a look at the online documentation. There you will find the getting started guide which will help you get up and running quickly. If you have an question, issue or bug with the Core plugin please submit an issue on the Give website. We also welcome your feedback and feature requests. Welcome to Give. We hope you much success with your cause.', 'give' ); ?></p> |
|
270 | + <p><?php esc_html_e('Before you get started with Give we suggest you take a look at the online documentation. There you will find the getting started guide which will help you get up and running quickly. If you have an question, issue or bug with the Core plugin please submit an issue on the Give website. We also welcome your feedback and feature requests. Welcome to Give. We hope you much success with your cause.', 'give'); ?></p> |
|
271 | 271 | <a href="https://givewp.com/documentation" target="_blank" class="button-secondary"> |
272 | - <?php esc_html_e( 'View Documentation', 'give' ); ?> |
|
272 | + <?php esc_html_e('View Documentation', 'give'); ?> |
|
273 | 273 | <span class="dashicons dashicons-external"></span> |
274 | 274 | </a> |
275 | 275 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | <div class="content feature-section-item last-feature"> |
279 | 279 | |
280 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-logo-photo-mashup.png' ?>" alt="<?php esc_attr_e( 'Give', 'give' ); ?>"> |
|
280 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/give-logo-photo-mashup.png' ?>" alt="<?php esc_attr_e('Give', 'give'); ?>"> |
|
281 | 281 | |
282 | 282 | </div> |
283 | 283 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return void |
298 | 298 | */ |
299 | 299 | public function changelog_screen() { |
300 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
300 | + list($display_version) = explode('-', GIVE_VERSION); |
|
301 | 301 | ?> |
302 | 302 | <div class="wrap about-wrap"> |
303 | 303 | <h1><?php echo get_admin_page_title(); ?></h1> |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | <p class="about-text"><?php |
306 | 306 | printf( |
307 | 307 | /* translators: %s: Give version */ |
308 | - esc_html__( 'Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give' ), |
|
308 | + esc_html__('Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give'), |
|
309 | 309 | $display_version |
310 | 310 | ); |
311 | 311 | ?></p> |
312 | 312 | <div class="give-badge"><?php |
313 | 313 | printf( |
314 | 314 | /* translators: %s: Give version */ |
315 | - esc_html__( 'Version %s', 'give' ), |
|
315 | + esc_html__('Version %s', 'give'), |
|
316 | 316 | $display_version |
317 | 317 | ); |
318 | 318 | ?></div> |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | <?php $this->tabs(); ?> |
321 | 321 | |
322 | 322 | <div class="changelog"> |
323 | - <h3><?php esc_html_e( 'Full Changelog', 'give' ); ?></h3> |
|
323 | + <h3><?php esc_html_e('Full Changelog', 'give'); ?></h3> |
|
324 | 324 | |
325 | 325 | <div class="feature-section"> |
326 | 326 | <?php echo $this->parse_readme(); ?> |
@@ -328,10 +328,10 @@ discard block |
||
328 | 328 | </div> |
329 | 329 | |
330 | 330 | <div class="return-to-dashboard"> |
331 | - <a href="<?php echo esc_url( admin_url( add_query_arg( array( |
|
331 | + <a href="<?php echo esc_url(admin_url(add_query_arg(array( |
|
332 | 332 | 'post_type' => 'give_forms', |
333 | 333 | 'page' => 'give-settings' |
334 | - ), 'edit.php' ) ) ); ?>"><?php esc_html_e( 'Give Settings', 'give' ); ?></a> |
|
334 | + ), 'edit.php'))); ?>"><?php esc_html_e('Give Settings', 'give'); ?></a> |
|
335 | 335 | </div> |
336 | 336 | </div> |
337 | 337 | <?php |
@@ -345,37 +345,37 @@ discard block |
||
345 | 345 | * @return void |
346 | 346 | */ |
347 | 347 | public function getting_started_screen() { |
348 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
348 | + list($display_version) = explode('-', GIVE_VERSION); |
|
349 | 349 | ?> |
350 | 350 | <div class="wrap about-wrap get-started"> |
351 | 351 | <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1> |
352 | 352 | |
353 | 353 | <?php give_social_media_elements() ?> |
354 | 354 | |
355 | - <p class="about-text"><?php esc_html_e( 'Welcome to the getting started guide.', 'give' ); ?></p> |
|
355 | + <p class="about-text"><?php esc_html_e('Welcome to the getting started guide.', 'give'); ?></p> |
|
356 | 356 | |
357 | 357 | <?php give_get_newsletter(); ?> |
358 | 358 | |
359 | 359 | <div class="give-badge"><?php |
360 | 360 | printf( |
361 | 361 | /* translators: %s: Give version */ |
362 | - esc_html__( 'Version %s', 'give' ), |
|
362 | + esc_html__('Version %s', 'give'), |
|
363 | 363 | $display_version |
364 | 364 | ); |
365 | 365 | ?></div> |
366 | 366 | |
367 | 367 | <?php $this->tabs(); ?> |
368 | 368 | |
369 | - <p class="about-text"><?php printf( esc_html__( 'Getting started with Give is easy! We put together this quick start guide to help first time users of the plugin. Our goal is to get you up and running in no time. Let\'s begin!', 'give' ), $display_version ); ?></p> |
|
369 | + <p class="about-text"><?php printf(esc_html__('Getting started with Give is easy! We put together this quick start guide to help first time users of the plugin. Our goal is to get you up and running in no time. Let\'s begin!', 'give'), $display_version); ?></p> |
|
370 | 370 | |
371 | 371 | <div class="feature-section clearfix"> |
372 | 372 | |
373 | 373 | <div class="content feature-section-item"> |
374 | - <h3><?php esc_html_e( 'STEP 1: Create a New Form', 'give' ); ?></h3> |
|
374 | + <h3><?php esc_html_e('STEP 1: Create a New Form', 'give'); ?></h3> |
|
375 | 375 | |
376 | - <p><?php esc_html_e( 'Give is driven by it\'s powerful donation form building features. However, it is much more than just a "donation form". From the "Add Form" page you\'ll be able to choose how and where you want to receive your donations. You will also be able to set the preferred donation amounts.', 'give' ); ?></p> |
|
376 | + <p><?php esc_html_e('Give is driven by it\'s powerful donation form building features. However, it is much more than just a "donation form". From the "Add Form" page you\'ll be able to choose how and where you want to receive your donations. You will also be able to set the preferred donation amounts.', 'give'); ?></p> |
|
377 | 377 | |
378 | - <p><?php esc_html_e( 'All of these features begin by simply going to the menu and choosing "Donations > Add Form".', 'give' ); ?></p> |
|
378 | + <p><?php esc_html_e('All of these features begin by simply going to the menu and choosing "Donations > Add Form".', 'give'); ?></p> |
|
379 | 379 | </div> |
380 | 380 | |
381 | 381 | <div class="content feature-section-item last-feature"> |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | </div> |
393 | 393 | |
394 | 394 | <div class="content feature-section-item last-feature"> |
395 | - <h3><?php esc_html_e( 'STEP 2: Customize Your Donation Forms', 'give' ); ?></h3> |
|
395 | + <h3><?php esc_html_e('STEP 2: Customize Your Donation Forms', 'give'); ?></h3> |
|
396 | 396 | |
397 | - <p><?php esc_html_e( 'Each donation form you create can be customized to receive either a pre-determined set donation amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the donation levels view where you can add as many levels as you\'d like with your own custom names and suggested amounts. As well, you can allow donors to give a custom amount and even set up donation goals.', 'give' ); ?></p> |
|
397 | + <p><?php esc_html_e('Each donation form you create can be customized to receive either a pre-determined set donation amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the donation levels view where you can add as many levels as you\'d like with your own custom names and suggested amounts. As well, you can allow donors to give a custom amount and even set up donation goals.', 'give'); ?></p> |
|
398 | 398 | </div> |
399 | 399 | |
400 | 400 | </div> |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | <div class="feature-section clearfix"> |
404 | 404 | |
405 | 405 | <div class="content feature-section-item add-content"> |
406 | - <h3><?php esc_html_e( 'STEP 3: Add Additional Content', 'give' ); ?></h3> |
|
406 | + <h3><?php esc_html_e('STEP 3: Add Additional Content', 'give'); ?></h3> |
|
407 | 407 | |
408 | - <p><?php esc_html_e( 'Every donation form you create with Give can be used on its own stand-alone page, or it can be inserted into any other page or post throughout your site via a shortcode or widget.', 'give' ); ?></p> |
|
408 | + <p><?php esc_html_e('Every donation form you create with Give can be used on its own stand-alone page, or it can be inserted into any other page or post throughout your site via a shortcode or widget.', 'give'); ?></p> |
|
409 | 409 | |
410 | - <p><?php esc_html_e( 'You can choose these different modes by going to the "Form Content" section. From there, you can choose to add content before or after the donation form on a page, or if you choose "None" perhaps you want to instead use the shortcode. You can find the shortcode in the top right column directly under the Publish/Save button. This feature gives you the most amount of flexibility with controlling your content on your website all within the same page.', 'give' ); ?></p> |
|
410 | + <p><?php esc_html_e('You can choose these different modes by going to the "Form Content" section. From there, you can choose to add content before or after the donation form on a page, or if you choose "None" perhaps you want to instead use the shortcode. You can find the shortcode in the top right column directly under the Publish/Save button. This feature gives you the most amount of flexibility with controlling your content on your website all within the same page.', 'give'); ?></p> |
|
411 | 411 | </div> |
412 | 412 | |
413 | 413 | <div class="content feature-section-item last-feature"> |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | </div> |
425 | 425 | |
426 | 426 | <div class="content feature-section-item last-feature"> |
427 | - <h3><?php esc_html_e( 'STEP 4: Configure Your Display Options', 'give' ); ?></h3> |
|
427 | + <h3><?php esc_html_e('STEP 4: Configure Your Display Options', 'give'); ?></h3> |
|
428 | 428 | |
429 | - <p><?php esc_html_e( 'Lastly, you can present the form in a number of different ways that each create their own unique donor experience. The "Modal" display mode opens the credit card fieldset within a popup window. The "Reveal" mode will slide into place the additional fields. If you\'re looking for a simple button, then "Button" more is the way to go. This allows you to create a customizable "Donate Now" button which will open the donation form upon clicking. There\'s tons of possibilities here, give it a try!', 'give' ); ?></p> |
|
429 | + <p><?php esc_html_e('Lastly, you can present the form in a number of different ways that each create their own unique donor experience. The "Modal" display mode opens the credit card fieldset within a popup window. The "Reveal" mode will slide into place the additional fields. If you\'re looking for a simple button, then "Button" more is the way to go. This allows you to create a customizable "Donate Now" button which will open the donation form upon clicking. There\'s tons of possibilities here, give it a try!', 'give'); ?></p> |
|
430 | 430 | </div> |
431 | 431 | |
432 | 432 | |
@@ -446,23 +446,23 @@ discard block |
||
446 | 446 | * @return void |
447 | 447 | */ |
448 | 448 | public function credits_screen() { |
449 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
449 | + list($display_version) = explode('-', GIVE_VERSION); |
|
450 | 450 | ?> |
451 | 451 | <div class="wrap about-wrap"> |
452 | 452 | <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1> |
453 | 453 | |
454 | 454 | <?php give_social_media_elements() ?> |
455 | 455 | |
456 | - <p class="about-text"><?php esc_html_e( 'Thanks to all those who have contributed code directly or indirectly.', 'give' ); ?></p> |
|
456 | + <p class="about-text"><?php esc_html_e('Thanks to all those who have contributed code directly or indirectly.', 'give'); ?></p> |
|
457 | 457 | |
458 | - <p class="about-text"><?php esc_html_e( 'Welcome to the getting started guide.', 'give' ); ?></p> |
|
458 | + <p class="about-text"><?php esc_html_e('Welcome to the getting started guide.', 'give'); ?></p> |
|
459 | 459 | |
460 | 460 | <?php give_get_newsletter(); ?> |
461 | 461 | |
462 | 462 | <div class="give-badge"><?php |
463 | 463 | printf( |
464 | 464 | /* translators: %s: Give version */ |
465 | - esc_html__( 'Version %s', 'give' ), |
|
465 | + esc_html__('Version %s', 'give'), |
|
466 | 466 | $display_version |
467 | 467 | ); |
468 | 468 | ?></div> |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | <p class="about-description"><?php |
473 | 473 | printf( |
474 | 474 | /* translators: %s: https://github.com/WordImpress/give */ |
475 | - __( 'Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repo</a>.', 'give' ), |
|
476 | - esc_url( 'https://github.com/WordImpress/give' ) |
|
475 | + __('Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repo</a>.', 'give'), |
|
476 | + esc_url('https://github.com/WordImpress/give') |
|
477 | 477 | ); |
478 | 478 | ?></p> |
479 | 479 | |
@@ -490,21 +490,21 @@ discard block |
||
490 | 490 | * @return string $readme HTML formatted readme file |
491 | 491 | */ |
492 | 492 | public function parse_readme() { |
493 | - $file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null; |
|
493 | + $file = file_exists(GIVE_PLUGIN_DIR.'readme.txt') ? GIVE_PLUGIN_DIR.'readme.txt' : null; |
|
494 | 494 | |
495 | - if ( ! $file ) { |
|
496 | - $readme = '<p>' . esc_html__( 'No valid changlog was found.', 'give' ) . '</p>'; |
|
495 | + if ( ! $file) { |
|
496 | + $readme = '<p>'.esc_html__('No valid changlog was found.', 'give').'</p>'; |
|
497 | 497 | } else { |
498 | - $readme = file_get_contents( $file ); |
|
499 | - $readme = nl2br( esc_html( $readme ) ); |
|
500 | - $readme = explode( '== Changelog ==', $readme ); |
|
501 | - $readme = end( $readme ); |
|
502 | - |
|
503 | - $readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme ); |
|
504 | - $readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme ); |
|
505 | - $readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme ); |
|
506 | - $readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme ); |
|
507 | - $readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme ); |
|
498 | + $readme = file_get_contents($file); |
|
499 | + $readme = nl2br(esc_html($readme)); |
|
500 | + $readme = explode('== Changelog ==', $readme); |
|
501 | + $readme = end($readme); |
|
502 | + |
|
503 | + $readme = preg_replace('/`(.*?)`/', '<code>\\1</code>', $readme); |
|
504 | + $readme = preg_replace('/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme); |
|
505 | + $readme = preg_replace('/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme); |
|
506 | + $readme = preg_replace('/= (.*?) =/', '<h4>\\1</h4>', $readme); |
|
507 | + $readme = preg_replace('/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | return $readme; |
@@ -521,24 +521,24 @@ discard block |
||
521 | 521 | public function contributors() { |
522 | 522 | $contributors = $this->get_contributors(); |
523 | 523 | |
524 | - if ( empty( $contributors ) ) { |
|
524 | + if (empty($contributors)) { |
|
525 | 525 | return ''; |
526 | 526 | } |
527 | 527 | |
528 | 528 | $contributor_list = '<ul class="wp-people-group">'; |
529 | 529 | |
530 | - foreach ( $contributors as $contributor ) { |
|
530 | + foreach ($contributors as $contributor) { |
|
531 | 531 | $contributor_list .= '<li class="wp-person">'; |
532 | 532 | $contributor_list .= sprintf( |
533 | 533 | '<a href="%1$s" target="_blank"><img src="%2$s" width="64" height="64" class="gravatar" alt="%3$s" /></a>', |
534 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
535 | - esc_url( $contributor->avatar_url ), |
|
536 | - esc_attr( $contributor->login ) |
|
534 | + esc_url('https://github.com/'.$contributor->login), |
|
535 | + esc_url($contributor->avatar_url), |
|
536 | + esc_attr($contributor->login) |
|
537 | 537 | ); |
538 | 538 | $contributor_list .= sprintf( |
539 | 539 | '<a class="web" target="_blank" href="%1$s">%2$s</a>', |
540 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
541 | - esc_html( $contributor->login ) |
|
540 | + esc_url('https://github.com/'.$contributor->login), |
|
541 | + esc_html($contributor->login) |
|
542 | 542 | ); |
543 | 543 | $contributor_list .= '</li>'; |
544 | 544 | } |
@@ -556,25 +556,25 @@ discard block |
||
556 | 556 | * @return array $contributors List of contributors |
557 | 557 | */ |
558 | 558 | public function get_contributors() { |
559 | - $contributors = Give_Cache::get( 'give_contributors', true ); |
|
559 | + $contributors = Give_Cache::get('give_contributors', true); |
|
560 | 560 | |
561 | - if ( false !== $contributors ) { |
|
561 | + if (false !== $contributors) { |
|
562 | 562 | return $contributors; |
563 | 563 | } |
564 | 564 | |
565 | - $response = wp_remote_get( 'https://api.github.com/repos/WordImpress/Give/contributors', array( 'sslverify' => false ) ); |
|
565 | + $response = wp_remote_get('https://api.github.com/repos/WordImpress/Give/contributors', array('sslverify' => false)); |
|
566 | 566 | |
567 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
567 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
568 | 568 | return array(); |
569 | 569 | } |
570 | 570 | |
571 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
571 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
572 | 572 | |
573 | - if ( ! is_array( $contributors ) ) { |
|
573 | + if ( ! is_array($contributors)) { |
|
574 | 574 | return array(); |
575 | 575 | } |
576 | 576 | |
577 | - Give_Cache::set( 'give_contributors', $contributors, HOUR_IN_SECONDS, true ); |
|
577 | + Give_Cache::set('give_contributors', $contributors, HOUR_IN_SECONDS, true); |
|
578 | 578 | |
579 | 579 | return $contributors; |
580 | 580 | } |
@@ -592,24 +592,24 @@ discard block |
||
592 | 592 | $give_options = give_get_settings(); |
593 | 593 | |
594 | 594 | // Bail if no activation redirect |
595 | - if ( ! Give_Cache::get( '_give_activation_redirect', true ) ) { |
|
595 | + if ( ! Give_Cache::get('_give_activation_redirect', true)) { |
|
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
599 | 599 | // Delete the redirect transient |
600 | - Give_Cache::delete( Give_Cache::get_key( '_give_activation_redirect' ) ); |
|
600 | + Give_Cache::delete(Give_Cache::get_key('_give_activation_redirect')); |
|
601 | 601 | |
602 | 602 | // Bail if activating from network, or bulk |
603 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
603 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
604 | 604 | return; |
605 | 605 | } |
606 | 606 | |
607 | - $upgrade = get_option( 'give_version_upgraded_from' ); |
|
607 | + $upgrade = get_option('give_version_upgraded_from'); |
|
608 | 608 | |
609 | - if ( ! $upgrade ) { // First time install |
|
610 | - wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
|
609 | + if ( ! $upgrade) { // First time install |
|
610 | + wp_safe_redirect(admin_url('index.php?page=give-about')); |
|
611 | 611 | exit; |
612 | - } elseif( ! give_is_setting_enabled( give_get_option( 'welcome' ) ) ) { // Welcome is disabled in settings |
|
612 | + } elseif ( ! give_is_setting_enabled(give_get_option('welcome'))) { // Welcome is disabled in settings |
|
613 | 613 | |
614 | 614 | } else { // Welcome is NOT disabled in settings |
615 | 615 | wp_safe_redirect(admin_url('index.php?page=give-about')); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,53 +24,53 @@ discard block |
||
24 | 24 | function give_hide_subscription_notices() { |
25 | 25 | |
26 | 26 | // Hide subscription notices permanently. |
27 | - if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
27 | + if ( ! empty($_GET['_give_hide_license_notices_permanently'])) { |
|
28 | 28 | $current_user = wp_get_current_user(); |
29 | 29 | |
30 | 30 | // check previously disabled notice ids. |
31 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
31 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
32 | 32 | ? $already_dismiss_notices |
33 | 33 | : array(); |
34 | 34 | |
35 | 35 | // Get notice id. |
36 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
36 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_permanently']); |
|
37 | 37 | |
38 | - if ( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
38 | + if ( ! in_array($notice_id, $already_dismiss_notices)) { |
|
39 | 39 | $already_dismiss_notices[] = $notice_id; |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Store subscription ids. |
43 | - update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
43 | + update_user_meta($current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices); |
|
44 | 44 | |
45 | 45 | // Redirect user. |
46 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
46 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'])); |
|
47 | 47 | exit(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Hide subscription notices shortly. |
51 | - if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
51 | + if ( ! empty($_GET['_give_hide_license_notices_shortly'])) { |
|
52 | 52 | $current_user = wp_get_current_user(); |
53 | 53 | |
54 | 54 | // Get notice id. |
55 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
55 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_shortly']); |
|
56 | 56 | |
57 | 57 | // Transient key name. |
58 | 58 | $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
59 | 59 | |
60 | - if ( Give_Cache::get( $transient_key, true ) ) { |
|
60 | + if (Give_Cache::get($transient_key, true)) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Hide notice for 24 hours. |
65 | - Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
65 | + Give_Cache::set($transient_key, true, DAY_IN_SECONDS, true); |
|
66 | 66 | |
67 | 67 | // Redirect user. |
68 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
68 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'])); |
|
69 | 69 | exit(); |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'admin_init', 'give_hide_subscription_notices' ); |
|
73 | +add_action('admin_init', 'give_hide_subscription_notices'); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Load wp editor by ajax. |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @since 1.8 |
79 | 79 | */ |
80 | 80 | function give_load_wp_editor() { |
81 | - if ( ! isset( $_POST['wp_editor'] ) ) { |
|
81 | + if ( ! isset($_POST['wp_editor'])) { |
|
82 | 82 | die(); |
83 | 83 | } |
84 | 84 | |
85 | - $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
85 | + $wp_editor = json_decode(base64_decode($_POST['wp_editor']), true); |
|
86 | 86 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
87 | 87 | |
88 | - wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
88 | + wp_editor($wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2]); |
|
89 | 89 | |
90 | 90 | die(); |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
93 | +add_action('wp_ajax_give_load_wp_editor', 'give_load_wp_editor'); |
|
94 | 94 | |
95 | 95 | |
96 | 96 | /** |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // Get current page. |
112 | - $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
112 | + $current_page = isset($_GET['page']) ? esc_attr($_GET['page']) : ''; |
|
113 | 113 | |
114 | 114 | // Bailout. |
115 | 115 | if ( |
116 | - empty( $current_page ) |
|
117 | - || empty( $_GET['_wp_http_referer'] ) |
|
118 | - || ! in_array( $current_page, $give_pages ) |
|
116 | + empty($current_page) |
|
117 | + || empty($_GET['_wp_http_referer']) |
|
118 | + || ! in_array($current_page, $give_pages) |
|
119 | 119 | ) { |
120 | 120 | return false; |
121 | 121 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.8 |
127 | 127 | */ |
128 | - $redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
128 | + $redirect = apply_filters("give_validate_{$current_page}", true); |
|
129 | 129 | |
130 | - if ( $redirect ) { |
|
130 | + if ($redirect) { |
|
131 | 131 | // Redirect. |
132 | 132 | wp_redirect( |
133 | 133 | remove_query_arg( |
134 | - array( '_wp_http_referer', '_wpnonce' ), |
|
135 | - wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
134 | + array('_wp_http_referer', '_wpnonce'), |
|
135 | + wp_unslash($_SERVER['REQUEST_URI']) |
|
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | exit; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
142 | +add_action('admin_init', 'give_redirect_to_clean_url_admin_pages'); |
@@ -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 | |
@@ -38,35 +38,35 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
55 | - if ( empty( $form_id ) ) { |
|
55 | + if (empty($form_id)) { |
|
56 | 56 | |
57 | 57 | // Global sale stats |
58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
59 | 59 | |
60 | - if ( is_array( $status ) ) { |
|
60 | + if (is_array($status)) { |
|
61 | 61 | $count = 0; |
62 | - foreach ( $status as $payment_status ) { |
|
62 | + foreach ($status as $payment_status) { |
|
63 | 63 | $count += give_count_payments()->$payment_status; |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $count = give_count_payments()->$status; |
67 | 67 | } |
68 | 68 | |
69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | // Product specific stats |
76 | 76 | global $give_logs; |
77 | 77 | |
78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
79 | 79 | |
80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
81 | 81 | |
82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
103 | 103 | */ |
104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
105 | 105 | |
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - $this->setup_dates( $start_date, $end_date ); |
|
108 | + $this->setup_dates($start_date, $end_date); |
|
109 | 109 | |
110 | 110 | // Make sure start date is valid |
111 | - if ( is_wp_error( $this->start_date ) ) { |
|
111 | + if (is_wp_error($this->start_date)) { |
|
112 | 112 | return $this->start_date; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Make sure end date is valid |
116 | - if ( is_wp_error( $this->end_date ) ) { |
|
116 | + if (is_wp_error($this->end_date)) { |
|
117 | 117 | return $this->end_date; |
118 | 118 | } |
119 | 119 | |
120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
121 | 121 | |
122 | - if ( empty( $form_id ) ) { |
|
122 | + if (empty($form_id)) { |
|
123 | 123 | |
124 | 124 | // Global earning stats |
125 | 125 | $args = array( |
126 | 126 | 'post_type' => 'give_payment', |
127 | 127 | 'nopaging' => true, |
128 | - 'post_status' => array( 'publish' ), |
|
128 | + 'post_status' => array('publish'), |
|
129 | 129 | 'fields' => 'ids', |
130 | 130 | 'update_post_term_cache' => false, |
131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | //Filter by Gateway ID meta_key |
140 | - if ( $gateway_id !== false ) { |
|
140 | + if ($gateway_id !== false) { |
|
141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
142 | 142 | $args['meta_value'] = $gateway_id; |
143 | 143 | } |
144 | 144 | |
145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
146 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
147 | - $earnings = Give_Cache::get( $key ); |
|
145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
146 | + $key = Give_Cache::get_key('give_stats', $args); |
|
147 | + $earnings = Give_Cache::get($key); |
|
148 | 148 | |
149 | - if ( false === $earnings ) { |
|
150 | - $sales = get_posts( $args ); |
|
149 | + if (false === $earnings) { |
|
150 | + $sales = get_posts($args); |
|
151 | 151 | $earnings = 0; |
152 | - if ( $sales ) { |
|
153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
152 | + if ($sales) { |
|
153 | + $sales = implode(',', array_map('intval', $sales)); |
|
154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
155 | 155 | } |
156 | 156 | // Cache the results for one hour |
157 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
157 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | 'give_transient_type' => 'give_earnings', |
175 | 175 | // This is not a valid query arg, but is used for cache keying |
176 | 176 | ); |
177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
178 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
178 | + $key = Give_Cache::get_key('give_stats', $args); |
|
179 | 179 | //Set transient for faster stats |
180 | - $earnings = Give_Cache::get( $key ); |
|
180 | + $earnings = Give_Cache::get($key); |
|
181 | 181 | |
182 | - if ( false === $earnings ) { |
|
182 | + if (false === $earnings) { |
|
183 | 183 | |
184 | 184 | $this->timestamp = false; |
185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
186 | 186 | $earnings = 0; |
187 | 187 | |
188 | - if ( $log_ids ) { |
|
189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
188 | + if ($log_ids) { |
|
189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
191 | 191 | |
192 | - foreach ( $payment_ids as $payment_id ) { |
|
193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
192 | + foreach ($payment_ids as $payment_id) { |
|
193 | + $earnings += give_get_payment_amount($payment_id); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Cache the results for one hour |
199 | - Give_Cache::set( $key, $earnings, 60 * 60 ); |
|
199 | + Give_Cache::set($key, $earnings, 60 * 60); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //remove our filter |
204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
205 | 205 | |
206 | 206 | //return earnings |
207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
207 | + return round($earnings, give_currency_decimal_filter()); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
223 | 223 | */ |
224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
225 | 225 | |
226 | - $this->setup_dates( $start_date, $end_date ); |
|
226 | + $this->setup_dates($start_date, $end_date); |
|
227 | 227 | |
228 | 228 | // Make sure start date is valid |
229 | - if ( is_wp_error( $this->start_date ) ) { |
|
229 | + if (is_wp_error($this->start_date)) { |
|
230 | 230 | return $this->start_date; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Make sure end date is valid |
234 | - if ( is_wp_error( $this->end_date ) ) { |
|
234 | + if (is_wp_error($this->end_date)) { |
|
235 | 235 | return $this->end_date; |
236 | 236 | } |
237 | 237 | |
238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
239 | 239 | |
240 | - if ( empty( $form_id ) ) { |
|
240 | + if (empty($form_id)) { |
|
241 | 241 | |
242 | 242 | // Global earning stats |
243 | 243 | $args = array( |
244 | 244 | 'post_type' => 'give_payment', |
245 | 245 | 'nopaging' => true, |
246 | - 'post_status' => array( 'publish' ), |
|
246 | + 'post_status' => array('publish'), |
|
247 | 247 | 'fields' => 'ids', |
248 | 248 | 'update_post_term_cache' => false, |
249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | ); |
256 | 256 | |
257 | 257 | //Filter by Gateway ID meta_key |
258 | - if ( $gateway_id !== false ) { |
|
258 | + if ($gateway_id !== false) { |
|
259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
260 | 260 | $args['meta_value'] = $gateway_id; |
261 | 261 | } |
262 | 262 | |
263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
264 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
264 | + $key = Give_Cache::get_key('give_stats', $args); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | // This is not a valid query arg, but is used for cache keying |
282 | 282 | ); |
283 | 283 | |
284 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
285 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
284 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
285 | + $key = Give_Cache::get_key('give_stats', $args); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | //remove our filter |
289 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
289 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
290 | 290 | |
291 | 291 | //return earnings |
292 | 292 | return $key; |
@@ -303,16 +303,16 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @return array Best selling forms |
305 | 305 | */ |
306 | - public function get_best_selling( $number = 10 ) { |
|
306 | + public function get_best_selling($number = 10) { |
|
307 | 307 | |
308 | 308 | global $wpdb; |
309 | 309 | |
310 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
310 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
311 | 311 | "SELECT post_id as form_id, max(meta_value) as sales |
312 | 312 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
313 | 313 | GROUP BY meta_value+0 |
314 | 314 | DESC LIMIT %d;", $number |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | |
317 | 317 | return $give_forms; |
318 | 318 | } |
@@ -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,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return array $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility. |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | // Set properties. |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,31 +162,31 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | // Add the donation. |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(), |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array(), |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | // Set date if present. |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | // Handle sequential payments. |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's donation cache. |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | // Save payment. |
192 | 192 | $payment->save(); |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param int $payment_id The payment ID. |
200 | 200 | * @param array $payment_data Arguments passed. |
201 | 201 | */ |
202 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
202 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
203 | 203 | |
204 | 204 | // Return payment ID upon success. |
205 | - if ( ! empty( $payment->ID ) ) { |
|
205 | + if ( ! empty($payment->ID)) { |
|
206 | 206 | return $payment->ID; |
207 | 207 | } |
208 | 208 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return bool|int |
220 | 220 | */ |
221 | -function give_create_payment( $payment_data ) { |
|
221 | +function give_create_payment($payment_data) { |
|
222 | 222 | |
223 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
224 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
223 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
224 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
225 | 225 | |
226 | 226 | // Collect payment data. |
227 | 227 | $insert_payment_data = array( |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param array $insert_payment_data |
247 | 247 | */ |
248 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
248 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
249 | 249 | |
250 | 250 | // Record the pending payment. |
251 | - return give_insert_payment( $insert_payment_data ); |
|
251 | + return give_insert_payment($insert_payment_data); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
264 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
265 | 265 | |
266 | - $payment = new Give_Payment( $payment_id ); |
|
266 | + $payment = new Give_Payment($payment_id); |
|
267 | 267 | $payment->status = $new_status; |
268 | 268 | $updated = $payment->save(); |
269 | 269 | |
@@ -282,38 +282,38 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return void |
284 | 284 | */ |
285 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
285 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
286 | 286 | global $give_logs; |
287 | 287 | |
288 | - $payment = new Give_Payment( $payment_id ); |
|
289 | - $amount = give_get_payment_amount( $payment_id ); |
|
288 | + $payment = new Give_Payment($payment_id); |
|
289 | + $amount = give_get_payment_amount($payment_id); |
|
290 | 290 | $status = $payment->post_status; |
291 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
292 | - $customer = new Give_Customer( $customer_id ); |
|
291 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
292 | + $customer = new Give_Customer($customer_id); |
|
293 | 293 | |
294 | 294 | // Only undo donations that aren't these statuses. |
295 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
295 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
296 | 296 | 'pending', |
297 | 297 | 'cancelled', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
301 | - give_undo_purchase( false, $payment_id ); |
|
300 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
301 | + give_undo_purchase(false, $payment_id); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $status == 'publish' ) { |
|
304 | + if ($status == 'publish') { |
|
305 | 305 | |
306 | 306 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
307 | - give_decrease_total_earnings( $amount ); |
|
307 | + give_decrease_total_earnings($amount); |
|
308 | 308 | |
309 | 309 | // @todo: Refresh only range related stat cache |
310 | 310 | give_delete_donation_stats(); |
311 | 311 | |
312 | - if ( $customer->id && $update_customer ) { |
|
312 | + if ($customer->id && $update_customer) { |
|
313 | 313 | |
314 | 314 | // Decrement the stats for the donor. |
315 | 315 | $customer->decrease_purchase_count(); |
316 | - $customer->decrease_value( $amount ); |
|
316 | + $customer->decrease_value($amount); |
|
317 | 317 | |
318 | 318 | } |
319 | 319 | } |
@@ -325,17 +325,17 @@ discard block |
||
325 | 325 | * |
326 | 326 | * @param int $payment_id Payment ID. |
327 | 327 | */ |
328 | - do_action( 'give_payment_delete', $payment_id ); |
|
328 | + do_action('give_payment_delete', $payment_id); |
|
329 | 329 | |
330 | - if ( $customer->id && $update_customer ) { |
|
330 | + if ($customer->id && $update_customer) { |
|
331 | 331 | |
332 | 332 | // Remove the payment ID from the donor. |
333 | - $customer->remove_payment( $payment_id ); |
|
333 | + $customer->remove_payment($payment_id); |
|
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | 337 | // Remove the payment. |
338 | - wp_delete_post( $payment_id, true ); |
|
338 | + wp_delete_post($payment_id, true); |
|
339 | 339 | |
340 | 340 | // Remove related sale log entries. |
341 | 341 | $give_logs->delete_logs( |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * |
357 | 357 | * @param int $payment_id Payment ID. |
358 | 358 | */ |
359 | - do_action( 'give_payment_deleted', $payment_id ); |
|
359 | + do_action('give_payment_deleted', $payment_id); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return void |
374 | 374 | */ |
375 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
375 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
376 | 376 | |
377 | - if ( ! empty( $form_id ) ) { |
|
377 | + if ( ! empty($form_id)) { |
|
378 | 378 | $form_id = false; |
379 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
379 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
380 | 380 | } |
381 | 381 | |
382 | - $payment = new Give_Payment( $payment_id ); |
|
382 | + $payment = new Give_Payment($payment_id); |
|
383 | 383 | |
384 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
385 | - if ( true === $maybe_decrease_earnings ) { |
|
384 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
385 | + if (true === $maybe_decrease_earnings) { |
|
386 | 386 | // Decrease earnings. |
387 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
387 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
388 | 388 | } |
389 | 389 | |
390 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
391 | - if ( true === $maybe_decrease_sales ) { |
|
390 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
391 | + if (true === $maybe_decrease_sales) { |
|
392 | 392 | // Decrease donation count. |
393 | - give_decrease_purchase_count( $payment->form_id ); |
|
393 | + give_decrease_purchase_count($payment->form_id); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return object $stats Contains the number of payments per payment status. |
409 | 409 | */ |
410 | -function give_count_payments( $args = array() ) { |
|
410 | +function give_count_payments($args = array()) { |
|
411 | 411 | |
412 | 412 | global $wpdb; |
413 | 413 | |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | 'form_id' => null, |
420 | 420 | ); |
421 | 421 | |
422 | - $args = wp_parse_args( $args, $defaults ); |
|
422 | + $args = wp_parse_args($args, $defaults); |
|
423 | 423 | |
424 | 424 | $select = 'SELECT p.post_status,count( * ) AS num_posts'; |
425 | 425 | $join = ''; |
426 | 426 | $where = "WHERE p.post_type = 'give_payment'"; |
427 | 427 | |
428 | 428 | // Count payments for a specific user. |
429 | - if ( ! empty( $args['user'] ) ) { |
|
429 | + if ( ! empty($args['user'])) { |
|
430 | 430 | |
431 | - if ( is_email( $args['user'] ) ) { |
|
431 | + if (is_email($args['user'])) { |
|
432 | 432 | $field = 'email'; |
433 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
433 | + } elseif (is_numeric($args['user'])) { |
|
434 | 434 | $field = 'id'; |
435 | 435 | } else { |
436 | 436 | $field = ''; |
@@ -438,105 +438,105 @@ discard block |
||
438 | 438 | |
439 | 439 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
440 | 440 | |
441 | - if ( ! empty( $field ) ) { |
|
441 | + if ( ! empty($field)) { |
|
442 | 442 | $where .= " |
443 | 443 | AND m.meta_key = '_give_payment_user_{$field}' |
444 | 444 | AND m.meta_value = '{$args['user']}'"; |
445 | 445 | } |
446 | 446 | |
447 | 447 | // Count payments for a search. |
448 | - } elseif ( ! empty( $args['s'] ) ) { |
|
448 | + } elseif ( ! empty($args['s'])) { |
|
449 | 449 | |
450 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
450 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
451 | 451 | |
452 | - if ( is_email( $args['s'] ) ) { |
|
452 | + if (is_email($args['s'])) { |
|
453 | 453 | $field = '_give_payment_user_email'; |
454 | 454 | } else { |
455 | 455 | $field = '_give_payment_purchase_key'; |
456 | 456 | } |
457 | 457 | |
458 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | - $where .= $wpdb->prepare( ' |
|
458 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
459 | + $where .= $wpdb->prepare(' |
|
460 | 460 | AND m.meta_key = %s |
461 | 461 | AND m.meta_value = %s', |
462 | 462 | $field, |
463 | 463 | $args['s'] |
464 | 464 | ); |
465 | 465 | |
466 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
466 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
467 | 467 | |
468 | - $search = str_replace( '#:', '', $args['s'] ); |
|
469 | - $search = str_replace( '#', '', $search ); |
|
468 | + $search = str_replace('#:', '', $args['s']); |
|
469 | + $search = str_replace('#', '', $search); |
|
470 | 470 | |
471 | 471 | $select = 'SELECT p2.post_status,count( * ) AS num_posts '; |
472 | 472 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
473 | 473 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
474 | 474 | $where = "WHERE p.post_type = 'give_log' "; |
475 | - $where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search ); |
|
475 | + $where .= $wpdb->prepare('AND p.post_parent = %d} ', $search); |
|
476 | 476 | |
477 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
477 | + } elseif (is_numeric($args['s'])) { |
|
478 | 478 | |
479 | - $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | - $where .= $wpdb->prepare( " |
|
479 | + $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
|
480 | + $where .= $wpdb->prepare(" |
|
481 | 481 | AND m.meta_key = '_give_payment_user_id' |
482 | 482 | AND m.meta_value = %d", |
483 | 483 | $args['s'] |
484 | 484 | ); |
485 | 485 | |
486 | 486 | } else { |
487 | - $search = $wpdb->esc_like( $args['s'] ); |
|
488 | - $search = '%' . $search . '%'; |
|
487 | + $search = $wpdb->esc_like($args['s']); |
|
488 | + $search = '%'.$search.'%'; |
|
489 | 489 | |
490 | - $where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search ); |
|
490 | + $where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search); |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
494 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
494 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
495 | 495 | |
496 | - $where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] ); |
|
496 | + $where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']); |
|
497 | 497 | |
498 | 498 | } |
499 | 499 | // Limit payments count by date. |
500 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
500 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
501 | 501 | |
502 | - $date_parts = explode( '/', $args['start-date'] ); |
|
503 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
504 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
505 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
502 | + $date_parts = explode('/', $args['start-date']); |
|
503 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
504 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
505 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
506 | 506 | |
507 | - $is_date = checkdate( $month, $day, $year ); |
|
508 | - if ( false !== $is_date ) { |
|
507 | + $is_date = checkdate($month, $day, $year); |
|
508 | + if (false !== $is_date) { |
|
509 | 509 | |
510 | - $date = new DateTime( $args['start-date'] ); |
|
511 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
510 | + $date = new DateTime($args['start-date']); |
|
511 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class). |
516 | - if ( empty( $args['end-date'] ) ) { |
|
516 | + if (empty($args['end-date'])) { |
|
517 | 517 | $args['end-date'] = $args['start-date']; |
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
521 | + if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
522 | 522 | |
523 | - $date_parts = explode( '/', $args['end-date'] ); |
|
523 | + $date_parts = explode('/', $args['end-date']); |
|
524 | 524 | |
525 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
526 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
527 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
525 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
526 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
527 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
528 | 528 | |
529 | - $is_date = checkdate( $month, $day, $year ); |
|
530 | - if ( false !== $is_date ) { |
|
529 | + $is_date = checkdate($month, $day, $year); |
|
530 | + if (false !== $is_date) { |
|
531 | 531 | |
532 | - $date = new DateTime( $args['end-date'] ); |
|
533 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
532 | + $date = new DateTime($args['end-date']); |
|
533 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
534 | 534 | |
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
539 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
538 | + $where = apply_filters('give_count_payments_where', $where); |
|
539 | + $join = apply_filters('give_count_payments_join', $join); |
|
540 | 540 | |
541 | 541 | $query = "$select |
542 | 542 | FROM $wpdb->posts p |
@@ -545,36 +545,36 @@ discard block |
||
545 | 545 | GROUP BY p.post_status |
546 | 546 | "; |
547 | 547 | |
548 | - $cache_key = md5( $query ); |
|
548 | + $cache_key = md5($query); |
|
549 | 549 | |
550 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
551 | - if ( false !== $count ) { |
|
550 | + $count = wp_cache_get($cache_key, 'counts'); |
|
551 | + if (false !== $count) { |
|
552 | 552 | return $count; |
553 | 553 | } |
554 | 554 | |
555 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
555 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
556 | 556 | |
557 | 557 | $stats = array(); |
558 | 558 | $statuses = get_post_stati(); |
559 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
560 | - unset( $statuses['private'] ); |
|
559 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
560 | + unset($statuses['private']); |
|
561 | 561 | } |
562 | 562 | |
563 | - foreach ( $statuses as $state ) { |
|
564 | - $stats[ $state ] = 0; |
|
563 | + foreach ($statuses as $state) { |
|
564 | + $stats[$state] = 0; |
|
565 | 565 | } |
566 | 566 | |
567 | - foreach ( (array) $count as $row ) { |
|
567 | + foreach ((array) $count as $row) { |
|
568 | 568 | |
569 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
569 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
570 | 570 | continue; |
571 | 571 | } |
572 | 572 | |
573 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
573 | + $stats[$row['post_status']] = $row['num_posts']; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | $stats = (object) $stats; |
577 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
577 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
578 | 578 | |
579 | 579 | return $stats; |
580 | 580 | } |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return bool $exists True if payment exists, false otherwise. |
591 | 591 | */ |
592 | -function give_check_for_existing_payment( $payment_id ) { |
|
592 | +function give_check_for_existing_payment($payment_id) { |
|
593 | 593 | $exists = false; |
594 | - $payment = new Give_Payment( $payment_id ); |
|
594 | + $payment = new Give_Payment($payment_id); |
|
595 | 595 | |
596 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
596 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
597 | 597 | $exists = true; |
598 | 598 | } |
599 | 599 | |
@@ -611,31 +611,31 @@ discard block |
||
611 | 611 | * |
612 | 612 | * @return bool|mixed True if payment status exists, false otherwise. |
613 | 613 | */ |
614 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
614 | +function give_get_payment_status($payment, $return_label = false) { |
|
615 | 615 | |
616 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
616 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
617 | 617 | return false; |
618 | 618 | } |
619 | 619 | |
620 | 620 | $statuses = give_get_payment_statuses(); |
621 | 621 | |
622 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
622 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
623 | 623 | return false; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Get payment object if no already given. |
627 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
627 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
628 | 628 | |
629 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
630 | - if ( true === $return_label ) { |
|
629 | + if (array_key_exists($payment->status, $statuses)) { |
|
630 | + if (true === $return_label) { |
|
631 | 631 | // Return translated status label. |
632 | - return $statuses[ $payment->status ]; |
|
632 | + return $statuses[$payment->status]; |
|
633 | 633 | } else { |
634 | 634 | // Account that our 'publish' status is labeled 'Complete' |
635 | 635 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
636 | 636 | |
637 | 637 | // Make sure we're matching cases, since they matter |
638 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
638 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -651,17 +651,17 @@ discard block |
||
651 | 651 | */ |
652 | 652 | function give_get_payment_statuses() { |
653 | 653 | $payment_statuses = array( |
654 | - 'pending' => __( 'Pending', 'give' ), |
|
655 | - 'publish' => __( 'Complete', 'give' ), |
|
656 | - 'refunded' => __( 'Refunded', 'give' ), |
|
657 | - 'failed' => __( 'Failed', 'give' ), |
|
658 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
659 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
660 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
661 | - 'revoked' => __( 'Revoked', 'give' ), |
|
654 | + 'pending' => __('Pending', 'give'), |
|
655 | + 'publish' => __('Complete', 'give'), |
|
656 | + 'refunded' => __('Refunded', 'give'), |
|
657 | + 'failed' => __('Failed', 'give'), |
|
658 | + 'cancelled' => __('Cancelled', 'give'), |
|
659 | + 'abandoned' => __('Abandoned', 'give'), |
|
660 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
661 | + 'revoked' => __('Revoked', 'give'), |
|
662 | 662 | ); |
663 | 663 | |
664 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
664 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | * @return array $payment_status All the available payment statuses. |
675 | 675 | */ |
676 | 676 | function give_get_payment_status_keys() { |
677 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
678 | - asort( $statuses ); |
|
677 | + $statuses = array_keys(give_get_payment_statuses()); |
|
678 | + asort($statuses); |
|
679 | 679 | |
680 | - return array_values( $statuses ); |
|
680 | + return array_values($statuses); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return int $earnings Earnings |
694 | 694 | */ |
695 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
695 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
696 | 696 | |
697 | 697 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
698 | 698 | global $wpdb; |
@@ -702,41 +702,41 @@ discard block |
||
702 | 702 | 'nopaging' => true, |
703 | 703 | 'year' => $year, |
704 | 704 | 'monthnum' => $month_num, |
705 | - 'post_status' => array( 'publish' ), |
|
705 | + 'post_status' => array('publish'), |
|
706 | 706 | 'fields' => 'ids', |
707 | 707 | 'update_post_term_cache' => false, |
708 | 708 | ); |
709 | - if ( ! empty( $day ) ) { |
|
709 | + if ( ! empty($day)) { |
|
710 | 710 | $args['day'] = $day; |
711 | 711 | } |
712 | 712 | |
713 | - if ( ! empty( $hour ) ) { |
|
713 | + if ( ! empty($hour)) { |
|
714 | 714 | $args['hour'] = $hour; |
715 | 715 | } |
716 | 716 | |
717 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
718 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
717 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
718 | + $key = Give_Cache::get_key('give_stats', $args); |
|
719 | 719 | |
720 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
720 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
721 | 721 | $earnings = false; |
722 | 722 | } else { |
723 | - $earnings = Give_Cache::get( $key ); |
|
723 | + $earnings = Give_Cache::get($key); |
|
724 | 724 | } |
725 | 725 | |
726 | - if ( false === $earnings ) { |
|
727 | - $sales = get_posts( $args ); |
|
726 | + if (false === $earnings) { |
|
727 | + $sales = get_posts($args); |
|
728 | 728 | $earnings = 0; |
729 | - if ( $sales ) { |
|
730 | - $sales = implode( ',', $sales ); |
|
729 | + if ($sales) { |
|
730 | + $sales = implode(',', $sales); |
|
731 | 731 | |
732 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
732 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | // Cache the results for one hour. |
736 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
736 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
737 | 737 | } |
738 | 738 | |
739 | - return round( $earnings, 2 ); |
|
739 | + return round($earnings, 2); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @return int $count Sales |
753 | 753 | */ |
754 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
754 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
755 | 755 | |
756 | 756 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
757 | 757 | $args = array( |
@@ -759,14 +759,14 @@ discard block |
||
759 | 759 | 'nopaging' => true, |
760 | 760 | 'year' => $year, |
761 | 761 | 'fields' => 'ids', |
762 | - 'post_status' => array( 'publish' ), |
|
762 | + 'post_status' => array('publish'), |
|
763 | 763 | 'update_post_meta_cache' => false, |
764 | 764 | 'update_post_term_cache' => false, |
765 | 765 | ); |
766 | 766 | |
767 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
767 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
768 | 768 | |
769 | - if ( false === $show_free ) { |
|
769 | + if (false === $show_free) { |
|
770 | 770 | $args['meta_query'] = array( |
771 | 771 | array( |
772 | 772 | 'key' => '_give_payment_total', |
@@ -777,33 +777,33 @@ discard block |
||
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | - if ( ! empty( $month_num ) ) { |
|
780 | + if ( ! empty($month_num)) { |
|
781 | 781 | $args['monthnum'] = $month_num; |
782 | 782 | } |
783 | 783 | |
784 | - if ( ! empty( $day ) ) { |
|
784 | + if ( ! empty($day)) { |
|
785 | 785 | $args['day'] = $day; |
786 | 786 | } |
787 | 787 | |
788 | - if ( ! empty( $hour ) ) { |
|
788 | + if ( ! empty($hour)) { |
|
789 | 789 | $args['hour'] = $hour; |
790 | 790 | } |
791 | 791 | |
792 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
792 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
793 | 793 | |
794 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
794 | + $key = Give_Cache::get_key('give_stats', $args); |
|
795 | 795 | |
796 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
796 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
797 | 797 | $count = false; |
798 | 798 | } else { |
799 | - $count = Give_Cache::get( $key ); |
|
799 | + $count = Give_Cache::get($key); |
|
800 | 800 | } |
801 | 801 | |
802 | - if ( false === $count ) { |
|
803 | - $sales = new WP_Query( $args ); |
|
802 | + if (false === $count) { |
|
803 | + $sales = new WP_Query($args); |
|
804 | 804 | $count = (int) $sales->post_count; |
805 | 805 | // Cache the results for one hour. |
806 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
806 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | return $count; |
@@ -818,19 +818,19 @@ discard block |
||
818 | 818 | * |
819 | 819 | * @return bool $ret True if complete, false otherwise. |
820 | 820 | */ |
821 | -function give_is_payment_complete( $payment_id ) { |
|
822 | - $payment = new Give_Payment( $payment_id ); |
|
821 | +function give_is_payment_complete($payment_id) { |
|
822 | + $payment = new Give_Payment($payment_id); |
|
823 | 823 | |
824 | 824 | $ret = false; |
825 | 825 | |
826 | - if ( $payment->ID > 0 ) { |
|
826 | + if ($payment->ID > 0) { |
|
827 | 827 | |
828 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
828 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
829 | 829 | $ret = true; |
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
833 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | /** |
@@ -856,49 +856,49 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return float $total Total earnings. |
858 | 858 | */ |
859 | -function give_get_total_earnings( $recalculate = false ) { |
|
859 | +function give_get_total_earnings($recalculate = false) { |
|
860 | 860 | |
861 | - $total = get_option( 'give_earnings_total', 0 ); |
|
861 | + $total = get_option('give_earnings_total', 0); |
|
862 | 862 | |
863 | 863 | // Calculate total earnings. |
864 | - if ( ! $total || $recalculate ) { |
|
864 | + if ( ! $total || $recalculate) { |
|
865 | 865 | global $wpdb; |
866 | 866 | |
867 | 867 | $total = (float) 0; |
868 | 868 | |
869 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
869 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
870 | 870 | 'offset' => 0, |
871 | - 'number' => - 1, |
|
872 | - 'status' => array( 'publish' ), |
|
871 | + 'number' => -1, |
|
872 | + 'status' => array('publish'), |
|
873 | 873 | 'fields' => 'ids', |
874 | - ) ); |
|
874 | + )); |
|
875 | 875 | |
876 | - $payments = give_get_payments( $args ); |
|
877 | - if ( $payments ) { |
|
876 | + $payments = give_get_payments($args); |
|
877 | + if ($payments) { |
|
878 | 878 | |
879 | 879 | /** |
880 | 880 | * If performing a donation, we need to skip the very last payment in the database, |
881 | 881 | * since it calls give_increase_total_earnings() on completion, |
882 | 882 | * which results in duplicated earnings for the very first donation. |
883 | 883 | */ |
884 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
885 | - array_pop( $payments ); |
|
884 | + if (did_action('give_update_payment_status')) { |
|
885 | + array_pop($payments); |
|
886 | 886 | } |
887 | 887 | |
888 | - if ( ! empty( $payments ) ) { |
|
889 | - $payments = implode( ',', $payments ); |
|
890 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
888 | + if ( ! empty($payments)) { |
|
889 | + $payments = implode(',', $payments); |
|
890 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
894 | + update_option('give_earnings_total', $total, 'no'); |
|
895 | 895 | } |
896 | 896 | |
897 | - if ( $total < 0 ) { |
|
897 | + if ($total < 0) { |
|
898 | 898 | $total = 0; // Don't ever show negative earnings. |
899 | 899 | } |
900 | 900 | |
901 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
901 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
@@ -911,10 +911,10 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return float $total Total earnings. |
913 | 913 | */ |
914 | -function give_increase_total_earnings( $amount = 0 ) { |
|
914 | +function give_increase_total_earnings($amount = 0) { |
|
915 | 915 | $total = give_get_total_earnings(); |
916 | 916 | $total += $amount; |
917 | - update_option( 'give_earnings_total', $total ); |
|
917 | + update_option('give_earnings_total', $total); |
|
918 | 918 | |
919 | 919 | return $total; |
920 | 920 | } |
@@ -928,13 +928,13 @@ discard block |
||
928 | 928 | * |
929 | 929 | * @return float $total Total earnings. |
930 | 930 | */ |
931 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
931 | +function give_decrease_total_earnings($amount = 0) { |
|
932 | 932 | $total = give_get_total_earnings(); |
933 | 933 | $total -= $amount; |
934 | - if ( $total < 0 ) { |
|
934 | + if ($total < 0) { |
|
935 | 935 | $total = 0; |
936 | 936 | } |
937 | - update_option( 'give_earnings_total', $total ); |
|
937 | + update_option('give_earnings_total', $total); |
|
938 | 938 | |
939 | 939 | return $total; |
940 | 940 | } |
@@ -950,10 +950,10 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @return mixed $meta Payment Meta. |
952 | 952 | */ |
953 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
954 | - $payment = new Give_Payment( $payment_id ); |
|
953 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
954 | + $payment = new Give_Payment($payment_id); |
|
955 | 955 | |
956 | - return $payment->get_meta( $meta_key, $single ); |
|
956 | + return $payment->get_meta($meta_key, $single); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -966,10 +966,10 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @return mixed Meta ID if successful, false if unsuccessful. |
968 | 968 | */ |
969 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
970 | - $payment = new Give_Payment( $payment_id ); |
|
969 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
970 | + $payment = new Give_Payment($payment_id); |
|
971 | 971 | |
972 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
972 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @return string $user_info User Info Meta Values. |
983 | 983 | */ |
984 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
985 | - $payment = new Give_Payment( $payment_id ); |
|
984 | +function give_get_payment_meta_user_info($payment_id) { |
|
985 | + $payment = new Give_Payment($payment_id); |
|
986 | 986 | |
987 | 987 | return $payment->user_info; |
988 | 988 | } |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return int $form_id Form ID. |
1000 | 1000 | */ |
1001 | -function give_get_payment_form_id( $payment_id ) { |
|
1002 | - $payment = new Give_Payment( $payment_id ); |
|
1001 | +function give_get_payment_form_id($payment_id) { |
|
1002 | + $payment = new Give_Payment($payment_id); |
|
1003 | 1003 | |
1004 | 1004 | return $payment->form_id; |
1005 | 1005 | } |
@@ -1013,8 +1013,8 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @return string $email User email. |
1015 | 1015 | */ |
1016 | -function give_get_payment_user_email( $payment_id ) { |
|
1017 | - $payment = new Give_Payment( $payment_id ); |
|
1016 | +function give_get_payment_user_email($payment_id) { |
|
1017 | + $payment = new Give_Payment($payment_id); |
|
1018 | 1018 | |
1019 | 1019 | return $payment->email; |
1020 | 1020 | } |
@@ -1028,11 +1028,11 @@ discard block |
||
1028 | 1028 | * |
1029 | 1029 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
1030 | 1030 | */ |
1031 | -function give_is_guest_payment( $payment_id ) { |
|
1032 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
1033 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
1031 | +function give_is_guest_payment($payment_id) { |
|
1032 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
1033 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
1034 | 1034 | |
1035 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
1035 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | * |
1045 | 1045 | * @return int $user_id User ID. |
1046 | 1046 | */ |
1047 | -function give_get_payment_user_id( $payment_id ) { |
|
1048 | - $payment = new Give_Payment( $payment_id ); |
|
1047 | +function give_get_payment_user_id($payment_id) { |
|
1048 | + $payment = new Give_Payment($payment_id); |
|
1049 | 1049 | |
1050 | 1050 | return $payment->user_id; |
1051 | 1051 | } |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | * |
1060 | 1060 | * @return int $customer_id Customer ID. |
1061 | 1061 | */ |
1062 | -function give_get_payment_customer_id( $payment_id ) { |
|
1063 | - $payment = new Give_Payment( $payment_id ); |
|
1062 | +function give_get_payment_customer_id($payment_id) { |
|
1063 | + $payment = new Give_Payment($payment_id); |
|
1064 | 1064 | |
1065 | 1065 | return $payment->customer_id; |
1066 | 1066 | } |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * |
1075 | 1075 | * @return string $ip User IP. |
1076 | 1076 | */ |
1077 | -function give_get_payment_user_ip( $payment_id ) { |
|
1078 | - $payment = new Give_Payment( $payment_id ); |
|
1077 | +function give_get_payment_user_ip($payment_id) { |
|
1078 | + $payment = new Give_Payment($payment_id); |
|
1079 | 1079 | |
1080 | 1080 | return $payment->ip; |
1081 | 1081 | } |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | * |
1090 | 1090 | * @return string $date The date the payment was completed. |
1091 | 1091 | */ |
1092 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1093 | - $payment = new Give_Payment( $payment_id ); |
|
1092 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1093 | + $payment = new Give_Payment($payment_id); |
|
1094 | 1094 | |
1095 | 1095 | return $payment->completed_date; |
1096 | 1096 | } |
@@ -1104,8 +1104,8 @@ discard block |
||
1104 | 1104 | * |
1105 | 1105 | * @return string $gateway Gateway. |
1106 | 1106 | */ |
1107 | -function give_get_payment_gateway( $payment_id ) { |
|
1108 | - $payment = new Give_Payment( $payment_id ); |
|
1107 | +function give_get_payment_gateway($payment_id) { |
|
1108 | + $payment = new Give_Payment($payment_id); |
|
1109 | 1109 | |
1110 | 1110 | return $payment->gateway; |
1111 | 1111 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | * |
1120 | 1120 | * @return string $currency The currency code. |
1121 | 1121 | */ |
1122 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1123 | - $payment = new Give_Payment( $payment_id ); |
|
1122 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1123 | + $payment = new Give_Payment($payment_id); |
|
1124 | 1124 | |
1125 | 1125 | return $payment->currency; |
1126 | 1126 | } |
@@ -1134,10 +1134,10 @@ discard block |
||
1134 | 1134 | * |
1135 | 1135 | * @return string $currency The currency name. |
1136 | 1136 | */ |
1137 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1138 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1137 | +function give_get_payment_currency($payment_id = 0) { |
|
1138 | + $currency = give_get_payment_currency_code($payment_id); |
|
1139 | 1139 | |
1140 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1140 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | /** |
@@ -1149,8 +1149,8 @@ discard block |
||
1149 | 1149 | * |
1150 | 1150 | * @return string $key Donation key. |
1151 | 1151 | */ |
1152 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1153 | - $payment = new Give_Payment( $payment_id ); |
|
1152 | +function give_get_payment_key($payment_id = 0) { |
|
1153 | + $payment = new Give_Payment($payment_id); |
|
1154 | 1154 | |
1155 | 1155 | return $payment->key; |
1156 | 1156 | } |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | * |
1167 | 1167 | * @return string $number Payment order number. |
1168 | 1168 | */ |
1169 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1170 | - $payment = new Give_Payment( $payment_id ); |
|
1169 | +function give_get_payment_number($payment_id = 0) { |
|
1170 | + $payment = new Give_Payment($payment_id); |
|
1171 | 1171 | |
1172 | 1172 | return $payment->number; |
1173 | 1173 | } |
@@ -1181,23 +1181,23 @@ discard block |
||
1181 | 1181 | * |
1182 | 1182 | * @return string The formatted payment number. |
1183 | 1183 | */ |
1184 | -function give_format_payment_number( $number ) { |
|
1184 | +function give_format_payment_number($number) { |
|
1185 | 1185 | |
1186 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1186 | + if ( ! give_get_option('enable_sequential')) { |
|
1187 | 1187 | return $number; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | - if ( ! is_numeric( $number ) ) { |
|
1190 | + if ( ! is_numeric($number)) { |
|
1191 | 1191 | return $number; |
1192 | 1192 | } |
1193 | 1193 | |
1194 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1195 | - $number = absint( $number ); |
|
1196 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1194 | + $prefix = give_get_option('sequential_prefix'); |
|
1195 | + $number = absint($number); |
|
1196 | + $postfix = give_get_option('sequential_postfix'); |
|
1197 | 1197 | |
1198 | - $formatted_number = $prefix . $number . $postfix; |
|
1198 | + $formatted_number = $prefix.$number.$postfix; |
|
1199 | 1199 | |
1200 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1200 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | /** |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | function give_get_next_payment_number() { |
1212 | 1212 | |
1213 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1213 | + if ( ! give_get_option('enable_sequential')) { |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - $number = get_option( 'give_last_payment_number' ); |
|
1218 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1217 | + $number = get_option('give_last_payment_number'); |
|
1218 | + $start = give_get_option('sequential_start', 1); |
|
1219 | 1219 | $increment_number = true; |
1220 | 1220 | |
1221 | - if ( false !== $number ) { |
|
1221 | + if (false !== $number) { |
|
1222 | 1222 | |
1223 | - if ( empty( $number ) ) { |
|
1223 | + if (empty($number)) { |
|
1224 | 1224 | |
1225 | 1225 | $number = $start; |
1226 | 1226 | $increment_number = false; |
@@ -1229,24 +1229,24 @@ discard block |
||
1229 | 1229 | } else { |
1230 | 1230 | |
1231 | 1231 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
1232 | - $payments = new Give_Payments_Query( array( |
|
1232 | + $payments = new Give_Payments_Query(array( |
|
1233 | 1233 | 'number' => 1, |
1234 | 1234 | 'order' => 'DESC', |
1235 | 1235 | 'orderby' => 'ID', |
1236 | 1236 | 'output' => 'posts', |
1237 | 1237 | 'fields' => 'ids', |
1238 | - ) ); |
|
1238 | + )); |
|
1239 | 1239 | $last_payment = $payments->get_payments(); |
1240 | 1240 | |
1241 | - if ( ! empty( $last_payment ) ) { |
|
1241 | + if ( ! empty($last_payment)) { |
|
1242 | 1242 | |
1243 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1243 | + $number = give_get_payment_number($last_payment[0]); |
|
1244 | 1244 | |
1245 | 1245 | } |
1246 | 1246 | |
1247 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1247 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1248 | 1248 | |
1249 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1249 | + $number = give_remove_payment_prefix_postfix($number); |
|
1250 | 1250 | |
1251 | 1251 | } else { |
1252 | 1252 | |
@@ -1255,13 +1255,13 @@ discard block |
||
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | |
1258 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1258 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1259 | 1259 | |
1260 | - if ( $increment_number ) { |
|
1261 | - $number ++; |
|
1260 | + if ($increment_number) { |
|
1261 | + $number++; |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1264 | + return apply_filters('give_get_next_payment_number', $number); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -1273,25 +1273,25 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @return string The new Payment number without prefix and postfix. |
1275 | 1275 | */ |
1276 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1276 | +function give_remove_payment_prefix_postfix($number) { |
|
1277 | 1277 | |
1278 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1279 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1278 | + $prefix = give_get_option('sequential_prefix'); |
|
1279 | + $postfix = give_get_option('sequential_postfix'); |
|
1280 | 1280 | |
1281 | 1281 | // Remove prefix. |
1282 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1282 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1283 | 1283 | |
1284 | 1284 | // Remove the postfix. |
1285 | - $length = strlen( $number ); |
|
1286 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1287 | - if ( false !== $postfix_pos ) { |
|
1288 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1285 | + $length = strlen($number); |
|
1286 | + $postfix_pos = strrpos($number, $postfix); |
|
1287 | + if (false !== $postfix_pos) { |
|
1288 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | // Ensure it's a whole number. |
1292 | - $number = intval( $number ); |
|
1292 | + $number = intval($number); |
|
1293 | 1293 | |
1294 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1294 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1295 | 1295 | |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | * |
1309 | 1309 | * @return string $amount Fully formatted payment amount. |
1310 | 1310 | */ |
1311 | -function give_payment_amount( $payment_id = 0 ) { |
|
1312 | - $amount = give_get_payment_amount( $payment_id ); |
|
1311 | +function give_payment_amount($payment_id = 0) { |
|
1312 | + $amount = give_get_payment_amount($payment_id); |
|
1313 | 1313 | |
1314 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1314 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | /** |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | * |
1325 | 1325 | * @return mixed|void |
1326 | 1326 | */ |
1327 | -function give_get_payment_amount( $payment_id ) { |
|
1327 | +function give_get_payment_amount($payment_id) { |
|
1328 | 1328 | |
1329 | - $payment = new Give_Payment( $payment_id ); |
|
1329 | + $payment = new Give_Payment($payment_id); |
|
1330 | 1330 | |
1331 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1331 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1345,10 +1345,10 @@ discard block |
||
1345 | 1345 | * |
1346 | 1346 | * @return array Fully formatted payment subtotal. |
1347 | 1347 | */ |
1348 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1349 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1348 | +function give_payment_subtotal($payment_id = 0) { |
|
1349 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1350 | 1350 | |
1351 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1351 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | /** |
@@ -1362,8 +1362,8 @@ discard block |
||
1362 | 1362 | * |
1363 | 1363 | * @return float $subtotal Subtotal for payment (non formatted). |
1364 | 1364 | */ |
1365 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1366 | - $payment = new G_Payment( $payment_id ); |
|
1365 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1366 | + $payment = new G_Payment($payment_id); |
|
1367 | 1367 | |
1368 | 1368 | return $payment->subtotal; |
1369 | 1369 | } |
@@ -1378,10 +1378,10 @@ discard block |
||
1378 | 1378 | * |
1379 | 1379 | * @return mixed array if payment fees found, false otherwise. |
1380 | 1380 | */ |
1381 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1382 | - $payment = new Give_Payment( $payment_id ); |
|
1381 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1382 | + $payment = new Give_Payment($payment_id); |
|
1383 | 1383 | |
1384 | - return $payment->get_fees( $type ); |
|
1384 | + return $payment->get_fees($type); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | /** |
@@ -1393,8 +1393,8 @@ discard block |
||
1393 | 1393 | * |
1394 | 1394 | * @return string The donation ID. |
1395 | 1395 | */ |
1396 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1397 | - $payment = new Give_Payment( $payment_id ); |
|
1396 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1397 | + $payment = new Give_Payment($payment_id); |
|
1398 | 1398 | |
1399 | 1399 | return $payment->transaction_id; |
1400 | 1400 | } |
@@ -1409,15 +1409,15 @@ discard block |
||
1409 | 1409 | * |
1410 | 1410 | * @return bool|mixed |
1411 | 1411 | */ |
1412 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1412 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1413 | 1413 | |
1414 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1414 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1415 | 1415 | return false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1418 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1419 | 1419 | |
1420 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1420 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | /** |
@@ -1430,12 +1430,12 @@ discard block |
||
1430 | 1430 | * |
1431 | 1431 | * @return int $purchase Donation ID. |
1432 | 1432 | */ |
1433 | -function give_get_purchase_id_by_key( $key ) { |
|
1433 | +function give_get_purchase_id_by_key($key) { |
|
1434 | 1434 | global $wpdb; |
1435 | 1435 | |
1436 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1436 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1437 | 1437 | |
1438 | - if ( $purchase != null ) { |
|
1438 | + if ($purchase != null) { |
|
1439 | 1439 | return $purchase; |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1453,12 +1453,12 @@ discard block |
||
1453 | 1453 | * |
1454 | 1454 | * @return int $purchase Donation ID. |
1455 | 1455 | */ |
1456 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1456 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1457 | 1457 | global $wpdb; |
1458 | 1458 | |
1459 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1459 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1460 | 1460 | |
1461 | - if ( $purchase != null ) { |
|
1461 | + if ($purchase != null) { |
|
1462 | 1462 | return $purchase; |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1475,19 +1475,19 @@ discard block |
||
1475 | 1475 | * |
1476 | 1476 | * @return array $notes Donation Notes |
1477 | 1477 | */ |
1478 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1478 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1479 | 1479 | |
1480 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1480 | + if (empty($payment_id) && empty($search)) { |
|
1481 | 1481 | return false; |
1482 | 1482 | } |
1483 | 1483 | |
1484 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1485 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1484 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1485 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1486 | 1486 | |
1487 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1487 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1488 | 1488 | |
1489 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1490 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1489 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1490 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1491 | 1491 | |
1492 | 1492 | return $notes; |
1493 | 1493 | } |
@@ -1503,8 +1503,8 @@ discard block |
||
1503 | 1503 | * |
1504 | 1504 | * @return int The new note ID |
1505 | 1505 | */ |
1506 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1507 | - if ( empty( $payment_id ) ) { |
|
1506 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1507 | + if (empty($payment_id)) { |
|
1508 | 1508 | return false; |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1516,14 +1516,14 @@ discard block |
||
1516 | 1516 | * @param int $payment_id Payment ID. |
1517 | 1517 | * @param string $note The note. |
1518 | 1518 | */ |
1519 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1519 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1520 | 1520 | |
1521 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1521 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1522 | 1522 | 'comment_post_ID' => $payment_id, |
1523 | 1523 | 'comment_content' => $note, |
1524 | 1524 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1525 | - 'comment_date' => current_time( 'mysql' ), |
|
1526 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1525 | + 'comment_date' => current_time('mysql'), |
|
1526 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1527 | 1527 | 'comment_approved' => 1, |
1528 | 1528 | 'comment_parent' => 0, |
1529 | 1529 | 'comment_author' => '', |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | 'comment_author_email' => '', |
1533 | 1533 | 'comment_type' => 'give_payment_note', |
1534 | 1534 | |
1535 | - ) ) ); |
|
1535 | + ))); |
|
1536 | 1536 | |
1537 | 1537 | /** |
1538 | 1538 | * Fires after payment note inserted. |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | * @param int $payment_id Payment ID. |
1544 | 1544 | * @param string $note The note. |
1545 | 1545 | */ |
1546 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1546 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1547 | 1547 | |
1548 | 1548 | return $note_id; |
1549 | 1549 | } |
@@ -1558,8 +1558,8 @@ discard block |
||
1558 | 1558 | * |
1559 | 1559 | * @return bool True on success, false otherwise. |
1560 | 1560 | */ |
1561 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1562 | - if ( empty( $comment_id ) ) { |
|
1561 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1562 | + if (empty($comment_id)) { |
|
1563 | 1563 | return false; |
1564 | 1564 | } |
1565 | 1565 | |
@@ -1571,9 +1571,9 @@ discard block |
||
1571 | 1571 | * @param int $comment_id Note ID. |
1572 | 1572 | * @param int $payment_id Payment ID. |
1573 | 1573 | */ |
1574 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1574 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1575 | 1575 | |
1576 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1576 | + $ret = wp_delete_comment($comment_id, true); |
|
1577 | 1577 | |
1578 | 1578 | /** |
1579 | 1579 | * Fires after donation note deleted. |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | * @param int $comment_id Note ID. |
1584 | 1584 | * @param int $payment_id Payment ID. |
1585 | 1585 | */ |
1586 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1586 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1587 | 1587 | |
1588 | 1588 | return $ret; |
1589 | 1589 | } |
@@ -1598,34 +1598,34 @@ discard block |
||
1598 | 1598 | * |
1599 | 1599 | * @return string |
1600 | 1600 | */ |
1601 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1601 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1602 | 1602 | |
1603 | - if ( is_numeric( $note ) ) { |
|
1604 | - $note = get_comment( $note ); |
|
1603 | + if (is_numeric($note)) { |
|
1604 | + $note = get_comment($note); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | - if ( ! empty( $note->user_id ) ) { |
|
1608 | - $user = get_userdata( $note->user_id ); |
|
1607 | + if ( ! empty($note->user_id)) { |
|
1608 | + $user = get_userdata($note->user_id); |
|
1609 | 1609 | $user = $user->display_name; |
1610 | 1610 | } else { |
1611 | - $user = esc_html__( 'System', 'give' ); |
|
1611 | + $user = esc_html__('System', 'give'); |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
1614 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
1615 | 1615 | |
1616 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1616 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1617 | 1617 | 'give-action' => 'delete_payment_note', |
1618 | 1618 | 'note_id' => $note->comment_ID, |
1619 | 1619 | 'payment_id' => $payment_id, |
1620 | - ) ), |
|
1621 | - 'give_delete_payment_note_' . $note->comment_ID |
|
1620 | + )), |
|
1621 | + 'give_delete_payment_note_'.$note->comment_ID |
|
1622 | 1622 | ); |
1623 | 1623 | |
1624 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1624 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1625 | 1625 | $note_html .= '<p>'; |
1626 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1626 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1627 | 1627 | $note_html .= $note->comment_content; |
1628 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1628 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1629 | 1629 | $note_html .= '</p>'; |
1630 | 1630 | $note_html .= '</div>'; |
1631 | 1631 | |
@@ -1643,18 +1643,18 @@ discard block |
||
1643 | 1643 | * |
1644 | 1644 | * @return void |
1645 | 1645 | */ |
1646 | -function give_hide_payment_notes( $query ) { |
|
1647 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
1648 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1649 | - if ( ! is_array( $types ) ) { |
|
1650 | - $types = array( $types ); |
|
1646 | +function give_hide_payment_notes($query) { |
|
1647 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
1648 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1649 | + if ( ! is_array($types)) { |
|
1650 | + $types = array($types); |
|
1651 | 1651 | } |
1652 | 1652 | $types[] = 'give_payment_note'; |
1653 | 1653 | $query->query_vars['type__not_in'] = $types; |
1654 | 1654 | } |
1655 | 1655 | } |
1656 | 1656 | |
1657 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1657 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1666,15 +1666,15 @@ discard block |
||
1666 | 1666 | * |
1667 | 1667 | * @return array $clauses Updated comment clauses. |
1668 | 1668 | */ |
1669 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1670 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
1669 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1670 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
1671 | 1671 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | return $clauses; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1677 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1678 | 1678 | |
1679 | 1679 | |
1680 | 1680 | /** |
@@ -1687,15 +1687,15 @@ discard block |
||
1687 | 1687 | * |
1688 | 1688 | * @return string $where |
1689 | 1689 | */ |
1690 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1690 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1691 | 1691 | global $wpdb; |
1692 | 1692 | |
1693 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
1693 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
1694 | 1694 | |
1695 | 1695 | return $where; |
1696 | 1696 | } |
1697 | 1697 | |
1698 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1698 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1699 | 1699 | |
1700 | 1700 | |
1701 | 1701 | /** |
@@ -1709,32 +1709,32 @@ discard block |
||
1709 | 1709 | * |
1710 | 1710 | * @return array Array of comment counts. |
1711 | 1711 | */ |
1712 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1712 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1713 | 1713 | global $wpdb, $pagenow; |
1714 | 1714 | |
1715 | - if ( 'index.php' != $pagenow ) { |
|
1715 | + if ('index.php' != $pagenow) { |
|
1716 | 1716 | return $stats; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 | $post_id = (int) $post_id; |
1720 | 1720 | |
1721 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1721 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1722 | 1722 | return $stats; |
1723 | 1723 | } |
1724 | 1724 | |
1725 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1725 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1726 | 1726 | |
1727 | - if ( false !== $stats ) { |
|
1727 | + if (false !== $stats) { |
|
1728 | 1728 | return $stats; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | 1731 | $where = 'WHERE comment_type != "give_payment_note"'; |
1732 | 1732 | |
1733 | - if ( $post_id > 0 ) { |
|
1734 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
1733 | + if ($post_id > 0) { |
|
1734 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
1735 | 1735 | } |
1736 | 1736 | |
1737 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1737 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1738 | 1738 | |
1739 | 1739 | $total = 0; |
1740 | 1740 | $approved = array( |
@@ -1744,30 +1744,30 @@ discard block |
||
1744 | 1744 | 'trash' => 'trash', |
1745 | 1745 | 'post-trashed' => 'post-trashed', |
1746 | 1746 | ); |
1747 | - foreach ( (array) $count as $row ) { |
|
1747 | + foreach ((array) $count as $row) { |
|
1748 | 1748 | // Don't count post-trashed toward totals. |
1749 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1749 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1750 | 1750 | $total += $row['num_comments']; |
1751 | 1751 | } |
1752 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1753 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1752 | + if (isset($approved[$row['comment_approved']])) { |
|
1753 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1754 | 1754 | } |
1755 | 1755 | } |
1756 | 1756 | |
1757 | 1757 | $stats['total_comments'] = $total; |
1758 | - foreach ( $approved as $key ) { |
|
1759 | - if ( empty( $stats[ $key ] ) ) { |
|
1760 | - $stats[ $key ] = 0; |
|
1758 | + foreach ($approved as $key) { |
|
1759 | + if (empty($stats[$key])) { |
|
1760 | + $stats[$key] = 0; |
|
1761 | 1761 | } |
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | $stats = (object) $stats; |
1765 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1765 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1766 | 1766 | |
1767 | 1767 | return $stats; |
1768 | 1768 | } |
1769 | 1769 | |
1770 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1770 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1771 | 1771 | |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1780,9 +1780,9 @@ discard block |
||
1780 | 1780 | * |
1781 | 1781 | * @return string $where Modified where clause. |
1782 | 1782 | */ |
1783 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1783 | +function give_filter_where_older_than_week($where = '') { |
|
1784 | 1784 | // Payments older than one week. |
1785 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1785 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1786 | 1786 | $where .= " AND post_date <= '{$start}'"; |
1787 | 1787 | |
1788 | 1788 | return $where; |
@@ -1802,38 +1802,38 @@ discard block |
||
1802 | 1802 | * |
1803 | 1803 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
1804 | 1804 | */ |
1805 | -function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) { |
|
1805 | +function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') { |
|
1806 | 1806 | |
1807 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1808 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1809 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1807 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1808 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1809 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1810 | 1810 | |
1811 | - if ( $only_level == true ) { |
|
1811 | + if ($only_level == true) { |
|
1812 | 1812 | $form_title = ''; |
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | //If multi-level, append to the form title. |
1816 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1816 | + if (give_has_variable_prices($form_id)) { |
|
1817 | 1817 | |
1818 | 1818 | //Only add separator if there is a form title. |
1819 | - if ( ! empty( $form_title ) ) { |
|
1820 | - $form_title .= ' ' . $separator . ' '; |
|
1819 | + if ( ! empty($form_title)) { |
|
1820 | + $form_title .= ' '.$separator.' '; |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | $form_title .= '<span class="donation-level-text-wrap">'; |
1824 | 1824 | |
1825 | - if ( $price_id == 'custom' ) { |
|
1826 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1827 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
1825 | + if ($price_id == 'custom') { |
|
1826 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1827 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
1828 | 1828 | } else { |
1829 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1829 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | $form_title .= '</span>'; |
1833 | 1833 | |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1836 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1837 | 1837 | |
1838 | 1838 | } |
1839 | 1839 | |
@@ -1847,20 +1847,20 @@ discard block |
||
1847 | 1847 | * |
1848 | 1848 | * @return string $price_id |
1849 | 1849 | */ |
1850 | -function give_get_price_id( $form_id, $price ) { |
|
1850 | +function give_get_price_id($form_id, $price) { |
|
1851 | 1851 | |
1852 | 1852 | $price_id = 0; |
1853 | 1853 | |
1854 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1854 | + if (give_has_variable_prices($form_id)) { |
|
1855 | 1855 | |
1856 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1856 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1857 | 1857 | |
1858 | - foreach ( $levels as $level ) { |
|
1858 | + foreach ($levels as $level) { |
|
1859 | 1859 | |
1860 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1860 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1861 | 1861 | |
1862 | 1862 | // Check that this indeed the recurring price. |
1863 | - if ( $level_amount == $price ) { |
|
1863 | + if ($level_amount == $price) { |
|
1864 | 1864 | |
1865 | 1865 | $price_id = $level['_give_id']['level_id']; |
1866 | 1866 | |
@@ -1885,10 +1885,10 @@ discard block |
||
1885 | 1885 | * |
1886 | 1886 | * @return string|void |
1887 | 1887 | */ |
1888 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
1889 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1888 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1889 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1890 | 1890 | |
1891 | - if ( ! $echo ) { |
|
1891 | + if ( ! $echo) { |
|
1892 | 1892 | return $form_dropdown_html; |
1893 | 1893 | } |
1894 | 1894 | |
@@ -1905,17 +1905,17 @@ discard block |
||
1905 | 1905 | * |
1906 | 1906 | * @return string|bool |
1907 | 1907 | */ |
1908 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
1908 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1909 | 1909 | |
1910 | 1910 | // Check for give form id. |
1911 | - if ( empty( $args['id'] ) ) { |
|
1911 | + if (empty($args['id'])) { |
|
1912 | 1912 | return false; |
1913 | 1913 | } |
1914 | 1914 | |
1915 | - $form = new Give_Donate_Form( $args['id'] ); |
|
1915 | + $form = new Give_Donate_Form($args['id']); |
|
1916 | 1916 | |
1917 | 1917 | // Check if form has variable prices or not. |
1918 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
1918 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
1919 | 1919 | return false; |
1920 | 1920 | } |
1921 | 1921 | |
@@ -1923,22 +1923,22 @@ discard block |
||
1923 | 1923 | $variable_price_options = array(); |
1924 | 1924 | |
1925 | 1925 | // Check if multi donation form support custom donation or not. |
1926 | - if ( $form->is_custom_price_mode() ) { |
|
1927 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1926 | + if ($form->is_custom_price_mode()) { |
|
1927 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | // Get variable price and ID from variable price array. |
1931 | - foreach ( $variable_prices as $variable_price ) { |
|
1932 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) ); |
|
1931 | + foreach ($variable_prices as $variable_price) { |
|
1932 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'])); |
|
1933 | 1933 | } |
1934 | 1934 | |
1935 | 1935 | // Update options. |
1936 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1936 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1937 | 1937 | |
1938 | 1938 | // Generate select html. |
1939 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1939 | + $form_dropdown_html = Give()->html->select($args); |
|
1940 | 1940 | |
1941 | - if ( ! $echo ) { |
|
1941 | + if ( ! $echo) { |
|
1942 | 1942 | return $form_dropdown_html; |
1943 | 1943 | } |
1944 | 1944 | |
@@ -1957,14 +1957,14 @@ discard block |
||
1957 | 1957 | * |
1958 | 1958 | * @return string |
1959 | 1959 | */ |
1960 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
1960 | +function give_get_payment_meta_price_id($payment_meta) { |
|
1961 | 1961 | |
1962 | - if(isset($payment_meta['give_price_id'])) { |
|
1963 | - $price_id = $payment_meta['give_price_id']; |
|
1964 | - } elseif(isset($payment_meta['price_id'])) { |
|
1965 | - $price_id = $payment_meta['price_id']; |
|
1962 | + if (isset($payment_meta['give_price_id'])) { |
|
1963 | + $price_id = $payment_meta['give_price_id']; |
|
1964 | + } elseif (isset($payment_meta['price_id'])) { |
|
1965 | + $price_id = $payment_meta['price_id']; |
|
1966 | 1966 | } else { |
1967 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
1967 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
1968 | 1968 | } |
1969 | 1969 | |
1970 | 1970 | return apply_filters('give_get_payment_meta_price_id', $price_id); |
@@ -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 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
61 | + do_action('give_pre_complete_purchase', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_purchase_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_purchase_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $customer = new Give_Customer( $customer_id ); |
|
89 | + $customer = new Give_Customer($customer_id); |
|
90 | 90 | $customer->increase_purchase_count(); |
91 | - $customer->increase_value( $amount ); |
|
91 | + $customer->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | 136 | $status_change = sprintf( |
137 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
137 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
138 | 138 | $old_status, |
139 | 139 | $new_status |
140 | 140 | ); |
141 | 141 | |
142 | - give_insert_payment_note( $payment_id, $status_change ); |
|
142 | + give_insert_payment_note($payment_id, $status_change); |
|
143 | 143 | } |
144 | 144 | |
145 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
145 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | /** |
@@ -158,25 +158,25 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return void |
160 | 160 | */ |
161 | -function give_update_old_payments_with_totals( $data ) { |
|
162 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
161 | +function give_update_old_payments_with_totals($data) { |
|
162 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
166 | + if (get_option('give_payment_totals_upgraded')) { |
|
167 | 167 | return; |
168 | 168 | } |
169 | 169 | |
170 | - $payments = give_get_payments( array( |
|
170 | + $payments = give_get_payments(array( |
|
171 | 171 | 'offset' => 0, |
172 | - 'number' => - 1, |
|
172 | + 'number' => -1, |
|
173 | 173 | 'mode' => 'all', |
174 | - ) ); |
|
174 | + )); |
|
175 | 175 | |
176 | - if ( $payments ) { |
|
177 | - foreach ( $payments as $payment ) { |
|
176 | + if ($payments) { |
|
177 | + foreach ($payments as $payment) { |
|
178 | 178 | |
179 | - $payment = new Give_Payment( $payment->ID ); |
|
179 | + $payment = new Give_Payment($payment->ID); |
|
180 | 180 | $meta = $payment->get_meta(); |
181 | 181 | |
182 | 182 | $payment->total = $meta['amount']; |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
188 | + add_option('give_payment_totals_upgraded', 1); |
|
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
191 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Mark Abandoned Donations |
@@ -202,17 +202,17 @@ discard block |
||
202 | 202 | function give_mark_abandoned_donations() { |
203 | 203 | $args = array( |
204 | 204 | 'status' => 'pending', |
205 | - 'number' => - 1, |
|
205 | + 'number' => -1, |
|
206 | 206 | 'output' => 'give_payments', |
207 | 207 | ); |
208 | 208 | |
209 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - $payments = give_get_payments( $args ); |
|
211 | + $payments = give_get_payments($args); |
|
212 | 212 | |
213 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
213 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
214 | 214 | |
215 | - if ( $payments ) { |
|
215 | + if ($payments) { |
|
216 | 216 | /** |
217 | 217 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
218 | 218 | * |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param array $skip_payment_gateways Array of payment gateways |
222 | 222 | */ |
223 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
223 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
224 | 224 | |
225 | - foreach ( $payments as $payment ) { |
|
226 | - $gateway = give_get_payment_gateway( $payment ); |
|
225 | + foreach ($payments as $payment) { |
|
226 | + $gateway = give_get_payment_gateway($payment); |
|
227 | 227 | |
228 | 228 | // Skip payment gateways. |
229 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
229 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
239 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
240 | 240 | |
241 | 241 | |
242 | 242 | /** |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return void |
250 | 250 | */ |
251 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
251 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
252 | 252 | // Monthly stats. |
253 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
253 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
254 | 254 | |
255 | 255 | // @todo: Refresh only range related stat cache |
256 | 256 | give_delete_donation_stats(); |
257 | 257 | } |
258 | 258 | |
259 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
259 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -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 | |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return mixed void|false |
396 | 396 | */ |
397 | - public function __construct( $payment_id = false ) { |
|
397 | + public function __construct($payment_id = false) { |
|
398 | 398 | |
399 | - if ( empty( $payment_id ) ) { |
|
399 | + if (empty($payment_id)) { |
|
400 | 400 | return false; |
401 | 401 | } |
402 | 402 | |
403 | - $this->setup_payment( $payment_id ); |
|
403 | + $this->setup_payment($payment_id); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -413,11 +413,11 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return mixed The value. |
415 | 415 | */ |
416 | - public function __get( $key ) { |
|
416 | + public function __get($key) { |
|
417 | 417 | |
418 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
418 | + if (method_exists($this, 'get_'.$key)) { |
|
419 | 419 | |
420 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
420 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
421 | 421 | |
422 | 422 | } else { |
423 | 423 | |
@@ -439,18 +439,18 @@ discard block |
||
439 | 439 | * @param string $key The property name |
440 | 440 | * @param mixed $value The value of the property |
441 | 441 | */ |
442 | - public function __set( $key, $value ) { |
|
443 | - $ignore = array( '_ID' ); |
|
442 | + public function __set($key, $value) { |
|
443 | + $ignore = array('_ID'); |
|
444 | 444 | |
445 | - if ( $key === 'status' ) { |
|
445 | + if ($key === 'status') { |
|
446 | 446 | $this->old_status = $this->status; |
447 | 447 | } |
448 | 448 | |
449 | - if ( ! in_array( $key, $ignore ) ) { |
|
450 | - $this->pending[ $key ] = $value; |
|
449 | + if ( ! in_array($key, $ignore)) { |
|
450 | + $this->pending[$key] = $value; |
|
451 | 451 | } |
452 | 452 | |
453 | - if ( '_ID' !== $key ) { |
|
453 | + if ('_ID' !== $key) { |
|
454 | 454 | $this->$key = $value; |
455 | 455 | } |
456 | 456 | } |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return boolean If the item is set or not |
467 | 467 | */ |
468 | - public function __isset( $name ) { |
|
469 | - if ( property_exists( $this, $name ) ) { |
|
470 | - return false === empty( $this->$name ); |
|
468 | + public function __isset($name) { |
|
469 | + if (property_exists($this, $name)) { |
|
470 | + return false === empty($this->$name); |
|
471 | 471 | } else { |
472 | 472 | return null; |
473 | 473 | } |
@@ -483,20 +483,20 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return bool If the setup was successful or not |
485 | 485 | */ |
486 | - private function setup_payment( $payment_id ) { |
|
486 | + private function setup_payment($payment_id) { |
|
487 | 487 | $this->pending = array(); |
488 | 488 | |
489 | - if ( empty( $payment_id ) ) { |
|
489 | + if (empty($payment_id)) { |
|
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | |
493 | - $payment = get_post( $payment_id ); |
|
493 | + $payment = get_post($payment_id); |
|
494 | 494 | |
495 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
495 | + if ( ! $payment || is_wp_error($payment)) { |
|
496 | 496 | return false; |
497 | 497 | } |
498 | 498 | |
499 | - if ( 'give_payment' !== $payment->post_type ) { |
|
499 | + if ('give_payment' !== $payment->post_type) { |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | * @param Give_Payment $this Payment object. |
511 | 511 | * @param int $payment_id The ID of the payment. |
512 | 512 | */ |
513 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
513 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
514 | 514 | |
515 | 515 | // Primary Identifier. |
516 | - $this->ID = absint( $payment_id ); |
|
516 | + $this->ID = absint($payment_id); |
|
517 | 517 | |
518 | 518 | // Protected ID that can never be changed. |
519 | - $this->_ID = absint( $payment_id ); |
|
519 | + $this->_ID = absint($payment_id); |
|
520 | 520 | |
521 | 521 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
522 | 522 | $this->payment_meta = $this->get_meta(); |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $this->parent_payment = $payment->post_parent; |
532 | 532 | |
533 | 533 | $all_payment_statuses = give_get_payment_statuses(); |
534 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
534 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
535 | 535 | |
536 | 536 | // Items. |
537 | 537 | $this->fees = $this->setup_fees(); |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @param Give_Payment $this Payment object. |
574 | 574 | * @param int $payment_id The ID of the payment. |
575 | 575 | */ |
576 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
576 | + do_action('give_setup_payment', $this, $payment_id); |
|
577 | 577 | |
578 | 578 | return true; |
579 | 579 | } |
@@ -591,8 +591,8 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return void |
593 | 593 | */ |
594 | - public function update_payment_setup( $payment_id ) { |
|
595 | - $this->setup_payment( $payment_id ); |
|
594 | + public function update_payment_setup($payment_id) { |
|
595 | + $this->setup_payment($payment_id); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -607,24 +607,24 @@ discard block |
||
607 | 607 | |
608 | 608 | // Construct the payment title. |
609 | 609 | $payment_title = ''; |
610 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
611 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
612 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
610 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
611 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
612 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
613 | 613 | $payment_title = $this->first_name; |
614 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
614 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
615 | 615 | $payment_title = $this->email; |
616 | 616 | } |
617 | 617 | |
618 | 618 | // Set Key. |
619 | - if ( empty( $this->key ) ) { |
|
619 | + if (empty($this->key)) { |
|
620 | 620 | |
621 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
622 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
621 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
622 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
623 | 623 | $this->pending['key'] = $this->key; |
624 | 624 | } |
625 | 625 | |
626 | 626 | // Set IP. |
627 | - if ( empty( $this->ip ) ) { |
|
627 | + if (empty($this->ip)) { |
|
628 | 628 | |
629 | 629 | $this->ip = give_get_ip(); |
630 | 630 | $this->pending['ip'] = $this->ip; |
@@ -651,63 +651,63 @@ discard block |
||
651 | 651 | 'fees' => $this->fees, |
652 | 652 | ); |
653 | 653 | |
654 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
654 | + $args = apply_filters('give_insert_payment_args', array( |
|
655 | 655 | 'post_title' => $payment_title, |
656 | 656 | 'post_status' => $this->status, |
657 | 657 | 'post_type' => 'give_payment', |
658 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
659 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
658 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
659 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
660 | 660 | 'post_parent' => $this->parent_payment, |
661 | - ), $payment_data ); |
|
661 | + ), $payment_data); |
|
662 | 662 | |
663 | 663 | // Create a blank payment |
664 | - $payment_id = wp_insert_post( $args ); |
|
664 | + $payment_id = wp_insert_post($args); |
|
665 | 665 | |
666 | - if ( ! empty( $payment_id ) ) { |
|
666 | + if ( ! empty($payment_id)) { |
|
667 | 667 | |
668 | 668 | $this->ID = $payment_id; |
669 | 669 | $this->_ID = $payment_id; |
670 | 670 | |
671 | 671 | $customer = new stdClass; |
672 | 672 | |
673 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
674 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
673 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
674 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
675 | 675 | |
676 | 676 | // Customer is logged in but used a different email to purchase with so assign to their customer record |
677 | - if ( ! empty( $customer->id ) && $this->email != $customer->email ) { |
|
678 | - $customer->add_email( $this->email ); |
|
677 | + if ( ! empty($customer->id) && $this->email != $customer->email) { |
|
678 | + $customer->add_email($this->email); |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
682 | - if ( empty( $customer->id ) ) { |
|
683 | - $customer = new Give_Customer( $this->email ); |
|
682 | + if (empty($customer->id)) { |
|
683 | + $customer = new Give_Customer($this->email); |
|
684 | 684 | } |
685 | 685 | |
686 | - if ( empty( $customer->id ) ) { |
|
686 | + if (empty($customer->id)) { |
|
687 | 687 | |
688 | 688 | $customer_data = array( |
689 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
689 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
690 | 690 | 'email' => $this->email, |
691 | 691 | 'user_id' => $this->user_id, |
692 | 692 | ); |
693 | 693 | |
694 | - $customer->create( $customer_data ); |
|
694 | + $customer->create($customer_data); |
|
695 | 695 | |
696 | 696 | } |
697 | 697 | |
698 | 698 | $this->customer_id = $customer->id; |
699 | 699 | $this->pending['customer_id'] = $this->customer_id; |
700 | - $customer->attach_payment( $this->ID, false ); |
|
700 | + $customer->attach_payment($this->ID, false); |
|
701 | 701 | |
702 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
703 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
704 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
705 | - foreach ( $this->fees as $fee ) { |
|
706 | - $this->increase_fees( $fee['amount'] ); |
|
702 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
703 | + if ( ! empty($this->payment_meta['fees'])) { |
|
704 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
705 | + foreach ($this->fees as $fee) { |
|
706 | + $this->increase_fees($fee['amount']); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | |
710 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
710 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
711 | 711 | $this->new = true; |
712 | 712 | } |
713 | 713 | |
@@ -729,11 +729,11 @@ discard block |
||
729 | 729 | $saved = false; |
730 | 730 | |
731 | 731 | // Must have an ID. |
732 | - if ( empty( $this->ID ) ) { |
|
732 | + if (empty($this->ID)) { |
|
733 | 733 | |
734 | 734 | $payment_id = $this->insert_payment(); |
735 | 735 | |
736 | - if ( false === $payment_id ) { |
|
736 | + if (false === $payment_id) { |
|
737 | 737 | $saved = false; |
738 | 738 | } else { |
739 | 739 | $this->ID = $payment_id; |
@@ -741,48 +741,48 @@ discard block |
||
741 | 741 | } |
742 | 742 | |
743 | 743 | // Set ID if not matching. |
744 | - if ( $this->ID !== $this->_ID ) { |
|
744 | + if ($this->ID !== $this->_ID) { |
|
745 | 745 | $this->ID = $this->_ID; |
746 | 746 | } |
747 | 747 | |
748 | 748 | // If we have something pending, let's save it. |
749 | - if ( ! empty( $this->pending ) ) { |
|
749 | + if ( ! empty($this->pending)) { |
|
750 | 750 | |
751 | 751 | $total_increase = 0; |
752 | 752 | $total_decrease = 0; |
753 | 753 | |
754 | - foreach ( $this->pending as $key => $value ) { |
|
754 | + foreach ($this->pending as $key => $value) { |
|
755 | 755 | |
756 | - switch ( $key ) { |
|
756 | + switch ($key) { |
|
757 | 757 | |
758 | 758 | case 'donations': |
759 | 759 | // Update totals for pending donations. |
760 | - foreach ( $this->pending[ $key ] as $item ) { |
|
760 | + foreach ($this->pending[$key] as $item) { |
|
761 | 761 | |
762 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
763 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
762 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
763 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
764 | 764 | |
765 | - switch ( $item['action'] ) { |
|
765 | + switch ($item['action']) { |
|
766 | 766 | |
767 | 767 | case 'add': |
768 | 768 | |
769 | 769 | $price = $item['price']; |
770 | 770 | |
771 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
771 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
772 | 772 | |
773 | 773 | // Add sales logs. |
774 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
774 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
775 | 775 | |
776 | 776 | $y = 0; |
777 | - while ( $y < $quantity ) { |
|
777 | + while ($y < $quantity) { |
|
778 | 778 | |
779 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
780 | - $y ++; |
|
779 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
780 | + $y++; |
|
781 | 781 | } |
782 | 782 | |
783 | - $form = new Give_Donate_Form( $item['id'] ); |
|
784 | - $form->increase_sales( $quantity ); |
|
785 | - $form->increase_earnings( $price ); |
|
783 | + $form = new Give_Donate_Form($item['id']); |
|
784 | + $form->increase_sales($quantity); |
|
785 | + $form->increase_earnings($price); |
|
786 | 786 | |
787 | 787 | $total_increase += $price; |
788 | 788 | } |
@@ -807,15 +807,15 @@ discard block |
||
807 | 807 | ), |
808 | 808 | ); |
809 | 809 | |
810 | - $found_logs = get_posts( $log_args ); |
|
811 | - foreach ( $found_logs as $log ) { |
|
812 | - wp_delete_post( $log->ID, true ); |
|
810 | + $found_logs = get_posts($log_args); |
|
811 | + foreach ($found_logs as $log) { |
|
812 | + wp_delete_post($log->ID, true); |
|
813 | 813 | } |
814 | 814 | |
815 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
816 | - $form = new Give_Donate_Form( $item['id'] ); |
|
817 | - $form->decrease_sales( $quantity ); |
|
818 | - $form->decrease_earnings( $item['amount'] ); |
|
815 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
816 | + $form = new Give_Donate_Form($item['id']); |
|
817 | + $form->decrease_sales($quantity); |
|
818 | + $form->decrease_earnings($item['amount']); |
|
819 | 819 | |
820 | 820 | $total_decrease += $item['amount']; |
821 | 821 | } |
@@ -827,17 +827,17 @@ discard block |
||
827 | 827 | |
828 | 828 | case 'fees': |
829 | 829 | |
830 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
830 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
831 | 831 | break; |
832 | 832 | } |
833 | 833 | |
834 | - if ( empty( $this->pending[ $key ] ) ) { |
|
834 | + if (empty($this->pending[$key])) { |
|
835 | 835 | break; |
836 | 836 | } |
837 | 837 | |
838 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
838 | + foreach ($this->pending[$key] as $fee) { |
|
839 | 839 | |
840 | - switch ( $fee['action'] ) { |
|
840 | + switch ($fee['action']) { |
|
841 | 841 | |
842 | 842 | case 'add': |
843 | 843 | $total_increase += $fee['amount']; |
@@ -853,43 +853,43 @@ discard block |
||
853 | 853 | break; |
854 | 854 | |
855 | 855 | case 'status': |
856 | - $this->update_status( $this->status ); |
|
856 | + $this->update_status($this->status); |
|
857 | 857 | break; |
858 | 858 | |
859 | 859 | case 'gateway': |
860 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
860 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
861 | 861 | break; |
862 | 862 | |
863 | 863 | case 'mode': |
864 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
864 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
865 | 865 | break; |
866 | 866 | |
867 | 867 | case 'transaction_id': |
868 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
868 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
869 | 869 | break; |
870 | 870 | |
871 | 871 | case 'ip': |
872 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
872 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
873 | 873 | break; |
874 | 874 | |
875 | 875 | case 'customer_id': |
876 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
876 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
877 | 877 | break; |
878 | 878 | |
879 | 879 | case 'user_id': |
880 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
880 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
881 | 881 | break; |
882 | 882 | |
883 | 883 | case 'form_title': |
884 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
884 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
885 | 885 | break; |
886 | 886 | |
887 | 887 | case 'form_id': |
888 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
888 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
889 | 889 | break; |
890 | 890 | |
891 | 891 | case 'price_id': |
892 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
892 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
893 | 893 | break; |
894 | 894 | |
895 | 895 | case 'first_name': |
@@ -905,15 +905,15 @@ discard block |
||
905 | 905 | break; |
906 | 906 | |
907 | 907 | case 'email': |
908 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
908 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
909 | 909 | break; |
910 | 910 | |
911 | 911 | case 'key': |
912 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
912 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
913 | 913 | break; |
914 | 914 | |
915 | 915 | case 'number': |
916 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
916 | + $this->update_meta('_give_payment_number', $this->number); |
|
917 | 917 | break; |
918 | 918 | |
919 | 919 | case 'date': |
@@ -923,11 +923,11 @@ discard block |
||
923 | 923 | 'edit_date' => true, |
924 | 924 | ); |
925 | 925 | |
926 | - wp_update_post( $args ); |
|
926 | + wp_update_post($args); |
|
927 | 927 | break; |
928 | 928 | |
929 | 929 | case 'completed_date': |
930 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
930 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
931 | 931 | break; |
932 | 932 | |
933 | 933 | case 'parent_payment': |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | 'post_parent' => $this->parent_payment, |
937 | 937 | ); |
938 | 938 | |
939 | - wp_update_post( $args ); |
|
939 | + wp_update_post($args); |
|
940 | 940 | break; |
941 | 941 | |
942 | 942 | default: |
@@ -947,33 +947,33 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @param Give_Payment $this Payment object. |
949 | 949 | */ |
950 | - do_action( 'give_payment_save', $this, $key ); |
|
950 | + do_action('give_payment_save', $this, $key); |
|
951 | 951 | break; |
952 | 952 | } |
953 | 953 | } |
954 | 954 | |
955 | - if ( 'pending' !== $this->status ) { |
|
955 | + if ('pending' !== $this->status) { |
|
956 | 956 | |
957 | - $customer = new Give_Customer( $this->customer_id ); |
|
957 | + $customer = new Give_Customer($this->customer_id); |
|
958 | 958 | |
959 | 959 | $total_change = $total_increase - $total_decrease; |
960 | - if ( $total_change < 0 ) { |
|
960 | + if ($total_change < 0) { |
|
961 | 961 | |
962 | - $total_change = - ( $total_change ); |
|
962 | + $total_change = - ($total_change); |
|
963 | 963 | // Decrease the customer's donation stats. |
964 | - $customer->decrease_value( $total_change ); |
|
965 | - give_decrease_total_earnings( $total_change ); |
|
964 | + $customer->decrease_value($total_change); |
|
965 | + give_decrease_total_earnings($total_change); |
|
966 | 966 | |
967 | - } elseif ( $total_change > 0 ) { |
|
967 | + } elseif ($total_change > 0) { |
|
968 | 968 | |
969 | 969 | // Increase the customer's donation stats. |
970 | - $customer->increase_value( $total_change ); |
|
971 | - give_increase_total_earnings( $total_change ); |
|
970 | + $customer->increase_value($total_change); |
|
971 | + give_increase_total_earnings($total_change); |
|
972 | 972 | |
973 | 973 | } |
974 | 974 | } |
975 | 975 | |
976 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
976 | + $this->update_meta('_give_payment_total', $this->total); |
|
977 | 977 | |
978 | 978 | $new_meta = array( |
979 | 979 | 'form_title' => $this->form_title, |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | ); |
986 | 986 | |
987 | 987 | $meta = $this->get_meta(); |
988 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
988 | + $merged_meta = array_merge($meta, $new_meta); |
|
989 | 989 | |
990 | 990 | // Only save the payment meta if it's changed. |
991 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
992 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
993 | - if ( false !== $updated ) { |
|
991 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
992 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
993 | + if (false !== $updated) { |
|
994 | 994 | $saved = true; |
995 | 995 | } |
996 | 996 | } |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | $saved = true; |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - if ( true === $saved ) { |
|
1003 | - $this->setup_payment( $this->ID ); |
|
1002 | + if (true === $saved) { |
|
1003 | + $this->setup_payment($this->ID); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | return $saved; |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | * |
1019 | 1019 | * @return bool True when successful, false otherwise |
1020 | 1020 | */ |
1021 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
1021 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
1022 | 1022 | |
1023 | - $donation = new Give_Donate_Form( $form_id ); |
|
1023 | + $donation = new Give_Donate_Form($form_id); |
|
1024 | 1024 | |
1025 | 1025 | // Bail if this post isn't a give donation form. |
1026 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
1026 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
1027 | 1027 | return false; |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1034,59 +1034,59 @@ discard block |
||
1034 | 1034 | 'fees' => array(), |
1035 | 1035 | ); |
1036 | 1036 | |
1037 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
1037 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
1038 | 1038 | |
1039 | 1039 | // Allow overriding the price. |
1040 | - if ( false !== $args['price'] ) { |
|
1040 | + if (false !== $args['price']) { |
|
1041 | 1041 | $item_price = $args['price']; |
1042 | 1042 | } else { |
1043 | 1043 | |
1044 | 1044 | // Deal with variable pricing. |
1045 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
1046 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1045 | + if (give_has_variable_prices($donation->ID)) { |
|
1046 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1047 | 1047 | $item_price = ''; |
1048 | 1048 | // Loop through prices. |
1049 | - foreach ( $prices as $price ) { |
|
1049 | + foreach ($prices as $price) { |
|
1050 | 1050 | // Find a match between price_id and level_id. |
1051 | 1051 | // First verify array keys exists THEN make the match. |
1052 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
1052 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
1053 | 1053 | && $args['price_id'] == $price['_give_id']['level_id'] |
1054 | 1054 | ) { |
1055 | 1055 | $item_price = $price['_give_amount']; |
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | // Fallback to the lowest price point. |
1059 | - if ( $item_price == '' ) { |
|
1060 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
1061 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1059 | + if ($item_price == '') { |
|
1060 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
1061 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1062 | 1062 | } |
1063 | 1063 | } else { |
1064 | 1064 | // Simple form price. |
1065 | - $item_price = give_get_form_price( $donation->ID ); |
|
1065 | + $item_price = give_get_form_price($donation->ID); |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | // Sanitizing the price here so we don't have a dozen calls later. |
1070 | - $item_price = give_sanitize_amount( $item_price ); |
|
1071 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
1070 | + $item_price = give_sanitize_amount($item_price); |
|
1071 | + $total = round($item_price, give_currency_decimal_filter()); |
|
1072 | 1072 | |
1073 | 1073 | // Add Options. |
1074 | 1074 | $default_options = array(); |
1075 | - if ( false !== $args['price_id'] ) { |
|
1075 | + if (false !== $args['price_id']) { |
|
1076 | 1076 | $default_options['price_id'] = (int) $args['price_id']; |
1077 | 1077 | } |
1078 | - $options = wp_parse_args( $options, $default_options ); |
|
1078 | + $options = wp_parse_args($options, $default_options); |
|
1079 | 1079 | |
1080 | 1080 | // Do not allow totals to go negative. |
1081 | - if ( $total < 0 ) { |
|
1081 | + if ($total < 0) { |
|
1082 | 1082 | $total = 0; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | $donation = array( |
1086 | 1086 | 'name' => $donation->post_title, |
1087 | 1087 | 'id' => $donation->ID, |
1088 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
1089 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
1088 | + 'price' => round($total, give_currency_decimal_filter()), |
|
1089 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
1090 | 1090 | 'fees' => $args['fees'], |
1091 | 1091 | 'price_id' => $args['price_id'], |
1092 | 1092 | 'action' => 'add', |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | $this->pending['donations'][] = $donation; |
1097 | 1097 | |
1098 | - $this->increase_subtotal( $total ); |
|
1098 | + $this->increase_subtotal($total); |
|
1099 | 1099 | |
1100 | 1100 | return true; |
1101 | 1101 | |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * |
1113 | 1113 | * @return bool If the item was removed or not |
1114 | 1114 | */ |
1115 | - public function remove_donation( $form_id, $args = array() ) { |
|
1115 | + public function remove_donation($form_id, $args = array()) { |
|
1116 | 1116 | |
1117 | 1117 | // Set some defaults. |
1118 | 1118 | $defaults = array( |
@@ -1120,12 +1120,12 @@ discard block |
||
1120 | 1120 | 'price' => false, |
1121 | 1121 | 'price_id' => false, |
1122 | 1122 | ); |
1123 | - $args = wp_parse_args( $args, $defaults ); |
|
1123 | + $args = wp_parse_args($args, $defaults); |
|
1124 | 1124 | |
1125 | - $form = new Give_Donate_Form( $form_id ); |
|
1125 | + $form = new Give_Donate_Form($form_id); |
|
1126 | 1126 | |
1127 | 1127 | // Bail if this post isn't a valid give donation form. |
1128 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1128 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1129 | 1129 | return false; |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | |
1139 | 1139 | $this->pending['donations'][] = $pending_args; |
1140 | 1140 | |
1141 | - $this->decrease_subtotal( $this->total ); |
|
1141 | + $this->decrease_subtotal($this->total); |
|
1142 | 1142 | |
1143 | 1143 | return true; |
1144 | 1144 | } |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return bool If the fee was added |
1156 | 1156 | */ |
1157 | - public function add_fee( $args, $global = true ) { |
|
1157 | + public function add_fee($args, $global = true) { |
|
1158 | 1158 | |
1159 | 1159 | $default_args = array( |
1160 | 1160 | 'label' => '', |
@@ -1164,15 +1164,15 @@ discard block |
||
1164 | 1164 | 'price_id' => 0, |
1165 | 1165 | ); |
1166 | 1166 | |
1167 | - $fee = wp_parse_args( $args, $default_args ); |
|
1167 | + $fee = wp_parse_args($args, $default_args); |
|
1168 | 1168 | $this->fees[] = $fee; |
1169 | 1169 | |
1170 | 1170 | $added_fee = $fee; |
1171 | 1171 | $added_fee['action'] = 'add'; |
1172 | 1172 | $this->pending['fees'][] = $added_fee; |
1173 | - reset( $this->fees ); |
|
1173 | + reset($this->fees); |
|
1174 | 1174 | |
1175 | - $this->increase_fees( $fee['amount'] ); |
|
1175 | + $this->increase_fees($fee['amount']); |
|
1176 | 1176 | |
1177 | 1177 | return true; |
1178 | 1178 | } |
@@ -1187,11 +1187,11 @@ discard block |
||
1187 | 1187 | * |
1188 | 1188 | * @return bool If the fee was removed successfully |
1189 | 1189 | */ |
1190 | - public function remove_fee( $key ) { |
|
1190 | + public function remove_fee($key) { |
|
1191 | 1191 | $removed = false; |
1192 | 1192 | |
1193 | - if ( is_numeric( $key ) ) { |
|
1194 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
1193 | + if (is_numeric($key)) { |
|
1194 | + $removed = $this->remove_fee_by('index', $key); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | return $removed; |
@@ -1210,55 +1210,55 @@ discard block |
||
1210 | 1210 | * |
1211 | 1211 | * @return boolean If the item is removed |
1212 | 1212 | */ |
1213 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
1213 | + public function remove_fee_by($key, $value, $global = false) { |
|
1214 | 1214 | |
1215 | - $allowed_fee_keys = apply_filters( 'give_payment_fee_keys', array( |
|
1215 | + $allowed_fee_keys = apply_filters('give_payment_fee_keys', array( |
|
1216 | 1216 | 'index', |
1217 | 1217 | 'label', |
1218 | 1218 | 'amount', |
1219 | 1219 | 'type', |
1220 | - ) ); |
|
1220 | + )); |
|
1221 | 1221 | |
1222 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
1222 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
1223 | 1223 | return false; |
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | $removed = false; |
1227 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
1227 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
1228 | 1228 | |
1229 | - $removed_fee = $this->fees[ $value ]; |
|
1229 | + $removed_fee = $this->fees[$value]; |
|
1230 | 1230 | $removed_fee['action'] = 'remove'; |
1231 | 1231 | $this->pending['fees'][] = $removed_fee; |
1232 | 1232 | |
1233 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1233 | + $this->decrease_fees($removed_fee['amount']); |
|
1234 | 1234 | |
1235 | - unset( $this->fees[ $value ] ); |
|
1235 | + unset($this->fees[$value]); |
|
1236 | 1236 | $removed = true; |
1237 | 1237 | |
1238 | - } elseif ( 'index' !== $key ) { |
|
1238 | + } elseif ('index' !== $key) { |
|
1239 | 1239 | |
1240 | - foreach ( $this->fees as $index => $fee ) { |
|
1240 | + foreach ($this->fees as $index => $fee) { |
|
1241 | 1241 | |
1242 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
1242 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
1243 | 1243 | |
1244 | 1244 | $removed_fee = $fee; |
1245 | 1245 | $removed_fee['action'] = 'remove'; |
1246 | 1246 | $this->pending['fees'][] = $removed_fee; |
1247 | 1247 | |
1248 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1248 | + $this->decrease_fees($removed_fee['amount']); |
|
1249 | 1249 | |
1250 | - unset( $this->fees[ $index ] ); |
|
1250 | + unset($this->fees[$index]); |
|
1251 | 1251 | $removed = true; |
1252 | 1252 | |
1253 | - if ( false === $global ) { |
|
1253 | + if (false === $global) { |
|
1254 | 1254 | break; |
1255 | 1255 | } |
1256 | 1256 | } |
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - if ( true === $removed ) { |
|
1261 | - $this->fees = array_values( $this->fees ); |
|
1260 | + if (true === $removed) { |
|
1261 | + $this->fees = array_values($this->fees); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | return $removed; |
@@ -1274,14 +1274,14 @@ discard block |
||
1274 | 1274 | * |
1275 | 1275 | * @return array The Fees for the type specified |
1276 | 1276 | */ |
1277 | - public function get_fees( $type = 'all' ) { |
|
1277 | + public function get_fees($type = 'all') { |
|
1278 | 1278 | $fees = array(); |
1279 | 1279 | |
1280 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
1280 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
1281 | 1281 | |
1282 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
1282 | + foreach ($this->fees as $fee_id => $fee) { |
|
1283 | 1283 | |
1284 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1284 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
1285 | 1285 | continue; |
1286 | 1286 | } |
1287 | 1287 | |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
1294 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | /** |
@@ -1304,13 +1304,13 @@ discard block |
||
1304 | 1304 | * |
1305 | 1305 | * @return void |
1306 | 1306 | */ |
1307 | - public function add_note( $note = false ) { |
|
1307 | + public function add_note($note = false) { |
|
1308 | 1308 | // Bail if no note specified. |
1309 | - if ( ! $note ) { |
|
1309 | + if ( ! $note) { |
|
1310 | 1310 | return false; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - give_insert_payment_note( $this->ID, $note ); |
|
1313 | + give_insert_payment_note($this->ID, $note); |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | /** |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | * |
1324 | 1324 | * @return void |
1325 | 1325 | */ |
1326 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1326 | + private function increase_subtotal($amount = 0.00) { |
|
1327 | 1327 | $amount = (float) $amount; |
1328 | 1328 | $this->subtotal += $amount; |
1329 | 1329 | |
@@ -1340,11 +1340,11 @@ discard block |
||
1340 | 1340 | * |
1341 | 1341 | * @return void |
1342 | 1342 | */ |
1343 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1343 | + private function decrease_subtotal($amount = 0.00) { |
|
1344 | 1344 | $amount = (float) $amount; |
1345 | 1345 | $this->subtotal -= $amount; |
1346 | 1346 | |
1347 | - if ( $this->subtotal < 0 ) { |
|
1347 | + if ($this->subtotal < 0) { |
|
1348 | 1348 | $this->subtotal = 0; |
1349 | 1349 | } |
1350 | 1350 | |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | * |
1362 | 1362 | * @return void |
1363 | 1363 | */ |
1364 | - private function increase_fees( $amount = 0.00 ) { |
|
1364 | + private function increase_fees($amount = 0.00) { |
|
1365 | 1365 | $amount = (float) $amount; |
1366 | 1366 | $this->fees_total += $amount; |
1367 | 1367 | |
@@ -1378,11 +1378,11 @@ discard block |
||
1378 | 1378 | * |
1379 | 1379 | * @return void |
1380 | 1380 | */ |
1381 | - private function decrease_fees( $amount = 0.00 ) { |
|
1381 | + private function decrease_fees($amount = 0.00) { |
|
1382 | 1382 | $amount = (float) $amount; |
1383 | 1383 | $this->fees_total -= $amount; |
1384 | 1384 | |
1385 | - if ( $this->fees_total < 0 ) { |
|
1385 | + if ($this->fees_total < 0) { |
|
1386 | 1386 | $this->fees_total = 0; |
1387 | 1387 | } |
1388 | 1388 | |
@@ -1411,24 +1411,24 @@ discard block |
||
1411 | 1411 | * |
1412 | 1412 | * @return bool $updated Returns if the status was successfully updated. |
1413 | 1413 | */ |
1414 | - public function update_status( $status = false ) { |
|
1414 | + public function update_status($status = false) { |
|
1415 | 1415 | |
1416 | 1416 | // standardize the 'complete(d)' status. |
1417 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1417 | + if ($status == 'completed' || $status == 'complete') { |
|
1418 | 1418 | $status = 'publish'; |
1419 | 1419 | } |
1420 | 1420 | |
1421 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1421 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1422 | 1422 | |
1423 | - if ( $old_status === $status ) { |
|
1423 | + if ($old_status === $status) { |
|
1424 | 1424 | return false; // Don't permit status changes that aren't changes. |
1425 | 1425 | } |
1426 | 1426 | |
1427 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1427 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1428 | 1428 | |
1429 | 1429 | $updated = false; |
1430 | 1430 | |
1431 | - if ( $do_change ) { |
|
1431 | + if ($do_change) { |
|
1432 | 1432 | |
1433 | 1433 | /** |
1434 | 1434 | * Fires before changing payment status. |
@@ -1439,21 +1439,21 @@ discard block |
||
1439 | 1439 | * @param string $status The new status. |
1440 | 1440 | * @param string $old_status The old status. |
1441 | 1441 | */ |
1442 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1442 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1443 | 1443 | |
1444 | 1444 | $update_fields = array( |
1445 | 1445 | 'ID' => $this->ID, |
1446 | 1446 | 'post_status' => $status, |
1447 | - 'edit_date' => current_time( 'mysql' ), |
|
1447 | + 'edit_date' => current_time('mysql'), |
|
1448 | 1448 | ); |
1449 | 1449 | |
1450 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1450 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1451 | 1451 | |
1452 | 1452 | $all_payment_statuses = give_get_payment_statuses(); |
1453 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1453 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1454 | 1454 | |
1455 | 1455 | // Process any specific status functions. |
1456 | - switch ( $status ) { |
|
1456 | + switch ($status) { |
|
1457 | 1457 | case 'refunded': |
1458 | 1458 | $this->process_refund(); |
1459 | 1459 | break; |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | * @param string $status The new status. |
1481 | 1481 | * @param string $old_status The old status. |
1482 | 1482 | */ |
1483 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1483 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1484 | 1484 | |
1485 | 1485 | } |
1486 | 1486 | |
@@ -1515,33 +1515,33 @@ discard block |
||
1515 | 1515 | * |
1516 | 1516 | * @return mixed The value from the post meta |
1517 | 1517 | */ |
1518 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1518 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1519 | 1519 | |
1520 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
1520 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
1521 | 1521 | |
1522 | - if ( $meta_key === '_give_payment_meta' ) { |
|
1522 | + if ($meta_key === '_give_payment_meta') { |
|
1523 | 1523 | $meta = (array) $meta; |
1524 | 1524 | |
1525 | - if ( empty( $meta['key'] ) ) { |
|
1525 | + if (empty($meta['key'])) { |
|
1526 | 1526 | $meta['key'] = $this->setup_payment_key(); |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - if ( empty( $meta['form_title'] ) ) { |
|
1529 | + if (empty($meta['form_title'])) { |
|
1530 | 1530 | $meta['form_title'] = $this->setup_form_title(); |
1531 | 1531 | } |
1532 | 1532 | |
1533 | - if ( empty( $meta['email'] ) ) { |
|
1533 | + if (empty($meta['email'])) { |
|
1534 | 1534 | $meta['email'] = $this->setup_email(); |
1535 | 1535 | } |
1536 | 1536 | |
1537 | - if ( empty( $meta['date'] ) ) { |
|
1538 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1537 | + if (empty($meta['date'])) { |
|
1538 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1539 | 1539 | } |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1542 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1543 | 1543 | |
1544 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1544 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | /** |
@@ -1556,23 +1556,23 @@ discard block |
||
1556 | 1556 | * |
1557 | 1557 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1558 | 1558 | */ |
1559 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1560 | - if ( empty( $meta_key ) ) { |
|
1559 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1560 | + if (empty($meta_key)) { |
|
1561 | 1561 | return false; |
1562 | 1562 | } |
1563 | 1563 | |
1564 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
1564 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
1565 | 1565 | |
1566 | 1566 | $current_meta = $this->get_meta(); |
1567 | - $current_meta[ $meta_key ] = $meta_value; |
|
1567 | + $current_meta[$meta_key] = $meta_value; |
|
1568 | 1568 | |
1569 | 1569 | $meta_key = '_give_payment_meta'; |
1570 | 1570 | $meta_value = $current_meta; |
1571 | 1571 | |
1572 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
1572 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
1573 | 1573 | |
1574 | - $meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1575 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
1574 | + $meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1575 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
1576 | 1576 | |
1577 | 1577 | $current_meta = $this->get_meta(); |
1578 | 1578 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1582,9 +1582,9 @@ discard block |
||
1582 | 1582 | |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1585 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1586 | 1586 | |
1587 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1587 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | /** |
@@ -1599,14 +1599,14 @@ discard block |
||
1599 | 1599 | $process_refund = true; |
1600 | 1600 | |
1601 | 1601 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1602 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
1602 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
1603 | 1603 | $process_refund = false; |
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1607 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
1607 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
1608 | 1608 | |
1609 | - if ( false === $process_refund ) { |
|
1609 | + if (false === $process_refund) { |
|
1610 | 1610 | return; |
1611 | 1611 | } |
1612 | 1612 | |
@@ -1617,13 +1617,13 @@ discard block |
||
1617 | 1617 | * |
1618 | 1618 | * @param Give_Payment $this Payment object. |
1619 | 1619 | */ |
1620 | - do_action( 'give_pre_refund_payment', $this ); |
|
1620 | + do_action('give_pre_refund_payment', $this); |
|
1621 | 1621 | |
1622 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
1623 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
1624 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
1622 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
1623 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
1624 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
1625 | 1625 | |
1626 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1626 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1627 | 1627 | $this->delete_sales_logs(); |
1628 | 1628 | |
1629 | 1629 | // @todo: Refresh only range related stat cache |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | * |
1637 | 1637 | * @param Give_Payment $this Payment object. |
1638 | 1638 | */ |
1639 | - do_action( 'give_post_refund_payment', $this ); |
|
1639 | + do_action('give_post_refund_payment', $this); |
|
1640 | 1640 | } |
1641 | 1641 | |
1642 | 1642 | /** |
@@ -1663,26 +1663,26 @@ discard block |
||
1663 | 1663 | $process_pending = true; |
1664 | 1664 | |
1665 | 1665 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1666 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
1666 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
1667 | 1667 | $process_pending = false; |
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1671 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
1671 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
1672 | 1672 | |
1673 | - if ( false === $process_pending ) { |
|
1673 | + if (false === $process_pending) { |
|
1674 | 1674 | return; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
1678 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
1679 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
1677 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
1678 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
1679 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
1680 | 1680 | |
1681 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1681 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1682 | 1682 | $this->delete_sales_logs(); |
1683 | 1683 | |
1684 | 1684 | $this->completed_date = false; |
1685 | - $this->update_meta( '_give_completed_date', '' ); |
|
1685 | + $this->update_meta('_give_completed_date', ''); |
|
1686 | 1686 | |
1687 | 1687 | // @todo: Refresh only range related stat cache |
1688 | 1688 | give_delete_donation_stats(); |
@@ -1700,26 +1700,26 @@ discard block |
||
1700 | 1700 | $process_cancelled = true; |
1701 | 1701 | |
1702 | 1702 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1703 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1703 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
1704 | 1704 | $process_cancelled = false; |
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1708 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1708 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
1709 | 1709 | |
1710 | - if ( false === $process_cancelled ) { |
|
1710 | + if (false === $process_cancelled) { |
|
1711 | 1711 | return; |
1712 | 1712 | } |
1713 | 1713 | |
1714 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
1715 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
1716 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
1714 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
1715 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
1716 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
1717 | 1717 | |
1718 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1718 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1719 | 1719 | $this->delete_sales_logs(); |
1720 | 1720 | |
1721 | 1721 | $this->completed_date = false; |
1722 | - $this->update_meta( '_give_completed_date', '' ); |
|
1722 | + $this->update_meta('_give_completed_date', ''); |
|
1723 | 1723 | |
1724 | 1724 | // @todo: Refresh only range related stat cache |
1725 | 1725 | give_delete_donation_stats(); |
@@ -1735,26 +1735,26 @@ discard block |
||
1735 | 1735 | $process_revoked = true; |
1736 | 1736 | |
1737 | 1737 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
1738 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1738 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
1739 | 1739 | $process_revoked = false; |
1740 | 1740 | } |
1741 | 1741 | |
1742 | 1742 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1743 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1743 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
1744 | 1744 | |
1745 | - if ( false === $process_revoked ) { |
|
1745 | + if (false === $process_revoked) { |
|
1746 | 1746 | return; |
1747 | 1747 | } |
1748 | 1748 | |
1749 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
1750 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
1751 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
1749 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
1750 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
1751 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
1752 | 1752 | |
1753 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1753 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1754 | 1754 | $this->delete_sales_logs(); |
1755 | 1755 | |
1756 | 1756 | $this->completed_date = false; |
1757 | - $this->update_meta( '_give_completed_date', '' ); |
|
1757 | + $this->update_meta('_give_completed_date', ''); |
|
1758 | 1758 | |
1759 | 1759 | // @todo: Refresh only range related stat cache |
1760 | 1760 | give_delete_donation_stats(); |
@@ -1772,25 +1772,25 @@ discard block |
||
1772 | 1772 | * |
1773 | 1773 | * @return void |
1774 | 1774 | */ |
1775 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1775 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1776 | 1776 | |
1777 | - give_undo_purchase( false, $this->ID ); |
|
1777 | + give_undo_purchase(false, $this->ID); |
|
1778 | 1778 | |
1779 | 1779 | // Decrease store earnings. |
1780 | - if ( true === $alter_store_earnings ) { |
|
1781 | - give_decrease_total_earnings( $this->total ); |
|
1780 | + if (true === $alter_store_earnings) { |
|
1781 | + give_decrease_total_earnings($this->total); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | // Decrement the stats for the customer. |
1785 | - if ( ! empty( $this->customer_id ) ) { |
|
1785 | + if ( ! empty($this->customer_id)) { |
|
1786 | 1786 | |
1787 | - $customer = new Give_Customer( $this->customer_id ); |
|
1787 | + $customer = new Give_Customer($this->customer_id); |
|
1788 | 1788 | |
1789 | - if ( true === $alter_customer_value ) { |
|
1790 | - $customer->decrease_value( $this->total ); |
|
1789 | + if (true === $alter_customer_value) { |
|
1790 | + $customer->decrease_value($this->total); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | - if ( true === $alter_customer_purchase_count ) { |
|
1793 | + if (true === $alter_customer_purchase_count) { |
|
1794 | 1794 | $customer->decrease_purchase_count(); |
1795 | 1795 | } |
1796 | 1796 | } |
@@ -1839,13 +1839,13 @@ discard block |
||
1839 | 1839 | * @return string The date the payment was completed |
1840 | 1840 | */ |
1841 | 1841 | private function setup_completed_date() { |
1842 | - $payment = get_post( $this->ID ); |
|
1842 | + $payment = get_post($this->ID); |
|
1843 | 1843 | |
1844 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1844 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1845 | 1845 | return false; // This payment was never completed. |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1848 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1849 | 1849 | |
1850 | 1850 | return $date; |
1851 | 1851 | } |
@@ -1859,7 +1859,7 @@ discard block |
||
1859 | 1859 | * @return string The payment mode |
1860 | 1860 | */ |
1861 | 1861 | private function setup_mode() { |
1862 | - return $this->get_meta( '_give_payment_mode' ); |
|
1862 | + return $this->get_meta('_give_payment_mode'); |
|
1863 | 1863 | } |
1864 | 1864 | |
1865 | 1865 | /** |
@@ -1871,19 +1871,19 @@ discard block |
||
1871 | 1871 | * @return float The payment total |
1872 | 1872 | */ |
1873 | 1873 | private function setup_total() { |
1874 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1874 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1875 | 1875 | |
1876 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
1877 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
1878 | - $meta = maybe_unserialize( $meta ); |
|
1876 | + if (empty($amount) && '0.00' != $amount) { |
|
1877 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
1878 | + $meta = maybe_unserialize($meta); |
|
1879 | 1879 | |
1880 | - if ( isset( $meta['amount'] ) ) { |
|
1880 | + if (isset($meta['amount'])) { |
|
1881 | 1881 | $amount = $meta['amount']; |
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | |
1885 | 1885 | |
1886 | - return round( floatval( $amount ), give_currency_decimal_filter() ); |
|
1886 | + return round(floatval($amount), give_currency_decimal_filter()); |
|
1887 | 1887 | } |
1888 | 1888 | |
1889 | 1889 | /** |
@@ -1911,9 +1911,9 @@ discard block |
||
1911 | 1911 | private function setup_fees_total() { |
1912 | 1912 | $fees_total = (float) 0.00; |
1913 | 1913 | |
1914 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1915 | - if ( ! empty( $payment_fees ) ) { |
|
1916 | - foreach ( $payment_fees as $fee ) { |
|
1914 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1915 | + if ( ! empty($payment_fees)) { |
|
1916 | + foreach ($payment_fees as $fee) { |
|
1917 | 1917 | $fees_total += (float) $fee['amount']; |
1918 | 1918 | } |
1919 | 1919 | } |
@@ -1931,7 +1931,7 @@ discard block |
||
1931 | 1931 | * @return string The currency for the payment |
1932 | 1932 | */ |
1933 | 1933 | private function setup_currency() { |
1934 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
1934 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
1935 | 1935 | |
1936 | 1936 | return $currency; |
1937 | 1937 | } |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | * @return array The Fees |
1946 | 1946 | */ |
1947 | 1947 | private function setup_fees() { |
1948 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1948 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1949 | 1949 | |
1950 | 1950 | return $payment_fees; |
1951 | 1951 | } |
@@ -1959,7 +1959,7 @@ discard block |
||
1959 | 1959 | * @return string The gateway |
1960 | 1960 | */ |
1961 | 1961 | private function setup_gateway() { |
1962 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1962 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1963 | 1963 | |
1964 | 1964 | return $gateway; |
1965 | 1965 | } |
@@ -1973,11 +1973,11 @@ discard block |
||
1973 | 1973 | * @return string The donation ID |
1974 | 1974 | */ |
1975 | 1975 | private function setup_transaction_id() { |
1976 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1976 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1977 | 1977 | |
1978 | - if ( empty( $transaction_id ) ) { |
|
1978 | + if (empty($transaction_id)) { |
|
1979 | 1979 | $gateway = $this->gateway; |
1980 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1980 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1981 | 1981 | } |
1982 | 1982 | |
1983 | 1983 | return $transaction_id; |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | * @return string The IP address for the payment |
1993 | 1993 | */ |
1994 | 1994 | private function setup_ip() { |
1995 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
1995 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
1996 | 1996 | |
1997 | 1997 | return $ip; |
1998 | 1998 | } |
@@ -2006,7 +2006,7 @@ discard block |
||
2006 | 2006 | * @return int The Customer ID |
2007 | 2007 | */ |
2008 | 2008 | private function setup_customer_id() { |
2009 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
2009 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
2010 | 2010 | |
2011 | 2011 | return $customer_id; |
2012 | 2012 | } |
@@ -2020,7 +2020,7 @@ discard block |
||
2020 | 2020 | * @return int The User ID |
2021 | 2021 | */ |
2022 | 2022 | private function setup_user_id() { |
2023 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
2023 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
2024 | 2024 | |
2025 | 2025 | return $user_id; |
2026 | 2026 | } |
@@ -2034,10 +2034,10 @@ discard block |
||
2034 | 2034 | * @return string The email address for the payment |
2035 | 2035 | */ |
2036 | 2036 | private function setup_email() { |
2037 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
2037 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
2038 | 2038 | |
2039 | - if ( empty( $email ) ) { |
|
2040 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
2039 | + if (empty($email)) { |
|
2040 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
2041 | 2041 | } |
2042 | 2042 | |
2043 | 2043 | return $email; |
@@ -2057,15 +2057,15 @@ discard block |
||
2057 | 2057 | 'last_name' => $this->last_name, |
2058 | 2058 | ); |
2059 | 2059 | |
2060 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
2061 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
2060 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
2061 | + $user_info = wp_parse_args($user_info, $defaults); |
|
2062 | 2062 | |
2063 | - if ( empty( $user_info ) ) { |
|
2063 | + if (empty($user_info)) { |
|
2064 | 2064 | // Get the customer, but only if it's been created. |
2065 | - $customer = new Give_Customer( $this->customer_id ); |
|
2065 | + $customer = new Give_Customer($this->customer_id); |
|
2066 | 2066 | |
2067 | - if ( $customer->id > 0 ) { |
|
2068 | - $name = explode( ' ', $customer->name, 2 ); |
|
2067 | + if ($customer->id > 0) { |
|
2068 | + $name = explode(' ', $customer->name, 2); |
|
2069 | 2069 | $user_info = array( |
2070 | 2070 | 'first_name' => $name[0], |
2071 | 2071 | 'last_name' => $name[1], |
@@ -2075,29 +2075,29 @@ discard block |
||
2075 | 2075 | } |
2076 | 2076 | } else { |
2077 | 2077 | // Get the customer, but only if it's been created. |
2078 | - $customer = new Give_Customer( $this->customer_id ); |
|
2079 | - if ( $customer->id > 0 ) { |
|
2080 | - foreach ( $user_info as $key => $value ) { |
|
2081 | - if ( ! empty( $value ) ) { |
|
2078 | + $customer = new Give_Customer($this->customer_id); |
|
2079 | + if ($customer->id > 0) { |
|
2080 | + foreach ($user_info as $key => $value) { |
|
2081 | + if ( ! empty($value)) { |
|
2082 | 2082 | continue; |
2083 | 2083 | } |
2084 | 2084 | |
2085 | - switch ( $key ) { |
|
2085 | + switch ($key) { |
|
2086 | 2086 | case 'first_name': |
2087 | - $name = explode( ' ', $customer->name, 2 ); |
|
2087 | + $name = explode(' ', $customer->name, 2); |
|
2088 | 2088 | |
2089 | - $user_info[ $key ] = $name[0]; |
|
2089 | + $user_info[$key] = $name[0]; |
|
2090 | 2090 | break; |
2091 | 2091 | |
2092 | 2092 | case 'last_name': |
2093 | - $name = explode( ' ', $customer->name, 2 ); |
|
2094 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
2093 | + $name = explode(' ', $customer->name, 2); |
|
2094 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
2095 | 2095 | |
2096 | - $user_info[ $key ] = $last_name; |
|
2096 | + $user_info[$key] = $last_name; |
|
2097 | 2097 | break; |
2098 | 2098 | |
2099 | 2099 | case 'email': |
2100 | - $user_info[ $key ] = $customer->email; |
|
2100 | + $user_info[$key] = $customer->email; |
|
2101 | 2101 | break; |
2102 | 2102 | } |
2103 | 2103 | } |
@@ -2118,7 +2118,7 @@ discard block |
||
2118 | 2118 | */ |
2119 | 2119 | private function setup_address() { |
2120 | 2120 | |
2121 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
2121 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
2122 | 2122 | 'line1' => '', |
2123 | 2123 | 'line2' => '', |
2124 | 2124 | 'city' => '', |
@@ -2140,7 +2140,7 @@ discard block |
||
2140 | 2140 | */ |
2141 | 2141 | private function setup_form_title() { |
2142 | 2142 | |
2143 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
2143 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
2144 | 2144 | |
2145 | 2145 | return $form_id; |
2146 | 2146 | } |
@@ -2155,7 +2155,7 @@ discard block |
||
2155 | 2155 | */ |
2156 | 2156 | private function setup_form_id() { |
2157 | 2157 | |
2158 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
2158 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
2159 | 2159 | |
2160 | 2160 | return $form_id; |
2161 | 2161 | } |
@@ -2169,7 +2169,7 @@ discard block |
||
2169 | 2169 | * @return int The Form Price ID |
2170 | 2170 | */ |
2171 | 2171 | private function setup_price_id() { |
2172 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
2172 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
2173 | 2173 | |
2174 | 2174 | return $price_id; |
2175 | 2175 | } |
@@ -2183,7 +2183,7 @@ discard block |
||
2183 | 2183 | * @return string The Payment Key |
2184 | 2184 | */ |
2185 | 2185 | private function setup_payment_key() { |
2186 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
2186 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
2187 | 2187 | |
2188 | 2188 | return $key; |
2189 | 2189 | } |
@@ -2199,11 +2199,11 @@ discard block |
||
2199 | 2199 | private function setup_payment_number() { |
2200 | 2200 | $number = $this->ID; |
2201 | 2201 | |
2202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
2202 | + if (give_get_option('enable_sequential')) { |
|
2203 | 2203 | |
2204 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
2204 | + $number = $this->get_meta('_give_payment_number', true); |
|
2205 | 2205 | |
2206 | - if ( ! $number ) { |
|
2206 | + if ( ! $number) { |
|
2207 | 2207 | |
2208 | 2208 | $number = $this->ID; |
2209 | 2209 | |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | * @return array The payment object as an array |
2222 | 2222 | */ |
2223 | 2223 | public function array_convert() { |
2224 | - return get_object_vars( $this ); |
|
2224 | + return get_object_vars($this); |
|
2225 | 2225 | } |
2226 | 2226 | |
2227 | 2227 | |
@@ -2234,7 +2234,7 @@ discard block |
||
2234 | 2234 | * @return bool |
2235 | 2235 | */ |
2236 | 2236 | public function is_completed() { |
2237 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
2237 | + return ('publish' === $this->status && $this->completed_date); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | /** |
@@ -2246,7 +2246,7 @@ discard block |
||
2246 | 2246 | * @return string Date payment was completed |
2247 | 2247 | */ |
2248 | 2248 | private function get_completed_date() { |
2249 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
2249 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | 2252 | /** |
@@ -2258,7 +2258,7 @@ discard block |
||
2258 | 2258 | * @return float Payment subtotal |
2259 | 2259 | */ |
2260 | 2260 | private function get_subtotal() { |
2261 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
2261 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
2262 | 2262 | } |
2263 | 2263 | |
2264 | 2264 | /** |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | * @return string Payment currency code |
2271 | 2271 | */ |
2272 | 2272 | private function get_currency() { |
2273 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
2273 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
2274 | 2274 | } |
2275 | 2275 | |
2276 | 2276 | /** |
@@ -2282,7 +2282,7 @@ discard block |
||
2282 | 2282 | * @return string Gateway used |
2283 | 2283 | */ |
2284 | 2284 | private function get_gateway() { |
2285 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
2285 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
2286 | 2286 | } |
2287 | 2287 | |
2288 | 2288 | /** |
@@ -2294,7 +2294,7 @@ discard block |
||
2294 | 2294 | * @return string Donation ID from merchant processor |
2295 | 2295 | */ |
2296 | 2296 | private function get_transaction_id() { |
2297 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
2297 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
2298 | 2298 | } |
2299 | 2299 | |
2300 | 2300 | /** |
@@ -2306,7 +2306,7 @@ discard block |
||
2306 | 2306 | * @return string Payment IP address |
2307 | 2307 | */ |
2308 | 2308 | private function get_ip() { |
2309 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
2309 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | /** |
@@ -2318,7 +2318,7 @@ discard block |
||
2318 | 2318 | * @return int Payment customer ID |
2319 | 2319 | */ |
2320 | 2320 | private function get_customer_id() { |
2321 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
2321 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | /** |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | * @return int Payment user ID |
2331 | 2331 | */ |
2332 | 2332 | private function get_user_id() { |
2333 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
2333 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | /** |
@@ -2342,7 +2342,7 @@ discard block |
||
2342 | 2342 | * @return string Payment customer email |
2343 | 2343 | */ |
2344 | 2344 | private function get_email() { |
2345 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
2345 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
2346 | 2346 | } |
2347 | 2347 | |
2348 | 2348 | /** |
@@ -2354,7 +2354,7 @@ discard block |
||
2354 | 2354 | * @return array Payment user info |
2355 | 2355 | */ |
2356 | 2356 | private function get_user_info() { |
2357 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2357 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
2358 | 2358 | } |
2359 | 2359 | |
2360 | 2360 | /** |
@@ -2366,7 +2366,7 @@ discard block |
||
2366 | 2366 | * @return array Payment billing address |
2367 | 2367 | */ |
2368 | 2368 | private function get_address() { |
2369 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2369 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | /** |
@@ -2378,7 +2378,7 @@ discard block |
||
2378 | 2378 | * @return string Payment key |
2379 | 2379 | */ |
2380 | 2380 | private function get_key() { |
2381 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2381 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | /** |
@@ -2390,7 +2390,7 @@ discard block |
||
2390 | 2390 | * @return string Payment form id |
2391 | 2391 | */ |
2392 | 2392 | private function get_form_id() { |
2393 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2393 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2394 | 2394 | } |
2395 | 2395 | |
2396 | 2396 | /** |
@@ -2402,7 +2402,7 @@ discard block |
||
2402 | 2402 | * @return int|string Payment number |
2403 | 2403 | */ |
2404 | 2404 | private function get_number() { |
2405 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2405 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2406 | 2406 | } |
2407 | 2407 | |
2408 | 2408 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option('thousands_separator', ','); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option('decimal_separator', '.'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -61,67 +61,67 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string $amount Newly sanitized amount |
63 | 63 | */ |
64 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
64 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
65 | 65 | |
66 | 66 | // Bailout. |
67 | - if ( empty( $number ) ) { |
|
67 | + if (empty($number)) { |
|
68 | 68 | return $number; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Remove slash from amount. |
72 | 72 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
73 | 73 | // To prevent notices and warning remove slash from amount/number. |
74 | - $number = wp_unslash( $number ); |
|
74 | + $number = wp_unslash($number); |
|
75 | 75 | |
76 | 76 | $thousand_separator = give_get_price_thousand_separator(); |
77 | 77 | |
78 | 78 | $locale = localeconv(); |
79 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
79 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
80 | 80 | |
81 | 81 | // Remove locale from string |
82 | - if ( ! is_float( $number ) ) { |
|
83 | - $number = str_replace( $decimals, '.', $number ); |
|
82 | + if ( ! is_float($number)) { |
|
83 | + $number = str_replace($decimals, '.', $number); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Remove thousand amount formatting if amount has. |
87 | 87 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
88 | 88 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
89 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
90 | - $number = str_replace( $thousand_separator, '', $number ); |
|
91 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
92 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
89 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
90 | + $number = str_replace($thousand_separator, '', $number); |
|
91 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
92 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Remove non numeric entity before decimal separator. |
96 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
96 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
97 | 97 | $default_dp = give_get_price_decimals(); |
98 | 98 | |
99 | 99 | // Reset negative amount to zero. |
100 | - if ( 0 > $number ) { |
|
101 | - $number = number_format( 0, $default_dp, '.' ); |
|
100 | + if (0 > $number) { |
|
101 | + $number = number_format(0, $default_dp, '.'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // If number does not have decimal then add number of decimals to it. |
105 | 105 | if ( |
106 | - false === strpos( $number, '.' ) |
|
107 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
106 | + false === strpos($number, '.') |
|
107 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
108 | 108 | ) { |
109 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
109 | + $number = number_format($number, $default_dp, '.', ''); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Format number by custom number of decimals. |
113 | - if ( false !== $dp ) { |
|
114 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
115 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
116 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
113 | + if (false !== $dp) { |
|
114 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
115 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
116 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Trim zeros. |
120 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
121 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
120 | + if ($trim_zeros && strstr($number, '.')) { |
|
121 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
124 | + return apply_filters('give_sanitize_amount', $number); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return string $amount Newly formatted amount or Price Not Available |
136 | 136 | */ |
137 | -function give_format_amount( $amount, $decimals = true ) { |
|
138 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
139 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
137 | +function give_format_amount($amount, $decimals = true) { |
|
138 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
139 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
140 | 140 | |
141 | - if ( empty( $amount ) ) { |
|
141 | + if (empty($amount)) { |
|
142 | 142 | $amount = 0; |
143 | 143 | } else { |
144 | 144 | // Sanitize amount before formatting. |
145 | - $amount = give_sanitize_amount( $amount ); |
|
145 | + $amount = give_sanitize_amount($amount); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $decimals = $decimals ? give_get_price_decimals() : 0; |
149 | 149 | |
150 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
150 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
151 | 151 | |
152 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
152 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -166,33 +166,33 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return float|string formatted amount number with large number names. |
168 | 168 | */ |
169 | -function give_human_format_large_amount( $amount ) { |
|
169 | +function give_human_format_large_amount($amount) { |
|
170 | 170 | |
171 | 171 | // Get thousand separator. |
172 | 172 | $thousands_sep = give_get_price_thousand_separator(); |
173 | 173 | |
174 | 174 | // Sanitize amount. |
175 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
175 | + $sanitize_amount = give_sanitize_amount($amount); |
|
176 | 176 | |
177 | 177 | // Explode amount to calculate name of large numbers. |
178 | - $amount_array = explode( $thousands_sep, $amount ); |
|
178 | + $amount_array = explode($thousands_sep, $amount); |
|
179 | 179 | |
180 | 180 | // Calculate amount parts count. |
181 | - $amount_count_parts = count( $amount_array ); |
|
181 | + $amount_count_parts = count($amount_array); |
|
182 | 182 | |
183 | 183 | // Human format amount (default). |
184 | 184 | $human_format_amount = $amount; |
185 | 185 | |
186 | 186 | // Calculate large number formatted amount. |
187 | - if ( 4 < $amount_count_parts ) { |
|
188 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
189 | - } elseif ( 3 < $amount_count_parts ) { |
|
190 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
191 | - } elseif ( 2 < $amount_count_parts ) { |
|
192 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
187 | + if (4 < $amount_count_parts) { |
|
188 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
189 | + } elseif (3 < $amount_count_parts) { |
|
190 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
191 | + } elseif (2 < $amount_count_parts) { |
|
192 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
193 | 193 | } |
194 | 194 | |
195 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
195 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return string $amount Newly formatted amount or Price Not Available |
207 | 207 | */ |
208 | -function give_format_decimal( $amount, $dp = false ) { |
|
208 | +function give_format_decimal($amount, $dp = false) { |
|
209 | 209 | $decimal_separator = give_get_price_decimal_separator(); |
210 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
210 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
211 | 211 | |
212 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
213 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
212 | + if (false !== strpos($formatted_amount, '.')) { |
|
213 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
214 | 214 | } |
215 | 215 | |
216 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
216 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return mixed|string |
228 | 228 | */ |
229 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
229 | +function give_currency_filter($price = '', $currency = '') { |
|
230 | 230 | |
231 | - if ( empty( $currency ) ) { |
|
231 | + if (empty($currency)) { |
|
232 | 232 | $currency = give_get_currency(); |
233 | 233 | } |
234 | 234 | |
235 | - $position = give_get_option( 'currency_position', 'before' ); |
|
235 | + $position = give_get_option('currency_position', 'before'); |
|
236 | 236 | |
237 | 237 | $negative = $price < 0; |
238 | 238 | |
239 | - if ( $negative ) { |
|
239 | + if ($negative) { |
|
240 | 240 | // Remove proceeding "-". |
241 | - $price = substr( $price, 1 ); |
|
241 | + $price = substr($price, 1); |
|
242 | 242 | } |
243 | 243 | |
244 | - $symbol = give_currency_symbol( $currency ); |
|
244 | + $symbol = give_currency_symbol($currency); |
|
245 | 245 | |
246 | - switch ( $currency ) : |
|
246 | + switch ($currency) : |
|
247 | 247 | case 'GBP' : |
248 | 248 | case 'BRL' : |
249 | 249 | case 'EUR' : |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | case 'MAD' : |
273 | 273 | case 'KRW' : |
274 | 274 | case 'ZAR' : |
275 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
275 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
276 | 276 | break; |
277 | 277 | case 'NOK' : |
278 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
278 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
279 | 279 | break; |
280 | 280 | default : |
281 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
281 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
282 | 282 | break; |
283 | 283 | endswitch; |
284 | 284 | |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * and if currency is USD and currency position is after then |
294 | 294 | * filter name will be give_usd_currency_filter_after |
295 | 295 | */ |
296 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
296 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
297 | 297 | |
298 | - if ( $negative ) { |
|
298 | + if ($negative) { |
|
299 | 299 | // Prepend the minus sign before the currency sign. |
300 | - $formatted = '-' . $formatted; |
|
300 | + $formatted = '-'.$formatted; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return $formatted; |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function give_currency_decimal_filter() { |
315 | 315 | |
316 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
316 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
317 | 317 | |
318 | 318 | // Set default number of decimals. |
319 | 319 | $decimals = give_get_price_decimals(); |
320 | 320 | |
321 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
321 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
322 | 322 | |
323 | 323 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
324 | - if ( 1 <= func_num_args() ) { |
|
325 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
324 | + if (1 <= func_num_args()) { |
|
325 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $currency = give_get_currency(); |
329 | 329 | |
330 | - switch ( $currency ) { |
|
330 | + switch ($currency) { |
|
331 | 331 | case 'RIAL' : |
332 | 332 | case 'JPY' : |
333 | 333 | case 'TWD' : |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | break; |
338 | 338 | } |
339 | 339 | |
340 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
340 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
341 | 341 | } |
342 | 342 | |
343 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
344 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
343 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
344 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
345 | 345 | |
346 | 346 | |
347 | 347 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string Date format string |
355 | 355 | */ |
356 | -function give_date_format( $date_context = '' ) { |
|
356 | +function give_date_format($date_context = '') { |
|
357 | 357 | /** |
358 | 358 | * Filter the date context |
359 | 359 | * |
@@ -374,19 +374,19 @@ discard block |
||
374 | 374 | * |
375 | 375 | * } |
376 | 376 | */ |
377 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
377 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
378 | 378 | |
379 | 379 | // Set date format to default date format. |
380 | - $date_format = get_option( 'date_format' ); |
|
380 | + $date_format = get_option('date_format'); |
|
381 | 381 | |
382 | 382 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
383 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
384 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
385 | - ? $date_format_contexts[ $date_context ] |
|
383 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
384 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
385 | + ? $date_format_contexts[$date_context] |
|
386 | 386 | : $date_format; |
387 | 387 | } |
388 | 388 | |
389 | - return apply_filters( 'give_date_format', $date_format ); |
|
389 | + return apply_filters('give_date_format', $date_format); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string |
402 | 402 | */ |
403 | -function give_get_cache_key( $action, $query_args ) { |
|
404 | - return Give_Cache::get_key( $action, $query_args ); |
|
403 | +function give_get_cache_key($action, $query_args) { |
|
404 | + return Give_Cache::get_key($action, $query_args); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return string|array |
416 | 416 | */ |
417 | -function give_clean( $var ) { |
|
418 | - if ( is_array( $var ) ) { |
|
419 | - return array_map( 'give_clean', $var ); |
|
417 | +function give_clean($var) { |
|
418 | + if (is_array($var)) { |
|
419 | + return array_map('give_clean', $var); |
|
420 | 420 | } else { |
421 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
421 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @return int |
433 | 433 | */ |
434 | -function give_let_to_num( $size ) { |
|
435 | - $l = substr( $size, - 1 ); |
|
436 | - $ret = substr( $size, 0, - 1 ); |
|
437 | - switch ( strtoupper( $l ) ) { |
|
434 | +function give_let_to_num($size) { |
|
435 | + $l = substr($size, - 1); |
|
436 | + $ret = substr($size, 0, - 1); |
|
437 | + switch (strtoupper($l)) { |
|
438 | 438 | case 'P': |
439 | 439 | $ret *= 1024; |
440 | 440 | case 'T': |
@@ -459,17 +459,17 @@ discard block |
||
459 | 459 | * @param int $action |
460 | 460 | * @param array $wp_die_args |
461 | 461 | */ |
462 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
462 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
463 | 463 | |
464 | 464 | $default_wp_die_args = array( |
465 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
466 | - 'title' => esc_html__( 'Error', 'give' ), |
|
467 | - 'args' => array( 'response' => 403 ), |
|
465 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
466 | + 'title' => esc_html__('Error', 'give'), |
|
467 | + 'args' => array('response' => 403), |
|
468 | 468 | ); |
469 | 469 | |
470 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
470 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
471 | 471 | |
472 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
472 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
473 | 473 | wp_die( |
474 | 474 | $wp_die_args['message'], |
475 | 475 | $wp_die_args['title'], |
@@ -491,23 +491,23 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return mixed |
493 | 493 | */ |
494 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
494 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
495 | 495 | |
496 | - switch ( $conditional ) { |
|
496 | + switch ($conditional) { |
|
497 | 497 | case 'isset_empty': |
498 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
498 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
499 | 499 | break; |
500 | 500 | |
501 | 501 | case 'empty': |
502 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
502 | + $variable = ! empty($variable) ? $variable : $default; |
|
503 | 503 | break; |
504 | 504 | |
505 | 505 | case 'null': |
506 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
506 | + $variable = ! is_null($variable) ? $variable : $default; |
|
507 | 507 | break; |
508 | 508 | |
509 | 509 | default: |
510 | - $variable = isset( $variable ) ? $variable : $default; |
|
510 | + $variable = isset($variable) ? $variable : $default; |
|
511 | 511 | |
512 | 512 | } |
513 | 513 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
31 | - if( empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function give_post_actions() { |
60 | 60 | |
61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | // Add backward compatibility to give-action param ( $_POST ) |
65 | - if( empty( $_post_action ) ) { |
|
66 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
65 | + if (empty($_post_action)) { |
|
66 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( isset( $_post_action ) ) { |
|
69 | + if (isset($_post_action)) { |
|
70 | 70 | /** |
71 | 71 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
72 | 72 | * |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array $_POST Array of HTTP POST variables. |
76 | 76 | */ |
77 | - do_action( "give_{$_post_action}", $_POST ); |
|
77 | + do_action("give_{$_post_action}", $_POST); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | -add_action( 'init', 'give_post_actions' ); |
|
82 | +add_action('init', 'give_post_actions'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Connect WordPress user with Donor. |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | * @param array $user_data User Data |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
92 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
93 | 93 | /* @var Give_Customer $donor */ |
94 | - $donor = new Give_Customer( $user_data['user_email'] ); |
|
94 | + $donor = new Give_Customer($user_data['user_email']); |
|
95 | 95 | |
96 | 96 | // Validate donor id and check if do nor is already connect to wp user or not. |
97 | - if( $donor->id && ! $donor->user_id ) { |
|
97 | + if ($donor->id && ! $donor->user_id) { |
|
98 | 98 | |
99 | 99 | // Update donor user_id. |
100 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
101 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
102 | - $donor->add_note( $donor_note ); |
|
100 | + if ($donor->update(array('user_id' => $user_id))) { |
|
101 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
102 | + $donor->add_note($donor_note); |
|
103 | 103 | |
104 | 104 | // Update user_id meta in payments. |
105 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
106 | - foreach ( $donations as $donation ) { |
|
107 | - update_post_meta( $donation, '_give_payment_user_id', $user_id ); |
|
105 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
106 | + foreach ($donations as $donation) { |
|
107 | + update_post_meta($donation, '_give_payment_user_id', $user_id); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
113 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | function give_validate_license_when_site_migrated() { |
125 | 125 | // Store current site address if not already stored. |
126 | 126 | $homeurl = home_url(); |
127 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
127 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
128 | 128 | // Update site address. |
129 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
129 | + update_option('give_site_address_before_migrate', $homeurl); |
|
130 | 130 | |
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
134 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
135 | 135 | // Immediately run cron. |
136 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
136 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
137 | 137 | |
138 | 138 | // Update site address. |
139 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
139 | + update_option('give_site_address_before_migrate', home_url()); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
144 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
143 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
144 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @since 1.8 |
151 | 151 | * @param $data |
152 | 152 | */ |
153 | -function give_donor_batch_export_complete( $data ) { |
|
153 | +function give_donor_batch_export_complete($data) { |
|
154 | 154 | // Remove donor ids cache. |
155 | - if( |
|
156 | - isset( $data['class'] ) |
|
155 | + if ( |
|
156 | + isset($data['class']) |
|
157 | 157 | && 'Give_Batch_Customers_Export' === $data['class'] |
158 | - && ! empty( $data['forms'] ) |
|
159 | - && isset( $data['give_export_option']['query_id'] ) |
|
158 | + && ! empty($data['forms']) |
|
159 | + && isset($data['give_export_option']['query_id']) |
|
160 | 160 | ) { |
161 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
161 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
162 | 162 | } |
163 | 163 | } |
164 | -add_action('give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
164 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
@@ -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 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } elseif ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } elseif (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_donations_args', array( |
|
55 | + $args = apply_filters('give_get_users_donations_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date', |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
139 | - $completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : ''; |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | + $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1, |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1, |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool True if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,21 +247,21 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int The total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | // Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
262 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
263 | 263 | |
264 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
264 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return float The total amount the user has spent |
276 | 276 | */ |
277 | -function give_purchase_total_of_user( $user = null ) { |
|
277 | +function give_purchase_total_of_user($user = null) { |
|
278 | 278 | |
279 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
279 | + $stats = give_get_purchase_stats_by_user($user); |
|
280 | 280 | |
281 | 281 | return $stats['total_spent']; |
282 | 282 | } |
@@ -292,40 +292,40 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | -function give_validate_username( $username, $form_id = 0 ) { |
|
295 | +function give_validate_username($username, $form_id = 0) { |
|
296 | 296 | $valid = true; |
297 | 297 | |
298 | 298 | // Validate username. |
299 | - if ( ! empty( $username ) ) { |
|
299 | + if ( ! empty($username)) { |
|
300 | 300 | |
301 | 301 | // Sanitize username. |
302 | - $sanitized_user_name = sanitize_user( $username, false ); |
|
302 | + $sanitized_user_name = sanitize_user($username, false); |
|
303 | 303 | |
304 | 304 | // We have an user name, check if it already exists. |
305 | - if ( username_exists( $username ) ) { |
|
305 | + if (username_exists($username)) { |
|
306 | 306 | // Username already registered. |
307 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
307 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
308 | 308 | $valid = false; |
309 | 309 | |
310 | 310 | // Check if it's valid. |
311 | - } elseif ( $sanitized_user_name !== $username ) { |
|
311 | + } elseif ($sanitized_user_name !== $username) { |
|
312 | 312 | // Invalid username. |
313 | - if ( is_multisite() ) { |
|
314 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
313 | + if (is_multisite()) { |
|
314 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
315 | 315 | $valid = false; |
316 | 316 | } else { |
317 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
317 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
318 | 318 | $valid = false; |
319 | 319 | } |
320 | 320 | } |
321 | 321 | } else { |
322 | 322 | // Username is empty. |
323 | - give_set_error( 'username_empty', esc_html__( 'Enter a username.', 'give' ) ); |
|
323 | + give_set_error('username_empty', esc_html__('Enter a username.', 'give')); |
|
324 | 324 | $valid = false; |
325 | 325 | |
326 | 326 | // Check if guest checkout is disable for form. |
327 | - if ( $form_id && give_logged_in_only( $form_id ) ) { |
|
328 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
327 | + if ($form_id && give_logged_in_only($form_id)) { |
|
328 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
329 | 329 | $valid = false; |
330 | 330 | } |
331 | 331 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @param string $username |
340 | 340 | * @param bool $form_id |
341 | 341 | */ |
342 | - $valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id ); |
|
342 | + $valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id); |
|
343 | 343 | |
344 | 344 | return $valid; |
345 | 345 | } |
@@ -355,22 +355,22 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return bool |
357 | 357 | */ |
358 | -function give_validate_user_email( $email, $registering_new_user = false ) { |
|
358 | +function give_validate_user_email($email, $registering_new_user = false) { |
|
359 | 359 | $valid = true; |
360 | 360 | |
361 | - if ( empty( $email ) ) { |
|
361 | + if (empty($email)) { |
|
362 | 362 | // No email. |
363 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
363 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
364 | 364 | $valid = false; |
365 | 365 | |
366 | - } elseif ( ! is_email( $email ) ) { |
|
366 | + } elseif ( ! is_email($email)) { |
|
367 | 367 | // Validate email. |
368 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
368 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
369 | 369 | $valid = false; |
370 | 370 | |
371 | - } elseif ( $registering_new_user && email_exists( $email ) ) { |
|
371 | + } elseif ($registering_new_user && email_exists($email)) { |
|
372 | 372 | // Check if email exists. |
373 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
373 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
374 | 374 | $valid = false; |
375 | 375 | } |
376 | 376 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param string $email |
384 | 384 | * @param bool $registering_new_user |
385 | 385 | */ |
386 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user ); |
|
386 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user); |
|
387 | 387 | |
388 | 388 | return $valid; |
389 | 389 | } |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return bool |
401 | 401 | */ |
402 | -function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) { |
|
402 | +function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) { |
|
403 | 403 | $valid = true; |
404 | 404 | |
405 | - if ( $password && $confirm_password ) { |
|
405 | + if ($password && $confirm_password) { |
|
406 | 406 | // Verify confirmation matches. |
407 | - if ( $password != $confirm_password ) { |
|
407 | + if ($password != $confirm_password) { |
|
408 | 408 | // Passwords do not match |
409 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
409 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
410 | 410 | $valid = false; |
411 | 411 | } |
412 | - } elseif ( $registering_new_user ) { |
|
412 | + } elseif ($registering_new_user) { |
|
413 | 413 | // Password or confirmation missing. |
414 | - if ( ! $password ) { |
|
414 | + if ( ! $password) { |
|
415 | 415 | // The password is invalid. |
416 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
416 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
417 | 417 | $valid = false; |
418 | - } elseif ( ! $confirm_password ) { |
|
418 | + } elseif ( ! $confirm_password) { |
|
419 | 419 | // Confirmation password is invalid. |
420 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
420 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
421 | 421 | $valid = false; |
422 | 422 | } |
423 | 423 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param string $confirm_password |
433 | 433 | * @param bool $registering_new_user |
434 | 434 | */ |
435 | - $valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user ); |
|
435 | + $valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user); |
|
436 | 436 | |
437 | 437 | return $valid; |
438 | 438 | } |
@@ -451,32 +451,32 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
454 | +function give_add_past_purchases_to_new_user($user_id) { |
|
455 | 455 | |
456 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
456 | + $email = get_the_author_meta('user_email', $user_id); |
|
457 | 457 | |
458 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
458 | + $payments = give_get_payments(array('s' => $email)); |
|
459 | 459 | |
460 | - if ( $payments ) { |
|
461 | - foreach ( $payments as $payment ) { |
|
462 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
460 | + if ($payments) { |
|
461 | + foreach ($payments as $payment) { |
|
462 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
463 | 463 | continue; |
464 | 464 | } // This payment already associated with an account |
465 | 465 | |
466 | - $meta = give_get_payment_meta( $payment->ID ); |
|
467 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
466 | + $meta = give_get_payment_meta($payment->ID); |
|
467 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
468 | 468 | $meta['user_info']['id'] = $user_id; |
469 | 469 | $meta['user_info'] = $meta['user_info']; |
470 | 470 | |
471 | 471 | // Store the updated user ID in the payment meta |
472 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
473 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
472 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
473 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
479 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
480 | 480 | |
481 | 481 | |
482 | 482 | /** |
@@ -502,34 +502,34 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return array The donor's address, if any |
504 | 504 | */ |
505 | -function give_get_donor_address( $user_id = 0 ) { |
|
506 | - if ( empty( $user_id ) ) { |
|
505 | +function give_get_donor_address($user_id = 0) { |
|
506 | + if (empty($user_id)) { |
|
507 | 507 | $user_id = get_current_user_id(); |
508 | 508 | } |
509 | 509 | |
510 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
510 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
511 | 511 | |
512 | - if ( ! isset( $address['line1'] ) ) { |
|
512 | + if ( ! isset($address['line1'])) { |
|
513 | 513 | $address['line1'] = ''; |
514 | 514 | } |
515 | 515 | |
516 | - if ( ! isset( $address['line2'] ) ) { |
|
516 | + if ( ! isset($address['line2'])) { |
|
517 | 517 | $address['line2'] = ''; |
518 | 518 | } |
519 | 519 | |
520 | - if ( ! isset( $address['city'] ) ) { |
|
520 | + if ( ! isset($address['city'])) { |
|
521 | 521 | $address['city'] = ''; |
522 | 522 | } |
523 | 523 | |
524 | - if ( ! isset( $address['zip'] ) ) { |
|
524 | + if ( ! isset($address['zip'])) { |
|
525 | 525 | $address['zip'] = ''; |
526 | 526 | } |
527 | 527 | |
528 | - if ( ! isset( $address['country'] ) ) { |
|
528 | + if ( ! isset($address['country'])) { |
|
529 | 529 | $address['country'] = ''; |
530 | 530 | } |
531 | 531 | |
532 | - if ( ! isset( $address['state'] ) ) { |
|
532 | + if ( ! isset($address['state'])) { |
|
533 | 533 | $address['state'] = ''; |
534 | 534 | } |
535 | 535 | |
@@ -549,42 +549,42 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return void |
551 | 551 | */ |
552 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
552 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
553 | 553 | |
554 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
554 | + if (empty($user_id) || empty($user_data)) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
557 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
558 | 558 | |
559 | 559 | /* translators: %s: site name */ |
560 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
560 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
561 | 561 | /* translators: %s: user login */ |
562 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
562 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
563 | 563 | /* translators: %s: user email */ |
564 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
564 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
565 | 565 | |
566 | 566 | Give()->emails->send( |
567 | - get_option( 'admin_email' ), |
|
567 | + get_option('admin_email'), |
|
568 | 568 | sprintf( |
569 | 569 | /* translators: %s: site name */ |
570 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
570 | + esc_attr__('[%s] New User Registration', 'give'), |
|
571 | 571 | $blogname |
572 | 572 | ), |
573 | 573 | $message |
574 | 574 | ); |
575 | 575 | |
576 | 576 | /* translators: %s: user login */ |
577 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
577 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
578 | 578 | /* translators: %s: paswword */ |
579 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
579 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
580 | 580 | |
581 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
581 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
582 | 582 | |
583 | 583 | Give()->emails->send( |
584 | 584 | $user_data['user_email'], |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: site name */ |
587 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
587 | + esc_attr__('[%s] Your username and password', 'give'), |
|
588 | 588 | $blogname |
589 | 589 | ), |
590 | 590 | $message |
@@ -592,4 +592,4 @@ discard block |
||
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
595 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |