@@ -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_Import' ) ) { |
|
16 | +if ( ! class_exists('Give_Settings_Import')) { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Import. |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | 40 | $this->id = 'import'; |
41 | - $this->label = __( 'Import', 'give' ); |
|
41 | + $this->label = __('Import', 'give'); |
|
42 | 42 | |
43 | 43 | // Add Import tab in submenu. |
44 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
44 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
45 | 45 | |
46 | 46 | // Will display html of the import donation. |
47 | - add_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field' ), 10, 2 ); |
|
47 | + add_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Will call the function that generated the hook called 'give_admin_field_tools_import'. |
50 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
50 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
51 | 51 | |
52 | 52 | // Do not use main form for this tab. |
53 | - if ( give_get_current_setting_tab() === $this->id ) { |
|
54 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
55 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
53 | + if (give_get_current_setting_tab() === $this->id) { |
|
54 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
55 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
56 | 56 | |
57 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/import/class-give-import-donations.php'; |
|
57 | + require_once GIVE_PLUGIN_DIR.'includes/admin/tools/import/class-give-import-donations.php'; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param array $settings |
78 | 78 | */ |
79 | 79 | $settings = apply_filters( |
80 | - 'give_get_settings_' . $this->id, |
|
80 | + 'give_get_settings_'.$this->id, |
|
81 | 81 | array( |
82 | 82 | array( |
83 | 83 | 'id' => 'give_tools_import', |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | ), |
87 | 87 | array( |
88 | 88 | 'id' => 'import', |
89 | - 'name' => __( 'Import', 'give' ), |
|
89 | + 'name' => __('Import', 'give'), |
|
90 | 90 | 'type' => 'tools_import', |
91 | 91 | ), |
92 | 92 | array( |
93 | - 'name' => esc_html__( 'Import Docs Link', 'give' ), |
|
93 | + 'name' => esc_html__('Import Docs Link', 'give'), |
|
94 | 94 | 'id' => 'import_docs_link', |
95 | - 'url' => esc_url( 'http://docs.givewp.com/tools-importer' ), |
|
96 | - 'title' => __( 'Import Tab', 'give' ), |
|
95 | + 'url' => esc_url('http://docs.givewp.com/tools-importer'), |
|
96 | + 'title' => __('Import Tab', 'give'), |
|
97 | 97 | 'type' => 'give_docs_link', |
98 | 98 | ), |
99 | 99 | array( |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param $field |
118 | 118 | * @param $option_value |
119 | 119 | */ |
120 | - public static function render_import_field( $field, $option_value ) { |
|
121 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php'; |
|
120 | + public static function render_import_field($field, $option_value) { |
|
121 | + include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php'; |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
@@ -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,13 +26,13 @@ discard block |
||
26 | 26 | ob_start(); ?> |
27 | 27 | <div class="wrap" id="give-add-ons"> |
28 | 28 | <h1><?php echo get_admin_page_title(); ?> |
29 | - — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?> |
|
29 | + — <a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?> |
|
30 | 30 | <span class="dashicons dashicons-external"></span></a> |
31 | 31 | </h1> |
32 | 32 | |
33 | 33 | <hr class="wp-header-end"> |
34 | 34 | |
35 | - <p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p> |
|
35 | + <p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p> |
|
36 | 36 | <?php echo give_add_ons_get_feed(); ?> |
37 | 37 | </div> |
38 | 38 | <?php |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | function give_add_ons_get_feed() { |
51 | 51 | |
52 | 52 | $addons_debug = false; //set to true to debug |
53 | - $cache = Give_Cache::get( 'give_add_ons_feed', true ); |
|
53 | + $cache = Give_Cache::get('give_add_ons_feed', true); |
|
54 | 54 | |
55 | - if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) { |
|
56 | - $feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) ); |
|
55 | + if ($cache === false || $addons_debug === true && WP_DEBUG === true) { |
|
56 | + $feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false)); |
|
57 | 57 | |
58 | - if ( ! is_wp_error( $feed ) ) { |
|
59 | - if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) { |
|
60 | - $cache = wp_remote_retrieve_body( $feed ); |
|
61 | - Give_Cache::set( 'give_add_ons_feed', $cache, HOUR_IN_SECONDS, true ); |
|
58 | + if ( ! is_wp_error($feed)) { |
|
59 | + if (isset($feed['body']) && strlen($feed['body']) > 0) { |
|
60 | + $cache = wp_remote_retrieve_body($feed); |
|
61 | + Give_Cache::set('give_add_ons_feed', $cache, HOUR_IN_SECONDS, true); |
|
62 | 62 | } |
63 | 63 | } else { |
64 | 64 | $cache = sprintf( |
65 | 65 | '<div class="error"><p>%s</p></div>', |
66 | - esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) |
|
66 | + esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @access public |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
39 | - add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10 ); |
|
40 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard'), 10 ); |
|
38 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
39 | + add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10); |
|
40 | + add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public function add_roles() { |
54 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
54 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
55 | 55 | 'read' => true, |
56 | 56 | 'edit_posts' => true, |
57 | 57 | 'delete_posts' => true, |
@@ -80,25 +80,25 @@ discard block |
||
80 | 80 | 'publish_posts' => true, |
81 | 81 | 'read_private_pages' => true, |
82 | 82 | 'read_private_posts' => true, |
83 | - ) ); |
|
83 | + )); |
|
84 | 84 | |
85 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
85 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
86 | 86 | 'read' => true, |
87 | 87 | 'edit_posts' => false, |
88 | 88 | 'delete_posts' => false |
89 | - ) ); |
|
89 | + )); |
|
90 | 90 | |
91 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
91 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
92 | 92 | 'read' => true, |
93 | 93 | 'edit_posts' => true, |
94 | 94 | 'edit_pages' => true, |
95 | 95 | 'upload_files' => true, |
96 | 96 | 'delete_posts' => false, |
97 | - ) ); |
|
97 | + )); |
|
98 | 98 | |
99 | - add_role( 'give_donor', __( 'Give Donor', 'give' ), array( |
|
99 | + add_role('give_donor', __('Give Donor', 'give'), array( |
|
100 | 100 | 'read' => true, |
101 | - ) ); |
|
101 | + )); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -117,38 +117,38 @@ discard block |
||
117 | 117 | public function add_caps() { |
118 | 118 | global $wp_roles; |
119 | 119 | |
120 | - if ( class_exists( 'WP_Roles' ) ) { |
|
121 | - if ( ! isset( $wp_roles ) ) { |
|
120 | + if (class_exists('WP_Roles')) { |
|
121 | + if ( ! isset($wp_roles)) { |
|
122 | 122 | $wp_roles = new WP_Roles(); |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if ( is_object( $wp_roles ) ) { |
|
127 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
126 | + if (is_object($wp_roles)) { |
|
127 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
128 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
129 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
131 | 131 | |
132 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
133 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
134 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
135 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
132 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
133 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
134 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
135 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
136 | 136 | |
137 | 137 | // Add the main post type capabilities. |
138 | 138 | $capabilities = $this->get_core_caps(); |
139 | - foreach ( $capabilities as $cap_group ) { |
|
140 | - foreach ( $cap_group as $cap ) { |
|
141 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
142 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
143 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
139 | + foreach ($capabilities as $cap_group) { |
|
140 | + foreach ($cap_group as $cap) { |
|
141 | + $wp_roles->add_cap('administrator', $cap); |
|
142 | + $wp_roles->add_cap('give_manager', $cap); |
|
143 | + $wp_roles->add_cap('give_worker', $cap); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
148 | - $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
149 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
150 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
151 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
147 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
148 | + $wp_roles->add_cap('give_accountant', 'read_private_give_forms'); |
|
149 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
150 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
151 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | } |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | public function get_core_caps() { |
167 | 167 | $capabilities = array(); |
168 | 168 | |
169 | - $capability_types = array( 'give_form', 'give_payment' ); |
|
169 | + $capability_types = array('give_form', 'give_payment'); |
|
170 | 170 | |
171 | - foreach ( $capability_types as $capability_type ) { |
|
172 | - $capabilities[ $capability_type ] = array( |
|
171 | + foreach ($capability_types as $capability_type) { |
|
172 | + $capabilities[$capability_type] = array( |
|
173 | 173 | // Post type. |
174 | 174 | "edit_{$capability_type}", |
175 | 175 | "read_{$capability_type}", |
@@ -215,22 +215,22 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return array $caps Meta capabilities. |
217 | 217 | */ |
218 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
218 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
219 | 219 | |
220 | - switch ( $cap ) { |
|
220 | + switch ($cap) { |
|
221 | 221 | |
222 | 222 | case 'view_give_form_stats' : |
223 | 223 | |
224 | - if ( empty( $args[0] ) ) { |
|
224 | + if (empty($args[0])) { |
|
225 | 225 | break; |
226 | 226 | } |
227 | 227 | |
228 | - $form = get_post( $args[0] ); |
|
229 | - if ( empty( $form ) ) { |
|
228 | + $form = get_post($args[0]); |
|
229 | + if (empty($form)) { |
|
230 | 230 | break; |
231 | 231 | } |
232 | 232 | |
233 | - if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
233 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
234 | 234 | $caps = array(); |
235 | 235 | } |
236 | 236 | |
@@ -257,41 +257,41 @@ discard block |
||
257 | 257 | |
258 | 258 | global $wp_roles; |
259 | 259 | |
260 | - if ( class_exists( 'WP_Roles' ) ) { |
|
261 | - if ( ! isset( $wp_roles ) ) { |
|
260 | + if (class_exists('WP_Roles')) { |
|
261 | + if ( ! isset($wp_roles)) { |
|
262 | 262 | $wp_roles = new WP_Roles(); |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - if ( is_object( $wp_roles ) ) { |
|
266 | + if (is_object($wp_roles)) { |
|
267 | 267 | // Give Manager Capabilities. |
268 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
269 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
270 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
271 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
268 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
269 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
270 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
271 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
272 | 272 | |
273 | 273 | // Site Administrator Capabilities. |
274 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
275 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
276 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
277 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
274 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
275 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
276 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
277 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
278 | 278 | |
279 | 279 | // Remove the Main Post Type Capabilities. |
280 | 280 | $capabilities = $this->get_core_caps(); |
281 | 281 | |
282 | - foreach ( $capabilities as $cap_group ) { |
|
283 | - foreach ( $cap_group as $cap ) { |
|
284 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
285 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
286 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
282 | + foreach ($capabilities as $cap_group) { |
|
283 | + foreach ($cap_group as $cap) { |
|
284 | + $wp_roles->remove_cap('give_manager', $cap); |
|
285 | + $wp_roles->remove_cap('administrator', $cap); |
|
286 | + $wp_roles->remove_cap('give_worker', $cap); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | 290 | /** Give Accountant Capabilities */ |
291 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
292 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
293 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
294 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
291 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
292 | + $wp_roles->remove_cap('give_accountant', 'read_private_give_forms'); |
|
293 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
294 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $current_user = wp_get_current_user(); |
312 | 312 | |
313 | 313 | // If user with "Give Accountant" user role is logged-in . |
314 | - if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) { |
|
314 | + if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) { |
|
315 | 315 | |
316 | 316 | // Return false, means no prevention. |
317 | 317 | return false; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|bool Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return array Variable prices |
67 | 67 | */ |
68 | -function give_get_variable_price_ids( $form_id = 0 ) { |
|
69 | - if( ! ( $prices = give_get_variable_prices( $form_id ) ) ) { |
|
68 | +function give_get_variable_price_ids($form_id = 0) { |
|
69 | + if ( ! ($prices = give_get_variable_prices($form_id))) { |
|
70 | 70 | return array(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $price_ids = array(); |
74 | - foreach ( $prices as $price ){ |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | $price_ids[] = $price['_give_id']['level_id']; |
76 | 76 | } |
77 | 77 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string $default_price |
91 | 91 | */ |
92 | -function give_get_default_multilevel_amount( $form_id ) { |
|
92 | +function give_get_default_multilevel_amount($form_id) { |
|
93 | 93 | $default_price = '1.00'; |
94 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
94 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
95 | 95 | |
96 | - foreach ( $prices as $price ) { |
|
96 | + foreach ($prices as $price) { |
|
97 | 97 | |
98 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
98 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
99 | 99 | $default_price = $price['_give_amount']; |
100 | 100 | } |
101 | 101 | |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | * @return string $default_price |
117 | 117 | * @since 1.0 |
118 | 118 | */ |
119 | -function give_get_default_form_amount( $form_id ) { |
|
119 | +function give_get_default_form_amount($form_id) { |
|
120 | 120 | |
121 | - if ( give_has_variable_prices( $form_id ) ) { |
|
121 | + if (give_has_variable_prices($form_id)) { |
|
122 | 122 | |
123 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
123 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
124 | 124 | |
125 | 125 | } else { |
126 | 126 | |
127 | - $default_amount = give_get_meta( $form_id, '_give_set_price', true ); |
|
127 | + $default_amount = give_get_meta($form_id, '_give_set_price', true); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - return apply_filters( 'give_default_form_amount', $default_amount, $form_id ); |
|
131 | + return apply_filters('give_default_form_amount', $default_amount, $form_id); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
149 | +function give_is_custom_price_mode($form_id = 0) { |
|
150 | 150 | |
151 | - if ( empty( $form_id ) ) { |
|
151 | + if (empty($form_id)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $form = new Give_Donate_Form( $form_id ); |
|
155 | + $form = new Give_Donate_Form($form_id); |
|
156 | 156 | |
157 | 157 | return $form->is_custom_price_mode(); |
158 | 158 | } |
159 | 159 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,34 +26,34 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
30 | 30 | // Bailout. |
31 | - if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) { |
|
31 | + if ( ! function_exists('give_v18_renamed_core_settings')) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get old setting names. |
36 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
36 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
37 | 37 | $update_setting = false; |
38 | 38 | |
39 | - foreach ( $settings as $key => $value ) { |
|
39 | + foreach ($settings as $key => $value) { |
|
40 | 40 | |
41 | 41 | // Check 1. Check if new option is really updated or not. |
42 | 42 | // Check 2. Continue if key is not renamed. |
43 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
43 | + if ( ! isset($old_settings[$key])) { |
|
44 | 44 | continue; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Set old setting. |
48 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
48 | + $settings[$old_settings[$key]] = 'on'; |
|
49 | 49 | |
50 | 50 | // Do not need to set old setting if new setting is not set. |
51 | 51 | if ( |
52 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
53 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
52 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
53 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
54 | 54 | |
55 | 55 | ) { |
56 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
56 | + unset($settings[$old_settings[$key]]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Tell bot to update setting. |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update setting if any old setting set. |
64 | - if ( $update_setting ) { |
|
65 | - update_option( 'give_settings', $settings ); |
|
64 | + if ($update_setting) { |
|
65 | + update_option('give_settings', $settings); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
69 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Check spam through Akismet. |
@@ -80,45 +80,45 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool|mixed |
82 | 82 | */ |
83 | -function give_akismet( $spam ) { |
|
83 | +function give_akismet($spam) { |
|
84 | 84 | |
85 | 85 | // Bail out, If spam. |
86 | - if ( $spam ) { |
|
86 | + if ($spam) { |
|
87 | 87 | return $spam; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Bail out, if Akismet key not exist. |
91 | - if ( ! give_check_akismet_key() ) { |
|
91 | + if ( ! give_check_akismet_key()) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Build args array. |
96 | 96 | $args = array(); |
97 | 97 | |
98 | - $args['comment_author'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
99 | - $args['comment_author_email'] = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
100 | - $args['blog'] = get_option( 'home' ); |
|
98 | + $args['comment_author'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
99 | + $args['comment_author_email'] = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
100 | + $args['blog'] = get_option('home'); |
|
101 | 101 | $args['blog_lang'] = get_locale(); |
102 | - $args['blog_charset'] = get_option( 'blog_charset' ); |
|
102 | + $args['blog_charset'] = get_option('blog_charset'); |
|
103 | 103 | $args['user_ip'] = $_SERVER['REMOTE_ADDR']; |
104 | 104 | $args['user_agent'] = $_SERVER['HTTP_USER_AGENT']; |
105 | 105 | $args['referrer'] = $_SERVER['HTTP_REFERER']; |
106 | 106 | $args['comment_type'] = 'contact-form'; |
107 | 107 | |
108 | - $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); |
|
108 | + $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'); |
|
109 | 109 | |
110 | - foreach ( $_SERVER as $key => $value ) { |
|
111 | - if ( ! in_array( $key, (array) $ignore ) ) { |
|
110 | + foreach ($_SERVER as $key => $value) { |
|
111 | + if ( ! in_array($key, (array) $ignore)) { |
|
112 | 112 | $args["$key"] = $value; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // It will return Akismet spam detect API response. |
117 | - return give_akismet_spam_check( $args ); |
|
117 | + return give_akismet_spam_check($args); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | -add_filter( 'give_spam', 'give_akismet' ); |
|
121 | +add_filter('give_spam', 'give_akismet'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Check Akismet API Key. |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | * @return bool |
129 | 129 | */ |
130 | 130 | function give_check_akismet_key() { |
131 | - if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+ |
|
131 | + if (is_callable(array('Akismet', 'get_api_key'))) { // Akismet v3.0+ |
|
132 | 132 | return (bool) Akismet::get_api_key(); |
133 | 133 | } |
134 | 134 | |
135 | - if ( function_exists( 'akismet_get_key' ) ) { |
|
135 | + if (function_exists('akismet_get_key')) { |
|
136 | 136 | return (bool) akismet_get_key(); |
137 | 137 | } |
138 | 138 | |
@@ -148,24 +148,24 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool|mixed |
150 | 150 | */ |
151 | -function give_akismet_spam_check( $args ) { |
|
151 | +function give_akismet_spam_check($args) { |
|
152 | 152 | global $akismet_api_host, $akismet_api_port; |
153 | 153 | |
154 | 154 | $spam = false; |
155 | - $query_string = http_build_query( $args ); |
|
155 | + $query_string = http_build_query($args); |
|
156 | 156 | |
157 | - if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+ |
|
158 | - $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
157 | + if (is_callable(array('Akismet', 'http_post'))) { // Akismet v3.0+ |
|
158 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
159 | 159 | } else { |
160 | - $response = akismet_http_post( $query_string, $akismet_api_host, |
|
161 | - '/1.1/comment-check', $akismet_api_port ); |
|
160 | + $response = akismet_http_post($query_string, $akismet_api_host, |
|
161 | + '/1.1/comment-check', $akismet_api_port); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // It's spam if response status is true. |
165 | - if ( 'true' === $response[1] ) { |
|
165 | + if ('true' === $response[1]) { |
|
166 | 166 | $spam = true; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Allow developer to modified Akismet spam detection response. |
170 | - return apply_filters( 'give_akismet_spam_check', $spam, $args ); |
|
170 | + return apply_filters('give_akismet_spam_check', $spam, $args); |
|
171 | 171 | } |
172 | 172 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /* @var WPDB $wpdb */ |
44 | 44 | global $wpdb; |
45 | 45 | |
46 | - $wpdb->customermeta = $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
46 | + $wpdb->customermeta = $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
47 | 47 | $this->primary_key = 'meta_id'; |
48 | 48 | $this->version = '1.0'; |
49 | 49 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
83 | 83 | */ |
84 | - public function get_meta( $donor_id = 0, $meta_key = '', $single = false ) { |
|
85 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
86 | - if ( false === $donor_id ) { |
|
84 | + public function get_meta($donor_id = 0, $meta_key = '', $single = false) { |
|
85 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
86 | + if (false === $donor_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
90 | - return get_metadata( 'customer', $donor_id, $meta_key, $single ); |
|
90 | + return get_metadata('customer', $donor_id, $meta_key, $single); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return bool False for failure. True for success. |
107 | 107 | */ |
108 | - public function add_meta( $donor_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
109 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
110 | - if ( false === $donor_id ) { |
|
108 | + public function add_meta($donor_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
109 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
110 | + if (false === $donor_id) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | |
114 | - return add_metadata( 'customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
114 | + return add_metadata('customer', $donor_id, $meta_key, $meta_value, $unique); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return bool False on failure, true if success. |
136 | 136 | */ |
137 | - public function update_meta( $donor_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
138 | - $donor_id = $this->sanitize_donor_id( $donor_id ); |
|
139 | - if ( false === $donor_id ) { |
|
137 | + public function update_meta($donor_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
138 | + $donor_id = $this->sanitize_donor_id($donor_id); |
|
139 | + if (false === $donor_id) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - return update_metadata( 'customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
143 | + return update_metadata('customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return bool False for failure. True for success. |
163 | 163 | */ |
164 | - public function delete_meta( $donor_id = 0, $meta_key = '', $meta_value = '' ) { |
|
165 | - return delete_metadata( 'customer', $donor_id, $meta_key, $meta_value ); |
|
164 | + public function delete_meta($donor_id = 0, $meta_key = '', $meta_value = '') { |
|
165 | + return delete_metadata('customer', $donor_id, $meta_key, $meta_value); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool False for failure. True for success. |
177 | 177 | */ |
178 | - public function delete_all_meta( $donor_id = 0 ) { |
|
178 | + public function delete_all_meta($donor_id = 0) { |
|
179 | 179 | global $wpdb; |
180 | - $wpdb->delete( $this->table_name, array( 'customer_id' => $donor_id ), array( '%d' ) ); |
|
180 | + $wpdb->delete($this->table_name, array('customer_id' => $donor_id), array('%d')); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function create_table() { |
192 | 192 | |
193 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
193 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
194 | 194 | |
195 | 195 | $sql = "CREATE TABLE {$this->table_name} ( |
196 | 196 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | KEY meta_key (meta_key) |
203 | 203 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
204 | 204 | |
205 | - dbDelta( $sql ); |
|
205 | + dbDelta($sql); |
|
206 | 206 | |
207 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
207 | + update_option($this->table_name.'_db_version', $this->version); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -217,23 +217,23 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return int|bool The normalized donor ID or false if it's found to not be valid. |
219 | 219 | */ |
220 | - private function sanitize_donor_id( $donor_id ) { |
|
221 | - if ( ! is_numeric( $donor_id ) ) { |
|
220 | + private function sanitize_donor_id($donor_id) { |
|
221 | + if ( ! is_numeric($donor_id)) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $donor_id = (int) $donor_id; |
226 | 226 | |
227 | 227 | // We were given a non positive number. |
228 | - if ( absint( $donor_id ) !== $donor_id ) { |
|
228 | + if (absint($donor_id) !== $donor_id) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | |
232 | - if ( empty( $donor_id ) ) { |
|
232 | + if (empty($donor_id)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - return absint( $donor_id ); |
|
236 | + return absint($donor_id); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 |
@@ -288,8 +288,8 @@ |
||
288 | 288 | |
289 | 289 | // Check spam detect. |
290 | 290 | if ( isset( $_POST['action'] ) |
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | - && give_is_spam_donation() |
|
291 | + && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
292 | + && give_is_spam_donation() |
|
293 | 293 | ) { |
294 | 294 | give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
295 | 295 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -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_donation_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_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_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,21 +97,20 @@ 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'] ) ? |
|
103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
104 | - '0.00'; |
|
105 | - $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']) ? |
|
103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
106 | 105 | |
107 | 106 | // Setup donation information. |
108 | 107 | $donation_data = array( |
109 | 108 | 'price' => $price, |
110 | 109 | 'purchase_key' => $purchase_key, |
111 | 110 | 'user_email' => $user['user_email'], |
112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
114 | - 'post_data' => give_clean( $_POST ), |
|
111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
112 | + 'user_info' => stripslashes_deep($user_info), |
|
113 | + 'post_data' => give_clean($_POST), |
|
115 | 114 | 'gateway' => $valid_data['gateway'], |
116 | 115 | 'card_info' => $valid_data['cc_info'], |
117 | 116 | ); |
@@ -130,10 +129,10 @@ discard block |
||
130 | 129 | * @param array $user_info Array containing basic user information. |
131 | 130 | * @param bool|array $valid_data Validate fields. |
132 | 131 | */ |
133 | - do_action( 'give_checkout_before_gateway', give_clean( $_POST ), $user_info, $valid_data ); |
|
132 | + do_action('give_checkout_before_gateway', give_clean($_POST), $user_info, $valid_data); |
|
134 | 133 | |
135 | 134 | // Sanity check for price. |
136 | - if ( ! $donation_data['price'] ) { |
|
135 | + if ( ! $donation_data['price']) { |
|
137 | 136 | // Revert to manual. |
138 | 137 | $donation_data['gateway'] = 'manual'; |
139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
144 | 143 | * |
145 | 144 | * @since 1.7 |
146 | 145 | */ |
147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
148 | 147 | |
149 | 148 | // Setup the data we're storing in the donation session. |
150 | 149 | $session_data = $donation_data; |
151 | 150 | |
152 | 151 | // Make sure credit card numbers are never stored in sessions. |
153 | - unset( $session_data['card_info']['card_number'] ); |
|
154 | - unset( $session_data['post_data']['card_number'] ); |
|
152 | + unset($session_data['card_info']['card_number']); |
|
153 | + unset($session_data['post_data']['card_number']); |
|
155 | 154 | |
156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
157 | - give_set_purchase_session( $session_data ); |
|
156 | + give_set_purchase_session($session_data); |
|
158 | 157 | |
159 | 158 | // Send info to the gateway for payment processing. |
160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
161 | 160 | give_die(); |
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
168 | 167 | |
169 | 168 | |
170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return void |
179 | 178 | */ |
180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
181 | 180 | |
182 | 181 | // Verify that the email address belongs to this customer. |
183 | - if ( is_user_logged_in() ) { |
|
182 | + if (is_user_logged_in()) { |
|
184 | 183 | |
185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
187 | 186 | |
188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer. |
189 | 188 | if ( |
190 | 189 | $submitted_email !== $donor->email |
191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
192 | 191 | ) { |
193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
192 | + $found_donor = new Give_Donor($submitted_email); |
|
194 | 193 | |
195 | - if ( $found_donor->id > 0 ) { |
|
196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
194 | + if ($found_donor->id > 0) { |
|
195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
203 | 202 | |
204 | 203 | /** |
205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
209 | 208 | * @return void |
210 | 209 | */ |
211 | 210 | function give_process_form_login() { |
212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
211 | + $is_ajax = isset($_POST['give_ajax']); |
|
213 | 212 | |
214 | 213 | $user_data = give_donation_form_validate_user_login(); |
215 | 214 | |
216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
217 | - if ( $is_ajax ) { |
|
215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
216 | + if ($is_ajax) { |
|
218 | 217 | /** |
219 | 218 | * Fires when AJAX sends back errors from the donation form. |
220 | 219 | * |
221 | 220 | * @since 1.0 |
222 | 221 | */ |
223 | 222 | ob_start(); |
224 | - do_action( 'give_ajax_donation_errors' ); |
|
223 | + do_action('give_ajax_donation_errors'); |
|
225 | 224 | $message = ob_get_contents(); |
226 | 225 | ob_end_clean(); |
227 | - wp_send_json_error( $message ); |
|
226 | + wp_send_json_error($message); |
|
228 | 227 | } else { |
229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
230 | 229 | exit; |
231 | 230 | } |
232 | 231 | } |
233 | 232 | |
234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
235 | 234 | |
236 | - if ( $is_ajax ) { |
|
235 | + if ($is_ajax) { |
|
237 | 236 | $message = Give()->notices->print_frontend_notice( |
238 | 237 | sprintf( |
239 | 238 | /* translators: %s: user first name */ |
240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
242 | 241 | ), |
243 | 242 | false, |
244 | 243 | 'success' |
245 | 244 | ); |
246 | 245 | |
247 | - wp_send_json_success( $message ); |
|
246 | + wp_send_json_success($message); |
|
248 | 247 | } else { |
249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
250 | 249 | } |
251 | 250 | } |
252 | 251 | |
253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
255 | 254 | |
256 | 255 | /** |
257 | 256 | * Donation Form Validate Fields. |
@@ -263,63 +262,63 @@ discard block |
||
263 | 262 | function give_donation_form_validate_fields() { |
264 | 263 | |
265 | 264 | // Check if there is $_POST. |
266 | - if ( empty( $_POST ) ) { |
|
265 | + if (empty($_POST)) { |
|
267 | 266 | return false; |
268 | 267 | } |
269 | 268 | |
270 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
269 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
271 | 270 | |
272 | 271 | // Start an array to collect valid data. |
273 | 272 | $valid_data = array( |
274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here). |
275 | - 'need_new_user' => false, // New user flag. |
|
276 | - 'need_user_login' => false, // Login user flag. |
|
277 | - 'logged_user_data' => array(), // Logged user collected data. |
|
278 | - 'new_user_data' => array(), // New user collected data. |
|
279 | - 'login_user_data' => array(), // Login user collected data. |
|
280 | - 'guest_user_data' => array(), // Guest user collected data. |
|
281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info. |
|
274 | + 'need_new_user' => false, // New user flag. |
|
275 | + 'need_user_login' => false, // Login user flag. |
|
276 | + 'logged_user_data' => array(), // Logged user collected data. |
|
277 | + 'new_user_data' => array(), // New user collected data. |
|
278 | + 'login_user_data' => array(), // Login user collected data. |
|
279 | + 'guest_user_data' => array(), // Guest user collected data. |
|
280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info. |
|
282 | 281 | ); |
283 | 282 | |
284 | 283 | // Validate Honeypot First. |
285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
287 | 286 | } |
288 | 287 | |
289 | 288 | // Check spam detect. |
290 | - if ( isset( $_POST['action'] ) |
|
291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
289 | + if (isset($_POST['action']) |
|
290 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
292 | 291 | && give_is_spam_donation() |
293 | 292 | ) { |
294 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
293 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
295 | 294 | } |
296 | 295 | |
297 | 296 | // Validate agree to terms. |
298 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
297 | + if (give_is_terms_enabled($form_id)) { |
|
299 | 298 | give_donation_form_validate_agree_to_terms(); |
300 | 299 | } |
301 | 300 | |
302 | 301 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
303 | 302 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
304 | 303 | if ( |
305 | - ! give_logged_in_only( $form_id ) |
|
306 | - && isset( $_POST['give-purchase-var'] ) |
|
304 | + ! give_logged_in_only($form_id) |
|
305 | + && isset($_POST['give-purchase-var']) |
|
307 | 306 | && $_POST['give-purchase-var'] == 'needs-to-register' |
308 | - && empty( $_POST['give_user_login'] ) |
|
307 | + && empty($_POST['give_user_login']) |
|
309 | 308 | ) { |
310 | - unset( $_POST['give-purchase-var'] ); |
|
309 | + unset($_POST['give-purchase-var']); |
|
311 | 310 | } |
312 | 311 | |
313 | - if ( is_user_logged_in() ) { |
|
312 | + if (is_user_logged_in()) { |
|
314 | 313 | // Collect logged in user data. |
315 | 314 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
316 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
315 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
317 | 316 | // Set new user registration as required. |
318 | 317 | $valid_data['need_new_user'] = true; |
319 | 318 | // Validate new user data. |
320 | 319 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
321 | 320 | // Check if login validation is needed. |
322 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
321 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
323 | 322 | // Set user login as required. |
324 | 323 | $valid_data['need_user_login'] = true; |
325 | 324 | // Validate users login info. |
@@ -343,14 +342,14 @@ discard block |
||
343 | 342 | function give_is_spam_donation() { |
344 | 343 | $spam = false; |
345 | 344 | |
346 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
345 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
347 | 346 | |
348 | - if ( strlen( $user_agent ) < 2 ) { |
|
347 | + if (strlen($user_agent) < 2) { |
|
349 | 348 | $spam = true; |
350 | 349 | } |
351 | 350 | |
352 | 351 | // Allow developer to customized Akismet spam detect API call and it's response. |
353 | - return apply_filters( 'give_spam', $spam ); |
|
352 | + return apply_filters('give_spam', $spam); |
|
354 | 353 | } |
355 | 354 | |
356 | 355 | /** |
@@ -364,41 +363,41 @@ discard block |
||
364 | 363 | */ |
365 | 364 | function give_donation_form_validate_gateway() { |
366 | 365 | |
367 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
368 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
369 | - $gateway = give_get_default_gateway( $form_id ); |
|
366 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
367 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
368 | + $gateway = give_get_default_gateway($form_id); |
|
370 | 369 | |
371 | 370 | // Check if a gateway value is present. |
372 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
371 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
373 | 372 | |
374 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
373 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
375 | 374 | |
376 | 375 | // Is amount being donated in LIVE mode 0.00? If so, error: |
377 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
376 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
378 | 377 | |
379 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
378 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
380 | 379 | |
381 | 380 | } // End if(). |
382 | - elseif ( ! give_verify_minimum_price() ) { |
|
381 | + elseif ( ! give_verify_minimum_price()) { |
|
383 | 382 | // translators: %s: minimum donation amount. |
384 | 383 | give_set_error( |
385 | 384 | 'invalid_donation_minimum', |
386 | 385 | sprintf( |
387 | 386 | /* translators: %s: minimum donation amount */ |
388 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
389 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
387 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
388 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
390 | 389 | ) |
391 | 390 | ); |
392 | 391 | |
393 | 392 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
394 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
393 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
395 | 394 | |
396 | 395 | $gateway = 'manual'; |
397 | 396 | |
398 | 397 | } //Check if this gateway is active. |
399 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
398 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
400 | 399 | |
401 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
400 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
402 | 401 | |
403 | 402 | } |
404 | 403 | } |
@@ -416,21 +415,21 @@ discard block |
||
416 | 415 | */ |
417 | 416 | function give_verify_minimum_price() { |
418 | 417 | |
419 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
420 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
421 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
422 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
418 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
419 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
420 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
421 | + $variable_prices = give_has_variable_prices($form_id); |
|
423 | 422 | |
424 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
423 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
425 | 424 | |
426 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
425 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
427 | 426 | |
428 | - if ( $price_level_amount == $amount ) { |
|
427 | + if ($price_level_amount == $amount) { |
|
429 | 428 | return true; |
430 | 429 | } |
431 | 430 | } |
432 | 431 | |
433 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
432 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
434 | 433 | return false; |
435 | 434 | } |
436 | 435 | |
@@ -446,9 +445,9 @@ discard block |
||
446 | 445 | */ |
447 | 446 | function give_donation_form_validate_agree_to_terms() { |
448 | 447 | // Validate agree to terms. |
449 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
448 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
450 | 449 | // User did not agree. |
451 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
450 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
452 | 451 | } |
453 | 452 | } |
454 | 453 | |
@@ -462,59 +461,59 @@ discard block |
||
462 | 461 | * |
463 | 462 | * @return array |
464 | 463 | */ |
465 | -function give_get_required_fields( $form_id ) { |
|
464 | +function give_get_required_fields($form_id) { |
|
466 | 465 | |
467 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
466 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
468 | 467 | |
469 | 468 | $required_fields = array( |
470 | 469 | 'give_email' => array( |
471 | 470 | 'error_id' => 'invalid_email', |
472 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
471 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
473 | 472 | ), |
474 | 473 | 'give_first' => array( |
475 | 474 | 'error_id' => 'invalid_first_name', |
476 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
475 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
477 | 476 | ), |
478 | 477 | ); |
479 | 478 | |
480 | - $require_address = give_require_billing_address( $payment_mode ); |
|
479 | + $require_address = give_require_billing_address($payment_mode); |
|
481 | 480 | |
482 | - if ( $require_address ) { |
|
483 | - $required_fields['card_address'] = array( |
|
481 | + if ($require_address) { |
|
482 | + $required_fields['card_address'] = array( |
|
484 | 483 | 'error_id' => 'invalid_card_address', |
485 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
484 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
486 | 485 | ); |
487 | - $required_fields['card_zip'] = array( |
|
486 | + $required_fields['card_zip'] = array( |
|
488 | 487 | 'error_id' => 'invalid_zip_code', |
489 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
488 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
490 | 489 | ); |
491 | - $required_fields['card_city'] = array( |
|
490 | + $required_fields['card_city'] = array( |
|
492 | 491 | 'error_id' => 'invalid_city', |
493 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
492 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
494 | 493 | ); |
495 | 494 | $required_fields['billing_country'] = array( |
496 | 495 | 'error_id' => 'invalid_country', |
497 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
496 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
498 | 497 | ); |
499 | 498 | |
500 | 499 | |
501 | 500 | $required_fields['card_state'] = array( |
502 | 501 | 'error_id' => 'invalid_state', |
503 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
502 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
504 | 503 | ); |
505 | 504 | |
506 | 505 | // Check if billing country alredy exists. |
507 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
506 | + if ( ! empty($_POST['billing_country'])) { |
|
508 | 507 | // Get the value from $_POST. |
509 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
508 | + $country = sanitize_text_field($_POST['billing_country']); |
|
510 | 509 | |
511 | 510 | // Get the country list that does not required any states init. |
512 | 511 | $states_country = give_states_not_required_country_list(); |
513 | 512 | |
514 | 513 | // Check if states is empty or not. |
515 | - if ( array_key_exists( $country, $states_country ) ) { |
|
514 | + if (array_key_exists($country, $states_country)) { |
|
516 | 515 | // If states is empty remove the required feilds of state in billing cart. |
517 | - unset( $required_fields['card_state'] ); |
|
516 | + unset($required_fields['card_state']); |
|
518 | 517 | } |
519 | 518 | } |
520 | 519 | } |
@@ -524,7 +523,7 @@ discard block |
||
524 | 523 | * |
525 | 524 | * @since 1.7 |
526 | 525 | */ |
527 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
526 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
528 | 527 | |
529 | 528 | return $required_fields; |
530 | 529 | |
@@ -539,16 +538,16 @@ discard block |
||
539 | 538 | * |
540 | 539 | * @return bool |
541 | 540 | */ |
542 | -function give_require_billing_address( $payment_mode ) { |
|
541 | +function give_require_billing_address($payment_mode) { |
|
543 | 542 | |
544 | 543 | $return = false; |
545 | 544 | |
546 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
545 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
547 | 546 | $return = true; |
548 | 547 | } |
549 | 548 | |
550 | 549 | // Let payment gateways and other extensions determine if address fields should be required. |
551 | - return apply_filters( 'give_require_billing_address', $return ); |
|
550 | + return apply_filters('give_require_billing_address', $return); |
|
552 | 551 | |
553 | 552 | } |
554 | 553 | |
@@ -562,42 +561,42 @@ discard block |
||
562 | 561 | function give_donation_form_validate_logged_in_user() { |
563 | 562 | global $user_ID; |
564 | 563 | |
565 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
564 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
566 | 565 | |
567 | 566 | // Start empty array to collect valid user data. |
568 | 567 | $valid_user_data = array( |
569 | 568 | // Assume there will be errors. |
570 | - 'user_id' => - 1, |
|
569 | + 'user_id' => -1, |
|
571 | 570 | ); |
572 | 571 | |
573 | 572 | // Verify there is a user_ID. |
574 | - if ( $user_ID > 0 ) { |
|
573 | + if ($user_ID > 0) { |
|
575 | 574 | // Get the logged in user data. |
576 | - $user_data = get_userdata( $user_ID ); |
|
575 | + $user_data = get_userdata($user_ID); |
|
577 | 576 | |
578 | 577 | // Loop through required fields and show error messages. |
579 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
580 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
581 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
578 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
579 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
580 | + give_set_error($value['error_id'], $value['error_message']); |
|
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
585 | 584 | // Verify data. |
586 | - if ( $user_data ) { |
|
585 | + if ($user_data) { |
|
587 | 586 | // Collected logged in user data. |
588 | 587 | $valid_user_data = array( |
589 | 588 | 'user_id' => $user_ID, |
590 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
591 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
592 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
589 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
590 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
591 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
593 | 592 | ); |
594 | 593 | |
595 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
596 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
594 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
595 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
597 | 596 | } |
598 | 597 | } else { |
599 | 598 | // Set invalid user error. |
600 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
599 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
601 | 600 | } |
602 | 601 | } |
603 | 602 | |
@@ -616,7 +615,7 @@ discard block |
||
616 | 615 | // Default user data. |
617 | 616 | $default_user_data = array( |
618 | 617 | 'give-form-id' => '', |
619 | - 'user_id' => - 1, // Assume there will be errors. |
|
618 | + 'user_id' => -1, // Assume there will be errors. |
|
620 | 619 | 'user_first' => '', |
621 | 620 | 'user_last' => '', |
622 | 621 | 'give_user_login' => false, |
@@ -626,14 +625,14 @@ discard block |
||
626 | 625 | ); |
627 | 626 | |
628 | 627 | // Get user data. |
629 | - $user_data = wp_parse_args( give_clean( $_POST ), $default_user_data ); |
|
628 | + $user_data = wp_parse_args(give_clean($_POST), $default_user_data); |
|
630 | 629 | $registering_new_user = false; |
631 | - $form_id = absint( $user_data['give-form-id'] ); |
|
630 | + $form_id = absint($user_data['give-form-id']); |
|
632 | 631 | |
633 | 632 | // Start an empty array to collect valid user data. |
634 | 633 | $valid_user_data = array( |
635 | 634 | // Assume there will be errors. |
636 | - 'user_id' => - 1, |
|
635 | + 'user_id' => -1, |
|
637 | 636 | |
638 | 637 | // Get first name. |
639 | 638 | 'user_first' => $user_data['give_first'], |
@@ -643,25 +642,25 @@ discard block |
||
643 | 642 | ); |
644 | 643 | |
645 | 644 | // Loop through required fields and show error messages. |
646 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
647 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
648 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
645 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
646 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
647 | + give_set_error($value['error_id'], $value['error_message']); |
|
649 | 648 | } |
650 | 649 | } |
651 | 650 | |
652 | 651 | // Check if we have an username to register. |
653 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
652 | + if (give_validate_username($user_data['give_user_login'])) { |
|
654 | 653 | $registering_new_user = true; |
655 | 654 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
656 | 655 | } |
657 | 656 | |
658 | 657 | // Check if we have an email to verify. |
659 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
658 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
660 | 659 | $valid_user_data['user_email'] = $user_data['give_email']; |
661 | 660 | } |
662 | 661 | |
663 | 662 | // Check password. |
664 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
663 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
665 | 664 | // All is good to go. |
666 | 665 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
667 | 666 | } |
@@ -681,36 +680,36 @@ discard block |
||
681 | 680 | // Start an array to collect valid user data. |
682 | 681 | $valid_user_data = array( |
683 | 682 | // Assume there will be errors. |
684 | - 'user_id' => - 1, |
|
683 | + 'user_id' => -1, |
|
685 | 684 | ); |
686 | 685 | |
687 | 686 | // Username. |
688 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
689 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
687 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
688 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
690 | 689 | |
691 | 690 | return $valid_user_data; |
692 | 691 | } |
693 | 692 | |
694 | 693 | // Get the user by login. |
695 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
694 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
696 | 695 | |
697 | 696 | // Check if user exists. |
698 | - if ( $user_data ) { |
|
697 | + if ($user_data) { |
|
699 | 698 | // Get password. |
700 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
699 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
701 | 700 | |
702 | 701 | // Check user_pass. |
703 | - if ( $user_pass ) { |
|
702 | + if ($user_pass) { |
|
704 | 703 | // Check if password is valid. |
705 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
704 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
706 | 705 | // Incorrect password. |
707 | 706 | give_set_error( |
708 | 707 | 'password_incorrect', |
709 | 708 | sprintf( |
710 | 709 | '%1$s <a href="%2$s">%3$s</a>', |
711 | - __( 'The password you entered is incorrect.', 'give' ), |
|
712 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
713 | - __( 'Reset Password', 'give' ) |
|
710 | + __('The password you entered is incorrect.', 'give'), |
|
711 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
712 | + __('Reset Password', 'give') |
|
714 | 713 | ) |
715 | 714 | ); |
716 | 715 | // All is correct. |
@@ -728,11 +727,11 @@ discard block |
||
728 | 727 | } |
729 | 728 | } else { |
730 | 729 | // Empty password. |
731 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
730 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
732 | 731 | } |
733 | 732 | } else { |
734 | 733 | // No username. |
735 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
734 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
736 | 735 | }// End if(). |
737 | 736 | |
738 | 737 | return $valid_user_data; |
@@ -747,7 +746,7 @@ discard block |
||
747 | 746 | */ |
748 | 747 | function give_donation_form_validate_guest_user() { |
749 | 748 | |
750 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
749 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
751 | 750 | |
752 | 751 | // Start an array to collect valid user data. |
753 | 752 | $valid_user_data = array( |
@@ -756,38 +755,38 @@ discard block |
||
756 | 755 | ); |
757 | 756 | |
758 | 757 | // Show error message if user must be logged in. |
759 | - if ( give_logged_in_only( $form_id ) ) { |
|
760 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
758 | + if (give_logged_in_only($form_id)) { |
|
759 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
761 | 760 | } |
762 | 761 | |
763 | 762 | // Get the guest email. |
764 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
763 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
765 | 764 | |
766 | 765 | // Check email. |
767 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
766 | + if ($guest_email && strlen($guest_email) > 0) { |
|
768 | 767 | // Validate email. |
769 | - if ( ! is_email( $guest_email ) ) { |
|
768 | + if ( ! is_email($guest_email)) { |
|
770 | 769 | // Invalid email. |
771 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
770 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
772 | 771 | } else { |
773 | 772 | // All is good to go. |
774 | 773 | $valid_user_data['user_email'] = $guest_email; |
775 | 774 | |
776 | 775 | // Get user_id from donor if exist. |
777 | - $donor = new Give_Donor( $guest_email ); |
|
778 | - if ( $donor->id && $donor->user_id ) { |
|
776 | + $donor = new Give_Donor($guest_email); |
|
777 | + if ($donor->id && $donor->user_id) { |
|
779 | 778 | $valid_user_data['user_id'] = $donor->user_id; |
780 | 779 | } |
781 | 780 | } |
782 | 781 | } else { |
783 | 782 | // No email. |
784 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
783 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
785 | 784 | } |
786 | 785 | |
787 | 786 | // Loop through required fields and show error messages. |
788 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
789 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
790 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
787 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
788 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
789 | + give_set_error($value['error_id'], $value['error_message']); |
|
791 | 790 | } |
792 | 791 | } |
793 | 792 | |
@@ -803,36 +802,36 @@ discard block |
||
803 | 802 | * @since 1.0 |
804 | 803 | * @return integer |
805 | 804 | */ |
806 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
805 | +function give_register_and_login_new_user($user_data = array()) { |
|
807 | 806 | // Verify the array. |
808 | - if ( empty( $user_data ) ) { |
|
809 | - return - 1; |
|
807 | + if (empty($user_data)) { |
|
808 | + return -1; |
|
810 | 809 | } |
811 | 810 | |
812 | - if ( give_get_errors() ) { |
|
813 | - return - 1; |
|
811 | + if (give_get_errors()) { |
|
812 | + return -1; |
|
814 | 813 | } |
815 | 814 | |
816 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
817 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
818 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
819 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
820 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
821 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
822 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
823 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
824 | - ), $user_data ); |
|
815 | + $user_args = apply_filters('give_insert_user_args', array( |
|
816 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
817 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
818 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
819 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
820 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
821 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
822 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
823 | + ), $user_data); |
|
825 | 824 | |
826 | 825 | // Insert new user. |
827 | - $user_id = wp_insert_user( $user_args ); |
|
826 | + $user_id = wp_insert_user($user_args); |
|
828 | 827 | |
829 | 828 | // Validate inserted user. |
830 | - if ( is_wp_error( $user_id ) ) { |
|
831 | - return - 1; |
|
829 | + if (is_wp_error($user_id)) { |
|
830 | + return -1; |
|
832 | 831 | } |
833 | 832 | |
834 | 833 | // Allow themes and plugins to filter the user data. |
835 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
834 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
836 | 835 | |
837 | 836 | /** |
838 | 837 | * Fires after inserting user. |
@@ -842,7 +841,7 @@ discard block |
||
842 | 841 | * @param int $user_id User id. |
843 | 842 | * @param array $user_data Array containing user data. |
844 | 843 | */ |
845 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
844 | + do_action('give_insert_user', $user_id, $user_data); |
|
846 | 845 | |
847 | 846 | /** |
848 | 847 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -851,9 +850,9 @@ discard block |
||
851 | 850 | * |
852 | 851 | * return bool True if login with registration and False if only want to register. |
853 | 852 | */ |
854 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
853 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
855 | 854 | // Login new user. |
856 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
855 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
857 | 856 | } |
858 | 857 | |
859 | 858 | // Return user id. |
@@ -869,27 +868,27 @@ discard block |
||
869 | 868 | * @since 1.0 |
870 | 869 | * @return array|bool |
871 | 870 | */ |
872 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
871 | +function give_get_donation_form_user($valid_data = array()) { |
|
873 | 872 | |
874 | 873 | // Initialize user. |
875 | 874 | $user = false; |
876 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
875 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
877 | 876 | |
878 | - if ( $is_ajax ) { |
|
877 | + if ($is_ajax) { |
|
879 | 878 | // Do not create or login the user during the ajax submission (check for errors only). |
880 | 879 | return true; |
881 | - } elseif ( is_user_logged_in() ) { |
|
880 | + } elseif (is_user_logged_in()) { |
|
882 | 881 | // Set the valid user as the logged in collected data. |
883 | 882 | $user = $valid_data['logged_in_user']; |
884 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
883 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
885 | 884 | // New user registration. |
886 | - if ( $valid_data['need_new_user'] === true ) { |
|
885 | + if ($valid_data['need_new_user'] === true) { |
|
887 | 886 | // Set user. |
888 | 887 | $user = $valid_data['new_user_data']; |
889 | 888 | // Register and login new user. |
890 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
889 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
891 | 890 | // User login |
892 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
891 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
893 | 892 | |
894 | 893 | /** |
895 | 894 | * The login form is now processed in the give_process_donation_login() function. |
@@ -901,48 +900,48 @@ discard block |
||
901 | 900 | // Set user. |
902 | 901 | $user = $valid_data['login_user_data']; |
903 | 902 | // Login user. |
904 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
903 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
905 | 904 | } |
906 | 905 | } |
907 | 906 | |
908 | 907 | // Check guest checkout. |
909 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
908 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
910 | 909 | // Set user |
911 | 910 | $user = $valid_data['guest_user_data']; |
912 | 911 | } |
913 | 912 | |
914 | 913 | // Verify we have an user. |
915 | - if ( false === $user || empty( $user ) ) { |
|
914 | + if (false === $user || empty($user)) { |
|
916 | 915 | // Return false. |
917 | 916 | return false; |
918 | 917 | } |
919 | 918 | |
920 | 919 | // Get user first name. |
921 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
922 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
920 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
921 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
923 | 922 | } |
924 | 923 | |
925 | 924 | // Get user last name. |
926 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
927 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
925 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
926 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
928 | 927 | } |
929 | 928 | |
930 | 929 | // Get the user's billing address details. |
931 | 930 | $user['address'] = array(); |
932 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
933 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
934 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
935 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
936 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
937 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
938 | - |
|
939 | - if ( empty( $user['address']['country'] ) ) { |
|
931 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
932 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
933 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
934 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
935 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
936 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
937 | + |
|
938 | + if (empty($user['address']['country'])) { |
|
940 | 939 | $user['address'] = false; |
941 | 940 | } // End if(). |
942 | 941 | |
943 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
942 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
944 | 943 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
945 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
944 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
946 | 945 | } |
947 | 946 | |
948 | 947 | // Return valid user. |
@@ -961,16 +960,16 @@ discard block |
||
961 | 960 | $card_data = give_get_donation_cc_info(); |
962 | 961 | |
963 | 962 | // Validate the card zip. |
964 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
965 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
966 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
963 | + if ( ! empty($card_data['card_zip'])) { |
|
964 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
965 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
967 | 966 | } |
968 | 967 | } |
969 | 968 | |
970 | 969 | // Ensure no spaces. |
971 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
972 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
973 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
970 | + if ( ! empty($card_data['card_number'])) { |
|
971 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
972 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
974 | 973 | } |
975 | 974 | |
976 | 975 | // This should validate card numbers at some point too. |
@@ -987,17 +986,17 @@ discard block |
||
987 | 986 | function give_get_donation_cc_info() { |
988 | 987 | |
989 | 988 | $cc_info = array(); |
990 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
991 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
992 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
993 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
994 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
995 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
996 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
997 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
998 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
999 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
1000 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
989 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
990 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
991 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
992 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
993 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
994 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
995 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
996 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
997 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
998 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
999 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
1001 | 1000 | |
1002 | 1001 | // Return cc info. |
1003 | 1002 | return $cc_info; |
@@ -1013,14 +1012,14 @@ discard block |
||
1013 | 1012 | * |
1014 | 1013 | * @return bool|mixed |
1015 | 1014 | */ |
1016 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
1015 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
1017 | 1016 | $ret = false; |
1018 | 1017 | |
1019 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
1018 | + if (empty($zip) || empty($country_code)) { |
|
1020 | 1019 | return $ret; |
1021 | 1020 | } |
1022 | 1021 | |
1023 | - $country_code = strtoupper( $country_code ); |
|
1022 | + $country_code = strtoupper($country_code); |
|
1024 | 1023 | |
1025 | 1024 | $zip_regex = array( |
1026 | 1025 | 'AD' => 'AD\d{3}', |
@@ -1180,11 +1179,11 @@ discard block |
||
1180 | 1179 | 'ZM' => '\d{5}', |
1181 | 1180 | ); |
1182 | 1181 | |
1183 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1182 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1184 | 1183 | $ret = true; |
1185 | 1184 | } |
1186 | 1185 | |
1187 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1186 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1188 | 1187 | } |
1189 | 1188 | |
1190 | 1189 | |
@@ -1198,33 +1197,33 @@ discard block |
||
1198 | 1197 | * |
1199 | 1198 | * @return bool |
1200 | 1199 | */ |
1201 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1200 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1202 | 1201 | /* @var Give_Donate_Form $form */ |
1203 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1202 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1204 | 1203 | |
1205 | 1204 | $donation_level_matched = false; |
1206 | 1205 | |
1207 | - if ( $form->is_multi_type_donation_form() ) { |
|
1206 | + if ($form->is_multi_type_donation_form()) { |
|
1208 | 1207 | |
1209 | 1208 | // Bailout. |
1210 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1209 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1211 | 1210 | return false; |
1212 | 1211 | } |
1213 | 1212 | |
1214 | 1213 | // Sanitize donation amount. |
1215 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1214 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1216 | 1215 | |
1217 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1216 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1218 | 1217 | return true; |
1219 | 1218 | } |
1220 | 1219 | |
1221 | 1220 | // Find correct donation level from all donation levels. |
1222 | - foreach ( $variable_prices as $variable_price ) { |
|
1221 | + foreach ($variable_prices as $variable_price) { |
|
1223 | 1222 | // Sanitize level amount. |
1224 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1223 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1225 | 1224 | |
1226 | 1225 | // Set first match donation level ID. |
1227 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1226 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1228 | 1227 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1229 | 1228 | $donation_level_matched = true; |
1230 | 1229 | break; |
@@ -1235,19 +1234,19 @@ discard block |
||
1235 | 1234 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1236 | 1235 | if ( |
1237 | 1236 | ! $donation_level_matched |
1238 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1237 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1239 | 1238 | ) { |
1240 | 1239 | // Sanitize custom minimum amount. |
1241 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
1240 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
1242 | 1241 | |
1243 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1242 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1244 | 1243 | $_POST['give-price-id'] = 'custom'; |
1245 | 1244 | $donation_level_matched = true; |
1246 | 1245 | } |
1247 | 1246 | } |
1248 | 1247 | }// End if(). |
1249 | 1248 | |
1250 | - return ( $donation_level_matched ? true : false ); |
|
1249 | + return ($donation_level_matched ? true : false); |
|
1251 | 1250 | } |
1252 | 1251 | |
1253 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1252 | +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 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @global $wpdb |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_install( $network_wide = false ) { |
|
29 | +function give_install($network_wide = false) { |
|
30 | 30 | |
31 | 31 | global $wpdb; |
32 | 32 | |
33 | - if ( is_multisite() && $network_wide ) { |
|
33 | + if (is_multisite() && $network_wide) { |
|
34 | 34 | |
35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
36 | 36 | |
37 | - switch_to_blog( $blog_id ); |
|
37 | + switch_to_blog($blog_id); |
|
38 | 38 | give_run_install(); |
39 | 39 | restore_current_blog(); |
40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | give_setup_post_types(); |
62 | 62 | |
63 | 63 | // Add Upgraded From Option. |
64 | - $current_version = get_option( 'give_version' ); |
|
65 | - if ( $current_version ) { |
|
66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
64 | + $current_version = get_option('give_version'); |
|
65 | + if ($current_version) { |
|
66 | + update_option('give_version_upgraded_from', $current_version); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Setup some default options. |
70 | 70 | $options = array(); |
71 | 71 | |
72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
73 | - if ( empty( $current_version ) ) { |
|
74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
73 | + if (empty($current_version)) { |
|
74 | + $options = array_merge($options, give_get_default_settings()); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Populate the default values. |
78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Run plugin upgrades. |
82 | 82 | * |
83 | 83 | * @since 1.8 |
84 | 84 | */ |
85 | - do_action( 'give_upgrades' ); |
|
85 | + do_action('give_upgrades'); |
|
86 | 86 | |
87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
88 | - update_option( 'give_version', GIVE_VERSION ); |
|
87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
88 | + update_option('give_version', GIVE_VERSION); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // Set api version, end point and refresh permalink. |
97 | 97 | $api = new Give_API(); |
98 | 98 | $api->add_endpoint(); |
99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
100 | 100 | |
101 | 101 | flush_rewrite_rules(); |
102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $give_sessions->use_php_sessions(); |
106 | 106 | |
107 | 107 | // Add a temporary option to note that Give pages have been created. |
108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
109 | 109 | |
110 | - if ( ! $current_version ) { |
|
110 | + if ( ! $current_version) { |
|
111 | 111 | |
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
113 | 113 | |
114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | 'v1813_update_donor_user_roles' |
126 | 126 | ); |
127 | 127 | |
128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
129 | - give_set_upgrade_complete( $upgrade ); |
|
128 | + foreach ($upgrade_routines as $upgrade) { |
|
129 | + give_set_upgrade_complete($upgrade); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | // Bail if activating from network, or bulk. |
134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
135 | 135 | return; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Add the transient to redirect. |
139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @param int $site_id The Site ID. |
154 | 154 | * @param array $meta Blog Meta. |
155 | 155 | */ |
156 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
156 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
157 | 157 | |
158 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
158 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
159 | 159 | |
160 | - switch_to_blog( $blog_id ); |
|
160 | + switch_to_blog($blog_id); |
|
161 | 161 | give_install(); |
162 | 162 | restore_current_blog(); |
163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
168 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return array The tables to drop. |
180 | 180 | */ |
181 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
181 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
182 | 182 | |
183 | - switch_to_blog( $blog_id ); |
|
183 | + switch_to_blog($blog_id); |
|
184 | 184 | $donors_db = new Give_DB_Donors(); |
185 | 185 | $donor_meta_db = new Give_DB_Donor_Meta(); |
186 | 186 | |
187 | - if ( $donors_db->installed() ) { |
|
187 | + if ($donors_db->installed()) { |
|
188 | 188 | $tables[] = $donors_db->table_name; |
189 | 189 | $tables[] = $donor_meta_db->table_name; |
190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
197 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Post-installation |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function give_after_install() { |
208 | 208 | |
209 | - if ( ! is_admin() ) { |
|
209 | + if ( ! is_admin()) { |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
213 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
214 | - $give_table_check = get_option( '_give_table_check', false ); |
|
213 | + $give_options = Give_Cache::get('_give_installed', true); |
|
214 | + $give_table_check = get_option('_give_table_check', false); |
|
215 | 215 | |
216 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
216 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
217 | 217 | |
218 | - if ( ! @Give()->donor_meta->installed() ) { |
|
218 | + if ( ! @Give()->donor_meta->installed()) { |
|
219 | 219 | |
220 | 220 | // Create the donor meta database. |
221 | 221 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! @Give()->donors->installed() ) { |
|
226 | + if ( ! @Give()->donors->installed()) { |
|
227 | 227 | // Create the donor database. |
228 | 228 | // (this ensures it creates it on multisite instances where it is network activated). |
229 | 229 | @Give()->donors->create_table(); |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param array $give_options Give plugin options. |
237 | 237 | */ |
238 | - do_action( 'give_after_install', $give_options ); |
|
238 | + do_action('give_after_install', $give_options); |
|
239 | 239 | } |
240 | 240 | |
241 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
241 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Delete the transient |
246 | - if ( false !== $give_options ) { |
|
247 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
246 | + if (false !== $give_options) { |
|
247 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
251 | 251 | } |
252 | 252 | |
253 | -add_action( 'admin_init', 'give_after_install' ); |
|
253 | +add_action('admin_init', 'give_after_install'); |
|
254 | 254 | |
255 | 255 | |
256 | 256 | /** |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | global $wp_roles; |
267 | 267 | |
268 | - if ( ! is_object( $wp_roles ) ) { |
|
268 | + if ( ! is_object($wp_roles)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
272 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
273 | 273 | |
274 | 274 | // Create Give plugin roles |
275 | 275 | $roles = new Give_Roles(); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
283 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Default core setting values. |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | 'uninstall_on_delete' => 'disabled', |
319 | 319 | 'the_content_filter' => 'enabled', |
320 | 320 | 'scripts_footer' => 'disabled', |
321 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
321 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
322 | 322 | 'agreement_text' => give_get_default_agreement_text(), |
323 | 323 | |
324 | 324 | // Paypal IPN verification. |
325 | 325 | 'paypal_verification' => 'enabled', |
326 | 326 | |
327 | 327 | // Default is manual gateway. |
328 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
328 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
329 | 329 | 'default_gateway' => 'manual', |
330 | 330 | |
331 | 331 | // Offline gateway setup. |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function give_get_default_agreement_text() { |
355 | 355 | |
356 | - $org_name = get_bloginfo( 'name' ); |
|
356 | + $org_name = get_bloginfo('name'); |
|
357 | 357 | |
358 | 358 | $agreement = sprintf( |
359 | 359 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $org_name |
368 | 368 | ); |
369 | 369 | |
370 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
370 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -376,22 +376,22 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @since 1.8.11 |
378 | 378 | */ |
379 | -function give_create_pages(){ |
|
379 | +function give_create_pages() { |
|
380 | 380 | |
381 | 381 | // Bailout if pages already created. |
382 | - if( get_option( 'give_install_pages_created') ) { |
|
382 | + if (get_option('give_install_pages_created')) { |
|
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $options = array(); |
387 | 387 | |
388 | 388 | // Checks if the Success Page option exists AND that the page exists. |
389 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
389 | + if ( ! get_post(give_get_option('success_page'))) { |
|
390 | 390 | |
391 | 391 | // Donation Confirmation (Success) Page |
392 | 392 | $success = wp_insert_post( |
393 | 393 | array( |
394 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
394 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
395 | 395 | 'post_content' => '[give_receipt]', |
396 | 396 | 'post_status' => 'publish', |
397 | 397 | 'post_author' => 1, |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | // Checks if the Failure Page option exists AND that the page exists. |
408 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
408 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
409 | 409 | |
410 | 410 | // Failed Donation Page |
411 | 411 | $failed = wp_insert_post( |
412 | 412 | array( |
413 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
414 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
413 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
414 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
415 | 415 | 'post_status' => 'publish', |
416 | 416 | 'post_author' => 1, |
417 | 417 | 'post_type' => 'page', |
@@ -423,11 +423,11 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Checks if the History Page option exists AND that the page exists. |
426 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
426 | + if ( ! get_post(give_get_option('history_page'))) { |
|
427 | 427 | // Donation History Page |
428 | 428 | $history = wp_insert_post( |
429 | 429 | array( |
430 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
430 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
431 | 431 | 'post_content' => '[donation_history]', |
432 | 432 | 'post_status' => 'publish', |
433 | 433 | 'post_author' => 1, |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $options['history_page'] = $history; |
440 | 440 | } |
441 | 441 | |
442 | - if( ! empty( $options ) ) { |
|
443 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
442 | + if ( ! empty($options)) { |
|
443 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
444 | 444 | } |
445 | 445 | |
446 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
446 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
447 | 447 | } |
448 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
448 | +add_action('admin_init', 'give_create_pages', -1); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,52 +25,52 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return void |
27 | 27 | */ |
28 | -function give_update_payment_details( $data ) { |
|
28 | +function give_update_payment_details($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
31 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
31 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
34 | + check_admin_referer('give_update_payment_details_nonce'); |
|
35 | 35 | |
36 | 36 | // Retrieve the payment ID. |
37 | - $payment_id = absint( $data['give_payment_id'] ); |
|
37 | + $payment_id = absint($data['give_payment_id']); |
|
38 | 38 | |
39 | 39 | /* @var Give_Payment $payment */ |
40 | - $payment = new Give_Payment( $payment_id ); |
|
40 | + $payment = new Give_Payment($payment_id); |
|
41 | 41 | |
42 | 42 | // Retrieve existing payment meta. |
43 | 43 | $meta = $payment->get_meta(); |
44 | 44 | $user_info = $payment->user_info; |
45 | 45 | |
46 | 46 | $status = $data['give-payment-status']; |
47 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
48 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
47 | + $date = sanitize_text_field($data['give-payment-date']); |
|
48 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
49 | 49 | |
50 | 50 | // Restrict to our high and low. |
51 | - if ( $hour > 23 ) { |
|
51 | + if ($hour > 23) { |
|
52 | 52 | $hour = 23; |
53 | - } elseif ( $hour < 0 ) { |
|
53 | + } elseif ($hour < 0) { |
|
54 | 54 | $hour = 00; |
55 | 55 | } |
56 | 56 | |
57 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
57 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
58 | 58 | |
59 | 59 | // Restrict to our high and low. |
60 | - if ( $minute > 59 ) { |
|
60 | + if ($minute > 59) { |
|
61 | 61 | $minute = 59; |
62 | - } elseif ( $minute < 0 ) { |
|
62 | + } elseif ($minute < 0) { |
|
63 | 63 | $minute = 00; |
64 | 64 | } |
65 | 65 | |
66 | - $address = give_clean( $data['give-payment-address'][0] ); |
|
66 | + $address = give_clean($data['give-payment-address'][0]); |
|
67 | 67 | |
68 | 68 | $curr_total = $payment->total; |
69 | - $new_total = give_maybe_sanitize_amount( $data['give-payment-total'] ); |
|
70 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $new_total = give_maybe_sanitize_amount($data['give-payment-total']); |
|
70 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
71 | 71 | |
72 | - $curr_donor_id = sanitize_text_field( $data['give-current-donor'] ); |
|
73 | - $new_donor_id = sanitize_text_field( $data['donor-id'] ); |
|
72 | + $curr_donor_id = sanitize_text_field($data['give-current-donor']); |
|
73 | + $new_donor_id = sanitize_text_field($data['donor-id']); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Fires before updating edited donation. |
@@ -80,98 +80,98 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_donation', $payment_id ); |
|
83 | + do_action('give_update_edited_donation', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Donation.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Donation.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $donor_changed = false; |
93 | 93 | |
94 | - if ( isset( $data['give-new-donor'] ) && $data['give-new-donor'] == '1' ) { |
|
94 | + if (isset($data['give-new-donor']) && $data['give-new-donor'] == '1') { |
|
95 | 95 | |
96 | - $email = isset( $data['give-new-donor-email'] ) ? sanitize_text_field( $data['give-new-donor-email'] ) : ''; |
|
97 | - $names = isset( $data['give-new-donor-name'] ) ? sanitize_text_field( $data['give-new-donor-name'] ) : ''; |
|
96 | + $email = isset($data['give-new-donor-email']) ? sanitize_text_field($data['give-new-donor-email']) : ''; |
|
97 | + $names = isset($data['give-new-donor-name']) ? sanitize_text_field($data['give-new-donor-name']) : ''; |
|
98 | 98 | |
99 | - if ( empty( $email ) || empty( $names ) ) { |
|
100 | - wp_die( esc_html__( 'New donors require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
99 | + if (empty($email) || empty($names)) { |
|
100 | + wp_die(esc_html__('New donors require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
101 | 101 | } |
102 | 102 | |
103 | - $donor = new Give_Donor( $email ); |
|
104 | - if ( empty( $donor->id ) ) { |
|
105 | - $donor_data = array( 'name' => $names, 'email' => $email ); |
|
106 | - $user_id = email_exists( $email ); |
|
107 | - if ( false !== $user_id ) { |
|
103 | + $donor = new Give_Donor($email); |
|
104 | + if (empty($donor->id)) { |
|
105 | + $donor_data = array('name' => $names, 'email' => $email); |
|
106 | + $user_id = email_exists($email); |
|
107 | + if (false !== $user_id) { |
|
108 | 108 | $donor_data['user_id'] = $user_id; |
109 | 109 | } |
110 | 110 | |
111 | - if ( ! $donor->create( $donor_data ) ) { |
|
111 | + if ( ! $donor->create($donor_data)) { |
|
112 | 112 | // Failed to crete the new donor, assume the previous donor. |
113 | 113 | $donor_changed = false; |
114 | - $donor = new Give_Donor( $curr_donor_id ); |
|
115 | - give_set_error( 'give-payment-new-donor-fail', __( 'Error creating new donor.', 'give' ) ); |
|
114 | + $donor = new Give_Donor($curr_donor_id); |
|
115 | + give_set_error('give-payment-new-donor-fail', __('Error creating new donor.', 'give')); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | $new_donor_id = $donor->id; |
120 | 120 | |
121 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
121 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
122 | 122 | |
123 | 123 | $donor_changed = true; |
124 | 124 | |
125 | - } elseif ( $curr_donor_id !== $new_donor_id ) { |
|
125 | + } elseif ($curr_donor_id !== $new_donor_id) { |
|
126 | 126 | |
127 | - $donor = new Give_Donor( $new_donor_id ); |
|
127 | + $donor = new Give_Donor($new_donor_id); |
|
128 | 128 | $email = $donor->email; |
129 | 129 | $names = $donor->name; |
130 | 130 | |
131 | - $previous_donor = new Give_Donor( $curr_donor_id ); |
|
131 | + $previous_donor = new Give_Donor($curr_donor_id); |
|
132 | 132 | |
133 | 133 | $donor_changed = true; |
134 | 134 | |
135 | 135 | } else { |
136 | 136 | |
137 | - $donor = new Give_Donor( $curr_donor_id ); |
|
137 | + $donor = new Give_Donor($curr_donor_id); |
|
138 | 138 | $email = $donor->email; |
139 | 139 | $names = $donor->name; |
140 | 140 | |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Setup first and last name from input values. |
144 | - $names = explode( ' ', $names ); |
|
145 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
144 | + $names = explode(' ', $names); |
|
145 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
146 | 146 | $last_name = ''; |
147 | - if ( ! empty( $names[1] ) ) { |
|
148 | - unset( $names[0] ); |
|
149 | - $last_name = implode( ' ', $names ); |
|
147 | + if ( ! empty($names[1])) { |
|
148 | + unset($names[0]); |
|
149 | + $last_name = implode(' ', $names); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( $donor_changed ) { |
|
152 | + if ($donor_changed) { |
|
153 | 153 | |
154 | 154 | // Remove the stats and payment from the previous donor and attach it to the new donor. |
155 | - $previous_donor->remove_payment( $payment_id, false ); |
|
156 | - $donor->attach_payment( $payment_id, false ); |
|
155 | + $previous_donor->remove_payment($payment_id, false); |
|
156 | + $donor->attach_payment($payment_id, false); |
|
157 | 157 | |
158 | - if ( 'publish' == $status ) { |
|
158 | + if ('publish' == $status) { |
|
159 | 159 | |
160 | 160 | // Reduce previous user donation count and amount. |
161 | 161 | $previous_donor->decrease_donation_count(); |
162 | - $previous_donor->decrease_value( $curr_total ); |
|
162 | + $previous_donor->decrease_value($curr_total); |
|
163 | 163 | |
164 | 164 | // If donation was completed adjust stats of new donors. |
165 | 165 | $donor->increase_purchase_count(); |
166 | - $donor->increase_value( $new_total ); |
|
166 | + $donor->increase_value($new_total); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $payment->customer_id = $donor->id; |
170 | 170 | } else { |
171 | 171 | |
172 | - if ( 'publish' === $status ) { |
|
172 | + if ('publish' === $status) { |
|
173 | 173 | // Update user donation stat. |
174 | - $donor->update_donation_value( $curr_total, $new_total ); |
|
174 | + $donor->update_donation_value($curr_total, $new_total); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | $payment->total = $new_total; |
185 | 185 | |
186 | 186 | // Check for payment notes. |
187 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
187 | + if ( ! empty($data['give-payment-note'])) { |
|
188 | 188 | |
189 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
190 | - give_insert_payment_note( $payment_id, $note ); |
|
189 | + $note = wp_kses($data['give-payment-note'], array()); |
|
190 | + give_insert_payment_note($payment_id, $note); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | $payment->status = $status; |
196 | 196 | |
197 | 197 | // Adjust total store earnings if the payment total has been changed. |
198 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
198 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
199 | 199 | |
200 | - if ( $new_total > $curr_total ) { |
|
200 | + if ($new_total > $curr_total) { |
|
201 | 201 | // Increase if our new total is higher. |
202 | 202 | $difference = $new_total - $curr_total; |
203 | - give_increase_total_earnings( $difference ); |
|
203 | + give_increase_total_earnings($difference); |
|
204 | 204 | |
205 | - } elseif ( $curr_total > $new_total ) { |
|
205 | + } elseif ($curr_total > $new_total) { |
|
206 | 206 | // Decrease if our new total is lower. |
207 | 207 | $difference = $curr_total - $new_total; |
208 | - give_decrease_total_earnings( $difference ); |
|
208 | + give_decrease_total_earnings($difference); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | } |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | $payment->save(); |
214 | 214 | |
215 | 215 | // Get new give form ID. |
216 | - $new_form_id = absint( $data['give-payment-form-select'] ); |
|
217 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
216 | + $new_form_id = absint($data['give-payment-form-select']); |
|
217 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
218 | 218 | |
219 | 219 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
220 | 220 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
221 | 221 | // Check if user want to transfer current payment to new give form id. |
222 | - if ( $new_form_id != $current_form_id ) { |
|
222 | + if ($new_form_id != $current_form_id) { |
|
223 | 223 | |
224 | 224 | // Get new give form title. |
225 | - $new_form_title = get_the_title( $new_form_id ); |
|
225 | + $new_form_title = get_the_title($new_form_id); |
|
226 | 226 | |
227 | 227 | // Update new give form data in payment data. |
228 | 228 | $payment_meta = $payment->get_meta(); |
@@ -230,43 +230,43 @@ discard block |
||
230 | 230 | $payment_meta['form_id'] = $new_form_id; |
231 | 231 | |
232 | 232 | // Update price id post meta data for set donation form. |
233 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
233 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
234 | 234 | $payment_meta['price_id'] = ''; |
235 | 235 | } |
236 | 236 | |
237 | 237 | // Update payment give form meta data. |
238 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
239 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
240 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
238 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
239 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
240 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
241 | 241 | |
242 | 242 | // Update price id payment metadata. |
243 | - if ( ! give_has_variable_prices( $new_form_id ) ) { |
|
244 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
243 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
244 | + $payment->update_meta('_give_payment_price_id', ''); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // If donation was completed, adjust stats of forms. |
248 | - if ( 'publish' == $status ) { |
|
248 | + if ('publish' == $status) { |
|
249 | 249 | |
250 | 250 | // Decrease sale of old give form. For other payment status. |
251 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
251 | + $current_form = new Give_Donate_Form($current_form_id); |
|
252 | 252 | $current_form->decrease_sales(); |
253 | - $current_form->decrease_earnings( $curr_total ); |
|
253 | + $current_form->decrease_earnings($curr_total); |
|
254 | 254 | |
255 | 255 | // Increase sale of new give form. |
256 | - $new_form = new Give_Donate_Form( $new_form_id ); |
|
256 | + $new_form = new Give_Donate_Form($new_form_id); |
|
257 | 257 | $new_form->increase_sales(); |
258 | - $new_form->increase_earnings( $new_total ); |
|
258 | + $new_form->increase_earnings($new_total); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Re setup payment to update new meta value in object. |
262 | - $payment->update_payment_setup( $payment->ID ); |
|
262 | + $payment->update_payment_setup($payment->ID); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | // Update price id if current form is variable form. |
266 | 266 | /* @var Give_Donate_Form $form */ |
267 | - $form = new Give_Donate_Form( $payment->form_id ); |
|
267 | + $form = new Give_Donate_Form($payment->form_id); |
|
268 | 268 | |
269 | - if ( isset( $data['give-variable-price'] ) && $form->has_variable_prices() ) { |
|
269 | + if (isset($data['give-variable-price']) && $form->has_variable_prices()) { |
|
270 | 270 | |
271 | 271 | // Get payment meta data. |
272 | 272 | $payment_meta = $payment->get_meta(); |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | $price_id = ''; |
276 | 276 | |
277 | 277 | // Get price info |
278 | - if( 0 <= $data['give-variable-price'] ) { |
|
279 | - foreach ( $form->prices as $variable_price ) { |
|
280 | - if( $new_total === give_maybe_sanitize_amount( $variable_price['_give_amount'] ) ) { |
|
278 | + if (0 <= $data['give-variable-price']) { |
|
279 | + foreach ($form->prices as $variable_price) { |
|
280 | + if ($new_total === give_maybe_sanitize_amount($variable_price['_give_amount'])) { |
|
281 | 281 | $price_info = $variable_price; |
282 | 282 | break; |
283 | 283 | } |
@@ -285,15 +285,15 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | // Set price id. |
288 | - if( ! empty( $price_info ) ) { |
|
288 | + if ( ! empty($price_info)) { |
|
289 | 289 | $price_id = $data['give-variable-price']; |
290 | 290 | |
291 | - if( $data['give-variable-price'] !== $price_info['_give_id']['level_id'] ) { |
|
291 | + if ($data['give-variable-price'] !== $price_info['_give_id']['level_id']) { |
|
292 | 292 | // Set price id to amount match. |
293 | 293 | $price_id = $price_info['_give_id']['level_id']; |
294 | 294 | } |
295 | 295 | |
296 | - } elseif( $form->is_custom_price_mode() ){ |
|
296 | + } elseif ($form->is_custom_price_mode()) { |
|
297 | 297 | $price_id = 'custom'; |
298 | 298 | } |
299 | 299 | |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | $payment_meta['price_id'] = $price_id; |
302 | 302 | |
303 | 303 | // Update payment give form meta data. |
304 | - $payment->update_meta( '_give_payment_price_id', $price_id ); |
|
305 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
304 | + $payment->update_meta('_give_payment_price_id', $price_id); |
|
305 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
306 | 306 | |
307 | 307 | // Re setup payment to update new meta value in object. |
308 | - $payment->update_payment_setup( $payment->ID ); |
|
308 | + $payment->update_payment_setup($payment->ID); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @param int $payment_id The ID of the payment. |
318 | 318 | */ |
319 | - do_action( 'give_updated_edited_donation', $payment_id ); |
|
319 | + do_action('give_updated_edited_donation', $payment_id); |
|
320 | 320 | |
321 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
321 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=payment-updated&id='.$payment_id)); |
|
322 | 322 | exit; |
323 | 323 | } |
324 | 324 | |
325 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
325 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Trigger a Donation Deletion. |
@@ -333,48 +333,48 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @return void |
335 | 335 | */ |
336 | -function give_trigger_donation_delete( $data ) { |
|
337 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_donation_nonce' ) ) { |
|
336 | +function give_trigger_donation_delete($data) { |
|
337 | + if (wp_verify_nonce($data['_wpnonce'], 'give_donation_nonce')) { |
|
338 | 338 | |
339 | - $payment_id = absint( $data['purchase_id'] ); |
|
339 | + $payment_id = absint($data['purchase_id']); |
|
340 | 340 | |
341 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
342 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
341 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
342 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
343 | 343 | } |
344 | 344 | |
345 | - give_delete_donation( $payment_id ); |
|
346 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted' ) ); |
|
345 | + give_delete_donation($payment_id); |
|
346 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&give-message=donation_deleted')); |
|
347 | 347 | give_die(); |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'give_delete_payment', 'give_trigger_donation_delete' ); |
|
351 | +add_action('give_delete_payment', 'give_trigger_donation_delete'); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * AJAX Store Donation Note |
355 | 355 | */ |
356 | 356 | function give_ajax_store_payment_note() { |
357 | 357 | |
358 | - $payment_id = absint( $_POST['payment_id'] ); |
|
359 | - $note = wp_kses( $_POST['note'], array() ); |
|
358 | + $payment_id = absint($_POST['payment_id']); |
|
359 | + $note = wp_kses($_POST['note'], array()); |
|
360 | 360 | |
361 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
362 | - wp_die( __( 'You do not have permission to edit payments.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
361 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
362 | + wp_die(__('You do not have permission to edit payments.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( empty( $payment_id ) ) { |
|
366 | - die( '-1' ); |
|
365 | + if (empty($payment_id)) { |
|
366 | + die('-1'); |
|
367 | 367 | } |
368 | 368 | |
369 | - if ( empty( $note ) ) { |
|
370 | - die( '-1' ); |
|
369 | + if (empty($note)) { |
|
370 | + die('-1'); |
|
371 | 371 | } |
372 | 372 | |
373 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
374 | - die( give_get_payment_note_html( $note_id ) ); |
|
373 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
374 | + die(give_get_payment_note_html($note_id)); |
|
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
377 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Triggers a donation note deletion without ajax |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return void |
387 | 387 | */ |
388 | -function give_trigger_payment_note_deletion( $data ) { |
|
388 | +function give_trigger_payment_note_deletion($data) { |
|
389 | 389 | |
390 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
390 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
391 | 391 | return; |
392 | 392 | } |
393 | 393 | |
394 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
395 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
394 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
395 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
396 | 396 | } |
397 | 397 | |
398 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
398 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&give-message=donation-note-deleted&id='.absint($data['payment_id'])); |
|
399 | 399 | |
400 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
400 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
401 | 401 | |
402 | - wp_redirect( $edit_order_url ); |
|
402 | + wp_redirect($edit_order_url); |
|
403 | 403 | } |
404 | 404 | |
405 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
405 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Delete a payment note deletion with ajax |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | */ |
414 | 414 | function give_ajax_delete_payment_note() { |
415 | 415 | |
416 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
417 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
416 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
417 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
418 | 418 | } |
419 | 419 | |
420 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
421 | - die( '1' ); |
|
420 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
421 | + die('1'); |
|
422 | 422 | } else { |
423 | - die( '-1' ); |
|
423 | + die('-1'); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | } |
427 | 427 | |
428 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
428 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |