@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Donation_Form_Goal extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Donation Form Goal', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Donation Form Goal', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Donation Form Goal', 'give'); |
|
22 | + $this->shortcode['label'] = __('Donation Form Goal', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_goal' ); |
|
24 | + parent::__construct('give_goal'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function define_fields() { |
33 | 33 | |
34 | - $create_form_link = sprintf( __( '%sClick here%s to create a new Donation Form.', 'give' ), |
|
35 | - '<a href="' . admin_url( 'post-new.php?post_type=give_forms' ) . '">', |
|
34 | + $create_form_link = sprintf(__('%sClick here%s to create a new Donation Form.', 'give'), |
|
35 | + '<a href="'.admin_url('post-new.php?post_type=give_forms').'">', |
|
36 | 36 | '</a>' |
37 | 37 | ); |
38 | 38 | |
@@ -43,35 +43,35 @@ discard block |
||
43 | 43 | 'post_type' => 'give_forms', |
44 | 44 | ), |
45 | 45 | 'name' => 'id', |
46 | - 'tooltip' => __( 'Select a Donation Form', 'give' ), |
|
47 | - 'placeholder' => sprintf( '– %s –', __( 'Select a Form', 'give' ) ), |
|
46 | + 'tooltip' => __('Select a Donation Form', 'give'), |
|
47 | + 'placeholder' => sprintf('– %s –', __('Select a Form', 'give')), |
|
48 | 48 | 'required' => array( |
49 | - 'alert' => __( 'You must first select a Form!', 'give' ), |
|
50 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', __( 'No donation forms were found!', 'give' ), $create_form_link ), |
|
49 | + 'alert' => __('You must first select a Form!', 'give'), |
|
50 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', __('No donation forms were found!', 'give'), $create_form_link), |
|
51 | 51 | ), |
52 | 52 | ), |
53 | 53 | array( |
54 | 54 | 'type' => 'container', |
55 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', __( 'Optional settings', 'give' ) ), |
|
55 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', __('Optional settings', 'give')), |
|
56 | 56 | ), |
57 | 57 | array( |
58 | 58 | 'type' => 'listbox', |
59 | 59 | 'name' => 'show_text', |
60 | - 'label' => __( 'Show Text:', 'give' ), |
|
61 | - 'tooltip' => __( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
60 | + 'label' => __('Show Text:', 'give'), |
|
61 | + 'tooltip' => __('This text displays the amount of income raised compared to the goal.', 'give'), |
|
62 | 62 | 'options' => array( |
63 | - 'true' => __( 'Show', 'give' ), |
|
64 | - 'false' => __( 'Hide', 'give' ), |
|
63 | + 'true' => __('Show', 'give'), |
|
64 | + 'false' => __('Hide', 'give'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | array( |
68 | 68 | 'type' => 'listbox', |
69 | 69 | 'name' => 'show_bar', |
70 | - 'label' => __( 'Show Progress Bar:', 'give' ), |
|
71 | - 'tooltip' => __( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
70 | + 'label' => __('Show Progress Bar:', 'give'), |
|
71 | + 'tooltip' => __('Do you want to display the goal\'s progress bar?', 'give'), |
|
72 | 72 | 'options' => array( |
73 | - 'true' => __( 'Show', 'give' ), |
|
74 | - 'false' => __( 'Hide', 'give' ), |
|
73 | + 'true' => __('Show', 'give'), |
|
74 | + 'false' => __('Hide', 'give'), |
|
75 | 75 | ), |
76 | 76 | ), |
77 | 77 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Login extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Login', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Login', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Login', 'give'); |
|
22 | + $this->shortcode['label'] = __('Login', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_login' ); |
|
24 | + parent::__construct('give_login'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Redirect URL (optional):', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="no-margin">%s</p>', __('Redirect URL (optional):', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'textbox', |
41 | 41 | 'name' => 'redirect', |
42 | 42 | 'minWidth' => 320, |
43 | - 'tooltip' => __( 'Enter an URL here to redirect to after login.', 'give' ), |
|
43 | + 'tooltip' => __('Enter an URL here to redirect to after login.', 'give'), |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Profile_Editor extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['label'] = __( 'Profile Editor', 'give' ); |
|
21 | + $this->shortcode['label'] = __('Profile Editor', 'give'); |
|
22 | 22 | |
23 | - parent::__construct( 'give_profile_editor' ); |
|
23 | + parent::__construct('give_profile_editor'); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Donation_Receipt extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Donation Receipt', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Donation Receipt', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Donation Receipt', 'give'); |
|
22 | + $this->shortcode['label'] = __('Donation Receipt', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_receipt' ); |
|
24 | + parent::__construct('give_receipt'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,51 +34,51 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="strong">%s</p>', __( 'Optional settings', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="strong">%s</p>', __('Optional settings', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'listbox', |
41 | 41 | 'name' => 'price', |
42 | - 'label' => __( 'Show Price:', 'give' ), |
|
42 | + 'label' => __('Show Price:', 'give'), |
|
43 | 43 | 'options' => array( |
44 | - 'true' => __( 'Show', 'give' ), |
|
45 | - 'false' => __( 'Hide', 'give' ), |
|
44 | + 'true' => __('Show', 'give'), |
|
45 | + 'false' => __('Hide', 'give'), |
|
46 | 46 | ), |
47 | 47 | ), |
48 | 48 | array( |
49 | 49 | 'type' => 'listbox', |
50 | 50 | 'name' => 'date', |
51 | - 'label' => __( 'Show Date:', 'give' ), |
|
51 | + 'label' => __('Show Date:', 'give'), |
|
52 | 52 | 'options' => array( |
53 | - 'true' => __( 'Show', 'give' ), |
|
54 | - 'false' => __( 'Hide', 'give' ), |
|
53 | + 'true' => __('Show', 'give'), |
|
54 | + 'false' => __('Hide', 'give'), |
|
55 | 55 | ), |
56 | 56 | ), |
57 | 57 | array( |
58 | 58 | 'type' => 'listbox', |
59 | 59 | 'name' => 'payment_key', |
60 | - 'label' => __( 'Show Payment Key:', 'give' ), |
|
60 | + 'label' => __('Show Payment Key:', 'give'), |
|
61 | 61 | 'options' => array( |
62 | - 'true' => __( 'Show', 'give' ), |
|
63 | - 'false' => __( 'Hide', 'give' ), |
|
62 | + 'true' => __('Show', 'give'), |
|
63 | + 'false' => __('Hide', 'give'), |
|
64 | 64 | ), |
65 | 65 | ), |
66 | 66 | array( |
67 | 67 | 'type' => 'listbox', |
68 | 68 | 'name' => 'payment_method', |
69 | - 'label' => __( 'Show Payment Method:', 'give' ), |
|
69 | + 'label' => __('Show Payment Method:', 'give'), |
|
70 | 70 | 'options' => array( |
71 | - 'true' => __( 'Show', 'give' ), |
|
72 | - 'false' => __( 'Hide', 'give' ), |
|
71 | + 'true' => __('Show', 'give'), |
|
72 | + 'false' => __('Hide', 'give'), |
|
73 | 73 | ), |
74 | 74 | ), |
75 | 75 | array( |
76 | 76 | 'type' => 'listbox', |
77 | 77 | 'name' => 'payment_id', |
78 | - 'label' => __( 'Show Payment ID:', 'give' ), |
|
78 | + 'label' => __('Show Payment ID:', 'give'), |
|
79 | 79 | 'options' => array( |
80 | - 'true' => __( 'Show', 'give' ), |
|
81 | - 'false' => __( 'Hide', 'give' ), |
|
80 | + 'true' => __('Show', 'give'), |
|
81 | + 'false' => __('Hide', 'give'), |
|
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Register extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = __( 'Register', 'give' ); |
|
22 | - $this->shortcode['label'] = __( 'Register', 'give' ); |
|
21 | + $this->shortcode['title'] = __('Register', 'give'); |
|
22 | + $this->shortcode['label'] = __('Register', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_register' ); |
|
24 | + parent::__construct('give_register'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', __( 'Redirect URL (optional):', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="no-margin">%s</p>', __('Redirect URL (optional):', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'textbox', |
41 | 41 | 'name' => 'redirect', |
42 | 42 | 'minWidth' => 320, |
43 | - 'tooltip' => __( 'Enter an URL here to redirect to after registering.', 'give' ), |
|
43 | + 'tooltip' => __('Enter an URL here to redirect to after registering.', 'give'), |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_upgrades_screen() { |
24 | - $action = isset( $_GET['give-upgrade'] ) ? sanitize_text_field( $_GET['give-upgrade'] ) : ''; |
|
25 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
26 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
27 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
28 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
29 | - $steps = round( ( $total / $number ), 0 ); |
|
24 | + $action = isset($_GET['give-upgrade']) ? sanitize_text_field($_GET['give-upgrade']) : ''; |
|
25 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
26 | + $total = isset($_GET['total']) ? absint($_GET['total']) : false; |
|
27 | + $custom = isset($_GET['custom']) ? absint($_GET['custom']) : 0; |
|
28 | + $number = isset($_GET['number']) ? absint($_GET['number']) : 100; |
|
29 | + $steps = round(($total / $number), 0); |
|
30 | 30 | |
31 | 31 | $doing_upgrade_args = array( |
32 | 32 | 'page' => 'give-upgrades', |
@@ -36,25 +36,25 @@ discard block |
||
36 | 36 | 'custom' => $custom, |
37 | 37 | 'steps' => $steps |
38 | 38 | ); |
39 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
40 | - if ( $step > $steps ) { |
|
39 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
40 | + if ($step > $steps) { |
|
41 | 41 | // Prevent a weird case where the estimate was off. Usually only a couple. |
42 | 42 | $steps = $step; |
43 | 43 | } |
44 | 44 | ?> |
45 | 45 | <div class="wrap"> |
46 | - <h2><?php _e( 'Give - Upgrades', 'give' ); ?></h2> |
|
46 | + <h2><?php _e('Give - Upgrades', 'give'); ?></h2> |
|
47 | 47 | |
48 | - <?php if ( ! empty( $action ) ) : ?> |
|
48 | + <?php if ( ! empty($action)) : ?> |
|
49 | 49 | |
50 | 50 | <div id="give-upgrade-status"> |
51 | - <p style="font-size: 20px;max-width: 900px;"><?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
52 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
51 | + <p style="font-size: 20px;max-width: 900px;"><?php _e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
52 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
53 | 53 | </p> |
54 | 54 | |
55 | - <?php if ( ! empty( $total ) ) : ?> |
|
55 | + <?php if ( ! empty($total)) : ?> |
|
56 | 56 | <p> |
57 | - <strong><?php printf( __( 'Step %d of approximately %d running', 'give' ), $step, $steps ); ?></strong> |
|
57 | + <strong><?php printf(__('Step %d of approximately %d running', 'give'), $step, $steps); ?></strong> |
|
58 | 58 | </p> |
59 | 59 | <?php endif; ?> |
60 | 60 | </div> |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | <div id="give-upgrade-status"> |
70 | 70 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
71 | + <?php _e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
72 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
73 | 73 | </p> |
74 | 74 | </div> |
75 | 75 | <script type="text/javascript"> |
@@ -64,11 +64,14 @@ |
||
64 | 64 | }, 250 ); |
65 | 65 | </script> |
66 | 66 | |
67 | - <?php else : ?> |
|
67 | + <?php else { |
|
68 | + : ?> |
|
68 | 69 | |
69 | 70 | <div id="give-upgrade-status"> |
70 | 71 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | + <?php _e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); |
|
73 | +} |
|
74 | +?> |
|
72 | 75 | <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
73 | 76 | </p> |
74 | 77 | </div> |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give_API_V1 Class |
@@ -10,7 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Give_API_V1 Class |
@@ -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 | |
@@ -96,29 +96,29 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 1.0 |
98 | 98 | */ |
99 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
99 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
100 | 100 | |
101 | 101 | $this->db = new Give_DB_Customers; |
102 | 102 | |
103 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
103 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
107 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
108 | 108 | |
109 | - if ( is_numeric( $_id_or_email ) ) { |
|
109 | + if (is_numeric($_id_or_email)) { |
|
110 | 110 | $field = $by_user_id ? 'user_id' : 'id'; |
111 | 111 | } else { |
112 | 112 | $field = 'email'; |
113 | 113 | } |
114 | 114 | |
115 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
115 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
116 | 116 | |
117 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
117 | + if (empty($customer) || ! is_object($customer)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - $this->setup_customer( $customer ); |
|
121 | + $this->setup_customer($customer); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool If the setup was successful or not |
133 | 133 | */ |
134 | - private function setup_customer( $customer ) { |
|
134 | + private function setup_customer($customer) { |
|
135 | 135 | |
136 | - if ( ! is_object( $customer ) ) { |
|
136 | + if ( ! is_object($customer)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - foreach ( $customer as $key => $value ) { |
|
140 | + foreach ($customer as $key => $value) { |
|
141 | 141 | |
142 | - switch ( $key ) { |
|
142 | + switch ($key) { |
|
143 | 143 | |
144 | 144 | case 'notes': |
145 | 145 | $this->$key = $this->get_notes(); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Customer ID and email are the only things that are necessary, make sure they exist |
157 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
157 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - public function __get( $key ) { |
|
170 | + public function __get($key) { |
|
171 | 171 | |
172 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
172 | + if (method_exists($this, 'get_'.$key)) { |
|
173 | 173 | |
174 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
174 | + return call_user_func(array($this, 'get_'.$key)); |
|
175 | 175 | |
176 | 176 | } else { |
177 | 177 | |
178 | - return new WP_Error( 'give-customer-invalid-property', sprintf( __( 'Can\'t get property %s', 'give' ), $key ) ); |
|
178 | + return new WP_Error('give-customer-invalid-property', sprintf(__('Can\'t get property %s', 'give'), $key)); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return mixed False if not a valid creation, Customer ID if user is found or valid creation |
192 | 192 | */ |
193 | - public function create( $data = array() ) { |
|
193 | + public function create($data = array()) { |
|
194 | 194 | |
195 | - if ( $this->id != 0 || empty( $data ) ) { |
|
195 | + if ($this->id != 0 || empty($data)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | 'payment_ids' => '' |
201 | 201 | ); |
202 | 202 | |
203 | - $args = wp_parse_args( $data, $defaults ); |
|
204 | - $args = $this->sanitize_columns( $args ); |
|
203 | + $args = wp_parse_args($data, $defaults); |
|
204 | + $args = $this->sanitize_columns($args); |
|
205 | 205 | |
206 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
206 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
211 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
210 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
211 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
212 | 212 | } |
213 | 213 | |
214 | - do_action( 'give_customer_pre_create', $args ); |
|
214 | + do_action('give_customer_pre_create', $args); |
|
215 | 215 | |
216 | 216 | $created = false; |
217 | 217 | |
218 | 218 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
219 | - if ( $this->db->add( $data ) ) { |
|
219 | + if ($this->db->add($data)) { |
|
220 | 220 | |
221 | 221 | // We've successfully added/updated the customer, reset the class vars with the new data |
222 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
222 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
223 | 223 | |
224 | 224 | // Setup the customer data with the values from DB |
225 | - $this->setup_customer( $customer ); |
|
225 | + $this->setup_customer($customer); |
|
226 | 226 | |
227 | 227 | $created = $this->id; |
228 | 228 | } |
229 | 229 | |
230 | - do_action( 'give_customer_post_create', $created, $args ); |
|
230 | + do_action('give_customer_post_create', $created, $args); |
|
231 | 231 | |
232 | 232 | return $created; |
233 | 233 | |
@@ -242,27 +242,27 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return bool If the update was successful or not |
244 | 244 | */ |
245 | - public function update( $data = array() ) { |
|
245 | + public function update($data = array()) { |
|
246 | 246 | |
247 | - if ( empty( $data ) ) { |
|
247 | + if (empty($data)) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | - $data = $this->sanitize_columns( $data ); |
|
251 | + $data = $this->sanitize_columns($data); |
|
252 | 252 | |
253 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
253 | + do_action('give_customer_pre_update', $this->id, $data); |
|
254 | 254 | |
255 | 255 | $updated = false; |
256 | 256 | |
257 | - if ( $this->db->update( $this->id, $data ) ) { |
|
257 | + if ($this->db->update($this->id, $data)) { |
|
258 | 258 | |
259 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
260 | - $this->setup_customer( $customer ); |
|
259 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
260 | + $this->setup_customer($customer); |
|
261 | 261 | |
262 | 262 | $updated = true; |
263 | 263 | } |
264 | 264 | |
265 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
265 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
266 | 266 | |
267 | 267 | return $updated; |
268 | 268 | } |
@@ -278,44 +278,44 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return bool If the attachment was successfuly |
280 | 280 | */ |
281 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
281 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
282 | 282 | |
283 | - if ( empty( $payment_id ) ) { |
|
283 | + if (empty($payment_id)) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
287 | - if ( empty( $this->payment_ids ) ) { |
|
287 | + if (empty($this->payment_ids)) { |
|
288 | 288 | |
289 | 289 | $new_payment_ids = $payment_id; |
290 | 290 | |
291 | 291 | } else { |
292 | 292 | |
293 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
293 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
294 | 294 | |
295 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
295 | + if (in_array($payment_id, $payment_ids)) { |
|
296 | 296 | $update_stats = false; |
297 | 297 | } |
298 | 298 | |
299 | 299 | $payment_ids[] = $payment_id; |
300 | 300 | |
301 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
301 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | |
305 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
305 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
306 | 306 | |
307 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
307 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
308 | 308 | |
309 | - if ( $payment_added ) { |
|
309 | + if ($payment_added) { |
|
310 | 310 | |
311 | 311 | $this->payment_ids = $new_payment_ids; |
312 | 312 | |
313 | 313 | // We added this payment successfully, increment the stats |
314 | - if ( $update_stats ) { |
|
315 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
314 | + if ($update_stats) { |
|
315 | + $payment_amount = give_get_payment_amount($payment_id); |
|
316 | 316 | |
317 | - if ( ! empty( $payment_amount ) ) { |
|
318 | - $this->increase_value( $payment_amount ); |
|
317 | + if ( ! empty($payment_amount)) { |
|
318 | + $this->increase_value($payment_amount); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $this->increase_purchase_count(); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
326 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
327 | 327 | |
328 | 328 | return $payment_added; |
329 | 329 | } |
@@ -339,44 +339,44 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return boolean If the removal was successful |
341 | 341 | */ |
342 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
342 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | $new_payment_ids = ''; |
349 | 349 | |
350 | - if ( ! empty( $this->payment_ids ) ) { |
|
350 | + if ( ! empty($this->payment_ids)) { |
|
351 | 351 | |
352 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
352 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
353 | 353 | |
354 | - $pos = array_search( $payment_id, $payment_ids ); |
|
355 | - if ( false === $pos ) { |
|
354 | + $pos = array_search($payment_id, $payment_ids); |
|
355 | + if (false === $pos) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | - unset( $payment_ids[ $pos ] ); |
|
360 | - $payment_ids = array_filter( $payment_ids ); |
|
359 | + unset($payment_ids[$pos]); |
|
360 | + $payment_ids = array_filter($payment_ids); |
|
361 | 361 | |
362 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
362 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | |
366 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
366 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
367 | 367 | |
368 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
368 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
369 | 369 | |
370 | - if ( $payment_removed ) { |
|
370 | + if ($payment_removed) { |
|
371 | 371 | |
372 | 372 | $this->payment_ids = $new_payment_ids; |
373 | 373 | |
374 | - if ( $update_stats ) { |
|
374 | + if ($update_stats) { |
|
375 | 375 | // We removed this payment successfully, decrement the stats |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | |
378 | - if ( ! empty( $payment_amount ) ) { |
|
379 | - $this->decrease_value( $payment_amount ); |
|
378 | + if ( ! empty($payment_amount)) { |
|
379 | + $this->decrease_value($payment_amount); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | $this->decrease_purchase_count(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
387 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
388 | 388 | |
389 | 389 | return $payment_removed; |
390 | 390 | |
@@ -399,22 +399,22 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return int The purchase count |
401 | 401 | */ |
402 | - public function increase_purchase_count( $count = 1 ) { |
|
402 | + public function increase_purchase_count($count = 1) { |
|
403 | 403 | |
404 | 404 | // Make sure it's numeric and not negative |
405 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
405 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $new_total = (int) $this->purchase_count + (int) $count; |
410 | 410 | |
411 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
411 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
412 | 412 | |
413 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
413 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
414 | 414 | $this->purchase_count = $new_total; |
415 | 415 | } |
416 | 416 | |
417 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
417 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
418 | 418 | |
419 | 419 | return $this->purchase_count; |
420 | 420 | } |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return mixed If successful, the new count, otherwise false |
430 | 430 | */ |
431 | - public function decrease_purchase_count( $count = 1 ) { |
|
431 | + public function decrease_purchase_count($count = 1) { |
|
432 | 432 | |
433 | 433 | // Make sure it's numeric and not negative |
434 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
434 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $new_total = (int) $this->purchase_count - (int) $count; |
439 | 439 | |
440 | - if ( $new_total < 0 ) { |
|
440 | + if ($new_total < 0) { |
|
441 | 441 | $new_total = 0; |
442 | 442 | } |
443 | 443 | |
444 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
444 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
445 | 445 | |
446 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
446 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
447 | 447 | $this->purchase_count = $new_total; |
448 | 448 | } |
449 | 449 | |
450 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
450 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
451 | 451 | |
452 | 452 | return $this->purchase_count; |
453 | 453 | } |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return mixed If successful, the new value, otherwise false |
463 | 463 | */ |
464 | - public function increase_value( $value = 0.00 ) { |
|
464 | + public function increase_value($value = 0.00) { |
|
465 | 465 | |
466 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
466 | + $new_value = floatval($this->purchase_value) + $value; |
|
467 | 467 | |
468 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
468 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
469 | 469 | |
470 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
470 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
471 | 471 | $this->purchase_value = $new_value; |
472 | 472 | } |
473 | 473 | |
474 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
474 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
475 | 475 | |
476 | 476 | return $this->purchase_value; |
477 | 477 | } |
@@ -485,21 +485,21 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return mixed If successful, the new value, otherwise false |
487 | 487 | */ |
488 | - public function decrease_value( $value = 0.00 ) { |
|
488 | + public function decrease_value($value = 0.00) { |
|
489 | 489 | |
490 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
490 | + $new_value = floatval($this->purchase_value) - $value; |
|
491 | 491 | |
492 | - if ( $new_value < 0 ) { |
|
492 | + if ($new_value < 0) { |
|
493 | 493 | $new_value = 0.00; |
494 | 494 | } |
495 | 495 | |
496 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
496 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
497 | 497 | |
498 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
498 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
499 | 499 | $this->purchase_value = $new_value; |
500 | 500 | } |
501 | 501 | |
502 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
502 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
503 | 503 | |
504 | 504 | return $this->purchase_value; |
505 | 505 | } |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @return array The notes requsted |
516 | 516 | */ |
517 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
517 | + public function get_notes($length = 20, $paged = 1) { |
|
518 | 518 | |
519 | - $length = is_numeric( $length ) ? $length : 20; |
|
520 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
519 | + $length = is_numeric($length) ? $length : 20; |
|
520 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
521 | 521 | |
522 | 522 | $all_notes = $this->get_raw_notes(); |
523 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
523 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
524 | 524 | |
525 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
525 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
526 | 526 | |
527 | 527 | return $desired_notes; |
528 | 528 | |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | public function get_notes_count() { |
538 | 538 | |
539 | 539 | $all_notes = $this->get_raw_notes(); |
540 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
540 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
541 | 541 | |
542 | - return count( $notes_array ); |
|
542 | + return count($notes_array); |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
@@ -552,32 +552,32 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string|boolean The new note if added succesfully, false otherwise |
554 | 554 | */ |
555 | - public function add_note( $note = '' ) { |
|
555 | + public function add_note($note = '') { |
|
556 | 556 | |
557 | - $note = trim( $note ); |
|
558 | - if ( empty( $note ) ) { |
|
557 | + $note = trim($note); |
|
558 | + if (empty($note)) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | $notes = $this->get_raw_notes(); |
563 | 563 | |
564 | - if ( empty( $notes ) ) { |
|
564 | + if (empty($notes)) { |
|
565 | 565 | $notes = ''; |
566 | 566 | } |
567 | 567 | |
568 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
569 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
570 | - $notes .= "\n\n" . $new_note; |
|
568 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
569 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
570 | + $notes .= "\n\n".$new_note; |
|
571 | 571 | |
572 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
572 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
573 | 573 | |
574 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
574 | + $updated = $this->update(array('notes' => $notes)); |
|
575 | 575 | |
576 | - if ( $updated ) { |
|
576 | + if ($updated) { |
|
577 | 577 | $this->notes = $this->get_notes(); |
578 | 578 | } |
579 | 579 | |
580 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
580 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
581 | 581 | |
582 | 582 | // Return the formatted note, so we can test, as well as update any displays |
583 | 583 | return $new_note; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | private function get_raw_notes() { |
594 | 594 | |
595 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
595 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
596 | 596 | |
597 | 597 | return $all_notes; |
598 | 598 | |
@@ -607,51 +607,51 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return array The sanitized data, based off column defaults |
609 | 609 | */ |
610 | - private function sanitize_columns( $data ) { |
|
610 | + private function sanitize_columns($data) { |
|
611 | 611 | |
612 | 612 | $columns = $this->db->get_columns(); |
613 | 613 | $default_values = $this->db->get_column_defaults(); |
614 | 614 | |
615 | - foreach ( $columns as $key => $type ) { |
|
615 | + foreach ($columns as $key => $type) { |
|
616 | 616 | |
617 | 617 | // Only sanitize data that we were provided |
618 | - if ( ! array_key_exists( $key, $data ) ) { |
|
618 | + if ( ! array_key_exists($key, $data)) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | |
622 | - switch ( $type ) { |
|
622 | + switch ($type) { |
|
623 | 623 | |
624 | 624 | case '%s': |
625 | - if ( 'email' == $key ) { |
|
626 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
627 | - } elseif ( 'notes' == $key ) { |
|
628 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
625 | + if ('email' == $key) { |
|
626 | + $data[$key] = sanitize_email($data[$key]); |
|
627 | + } elseif ('notes' == $key) { |
|
628 | + $data[$key] = strip_tags($data[$key]); |
|
629 | 629 | } else { |
630 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
630 | + $data[$key] = sanitize_text_field($data[$key]); |
|
631 | 631 | } |
632 | 632 | break; |
633 | 633 | |
634 | 634 | case '%d': |
635 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
636 | - $data[ $key ] = $default_values[ $key ]; |
|
635 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
636 | + $data[$key] = $default_values[$key]; |
|
637 | 637 | } else { |
638 | - $data[ $key ] = absint( $data[ $key ] ); |
|
638 | + $data[$key] = absint($data[$key]); |
|
639 | 639 | } |
640 | 640 | break; |
641 | 641 | |
642 | 642 | case '%f': |
643 | 643 | // Convert what was given to a float |
644 | - $value = floatval( $data[ $key ] ); |
|
644 | + $value = floatval($data[$key]); |
|
645 | 645 | |
646 | - if ( ! is_float( $value ) ) { |
|
647 | - $data[ $key ] = $default_values[ $key ]; |
|
646 | + if ( ! is_float($value)) { |
|
647 | + $data[$key] = $default_values[$key]; |
|
648 | 648 | } else { |
649 | - $data[ $key ] = $value; |
|
649 | + $data[$key] = $value; |
|
650 | 650 | } |
651 | 651 | break; |
652 | 652 | |
653 | 653 | default: |
654 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
654 | + $data[$key] = sanitize_text_field($data[$key]); |
|
655 | 655 | break; |
656 | 656 | |
657 | 657 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } // Exit if accessed directly |
14 | 14 | |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * @since 1.0 |
78 | 78 | * @return object |
79 | 79 | */ |
80 | - public function get( $row_id ) { |
|
80 | + public function get($row_id) { |
|
81 | 81 | global $wpdb; |
82 | 82 | |
83 | - return $wpdb->get_row( "SELECT * FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;" ); |
|
83 | + return $wpdb->get_row("SELECT * FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;"); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @since 1.0 |
91 | 91 | * @return object |
92 | 92 | */ |
93 | - public function get_by( $column, $row_id ) { |
|
93 | + public function get_by($column, $row_id) { |
|
94 | 94 | global $wpdb; |
95 | 95 | |
96 | - return $wpdb->get_row( "SELECT * FROM $this->table_name WHERE $column = '$row_id' LIMIT 1;" ); |
|
96 | + return $wpdb->get_row("SELECT * FROM $this->table_name WHERE $column = '$row_id' LIMIT 1;"); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return string |
105 | 105 | */ |
106 | - public function get_column( $column, $row_id ) { |
|
106 | + public function get_column($column, $row_id) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - return $wpdb->get_var( "SELECT $column FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;" ); |
|
109 | + return $wpdb->get_var("SELECT $column FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;"); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | * @return string |
118 | 118 | */ |
119 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
119 | + public function get_column_by($column, $column_where, $column_value) { |
|
120 | 120 | global $wpdb; |
121 | 121 | |
122 | - return $wpdb->get_var( "SELECT $column FROM $this->table_name WHERE $column_where = '$column_value' LIMIT 1;" ); |
|
122 | + return $wpdb->get_var("SELECT $column FROM $this->table_name WHERE $column_where = '$column_value' LIMIT 1;"); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,30 +129,30 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | * @return int |
131 | 131 | */ |
132 | - public function insert( $data, $type = '' ) { |
|
132 | + public function insert($data, $type = '') { |
|
133 | 133 | global $wpdb; |
134 | 134 | |
135 | 135 | // Set default values |
136 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
136 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
137 | 137 | |
138 | - do_action( 'give_pre_insert_' . $type, $data ); |
|
138 | + do_action('give_pre_insert_'.$type, $data); |
|
139 | 139 | |
140 | 140 | // Initialise column format array |
141 | 141 | $column_formats = $this->get_columns(); |
142 | 142 | |
143 | 143 | // Force fields to lower case |
144 | - $data = array_change_key_case( $data ); |
|
144 | + $data = array_change_key_case($data); |
|
145 | 145 | |
146 | 146 | // White list columns |
147 | - $data = array_intersect_key( $data, $column_formats ); |
|
147 | + $data = array_intersect_key($data, $column_formats); |
|
148 | 148 | |
149 | 149 | // Reorder $column_formats to match the order of columns given in $data |
150 | - $data_keys = array_keys( $data ); |
|
151 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
150 | + $data_keys = array_keys($data); |
|
151 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
152 | 152 | |
153 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
153 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
154 | 154 | |
155 | - do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data ); |
|
155 | + do_action('give_post_insert_'.$type, $wpdb->insert_id, $data); |
|
156 | 156 | |
157 | 157 | return $wpdb->insert_id; |
158 | 158 | } |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | * @since 1.0 |
165 | 165 | * @return bool |
166 | 166 | */ |
167 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
167 | + public function update($row_id, $data = array(), $where = '') { |
|
168 | 168 | |
169 | 169 | global $wpdb; |
170 | 170 | |
171 | 171 | // Row ID must be positive integer |
172 | - $row_id = absint( $row_id ); |
|
172 | + $row_id = absint($row_id); |
|
173 | 173 | |
174 | - if ( empty( $row_id ) ) { |
|
174 | + if (empty($row_id)) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
178 | - if ( empty( $where ) ) { |
|
178 | + if (empty($where)) { |
|
179 | 179 | $where = $this->primary_key; |
180 | 180 | } |
181 | 181 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | $column_formats = $this->get_columns(); |
184 | 184 | |
185 | 185 | // Force fields to lower case |
186 | - $data = array_change_key_case( $data ); |
|
186 | + $data = array_change_key_case($data); |
|
187 | 187 | |
188 | 188 | // White list columns |
189 | - $data = array_intersect_key( $data, $column_formats ); |
|
189 | + $data = array_intersect_key($data, $column_formats); |
|
190 | 190 | |
191 | 191 | // Reorder $column_formats to match the order of columns given in $data |
192 | - $data_keys = array_keys( $data ); |
|
193 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
192 | + $data_keys = array_keys($data); |
|
193 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
194 | 194 | |
195 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
195 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | * @since 1.0 |
207 | 207 | * @return bool |
208 | 208 | */ |
209 | - public function delete( $row_id = 0 ) { |
|
209 | + public function delete($row_id = 0) { |
|
210 | 210 | |
211 | 211 | global $wpdb; |
212 | 212 | |
213 | 213 | // Row ID must be positive integer |
214 | - $row_id = absint( $row_id ); |
|
214 | + $row_id = absint($row_id); |
|
215 | 215 | |
216 | - if ( empty( $row_id ) ) { |
|
216 | + if (empty($row_id)) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
220 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | * @param string $table The table name |
232 | 232 | * @return bool If the table name exists |
233 | 233 | */ |
234 | - public function table_exists( $table ) { |
|
234 | + public function table_exists($table) { |
|
235 | 235 | global $wpdb; |
236 | - $table = sanitize_text_field( $table ); |
|
236 | + $table = sanitize_text_field($table); |
|
237 | 237 | |
238 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
238 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |