@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | 'default' => get_bloginfo( 'admin_email' ), |
80 | 80 | 'type' => 'text' |
81 | 81 | ), |
82 | - array( |
|
83 | - 'name' => esc_html__( 'Email Settings Docs Link', 'give' ), |
|
84 | - 'id' => 'email_settings_docs_link', |
|
85 | - 'url' => esc_url( 'http://docs.givewp.com/settings-emails' ), |
|
86 | - 'title' => __( 'Email Settings', 'give' ), |
|
87 | - 'type' => 'give_docs_link', |
|
88 | - ), |
|
82 | + array( |
|
83 | + 'name' => esc_html__( 'Email Settings Docs Link', 'give' ), |
|
84 | + 'id' => 'email_settings_docs_link', |
|
85 | + 'url' => esc_url( 'http://docs.givewp.com/settings-emails' ), |
|
86 | + 'title' => __( 'Email Settings', 'give' ), |
|
87 | + 'type' => 'give_docs_link', |
|
88 | + ), |
|
89 | 89 | array( |
90 | 90 | 'id' => 'give_title_email_settings_1', |
91 | 91 | 'type' => 'sectionend' |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | 'type' => 'wysiwyg', |
119 | 119 | 'default' => give_get_default_donation_receipt_email() |
120 | 120 | ), |
121 | - array( |
|
122 | - 'name' => esc_html__( 'Donation Receipt Settings Docs Link', 'give' ), |
|
123 | - 'id' => 'donation_receipt_settings_docs_link', |
|
124 | - 'url' => esc_url( 'http://docs.givewp.com/settings-donation-receipt' ), |
|
125 | - 'title' => __( 'Donation Receipt Settings', 'give' ), |
|
126 | - 'type' => 'give_docs_link', |
|
127 | - ), |
|
121 | + array( |
|
122 | + 'name' => esc_html__( 'Donation Receipt Settings Docs Link', 'give' ), |
|
123 | + 'id' => 'donation_receipt_settings_docs_link', |
|
124 | + 'url' => esc_url( 'http://docs.givewp.com/settings-donation-receipt' ), |
|
125 | + 'title' => __( 'Donation Receipt Settings', 'give' ), |
|
126 | + 'type' => 'give_docs_link', |
|
127 | + ), |
|
128 | 128 | array( |
129 | 129 | 'id' => 'give_title_email_settings_2', |
130 | 130 | 'type' => 'sectionend' |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | 'type' => 'textarea', |
176 | 176 | 'default' => get_bloginfo( 'admin_email' ) |
177 | 177 | ), |
178 | - array( |
|
179 | - 'name' => esc_html__( 'Donation Notification Settings Docs Link', 'give' ), |
|
180 | - 'id' => 'donation_notification_settings_docs_link', |
|
181 | - 'url' => esc_url( 'http://docs.givewp.com/settings-donation-notification' ), |
|
182 | - 'title' => __( 'Donation Notification Settings', 'give' ), |
|
183 | - 'type' => 'give_docs_link', |
|
184 | - ), |
|
178 | + array( |
|
179 | + 'name' => esc_html__( 'Donation Notification Settings Docs Link', 'give' ), |
|
180 | + 'id' => 'donation_notification_settings_docs_link', |
|
181 | + 'url' => esc_url( 'http://docs.givewp.com/settings-donation-notification' ), |
|
182 | + 'title' => __( 'Donation Notification Settings', 'give' ), |
|
183 | + 'type' => 'give_docs_link', |
|
184 | + ), |
|
185 | 185 | array( |
186 | 186 | 'id' => 'give_title_email_settings_3', |
187 | 187 | 'type' => 'sectionend' |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Email' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Email')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Email. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | $this->id = 'emails'; |
30 | - $this->label = esc_html__( 'Emails', 'give' ); |
|
30 | + $this->label = esc_html__('Emails', 'give'); |
|
31 | 31 | |
32 | 32 | $this->default_tab = 'email-settings'; |
33 | 33 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $settings = array(); |
45 | 45 | $current_section = give_get_current_setting_section(); |
46 | 46 | |
47 | - switch ( $current_section ) { |
|
47 | + switch ($current_section) { |
|
48 | 48 | case 'email-settings' : |
49 | 49 | $settings = array( |
50 | 50 | // Section 1: Email |
@@ -54,36 +54,36 @@ discard block |
||
54 | 54 | ), |
55 | 55 | array( |
56 | 56 | 'id' => 'email_template', |
57 | - 'name' => esc_html__( 'Email Template', 'give' ), |
|
58 | - 'desc' => esc_html__( 'Choose your template from the available registered template types.', 'give' ), |
|
57 | + 'name' => esc_html__('Email Template', 'give'), |
|
58 | + 'desc' => esc_html__('Choose your template from the available registered template types.', 'give'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => give_get_email_templates() |
61 | 61 | ), |
62 | 62 | array( |
63 | 63 | 'id' => 'email_logo', |
64 | - 'name' => esc_html__( 'Logo', 'give' ), |
|
65 | - 'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
64 | + 'name' => esc_html__('Logo', 'give'), |
|
65 | + 'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
66 | 66 | 'type' => 'file' |
67 | 67 | ), |
68 | 68 | array( |
69 | 69 | 'id' => 'from_name', |
70 | - 'name' => esc_html__( 'From Name', 'give' ), |
|
71 | - 'desc' => esc_html__( 'The name which appears in the "From" field in all Give donation emails.', 'give' ), |
|
72 | - 'default' => get_bloginfo( 'name' ), |
|
70 | + 'name' => esc_html__('From Name', 'give'), |
|
71 | + 'desc' => esc_html__('The name which appears in the "From" field in all Give donation emails.', 'give'), |
|
72 | + 'default' => get_bloginfo('name'), |
|
73 | 73 | 'type' => 'text' |
74 | 74 | ), |
75 | 75 | array( |
76 | 76 | 'id' => 'from_email', |
77 | - 'name' => esc_html__( 'From Email', 'give' ), |
|
78 | - 'desc' => esc_html__( 'Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ), |
|
79 | - 'default' => get_bloginfo( 'admin_email' ), |
|
77 | + 'name' => esc_html__('From Email', 'give'), |
|
78 | + 'desc' => esc_html__('Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give'), |
|
79 | + 'default' => get_bloginfo('admin_email'), |
|
80 | 80 | 'type' => 'text' |
81 | 81 | ), |
82 | 82 | array( |
83 | - 'name' => esc_html__( 'Email Settings Docs Link', 'give' ), |
|
83 | + 'name' => esc_html__('Email Settings Docs Link', 'give'), |
|
84 | 84 | 'id' => 'email_settings_docs_link', |
85 | - 'url' => esc_url( 'http://docs.givewp.com/settings-emails' ), |
|
86 | - 'title' => __( 'Email Settings', 'give' ), |
|
85 | + 'url' => esc_url('http://docs.givewp.com/settings-emails'), |
|
86 | + 'title' => __('Email Settings', 'give'), |
|
87 | 87 | 'type' => 'give_docs_link', |
88 | 88 | ), |
89 | 89 | array( |
@@ -102,27 +102,27 @@ discard block |
||
102 | 102 | ), |
103 | 103 | array( |
104 | 104 | 'id' => 'donation_subject', |
105 | - 'name' => esc_html__( 'Donation Email Subject', 'give' ), |
|
106 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
107 | - 'default' => esc_attr__( 'Donation Receipt', 'give' ), |
|
105 | + 'name' => esc_html__('Donation Email Subject', 'give'), |
|
106 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
107 | + 'default' => esc_attr__('Donation Receipt', 'give'), |
|
108 | 108 | 'type' => 'text' |
109 | 109 | ), |
110 | 110 | array( |
111 | 111 | 'id' => 'donation_receipt', |
112 | - 'name' => esc_html__( 'Donation Receipt', 'give' ), |
|
112 | + 'name' => esc_html__('Donation Receipt', 'give'), |
|
113 | 113 | 'desc' => sprintf( |
114 | 114 | /* translators: %s: emails tags list */ |
115 | - __( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted.<br /><strong>Available template tags:</strong> %s', 'give' ), |
|
115 | + __('Enter the email that is sent to users after completing a successful donation. HTML is accepted.<br /><strong>Available template tags:</strong> %s', 'give'), |
|
116 | 116 | '<br/>'.give_get_emails_tags_list() |
117 | 117 | ), |
118 | 118 | 'type' => 'wysiwyg', |
119 | 119 | 'default' => give_get_default_donation_receipt_email() |
120 | 120 | ), |
121 | 121 | array( |
122 | - 'name' => esc_html__( 'Donation Receipt Settings Docs Link', 'give' ), |
|
122 | + 'name' => esc_html__('Donation Receipt Settings Docs Link', 'give'), |
|
123 | 123 | 'id' => 'donation_receipt_settings_docs_link', |
124 | - 'url' => esc_url( 'http://docs.givewp.com/settings-donation-receipt' ), |
|
125 | - 'title' => __( 'Donation Receipt Settings', 'give' ), |
|
124 | + 'url' => esc_url('http://docs.givewp.com/settings-donation-receipt'), |
|
125 | + 'title' => __('Donation Receipt Settings', 'give'), |
|
126 | 126 | 'type' => 'give_docs_link', |
127 | 127 | ), |
128 | 128 | array( |
@@ -141,28 +141,28 @@ discard block |
||
141 | 141 | ), |
142 | 142 | array( |
143 | 143 | 'id' => 'admin_notices', |
144 | - 'name' => esc_html__( 'Admin Notifications', 'give' ), |
|
145 | - 'desc' => esc_html__( 'Enable/Disable all admin notifications from Give completely.', 'give' ), |
|
144 | + 'name' => esc_html__('Admin Notifications', 'give'), |
|
145 | + 'desc' => esc_html__('Enable/Disable all admin notifications from Give completely.', 'give'), |
|
146 | 146 | 'type' => 'radio_inline', |
147 | 147 | 'default' => 'enabled', |
148 | 148 | 'options' => array( |
149 | - 'enabled' => __( 'Enabled', 'give' ), |
|
150 | - 'disabled' => __( 'Disabled', 'give' ), |
|
149 | + 'enabled' => __('Enabled', 'give'), |
|
150 | + 'disabled' => __('Disabled', 'give'), |
|
151 | 151 | ) |
152 | 152 | ), |
153 | 153 | array( |
154 | 154 | 'id' => 'donation_notification_subject', |
155 | - 'name' => esc_html__( 'Donation Notification Subject', 'give' ), |
|
156 | - 'desc' => esc_html__( 'Enter the subject line for the admin donation notification email.', 'give' ), |
|
155 | + 'name' => esc_html__('Donation Notification Subject', 'give'), |
|
156 | + 'desc' => esc_html__('Enter the subject line for the admin donation notification email.', 'give'), |
|
157 | 157 | 'type' => 'text', |
158 | - 'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ) |
|
158 | + 'default' => esc_attr__('New Donation - #{payment_id}', 'give') |
|
159 | 159 | ), |
160 | 160 | array( |
161 | 161 | 'id' => 'donation_notification', |
162 | - 'name' => esc_html__( 'Donation Notification', 'give' ), |
|
162 | + 'name' => esc_html__('Donation Notification', 'give'), |
|
163 | 163 | 'desc' => sprintf( |
164 | 164 | /* translators: %s: emails tags list */ |
165 | - __( 'Enter the content of the email that is sent to notify an admin of a new donation. HTML is accepted. <br /><strong>Available template tags:</strong> %s', 'give' ), |
|
165 | + __('Enter the content of the email that is sent to notify an admin of a new donation. HTML is accepted. <br /><strong>Available template tags:</strong> %s', 'give'), |
|
166 | 166 | '<br/>'.give_get_emails_tags_list() |
167 | 167 | ), |
168 | 168 | 'type' => 'wysiwyg', |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | ), |
171 | 171 | array( |
172 | 172 | 'id' => 'admin_notice_emails', |
173 | - 'name' => esc_html__( 'Donation Notification Emails', 'give' ), |
|
174 | - 'desc' => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ), |
|
173 | + 'name' => esc_html__('Donation Notification Emails', 'give'), |
|
174 | + 'desc' => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'), |
|
175 | 175 | 'type' => 'textarea', |
176 | - 'default' => get_bloginfo( 'admin_email' ) |
|
176 | + 'default' => get_bloginfo('admin_email') |
|
177 | 177 | ), |
178 | 178 | array( |
179 | - 'name' => esc_html__( 'Donation Notification Settings Docs Link', 'give' ), |
|
179 | + 'name' => esc_html__('Donation Notification Settings Docs Link', 'give'), |
|
180 | 180 | 'id' => 'donation_notification_settings_docs_link', |
181 | - 'url' => esc_url( 'http://docs.givewp.com/settings-donation-notification' ), |
|
182 | - 'title' => __( 'Donation Notification Settings', 'give' ), |
|
181 | + 'url' => esc_url('http://docs.givewp.com/settings-donation-notification'), |
|
182 | + 'title' => __('Donation Notification Settings', 'give'), |
|
183 | 183 | 'type' => 'give_docs_link', |
184 | 184 | ), |
185 | 185 | array( |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * Filter the emails settings. |
195 | 195 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
196 | 196 | */ |
197 | - $settings = apply_filters( 'give_settings_emails', $settings ); |
|
197 | + $settings = apply_filters('give_settings_emails', $settings); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Filter the settings. |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @since 1.8 |
203 | 203 | * @param array $settings |
204 | 204 | */ |
205 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
205 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
206 | 206 | |
207 | 207 | // Output. |
208 | 208 | return $settings; |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function get_sections() { |
218 | 218 | $sections = array( |
219 | - 'email-settings' => esc_html__( 'Email Settings', 'give' ), |
|
220 | - 'donation-receipt' => esc_html__( 'Donation Receipt', 'give' ), |
|
221 | - 'new-donation-notification' => esc_html__( 'New Donation Notification', 'give' ) |
|
219 | + 'email-settings' => esc_html__('Email Settings', 'give'), |
|
220 | + 'donation-receipt' => esc_html__('Donation Receipt', 'give'), |
|
221 | + 'new-donation-notification' => esc_html__('New Donation Notification', 'give') |
|
222 | 222 | ); |
223 | 223 | |
224 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
224 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param $args |
67 | 67 | * |
68 | 68 | */ |
69 | - public function __construct( $args ) { |
|
69 | + public function __construct($args) { |
|
70 | 70 | |
71 | 71 | //Only for admins. |
72 | - if ( ! is_admin() ) { |
|
72 | + if ( ! is_admin()) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | //This plugin is en_US native. |
77 | 77 | $this->locale = get_locale(); |
78 | - if ( 'en_US' === $this->locale ) { |
|
78 | + if ('en_US' === $this->locale) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - $this->init( $args ); |
|
82 | + $this->init($args); |
|
83 | 83 | |
84 | - if ( ! $this->hide_promo() ) { |
|
85 | - add_action( $this->hook, array( $this, 'promo' ) ); |
|
84 | + if ( ! $this->hide_promo()) { |
|
85 | + add_action($this->hook, array($this, 'promo')); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param array $args |
95 | 95 | */ |
96 | - private function init( $args ) { |
|
97 | - foreach ( $args as $key => $arg ) { |
|
96 | + private function init($args) { |
|
97 | + foreach ($args as $key => $arg) { |
|
98 | 98 | $this->$key = $arg; |
99 | 99 | } |
100 | 100 | |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | */ |
110 | 110 | private function hide_promo() { |
111 | - $hide_promo = get_transient( 'give_i18n_give_promo_hide' ); |
|
112 | - if ( ! $hide_promo ) { |
|
113 | - if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) { |
|
111 | + $hide_promo = get_transient('give_i18n_give_promo_hide'); |
|
112 | + if ( ! $hide_promo) { |
|
113 | + if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) { |
|
114 | 114 | // No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc. |
115 | - set_transient( 'give_i18n_give_promo_hide', true ); |
|
115 | + set_transient('give_i18n_give_promo_hide', true); |
|
116 | 116 | $hide_promo = true; |
117 | 117 | } |
118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | $message = false; |
132 | 132 | |
133 | 133 | //Using a translation less than 90% complete. |
134 | - if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) { |
|
135 | - $message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' ); |
|
136 | - } elseif ( ! $this->translation_loaded && $this->translation_exists ) { |
|
137 | - $message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' ); |
|
138 | - } elseif ( ! $this->translation_exists ) { |
|
139 | - $message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' ); |
|
134 | + if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) { |
|
135 | + $message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give'); |
|
136 | + } elseif ( ! $this->translation_loaded && $this->translation_exists) { |
|
137 | + $message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give'); |
|
138 | + } elseif ( ! $this->translation_exists) { |
|
139 | + $message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | //Links. |
143 | - $registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) ); |
|
144 | - $translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) ); |
|
143 | + $registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give')); |
|
144 | + $translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give')); |
|
145 | 145 | |
146 | 146 | //Message. |
147 | - $message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link ); |
|
147 | + $message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link); |
|
148 | 148 | |
149 | 149 | |
150 | 150 | return $message; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $this->translation_details(); |
160 | 160 | $message = $this->promo_message(); |
161 | 161 | |
162 | - if ( $message ) { ?> |
|
162 | + if ($message) { ?> |
|
163 | 163 | |
164 | 164 | <style> |
165 | 165 | /* Banner specific styles */ |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | <a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a> |
213 | 213 | |
214 | 214 | <div class="give-i18n-notice-content"> |
215 | - <a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
215 | + <a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a> |
|
216 | 216 | |
217 | - <h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2> |
|
217 | + <h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2> |
|
218 | 218 | <p><?php echo $message; ?></p> |
219 | 219 | <p> |
220 | - <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now »', 'give' ); ?></a> |
|
220 | + <a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now »', 'give'); ?></a> |
|
221 | 221 | </p> |
222 | 222 | </div> |
223 | 223 | </div> |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | */ |
235 | 235 | private function find_or_initialize_translation_details() { |
236 | 236 | |
237 | - $set = get_transient( 'give_i18n_give_' . $this->locale ); |
|
237 | + $set = get_transient('give_i18n_give_'.$this->locale); |
|
238 | 238 | |
239 | - if ( ! $set ) { |
|
239 | + if ( ! $set) { |
|
240 | 240 | $set = $this->retrieve_translation_details(); |
241 | - set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS ); |
|
241 | + set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | return $set; |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | private function translation_details() { |
253 | 253 | $set = $this->find_or_initialize_translation_details(); |
254 | 254 | |
255 | - $this->translation_exists = ! is_null( $set ); |
|
256 | - $this->translation_loaded = is_textdomain_loaded( 'give' ); |
|
255 | + $this->translation_exists = ! is_null($set); |
|
256 | + $this->translation_loaded = is_textdomain_loaded('give'); |
|
257 | 257 | |
258 | - $this->parse_translation_set( $set ); |
|
258 | + $this->parse_translation_set($set); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -267,26 +267,26 @@ discard block |
||
267 | 267 | */ |
268 | 268 | private function retrieve_translation_details() { |
269 | 269 | |
270 | - $api_url = trailingslashit( $this->glotpress_url ); |
|
270 | + $api_url = trailingslashit($this->glotpress_url); |
|
271 | 271 | |
272 | - $resp = wp_remote_get( $api_url ); |
|
272 | + $resp = wp_remote_get($api_url); |
|
273 | 273 | |
274 | - if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) { |
|
274 | + if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') { |
|
275 | 275 | return null; |
276 | 276 | } |
277 | 277 | |
278 | - $body = wp_remote_retrieve_body( $resp ); |
|
279 | - unset( $resp ); |
|
278 | + $body = wp_remote_retrieve_body($resp); |
|
279 | + unset($resp); |
|
280 | 280 | |
281 | - if ( $body ) { |
|
282 | - $body = json_decode( $body ); |
|
281 | + if ($body) { |
|
282 | + $body = json_decode($body); |
|
283 | 283 | |
284 | - foreach ( $body->translation_sets as $set ) { |
|
285 | - if ( ! property_exists( $set, 'wp_locale' ) ) { |
|
284 | + foreach ($body->translation_sets as $set) { |
|
285 | + if ( ! property_exists($set, 'wp_locale')) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( $this->locale == $set->wp_locale ) { |
|
289 | + if ($this->locale == $set->wp_locale) { |
|
290 | 290 | return $set; |
291 | 291 | } |
292 | 292 | } |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @access private |
304 | 304 | */ |
305 | - private function parse_translation_set( $set ) { |
|
306 | - if ( $this->translation_exists && is_object( $set ) ) { |
|
305 | + private function parse_translation_set($set) { |
|
306 | + if ($this->translation_exists && is_object($set)) { |
|
307 | 307 | $this->locale_name = $set->name; |
308 | 308 | $this->percent_translated = $set->percent_translated; |
309 | 309 | } else { |
@@ -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 | |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | public function get_data() { |
59 | 59 | global $wpdb; |
60 | 60 | |
61 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
61 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
62 | 62 | |
63 | - if ( ! is_array( $items ) ) { |
|
63 | + if ( ! is_array($items)) { |
|
64 | 64 | return false; |
65 | 65 | } |
66 | 66 | |
67 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
68 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
67 | + $offset = ($this->step - 1) * $this->per_step; |
|
68 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
69 | 69 | |
70 | - if ( $step_items ) { |
|
70 | + if ($step_items) { |
|
71 | 71 | |
72 | 72 | $step_ids = array( |
73 | 73 | 'customers' => array(), |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | 'other' => array(), |
76 | 76 | ); |
77 | 77 | |
78 | - foreach ( $step_items as $item ) { |
|
78 | + foreach ($step_items as $item) { |
|
79 | 79 | |
80 | - switch ( $item['type'] ) { |
|
80 | + switch ($item['type']) { |
|
81 | 81 | case 'customer': |
82 | 82 | $step_ids['customers'][] = $item['id']; |
83 | 83 | break; |
@@ -85,25 +85,25 @@ discard block |
||
85 | 85 | $step_ids['give_forms'][] = $item['id']; |
86 | 86 | break; |
87 | 87 | default: |
88 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
89 | - $step_ids[ $item_type ][] = $item['id']; |
|
88 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
89 | + $step_ids[$item_type][] = $item['id']; |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | $sql = array(); |
95 | 95 | |
96 | - foreach ( $step_ids as $type => $ids ) { |
|
96 | + foreach ($step_ids as $type => $ids) { |
|
97 | 97 | |
98 | - if ( empty( $ids ) ) { |
|
98 | + if (empty($ids)) { |
|
99 | 99 | continue; |
100 | 100 | } |
101 | 101 | |
102 | - $ids = implode( ',', $ids ); |
|
102 | + $ids = implode(',', $ids); |
|
103 | 103 | |
104 | - switch ( $type ) { |
|
104 | + switch ($type) { |
|
105 | 105 | case 'customers': |
106 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
106 | + $table_name = $wpdb->prefix.'give_customers'; |
|
107 | 107 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
108 | 108 | break; |
109 | 109 | case 'forms': |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | break; |
119 | 119 | } |
120 | 120 | |
121 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
121 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
122 | 122 | // Allows other types of custom post types to filter on their own post_type |
123 | 123 | // and add items to the query list, for the IDs found in their post type. |
124 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
124 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! empty( $sql ) ) { |
|
129 | - foreach ( $sql as $query ) { |
|
130 | - $wpdb->query( $query ); |
|
128 | + if ( ! empty($sql)) { |
|
129 | + foreach ($sql as $query) { |
|
130 | + $wpdb->query($query); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function get_percentage_complete() { |
149 | 149 | |
150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
151 | - $total = count( $items ); |
|
150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
151 | + $total = count($items); |
|
152 | 152 | |
153 | 153 | $percentage = 100; |
154 | 154 | |
155 | - if ( $total > 0 ) { |
|
156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
155 | + if ($total > 0) { |
|
156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $percentage > 100 ) { |
|
159 | + if ($percentage > 100) { |
|
160 | 160 | $percentage = 100; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param array $request The Form Data passed into the batch processing |
172 | 172 | */ |
173 | - public function set_properties( $request ) { |
|
173 | + public function set_properties($request) { |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function process_step() { |
183 | 183 | |
184 | - if ( ! $this->can_export() ) { |
|
185 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
184 | + if ( ! $this->can_export()) { |
|
185 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $had_data = $this->get_data(); |
189 | 189 | |
190 | - if ( $had_data ) { |
|
190 | + if ($had_data) { |
|
191 | 191 | $this->done = false; |
192 | 192 | |
193 | 193 | return true; |
194 | 194 | } else { |
195 | - update_option( 'give_earnings_total', 0 ); |
|
196 | - delete_transient( 'give_earnings_total' ); |
|
197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
195 | + update_option('give_earnings_total', 0); |
|
196 | + delete_transient('give_earnings_total'); |
|
197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
199 | + $this->delete_data('give_temp_reset_ids'); |
|
200 | 200 | |
201 | 201 | // Reset the sequential order numbers |
202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
203 | - delete_option( 'give_last_payment_number' ); |
|
202 | + if (give_get_option('enable_sequential')) { |
|
203 | + delete_option('give_last_payment_number'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->done = true; |
207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
208 | 208 | |
209 | 209 | return false; |
210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | * Headers |
215 | 215 | */ |
216 | 216 | public function headers() { |
217 | - ignore_user_abort( true ); |
|
217 | + ignore_user_abort(true); |
|
218 | 218 | |
219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
220 | - set_time_limit( 0 ); |
|
219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
220 | + set_time_limit(0); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function pre_fetch() { |
243 | 243 | |
244 | - if ( $this->step == 1 ) { |
|
245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
244 | + if ($this->step == 1) { |
|
245 | + $this->delete_data('give_temp_reset_ids'); |
|
246 | 246 | } |
247 | 247 | |
248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
248 | + $items = get_option('give_temp_reset_ids', false); |
|
249 | 249 | |
250 | - if ( false === $items ) { |
|
250 | + if (false === $items) { |
|
251 | 251 | $items = array(); |
252 | 252 | |
253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
255 | 255 | |
256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
257 | 257 | 'post_type' => $give_types_for_reset, |
258 | 258 | 'post_status' => 'any', |
259 | - 'posts_per_page' => - 1, |
|
260 | - ) ); |
|
259 | + 'posts_per_page' => -1, |
|
260 | + )); |
|
261 | 261 | |
262 | - $posts = get_posts( $args ); |
|
263 | - foreach ( $posts as $post ) { |
|
262 | + $posts = get_posts($args); |
|
263 | + foreach ($posts as $post) { |
|
264 | 264 | $items[] = array( |
265 | 265 | 'id' => (int) $post->ID, |
266 | 266 | 'type' => $post->post_type, |
267 | 267 | ); |
268 | 268 | } |
269 | 269 | |
270 | - $customer_args = array( 'number' => - 1 ); |
|
271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
272 | - foreach ( $customers as $customer ) { |
|
270 | + $customer_args = array('number' => -1); |
|
271 | + $customers = Give()->customers->get_customers($customer_args); |
|
272 | + foreach ($customers as $customer) { |
|
273 | 273 | $items[] = array( |
274 | 274 | 'id' => (int) $customer->id, |
275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | |
279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
281 | - $items = apply_filters( 'give_reset_items', $items ); |
|
281 | + $items = apply_filters('give_reset_items', $items); |
|
282 | 282 | |
283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
283 | + $this->store_data('give_temp_reset_ids', $items); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return mixed Returns the data from the database. |
296 | 296 | */ |
297 | - private function get_stored_data( $key ) { |
|
297 | + private function get_stored_data($key) { |
|
298 | 298 | global $wpdb; |
299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
300 | 300 | |
301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
301 | + return empty($value) ? false : maybe_unserialize($value); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return void |
313 | 313 | */ |
314 | - private function store_data( $key, $value ) { |
|
314 | + private function store_data($key, $value) { |
|
315 | 315 | global $wpdb; |
316 | 316 | |
317 | - $value = maybe_serialize( $value ); |
|
317 | + $value = maybe_serialize($value); |
|
318 | 318 | |
319 | 319 | $data = array( |
320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | '%s', |
329 | 329 | ); |
330 | 330 | |
331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - private function delete_data( $key ) { |
|
343 | + private function delete_data($key) { |
|
344 | 344 | global $wpdb; |
345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @since 1.0 |
21 | 21 | */ |
22 | -class Give_Forms_Widget extends WP_Widget{ |
|
22 | +class Give_Forms_Widget extends WP_Widget { |
|
23 | 23 | /** |
24 | 24 | * The widget class name |
25 | 25 | * |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Instantiate the class |
32 | 32 | */ |
33 | - public function __construct(){ |
|
34 | - $this->self = get_class( $this ); |
|
33 | + public function __construct() { |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ){ |
|
55 | + public function admin_widget_scripts($hook) { |
|
56 | 56 | // Directories of assets |
57 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
58 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
59 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
57 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
58 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
59 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
60 | 60 | |
61 | 61 | // Use minified libraries if SCRIPT_DEBUG is turned off |
62 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
62 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
63 | 63 | |
64 | 64 | // Widget Script |
65 | - if ( $hook == 'widgets.php' ) { |
|
65 | + if ($hook == 'widgets.php') { |
|
66 | 66 | |
67 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
67 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
69 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
71 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * before_widget, and after_widget. |
80 | 80 | * @param array $instance The settings for the particular instance of the widget. |
81 | 81 | */ |
82 | - public function widget( $args, $instance ){ |
|
83 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
84 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + public function widget($args, $instance) { |
|
83 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
84 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
85 | 85 | |
86 | 86 | echo $args['before_widget']; |
87 | 87 | |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @since 1.0 |
92 | 92 | */ |
93 | - do_action( 'give_before_forms_widget' ); |
|
93 | + do_action('give_before_forms_widget'); |
|
94 | 94 | |
95 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; |
|
95 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; |
|
96 | 96 | |
97 | - give_get_donation_form( $instance ); |
|
97 | + give_get_donation_form($instance); |
|
98 | 98 | |
99 | 99 | echo $args['after_widget']; |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @since 1.0 |
105 | 105 | */ |
106 | - do_action( 'give_after_forms_widget' ); |
|
106 | + do_action('give_after_forms_widget'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public function form( $instance ){ |
|
116 | + public function form($instance) { |
|
117 | 117 | $defaults = array( |
118 | 118 | 'title' => '', |
119 | 119 | 'id' => '', |
@@ -122,77 +122,77 @@ discard block |
||
122 | 122 | 'show_content' => 'none', |
123 | 123 | ); |
124 | 124 | |
125 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
125 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
126 | 126 | |
127 | 127 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
128 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
128 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
129 | 129 | |
130 | 130 | // Query Give Forms |
131 | 131 | $args = array( |
132 | 132 | 'post_type' => 'give_forms', |
133 | - 'posts_per_page' => - 1, |
|
133 | + 'posts_per_page' => -1, |
|
134 | 134 | 'post_status' => 'publish', |
135 | 135 | ); |
136 | 136 | |
137 | - $give_forms = get_posts( $args ); |
|
137 | + $give_forms = get_posts($args); |
|
138 | 138 | |
139 | 139 | // Widget: Title |
140 | 140 | |
141 | 141 | ?><p> |
142 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
143 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $instance['title'] ); ?>" /><br> |
|
144 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
142 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
143 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($instance['title']); ?>" /><br> |
|
144 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
145 | 145 | </p><?php |
146 | 146 | |
147 | 147 | // Widget: Give Form |
148 | 148 | |
149 | 149 | ?><p> |
150 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
151 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
152 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
153 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
154 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
155 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $form_title; ?></option> |
|
150 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
151 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
152 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
153 | + <?php foreach ($give_forms as $give_form) { ?> |
|
154 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
155 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $form_title; ?></option> |
|
156 | 156 | <?php } ?> |
157 | 157 | </select><br> |
158 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
158 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
159 | 159 | </p> |
160 | 160 | |
161 | 161 | <?php // Widget: Display Style ?> |
162 | 162 | <p> |
163 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
164 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
165 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
166 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
167 | - <label for="<?php echo $this->get_field_id( 'display_style' ); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-button" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
163 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
164 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-onpage" name="<?php echo $this->get_field_name('display_style'); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
165 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-reveal" name="<?php echo $this->get_field_name('display_style'); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
166 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-modal" name="<?php echo $this->get_field_name('display_style'); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
167 | + <label for="<?php echo $this->get_field_id('display_style'); ?>-button"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?>-button" name="<?php echo $this->get_field_name('display_style'); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
168 | 168 | <small class="give-field-description"> |
169 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
169 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
170 | 170 | </small> |
171 | 171 | </p> |
172 | 172 | |
173 | 173 | <?php // Widget: Floating Labels ?> |
174 | 174 | <p> |
175 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
176 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-global" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
177 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-enabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
178 | - <label for="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'float_labels' ); ?>-disabled" name="<?php echo $this->get_field_name( 'float_labels' ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
175 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
176 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-global" name="<?php echo $this->get_field_name('float_labels'); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
177 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-enabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
178 | + <label for="<?php echo $this->get_field_id('float_labels'); ?>-disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?>-disabled" name="<?php echo $this->get_field_name('float_labels'); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
179 | 179 | <small class="give-field-description"> |
180 | 180 | <?php |
181 | 181 | printf( |
182 | 182 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
183 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
184 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
183 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
184 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
185 | 185 | ); |
186 | 186 | ?></small> |
187 | 187 | </p> |
188 | 188 | |
189 | 189 | <?php // Widget: Display Content ?> |
190 | 190 | <p> |
191 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
192 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
193 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
194 | - <label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
195 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
191 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
192 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-none" name="<?php echo $this->get_field_name('show_content'); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
193 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-above" name="<?php echo $this->get_field_name('show_content'); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
194 | + <label for="<?php echo $this->get_field_id('show_content'); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('show_content'); ?>-below" name="<?php echo $this->get_field_name('show_content'); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
195 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
196 | 196 | <?php |
197 | 197 | } |
198 | 198 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - function widget_init(){ |
|
205 | - register_widget( $this->self ); |
|
204 | + function widget_init() { |
|
205 | + register_widget($this->self); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return array |
215 | 215 | */ |
216 | - public function update( $new_instance, $old_instance ){ |
|
216 | + public function update($new_instance, $old_instance) { |
|
217 | 217 | $this->flush_widget_cache(); |
218 | 218 | |
219 | 219 | return $new_instance; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return void |
226 | 226 | */ |
227 | - public function flush_widget_cache(){ |
|
228 | - wp_cache_delete( $this->self, 'widget' ); |
|
227 | + public function flush_widget_cache() { |
|
228 | + wp_cache_delete($this->self, 'widget'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_purchase_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
163 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
164 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer. |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,44 +247,44 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
274 | + if (give_is_terms_enabled($form_id)) { |
|
275 | 275 | give_purchase_form_validate_agree_to_terms(); |
276 | 276 | } |
277 | 277 | |
278 | - if ( is_user_logged_in() ) { |
|
278 | + if (is_user_logged_in()) { |
|
279 | 279 | // Collect logged in user data |
280 | 280 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
281 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
281 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
282 | 282 | // Set new user registration as required |
283 | 283 | $valid_data['need_new_user'] = true; |
284 | 284 | // Validate new user data |
285 | 285 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
286 | 286 | // Check if login validation is needed |
287 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
287 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
288 | 288 | // Set user login as required |
289 | 289 | $valid_data['need_user_login'] = true; |
290 | 290 | // Validate users login info |
@@ -309,41 +309,41 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function give_purchase_form_validate_gateway() { |
311 | 311 | |
312 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
313 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
314 | - $gateway = give_get_default_gateway( $form_id ); |
|
312 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
313 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
314 | + $gateway = give_get_default_gateway($form_id); |
|
315 | 315 | |
316 | 316 | // Check if a gateway value is present |
317 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
317 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
318 | 318 | |
319 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
319 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
320 | 320 | |
321 | 321 | // Is amount being donated in LIVE mode 0.00? If so, error: |
322 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
322 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
323 | 323 | |
324 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
324 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
325 | 325 | |
326 | 326 | } //Check for a minimum custom amount |
327 | - elseif ( ! give_verify_minimum_price() ) { |
|
327 | + elseif ( ! give_verify_minimum_price()) { |
|
328 | 328 | // translators: %s: minimum donation amount. |
329 | 329 | give_set_error( |
330 | 330 | 'invalid_donation_minimum', |
331 | 331 | sprintf( |
332 | 332 | /* translators: %s: minimum donation amount */ |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // Default user data. |
547 | 547 | $default_user_data = array( |
548 | 548 | 'give-form-id' => '', |
549 | - 'user_id' => - 1, // Assume there will be errors. |
|
549 | + 'user_id' => -1, // Assume there will be errors. |
|
550 | 550 | 'user_first' => '', |
551 | 551 | 'user_last' => '', |
552 | 552 | 'give_user_login' => false, |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | ); |
557 | 557 | |
558 | 558 | // Get user data. |
559 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
559 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
560 | 560 | $registering_new_user = false; |
561 | - $form_id = absint( $user_data['give-form-id'] ); |
|
561 | + $form_id = absint($user_data['give-form-id']); |
|
562 | 562 | |
563 | 563 | // Start an empty array to collect valid user data. |
564 | 564 | $valid_user_data = array( |
565 | 565 | // Assume there will be errors. |
566 | - 'user_id' => - 1, |
|
566 | + 'user_id' => -1, |
|
567 | 567 | |
568 | 568 | // Get first name. |
569 | 569 | 'user_first' => $user_data['give_first'], |
@@ -573,25 +573,25 @@ discard block |
||
573 | 573 | ); |
574 | 574 | |
575 | 575 | // Loop through required fields and show error messages. |
576 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
577 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
578 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
576 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
577 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
578 | + give_set_error($value['error_id'], $value['error_message']); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | // Check if we have an username to register. |
583 | - if( give_validate_username( $user_data['give_user_login'] ) ) { |
|
583 | + if (give_validate_username($user_data['give_user_login'])) { |
|
584 | 584 | $registering_new_user = true; |
585 | 585 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
586 | 586 | } |
587 | 587 | |
588 | 588 | // Check if we have an email to verify. |
589 | - if( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
589 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
590 | 590 | $valid_user_data['user_email'] = $user_data['give_email']; |
591 | 591 | } |
592 | 592 | |
593 | 593 | // Check password. |
594 | - if( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)){ |
|
594 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
595 | 595 | // All is good to go. |
596 | 596 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
597 | 597 | } |
@@ -611,36 +611,36 @@ discard block |
||
611 | 611 | // Start an array to collect valid user data. |
612 | 612 | $valid_user_data = array( |
613 | 613 | // Assume there will be errors |
614 | - 'user_id' => - 1, |
|
614 | + 'user_id' => -1, |
|
615 | 615 | ); |
616 | 616 | |
617 | 617 | // Username. |
618 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
619 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
618 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
619 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
620 | 620 | |
621 | 621 | return $valid_user_data; |
622 | 622 | } |
623 | 623 | |
624 | 624 | // Get the user by login. |
625 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
625 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
626 | 626 | |
627 | 627 | // Check if user exists. |
628 | - if ( $user_data ) { |
|
628 | + if ($user_data) { |
|
629 | 629 | // Get password. |
630 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
630 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
631 | 631 | |
632 | 632 | // Check user_pass. |
633 | - if ( $user_pass ) { |
|
633 | + if ($user_pass) { |
|
634 | 634 | // Check if password is valid. |
635 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
635 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
636 | 636 | // Incorrect password. |
637 | 637 | give_set_error( |
638 | 638 | 'password_incorrect', |
639 | 639 | sprintf( |
640 | 640 | '%1$s <a href="%2$s">%3$s</a>', |
641 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
642 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
643 | - esc_html__( 'Reset Password', 'give' ) |
|
641 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
642 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
643 | + esc_html__('Reset Password', 'give') |
|
644 | 644 | ) |
645 | 645 | ); |
646 | 646 | // All is correct. |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | } |
658 | 658 | } else { |
659 | 659 | // Empty password. |
660 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
660 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
661 | 661 | } |
662 | 662 | } else { |
663 | 663 | // No username. |
664 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
664 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $valid_user_data; |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | */ |
677 | 677 | function give_purchase_form_validate_guest_user() { |
678 | 678 | |
679 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
679 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
680 | 680 | |
681 | 681 | // Start an array to collect valid user data. |
682 | 682 | $valid_user_data = array( |
@@ -685,38 +685,38 @@ discard block |
||
685 | 685 | ); |
686 | 686 | |
687 | 687 | // Show error message if user must be logged in. |
688 | - if ( give_logged_in_only( $form_id ) ) { |
|
689 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
688 | + if (give_logged_in_only($form_id)) { |
|
689 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // Get the guest email. |
693 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
693 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
694 | 694 | |
695 | 695 | // Check email. |
696 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
696 | + if ($guest_email && strlen($guest_email) > 0) { |
|
697 | 697 | // Validate email. |
698 | - if ( ! is_email( $guest_email ) ) { |
|
698 | + if ( ! is_email($guest_email)) { |
|
699 | 699 | // Invalid email. |
700 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
700 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
701 | 701 | } else { |
702 | 702 | // All is good to go. |
703 | 703 | $valid_user_data['user_email'] = $guest_email; |
704 | 704 | |
705 | 705 | // Get user_id from donor if exist. |
706 | - $donor = new Give_Customer( $guest_email ); |
|
707 | - if ( $donor->id && $donor->user_id ) { |
|
706 | + $donor = new Give_Customer($guest_email); |
|
707 | + if ($donor->id && $donor->user_id) { |
|
708 | 708 | $valid_user_data['user_id'] = $donor->user_id; |
709 | 709 | } |
710 | 710 | } |
711 | 711 | } else { |
712 | 712 | // No email. |
713 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
713 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | // Loop through required fields and show error messages. |
717 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
718 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
719 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
717 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
718 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
719 | + give_set_error($value['error_id'], $value['error_message']); |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
@@ -732,36 +732,36 @@ discard block |
||
732 | 732 | * @since 1.0 |
733 | 733 | * @return integer |
734 | 734 | */ |
735 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
735 | +function give_register_and_login_new_user($user_data = array()) { |
|
736 | 736 | // Verify the array. |
737 | - if ( empty( $user_data ) ) { |
|
738 | - return - 1; |
|
737 | + if (empty($user_data)) { |
|
738 | + return -1; |
|
739 | 739 | } |
740 | 740 | |
741 | - if ( give_get_errors() ) { |
|
742 | - return - 1; |
|
741 | + if (give_get_errors()) { |
|
742 | + return -1; |
|
743 | 743 | } |
744 | 744 | |
745 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
746 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
747 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
748 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
749 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
750 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
751 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
752 | - 'role' => get_option( 'default_role' ), |
|
753 | - ), $user_data ); |
|
745 | + $user_args = apply_filters('give_insert_user_args', array( |
|
746 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
747 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
748 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
749 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
750 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
751 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
752 | + 'role' => get_option('default_role'), |
|
753 | + ), $user_data); |
|
754 | 754 | |
755 | 755 | // Insert new user. |
756 | - $user_id = wp_insert_user( $user_args ); |
|
756 | + $user_id = wp_insert_user($user_args); |
|
757 | 757 | |
758 | 758 | // Validate inserted user. |
759 | - if ( is_wp_error( $user_id ) ) { |
|
760 | - return - 1; |
|
759 | + if (is_wp_error($user_id)) { |
|
760 | + return -1; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | // Allow themes and plugins to filter the user data. |
764 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
764 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
765 | 765 | |
766 | 766 | /** |
767 | 767 | * Fires after inserting user. |
@@ -771,10 +771,10 @@ discard block |
||
771 | 771 | * @param int $user_id User id. |
772 | 772 | * @param array $user_data Array containing user data. |
773 | 773 | */ |
774 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
774 | + do_action('give_insert_user', $user_id, $user_data); |
|
775 | 775 | |
776 | 776 | // Login new user. |
777 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
777 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
778 | 778 | |
779 | 779 | // Return user id. |
780 | 780 | return $user_id; |
@@ -789,27 +789,27 @@ discard block |
||
789 | 789 | * @since 1.0 |
790 | 790 | * @return array |
791 | 791 | */ |
792 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
792 | +function give_get_purchase_form_user($valid_data = array()) { |
|
793 | 793 | |
794 | 794 | // Initialize user. |
795 | 795 | $user = false; |
796 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
796 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
797 | 797 | |
798 | - if ( $is_ajax ) { |
|
798 | + if ($is_ajax) { |
|
799 | 799 | // Do not create or login the user during the ajax submission (check for errors only). |
800 | 800 | return true; |
801 | - } elseif ( is_user_logged_in() ) { |
|
801 | + } elseif (is_user_logged_in()) { |
|
802 | 802 | // Set the valid user as the logged in collected data. |
803 | 803 | $user = $valid_data['logged_in_user']; |
804 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
804 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
805 | 805 | // New user registration. |
806 | - if ( $valid_data['need_new_user'] === true ) { |
|
806 | + if ($valid_data['need_new_user'] === true) { |
|
807 | 807 | // Set user. |
808 | 808 | $user = $valid_data['new_user_data']; |
809 | 809 | // Register and login new user. |
810 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
810 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
811 | 811 | // User login |
812 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
812 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
813 | 813 | |
814 | 814 | /* |
815 | 815 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -822,48 +822,48 @@ discard block |
||
822 | 822 | // Set user. |
823 | 823 | $user = $valid_data['login_user_data']; |
824 | 824 | // Login user. |
825 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
825 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | |
829 | 829 | // Check guest checkout. |
830 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
830 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
831 | 831 | // Set user |
832 | 832 | $user = $valid_data['guest_user_data']; |
833 | 833 | } |
834 | 834 | |
835 | 835 | // Verify we have an user. |
836 | - if ( false === $user || empty( $user ) ) { |
|
836 | + if (false === $user || empty($user)) { |
|
837 | 837 | // Return false. |
838 | 838 | return false; |
839 | 839 | } |
840 | 840 | |
841 | 841 | // Get user first name. |
842 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
843 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
842 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
843 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Get user last name. |
847 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
848 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
847 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
848 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | // Get the user's billing address details. |
852 | 852 | $user['address'] = array(); |
853 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
854 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
855 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
856 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
857 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
858 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
859 | - |
|
860 | - if ( empty( $user['address']['country'] ) ) { |
|
853 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
854 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
855 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
856 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
857 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
858 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
859 | + |
|
860 | + if (empty($user['address']['country'])) { |
|
861 | 861 | $user['address'] = false; |
862 | 862 | } // Country will always be set if address fields are present. |
863 | 863 | |
864 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
864 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
865 | 865 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
866 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
866 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | // Return valid user. |
@@ -882,16 +882,16 @@ discard block |
||
882 | 882 | $card_data = give_get_purchase_cc_info(); |
883 | 883 | |
884 | 884 | // Validate the card zip. |
885 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
886 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
887 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
885 | + if ( ! empty($card_data['card_zip'])) { |
|
886 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
887 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
891 | 891 | // Ensure no spaces. |
892 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
893 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
894 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
892 | + if ( ! empty($card_data['card_number'])) { |
|
893 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
894 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // This should validate card numbers at some point too. |
@@ -907,17 +907,17 @@ discard block |
||
907 | 907 | */ |
908 | 908 | function give_get_purchase_cc_info() { |
909 | 909 | $cc_info = array(); |
910 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
911 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
912 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
913 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
914 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
915 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
916 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
917 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
918 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
919 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
920 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
910 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
911 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
912 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
913 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
914 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
915 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
916 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
917 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
918 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
919 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
920 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
921 | 921 | |
922 | 922 | // Return cc info |
923 | 923 | return $cc_info; |
@@ -933,14 +933,14 @@ discard block |
||
933 | 933 | * |
934 | 934 | * @return bool|mixed|void |
935 | 935 | */ |
936 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
936 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
937 | 937 | $ret = false; |
938 | 938 | |
939 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
939 | + if (empty($zip) || empty($country_code)) { |
|
940 | 940 | return $ret; |
941 | 941 | } |
942 | 942 | |
943 | - $country_code = strtoupper( $country_code ); |
|
943 | + $country_code = strtoupper($country_code); |
|
944 | 944 | |
945 | 945 | $zip_regex = array( |
946 | 946 | 'AD' => 'AD\d{3}', |
@@ -1100,11 +1100,11 @@ discard block |
||
1100 | 1100 | 'ZM' => '\d{5}', |
1101 | 1101 | ); |
1102 | 1102 | |
1103 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1103 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1104 | 1104 | $ret = true; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1107 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | |
@@ -1118,36 +1118,36 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @return bool |
1120 | 1120 | */ |
1121 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1121 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1122 | 1122 | /* @var Give_Donate_Form $form */ |
1123 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1123 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1124 | 1124 | |
1125 | 1125 | $donation_level_matched = false; |
1126 | 1126 | |
1127 | - if ( $form->is_multi_type_donation_form() ) { |
|
1127 | + if ($form->is_multi_type_donation_form()) { |
|
1128 | 1128 | |
1129 | 1129 | // Bailout. |
1130 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1130 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | // Sanitize donation amount. |
1135 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1135 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1136 | 1136 | |
1137 | 1137 | // Get number of decimals. |
1138 | 1138 | $default_decimals = give_get_price_decimals(); |
1139 | 1139 | |
1140 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1140 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1141 | 1141 | return true; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | // Find correct donation level from all donation levels. |
1145 | - foreach ( $variable_prices as $variable_price ) { |
|
1145 | + foreach ($variable_prices as $variable_price) { |
|
1146 | 1146 | // Sanitize level amount. |
1147 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1147 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1148 | 1148 | |
1149 | 1149 | // Set first match donation level ID. |
1150 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1150 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1151 | 1151 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1152 | 1152 | $donation_level_matched = true; |
1153 | 1153 | break; |
@@ -1158,19 +1158,19 @@ discard block |
||
1158 | 1158 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1159 | 1159 | if ( |
1160 | 1160 | ! $donation_level_matched |
1161 | - && ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1161 | + && (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1162 | 1162 | ) { |
1163 | 1163 | // Sanitize custom minimum amount. |
1164 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1164 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1165 | 1165 | |
1166 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1166 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1167 | 1167 | $_POST['give-price-id'] = 'custom'; |
1168 | 1168 | $donation_level_matched = true; |
1169 | 1169 | } |
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - return ( $donation_level_matched ? true : false ); |
|
1173 | + return ($donation_level_matched ? true : false); |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1176 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -144,29 +144,29 @@ discard block |
||
144 | 144 | * @param bool $_id_or_email |
145 | 145 | * @param bool $by_user_id |
146 | 146 | */ |
147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
148 | 148 | |
149 | 149 | $this->db = new Give_DB_Customers; |
150 | 150 | |
151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
156 | 156 | |
157 | - if ( is_numeric( $_id_or_email ) ) { |
|
157 | + if (is_numeric($_id_or_email)) { |
|
158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
159 | 159 | } else { |
160 | 160 | $field = 'email'; |
161 | 161 | } |
162 | 162 | |
163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
164 | 164 | |
165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
165 | + if (empty($customer) || ! is_object($customer)) { |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
169 | - $this->setup_customer( $customer ); |
|
169 | + $this->setup_customer($customer); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool If the setup was successful or not. |
184 | 184 | */ |
185 | - private function setup_customer( $customer ) { |
|
185 | + private function setup_customer($customer) { |
|
186 | 186 | |
187 | - if ( ! is_object( $customer ) ) { |
|
187 | + if ( ! is_object($customer)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( $customer as $key => $value ) { |
|
191 | + foreach ($customer as $key => $value) { |
|
192 | 192 | |
193 | - switch ( $key ) { |
|
193 | + switch ($key) { |
|
194 | 194 | |
195 | 195 | case 'notes': |
196 | 196 | $this->$key = $this->get_notes(); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | // Get donor's all email including primary email. |
208 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
209 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
208 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
209 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
210 | 210 | |
211 | 211 | // Customer ID and email are the only things that are necessary, make sure they exist. |
212 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
212 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * @since 1.0 |
224 | 224 | * @access public |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '' |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Customer attributes. |
278 | 278 | */ |
279 | - do_action( 'give_customer_pre_create', $args ); |
|
279 | + do_action('give_customer_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the customer, reset the class vars with the new data |
287 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
287 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the customer data with the values from DB |
290 | - $this->setup_customer( $customer ); |
|
290 | + $this->setup_customer($customer); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * customer ID if user is found or valid creation. |
302 | 302 | * @param array $args Customer attributes. |
303 | 303 | */ |
304 | - do_action( 'give_customer_post_create', $created, $args ); |
|
304 | + do_action('give_customer_post_create', $created, $args); |
|
305 | 305 | |
306 | 306 | return $created; |
307 | 307 | |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return bool If the update was successful or not. |
319 | 319 | */ |
320 | - public function update( $data = array() ) { |
|
320 | + public function update($data = array()) { |
|
321 | 321 | |
322 | - if ( empty( $data ) ) { |
|
322 | + if (empty($data)) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | - $data = $this->sanitize_columns( $data ); |
|
326 | + $data = $this->sanitize_columns($data); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Fires before updating customers. |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * @param int $customer_id Customer id. |
334 | 334 | * @param array $data Customer attributes. |
335 | 335 | */ |
336 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
336 | + do_action('give_customer_pre_update', $this->id, $data); |
|
337 | 337 | |
338 | 338 | $updated = false; |
339 | 339 | |
340 | - if ( $this->db->update( $this->id, $data ) ) { |
|
340 | + if ($this->db->update($this->id, $data)) { |
|
341 | 341 | |
342 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
343 | - $this->setup_customer( $customer ); |
|
342 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
343 | + $this->setup_customer($customer); |
|
344 | 344 | |
345 | 345 | $updated = true; |
346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param int $customer_id Customer id. |
355 | 355 | * @param array $data Customer attributes. |
356 | 356 | */ |
357 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
357 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
358 | 358 | |
359 | 359 | return $updated; |
360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return bool If the attachment was successfuly. |
374 | 374 | */ |
375 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
375 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
376 | 376 | |
377 | - if ( empty( $payment_id ) ) { |
|
377 | + if (empty($payment_id)) { |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if ( empty( $this->payment_ids ) ) { |
|
381 | + if (empty($this->payment_ids)) { |
|
382 | 382 | |
383 | 383 | $new_payment_ids = $payment_id; |
384 | 384 | |
385 | 385 | } else { |
386 | 386 | |
387 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
387 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
388 | 388 | |
389 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
389 | + if (in_array($payment_id, $payment_ids)) { |
|
390 | 390 | $update_stats = false; |
391 | 391 | } |
392 | 392 | |
393 | 393 | $payment_ids[] = $payment_id; |
394 | 394 | |
395 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
395 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
@@ -404,20 +404,20 @@ discard block |
||
404 | 404 | * @param int $payment_id Payment id. |
405 | 405 | * @param int $customer_id Customer id. |
406 | 406 | */ |
407 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
407 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
408 | 408 | |
409 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
409 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
410 | 410 | |
411 | - if ( $payment_added ) { |
|
411 | + if ($payment_added) { |
|
412 | 412 | |
413 | 413 | $this->payment_ids = $new_payment_ids; |
414 | 414 | |
415 | 415 | // We added this payment successfully, increment the stats |
416 | - if ( $update_stats ) { |
|
417 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
416 | + if ($update_stats) { |
|
417 | + $payment_amount = give_get_payment_amount($payment_id); |
|
418 | 418 | |
419 | - if ( ! empty( $payment_amount ) ) { |
|
420 | - $this->increase_value( $payment_amount ); |
|
419 | + if ( ! empty($payment_amount)) { |
|
420 | + $this->increase_value($payment_amount); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | $this->increase_purchase_count(); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @param int $payment_id Payment id. |
435 | 435 | * @param int $customer_id Customer id. |
436 | 436 | */ |
437 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
437 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
438 | 438 | |
439 | 439 | return $payment_added; |
440 | 440 | } |
@@ -452,33 +452,33 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return boolean If the removal was successful. |
454 | 454 | */ |
455 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
455 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
456 | 456 | |
457 | - if ( empty( $payment_id ) ) { |
|
457 | + if (empty($payment_id)) { |
|
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | |
461 | - $payment = new Give_Payment( $payment_id ); |
|
461 | + $payment = new Give_Payment($payment_id); |
|
462 | 462 | |
463 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
463 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
464 | 464 | $update_stats = false; |
465 | 465 | } |
466 | 466 | |
467 | 467 | $new_payment_ids = ''; |
468 | 468 | |
469 | - if ( ! empty( $this->payment_ids ) ) { |
|
469 | + if ( ! empty($this->payment_ids)) { |
|
470 | 470 | |
471 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
471 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
472 | 472 | |
473 | - $pos = array_search( $payment_id, $payment_ids ); |
|
474 | - if ( false === $pos ) { |
|
473 | + $pos = array_search($payment_id, $payment_ids); |
|
474 | + if (false === $pos) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
478 | - unset( $payment_ids[ $pos ] ); |
|
479 | - $payment_ids = array_filter( $payment_ids ); |
|
478 | + unset($payment_ids[$pos]); |
|
479 | + $payment_ids = array_filter($payment_ids); |
|
480 | 480 | |
481 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
481 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -490,20 +490,20 @@ discard block |
||
490 | 490 | * @param int $payment_id Payment id. |
491 | 491 | * @param int $customer_id Customer id. |
492 | 492 | */ |
493 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
493 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
494 | 494 | |
495 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
495 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
496 | 496 | |
497 | - if ( $payment_removed ) { |
|
497 | + if ($payment_removed) { |
|
498 | 498 | |
499 | 499 | $this->payment_ids = $new_payment_ids; |
500 | 500 | |
501 | - if ( $update_stats ) { |
|
501 | + if ($update_stats) { |
|
502 | 502 | // We removed this payment successfully, decrement the stats |
503 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
503 | + $payment_amount = give_get_payment_amount($payment_id); |
|
504 | 504 | |
505 | - if ( ! empty( $payment_amount ) ) { |
|
506 | - $this->decrease_value( $payment_amount ); |
|
505 | + if ( ! empty($payment_amount)) { |
|
506 | + $this->decrease_value($payment_amount); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @param int $payment_id Payment id. |
521 | 521 | * @param int $customer_id Customer id. |
522 | 522 | */ |
523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
524 | 524 | |
525 | 525 | return $payment_removed; |
526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int The donation count. |
538 | 538 | */ |
539 | - public function increase_purchase_count( $count = 1 ) { |
|
539 | + public function increase_purchase_count($count = 1) { |
|
540 | 540 | |
541 | 541 | // Make sure it's numeric and not negative. |
542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | * @param int $count The number to increase by. |
554 | 554 | * @param int $customer_id Customer id. |
555 | 555 | */ |
556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
557 | 557 | |
558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
559 | 559 | $this->purchase_count = $new_total; |
560 | 560 | } |
561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param int $count The number increased by. |
569 | 569 | * @param int $customer_id Customer id. |
570 | 570 | */ |
571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
572 | 572 | |
573 | 573 | return $this->purchase_count; |
574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * |
584 | 584 | * @return mixed If successful, the new count, otherwise false. |
585 | 585 | */ |
586 | - public function decrease_purchase_count( $count = 1 ) { |
|
586 | + public function decrease_purchase_count($count = 1) { |
|
587 | 587 | |
588 | 588 | // Make sure it's numeric and not negative |
589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
590 | 590 | return false; |
591 | 591 | } |
592 | 592 | |
593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
594 | 594 | |
595 | - if ( $new_total < 0 ) { |
|
595 | + if ($new_total < 0) { |
|
596 | 596 | $new_total = 0; |
597 | 597 | } |
598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
604 | 604 | * @param int $count The number to decrease by. |
605 | 605 | * @param int $customer_id Customer id. |
606 | 606 | */ |
607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
608 | 608 | |
609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
610 | 610 | $this->purchase_count = $new_total; |
611 | 611 | } |
612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param int $count The number decreased by. |
620 | 620 | * @param int $customer_id Customer id. |
621 | 621 | */ |
622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
623 | 623 | |
624 | 624 | return $this->purchase_count; |
625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return mixed If successful, the new value, otherwise false. |
636 | 636 | */ |
637 | - public function increase_value( $value = 0.00 ) { |
|
637 | + public function increase_value($value = 0.00) { |
|
638 | 638 | |
639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
639 | + $new_value = floatval($this->purchase_value) + $value; |
|
640 | 640 | |
641 | 641 | /** |
642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @param float $value The value to increase by. |
647 | 647 | * @param int $customer_id Customer id. |
648 | 648 | */ |
649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
650 | 650 | |
651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
652 | 652 | $this->purchase_value = $new_value; |
653 | 653 | } |
654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @param float $value The value increased by. |
662 | 662 | * @param int $customer_id Customer id. |
663 | 663 | */ |
664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
665 | 665 | |
666 | 666 | return $this->purchase_value; |
667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | * |
677 | 677 | * @return mixed If successful, the new value, otherwise false. |
678 | 678 | */ |
679 | - public function decrease_value( $value = 0.00 ) { |
|
679 | + public function decrease_value($value = 0.00) { |
|
680 | 680 | |
681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
681 | + $new_value = floatval($this->purchase_value) - $value; |
|
682 | 682 | |
683 | - if ( $new_value < 0 ) { |
|
683 | + if ($new_value < 0) { |
|
684 | 684 | $new_value = 0.00; |
685 | 685 | } |
686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * @param float $value The value to decrease by. |
693 | 693 | * @param int $customer_id Customer id. |
694 | 694 | */ |
695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
696 | 696 | |
697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
698 | 698 | $this->purchase_value = $new_value; |
699 | 699 | } |
700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param float $value The value decreased by. |
708 | 708 | * @param int $customer_id Customer id. |
709 | 709 | */ |
710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
711 | 711 | |
712 | 712 | return $this->purchase_value; |
713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * |
727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
728 | 728 | */ |
729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
730 | 730 | /** |
731 | 731 | * Payment total difference value can be: |
732 | 732 | * zero (in case amount not change) |
@@ -736,13 +736,13 @@ discard block |
||
736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
737 | 737 | |
738 | 738 | // We do not need to update donation stat if donation did not change. |
739 | - if( ! $payment_total_diff ) { |
|
739 | + if ( ! $payment_total_diff) { |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
743 | 743 | |
744 | - if( $payment_total_diff > 0 ) { |
|
745 | - $this->increase_value( $payment_total_diff ); |
|
744 | + if ($payment_total_diff > 0) { |
|
745 | + $this->increase_value($payment_total_diff); |
|
746 | 746 | } else { |
747 | 747 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
748 | 748 | $this->decrease_value( -$payment_total_diff ); |
@@ -762,15 +762,15 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @return array The notes requested. |
764 | 764 | */ |
765 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
765 | + public function get_notes($length = 20, $paged = 1) { |
|
766 | 766 | |
767 | - $length = is_numeric( $length ) ? $length : 20; |
|
768 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
767 | + $length = is_numeric($length) ? $length : 20; |
|
768 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
769 | 769 | |
770 | 770 | $all_notes = $this->get_raw_notes(); |
771 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
771 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
772 | 772 | |
773 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
773 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
774 | 774 | |
775 | 775 | return $desired_notes; |
776 | 776 | |
@@ -787,9 +787,9 @@ discard block |
||
787 | 787 | public function get_notes_count() { |
788 | 788 | |
789 | 789 | $all_notes = $this->get_raw_notes(); |
790 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
790 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
791 | 791 | |
792 | - return count( $notes_array ); |
|
792 | + return count($notes_array); |
|
793 | 793 | |
794 | 794 | } |
795 | 795 | |
@@ -803,22 +803,22 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @return string|boolean The new note if added successfully, false otherwise. |
805 | 805 | */ |
806 | - public function add_note( $note = '' ) { |
|
806 | + public function add_note($note = '') { |
|
807 | 807 | |
808 | - $note = trim( $note ); |
|
809 | - if ( empty( $note ) ) { |
|
808 | + $note = trim($note); |
|
809 | + if (empty($note)) { |
|
810 | 810 | return false; |
811 | 811 | } |
812 | 812 | |
813 | 813 | $notes = $this->get_raw_notes(); |
814 | 814 | |
815 | - if ( empty( $notes ) ) { |
|
815 | + if (empty($notes)) { |
|
816 | 816 | $notes = ''; |
817 | 817 | } |
818 | 818 | |
819 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
820 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
821 | - $notes .= "\n\n" . $new_note; |
|
819 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
820 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
821 | + $notes .= "\n\n".$new_note; |
|
822 | 822 | |
823 | 823 | /** |
824 | 824 | * Fires before customer note added. |
@@ -828,11 +828,11 @@ discard block |
||
828 | 828 | * @param string $new_note New note to add. |
829 | 829 | * @param int $customer_id Customer id. |
830 | 830 | */ |
831 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
831 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
832 | 832 | |
833 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
833 | + $updated = $this->update(array('notes' => $notes)); |
|
834 | 834 | |
835 | - if ( $updated ) { |
|
835 | + if ($updated) { |
|
836 | 836 | $this->notes = $this->get_notes(); |
837 | 837 | } |
838 | 838 | |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | * @param string $new_note New note added. |
846 | 846 | * @param int $customer_id Customer id. |
847 | 847 | */ |
848 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
848 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
849 | 849 | |
850 | 850 | // Return the formatted note, so we can test, as well as update any displays |
851 | 851 | return $new_note; |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | */ |
863 | 863 | private function get_raw_notes() { |
864 | 864 | |
865 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
865 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
866 | 866 | |
867 | 867 | return $all_notes; |
868 | 868 | |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
881 | 881 | */ |
882 | - public function get_meta( $meta_key = '', $single = true ) { |
|
883 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
882 | + public function get_meta($meta_key = '', $single = true) { |
|
883 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | * |
896 | 896 | * @return bool False for failure. True for success. |
897 | 897 | */ |
898 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
899 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
898 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
899 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | /** |
@@ -911,8 +911,8 @@ discard block |
||
911 | 911 | * |
912 | 912 | * @return bool False on failure, true if success. |
913 | 913 | */ |
914 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
915 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
914 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
915 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | * |
927 | 927 | * @return bool False for failure. True for success. |
928 | 928 | */ |
929 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
930 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
929 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
930 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -940,51 +940,51 @@ discard block |
||
940 | 940 | * |
941 | 941 | * @return array The sanitized data, based off column defaults. |
942 | 942 | */ |
943 | - private function sanitize_columns( $data ) { |
|
943 | + private function sanitize_columns($data) { |
|
944 | 944 | |
945 | 945 | $columns = $this->db->get_columns(); |
946 | 946 | $default_values = $this->db->get_column_defaults(); |
947 | 947 | |
948 | - foreach ( $columns as $key => $type ) { |
|
948 | + foreach ($columns as $key => $type) { |
|
949 | 949 | |
950 | 950 | // Only sanitize data that we were provided |
951 | - if ( ! array_key_exists( $key, $data ) ) { |
|
951 | + if ( ! array_key_exists($key, $data)) { |
|
952 | 952 | continue; |
953 | 953 | } |
954 | 954 | |
955 | - switch ( $type ) { |
|
955 | + switch ($type) { |
|
956 | 956 | |
957 | 957 | case '%s': |
958 | - if ( 'email' == $key ) { |
|
959 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
960 | - } elseif ( 'notes' == $key ) { |
|
961 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
958 | + if ('email' == $key) { |
|
959 | + $data[$key] = sanitize_email($data[$key]); |
|
960 | + } elseif ('notes' == $key) { |
|
961 | + $data[$key] = strip_tags($data[$key]); |
|
962 | 962 | } else { |
963 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
963 | + $data[$key] = sanitize_text_field($data[$key]); |
|
964 | 964 | } |
965 | 965 | break; |
966 | 966 | |
967 | 967 | case '%d': |
968 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
969 | - $data[ $key ] = $default_values[ $key ]; |
|
968 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
969 | + $data[$key] = $default_values[$key]; |
|
970 | 970 | } else { |
971 | - $data[ $key ] = absint( $data[ $key ] ); |
|
971 | + $data[$key] = absint($data[$key]); |
|
972 | 972 | } |
973 | 973 | break; |
974 | 974 | |
975 | 975 | case '%f': |
976 | 976 | // Convert what was given to a float |
977 | - $value = floatval( $data[ $key ] ); |
|
977 | + $value = floatval($data[$key]); |
|
978 | 978 | |
979 | - if ( ! is_float( $value ) ) { |
|
980 | - $data[ $key ] = $default_values[ $key ]; |
|
979 | + if ( ! is_float($value)) { |
|
980 | + $data[$key] = $default_values[$key]; |
|
981 | 981 | } else { |
982 | - $data[ $key ] = $value; |
|
982 | + $data[$key] = $value; |
|
983 | 983 | } |
984 | 984 | break; |
985 | 985 | |
986 | 986 | default: |
987 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
987 | + $data[$key] = sanitize_text_field($data[$key]); |
|
988 | 988 | break; |
989 | 989 | |
990 | 990 | } |
@@ -1005,33 +1005,33 @@ discard block |
||
1005 | 1005 | * |
1006 | 1006 | * @return bool If the email was added successfully |
1007 | 1007 | */ |
1008 | - public function add_email( $email = '', $primary = false ) { |
|
1009 | - if( ! is_email( $email ) ) { |
|
1008 | + public function add_email($email = '', $primary = false) { |
|
1009 | + if ( ! is_email($email)) { |
|
1010 | 1010 | return false; |
1011 | 1011 | } |
1012 | - $existing = new Give_Customer( $email ); |
|
1012 | + $existing = new Give_Customer($email); |
|
1013 | 1013 | |
1014 | - if( $existing->id > 0 ) { |
|
1014 | + if ($existing->id > 0) { |
|
1015 | 1015 | // Email address already belongs to another customer |
1016 | 1016 | return false; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - if ( email_exists( $email ) ) { |
|
1020 | - $user = get_user_by( 'email', $email ); |
|
1021 | - if ( $user->ID != $this->user_id ) { |
|
1019 | + if (email_exists($email)) { |
|
1020 | + $user = get_user_by('email', $email); |
|
1021 | + if ($user->ID != $this->user_id) { |
|
1022 | 1022 | return false; |
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1026 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1027 | 1027 | |
1028 | 1028 | // Add is used to ensure duplicate emails are not added |
1029 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1029 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1030 | 1030 | |
1031 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1031 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1032 | 1032 | |
1033 | - if ( $ret && true === $primary ) { |
|
1034 | - $this->set_primary_email( $email ); |
|
1033 | + if ($ret && true === $primary) { |
|
1034 | + $this->set_primary_email($email); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | return $ret; |
@@ -1047,16 +1047,16 @@ discard block |
||
1047 | 1047 | * |
1048 | 1048 | * @return bool If the email was removed successfully |
1049 | 1049 | */ |
1050 | - public function remove_email( $email = '' ) { |
|
1051 | - if( ! is_email( $email ) ) { |
|
1050 | + public function remove_email($email = '') { |
|
1051 | + if ( ! is_email($email)) { |
|
1052 | 1052 | return false; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1055 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1056 | 1056 | |
1057 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1057 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1058 | 1058 | |
1059 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1059 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1060 | 1060 | |
1061 | 1061 | return $ret; |
1062 | 1062 | } |
@@ -1073,16 +1073,16 @@ discard block |
||
1073 | 1073 | * |
1074 | 1074 | * @return bool If the email was set as primary successfully |
1075 | 1075 | */ |
1076 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1077 | - if( ! is_email( $new_primary_email ) ) { |
|
1076 | + public function set_primary_email($new_primary_email = '') { |
|
1077 | + if ( ! is_email($new_primary_email)) { |
|
1078 | 1078 | return false; |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1081 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1082 | 1082 | |
1083 | - $existing = new Give_Customer( $new_primary_email ); |
|
1083 | + $existing = new Give_Customer($new_primary_email); |
|
1084 | 1084 | |
1085 | - if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1085 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1086 | 1086 | // This email belongs to another customer |
1087 | 1087 | return false; |
1088 | 1088 | } |
@@ -1090,21 +1090,21 @@ discard block |
||
1090 | 1090 | $old_email = $this->email; |
1091 | 1091 | |
1092 | 1092 | // Update customer record with new email |
1093 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1093 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1094 | 1094 | |
1095 | 1095 | // Remove new primary from list of additional emails |
1096 | - $remove = $this->remove_email( $new_primary_email ); |
|
1096 | + $remove = $this->remove_email($new_primary_email); |
|
1097 | 1097 | |
1098 | 1098 | // Add old email to additional emails list |
1099 | - $add = $this->add_email( $old_email ); |
|
1099 | + $add = $this->add_email($old_email); |
|
1100 | 1100 | |
1101 | 1101 | $ret = $update && $remove && $add; |
1102 | 1102 | |
1103 | - if( $ret ) { |
|
1103 | + if ($ret) { |
|
1104 | 1104 | $this->email = $new_primary_email; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1107 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1108 | 1108 | |
1109 | 1109 | return $ret; |
1110 | 1110 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,36 +26,36 @@ discard block |
||
26 | 26 | function give_donation_history() { |
27 | 27 | |
28 | 28 | // If payment_key query arg exists, return receipt instead of donation history. |
29 | - if ( isset( $_GET['payment_key'] ) ) { |
|
29 | + if (isset($_GET['payment_key'])) { |
|
30 | 30 | ob_start(); |
31 | - echo give_receipt_shortcode( array() ); |
|
32 | - echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">« ' . esc_html__( 'Return to All Donations', 'give' ) . '</a>'; |
|
31 | + echo give_receipt_shortcode(array()); |
|
32 | + echo '<a href="'.esc_url(give_get_history_page_uri()).'">« '.esc_html__('Return to All Donations', 'give').'</a>'; |
|
33 | 33 | |
34 | 34 | return ob_get_clean(); |
35 | 35 | } |
36 | 36 | |
37 | - $email_access = give_get_option( 'email_access' ); |
|
37 | + $email_access = give_get_option('email_access'); |
|
38 | 38 | |
39 | 39 | //Is user logged in? Does a session exist? Does an email-access token exist? |
40 | - if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) { |
|
40 | + if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) { |
|
41 | 41 | ob_start(); |
42 | - give_get_template_part( 'history', 'donations' ); |
|
42 | + give_get_template_part('history', 'donations'); |
|
43 | 43 | |
44 | 44 | return ob_get_clean(); |
45 | 45 | } //Is Email-based access enabled? |
46 | - elseif ( $email_access == 'on' ) { |
|
46 | + elseif ($email_access == 'on') { |
|
47 | 47 | |
48 | 48 | ob_start(); |
49 | - give_get_template_part( 'email', 'login-form' ); |
|
49 | + give_get_template_part('email', 'login-form'); |
|
50 | 50 | |
51 | 51 | return ob_get_clean(); |
52 | 52 | } else { |
53 | - $message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ); |
|
54 | - echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message ); |
|
53 | + $message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'); |
|
54 | + echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -add_shortcode( 'donation_history', 'give_donation_history' ); |
|
58 | +add_shortcode('donation_history', 'give_donation_history'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Donation Form Shortcode |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function give_form_shortcode( $atts ) { |
|
72 | - $atts = shortcode_atts( array( |
|
71 | +function give_form_shortcode($atts) { |
|
72 | + $atts = shortcode_atts(array( |
|
73 | 73 | 'id' => '', |
74 | 74 | 'show_title' => true, |
75 | 75 | 'show_goal' => true, |
76 | 76 | 'show_content' => '', |
77 | 77 | 'float_labels' => '', |
78 | 78 | 'display_style' => '', |
79 | - ), $atts, 'give_form' ); |
|
79 | + ), $atts, 'give_form'); |
|
80 | 80 | |
81 | 81 | // Convert string to bool. |
82 | - $atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ); |
|
83 | - $atts['show_goal'] = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN ); |
|
82 | + $atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN); |
|
83 | + $atts['show_goal'] = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN); |
|
84 | 84 | |
85 | 85 | //get the Give Form |
86 | 86 | ob_start(); |
87 | - give_get_donation_form( $atts ); |
|
87 | + give_get_donation_form($atts); |
|
88 | 88 | $final_output = ob_get_clean(); |
89 | 89 | |
90 | - return apply_filters( 'give_donate_form', $final_output, $atts ); |
|
90 | + return apply_filters('give_donate_form', $final_output, $atts); |
|
91 | 91 | } |
92 | 92 | |
93 | -add_shortcode( 'give_form', 'give_form_shortcode' ); |
|
93 | +add_shortcode('give_form', 'give_form_shortcode'); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Donation Form Goal Shortcode. |
@@ -103,37 +103,37 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return string |
105 | 105 | */ |
106 | -function give_goal_shortcode( $atts ) { |
|
107 | - $atts = shortcode_atts( array( |
|
106 | +function give_goal_shortcode($atts) { |
|
107 | + $atts = shortcode_atts(array( |
|
108 | 108 | 'id' => '', |
109 | 109 | 'show_text' => true, |
110 | 110 | 'show_bar' => true, |
111 | - ), $atts, 'give_goal' ); |
|
111 | + ), $atts, 'give_goal'); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | //get the Give Form. |
115 | 115 | ob_start(); |
116 | 116 | |
117 | 117 | //Sanity check 1: ensure there is an ID Provided. |
118 | - if ( empty( $atts['id'] ) ) { |
|
119 | - give_output_error( esc_html__( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); |
|
118 | + if (empty($atts['id'])) { |
|
119 | + give_output_error(esc_html__('The shortcode is missing Donation Form ID attribute.', 'give'), true); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | //Sanity check 2: Check the form even has Goals enabled. |
123 | - if ( ! give_is_setting_enabled( get_post_meta( $atts['id'], '_give_goal_option', true ) ) ) { |
|
123 | + if ( ! give_is_setting_enabled(get_post_meta($atts['id'], '_give_goal_option', true))) { |
|
124 | 124 | |
125 | - give_output_error( esc_html__( 'The form does not have Goals enabled.', 'give' ), true ); |
|
125 | + give_output_error(esc_html__('The form does not have Goals enabled.', 'give'), true); |
|
126 | 126 | } else { |
127 | 127 | //Passed all sanity checks: output Goal. |
128 | - give_show_goal_progress( $atts['id'], $atts ); |
|
128 | + give_show_goal_progress($atts['id'], $atts); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $final_output = ob_get_clean(); |
132 | 132 | |
133 | - return apply_filters( 'give_goal_shortcode_output', $final_output, $atts ); |
|
133 | + return apply_filters('give_goal_shortcode_output', $final_output, $atts); |
|
134 | 134 | } |
135 | 135 | |
136 | -add_shortcode( 'give_goal', 'give_goal_shortcode' ); |
|
136 | +add_shortcode('give_goal', 'give_goal_shortcode'); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -150,22 +150,22 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | -function give_login_form_shortcode( $atts ) { |
|
154 | - $atts = shortcode_atts( array( |
|
153 | +function give_login_form_shortcode($atts) { |
|
154 | + $atts = shortcode_atts(array( |
|
155 | 155 | // Add backward compatibility for redirect attribute. |
156 | 156 | 'redirect' => '', |
157 | 157 | |
158 | 158 | 'login-redirect' => '', |
159 | 159 | 'logout-redirect' => '', |
160 | - ), $atts, 'give_login' ); |
|
160 | + ), $atts, 'give_login'); |
|
161 | 161 | |
162 | 162 | // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute. |
163 | - $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' ); |
|
163 | + $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : ''); |
|
164 | 164 | |
165 | - return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] ); |
|
165 | + return give_login_form($atts['login-redirect'], $atts['logout-redirect']); |
|
166 | 166 | } |
167 | 167 | |
168 | -add_shortcode( 'give_login', 'give_login_form_shortcode' ); |
|
168 | +add_shortcode('give_login', 'give_login_form_shortcode'); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Register Shortcode. |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string |
182 | 182 | */ |
183 | -function give_register_form_shortcode( $atts ) { |
|
184 | - $atts = shortcode_atts( array( |
|
183 | +function give_register_form_shortcode($atts) { |
|
184 | + $atts = shortcode_atts(array( |
|
185 | 185 | 'redirect' => '', |
186 | - ), $atts, 'give_register' ); |
|
186 | + ), $atts, 'give_register'); |
|
187 | 187 | |
188 | - return give_register_form( $atts['redirect'] ); |
|
188 | + return give_register_form($atts['redirect']); |
|
189 | 189 | } |
190 | 190 | |
191 | -add_shortcode( 'give_register', 'give_register_form_shortcode' ); |
|
191 | +add_shortcode('give_register', 'give_register_form_shortcode'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Receipt Shortcode. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | -function give_receipt_shortcode( $atts ) { |
|
204 | +function give_receipt_shortcode($atts) { |
|
205 | 205 | |
206 | 206 | global $give_receipt_args, $payment; |
207 | 207 | |
208 | - $give_receipt_args = shortcode_atts( array( |
|
209 | - 'error' => esc_html__( 'You are missing the payment key to view this donation receipt.', 'give' ), |
|
208 | + $give_receipt_args = shortcode_atts(array( |
|
209 | + 'error' => esc_html__('You are missing the payment key to view this donation receipt.', 'give'), |
|
210 | 210 | 'price' => true, |
211 | 211 | 'donor' => true, |
212 | 212 | 'date' => true, |
@@ -215,50 +215,50 @@ discard block |
||
215 | 215 | 'payment_id' => true, |
216 | 216 | 'payment_status' => false, |
217 | 217 | 'status_notice' => true, |
218 | - ), $atts, 'give_receipt' ); |
|
218 | + ), $atts, 'give_receipt'); |
|
219 | 219 | |
220 | 220 | //set $session var |
221 | 221 | $session = give_get_purchase_session(); |
222 | 222 | |
223 | 223 | //set payment key var |
224 | - if ( isset( $_GET['payment_key'] ) ) { |
|
225 | - $payment_key = urldecode( $_GET['payment_key'] ); |
|
226 | - } elseif ( $session ) { |
|
224 | + if (isset($_GET['payment_key'])) { |
|
225 | + $payment_key = urldecode($_GET['payment_key']); |
|
226 | + } elseif ($session) { |
|
227 | 227 | $payment_key = $session['purchase_key']; |
228 | - } elseif ( $give_receipt_args['payment_key'] ) { |
|
228 | + } elseif ($give_receipt_args['payment_key']) { |
|
229 | 229 | $payment_key = $give_receipt_args['payment_key']; |
230 | 230 | } |
231 | 231 | |
232 | - $email_access = give_get_option( 'email_access' ); |
|
232 | + $email_access = give_get_option('email_access'); |
|
233 | 233 | |
234 | 234 | // No payment_key found & Email Access is Turned on: |
235 | - if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
235 | + if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
236 | 236 | |
237 | 237 | ob_start(); |
238 | 238 | |
239 | - give_get_template_part( 'email-login-form' ); |
|
239 | + give_get_template_part('email-login-form'); |
|
240 | 240 | |
241 | 241 | return ob_get_clean(); |
242 | 242 | |
243 | - } elseif ( ! isset( $payment_key ) ) { |
|
243 | + } elseif ( ! isset($payment_key)) { |
|
244 | 244 | |
245 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
245 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - $payment_id = give_get_purchase_id_by_key( $payment_key ); |
|
250 | - $user_can_view = give_can_view_receipt( $payment_key ); |
|
249 | + $payment_id = give_get_purchase_id_by_key($payment_key); |
|
250 | + $user_can_view = give_can_view_receipt($payment_key); |
|
251 | 251 | |
252 | 252 | // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. |
253 | - if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) { |
|
253 | + if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) { |
|
254 | 254 | |
255 | 255 | ob_start(); |
256 | 256 | |
257 | - give_get_template_part( 'email-login-form' ); |
|
257 | + give_get_template_part('email-login-form'); |
|
258 | 258 | |
259 | 259 | return ob_get_clean(); |
260 | 260 | |
261 | - } elseif ( ! $user_can_view ) { |
|
261 | + } elseif ( ! $user_can_view) { |
|
262 | 262 | |
263 | 263 | global $give_login_redirect; |
264 | 264 | |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | |
267 | 267 | ob_start(); |
268 | 268 | |
269 | - give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation receipt.', 'give' ) ) ); |
|
269 | + give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation receipt.', 'give'))); |
|
270 | 270 | |
271 | - give_get_template_part( 'shortcode', 'login' ); |
|
271 | + give_get_template_part('shortcode', 'login'); |
|
272 | 272 | |
273 | 273 | $login_form = ob_get_clean(); |
274 | 274 | |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | * or if user is logged in and the user can view sensitive shop data. |
284 | 284 | * |
285 | 285 | */ |
286 | - if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) { |
|
287 | - return give_output_error( $give_receipt_args['error'], false, 'error' ); |
|
286 | + if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { |
|
287 | + return give_output_error($give_receipt_args['error'], false, 'error'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | ob_start(); |
291 | 291 | |
292 | - give_get_template_part( 'shortcode', 'receipt' ); |
|
292 | + give_get_template_part('shortcode', 'receipt'); |
|
293 | 293 | |
294 | 294 | $display = ob_get_clean(); |
295 | 295 | |
296 | 296 | return $display; |
297 | 297 | } |
298 | 298 | |
299 | -add_shortcode( 'give_receipt', 'give_receipt_shortcode' ); |
|
299 | +add_shortcode('give_receipt', 'give_receipt_shortcode'); |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * Profile Editor Shortcode. |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return string Output generated from the profile editor |
317 | 317 | */ |
318 | -function give_profile_editor_shortcode( $atts ) { |
|
318 | +function give_profile_editor_shortcode($atts) { |
|
319 | 319 | |
320 | 320 | ob_start(); |
321 | 321 | |
322 | - give_get_template_part( 'shortcode', 'profile-editor' ); |
|
322 | + give_get_template_part('shortcode', 'profile-editor'); |
|
323 | 323 | |
324 | 324 | $display = ob_get_clean(); |
325 | 325 | |
326 | 326 | return $display; |
327 | 327 | } |
328 | 328 | |
329 | -add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' ); |
|
329 | +add_shortcode('give_profile_editor', 'give_profile_editor_shortcode'); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Process Profile Updater Form. |
@@ -339,30 +339,30 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return bool |
341 | 341 | */ |
342 | -function give_process_profile_editor_updates( $data ) { |
|
342 | +function give_process_profile_editor_updates($data) { |
|
343 | 343 | // Profile field change request |
344 | - if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) { |
|
344 | + if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Nonce security |
349 | - if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) { |
|
349 | + if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | $user_id = get_current_user_id(); |
354 | - $old_user_data = get_userdata( $user_id ); |
|
355 | - |
|
356 | - $display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name; |
|
357 | - $first_name = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name; |
|
358 | - $last_name = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name; |
|
359 | - $email = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email; |
|
360 | - $line1 = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' ); |
|
361 | - $line2 = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' ); |
|
362 | - $city = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' ); |
|
363 | - $state = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' ); |
|
364 | - $zip = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' ); |
|
365 | - $country = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' ); |
|
354 | + $old_user_data = get_userdata($user_id); |
|
355 | + |
|
356 | + $display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name; |
|
357 | + $first_name = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name; |
|
358 | + $last_name = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name; |
|
359 | + $email = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email; |
|
360 | + $line1 = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : ''); |
|
361 | + $line2 = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : ''); |
|
362 | + $city = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : ''); |
|
363 | + $state = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : ''); |
|
364 | + $zip = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : ''); |
|
365 | + $country = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : ''); |
|
366 | 366 | |
367 | 367 | $userdata = array( |
368 | 368 | 'ID' => $user_id, |
@@ -390,46 +390,46 @@ discard block |
||
390 | 390 | * @param int $user_id The ID of the user. |
391 | 391 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
392 | 392 | */ |
393 | - do_action( 'give_pre_update_user_profile', $user_id, $userdata ); |
|
393 | + do_action('give_pre_update_user_profile', $user_id, $userdata); |
|
394 | 394 | |
395 | 395 | // New password |
396 | - if ( ! empty( $data['give_new_user_pass1'] ) ) { |
|
397 | - if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) { |
|
398 | - give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) ); |
|
396 | + if ( ! empty($data['give_new_user_pass1'])) { |
|
397 | + if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) { |
|
398 | + give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give')); |
|
399 | 399 | } else { |
400 | 400 | $userdata['user_pass'] = $data['give_new_user_pass1']; |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | - if ( empty( $email ) ) { |
|
404 | + if (empty($email)) { |
|
405 | 405 | // Make sure email should not be empty. |
406 | - give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) ); |
|
406 | + give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give')); |
|
407 | 407 | |
408 | - } else if ( ! is_email( $email ) ) { |
|
408 | + } else if ( ! is_email($email)) { |
|
409 | 409 | // Make sure email should be valid. |
410 | - give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) ); |
|
410 | + give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give')); |
|
411 | 411 | |
412 | - } else if ( $email != $old_user_data->user_email ) { |
|
412 | + } else if ($email != $old_user_data->user_email) { |
|
413 | 413 | // Make sure the new email doesn't belong to another user |
414 | - if ( email_exists( $email ) ) { |
|
415 | - give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) ); |
|
414 | + if (email_exists($email)) { |
|
415 | + give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give')); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Check for errors |
420 | 420 | $errors = give_get_errors(); |
421 | 421 | |
422 | - if ( $errors ) { |
|
422 | + if ($errors) { |
|
423 | 423 | // Send back to the profile editor if there are errors |
424 | - wp_redirect( $data['give_redirect'] ); |
|
424 | + wp_redirect($data['give_redirect']); |
|
425 | 425 | give_die(); |
426 | 426 | } |
427 | 427 | |
428 | 428 | // Update the user |
429 | - $meta = update_user_meta( $user_id, '_give_user_address', $address ); |
|
430 | - $updated = wp_update_user( $userdata ); |
|
429 | + $meta = update_user_meta($user_id, '_give_user_address', $address); |
|
430 | + $updated = wp_update_user($userdata); |
|
431 | 431 | |
432 | - if ( $updated ) { |
|
432 | + if ($updated) { |
|
433 | 433 | |
434 | 434 | /** |
435 | 435 | * Fires after updating user profile. |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | * @param int $user_id The ID of the user. |
440 | 440 | * @param array $userdata User info, including ID, first name, last name, display name and email. |
441 | 441 | */ |
442 | - do_action( 'give_user_profile_updated', $user_id, $userdata ); |
|
443 | - wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) ); |
|
442 | + do_action('give_user_profile_updated', $user_id, $userdata); |
|
443 | + wp_redirect(add_query_arg('updated', 'true', $data['give_redirect'])); |
|
444 | 444 | give_die(); |
445 | 445 | } |
446 | 446 | |
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | |
450 | -add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' ); |
|
450 | +add_action('give_edit_user_profile', 'give_process_profile_editor_updates'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
51 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
52 | 52 | |
53 | 53 | /** |
54 | 54 | * Run the Give Install process. |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | give_setup_post_types(); |
65 | 65 | |
66 | 66 | // Clear the permalinks. |
67 | - flush_rewrite_rules( false ); |
|
67 | + flush_rewrite_rules(false); |
|
68 | 68 | |
69 | 69 | // Add Upgraded From Option. |
70 | - $current_version = get_option( 'give_version' ); |
|
71 | - if ( $current_version ) { |
|
72 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
70 | + $current_version = get_option('give_version'); |
|
71 | + if ($current_version) { |
|
72 | + update_option('give_version_upgraded_from', $current_version); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Setup some default options. |
76 | 76 | $options = array(); |
77 | 77 | |
78 | 78 | // Checks if the Success Page option exists AND that the page exists. |
79 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
79 | + if ( ! get_post(give_get_option('success_page'))) { |
|
80 | 80 | |
81 | 81 | // Donation Confirmation (Success) Page |
82 | 82 | $success = wp_insert_post( |
83 | 83 | array( |
84 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
84 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
85 | 85 | 'post_content' => '[give_receipt]', |
86 | 86 | 'post_status' => 'publish', |
87 | 87 | 'post_author' => 1, |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Checks if the Failure Page option exists AND that the page exists. |
98 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
98 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
99 | 99 | |
100 | 100 | // Failed Donation Page |
101 | 101 | $failed = wp_insert_post( |
102 | 102 | array( |
103 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
104 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
103 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
104 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
105 | 105 | 'post_status' => 'publish', |
106 | 106 | 'post_author' => 1, |
107 | 107 | 'post_type' => 'page', |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // Checks if the History Page option exists AND that the page exists. |
116 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
116 | + if ( ! get_post(give_get_option('history_page'))) { |
|
117 | 117 | // Donation History Page |
118 | 118 | $history = wp_insert_post( |
119 | 119 | array( |
120 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
120 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
121 | 121 | 'post_content' => '[donation_history]', |
122 | 122 | 'post_status' => 'publish', |
123 | 123 | 'post_author' => 1, |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
133 | - if ( empty( $current_version ) ) { |
|
134 | - $options = array_merge( $options, give_get_default_settings() ); |
|
133 | + if (empty($current_version)) { |
|
134 | + $options = array_merge($options, give_get_default_settings()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | // Populate the default values. |
138 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
138 | + update_option('give_settings', array_merge($give_options, $options)); |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Run plugin upgrades. |
142 | 142 | * |
143 | 143 | * @since 1.8 |
144 | 144 | */ |
145 | - do_action( 'give_upgrades' ); |
|
145 | + do_action('give_upgrades'); |
|
146 | 146 | |
147 | 147 | |
148 | - if( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
149 | - update_option( 'give_version', GIVE_VERSION ); |
|
148 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
149 | + update_option('give_version', GIVE_VERSION); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Create Give roles. |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $roles->add_caps(); |
156 | 156 | |
157 | 157 | $api = new Give_API(); |
158 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
158 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
159 | 159 | |
160 | 160 | // Create the customers databases. |
161 | 161 | @Give()->customers->create_table(); |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | Give()->session->use_php_sessions(); |
166 | 166 | |
167 | 167 | // Add a temporary option to note that Give pages have been created. |
168 | - set_transient( '_give_installed', $options, 30 ); |
|
168 | + set_transient('_give_installed', $options, 30); |
|
169 | 169 | |
170 | - if ( ! $current_version ) { |
|
170 | + if ( ! $current_version) { |
|
171 | 171 | |
172 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
172 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
173 | 173 | |
174 | 174 | // When new upgrade routines are added, mark them as complete on fresh install. |
175 | 175 | $upgrade_routines = array( |
@@ -180,22 +180,22 @@ discard block |
||
180 | 180 | 'v18_upgrades_form_metadata' |
181 | 181 | ); |
182 | 182 | |
183 | - foreach ( $upgrade_routines as $upgrade ) { |
|
184 | - give_set_upgrade_complete( $upgrade ); |
|
183 | + foreach ($upgrade_routines as $upgrade) { |
|
184 | + give_set_upgrade_complete($upgrade); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Bail if activating from network, or bulk. |
189 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
189 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Add the transient to redirect. |
194 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
194 | + set_transient('_give_activation_redirect', true, 30); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
198 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Network Activated New Site Setup. |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @param int $site_id The Site ID. |
212 | 212 | * @param array $meta Blog Meta. |
213 | 213 | */ |
214 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
214 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
215 | 215 | |
216 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
216 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
217 | 217 | |
218 | - switch_to_blog( $blog_id ); |
|
218 | + switch_to_blog($blog_id); |
|
219 | 219 | give_install(); |
220 | 220 | restore_current_blog(); |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
226 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
227 | 227 | |
228 | 228 | |
229 | 229 | /** |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return array The tables to drop. |
238 | 238 | */ |
239 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
239 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
240 | 240 | |
241 | - switch_to_blog( $blog_id ); |
|
241 | + switch_to_blog($blog_id); |
|
242 | 242 | $customers_db = new Give_DB_Customers(); |
243 | 243 | $customer_meta_db = new Give_DB_Customer_Meta(); |
244 | 244 | |
245 | - if ( $customers_db->installed() ) { |
|
245 | + if ($customers_db->installed()) { |
|
246 | 246 | $tables[] = $customers_db->table_name; |
247 | 247 | $tables[] = $customer_meta_db->table_name; |
248 | 248 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | } |
254 | 254 | |
255 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
255 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Post-installation |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function give_after_install() { |
266 | 266 | |
267 | - if ( ! is_admin() ) { |
|
267 | + if ( ! is_admin()) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | - $give_options = get_transient( '_give_installed' ); |
|
272 | - $give_table_check = get_option( '_give_table_check', false ); |
|
271 | + $give_options = get_transient('_give_installed'); |
|
272 | + $give_table_check = get_option('_give_table_check', false); |
|
273 | 273 | |
274 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
274 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
275 | 275 | |
276 | - if ( ! @Give()->customer_meta->installed() ) { |
|
276 | + if ( ! @Give()->customer_meta->installed()) { |
|
277 | 277 | |
278 | 278 | // Create the customer meta database |
279 | 279 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | - if ( ! @Give()->customers->installed() ) { |
|
284 | + if ( ! @Give()->customers->installed()) { |
|
285 | 285 | // Create the customers database |
286 | 286 | // (this ensures it creates it on multisite instances where it is network activated). |
287 | 287 | @Give()->customers->create_table(); |
@@ -293,22 +293,22 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param array $give_options Give plugin options. |
295 | 295 | */ |
296 | - do_action( 'give_after_install', $give_options ); |
|
296 | + do_action('give_after_install', $give_options); |
|
297 | 297 | } |
298 | 298 | |
299 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
299 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
300 | 300 | |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Delete the transient |
304 | - if ( false !== $give_options ) { |
|
305 | - delete_transient( '_give_installed' ); |
|
304 | + if (false !== $give_options) { |
|
305 | + delete_transient('_give_installed'); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | 309 | } |
310 | 310 | |
311 | -add_action( 'admin_init', 'give_after_install' ); |
|
311 | +add_action('admin_init', 'give_after_install'); |
|
312 | 312 | |
313 | 313 | |
314 | 314 | /** |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | |
324 | 324 | global $wp_roles; |
325 | 325 | |
326 | - if ( ! is_object( $wp_roles ) ) { |
|
326 | + if ( ! is_object($wp_roles)) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
330 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
331 | 331 | |
332 | 332 | // Create Give plugin roles |
333 | 333 | $roles = new Give_Roles(); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | } |
340 | 340 | |
341 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
341 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
342 | 342 | |
343 | 343 | /** |
344 | 344 | * Default core setting values. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'paypal_verification' => 'enabled', |
379 | 379 | |
380 | 380 | // Default is manual gateway. |
381 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
381 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
382 | 382 | 'default_gateway' => 'manual', |
383 | 383 | |
384 | 384 | // Offline gateway setup. |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Exit if accessed directly. |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if ( ! defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | // Add give command. |
15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @subcommand logo |
70 | 70 | */ |
71 | - public function ascii( $args, $assoc_args ) { |
|
72 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
71 | + public function ascii($args, $assoc_args) { |
|
72 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -94,54 +94,54 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @subcommand details |
96 | 96 | */ |
97 | - public function details( $args, $assoc_args ) { |
|
97 | + public function details($args, $assoc_args) { |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Plugin Information |
101 | 101 | */ |
102 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
102 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * General Information. |
106 | 106 | */ |
107 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
107 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
108 | 108 | |
109 | - $success_page = give_get_option( 'success_page' ); |
|
110 | - $failure_page = give_get_option( 'failure_page' ); |
|
111 | - $history_page = give_get_option( 'history_page' ); |
|
109 | + $success_page = give_get_option('success_page'); |
|
110 | + $failure_page = give_get_option('failure_page'); |
|
111 | + $history_page = give_get_option('history_page'); |
|
112 | 112 | |
113 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
114 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
115 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
116 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
113 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
114 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
115 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
116 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Currency Information. |
120 | 120 | */ |
121 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
121 | + $default_gateway = give_get_option('default_gateway'); |
|
122 | 122 | |
123 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
123 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
124 | 124 | |
125 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
126 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
127 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
128 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
129 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
130 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
131 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
125 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
126 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
127 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
128 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
129 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
130 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
131 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
132 | 132 | |
133 | 133 | // Payment gateways Information. |
134 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
135 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
134 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
135 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
136 | 136 | |
137 | - if ( ! empty( $gateways ) ) { |
|
137 | + if ( ! empty($gateways)) { |
|
138 | 138 | self::$counter = 1; |
139 | - foreach ( $gateways as $gateway ) { |
|
140 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
141 | - self::$counter ++; |
|
139 | + foreach ($gateways as $gateway) { |
|
140 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
141 | + self::$counter++; |
|
142 | 142 | } |
143 | 143 | } else { |
144 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
144 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @subcommand forms |
175 | 175 | */ |
176 | - public function forms( $args, $assoc_args ) { |
|
176 | + public function forms($args, $assoc_args) { |
|
177 | 177 | global $wp_query; |
178 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
179 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
178 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
179 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
180 | 180 | $start = time(); |
181 | 181 | |
182 | 182 | // Cache previous number query var. |
183 | 183 | $is_set_number = $cache_per_page = false; |
184 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
184 | + if (isset($wp_query->query_vars['number'])) { |
|
185 | 185 | $cache_per_page = $wp_query->query_vars['number']; |
186 | 186 | $is_set_number = true; |
187 | 187 | } |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | $wp_query->query_vars['number'] = $number; |
191 | 191 | |
192 | 192 | // Get forms. |
193 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
193 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
194 | 194 | |
195 | 195 | // Reset number query var. |
196 | - if ( $is_set_number ) { |
|
196 | + if ($is_set_number) { |
|
197 | 197 | $wp_query->query_vars['number'] = $cache_per_page; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // Bailout. |
201 | - if ( array_key_exists( 'error', $forms ) ) { |
|
201 | + if (array_key_exists('error', $forms)) { |
|
202 | 202 | |
203 | - WP_CLI::warning( $forms['error'] ); |
|
203 | + WP_CLI::warning($forms['error']); |
|
204 | 204 | |
205 | 205 | return; |
206 | - } elseif ( empty( $forms['forms'] ) ) { |
|
206 | + } elseif (empty($forms['forms'])) { |
|
207 | 207 | |
208 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
208 | + WP_CLI::error(__('No forms found.', 'give')); |
|
209 | 209 | |
210 | 210 | return; |
211 | 211 | } |
@@ -213,25 +213,25 @@ discard block |
||
213 | 213 | // Param to check if form typeis already showed or not. |
214 | 214 | $is_show_form_type = false; |
215 | 215 | |
216 | - if ( 1 === count( $forms ) && $form_id ) { |
|
216 | + if (1 === count($forms) && $form_id) { |
|
217 | 217 | // Show single form. |
218 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
219 | - switch ( $key ) { |
|
218 | + foreach ($forms['forms'][0] as $key => $info) { |
|
219 | + switch ($key) { |
|
220 | 220 | case 'stats': |
221 | - $this->color_main_heading( ucfirst( $key ) ); |
|
221 | + $this->color_main_heading(ucfirst($key)); |
|
222 | 222 | |
223 | - foreach ( $info as $heading => $data ) { |
|
224 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
225 | - switch ( $heading ) { |
|
223 | + foreach ($info as $heading => $data) { |
|
224 | + $this->color_sub_heading(ucfirst($heading)); |
|
225 | + switch ($heading) { |
|
226 | 226 | default: |
227 | - foreach ( $data as $subheading => $subdata ) { |
|
227 | + foreach ($data as $subheading => $subdata) { |
|
228 | 228 | |
229 | - switch ( $subheading ) { |
|
229 | + switch ($subheading) { |
|
230 | 230 | case 'earnings': |
231 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
231 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
232 | 232 | break; |
233 | 233 | default: |
234 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
234 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -241,26 +241,26 @@ discard block |
||
241 | 241 | case 'pricing': |
242 | 242 | case 'info': |
243 | 243 | default: |
244 | - $this->color_main_heading( ucfirst( $key ) ); |
|
244 | + $this->color_main_heading(ucfirst($key)); |
|
245 | 245 | |
246 | 246 | // Show form type. |
247 | - if ( ! $is_show_form_type ) { |
|
248 | - $form = new Give_Donate_Form( $form_id ); |
|
247 | + if ( ! $is_show_form_type) { |
|
248 | + $form = new Give_Donate_Form($form_id); |
|
249 | 249 | $is_show_form_type = true; |
250 | 250 | |
251 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
251 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
252 | 252 | } |
253 | 253 | |
254 | - foreach ( $info as $heading => $data ) { |
|
254 | + foreach ($info as $heading => $data) { |
|
255 | 255 | |
256 | - switch ( $heading ) { |
|
256 | + switch ($heading) { |
|
257 | 257 | case 'id': |
258 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
258 | + WP_CLI::log($this->color_message($heading, $data)); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | default: |
262 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
263 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
262 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
263 | + WP_CLI::log($this->color_message($heading, $data)); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -271,37 +271,37 @@ discard block |
||
271 | 271 | $is_table_first_row_set = false; |
272 | 272 | $table_column_count = 0; |
273 | 273 | |
274 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
274 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
275 | 275 | |
276 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
276 | + foreach ($forms['forms'] as $index => $form_data) { |
|
277 | 277 | |
278 | 278 | // Default table data. |
279 | 279 | $table_first_row = array(); |
280 | 280 | $table_row = array(); |
281 | 281 | |
282 | - foreach ( $form_data['info'] as $key => $form ) { |
|
282 | + foreach ($form_data['info'] as $key => $form) { |
|
283 | 283 | |
284 | 284 | // Do not show thumbnail, content and link in table. |
285 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
285 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if ( ! $is_table_first_row_set ) { |
|
289 | + if ( ! $is_table_first_row_set) { |
|
290 | 290 | $table_first_row[] = $key; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $table_row[] = $form; |
294 | 294 | |
295 | - if ( 'status' === $key ) { |
|
295 | + if ('status' === $key) { |
|
296 | 296 | // First array item will be an form id in our case. |
297 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
297 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
298 | 298 | |
299 | 299 | $table_row[] = $form->get_type(); |
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | 303 | // Set table first row. |
304 | - if ( ! $is_table_first_row_set ) { |
|
304 | + if ( ! $is_table_first_row_set) { |
|
305 | 305 | |
306 | 306 | // Add extra column to table. |
307 | 307 | $table_first_row[] = 'type'; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $table_data[] = $table_row; |
315 | 315 | } |
316 | 316 | |
317 | - $this->display_table( $table_data ); |
|
317 | + $this->display_table($table_data); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -366,37 +366,37 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @subcommand donors |
368 | 368 | */ |
369 | - public function donors( $args, $assoc_args ) { |
|
369 | + public function donors($args, $assoc_args) { |
|
370 | 370 | global $wp_query; |
371 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
372 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
373 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
374 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
375 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
376 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
377 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
371 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
372 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
373 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
374 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
375 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
376 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
377 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
378 | 378 | $start = time(); |
379 | 379 | |
380 | - if ( $create ) { |
|
380 | + if ($create) { |
|
381 | 381 | $number = 1; |
382 | 382 | |
383 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
384 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
383 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
384 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
385 | 385 | |
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Create one or more donors. |
390 | - if ( ! $email ) { |
|
390 | + if ( ! $email) { |
|
391 | 391 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
392 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
392 | + $number = is_numeric($create) ? absint($create) : 1; |
|
393 | 393 | } |
394 | 394 | |
395 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
396 | - if ( ! $email ) { |
|
395 | + for ($i = 0; $i < $number; $i++) { |
|
396 | + if ( ! $email) { |
|
397 | 397 | |
398 | 398 | // Generate fake email. |
399 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
399 | + $email = 'customer-'.uniqid().'@test.com'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | $args = array( |
@@ -404,19 +404,19 @@ discard block |
||
404 | 404 | 'name' => $name, |
405 | 405 | ); |
406 | 406 | |
407 | - $customer_id = Give()->customers->add( $args ); |
|
407 | + $customer_id = Give()->customers->add($args); |
|
408 | 408 | |
409 | - if ( $customer_id ) { |
|
410 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) ); |
|
409 | + if ($customer_id) { |
|
410 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id))); |
|
411 | 411 | } else { |
412 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
412 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | // Reset email to false so it is generated on the next loop (if creating donors). |
416 | 416 | $email = false; |
417 | 417 | } |
418 | 418 | |
419 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
419 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
420 | 420 | |
421 | 421 | } else { |
422 | 422 | // Counter. |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | // Cache previous number query var. |
432 | 432 | $is_set_number = $cache_per_page = false; |
433 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
433 | + if (isset($wp_query->query_vars['number'])) { |
|
434 | 434 | $cache_per_page = $wp_query->query_vars['number']; |
435 | 435 | $is_set_number = true; |
436 | 436 | } |
@@ -439,24 +439,24 @@ discard block |
||
439 | 439 | $wp_query->query_vars['number'] = $number; |
440 | 440 | |
441 | 441 | // Get donors. |
442 | - if ( $form_id ) { |
|
442 | + if ($form_id) { |
|
443 | 443 | // @TODO: Allow user to get a list of donors by donation status. |
444 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
444 | + $donors = $this->get_donors_by_form_id($form_id); |
|
445 | 445 | } else { |
446 | - $donors = $this->api->get_customers( $search ); |
|
446 | + $donors = $this->api->get_customers($search); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | // Reset number query var. |
450 | - if ( $is_set_number ) { |
|
450 | + if ($is_set_number) { |
|
451 | 451 | $wp_query->query_vars['number'] = $cache_per_page; |
452 | 452 | } |
453 | 453 | |
454 | - if ( isset( $donors['error'] ) ) { |
|
455 | - WP_CLI::error( $donors['error'] ); |
|
454 | + if (isset($donors['error'])) { |
|
455 | + WP_CLI::error($donors['error']); |
|
456 | 456 | } |
457 | 457 | |
458 | - if ( empty( $donors ) ) { |
|
459 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
458 | + if (empty($donors)) { |
|
459 | + WP_CLI::error(__('No donors found.', 'give')); |
|
460 | 460 | |
461 | 461 | return; |
462 | 462 | } |
@@ -464,24 +464,24 @@ discard block |
||
464 | 464 | $table_data = array(); |
465 | 465 | $is_table_first_row_set = false; |
466 | 466 | |
467 | - foreach ( $donors['donors'] as $donor_data ) { |
|
467 | + foreach ($donors['donors'] as $donor_data) { |
|
468 | 468 | // Set default table row data. |
469 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
470 | - $table_row = array( self::$counter ); |
|
469 | + $table_first_row = array(__('s_no', 'give')); |
|
470 | + $table_row = array(self::$counter); |
|
471 | 471 | |
472 | - foreach ( $donor_data as $key => $donor ) { |
|
473 | - switch ( $key ) { |
|
472 | + foreach ($donor_data as $key => $donor) { |
|
473 | + switch ($key) { |
|
474 | 474 | case 'stats': |
475 | - foreach ( $donor as $heading => $data ) { |
|
475 | + foreach ($donor as $heading => $data) { |
|
476 | 476 | |
477 | 477 | // Get first row. |
478 | - if ( ! $is_table_first_row_set ) { |
|
478 | + if ( ! $is_table_first_row_set) { |
|
479 | 479 | $table_first_row[] = $heading; |
480 | 480 | } |
481 | 481 | |
482 | - switch ( $heading ) { |
|
482 | + switch ($heading) { |
|
483 | 483 | case 'total_spent': |
484 | - $table_row[] = give_currency_filter( $data ); |
|
484 | + $table_row[] = give_currency_filter($data); |
|
485 | 485 | break; |
486 | 486 | |
487 | 487 | default: |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | |
493 | 493 | case 'info': |
494 | 494 | default: |
495 | - foreach ( $donor as $heading => $data ) { |
|
495 | + foreach ($donor as $heading => $data) { |
|
496 | 496 | |
497 | 497 | // Get first row. |
498 | - if ( ! $is_table_first_row_set ) { |
|
498 | + if ( ! $is_table_first_row_set) { |
|
499 | 499 | $table_first_row[] = $heading; |
500 | 500 | } |
501 | 501 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | // Add first row data to table data. |
508 | - if ( ! $is_table_first_row_set ) { |
|
508 | + if ( ! $is_table_first_row_set) { |
|
509 | 509 | $table_data[] = $table_first_row; |
510 | 510 | $is_table_first_row_set = true; |
511 | 511 | } |
@@ -514,44 +514,44 @@ discard block |
||
514 | 514 | $table_data[] = $table_row; |
515 | 515 | |
516 | 516 | // Increase counter. |
517 | - self::$counter ++; |
|
517 | + self::$counter++; |
|
518 | 518 | } |
519 | 519 | |
520 | - switch ( $format ) { |
|
520 | + switch ($format) { |
|
521 | 521 | case 'json': |
522 | 522 | $table_column_name = $table_data[0]; |
523 | - unset( $table_data[0] ); |
|
523 | + unset($table_data[0]); |
|
524 | 524 | |
525 | 525 | $new_table_data = array(); |
526 | - foreach ( $table_data as $index => $data ) { |
|
527 | - foreach ( $data as $key => $value ) { |
|
528 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
526 | + foreach ($table_data as $index => $data) { |
|
527 | + foreach ($data as $key => $value) { |
|
528 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
532 | + WP_CLI::log(json_encode($new_table_data)); |
|
533 | 533 | break; |
534 | 534 | |
535 | 535 | case 'csv': |
536 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
537 | - $fp = fopen( $file_path, 'w' ); |
|
536 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
537 | + $fp = fopen($file_path, 'w'); |
|
538 | 538 | |
539 | - if ( is_writable( $file_path ) ) { |
|
540 | - foreach ( $table_data as $fields ) { |
|
541 | - fputcsv( $fp, $fields ); |
|
539 | + if (is_writable($file_path)) { |
|
540 | + foreach ($table_data as $fields) { |
|
541 | + fputcsv($fp, $fields); |
|
542 | 542 | } |
543 | 543 | |
544 | - fclose( $fp ); |
|
544 | + fclose($fp); |
|
545 | 545 | |
546 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
546 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
547 | 547 | } else { |
548 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
548 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | break; |
552 | 552 | |
553 | 553 | default: |
554 | - $this->display_table( $table_data ); |
|
554 | + $this->display_table($table_data); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @subcommand donations |
583 | 583 | */ |
584 | - public function donations( $args, $assoc_args ) { |
|
584 | + public function donations($args, $assoc_args) { |
|
585 | 585 | global $wp_query; |
586 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
586 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
587 | 587 | |
588 | 588 | // Cache previous number query var. |
589 | 589 | $is_set_number = $cache_per_page = false; |
590 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
590 | + if (isset($wp_query->query_vars['number'])) { |
|
591 | 591 | $cache_per_page = $wp_query->query_vars['number']; |
592 | 592 | $is_set_number = true; |
593 | 593 | } |
@@ -599,46 +599,46 @@ discard block |
||
599 | 599 | $donations = $this->api->get_recent_donations(); |
600 | 600 | |
601 | 601 | // Reset number query var. |
602 | - if ( $is_set_number ) { |
|
602 | + if ($is_set_number) { |
|
603 | 603 | $wp_query->query_vars['number'] = $cache_per_page; |
604 | 604 | } |
605 | 605 | |
606 | - if ( empty( $donations ) ) { |
|
607 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
606 | + if (empty($donations)) { |
|
607 | + WP_CLI::error(__('No donations found.', 'give')); |
|
608 | 608 | |
609 | 609 | return; |
610 | 610 | } |
611 | 611 | |
612 | 612 | self::$counter = 1; |
613 | 613 | |
614 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
615 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
616 | - self::$counter ++; |
|
614 | + foreach ($donations['donations'] as $key => $donation) { |
|
615 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
616 | + self::$counter++; |
|
617 | 617 | |
618 | - foreach ( $donation as $column => $data ) { |
|
618 | + foreach ($donation as $column => $data) { |
|
619 | 619 | |
620 | - if ( is_array( $data ) ) { |
|
621 | - $this->color_sub_heading( $column ); |
|
622 | - foreach ( $data as $subcolumn => $subdata ) { |
|
620 | + if (is_array($data)) { |
|
621 | + $this->color_sub_heading($column); |
|
622 | + foreach ($data as $subcolumn => $subdata) { |
|
623 | 623 | |
624 | 624 | // Decode html codes. |
625 | - switch ( $subcolumn ) { |
|
625 | + switch ($subcolumn) { |
|
626 | 626 | case 'name': |
627 | - $subdata = html_entity_decode( $subdata ); |
|
627 | + $subdata = html_entity_decode($subdata); |
|
628 | 628 | break; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
632 | - if ( is_array( $subdata ) ) { |
|
632 | + if (is_array($subdata)) { |
|
633 | 633 | continue; |
634 | 634 | } |
635 | 635 | |
636 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
636 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
637 | 637 | } |
638 | 638 | continue; |
639 | 639 | } |
640 | 640 | |
641 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
641 | + WP_CLI::log($this->color_message($column, $data)); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } |
@@ -677,27 +677,27 @@ discard block |
||
677 | 677 | * |
678 | 678 | * @return void |
679 | 679 | */ |
680 | - public function report( $args, $assoc_args ) { |
|
680 | + public function report($args, $assoc_args) { |
|
681 | 681 | $stats = new Give_Payment_Stats(); |
682 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
683 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
684 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
685 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
682 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
683 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
684 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
685 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
686 | 686 | |
687 | - if ( ! empty( $date ) ) { |
|
687 | + if ( ! empty($date)) { |
|
688 | 688 | $start_date = $date; |
689 | 689 | $end_date = false; |
690 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
690 | + } elseif (empty($date) && empty($start_date)) { |
|
691 | 691 | $start_date = 'this_month'; |
692 | 692 | $end_date = false; |
693 | 693 | } |
694 | 694 | |
695 | 695 | // Get stats. |
696 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
697 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
696 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
697 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
698 | 698 | |
699 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
700 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
699 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
700 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -724,27 +724,27 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @subcommand cache |
726 | 726 | */ |
727 | - public function cache( $args, $assoc_args ) { |
|
728 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
727 | + public function cache($args, $assoc_args) { |
|
728 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
729 | 729 | |
730 | 730 | // Bailout. |
731 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
732 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
731 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
732 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
733 | 733 | |
734 | 734 | return; |
735 | 735 | } |
736 | 736 | |
737 | - switch ( $action ) { |
|
737 | + switch ($action) { |
|
738 | 738 | case 'delete' : |
739 | 739 | // Reset counter. |
740 | 740 | self::$counter = 1; |
741 | 741 | |
742 | - if ( $this->delete_stats_transients() ) { |
|
742 | + if ($this->delete_stats_transients()) { |
|
743 | 743 | // Report .eading. |
744 | - WP_CLI::success( 'Give cache deleted.' ); |
|
744 | + WP_CLI::success('Give cache deleted.'); |
|
745 | 745 | } else { |
746 | 746 | // Report .eading. |
747 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
747 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
748 | 748 | } |
749 | 749 | break; |
750 | 750 | } |
@@ -773,27 +773,27 @@ discard block |
||
773 | 773 | ARRAY_A |
774 | 774 | ); |
775 | 775 | |
776 | - if ( ! empty( $stat_option_names ) ) { |
|
776 | + if ( ! empty($stat_option_names)) { |
|
777 | 777 | |
778 | - foreach ( $stat_option_names as $option_name ) { |
|
778 | + foreach ($stat_option_names as $option_name) { |
|
779 | 779 | $error = false; |
780 | 780 | $option_name = $option_name['option_name']; |
781 | 781 | |
782 | - switch ( true ) { |
|
783 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
784 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
785 | - $error = delete_transient( $option_name ); |
|
782 | + switch (true) { |
|
783 | + case (false !== strpos($option_name, 'transient')): |
|
784 | + $option_name = str_replace('_transient_', '', $option_name); |
|
785 | + $error = delete_transient($option_name); |
|
786 | 786 | break; |
787 | 787 | |
788 | 788 | default: |
789 | - $error = delete_option( $option_name ); |
|
789 | + $error = delete_option($option_name); |
|
790 | 790 | } |
791 | 791 | |
792 | - if ( $error ) { |
|
793 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
794 | - self::$counter ++; |
|
792 | + if ($error) { |
|
793 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
794 | + self::$counter++; |
|
795 | 795 | } else { |
796 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
796 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return string |
816 | 816 | */ |
817 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
817 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
818 | 818 | // Add colon. |
819 | - if ( $colon ) { |
|
820 | - $heading = $heading . ': '; |
|
819 | + if ($colon) { |
|
820 | + $heading = $heading.': '; |
|
821 | 821 | } |
822 | 822 | |
823 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
823 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
839 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
838 | + private function color_main_heading($heading, $color = 'g') { |
|
839 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * |
850 | 850 | * @return void |
851 | 851 | */ |
852 | - private function color_sub_heading( $subheading ) { |
|
853 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
852 | + private function color_sub_heading($subheading) { |
|
853 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | |
@@ -864,17 +864,17 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return void |
866 | 866 | */ |
867 | - private function display_table( $data ) { |
|
867 | + private function display_table($data) { |
|
868 | 868 | $table = new \cli\Table(); |
869 | 869 | |
870 | 870 | // Set table header. |
871 | - $table->setHeaders( $data[0] ); |
|
871 | + $table->setHeaders($data[0]); |
|
872 | 872 | |
873 | 873 | // Remove table header. |
874 | - unset( $data[0] ); |
|
874 | + unset($data[0]); |
|
875 | 875 | |
876 | 876 | // Set table data. |
877 | - $table->setRows( $data ); |
|
877 | + $table->setRows($data); |
|
878 | 878 | |
879 | 879 | // Display table. |
880 | 880 | $table->display(); |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | * @return array |
892 | 892 | */ |
893 | 893 | |
894 | - private function get_donors_by_form_id( $form_id ) { |
|
894 | + private function get_donors_by_form_id($form_id) { |
|
895 | 895 | $donors = array(); |
896 | 896 | |
897 | 897 | $donations = new Give_Payments_Query( |
898 | 898 | array( |
899 | - 'give_forms' => array( $form_id ), |
|
900 | - 'number' => - 1, |
|
901 | - 'status' => array( 'publish' ), |
|
899 | + 'give_forms' => array($form_id), |
|
900 | + 'number' => -1, |
|
901 | + 'status' => array('publish'), |
|
902 | 902 | ) |
903 | 903 | ); |
904 | 904 | |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | $skip_donors = array(); |
907 | 907 | |
908 | 908 | /* @var Give_Payment|object $donation Payment object. */ |
909 | - foreach ( $donations as $donation ) { |
|
909 | + foreach ($donations as $donation) { |
|
910 | 910 | |
911 | - if ( in_array( $donation->customer_id, $skip_donors ) ) { |
|
911 | + if (in_array($donation->customer_id, $skip_donors)) { |
|
912 | 912 | continue; |
913 | 913 | } |
914 | 914 | |
915 | - if ( ! empty( $donors ) ) { |
|
916 | - $donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) ); |
|
915 | + if ( ! empty($donors)) { |
|
916 | + $donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id))); |
|
917 | 917 | } else { |
918 | - $donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) ); |
|
918 | + $donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id)); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | $skip_donors[] = $donation->customer_id; |