@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php'; |
|
19 | -require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php'; |
|
18 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php'; |
|
19 | +require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php'; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Process batch exports via ajax |
@@ -26,79 +26,79 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_do_ajax_export() { |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | - parse_str( $_POST['form'], $form ); |
|
31 | + parse_str($_POST['form'], $form); |
|
32 | 32 | |
33 | 33 | $_REQUEST = $form = (array) $form; |
34 | 34 | |
35 | - if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) { |
|
36 | - die( '-2' ); |
|
35 | + if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) { |
|
36 | + die('-2'); |
|
37 | 37 | } |
38 | 38 | |
39 | - do_action( 'give_batch_export_class_include', $form['give-export-class'] ); |
|
39 | + do_action('give_batch_export_class_include', $form['give-export-class']); |
|
40 | 40 | |
41 | - $step = absint( $_POST['step'] ); |
|
42 | - $class = sanitize_text_field( $form['give-export-class'] ); |
|
41 | + $step = absint($_POST['step']); |
|
42 | + $class = sanitize_text_field($form['give-export-class']); |
|
43 | 43 | |
44 | - $export = new $class( $step ); |
|
44 | + $export = new $class($step); |
|
45 | 45 | |
46 | - if ( ! $export->can_export() ) { |
|
47 | - die( '-1' ); |
|
46 | + if ( ! $export->can_export()) { |
|
47 | + die('-1'); |
|
48 | 48 | } |
49 | 49 | |
50 | - if ( ! $export->is_writable ) { |
|
50 | + if ( ! $export->is_writable) { |
|
51 | 51 | $json_args = array( |
52 | 52 | 'error' => true, |
53 | - 'message' => __( 'Export location or file not writable', 'give' ) |
|
53 | + 'message' => __('Export location or file not writable', 'give') |
|
54 | 54 | ); |
55 | 55 | echo json_encode($json_args); |
56 | 56 | exit; |
57 | 57 | } |
58 | 58 | |
59 | - $export->set_properties( $_REQUEST ); |
|
59 | + $export->set_properties($_REQUEST); |
|
60 | 60 | |
61 | 61 | $export->pre_fetch(); |
62 | 62 | |
63 | - $ret = $export->process_step( $step ); |
|
63 | + $ret = $export->process_step($step); |
|
64 | 64 | |
65 | 65 | $percentage = $export->get_percentage_complete(); |
66 | 66 | |
67 | - if ( $ret ) { |
|
67 | + if ($ret) { |
|
68 | 68 | |
69 | 69 | $step += 1; |
70 | - echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) ); |
|
70 | + echo json_encode(array('step' => $step, 'percentage' => $percentage)); |
|
71 | 71 | exit; |
72 | 72 | |
73 | - } elseif ( true === $export->is_empty ) { |
|
73 | + } elseif (true === $export->is_empty) { |
|
74 | 74 | |
75 | - echo json_encode( array( |
|
75 | + echo json_encode(array( |
|
76 | 76 | 'error' => true, |
77 | - 'message' => __( 'No data found for export parameters', 'give' ) |
|
78 | - ) ); |
|
77 | + 'message' => __('No data found for export parameters', 'give') |
|
78 | + )); |
|
79 | 79 | exit; |
80 | 80 | |
81 | - } elseif ( true === $export->done && true === $export->is_void ) { |
|
81 | + } elseif (true === $export->done && true === $export->is_void) { |
|
82 | 82 | |
83 | - $message = ! empty( $export->message ) ? $export->message : __( 'Batch Processing Complete', 'give' ); |
|
84 | - echo json_encode( array( 'success' => true, 'message' => $message ) ); |
|
83 | + $message = ! empty($export->message) ? $export->message : __('Batch Processing Complete', 'give'); |
|
84 | + echo json_encode(array('success' => true, 'message' => $message)); |
|
85 | 85 | exit; |
86 | 86 | |
87 | 87 | } else { |
88 | 88 | |
89 | - $args = array_merge( $_REQUEST, array( |
|
89 | + $args = array_merge($_REQUEST, array( |
|
90 | 90 | 'step' => $step, |
91 | 91 | 'class' => $class, |
92 | - 'nonce' => wp_create_nonce( 'give-batch-export' ), |
|
92 | + 'nonce' => wp_create_nonce('give-batch-export'), |
|
93 | 93 | 'give_action' => 'form_batch_export', |
94 | - ) ); |
|
94 | + )); |
|
95 | 95 | |
96 | - $download_url = add_query_arg( $args, admin_url() ); |
|
96 | + $download_url = add_query_arg($args, admin_url()); |
|
97 | 97 | |
98 | - echo json_encode( array( 'step' => 'done', 'url' => $download_url ) ); |
|
98 | + echo json_encode(array('step' => 'done', 'url' => $download_url)); |
|
99 | 99 | exit; |
100 | 100 | |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' ); |
|
104 | +add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'id' => __( 'ID', 'give' ), |
|
45 | - 'name' => __( 'Name', 'give' ), |
|
46 | - 'email' => __( 'Email', 'give' ), |
|
47 | - 'purchases' => __( 'Number of Donations', 'give' ), |
|
48 | - 'amount' => __( 'Donor Value', 'give' ) |
|
44 | + 'id' => __('ID', 'give'), |
|
45 | + 'name' => __('Name', 'give'), |
|
46 | + 'email' => __('Email', 'give'), |
|
47 | + 'purchases' => __('Number of Donations', 'give'), |
|
48 | + 'amount' => __('Donor Value', 'give') |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | return $cols; |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | |
65 | 65 | $data = array(); |
66 | 66 | |
67 | - if ( ! empty( $this->form ) ) { |
|
67 | + if ( ! empty($this->form)) { |
|
68 | 68 | |
69 | 69 | // Export customers of a specific product |
70 | 70 | global $give_logs; |
71 | 71 | |
72 | 72 | $args = array( |
73 | - 'post_parent' => absint( $this->form ), |
|
73 | + 'post_parent' => absint($this->form), |
|
74 | 74 | 'log_type' => 'sale', |
75 | 75 | 'posts_per_page' => 30, |
76 | 76 | 'paged' => $this->step |
77 | 77 | ); |
78 | 78 | |
79 | - if ( null !== $this->price_id ) { |
|
79 | + if (null !== $this->price_id) { |
|
80 | 80 | $args['meta_query'] = array( |
81 | 81 | array( |
82 | 82 | 'key' => '_give_log_price_id', |
@@ -85,21 +85,21 @@ discard block |
||
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - $logs = $give_logs->get_connected_logs( $args ); |
|
88 | + $logs = $give_logs->get_connected_logs($args); |
|
89 | 89 | |
90 | - if ( $logs ) { |
|
91 | - foreach ( $logs as $log ) { |
|
90 | + if ($logs) { |
|
91 | + foreach ($logs as $log) { |
|
92 | 92 | |
93 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
94 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
95 | - $customer = new Give_Customer( $customer_id ); |
|
93 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
94 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
95 | + $customer = new Give_Customer($customer_id); |
|
96 | 96 | |
97 | 97 | $data[] = array( |
98 | 98 | 'id' => $customer->id, |
99 | 99 | 'name' => $customer->name, |
100 | 100 | 'email' => $customer->email, |
101 | 101 | 'purchases' => $customer->purchase_count, |
102 | - 'amount' => give_format_amount( $customer->purchase_value ), |
|
102 | + 'amount' => give_format_amount($customer->purchase_value), |
|
103 | 103 | ); |
104 | 104 | } |
105 | 105 | } |
@@ -107,25 +107,25 @@ discard block |
||
107 | 107 | } else { |
108 | 108 | |
109 | 109 | // Export all customers |
110 | - $offset = 30 * ( $this->step - 1 ); |
|
111 | - $customers = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
110 | + $offset = 30 * ($this->step - 1); |
|
111 | + $customers = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
112 | 112 | |
113 | 113 | $i = 0; |
114 | 114 | |
115 | - foreach ( $customers as $customer ) { |
|
115 | + foreach ($customers as $customer) { |
|
116 | 116 | |
117 | - $data[ $i ]['id'] = $customer->id; |
|
118 | - $data[ $i ]['name'] = $customer->name; |
|
119 | - $data[ $i ]['email'] = $customer->email; |
|
120 | - $data[ $i ]['purchases'] = $customer->purchase_count; |
|
121 | - $data[ $i ]['amount'] = give_format_amount( $customer->purchase_value ); |
|
117 | + $data[$i]['id'] = $customer->id; |
|
118 | + $data[$i]['name'] = $customer->name; |
|
119 | + $data[$i]['email'] = $customer->email; |
|
120 | + $data[$i]['purchases'] = $customer->purchase_count; |
|
121 | + $data[$i]['amount'] = give_format_amount($customer->purchase_value); |
|
122 | 122 | |
123 | - $i ++; |
|
123 | + $i++; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
128 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
127 | + $data = apply_filters('give_export_get_data', $data); |
|
128 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
129 | 129 | |
130 | 130 | return $data; |
131 | 131 | } |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | $percentage = 0; |
142 | 142 | |
143 | 143 | // We can't count the number when getting them for a specific form |
144 | - if ( empty( $this->form ) ) { |
|
144 | + if (empty($this->form)) { |
|
145 | 145 | |
146 | 146 | $total = Give()->customers->count(); |
147 | 147 | |
148 | - if ( $total > 0 ) { |
|
148 | + if ($total > 0) { |
|
149 | 149 | |
150 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
150 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | - if ( $percentage > 100 ) { |
|
156 | + if ($percentage > 100) { |
|
157 | 157 | $percentage = 100; |
158 | 158 | } |
159 | 159 | |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param array $request The Form Data passed into the batch processing |
169 | 169 | */ |
170 | - public function set_properties( $request ) { |
|
171 | - $this->start = isset( $request['start'] ) ? sanitize_text_field( $request['start'] ) : ''; |
|
172 | - $this->end = isset( $request['end'] ) ? sanitize_text_field( $request['end'] ) : ''; |
|
173 | - $this->form = isset( $request['form'] ) ? absint( $request['form'] ) : null; |
|
174 | - $this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
170 | + public function set_properties($request) { |
|
171 | + $this->start = isset($request['start']) ? sanitize_text_field($request['start']) : ''; |
|
172 | + $this->end = isset($request['end']) ? sanitize_text_field($request['end']) : ''; |
|
173 | + $this->form = isset($request['form']) ? absint($request['form']) : null; |
|
174 | + $this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
175 | 175 | } |
176 | 176 | } |
@@ -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 | |
@@ -22,68 +22,68 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_tools_recount_stats_display() { |
24 | 24 | |
25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
25 | + if ( ! current_user_can('manage_give_settings')) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | - do_action( 'give_tools_recount_stats_before' ); |
|
29 | + do_action('give_tools_recount_stats_before'); |
|
30 | 30 | ?> |
31 | 31 | <div id="poststuff"> |
32 | 32 | <div class="postbox"> |
33 | 33 | |
34 | - <h2 class="hndle ui-sortable-handle"><span><?php _e( 'Recount Stats', 'give' ); ?></span></h2> |
|
34 | + <h2 class="hndle ui-sortable-handle"><span><?php _e('Recount Stats', 'give'); ?></span></h2> |
|
35 | 35 | |
36 | 36 | <div class="inside recount-stats-controls"> |
37 | - <p><?php _e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
37 | + <p><?php _e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
38 | 38 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
39 | 39 | |
40 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
40 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
41 | 41 | |
42 | 42 | <select name="give-export-class" id="recount-stats-type"> |
43 | - <option value="0" selected="selected" disabled="disabled"><?php _e( 'Please select an option', 'give' ); ?></option> |
|
44 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
45 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
46 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
47 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
48 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e( 'Delete Test Transactions', 'give' ); ?></option> |
|
49 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e( 'Delete All Data', 'give' ); ?></option> |
|
50 | - <?php do_action( 'give_recount_tool_options' ); ?> |
|
43 | + <option value="0" selected="selected" disabled="disabled"><?php _e('Please select an option', 'give'); ?></option> |
|
44 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php _e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
45 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php _e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
46 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php _e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
47 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php _e('Recalculate Donor Statistics', 'give'); ?></option> |
|
48 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php _e('Delete Test Transactions', 'give'); ?></option> |
|
49 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php _e('Delete All Data', 'give'); ?></option> |
|
50 | + <?php do_action('give_recount_tool_options'); ?> |
|
51 | 51 | </select> |
52 | 52 | |
53 | 53 | <span id="tools-form-dropdown" style="display: none"> |
54 | 54 | <?php |
55 | 55 | $args = array( |
56 | 56 | 'name' => 'form_id', |
57 | - 'number' => - 1, |
|
57 | + 'number' => -1, |
|
58 | 58 | 'chosen' => true, |
59 | 59 | ); |
60 | - echo Give()->html->forms_dropdown( $args ); |
|
60 | + echo Give()->html->forms_dropdown($args); |
|
61 | 61 | ?> |
62 | 62 | </span> |
63 | 63 | |
64 | - <input type="submit" id="recount-stats-submit" value="<?php _e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
64 | + <input type="submit" id="recount-stats-submit" value="<?php _e('Submit', 'give'); ?>" class="button-secondary"/> |
|
65 | 65 | |
66 | 66 | <br/> |
67 | 67 | |
68 | 68 | <span class="give-recount-stats-descriptions"> |
69 | - <span id="recount-stats"><?php _e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
70 | - <span id="recount-form"><?php printf( __( 'Recalculates the donation and income stats for a specific %s.', 'give' ), give_get_forms_label_singular( true ) ); ?></span> |
|
71 | - <span id="recount-all"><?php printf( __( 'Recalculates the earnings and sales stats for all %s.', 'give' ), give_get_forms_label_plural( true ) ); ?></span> |
|
72 | - <span id="recount-customer-stats"><?php _e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
73 | - <?php do_action( 'give_recount_tool_descriptions' ); ?> |
|
74 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give' ); ?></span> |
|
75 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
69 | + <span id="recount-stats"><?php _e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
70 | + <span id="recount-form"><?php printf(__('Recalculates the donation and income stats for a specific %s.', 'give'), give_get_forms_label_singular(true)); ?></span> |
|
71 | + <span id="recount-all"><?php printf(__('Recalculates the earnings and sales stats for all %s.', 'give'), give_get_forms_label_plural(true)); ?></span> |
|
72 | + <span id="recount-customer-stats"><?php _e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
73 | + <?php do_action('give_recount_tool_descriptions'); ?> |
|
74 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give'); ?></span> |
|
75 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
76 | 76 | </span> |
77 | 77 | |
78 | 78 | <span class="spinner"></span> |
79 | 79 | |
80 | 80 | </form> |
81 | - <?php do_action( 'give_tools_recount_forms' ); ?> |
|
81 | + <?php do_action('give_tools_recount_forms'); ?> |
|
82 | 82 | </div><!-- .inside --> |
83 | 83 | </div><!-- .postbox --> |
84 | 84 | </div><!-- #poststuff --> |
85 | 85 | <?php |
86 | - do_action( 'give_tools_recount_stats_after' ); |
|
86 | + do_action('give_tools_recount_stats_after'); |
|
87 | 87 | } |
88 | 88 | |
89 | -add_action( 'give_reports_tab_tools', 'give_tools_recount_stats_display' ); |
|
89 | +add_action('give_reports_tab_tools', 'give_tools_recount_stats_display'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @since 1.5 |
20 | 20 | */ |
21 | 21 | function give_register_batch_recount_store_earnings_tool() { |
22 | - add_action( 'give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1 ); |
|
22 | + add_action('give_batch_export_class_include', 'give_include_recount_income_tool_batch_processor', 10, 1); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10 ); |
|
25 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_store_earnings_tool', 10); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Loads the tools batch processing class for recounting store earnings |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | -function give_include_recount_income_tool_batch_processor( $class ) { |
|
36 | +function give_include_recount_income_tool_batch_processor($class) { |
|
37 | 37 | |
38 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
38 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-income.php'; |
|
39 | 39 | |
40 | - if ( 'Give_Tools_Recount_Income' === $class && file_exists( $file_path ) ) { |
|
40 | + if ('Give_Tools_Recount_Income' === $class && file_exists($file_path)) { |
|
41 | 41 | require_once $file_path; |
42 | 42 | } |
43 | 43 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @since 1.5 |
50 | 50 | */ |
51 | 51 | function give_register_batch_recount_form_tool() { |
52 | - add_action( 'give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1 ); |
|
52 | + add_action('give_batch_export_class_include', 'give_include_recount_form_tool_batch_processor', 10, 1); |
|
53 | 53 | } |
54 | 54 | |
55 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10 ); |
|
55 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_form_tool', 10); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Loads the tools batch processing class for recounting download stats |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | -function give_include_recount_form_tool_batch_processor( $class ) { |
|
66 | +function give_include_recount_form_tool_batch_processor($class) { |
|
67 | 67 | |
68 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
68 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-form-stats.php'; |
|
69 | 69 | |
70 | - if ( 'Give_Tools_Recount_Form_Stats' === $class && file_exists( $file_path ) ) { |
|
70 | + if ('Give_Tools_Recount_Form_Stats' === $class && file_exists($file_path)) { |
|
71 | 71 | require_once $file_path; |
72 | 72 | } |
73 | 73 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @since 1.5 |
79 | 79 | */ |
80 | 80 | function give_register_batch_recount_all_tool() { |
81 | - add_action( 'give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1 ); |
|
81 | + add_action('give_batch_export_class_include', 'give_include_recount_all_tool_batch_processor', 10, 1); |
|
82 | 82 | } |
83 | 83 | |
84 | -add_action( 'give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10 ); |
|
84 | +add_action('give_register_batch_exporter', 'give_register_batch_recount_all_tool', 10); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Loads the tools batch processing class for recounting all stats |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return void |
94 | 94 | */ |
95 | -function give_include_recount_all_tool_batch_processor( $class ) { |
|
96 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
97 | - if ( 'Give_Tools_Recount_All_Stats' === $class && file_exists( $file_path ) ) { |
|
95 | +function give_include_recount_all_tool_batch_processor($class) { |
|
96 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-all-stats.php'; |
|
97 | + if ('Give_Tools_Recount_All_Stats' === $class && file_exists($file_path)) { |
|
98 | 98 | require_once $file_path; |
99 | 99 | } |
100 | 100 | |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @since 1.5 |
107 | 107 | */ |
108 | 108 | function give_register_batch_reset_tool() { |
109 | - add_action( 'give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1 ); |
|
109 | + add_action('give_batch_export_class_include', 'give_include_reset_tool_batch_processor', 10, 1); |
|
110 | 110 | } |
111 | 111 | |
112 | -add_action( 'give_register_batch_exporter', 'give_register_batch_reset_tool', 10 ); |
|
112 | +add_action('give_register_batch_exporter', 'give_register_batch_reset_tool', 10); |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Loads the tools batch processing class for resetting store and product earnings |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return void |
122 | 122 | */ |
123 | -function give_include_reset_tool_batch_processor( $class ) { |
|
123 | +function give_include_reset_tool_batch_processor($class) { |
|
124 | 124 | |
125 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
125 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-reset-stats.php'; |
|
126 | 126 | |
127 | - if ( 'Give_Tools_Reset_Stats' === $class && file_exists( $file_path ) ) { |
|
127 | + if ('Give_Tools_Reset_Stats' === $class && file_exists($file_path)) { |
|
128 | 128 | require_once $file_path; |
129 | 129 | } |
130 | 130 | |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @since 1.5 |
136 | 136 | */ |
137 | 137 | function give_register_batch_customer_recount_tool() { |
138 | - add_action( 'give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1 ); |
|
138 | + add_action('give_batch_export_class_include', 'give_include_customer_recount_tool_batch_processor', 10, 1); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10 ); |
|
141 | +add_action('give_register_batch_exporter', 'give_register_batch_customer_recount_tool', 10); |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Loads the tools batch processing class for resetting all customer stats |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return void |
151 | 151 | */ |
152 | -function give_include_customer_recount_tool_batch_processor( $class ) { |
|
152 | +function give_include_customer_recount_tool_batch_processor($class) { |
|
153 | 153 | |
154 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
154 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-recount-customer-stats.php'; |
|
155 | 155 | |
156 | - if ( 'Give_Tools_Recount_Customer_Stats' === $class && file_exists( $file_path ) ) { |
|
156 | + if ('Give_Tools_Recount_Customer_Stats' === $class && file_exists($file_path)) { |
|
157 | 157 | require_once $file_path; |
158 | 158 | } |
159 | 159 | |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | * @since 1.5 |
165 | 165 | */ |
166 | 166 | function give_register_batch_delete_test_transactions_tool() { |
167 | - add_action( 'give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1 ); |
|
167 | + add_action('give_batch_export_class_include', 'give_include_delete_test_transactions_batch_processor', 10, 1); |
|
168 | 168 | } |
169 | 169 | |
170 | -add_action( 'give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10 ); |
|
170 | +add_action('give_register_batch_exporter', 'give_register_batch_delete_test_transactions_tool', 10); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Loads the tools batch processing class for resetting all customer stats |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return void |
180 | 180 | */ |
181 | -function give_include_delete_test_transactions_batch_processor( $class ) { |
|
181 | +function give_include_delete_test_transactions_batch_processor($class) { |
|
182 | 182 | |
183 | - $file_path = GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
183 | + $file_path = GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/class-give-tools-delete-test-transactions.php'; |
|
184 | 184 | |
185 | - if ( 'Give_Tools_Delete_Test_Transactions' === $class && file_exists( $file_path ) ) { |
|
185 | + if ('Give_Tools_Delete_Test_Transactions' === $class && file_exists($file_path)) { |
|
186 | 186 | require_once $file_path; |
187 | 187 | } |
188 | 188 |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | global $status, $page; |
51 | 51 | |
52 | 52 | // Set parent defaults |
53 | - parent::__construct( array( |
|
54 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
55 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
53 | + parent::__construct(array( |
|
54 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
55 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
56 | 56 | 'ajax' => false // Does this table support ajax? |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | |
59 | - add_action( 'give_report_view_actions', array( $this, 'category_filter' ) ); |
|
59 | + add_action('give_report_view_actions', array($this, 'category_filter')); |
|
60 | 60 | $this->query(); |
61 | 61 | |
62 | 62 | } |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return string Column Name |
74 | 74 | */ |
75 | - public function column_default( $item, $column_name ) { |
|
76 | - switch ( $column_name ) { |
|
75 | + public function column_default($item, $column_name) { |
|
76 | + switch ($column_name) { |
|
77 | 77 | case 'earnings' : |
78 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
78 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
79 | 79 | case 'average_sales' : |
80 | - return round( $item[ $column_name ] ); |
|
80 | + return round($item[$column_name]); |
|
81 | 81 | case 'average_earnings' : |
82 | - return give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
82 | + return give_currency_filter(give_format_amount($item[$column_name])); |
|
83 | 83 | case 'details' : |
84 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . __( 'View Detailed Report', 'give' ) . '</a>'; |
|
84 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.__('View Detailed Report', 'give').'</a>'; |
|
85 | 85 | default: |
86 | - return $item[ $column_name ]; |
|
86 | + return $item[$column_name]; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | public function get_columns() { |
98 | 98 | $columns = array( |
99 | 99 | 'title' => give_get_forms_label_singular(), |
100 | - 'sales' => __( 'Donations', 'give' ), |
|
101 | - 'earnings' => __( 'Income', 'give' ), |
|
102 | - 'average_sales' => __( 'Monthly Average Donations', 'give' ), |
|
103 | - 'average_earnings' => __( 'Monthly Average Income', 'give' ), |
|
104 | - 'details' => __( 'Detailed Report', 'give' ) |
|
100 | + 'sales' => __('Donations', 'give'), |
|
101 | + 'earnings' => __('Income', 'give'), |
|
102 | + 'average_sales' => __('Monthly Average Donations', 'give'), |
|
103 | + 'average_earnings' => __('Monthly Average Income', 'give'), |
|
104 | + 'details' => __('Detailed Report', 'give') |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | return $columns; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function get_sortable_columns() { |
118 | 118 | return array( |
119 | - 'title' => array( 'title', true ), |
|
120 | - 'sales' => array( 'sales', false ), |
|
121 | - 'earnings' => array( 'earnings', false ), |
|
119 | + 'title' => array('title', true), |
|
120 | + 'sales' => array('sales', false), |
|
121 | + 'earnings' => array('earnings', false), |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return int Current page number |
131 | 131 | */ |
132 | 132 | public function get_paged() { |
133 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
133 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return int Category ID |
143 | 143 | */ |
144 | 144 | public function get_category() { |
145 | - return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0; |
|
145 | + return isset($_GET['category']) ? absint($_GET['category']) : 0; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function get_total_forms() { |
157 | 157 | $total = 0; |
158 | - $counts = wp_count_posts( 'give_forms', 'readable' ); |
|
159 | - foreach ( $counts as $status => $count ) { |
|
158 | + $counts = wp_count_posts('give_forms', 'readable'); |
|
159 | + foreach ($counts as $status => $count) { |
|
160 | 160 | $total += $count; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @since 1.0 |
171 | 171 | * @return void |
172 | 172 | */ |
173 | - public function bulk_actions( $which = '' ) { |
|
173 | + public function bulk_actions($which = '') { |
|
174 | 174 | // These aren't really bulk actions but this outputs the markup in the right place |
175 | 175 | give_report_views(); |
176 | 176 | } |
@@ -183,23 +183,23 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param string $which |
185 | 185 | */ |
186 | - protected function display_tablenav( $which ) { |
|
186 | + protected function display_tablenav($which) { |
|
187 | 187 | |
188 | - if ( 'top' == $which ) { |
|
189 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
188 | + if ('top' == $which) { |
|
189 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
190 | 190 | } |
191 | 191 | ?> |
192 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
192 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
193 | 193 | |
194 | - <h3 class="alignleft reports-earnings-title"><span><?php _e( 'Donation Forms Report', 'give' ); ?></span></h3> |
|
194 | + <h3 class="alignleft reports-earnings-title"><span><?php _e('Donation Forms Report', 'give'); ?></span></h3> |
|
195 | 195 | |
196 | 196 | <div class="alignright tablenav-right"> |
197 | 197 | <div class="actions bulkactions"> |
198 | - <?php $this->bulk_actions( $which ); ?> |
|
198 | + <?php $this->bulk_actions($which); ?> |
|
199 | 199 | </div> |
200 | 200 | <?php |
201 | - $this->extra_tablenav( $which ); |
|
202 | - $this->pagination( $which ); |
|
201 | + $this->extra_tablenav($which); |
|
202 | + $this->pagination($which); |
|
203 | 203 | ?> |
204 | 204 | </div> |
205 | 205 | |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function category_filter() { |
221 | 221 | |
222 | - $categories = get_terms( 'form_category' ); |
|
223 | - if ( $categories && ! is_wp_error( $categories ) ) { |
|
224 | - echo Give()->html->category_dropdown( 'category', $this->get_category() ); |
|
222 | + $categories = get_terms('form_category'); |
|
223 | + if ($categories && ! is_wp_error($categories)) { |
|
224 | + echo Give()->html->category_dropdown('category', $this->get_category()); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function query() { |
237 | 237 | |
238 | - $orderby = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title'; |
|
239 | - $order = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC'; |
|
238 | + $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title'; |
|
239 | + $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; |
|
240 | 240 | $category = $this->get_category(); |
241 | 241 | |
242 | 242 | $args = array( |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | 'suppress_filters' => true |
250 | 250 | ); |
251 | 251 | |
252 | - if ( ! empty( $category ) ) { |
|
252 | + if ( ! empty($category)) { |
|
253 | 253 | $args['tax_query'] = array( |
254 | 254 | array( |
255 | 255 | 'taxonomy' => 'form_category', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | ); |
259 | 259 | } |
260 | 260 | |
261 | - switch ( $orderby ) : |
|
261 | + switch ($orderby) : |
|
262 | 262 | case 'title' : |
263 | 263 | $args['orderby'] = 'title'; |
264 | 264 | break; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | break; |
275 | 275 | endswitch; |
276 | 276 | |
277 | - $args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this ); |
|
277 | + $args = apply_filters('give_form_reports_prepare_items_args', $args, $this); |
|
278 | 278 | |
279 | - $this->products = new WP_Query( $args ); |
|
279 | + $this->products = new WP_Query($args); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | $give_forms = $this->products->posts; |
294 | 294 | |
295 | - if ( $give_forms ) { |
|
296 | - foreach ( $give_forms as $form ) { |
|
295 | + if ($give_forms) { |
|
296 | + foreach ($give_forms as $form) { |
|
297 | 297 | $reports_data[] = array( |
298 | 298 | 'ID' => $form, |
299 | - 'title' => get_the_title( $form ), |
|
300 | - 'sales' => give_get_form_sales_stats( $form ), |
|
301 | - 'earnings' => give_get_form_earnings_stats( $form ), |
|
302 | - 'average_sales' => give_get_average_monthly_form_sales( $form ), |
|
303 | - 'average_earnings' => give_get_average_monthly_form_earnings( $form ) |
|
299 | + 'title' => get_the_title($form), |
|
300 | + 'sales' => give_get_form_sales_stats($form), |
|
301 | + 'earnings' => give_get_form_earnings_stats($form), |
|
302 | + 'average_sales' => give_get_average_monthly_form_sales($form), |
|
303 | + 'average_earnings' => give_get_average_monthly_form_earnings($form) |
|
304 | 304 | ); |
305 | 305 | } |
306 | 306 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | $sortable = $this->get_sortable_columns(); |
330 | 330 | |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | |
333 | 333 | $data = $this->reports_data(); |
334 | 334 | |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | |
337 | 337 | $this->items = $data; |
338 | 338 | |
339 | - $this->set_pagination_args( array( |
|
339 | + $this->set_pagination_args(array( |
|
340 | 340 | 'total_items' => $total_items, |
341 | 341 | 'per_page' => $this->per_page, |
342 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
342 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
343 | 343 | ) |
344 | 344 | ); |
345 | 345 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } // Exit if accessed directly |
15 | 15 | |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | * @since 1.0 |
81 | 81 | * @return object |
82 | 82 | */ |
83 | - public function get( $row_id ) { |
|
83 | + public function get($row_id) { |
|
84 | 84 | global $wpdb; |
85 | 85 | |
86 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
86 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * @since 1.0 |
94 | 94 | * @return object |
95 | 95 | */ |
96 | - public function get_by( $column, $row_id ) { |
|
96 | + public function get_by($column, $row_id) { |
|
97 | 97 | global $wpdb; |
98 | - $column = esc_sql( $column ); |
|
99 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
98 | + $column = esc_sql($column); |
|
99 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @since 1.0 |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - public function get_column( $column, $row_id ) { |
|
109 | + public function get_column($column, $row_id) { |
|
110 | 110 | global $wpdb; |
111 | - $column = esc_sql( $column ); |
|
112 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
111 | + $column = esc_sql($column); |
|
112 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * @since 1.0 |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
122 | + public function get_column_by($column, $column_where, $column_value) { |
|
123 | 123 | global $wpdb; |
124 | - $column_where = esc_sql( $column_where ); |
|
125 | - $column = esc_sql( $column ); |
|
126 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
124 | + $column_where = esc_sql($column_where); |
|
125 | + $column = esc_sql($column); |
|
126 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -133,30 +133,30 @@ discard block |
||
133 | 133 | * @since 1.0 |
134 | 134 | * @return int |
135 | 135 | */ |
136 | - public function insert( $data, $type = '' ) { |
|
136 | + public function insert($data, $type = '') { |
|
137 | 137 | global $wpdb; |
138 | 138 | |
139 | 139 | // Set default values |
140 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
140 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
141 | 141 | |
142 | - do_action( 'give_pre_insert_' . $type, $data ); |
|
142 | + do_action('give_pre_insert_'.$type, $data); |
|
143 | 143 | |
144 | 144 | // Initialise column format array |
145 | 145 | $column_formats = $this->get_columns(); |
146 | 146 | |
147 | 147 | // Force fields to lower case |
148 | - $data = array_change_key_case( $data ); |
|
148 | + $data = array_change_key_case($data); |
|
149 | 149 | |
150 | 150 | // White list columns |
151 | - $data = array_intersect_key( $data, $column_formats ); |
|
151 | + $data = array_intersect_key($data, $column_formats); |
|
152 | 152 | |
153 | 153 | // Reorder $column_formats to match the order of columns given in $data |
154 | - $data_keys = array_keys( $data ); |
|
155 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
154 | + $data_keys = array_keys($data); |
|
155 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
156 | 156 | |
157 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
157 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
158 | 158 | |
159 | - do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data ); |
|
159 | + do_action('give_post_insert_'.$type, $wpdb->insert_id, $data); |
|
160 | 160 | |
161 | 161 | return $wpdb->insert_id; |
162 | 162 | } |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | * @since 1.0 |
169 | 169 | * @return bool |
170 | 170 | */ |
171 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
171 | + public function update($row_id, $data = array(), $where = '') { |
|
172 | 172 | |
173 | 173 | global $wpdb; |
174 | 174 | |
175 | 175 | // Row ID must be positive integer |
176 | - $row_id = absint( $row_id ); |
|
176 | + $row_id = absint($row_id); |
|
177 | 177 | |
178 | - if ( empty( $row_id ) ) { |
|
178 | + if (empty($row_id)) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - if ( empty( $where ) ) { |
|
182 | + if (empty($where)) { |
|
183 | 183 | $where = $this->primary_key; |
184 | 184 | } |
185 | 185 | |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | $column_formats = $this->get_columns(); |
188 | 188 | |
189 | 189 | // Force fields to lower case |
190 | - $data = array_change_key_case( $data ); |
|
190 | + $data = array_change_key_case($data); |
|
191 | 191 | |
192 | 192 | // White list columns |
193 | - $data = array_intersect_key( $data, $column_formats ); |
|
193 | + $data = array_intersect_key($data, $column_formats); |
|
194 | 194 | |
195 | 195 | // Reorder $column_formats to match the order of columns given in $data |
196 | - $data_keys = array_keys( $data ); |
|
197 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
196 | + $data_keys = array_keys($data); |
|
197 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
198 | 198 | |
199 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
199 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
@@ -210,18 +210,18 @@ discard block |
||
210 | 210 | * @since 1.0 |
211 | 211 | * @return bool |
212 | 212 | */ |
213 | - public function delete( $row_id = 0 ) { |
|
213 | + public function delete($row_id = 0) { |
|
214 | 214 | |
215 | 215 | global $wpdb; |
216 | 216 | |
217 | 217 | // Row ID must be positive integer |
218 | - $row_id = absint( $row_id ); |
|
218 | + $row_id = absint($row_id); |
|
219 | 219 | |
220 | - if ( empty( $row_id ) ) { |
|
220 | + if (empty($row_id)) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
224 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
224 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | * @param string $table The table name |
236 | 236 | * @return bool If the table name exists |
237 | 237 | */ |
238 | - public function table_exists( $table ) { |
|
238 | + public function table_exists($table) { |
|
239 | 239 | global $wpdb; |
240 | - $table = sanitize_text_field( $table ); |
|
240 | + $table = sanitize_text_field($table); |
|
241 | 241 | |
242 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
242 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | } |
246 | 246 | \ 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 | |
@@ -23,64 +23,64 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string $purchase_form |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = esc_url( add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = esc_url(add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | - ) ); |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts |
58 | - if ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) { |
|
58 | + if ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) { |
|
59 | 59 | return false; |
60 | 60 | } |
61 | 61 | |
62 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
62 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
63 | 63 | ? $args['display_style'] |
64 | - : get_post_meta( $form->ID, '_give_payment_display', true ); |
|
64 | + : get_post_meta($form->ID, '_give_payment_display', true); |
|
65 | 65 | |
66 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
66 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
67 | 67 | ? ' float-labels-enabled' |
68 | 68 | : ''; |
69 | 69 | |
70 | 70 | //Form Wrap Classes |
71 | - $form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array( |
|
71 | + $form_wrap_classes_array = apply_filters('give_form_wrap_classes', array( |
|
72 | 72 | 'give-form-wrap', |
73 | - 'give-display-' . $display_option |
|
74 | - ), $form->ID, $args ); |
|
75 | - $form_wrap_classes = implode( ' ', $form_wrap_classes_array ); |
|
73 | + 'give-display-'.$display_option |
|
74 | + ), $form->ID, $args); |
|
75 | + $form_wrap_classes = implode(' ', $form_wrap_classes_array); |
|
76 | 76 | |
77 | 77 | //Form Classes |
78 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
78 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
79 | 79 | 'give-form', |
80 | - 'give-form-' . $form->ID, |
|
80 | + 'give-form-'.$form->ID, |
|
81 | 81 | $float_labels_option |
82 | - ), $form->ID, $args ); |
|
83 | - $form_classes = implode( ' ', $form_classes_array ); |
|
82 | + ), $form->ID, $args); |
|
83 | + $form_classes = implode(' ', $form_classes_array); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | ob_start(); |
@@ -93,35 +93,35 @@ discard block |
||
93 | 93 | * @param int $form ->ID The current form ID |
94 | 94 | * @param array $args An array of form args |
95 | 95 | */ |
96 | - do_action( 'give_pre_form_output', $form->ID, $args ); ?> |
|
96 | + do_action('give_pre_form_output', $form->ID, $args); ?> |
|
97 | 97 | |
98 | 98 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
99 | 99 | |
100 | 100 | <?php |
101 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
101 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
102 | 102 | |
103 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
103 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
104 | 104 | |
105 | 105 | } ?> |
106 | 106 | |
107 | - <?php do_action( 'give_pre_form', $form->ID, $args ); ?> |
|
107 | + <?php do_action('give_pre_form', $form->ID, $args); ?> |
|
108 | 108 | |
109 | 109 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo $form_action; ?>" method="post"> |
110 | 110 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
111 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
112 | - <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
113 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
114 | - <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
111 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
112 | + <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
113 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
114 | + <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
115 | 115 | <?php |
116 | 116 | |
117 | 117 | //Price ID hidden field for variable (mult-level) donation forms |
118 | - if ( give_has_variable_prices( $form_id ) ) { |
|
118 | + if (give_has_variable_prices($form_id)) { |
|
119 | 119 | //get default selected price ID |
120 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
120 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
121 | 121 | $price_id = 0; |
122 | 122 | //loop through prices |
123 | - foreach ( $prices as $price ) { |
|
124 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
123 | + foreach ($prices as $price) { |
|
124 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
125 | 125 | $price_id = $price['_give_id']['level_id']; |
126 | 126 | }; |
127 | 127 | } |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | <input type="hidden" name="give-price-id" value="<?php echo $price_id; ?>"/> |
130 | 130 | <?php } |
131 | 131 | |
132 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
132 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
133 | 133 | |
134 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
134 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
135 | 135 | |
136 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
136 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
137 | 137 | |
138 | 138 | ?> |
139 | 139 | |
140 | 140 | </form> |
141 | 141 | |
142 | - <?php do_action( 'give_post_form', $form->ID, $args ); ?> |
|
142 | + <?php do_action('give_post_form', $form->ID, $args); ?> |
|
143 | 143 | |
144 | - <!--end #give-form-<?php echo absint( $form->ID ); ?>--></div> |
|
144 | + <!--end #give-form-<?php echo absint($form->ID); ?>--></div> |
|
145 | 145 | <?php |
146 | 146 | |
147 | 147 | /** |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * @param int $form ->ID The current form ID |
153 | 153 | * @param array $args An array of form args |
154 | 154 | */ |
155 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
155 | + do_action('give_post_form_output', $form->ID, $args); |
|
156 | 156 | |
157 | 157 | $final_output = ob_get_clean(); |
158 | 158 | |
159 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
159 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -176,43 +176,43 @@ discard block |
||
176 | 176 | * @global $give_options Array of all the Give options |
177 | 177 | * @return string |
178 | 178 | */ |
179 | -function give_show_purchase_form( $form_id ) { |
|
179 | +function give_show_purchase_form($form_id) { |
|
180 | 180 | |
181 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
181 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
182 | 182 | |
183 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
183 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
184 | 184 | $form_id = $_POST['give_form_id']; |
185 | 185 | } |
186 | 186 | |
187 | - do_action( 'give_purchase_form_top', $form_id ); |
|
187 | + do_action('give_purchase_form_top', $form_id); |
|
188 | 188 | |
189 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
189 | + if (give_can_checkout() && isset($form_id)) { |
|
190 | 190 | |
191 | - do_action( 'give_purchase_form_before_register_login', $form_id ); |
|
191 | + do_action('give_purchase_form_before_register_login', $form_id); |
|
192 | 192 | |
193 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
193 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
194 | 194 | |
195 | - do_action( 'give_purchase_form_before_cc_form', $form_id ); |
|
195 | + do_action('give_purchase_form_before_cc_form', $form_id); |
|
196 | 196 | |
197 | 197 | // Load the credit card form and allow gateways to load their own if they wish |
198 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
199 | - do_action( 'give_' . $payment_mode . '_cc_form', $form_id ); |
|
198 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
199 | + do_action('give_'.$payment_mode.'_cc_form', $form_id); |
|
200 | 200 | } else { |
201 | - do_action( 'give_cc_form', $form_id ); |
|
201 | + do_action('give_cc_form', $form_id); |
|
202 | 202 | } |
203 | 203 | |
204 | - do_action( 'give_purchase_form_after_cc_form', $form_id ); |
|
204 | + do_action('give_purchase_form_after_cc_form', $form_id); |
|
205 | 205 | |
206 | 206 | } else { |
207 | 207 | // Can't checkout |
208 | - do_action( 'give_purchase_form_no_access', $form_id ); |
|
208 | + do_action('give_purchase_form_no_access', $form_id); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
212 | - do_action( 'give_purchase_form_bottom', $form_id ); |
|
212 | + do_action('give_purchase_form_bottom', $form_id); |
|
213 | 213 | } |
214 | 214 | |
215 | -add_action( 'give_purchase_form', 'give_show_purchase_form' ); |
|
215 | +add_action('give_purchase_form', 'give_show_purchase_form'); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * |
@@ -224,26 +224,26 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return void |
226 | 226 | */ |
227 | -function give_show_register_login_fields( $form_id ) { |
|
227 | +function give_show_register_login_fields($form_id) { |
|
228 | 228 | |
229 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
229 | + $show_register_form = give_show_login_register_option($form_id); |
|
230 | 230 | |
231 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
231 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
232 | 232 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
233 | - <?php do_action( 'give_purchase_form_register_fields', $form_id ); ?> |
|
233 | + <?php do_action('give_purchase_form_register_fields', $form_id); ?> |
|
234 | 234 | </div> |
235 | - <?php elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
235 | + <?php elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
236 | 236 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
237 | - <?php do_action( 'give_purchase_form_login_fields', $form_id ); ?> |
|
237 | + <?php do_action('give_purchase_form_login_fields', $form_id); ?> |
|
238 | 238 | </div> |
239 | 239 | <?php endif; ?> |
240 | 240 | |
241 | - <?php if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
242 | - do_action( 'give_purchase_form_after_user_info', $form_id ); |
|
241 | + <?php if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
242 | + do_action('give_purchase_form_after_user_info', $form_id); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -add_action( 'give_purchase_form_register_login_fields', 'give_show_register_login_fields' ); |
|
246 | +add_action('give_purchase_form_register_login_fields', 'give_show_register_login_fields'); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Donation Amount Field |
@@ -257,33 +257,33 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
260 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
261 | 261 | |
262 | 262 | global $give_options; |
263 | 263 | |
264 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
265 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
266 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
267 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
268 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
269 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
270 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
264 | + $variable_pricing = give_has_variable_prices($form_id); |
|
265 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
266 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
267 | + $symbol = give_currency_symbol(give_get_currency()); |
|
268 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
269 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
270 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
271 | 271 | |
272 | - do_action( 'give_before_donation_levels', $form_id ); |
|
272 | + do_action('give_before_donation_levels', $form_id); |
|
273 | 273 | |
274 | 274 | //Set Price, No Custom Amount Allowed means hidden price field |
275 | - if ( $allow_custom_amount == 'no' ) { |
|
275 | + if ($allow_custom_amount == 'no') { |
|
276 | 276 | ?> |
277 | 277 | |
278 | - <label class="give-hidden" for="give-amount-hidden"><?php echo __( 'Donation Amount:', 'give' ); ?></label> |
|
278 | + <label class="give-hidden" for="give-amount-hidden"><?php echo __('Donation Amount:', 'give'); ?></label> |
|
279 | 279 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
280 | 280 | value="<?php echo $default_amount; ?>" required> |
281 | 281 | <div class="set-price give-donation-amount form-row-wide"> |
282 | - <?php if ( $currency_position == 'before' ) { |
|
282 | + <?php if ($currency_position == 'before') { |
|
283 | 283 | echo $currency_output; |
284 | 284 | } ?> |
285 | 285 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
286 | - <?php if ( $currency_position == 'after' ) { |
|
286 | + <?php if ($currency_position == 'after') { |
|
287 | 287 | echo $currency_output; |
288 | 288 | } ?> |
289 | 289 | </div> |
@@ -293,34 +293,34 @@ discard block |
||
293 | 293 | ?> |
294 | 294 | <div class="give-total-wrap"> |
295 | 295 | <div class="give-donation-amount form-row-wide"> |
296 | - <?php if ( $currency_position == 'before' ) { |
|
296 | + <?php if ($currency_position == 'before') { |
|
297 | 297 | echo $currency_output; |
298 | 298 | } ?> |
299 | - <label class="give-hidden" for="give-amount"><?php echo __( 'Donation Amount:', 'give' ); ?></label> |
|
299 | + <label class="give-hidden" for="give-amount"><?php echo __('Donation Amount:', 'give'); ?></label> |
|
300 | 300 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
301 | - <?php if ( $currency_position == 'after' ) { |
|
301 | + <?php if ($currency_position == 'after') { |
|
302 | 302 | echo $currency_output; |
303 | 303 | } ?> |
304 | 304 | </div> |
305 | 305 | </div> |
306 | 306 | <?php } |
307 | 307 | |
308 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
308 | + do_action('give_after_donation_amount', $form_id, $args); |
|
309 | 309 | |
310 | 310 | //Custom Amount Text |
311 | - if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?> |
|
311 | + if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?> |
|
312 | 312 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
313 | 313 | <?php } |
314 | 314 | |
315 | 315 | //Output Variable Pricing Levels |
316 | - if ( $variable_pricing ) { |
|
317 | - give_output_levels( $form_id ); |
|
316 | + if ($variable_pricing) { |
|
317 | + give_output_levels($form_id); |
|
318 | 318 | } |
319 | 319 | |
320 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
320 | + do_action('give_after_donation_levels', $form_id, $args); |
|
321 | 321 | } |
322 | 322 | |
323 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
323 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
324 | 324 | |
325 | 325 | |
326 | 326 | /** |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @return string |
334 | 334 | */ |
335 | -function give_output_levels( $form_id ) { |
|
335 | +function give_output_levels($form_id) { |
|
336 | 336 | |
337 | 337 | //Get variable pricing |
338 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
339 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
340 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
341 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
342 | - if ( empty( $custom_amount_text ) ) { |
|
343 | - $custom_amount_text = __( 'Give a Custom Amount', 'give' ); |
|
338 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
339 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
340 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
341 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
342 | + if (empty($custom_amount_text)) { |
|
343 | + $custom_amount_text = __('Give a Custom Amount', 'give'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | $output = ''; |
347 | 347 | $counter = 0; |
348 | 348 | |
349 | - switch ( $display_style ) { |
|
349 | + switch ($display_style) { |
|
350 | 350 | case 'buttons': |
351 | 351 | |
352 | 352 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
353 | 353 | |
354 | - foreach ( $prices as $price ) { |
|
355 | - $counter ++; |
|
356 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
357 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
354 | + foreach ($prices as $price) { |
|
355 | + $counter++; |
|
356 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
357 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
358 | 358 | |
359 | 359 | $output .= '<li>'; |
360 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
360 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
361 | 361 | $output .= $level_text; |
362 | 362 | $output .= '</button>'; |
363 | 363 | $output .= '</li>'; |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | //Custom Amount |
368 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
368 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
369 | 369 | $output .= '<li>'; |
370 | 370 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
371 | 371 | $output .= $custom_amount_text; |
@@ -381,23 +381,23 @@ discard block |
||
381 | 381 | |
382 | 382 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
383 | 383 | |
384 | - foreach ( $prices as $price ) { |
|
385 | - $counter ++; |
|
386 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
387 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
384 | + foreach ($prices as $price) { |
|
385 | + $counter++; |
|
386 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
387 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
388 | 388 | |
389 | 389 | $output .= '<li>'; |
390 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
391 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
390 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
391 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
392 | 392 | $output .= '</li>'; |
393 | 393 | |
394 | 394 | } |
395 | 395 | |
396 | 396 | //Custom Amount |
397 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
397 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
398 | 398 | $output .= '<li>'; |
399 | 399 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
400 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
400 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
401 | 401 | $output .= '</li>'; |
402 | 402 | } |
403 | 403 | |
@@ -407,23 +407,23 @@ discard block |
||
407 | 407 | |
408 | 408 | case 'dropdown': |
409 | 409 | |
410 | - $output .= '<label for="give-donation-level" class="give-hidden">' . __( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
411 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level">'; |
|
410 | + $output .= '<label for="give-donation-level" class="give-hidden">'.__('Choose Your Donation Amount', 'give').':</label>'; |
|
411 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level">'; |
|
412 | 412 | |
413 | 413 | //first loop through prices |
414 | - foreach ( $prices as $price ) { |
|
415 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
416 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
414 | + foreach ($prices as $price) { |
|
415 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
416 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
417 | 417 | |
418 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
418 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
419 | 419 | $output .= $level_text; |
420 | 420 | $output .= '</option>'; |
421 | 421 | |
422 | 422 | } |
423 | 423 | |
424 | 424 | //Custom Amount |
425 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
426 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
425 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
426 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output .= '</select>'; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | break; |
432 | 432 | } |
433 | 433 | |
434 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
434 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -443,26 +443,26 @@ discard block |
||
443 | 443 | * @param array $args |
444 | 444 | * |
445 | 445 | */ |
446 | -function give_display_checkout_button( $form_id, $args ) { |
|
446 | +function give_display_checkout_button($form_id, $args) { |
|
447 | 447 | |
448 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
448 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
449 | 449 | ? $args['display_style'] |
450 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
450 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
451 | 451 | |
452 | 452 | //no btn for onpage |
453 | - if ( $display_option === 'onpage' ) { |
|
453 | + if ($display_option === 'onpage') { |
|
454 | 454 | return; |
455 | 455 | } |
456 | 456 | |
457 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
458 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : __( 'Donate Now', 'give' ) ); |
|
457 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
458 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : __('Donate Now', 'give')); |
|
459 | 459 | |
460 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
460 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
461 | 461 | |
462 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
462 | + echo apply_filters('give_display_checkout_button', $output); |
|
463 | 463 | } |
464 | 464 | |
465 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
465 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
466 | 466 | |
467 | 467 | /** |
468 | 468 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -473,71 +473,71 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return void |
475 | 475 | */ |
476 | -function give_user_info_fields( $form_id ) { |
|
476 | +function give_user_info_fields($form_id) { |
|
477 | 477 | |
478 | - if ( is_user_logged_in() ) : |
|
479 | - $user_data = get_userdata( get_current_user_id() ); |
|
478 | + if (is_user_logged_in()) : |
|
479 | + $user_data = get_userdata(get_current_user_id()); |
|
480 | 480 | endif; |
481 | 481 | |
482 | - do_action( 'give_purchase_form_before_personal_info', $form_id ); |
|
482 | + do_action('give_purchase_form_before_personal_info', $form_id); |
|
483 | 483 | ?> |
484 | 484 | <fieldset id="give_checkout_user_info"> |
485 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
485 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', __('Personal Info', 'give')); ?></legend> |
|
486 | 486 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
487 | 487 | <label class="give-label" for="give-first"> |
488 | - <?php _e( 'First Name', 'give' ); ?> |
|
489 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) { ?> |
|
488 | + <?php _e('First Name', 'give'); ?> |
|
489 | + <?php if (give_field_is_required('give_first', $form_id)) { ?> |
|
490 | 490 | <span class="give-required-indicator">*</span> |
491 | 491 | <?php } ?> |
492 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
492 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
493 | 493 | </label> |
494 | - <input class="give-input required" type="text" name="give_first" placeholder="<?php _e( 'First name', 'give' ); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if ( give_field_is_required( 'give_first', $form_id ) ) { |
|
494 | + <input class="give-input required" type="text" name="give_first" placeholder="<?php _e('First name', 'give'); ?>" id="give-first" value="<?php echo is_user_logged_in() ? $user_data->first_name : ''; ?>"<?php if (give_field_is_required('give_first', $form_id)) { |
|
495 | 495 | echo ' required '; |
496 | 496 | } ?>/> |
497 | 497 | </p> |
498 | 498 | |
499 | 499 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
500 | 500 | <label class="give-label" for="give-last"> |
501 | - <?php _e( 'Last Name', 'give' ); ?> |
|
502 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) { ?> |
|
501 | + <?php _e('Last Name', 'give'); ?> |
|
502 | + <?php if (give_field_is_required('give_last', $form_id)) { ?> |
|
503 | 503 | <span class="give-required-indicator">*</span> |
504 | 504 | <?php } ?> |
505 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
505 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
506 | 506 | </label> |
507 | 507 | |
508 | - <input class="give-input<?php if ( give_field_is_required( 'give_last', $form_id ) ) { |
|
508 | + <input class="give-input<?php if (give_field_is_required('give_last', $form_id)) { |
|
509 | 509 | echo ' required'; |
510 | - } ?>" type="text" name="give_last" id="give-last" placeholder="<?php _e( 'Last name', 'give' ); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if ( give_field_is_required( 'give_last', $form_id ) ) { |
|
510 | + } ?>" type="text" name="give_last" id="give-last" placeholder="<?php _e('Last name', 'give'); ?>" value="<?php echo is_user_logged_in() ? $user_data->last_name : ''; ?>"<?php if (give_field_is_required('give_last', $form_id)) { |
|
511 | 511 | echo ' required '; |
512 | 512 | } ?> /> |
513 | 513 | </p> |
514 | 514 | |
515 | - <?php do_action( 'give_purchase_form_before_email', $form_id ); ?> |
|
515 | + <?php do_action('give_purchase_form_before_email', $form_id); ?> |
|
516 | 516 | <p id="give-email-wrap" class="form-row form-row-wide"> |
517 | 517 | <label class="give-label" for="give-email"> |
518 | - <?php _e( 'Email Address', 'give' ); ?> |
|
519 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
518 | + <?php _e('Email Address', 'give'); ?> |
|
519 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
520 | 520 | <span class="give-required-indicator">*</span> |
521 | 521 | <?php } ?> |
522 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'We will send the purchase receipt to this address.', 'give' ); ?>"></span> |
|
522 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('We will send the purchase receipt to this address.', 'give'); ?>"></span> |
|
523 | 523 | </label> |
524 | 524 | |
525 | - <input class="give-input required" type="email" name="give_email" placeholder="<?php _e( 'Email address', 'give' ); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if ( give_field_is_required( 'give_email', $form_id ) ) { |
|
525 | + <input class="give-input required" type="email" name="give_email" placeholder="<?php _e('Email address', 'give'); ?>" id="give-email" value="<?php echo is_user_logged_in() ? $user_data->user_email : ''; ?>"<?php if (give_field_is_required('give_email', $form_id)) { |
|
526 | 526 | echo ' required '; |
527 | 527 | } ?>/> |
528 | 528 | |
529 | 529 | </p> |
530 | - <?php do_action( 'give_purchase_form_after_email', $form_id ); ?> |
|
530 | + <?php do_action('give_purchase_form_after_email', $form_id); ?> |
|
531 | 531 | |
532 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
532 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
533 | 533 | </fieldset> |
534 | 534 | <?php |
535 | - do_action( 'give_purchase_form_after_personal_info', $form_id ); |
|
535 | + do_action('give_purchase_form_after_personal_info', $form_id); |
|
536 | 536 | |
537 | 537 | } |
538 | 538 | |
539 | -add_action( 'give_purchase_form_after_user_info', 'give_user_info_fields' ); |
|
540 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
539 | +add_action('give_purchase_form_after_user_info', 'give_user_info_fields'); |
|
540 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
541 | 541 | |
542 | 542 | /** |
543 | 543 | * Renders the credit card info form. |
@@ -548,73 +548,73 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return void |
550 | 550 | */ |
551 | -function give_get_cc_form( $form_id ) { |
|
551 | +function give_get_cc_form($form_id) { |
|
552 | 552 | |
553 | 553 | ob_start(); |
554 | 554 | |
555 | - do_action( 'give_before_cc_fields', $form_id ); ?> |
|
555 | + do_action('give_before_cc_fields', $form_id); ?> |
|
556 | 556 | |
557 | 557 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
558 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', __( 'Credit Card Info', 'give' ) ); ?></legend> |
|
559 | - <?php if ( is_ssl() ) : ?> |
|
558 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', __('Credit Card Info', 'give')); ?></legend> |
|
559 | + <?php if (is_ssl()) : ?> |
|
560 | 560 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
561 | 561 | <span class="give-icon padlock"></span> |
562 | - <span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
562 | + <span><?php _e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
563 | 563 | </div> |
564 | 564 | <?php endif; ?> |
565 | 565 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
566 | 566 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
567 | - <?php _e( 'Card Number', 'give' ); ?> |
|
567 | + <?php _e('Card Number', 'give'); ?> |
|
568 | 568 | <span class="give-required-indicator">*</span> |
569 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
569 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
570 | 570 | <span class="card-type"></span> |
571 | 571 | </label> |
572 | 572 | |
573 | - <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" required/> |
|
573 | + <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php _e('Card number', 'give'); ?>" required/> |
|
574 | 574 | </p> |
575 | 575 | |
576 | 576 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
577 | 577 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
578 | - <?php _e( 'CVC', 'give' ); ?> |
|
578 | + <?php _e('CVC', 'give'); ?> |
|
579 | 579 | <span class="give-required-indicator">*</span> |
580 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
580 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
581 | 581 | </label> |
582 | 582 | |
583 | - <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" required/> |
|
583 | + <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php _e('Security code', 'give'); ?>" required/> |
|
584 | 584 | </p> |
585 | 585 | |
586 | 586 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
587 | 587 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
588 | - <?php _e( 'Name on the Card', 'give' ); ?> |
|
588 | + <?php _e('Name on the Card', 'give'); ?> |
|
589 | 589 | <span class="give-required-indicator">*</span> |
590 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
590 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
591 | 591 | </label> |
592 | 592 | |
593 | - <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php _e( 'Card name', 'give' ); ?>" required/> |
|
593 | + <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php _e('Card name', 'give'); ?>" required/> |
|
594 | 594 | </p> |
595 | - <?php do_action( 'give_before_cc_expiration' ); ?> |
|
595 | + <?php do_action('give_before_cc_expiration'); ?> |
|
596 | 596 | <p class="card-expiration form-row form-row-one-third"> |
597 | 597 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
598 | - <?php _e( 'Expiration', 'give' ); ?> |
|
598 | + <?php _e('Expiration', 'give'); ?> |
|
599 | 599 | <span class="give-required-indicator">*</span> |
600 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
600 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
601 | 601 | </label> |
602 | 602 | |
603 | 603 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
604 | 604 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
605 | 605 | |
606 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php _e( 'MM / YY', 'give' ); ?>" required/> |
|
606 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php _e('MM / YY', 'give'); ?>" required/> |
|
607 | 607 | </p> |
608 | - <?php do_action( 'give_after_cc_expiration', $form_id ); ?> |
|
608 | + <?php do_action('give_after_cc_expiration', $form_id); ?> |
|
609 | 609 | |
610 | 610 | </fieldset> |
611 | 611 | <?php |
612 | - do_action( 'give_after_cc_fields', $form_id ); |
|
612 | + do_action('give_after_cc_fields', $form_id); |
|
613 | 613 | |
614 | 614 | echo ob_get_clean(); |
615 | 615 | } |
616 | 616 | |
617 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
617 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
618 | 618 | |
619 | 619 | /** |
620 | 620 | * Outputs the default credit card address fields |
@@ -625,110 +625,110 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return void |
627 | 627 | */ |
628 | -function give_default_cc_address_fields( $form_id ) { |
|
628 | +function give_default_cc_address_fields($form_id) { |
|
629 | 629 | |
630 | 630 | $logged_in = is_user_logged_in(); |
631 | 631 | |
632 | - if ( $logged_in ) { |
|
633 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
632 | + if ($logged_in) { |
|
633 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
634 | 634 | } |
635 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
636 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
637 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
638 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
635 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
636 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
637 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
638 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
639 | 639 | ob_start(); ?> |
640 | 640 | <fieldset id="give_cc_address" class="cc-address"> |
641 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', __( 'Billing Details', 'give' ) ); ?></legend> |
|
642 | - <?php do_action( 'give_cc_billing_top' ); ?> |
|
641 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', __('Billing Details', 'give')); ?></legend> |
|
642 | + <?php do_action('give_cc_billing_top'); ?> |
|
643 | 643 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
644 | 644 | <label for="card_address" class="give-label"> |
645 | - <?php _e( 'Address', 'give' ); ?> |
|
645 | + <?php _e('Address', 'give'); ?> |
|
646 | 646 | <?php |
647 | - if ( give_field_is_required( 'card_address', $form_id ) ) { ?> |
|
647 | + if (give_field_is_required('card_address', $form_id)) { ?> |
|
648 | 648 | <span class="give-required-indicator">*</span> |
649 | 649 | <?php } ?> |
650 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
650 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
651 | 651 | </label> |
652 | 652 | |
653 | - <input type="text" id="card_address" name="card_address" class="card-address give-input<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
653 | + <input type="text" id="card_address" name="card_address" class="card-address give-input<?php if (give_field_is_required('card_address', $form_id)) { |
|
654 | 654 | echo ' required'; |
655 | - } ?>" placeholder="<?php _e( 'Address line 1', 'give' ); ?>" value="<?php echo $line1; ?>"<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
655 | + } ?>" placeholder="<?php _e('Address line 1', 'give'); ?>" value="<?php echo $line1; ?>"<?php if (give_field_is_required('card_address', $form_id)) { |
|
656 | 656 | echo ' required '; |
657 | 657 | } ?>/> |
658 | 658 | </p> |
659 | 659 | |
660 | 660 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
661 | 661 | <label for="card_address_2" class="give-label"> |
662 | - <?php _e( 'Address Line 2', 'give' ); ?> |
|
663 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { ?> |
|
662 | + <?php _e('Address Line 2', 'give'); ?> |
|
663 | + <?php if (give_field_is_required('card_address_2', $form_id)) { ?> |
|
664 | 664 | <span class="give-required-indicator">*</span> |
665 | 665 | <?php } ?> |
666 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
666 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
667 | 667 | </label> |
668 | 668 | |
669 | - <input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { |
|
669 | + <input type="text" id="card_address_2" name="card_address_2" class="card-address-2 give-input<?php if (give_field_is_required('card_address_2', $form_id)) { |
|
670 | 670 | echo ' required'; |
671 | - } ?>" placeholder="<?php _e( 'Address line 2', 'give' ); ?>" value="<?php echo $line2; ?>"<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { |
|
671 | + } ?>" placeholder="<?php _e('Address line 2', 'give'); ?>" value="<?php echo $line2; ?>"<?php if (give_field_is_required('card_address_2', $form_id)) { |
|
672 | 672 | echo ' required '; |
673 | 673 | } ?>/> |
674 | 674 | </p> |
675 | 675 | |
676 | 676 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
677 | 677 | <label for="card_city" class="give-label"> |
678 | - <?php _e( 'City', 'give' ); ?> |
|
679 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) { ?> |
|
678 | + <?php _e('City', 'give'); ?> |
|
679 | + <?php if (give_field_is_required('card_city', $form_id)) { ?> |
|
680 | 680 | <span class="give-required-indicator">*</span> |
681 | 681 | <?php } ?> |
682 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
682 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The city for your billing address.', 'give'); ?>"></span> |
|
683 | 683 | </label> |
684 | - <input type="text" id="card_city" name="card_city" class="card-city give-input<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
684 | + <input type="text" id="card_city" name="card_city" class="card-city give-input<?php if (give_field_is_required('card_city', $form_id)) { |
|
685 | 685 | echo ' required'; |
686 | - } ?>" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $city; ?>"<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
686 | + } ?>" placeholder="<?php _e('City', 'give'); ?>" value="<?php echo $city; ?>"<?php if (give_field_is_required('card_city', $form_id)) { |
|
687 | 687 | echo ' required '; |
688 | 688 | } ?>/> |
689 | 689 | </p> |
690 | 690 | |
691 | 691 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
692 | 692 | <label for="card_zip" class="give-label"> |
693 | - <?php _e( 'Zip / Postal Code', 'give' ); ?> |
|
694 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { ?> |
|
693 | + <?php _e('Zip / Postal Code', 'give'); ?> |
|
694 | + <?php if (give_field_is_required('card_zip', $form_id)) { ?> |
|
695 | 695 | <span class="give-required-indicator">*</span> |
696 | 696 | <?php } ?> |
697 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
697 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
698 | 698 | </label> |
699 | 699 | |
700 | - <input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if ( give_field_is_required( 'card_zip', $form_id ) ) { |
|
700 | + <input type="text" size="4" id="card_zip" name="card_zip" class="card-zip give-input<?php if (give_field_is_required('card_zip', $form_id)) { |
|
701 | 701 | echo ' required'; |
702 | - } ?>" placeholder="<?php _e( 'Zip / Postal code', 'give' ); ?>" value="<?php echo $zip; ?>" <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { |
|
702 | + } ?>" placeholder="<?php _e('Zip / Postal code', 'give'); ?>" value="<?php echo $zip; ?>" <?php if (give_field_is_required('card_zip', $form_id)) { |
|
703 | 703 | echo ' required '; |
704 | 704 | } ?>/> |
705 | 705 | </p> |
706 | 706 | |
707 | 707 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
708 | 708 | <label for="billing_country" class="give-label"> |
709 | - <?php _e( 'Country', 'give' ); ?> |
|
710 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) { ?> |
|
709 | + <?php _e('Country', 'give'); ?> |
|
710 | + <?php if (give_field_is_required('billing_country', $form_id)) { ?> |
|
711 | 711 | <span class="give-required-indicator">*</span> |
712 | 712 | <?php } ?> |
713 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
713 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The country for your billing address.', 'give'); ?>"></span> |
|
714 | 714 | </label> |
715 | 715 | |
716 | - <select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
716 | + <select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if (give_field_is_required('billing_country', $form_id)) { |
|
717 | 717 | echo ' required'; |
718 | - } ?>"<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
718 | + } ?>"<?php if (give_field_is_required('billing_country', $form_id)) { |
|
719 | 719 | echo ' required '; |
720 | 720 | } ?>> |
721 | 721 | <?php |
722 | 722 | |
723 | 723 | $selected_country = give_get_country(); |
724 | 724 | |
725 | - if ( $logged_in && ! empty( $user_address['country'] ) && '*' !== $user_address['country'] ) { |
|
725 | + if ($logged_in && ! empty($user_address['country']) && '*' !== $user_address['country']) { |
|
726 | 726 | $selected_country = $user_address['country']; |
727 | 727 | } |
728 | 728 | |
729 | 729 | $countries = give_get_country_list(); |
730 | - foreach ( $countries as $country_code => $country ) { |
|
731 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
730 | + foreach ($countries as $country_code => $country) { |
|
731 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
732 | 732 | } |
733 | 733 | ?> |
734 | 734 | </select> |
@@ -736,44 +736,44 @@ discard block |
||
736 | 736 | |
737 | 737 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
738 | 738 | <label for="card_state" class="give-label"> |
739 | - <?php _e( 'State / Province', 'give' ); ?> |
|
740 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) { ?> |
|
739 | + <?php _e('State / Province', 'give'); ?> |
|
740 | + <?php if (give_field_is_required('card_state', $form_id)) { ?> |
|
741 | 741 | <span class="give-required-indicator">*</span> |
742 | 742 | <?php } ?> |
743 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
743 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The state or province for your billing address.', 'give'); ?>"></span> |
|
744 | 744 | </label> |
745 | 745 | |
746 | 746 | <?php |
747 | 747 | $selected_state = give_get_state(); |
748 | - $states = give_get_states( $selected_country ); |
|
748 | + $states = give_get_states($selected_country); |
|
749 | 749 | |
750 | - if ( $logged_in && ! empty( $user_address['state'] ) ) { |
|
750 | + if ($logged_in && ! empty($user_address['state'])) { |
|
751 | 751 | $selected_state = $user_address['state']; |
752 | 752 | } |
753 | 753 | |
754 | - if ( ! empty( $states ) ) : ?> |
|
755 | - <select name="card_state" id="card_state" class="card_state give-select<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
754 | + if ( ! empty($states)) : ?> |
|
755 | + <select name="card_state" id="card_state" class="card_state give-select<?php if (give_field_is_required('card_state', $form_id)) { |
|
756 | 756 | echo ' required'; |
757 | - } ?>"<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
757 | + } ?>"<?php if (give_field_is_required('card_state', $form_id)) { |
|
758 | 758 | echo ' required '; |
759 | 759 | } ?>> |
760 | 760 | <?php |
761 | - foreach ( $states as $state_code => $state ) { |
|
762 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
761 | + foreach ($states as $state_code => $state) { |
|
762 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
763 | 763 | } |
764 | 764 | ?> |
765 | 765 | </select> |
766 | 766 | <?php else : ?> |
767 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e( 'State / Province', 'give' ); ?>"/> |
|
767 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php _e('State / Province', 'give'); ?>"/> |
|
768 | 768 | <?php endif; ?> |
769 | 769 | </p> |
770 | - <?php do_action( 'give_cc_billing_bottom' ); ?> |
|
770 | + <?php do_action('give_cc_billing_bottom'); ?> |
|
771 | 771 | </fieldset> |
772 | 772 | <?php |
773 | 773 | echo ob_get_clean(); |
774 | 774 | } |
775 | 775 | |
776 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
776 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
777 | 777 | |
778 | 778 | |
779 | 779 | /** |
@@ -785,93 +785,93 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @return string |
787 | 787 | */ |
788 | -function give_get_register_fields( $form_id ) { |
|
788 | +function give_get_register_fields($form_id) { |
|
789 | 789 | |
790 | 790 | global $user_ID; |
791 | 791 | |
792 | - if ( is_user_logged_in() ) { |
|
793 | - $user_data = get_userdata( $user_ID ); |
|
792 | + if (is_user_logged_in()) { |
|
793 | + $user_data = get_userdata($user_ID); |
|
794 | 794 | } |
795 | 795 | |
796 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
796 | + $show_register_form = give_show_login_register_option($form_id); |
|
797 | 797 | |
798 | 798 | ob_start(); ?> |
799 | 799 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
800 | 800 | |
801 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
801 | + <?php if ($show_register_form == 'both') { ?> |
|
802 | 802 | <div class="give-login-account-wrap"> |
803 | - <p class="give-login-message"><?php _e( 'Already have an account?', 'give' ); ?> |
|
804 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php _e( 'Login', 'give' ); ?></a> |
|
803 | + <p class="give-login-message"><?php _e('Already have an account?', 'give'); ?> |
|
804 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php _e('Login', 'give'); ?></a> |
|
805 | 805 | </p> |
806 | 806 | <p class="give-loading-text"> |
807 | - <span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?></p> |
|
807 | + <span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?></p> |
|
808 | 808 | </div> |
809 | 809 | <?php } ?> |
810 | 810 | |
811 | - <?php do_action( 'give_register_fields_before', $form_id ); ?> |
|
811 | + <?php do_action('give_register_fields_before', $form_id); ?> |
|
812 | 812 | |
813 | 813 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
814 | - <legend><?php echo apply_filters( 'give_create_account_fieldset_heading', __( 'Create an account', 'give' ) ); |
|
815 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
816 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
814 | + <legend><?php echo apply_filters('give_create_account_fieldset_heading', __('Create an account', 'give')); |
|
815 | + if ( ! give_logged_in_only($form_id)) { |
|
816 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
817 | 817 | } ?></legend> |
818 | - <?php do_action( 'give_register_account_fields_before', $form_id ); ?> |
|
818 | + <?php do_action('give_register_account_fields_before', $form_id); ?> |
|
819 | 819 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
820 | 820 | <label for="give-user-login-<?php echo $form_id; ?>"> |
821 | - <?php _e( 'Username', 'give' ); ?> |
|
822 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
821 | + <?php _e('Username', 'give'); ?> |
|
822 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
823 | 823 | <span class="give-required-indicator">*</span> |
824 | 824 | <?php } ?> |
825 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
825 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
826 | 826 | </label> |
827 | 827 | |
828 | - <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
828 | + <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
829 | 829 | echo 'required '; |
830 | - } ?>give-input" type="text" placeholder="<?php _e( 'Username', 'give' ); ?>" title="<?php _e( 'Username', 'give' ); ?>"/> |
|
830 | + } ?>give-input" type="text" placeholder="<?php _e('Username', 'give'); ?>" title="<?php _e('Username', 'give'); ?>"/> |
|
831 | 831 | </div> |
832 | 832 | |
833 | 833 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
834 | 834 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
835 | - <?php _e( 'Password', 'give' ); ?> |
|
836 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
835 | + <?php _e('Password', 'give'); ?> |
|
836 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
837 | 837 | <span class="give-required-indicator">*</span> |
838 | 838 | <?php } ?> |
839 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
839 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('The password used to access your account.', 'give'); ?>"></span> |
|
840 | 840 | </label> |
841 | 841 | |
842 | - <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
842 | + <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
843 | 843 | echo 'required '; |
844 | - } ?>give-input" placeholder="<?php _e( 'Password', 'give' ); ?>" type="password"/> |
|
844 | + } ?>give-input" placeholder="<?php _e('Password', 'give'); ?>" type="password"/> |
|
845 | 845 | </div> |
846 | 846 | |
847 | 847 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third"> |
848 | 848 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
849 | - <?php _e( 'Confirm PW', 'give' ); ?> |
|
850 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
849 | + <?php _e('Confirm PW', 'give'); ?> |
|
850 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
851 | 851 | <span class="give-required-indicator">*</span> |
852 | 852 | <?php } ?> |
853 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
853 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php _e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
854 | 854 | </label> |
855 | 855 | |
856 | - <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
856 | + <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
857 | 857 | echo 'required '; |
858 | - } ?>give-input" placeholder="<?php _e( 'Confirm password', 'give' ); ?>" type="password"/> |
|
858 | + } ?>give-input" placeholder="<?php _e('Confirm password', 'give'); ?>" type="password"/> |
|
859 | 859 | </div> |
860 | - <?php do_action( 'give_register_account_fields_after', $form_id ); ?> |
|
860 | + <?php do_action('give_register_account_fields_after', $form_id); ?> |
|
861 | 861 | </fieldset> |
862 | 862 | |
863 | - <?php do_action( 'give_register_fields_after', $form_id ); ?> |
|
863 | + <?php do_action('give_register_fields_after', $form_id); ?> |
|
864 | 864 | |
865 | 865 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
866 | 866 | |
867 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
867 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
868 | 868 | |
869 | 869 | </fieldset> |
870 | 870 | <?php |
871 | 871 | echo ob_get_clean(); |
872 | 872 | } |
873 | 873 | |
874 | -add_action( 'give_purchase_form_register_fields', 'give_get_register_fields' ); |
|
874 | +add_action('give_purchase_form_register_fields', 'give_get_register_fields'); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -884,73 +884,73 @@ discard block |
||
884 | 884 | * |
885 | 885 | * @return string |
886 | 886 | */ |
887 | -function give_get_login_fields( $form_id ) { |
|
887 | +function give_get_login_fields($form_id) { |
|
888 | 888 | |
889 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
890 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
889 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
890 | + $show_register_form = give_show_login_register_option($form_id); |
|
891 | 891 | |
892 | 892 | ob_start(); |
893 | 893 | ?> |
894 | 894 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
895 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
896 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
897 | - echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
895 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', __('Login to Your Account', 'give')); |
|
896 | + if ( ! give_logged_in_only($form_id)) { |
|
897 | + echo ' <span class="sub-text">'.__('(optional)', 'give').'</span>'; |
|
898 | 898 | } ?> |
899 | 899 | </legend> |
900 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
900 | + <?php if ($show_register_form == 'both') { ?> |
|
901 | 901 | <p class="give-new-account-link"> |
902 | - <?php _e( 'Need to create an account?', 'give' ); ?> |
|
903 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
904 | - <?php _e( 'Register', 'give' ); |
|
905 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
906 | - echo ' ' . __( 'or checkout as a guest.', 'give' ); |
|
902 | + <?php _e('Need to create an account?', 'give'); ?> |
|
903 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
904 | + <?php _e('Register', 'give'); |
|
905 | + if ( ! give_logged_in_only($form_id)) { |
|
906 | + echo ' '.__('or checkout as a guest.', 'give'); |
|
907 | 907 | } ?> |
908 | 908 | </a> |
909 | 909 | </p> |
910 | 910 | <p class="give-loading-text"> |
911 | - <span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?> </p> |
|
911 | + <span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?> </p> |
|
912 | 912 | <?php } ?> |
913 | - <?php do_action( 'give_checkout_login_fields_before', $form_id ); ?> |
|
913 | + <?php do_action('give_checkout_login_fields_before', $form_id); ?> |
|
914 | 914 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
915 | 915 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
916 | - <?php _e( 'Username', 'give' ); ?> |
|
917 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
916 | + <?php _e('Username', 'give'); ?> |
|
917 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
918 | 918 | <span class="give-required-indicator">*</span> |
919 | 919 | <?php } ?> |
920 | 920 | </label> |
921 | 921 | |
922 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
922 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
923 | 923 | echo 'required '; |
924 | - } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php _e( 'Your username', 'give' ); ?>"/> |
|
924 | + } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php _e('Your username', 'give'); ?>"/> |
|
925 | 925 | </div> |
926 | 926 | |
927 | 927 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
928 | 928 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
929 | - <?php _e( 'Password', 'give' ); ?> |
|
930 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
929 | + <?php _e('Password', 'give'); ?> |
|
930 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
931 | 931 | <span class="give-required-indicator">*</span> |
932 | 932 | <?php } ?> |
933 | 933 | </label> |
934 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
934 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
935 | 935 | echo 'required '; |
936 | - } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php _e( 'Your password', 'give' ); ?>"/> |
|
936 | + } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php _e('Your password', 'give'); ?>"/> |
|
937 | 937 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
938 | 938 | </div> |
939 | 939 | |
940 | 940 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
941 | - <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php _e( 'Login', 'give' ); ?>"/> |
|
942 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
943 | - <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php _e( 'Cancel', 'give' ); ?>"/> |
|
941 | + <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php _e('Login', 'give'); ?>"/> |
|
942 | + <?php if ($show_register_form !== 'login') { ?> |
|
943 | + <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php _e('Cancel', 'give'); ?>"/> |
|
944 | 944 | <?php } ?> |
945 | 945 | <span class="give-loading-animation"></span> |
946 | 946 | </div> |
947 | - <?php do_action( 'give_checkout_login_fields_after', $form_id ); ?> |
|
947 | + <?php do_action('give_checkout_login_fields_after', $form_id); ?> |
|
948 | 948 | </fieldset><!--end #give-login-fields--> |
949 | 949 | <?php |
950 | 950 | echo ob_get_clean(); |
951 | 951 | } |
952 | 952 | |
953 | -add_action( 'give_purchase_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
953 | +add_action('give_purchase_form_login_fields', 'give_get_login_fields', 10, 1); |
|
954 | 954 | |
955 | 955 | /** |
956 | 956 | * Payment Mode Select |
@@ -966,49 +966,49 @@ discard block |
||
966 | 966 | * |
967 | 967 | * @return void |
968 | 968 | */ |
969 | -function give_payment_mode_select( $form_id ) { |
|
969 | +function give_payment_mode_select($form_id) { |
|
970 | 970 | |
971 | 971 | $gateways = give_get_enabled_payment_gateways(); |
972 | 972 | |
973 | - do_action( 'give_payment_mode_top', $form_id ); ?> |
|
973 | + do_action('give_payment_mode_top', $form_id); ?> |
|
974 | 974 | |
975 | 975 | <fieldset id="give-payment-mode-select"> |
976 | - <?php do_action( 'give_payment_mode_before_gateways_wrap' ); ?> |
|
976 | + <?php do_action('give_payment_mode_before_gateways_wrap'); ?> |
|
977 | 977 | <div id="give-payment-mode-wrap"> |
978 | - <legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', __( 'Select Payment Method', 'give' ) ); ?> |
|
979 | - <span class="give-loading-text"><span class="give-loading-animation"></span> <?php _e( 'Loading...', 'give' ); ?></span> |
|
978 | + <legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', __('Select Payment Method', 'give')); ?> |
|
979 | + <span class="give-loading-text"><span class="give-loading-animation"></span> <?php _e('Loading...', 'give'); ?></span> |
|
980 | 980 | </legend> |
981 | 981 | <?php |
982 | 982 | |
983 | - do_action( 'give_payment_mode_before_gateways' ) ?> |
|
983 | + do_action('give_payment_mode_before_gateways') ?> |
|
984 | 984 | |
985 | 985 | <ul id="give-gateway-radio-list"> |
986 | - <?php foreach ( $gateways as $gateway_id => $gateway ) : |
|
987 | - $checked = checked( $gateway_id, give_get_default_gateway( $form_id ), false ); |
|
986 | + <?php foreach ($gateways as $gateway_id => $gateway) : |
|
987 | + $checked = checked($gateway_id, give_get_default_gateway($form_id), false); |
|
988 | 988 | $checked_class = $checked ? ' give-gateway-option-selected' : ''; |
989 | - echo '<li><label for="give-gateway-' . esc_attr( $gateway_id ) . '-' . $form_id . '" class="give-gateway-option' . $checked_class . '" id="give-gateway-option-' . esc_attr( $gateway_id ) . '">'; |
|
990 | - echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-' . esc_attr( $gateway_id ) . '-' . $form_id . '" value="' . esc_attr( $gateway_id ) . '"' . $checked . '>' . esc_html( $gateway['checkout_label'] ); |
|
989 | + echo '<li><label for="give-gateway-'.esc_attr($gateway_id).'-'.$form_id.'" class="give-gateway-option'.$checked_class.'" id="give-gateway-option-'.esc_attr($gateway_id).'">'; |
|
990 | + echo '<input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-'.esc_attr($gateway_id).'-'.$form_id.'" value="'.esc_attr($gateway_id).'"'.$checked.'>'.esc_html($gateway['checkout_label']); |
|
991 | 991 | echo '</label></li>'; |
992 | 992 | endforeach; ?> |
993 | 993 | </ul> |
994 | - <?php do_action( 'give_payment_mode_after_gateways' ); ?> |
|
994 | + <?php do_action('give_payment_mode_after_gateways'); ?> |
|
995 | 995 | </div> |
996 | - <?php do_action( 'give_payment_mode_after_gateways_wrap' ); ?> |
|
996 | + <?php do_action('give_payment_mode_after_gateways_wrap'); ?> |
|
997 | 997 | </fieldset> |
998 | 998 | |
999 | - <?php do_action( 'give_payment_mode_bottom', $form_id ); ?> |
|
999 | + <?php do_action('give_payment_mode_bottom', $form_id); ?> |
|
1000 | 1000 | |
1001 | 1001 | <div id="give_purchase_form_wrap"> |
1002 | 1002 | |
1003 | - <?php do_action( 'give_purchase_form', $form_id ); ?> |
|
1003 | + <?php do_action('give_purchase_form', $form_id); ?> |
|
1004 | 1004 | |
1005 | 1005 | </div><!-- the checkout fields are loaded into this--> |
1006 | 1006 | |
1007 | - <?php do_action( 'give_purchase_form_wrap_bottom', $form_id ); |
|
1007 | + <?php do_action('give_purchase_form_wrap_bottom', $form_id); |
|
1008 | 1008 | |
1009 | 1009 | } |
1010 | 1010 | |
1011 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1011 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1012 | 1012 | |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1023,35 +1023,35 @@ discard block |
||
1023 | 1023 | * |
1024 | 1024 | * @return void |
1025 | 1025 | */ |
1026 | -function give_terms_agreement( $form_id ) { |
|
1026 | +function give_terms_agreement($form_id) { |
|
1027 | 1027 | |
1028 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1029 | - $label = get_post_meta( $form_id, '_give_agree_label', true ); |
|
1030 | - $terms = get_post_meta( $form_id, '_give_agree_text', true ); |
|
1028 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1029 | + $label = get_post_meta($form_id, '_give_agree_label', true); |
|
1030 | + $terms = get_post_meta($form_id, '_give_agree_text', true); |
|
1031 | 1031 | |
1032 | - if ( $form_option === 'yes' && ! empty( $terms ) ) { ?> |
|
1032 | + if ($form_option === 'yes' && ! empty($terms)) { ?> |
|
1033 | 1033 | <fieldset id="give_terms_agreement"> |
1034 | 1034 | <div id="give_terms" style="display:none;"> |
1035 | 1035 | <?php |
1036 | - do_action( 'give_before_terms' ); |
|
1037 | - echo wpautop( stripslashes( $terms ) ); |
|
1038 | - do_action( 'give_after_terms' ); |
|
1036 | + do_action('give_before_terms'); |
|
1037 | + echo wpautop(stripslashes($terms)); |
|
1038 | + do_action('give_after_terms'); |
|
1039 | 1039 | ?> |
1040 | 1040 | </div> |
1041 | 1041 | <div id="give_show_terms"> |
1042 | - <a href="#" class="give_terms_links"><?php _e( 'Show Terms', 'give' ); ?></a> |
|
1043 | - <a href="#" class="give_terms_links" style="display:none;"><?php _e( 'Hide Terms', 'give' ); ?></a> |
|
1042 | + <a href="#" class="give_terms_links"><?php _e('Show Terms', 'give'); ?></a> |
|
1043 | + <a href="#" class="give_terms_links" style="display:none;"><?php _e('Hide Terms', 'give'); ?></a> |
|
1044 | 1044 | </div> |
1045 | 1045 | |
1046 | 1046 | <label |
1047 | - for="give_agree_to_terms"><?php echo ! empty( $label ) ? stripslashes( $label ) : __( 'Agree to Terms?', 'give' ); ?></label> |
|
1047 | + for="give_agree_to_terms"><?php echo ! empty($label) ? stripslashes($label) : __('Agree to Terms?', 'give'); ?></label> |
|
1048 | 1048 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/> |
1049 | 1049 | </fieldset> |
1050 | 1050 | <?php |
1051 | 1051 | } |
1052 | 1052 | } |
1053 | 1053 | |
1054 | -add_action( 'give_purchase_form_before_submit', 'give_terms_agreement', 10, 1 ); |
|
1054 | +add_action('give_purchase_form_before_submit', 'give_terms_agreement', 10, 1); |
|
1055 | 1055 | |
1056 | 1056 | /** |
1057 | 1057 | * Checkout Final Total |
@@ -1063,27 +1063,27 @@ discard block |
||
1063 | 1063 | * @since 1.0 |
1064 | 1064 | * @return void |
1065 | 1065 | */ |
1066 | -function give_checkout_final_total( $form_id ) { |
|
1066 | +function give_checkout_final_total($form_id) { |
|
1067 | 1067 | |
1068 | - if ( isset( $_POST['give_total'] ) ) { |
|
1069 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
1068 | + if (isset($_POST['give_total'])) { |
|
1069 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
1070 | 1070 | } else { |
1071 | 1071 | //default total |
1072 | - $total = give_get_default_form_amount( $form_id ); |
|
1072 | + $total = give_get_default_form_amount($form_id); |
|
1073 | 1073 | } |
1074 | 1074 | //Only proceed if give_total available |
1075 | - if ( empty( $total ) ) { |
|
1075 | + if (empty($total)) { |
|
1076 | 1076 | return; |
1077 | 1077 | } |
1078 | 1078 | ?> |
1079 | 1079 | <p id="give-final-total-wrap" class="form-wrap "> |
1080 | - <span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_attr__( 'Donation Total:', 'give' ) ); ?></span> |
|
1081 | - <span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
1080 | + <span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_attr__('Donation Total:', 'give')); ?></span> |
|
1081 | + <span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
1082 | 1082 | </p> |
1083 | 1083 | <?php |
1084 | 1084 | } |
1085 | 1085 | |
1086 | -add_action( 'give_purchase_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1086 | +add_action('give_purchase_form_before_submit', 'give_checkout_final_total', 999); |
|
1087 | 1087 | |
1088 | 1088 | |
1089 | 1089 | /** |
@@ -1095,22 +1095,22 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return void |
1097 | 1097 | */ |
1098 | -function give_checkout_submit( $form_id ) { |
|
1098 | +function give_checkout_submit($form_id) { |
|
1099 | 1099 | ?> |
1100 | 1100 | <fieldset id="give_purchase_submit"> |
1101 | - <?php do_action( 'give_purchase_form_before_submit', $form_id ); ?> |
|
1101 | + <?php do_action('give_purchase_form_before_submit', $form_id); ?> |
|
1102 | 1102 | |
1103 | - <?php give_checkout_hidden_fields( $form_id ); ?> |
|
1103 | + <?php give_checkout_hidden_fields($form_id); ?> |
|
1104 | 1104 | |
1105 | - <?php echo give_checkout_button_purchase( $form_id ); ?> |
|
1105 | + <?php echo give_checkout_button_purchase($form_id); ?> |
|
1106 | 1106 | |
1107 | - <?php do_action( 'give_purchase_form_after_submit', $form_id ); ?> |
|
1107 | + <?php do_action('give_purchase_form_after_submit', $form_id); ?> |
|
1108 | 1108 | |
1109 | 1109 | </fieldset> |
1110 | 1110 | <?php |
1111 | 1111 | } |
1112 | 1112 | |
1113 | -add_action( 'give_purchase_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1113 | +add_action('give_purchase_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1114 | 1114 | |
1115 | 1115 | |
1116 | 1116 | /** |
@@ -1123,17 +1123,17 @@ discard block |
||
1123 | 1123 | * |
1124 | 1124 | * @return string |
1125 | 1125 | */ |
1126 | -function give_checkout_button_purchase( $form_id ) { |
|
1126 | +function give_checkout_button_purchase($form_id) { |
|
1127 | 1127 | |
1128 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
1129 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : __( 'Donate Now', 'give' ) ); |
|
1130 | - ob_start(); ?> |
|
1128 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
1129 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : __('Donate Now', 'give')); |
|
1130 | + ob_start(); ?> |
|
1131 | 1131 | <div class="give-submit-button-wrap give-clearfix"> |
1132 | 1132 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" value="<?php echo $display_label; ?>"/> |
1133 | 1133 | <span class="give-loading-animation"></span> |
1134 | 1134 | </div> |
1135 | 1135 | <?php |
1136 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
1136 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | /** |
@@ -1146,11 +1146,11 @@ discard block |
||
1146 | 1146 | * |
1147 | 1147 | * @return void |
1148 | 1148 | */ |
1149 | -function give_agree_to_terms_js( $form_id ) { |
|
1149 | +function give_agree_to_terms_js($form_id) { |
|
1150 | 1150 | |
1151 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1151 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1152 | 1152 | |
1153 | - if ( $form_option === 'yes' ) { |
|
1153 | + if ($form_option === 'yes') { |
|
1154 | 1154 | ?> |
1155 | 1155 | <script type="text/javascript"> |
1156 | 1156 | jQuery(document).ready(function ($) { |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | } |
1167 | 1167 | } |
1168 | 1168 | |
1169 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
1169 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
1170 | 1170 | |
1171 | 1171 | |
1172 | 1172 | /** |
@@ -1179,19 +1179,19 @@ discard block |
||
1179 | 1179 | * |
1180 | 1180 | * @return void |
1181 | 1181 | */ |
1182 | -function give_form_content( $form_id, $args ) { |
|
1182 | +function give_form_content($form_id, $args) { |
|
1183 | 1183 | |
1184 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
1184 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
1185 | 1185 | ? $args['show_content'] |
1186 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
1186 | + : get_post_meta($form_id, '_give_content_option', true); |
|
1187 | 1187 | |
1188 | - if ( $show_content !== 'none' ) { |
|
1188 | + if ($show_content !== 'none') { |
|
1189 | 1189 | //add action according to value |
1190 | - add_action( $show_content, 'give_form_display_content' ); |
|
1190 | + add_action($show_content, 'give_form_display_content'); |
|
1191 | 1191 | } |
1192 | 1192 | } |
1193 | 1193 | |
1194 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1194 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1195 | 1195 | |
1196 | 1196 | /** |
1197 | 1197 | * Show Give Goals |
@@ -1204,25 +1204,25 @@ discard block |
||
1204 | 1204 | * @return mixed |
1205 | 1205 | */ |
1206 | 1206 | |
1207 | -function give_show_goal_progress( $form_id, $args ) { |
|
1207 | +function give_show_goal_progress($form_id, $args) { |
|
1208 | 1208 | |
1209 | - $goal_option = get_post_meta( $form_id, '_give_goal_option', true ); |
|
1210 | - $form = new Give_Donate_Form( $form_id ); |
|
1209 | + $goal_option = get_post_meta($form_id, '_give_goal_option', true); |
|
1210 | + $form = new Give_Donate_Form($form_id); |
|
1211 | 1211 | $goal = $form->goal; |
1212 | - $goal_format = get_post_meta( $form_id, '_give_goal_format', true ); |
|
1212 | + $goal_format = get_post_meta($form_id, '_give_goal_format', true); |
|
1213 | 1213 | $income = $form->get_earnings(); |
1214 | - $color = get_post_meta( $form_id, '_give_goal_color', true ); |
|
1215 | - $show_text = (bool) isset( $args['show_text'] ) ? filter_var( $args['show_text'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
1216 | - $show_bar = (bool) isset( $args['show_bar'] ) ? filter_var( $args['show_bar'], FILTER_VALIDATE_BOOLEAN ) : true; |
|
1214 | + $color = get_post_meta($form_id, '_give_goal_color', true); |
|
1215 | + $show_text = (bool) isset($args['show_text']) ? filter_var($args['show_text'], FILTER_VALIDATE_BOOLEAN) : true; |
|
1216 | + $show_bar = (bool) isset($args['show_bar']) ? filter_var($args['show_bar'], FILTER_VALIDATE_BOOLEAN) : true; |
|
1217 | 1217 | |
1218 | 1218 | //Sanity check - respect shortcode args |
1219 | - if ( isset( $args['show_goal'] ) && $args['show_goal'] === false ) { |
|
1219 | + if (isset($args['show_goal']) && $args['show_goal'] === false) { |
|
1220 | 1220 | return false; |
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | //Sanity check - ensure form has goal set to output |
1224 | - if ( empty( $form->ID ) |
|
1225 | - || ( is_singular( 'give_forms' ) && $goal_option !== 'yes' ) |
|
1224 | + if (empty($form->ID) |
|
1225 | + || (is_singular('give_forms') && $goal_option !== 'yes') |
|
1226 | 1226 | || $goal_option !== 'yes' |
1227 | 1227 | || $goal == 0 |
1228 | 1228 | ) { |
@@ -1230,26 +1230,26 @@ discard block |
||
1230 | 1230 | return false; |
1231 | 1231 | } |
1232 | 1232 | |
1233 | - $progress = round( ( $income / $goal ) * 100, 2 ); |
|
1233 | + $progress = round(($income / $goal) * 100, 2); |
|
1234 | 1234 | |
1235 | - if ( $income >= $goal ) { |
|
1235 | + if ($income >= $goal) { |
|
1236 | 1236 | $progress = 100; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | $output = '<div class="give-goal-progress">'; |
1240 | 1240 | |
1241 | 1241 | //Goal Progress Text |
1242 | - if ( ! empty( $show_text ) ) { |
|
1242 | + if ( ! empty($show_text)) { |
|
1243 | 1243 | |
1244 | 1244 | $output .= '<div class="raised">'; |
1245 | 1245 | |
1246 | - if ( $goal_format !== 'percentage' ) { |
|
1246 | + if ($goal_format !== 'percentage') { |
|
1247 | 1247 | |
1248 | - $output .= sprintf( _x( '%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give' ), '<span class="income">' . apply_filters( 'give_goal_amount_raised_output', give_currency_filter( give_format_amount( $income ) ) ) . '</span>', '<span class="goal-text">' . apply_filters( 'give_goal_amount_target_output', give_currency_filter( give_format_amount( $goal ) ) ) ) . '</span>'; |
|
1248 | + $output .= sprintf(_x('%s of %s raised', 'This text displays the amount of income raised compared to the goal.', 'give'), '<span class="income">'.apply_filters('give_goal_amount_raised_output', give_currency_filter(give_format_amount($income))).'</span>', '<span class="goal-text">'.apply_filters('give_goal_amount_target_output', give_currency_filter(give_format_amount($goal)))).'</span>'; |
|
1249 | 1249 | |
1250 | - } elseif ( $goal_format == 'percentage' ) { |
|
1250 | + } elseif ($goal_format == 'percentage') { |
|
1251 | 1251 | |
1252 | - $output .= sprintf( _x( '%s%% funded', 'This text displays the percentage amount of income raised compared to the goal target.', 'give' ), '<span class="give-percentage">' . apply_filters( 'give_goal_amount_funded_percentage_output', round( $progress ) ) . '</span>' ) . '</span>'; |
|
1252 | + $output .= sprintf(_x('%s%% funded', 'This text displays the percentage amount of income raised compared to the goal target.', 'give'), '<span class="give-percentage">'.apply_filters('give_goal_amount_funded_percentage_output', round($progress)).'</span>').'</span>'; |
|
1253 | 1253 | |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1258,11 +1258,11 @@ discard block |
||
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | //Goal Progress Bar |
1261 | - if ( ! empty( $show_bar ) ) { |
|
1261 | + if ( ! empty($show_bar)) { |
|
1262 | 1262 | $output .= '<div class="give-progress-bar">'; |
1263 | - $output .= '<span style="width: ' . esc_attr( $progress ) . '%;'; |
|
1264 | - if ( ! empty( $color ) ) { |
|
1265 | - $output .= 'background-color:' . $color; |
|
1263 | + $output .= '<span style="width: '.esc_attr($progress).'%;'; |
|
1264 | + if ( ! empty($color)) { |
|
1265 | + $output .= 'background-color:'.$color; |
|
1266 | 1266 | } |
1267 | 1267 | $output .= '"></span>'; |
1268 | 1268 | $output .= '</div><!-- /.give-progress-bar -->'; |
@@ -1270,13 +1270,13 @@ discard block |
||
1270 | 1270 | |
1271 | 1271 | $output .= '</div><!-- /.goal-progress -->'; |
1272 | 1272 | |
1273 | - echo apply_filters( 'give_goal_output', $output ); |
|
1273 | + echo apply_filters('give_goal_output', $output); |
|
1274 | 1274 | |
1275 | 1275 | return false; |
1276 | 1276 | |
1277 | 1277 | } |
1278 | 1278 | |
1279 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1279 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1280 | 1280 | |
1281 | 1281 | /** |
1282 | 1282 | * Renders Post Form Content |
@@ -1288,17 +1288,17 @@ discard block |
||
1288 | 1288 | * @return void |
1289 | 1289 | * @since 1.0 |
1290 | 1290 | */ |
1291 | -function give_form_display_content( $form_id ) { |
|
1291 | +function give_form_display_content($form_id) { |
|
1292 | 1292 | |
1293 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
1293 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
1294 | 1294 | |
1295 | - if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) { |
|
1296 | - $content = apply_filters( 'the_content', $content ); |
|
1295 | + if (give_get_option('disable_the_content_filter') !== 'on') { |
|
1296 | + $content = apply_filters('the_content', $content); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
1299 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
1300 | 1300 | |
1301 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1301 | + echo apply_filters('give_form_content_output', $output); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | |
@@ -1311,16 +1311,16 @@ discard block |
||
1311 | 1311 | * |
1312 | 1312 | * @return void |
1313 | 1313 | */ |
1314 | -function give_checkout_hidden_fields( $form_id ) { |
|
1314 | +function give_checkout_hidden_fields($form_id) { |
|
1315 | 1315 | |
1316 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1317 | - if ( is_user_logged_in() ) { ?> |
|
1316 | + do_action('give_hidden_fields_before', $form_id); |
|
1317 | + if (is_user_logged_in()) { ?> |
|
1318 | 1318 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1319 | 1319 | <?php } ?> |
1320 | 1320 | <input type="hidden" name="give_action" value="purchase"/> |
1321 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1321 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1322 | 1322 | <?php |
1323 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1323 | + do_action('give_hidden_fields_after', $form_id); |
|
1324 | 1324 | |
1325 | 1325 | } |
1326 | 1326 | |
@@ -1335,20 +1335,20 @@ discard block |
||
1335 | 1335 | * |
1336 | 1336 | * @return string $content Filtered content |
1337 | 1337 | */ |
1338 | -function give_filter_success_page_content( $content ) { |
|
1338 | +function give_filter_success_page_content($content) { |
|
1339 | 1339 | |
1340 | 1340 | global $give_options; |
1341 | 1341 | |
1342 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1343 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1344 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1342 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1343 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1344 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1345 | 1345 | } |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | return $content; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1351 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1352 | 1352 | |
1353 | 1353 | |
1354 | 1354 | /** |
@@ -1360,14 +1360,14 @@ discard block |
||
1360 | 1360 | |
1361 | 1361 | function give_test_mode_frontend_warning() { |
1362 | 1362 | |
1363 | - $test_mode = give_get_option( 'test_mode' ); |
|
1363 | + $test_mode = give_get_option('test_mode'); |
|
1364 | 1364 | |
1365 | - if ( $test_mode == 'on' ) { |
|
1366 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . __( 'Notice', 'give' ) . '</strong>: ' . esc_attr__( 'Test mode is enabled. While in test mode no live transactions are processed.', 'give' ) . '</p></div>'; |
|
1365 | + if ($test_mode == 'on') { |
|
1366 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.__('Notice', 'give').'</strong>: '.esc_attr__('Test mode is enabled. While in test mode no live transactions are processed.', 'give').'</p></div>'; |
|
1367 | 1367 | } |
1368 | 1368 | } |
1369 | 1369 | |
1370 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1370 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1371 | 1371 | |
1372 | 1372 | |
1373 | 1373 | /** |
@@ -1377,21 +1377,21 @@ discard block |
||
1377 | 1377 | * @since 1.4.1 |
1378 | 1378 | */ |
1379 | 1379 | |
1380 | -function give_members_only_form( $final_output, $args ) { |
|
1380 | +function give_members_only_form($final_output, $args) { |
|
1381 | 1381 | |
1382 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1382 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1383 | 1383 | |
1384 | 1384 | //Sanity Check: Must have form_id & not be logged in |
1385 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1385 | + if (empty($form_id) || is_user_logged_in()) { |
|
1386 | 1386 | return $final_output; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | //Logged in only and Register / Login set to none |
1390 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1390 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1391 | 1391 | |
1392 | - $final_output = give_output_error( __( 'Please login in order to complete your donation.', 'give' ), false ); |
|
1392 | + $final_output = give_output_error(__('Please login in order to complete your donation.', 'give'), false); |
|
1393 | 1393 | |
1394 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1394 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1395 | 1395 | |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1399,4 +1399,4 @@ discard block |
||
1399 | 1399 | |
1400 | 1400 | } |
1401 | 1401 | |
1402 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1403 | 1402 | \ No newline at end of file |
1403 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
1404 | 1404 | \ 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 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' && $typenow != 'give_campaigns' ) { |
|
26 | + if ($typenow != 'give_forms' && $typenow != 'give_campaigns') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled'; |
|
74 | + if (empty($float_labels)) { |
|
75 | + $float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled'; |
|
76 | 76 | } |
77 | 77 | |
78 | - return ( $float_labels == 'enabled' ) ? true : false; |
|
78 | + return ($float_labels == 'enabled') ? true : false; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $can_checkout = true; |
92 | 92 | |
93 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
93 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | function give_get_success_page_uri() { |
104 | 104 | global $give_options; |
105 | 105 | |
106 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
106 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
107 | 107 | |
108 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
108 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function give_is_success_page() { |
118 | 118 | global $give_options; |
119 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
119 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
120 | 120 | |
121 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
121 | + return apply_filters('give_is_success_page', $is_success_page); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | * @since 1.0 |
133 | 133 | * @return void |
134 | 134 | */ |
135 | -function give_send_to_success_page( $query_string = null ) { |
|
135 | +function give_send_to_success_page($query_string = null) { |
|
136 | 136 | |
137 | 137 | $redirect = give_get_success_page_uri(); |
138 | 138 | |
139 | - if ( $query_string ) { |
|
139 | + if ($query_string) { |
|
140 | 140 | $redirect .= $query_string; |
141 | 141 | } |
142 | 142 | |
143 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
143 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
144 | 144 | |
145 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
145 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
146 | 146 | give_die(); |
147 | 147 | } |
148 | 148 | |
@@ -159,25 +159,25 @@ discard block |
||
159 | 159 | * @since 1.0 |
160 | 160 | * @return Void |
161 | 161 | */ |
162 | -function give_send_back_to_checkout( $args = array() ) { |
|
162 | +function give_send_back_to_checkout($args = array()) { |
|
163 | 163 | |
164 | - $redirect = ( isset( $_POST['give-current-url'] ) ) ? $_POST['give-current-url'] : ''; |
|
165 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : 0; |
|
164 | + $redirect = (isset($_POST['give-current-url'])) ? $_POST['give-current-url'] : ''; |
|
165 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : 0; |
|
166 | 166 | |
167 | 167 | $defaults = array( |
168 | 168 | 'form-id' => (int) $form_id |
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Check for backward compatibility |
172 | - if ( is_string( $args ) ) { |
|
173 | - $args = str_replace( '?', '', $args ); |
|
172 | + if (is_string($args)) { |
|
173 | + $args = str_replace('?', '', $args); |
|
174 | 174 | } |
175 | 175 | |
176 | - $args = wp_parse_args( $args, $defaults ); |
|
176 | + $args = wp_parse_args($args, $defaults); |
|
177 | 177 | |
178 | - $redirect = add_query_arg( $args, $redirect ) . '#give-form-' . $form_id . '-wrap'; |
|
178 | + $redirect = add_query_arg($args, $redirect).'#give-form-'.$form_id.'-wrap'; |
|
179 | 179 | |
180 | - wp_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
180 | + wp_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
@@ -192,16 +192,16 @@ discard block |
||
192 | 192 | * @since 1.0 |
193 | 193 | * @return string |
194 | 194 | */ |
195 | -function give_get_success_page_url( $query_string = null ) { |
|
195 | +function give_get_success_page_url($query_string = null) { |
|
196 | 196 | |
197 | - $success_page = give_get_option( 'success_page', 0 ); |
|
198 | - $success_page = get_permalink( $success_page ); |
|
197 | + $success_page = give_get_option('success_page', 0); |
|
198 | + $success_page = get_permalink($success_page); |
|
199 | 199 | |
200 | - if ( $query_string ) { |
|
200 | + if ($query_string) { |
|
201 | 201 | $success_page .= $query_string; |
202 | 202 | } |
203 | 203 | |
204 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
204 | + return apply_filters('give_success_page_url', $success_page); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist |
217 | 217 | */ |
218 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
218 | +function give_get_failed_transaction_uri($extras = false) { |
|
219 | 219 | global $give_options; |
220 | 220 | |
221 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
222 | - if ( $extras ) { |
|
221 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
222 | + if ($extras) { |
|
223 | 223 | $uri .= $extras; |
224 | 224 | } |
225 | 225 | |
226 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
226 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | */ |
235 | 235 | function give_is_failed_transaction_page() { |
236 | 236 | global $give_options; |
237 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
237 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
238 | 238 | |
239 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
239 | + return apply_filters('give_is_failure_page', $ret); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | */ |
249 | 249 | function give_listen_for_failed_payments() { |
250 | 250 | |
251 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
251 | + $failed_page = give_get_option('failure_page', 0); |
|
252 | 252 | |
253 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
253 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
254 | 254 | |
255 | - $payment_id = absint( $_GET['payment-id'] ); |
|
256 | - give_update_payment_status( $payment_id, 'failed' ); |
|
255 | + $payment_id = absint($_GET['payment-id']); |
|
256 | + give_update_payment_status($payment_id, 'failed'); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
262 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | /** |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | * @since 1.0 |
273 | 273 | * @return bool |
274 | 274 | */ |
275 | -function give_field_is_required( $field = '', $form_id ) { |
|
275 | +function give_field_is_required($field = '', $form_id) { |
|
276 | 276 | |
277 | - $required_fields = give_purchase_form_required_fields( $form_id ); |
|
277 | + $required_fields = give_purchase_form_required_fields($form_id); |
|
278 | 278 | |
279 | - return array_key_exists( $field, $required_fields ); |
|
279 | + return array_key_exists($field, $required_fields); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return void |
296 | 296 | */ |
297 | -function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) { |
|
297 | +function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) { |
|
298 | 298 | global $give_logs; |
299 | 299 | |
300 | 300 | $log_data = array( |
301 | 301 | 'post_parent' => $give_form_id, |
302 | 302 | 'log_type' => 'sale', |
303 | - 'post_date' => isset( $sale_date ) ? $sale_date : null, |
|
304 | - 'post_date_gmt' => isset( $sale_date ) ? $sale_date : null |
|
303 | + 'post_date' => isset($sale_date) ? $sale_date : null, |
|
304 | + 'post_date_gmt' => isset($sale_date) ? $sale_date : null |
|
305 | 305 | ); |
306 | 306 | |
307 | 307 | $log_meta = array( |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | 'price_id' => (int) $price_id |
310 | 310 | ); |
311 | 311 | |
312 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
312 | + $give_logs->insert_log($log_data, $log_meta); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return bool|int |
325 | 325 | */ |
326 | -function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
326 | +function give_increase_purchase_count($form_id = 0, $quantity = 1) { |
|
327 | 327 | $quantity = (int) $quantity; |
328 | - $form = new Give_Donate_Form( $form_id ); |
|
328 | + $form = new Give_Donate_Form($form_id); |
|
329 | 329 | |
330 | - return $form->increase_sales( $quantity ); |
|
330 | + return $form->increase_sales($quantity); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return bool|int |
342 | 342 | */ |
343 | -function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) { |
|
343 | +function give_decrease_purchase_count($form_id = 0, $quantity = 1) { |
|
344 | 344 | $quantity = (int) $quantity; |
345 | - $form = new Give_Donate_Form( $form_id ); |
|
345 | + $form = new Give_Donate_Form($form_id); |
|
346 | 346 | |
347 | - return $form->decrease_sales( $quantity ); |
|
347 | + return $form->decrease_sales($quantity); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return bool|int |
359 | 359 | */ |
360 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
361 | - $form = new Give_Donate_Form( $give_form_id ); |
|
360 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
361 | + $form = new Give_Donate_Form($give_form_id); |
|
362 | 362 | |
363 | - return $form->increase_earnings( $amount ); |
|
363 | + return $form->increase_earnings($amount); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|int |
375 | 375 | */ |
376 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
377 | - $form = new Give_Donate_Form( $form_id ); |
|
376 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
377 | + $form = new Give_Donate_Form($form_id); |
|
378 | 378 | |
379 | - return $form->decrease_earnings( $amount ); |
|
379 | + return $form->decrease_earnings($amount); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return int $earnings Earnings for a certain form |
391 | 391 | */ |
392 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
393 | - $give_form = new Give_Donate_Form( $form_id ); |
|
392 | +function give_get_form_earnings_stats($form_id = 0) { |
|
393 | + $give_form = new Give_Donate_Form($form_id); |
|
394 | 394 | |
395 | 395 | return $give_form->earnings; |
396 | 396 | } |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return int $sales Amount of sales for a certain form |
407 | 407 | */ |
408 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
409 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
408 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
409 | + $give_form = new Give_Donate_Form($give_form_id); |
|
410 | 410 | |
411 | 411 | return $give_form->sales; |
412 | 412 | } |
@@ -421,16 +421,16 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return float $sales Average monthly sales |
423 | 423 | */ |
424 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
425 | - $sales = give_get_form_sales_stats( $form_id ); |
|
426 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
424 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
425 | + $sales = give_get_form_sales_stats($form_id); |
|
426 | + $release_date = get_post_field('post_date', $form_id); |
|
427 | 427 | |
428 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
428 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
429 | 429 | |
430 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
430 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
431 | 431 | |
432 | - if ( $months > 0 ) { |
|
433 | - $sales = ( $sales / $months ); |
|
432 | + if ($months > 0) { |
|
433 | + $sales = ($sales / $months); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | return $sales; |
@@ -446,16 +446,16 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return float $earnings Average monthly earnings |
448 | 448 | */ |
449 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
450 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
451 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
449 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
450 | + $earnings = give_get_form_earnings_stats($form_id); |
|
451 | + $release_date = get_post_field('post_date', $form_id); |
|
452 | 452 | |
453 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
453 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
454 | 454 | |
455 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
455 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
456 | 456 | |
457 | - if ( $months > 0 ) { |
|
458 | - $earnings = ( $earnings / $months ); |
|
457 | + if ($months > 0) { |
|
458 | + $earnings = ($earnings / $months); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | return $earnings < 0 ? 0 : $earnings; |
@@ -475,25 +475,25 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return string $price_name Name of the price option |
477 | 477 | */ |
478 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
478 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
479 | 479 | |
480 | - $prices = give_get_variable_prices( $form_id ); |
|
480 | + $prices = give_get_variable_prices($form_id); |
|
481 | 481 | $price_name = ''; |
482 | 482 | |
483 | - foreach ( $prices as $price ) { |
|
483 | + foreach ($prices as $price) { |
|
484 | 484 | |
485 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
485 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
486 | 486 | |
487 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
488 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
489 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
487 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
488 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount'])); |
|
489 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
490 | 490 | |
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | 495 | |
496 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
496 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string $range A fully formatted price range |
508 | 508 | */ |
509 | -function give_price_range( $form_id = 0 ) { |
|
510 | - $low = give_get_lowest_price_option( $form_id ); |
|
511 | - $high = give_get_highest_price_option( $form_id ); |
|
512 | - $range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>'; |
|
509 | +function give_price_range($form_id = 0) { |
|
510 | + $low = give_get_lowest_price_option($form_id); |
|
511 | + $high = give_get_highest_price_option($form_id); |
|
512 | + $range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>'; |
|
513 | 513 | $range .= '<span class="give_price_range_sep"> – </span>'; |
514 | - $range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>'; |
|
514 | + $range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>'; |
|
515 | 515 | |
516 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
516 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | |
@@ -528,36 +528,36 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return int ID of the lowest price |
530 | 530 | */ |
531 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
531 | +function give_get_lowest_price_id($form_id = 0) { |
|
532 | 532 | |
533 | - if ( empty( $form_id ) ) { |
|
533 | + if (empty($form_id)) { |
|
534 | 534 | $form_id = get_the_ID(); |
535 | 535 | } |
536 | 536 | |
537 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
538 | - return give_get_form_price( $form_id ); |
|
537 | + if ( ! give_has_variable_prices($form_id)) { |
|
538 | + return give_get_form_price($form_id); |
|
539 | 539 | } |
540 | 540 | |
541 | - $prices = give_get_variable_prices( $form_id ); |
|
541 | + $prices = give_get_variable_prices($form_id); |
|
542 | 542 | |
543 | 543 | $low = 0.00; |
544 | 544 | $min_id = 1; |
545 | 545 | |
546 | - if ( ! empty( $prices ) ) { |
|
546 | + if ( ! empty($prices)) { |
|
547 | 547 | |
548 | - foreach ( $prices as $key => $price ) { |
|
548 | + foreach ($prices as $key => $price) { |
|
549 | 549 | |
550 | - if ( empty( $price['_give_amount'] ) ) { |
|
550 | + if (empty($price['_give_amount'])) { |
|
551 | 551 | continue; |
552 | 552 | } |
553 | 553 | |
554 | - if ( ! isset( $min ) ) { |
|
554 | + if ( ! isset($min)) { |
|
555 | 555 | $min = $price['_give_amount']; |
556 | 556 | } else { |
557 | - $min = min( $min, $price['_give_amount'] ); |
|
557 | + $min = min($min, $price['_give_amount']); |
|
558 | 558 | } |
559 | 559 | |
560 | - if ( $price['_give_amount'] == $min ) { |
|
560 | + if ($price['_give_amount'] == $min) { |
|
561 | 561 | $min_id = $price['_give_id']['level_id']; |
562 | 562 | } |
563 | 563 | } |
@@ -575,43 +575,43 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return float Amount of the lowest price |
577 | 577 | */ |
578 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
579 | - if ( empty( $form_id ) ) { |
|
578 | +function give_get_lowest_price_option($form_id = 0) { |
|
579 | + if (empty($form_id)) { |
|
580 | 580 | $form_id = get_the_ID(); |
581 | 581 | } |
582 | 582 | |
583 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
584 | - return give_get_form_price( $form_id ); |
|
583 | + if ( ! give_has_variable_prices($form_id)) { |
|
584 | + return give_get_form_price($form_id); |
|
585 | 585 | } |
586 | 586 | |
587 | - $prices = give_get_variable_prices( $form_id ); |
|
587 | + $prices = give_get_variable_prices($form_id); |
|
588 | 588 | |
589 | 589 | $low = 0.00; |
590 | 590 | |
591 | - if ( ! empty( $prices ) ) { |
|
591 | + if ( ! empty($prices)) { |
|
592 | 592 | |
593 | - foreach ( $prices as $key => $price ) { |
|
593 | + foreach ($prices as $key => $price) { |
|
594 | 594 | |
595 | - if ( empty( $price['_give_amount'] ) ) { |
|
595 | + if (empty($price['_give_amount'])) { |
|
596 | 596 | continue; |
597 | 597 | } |
598 | 598 | |
599 | - if ( ! isset( $min ) ) { |
|
599 | + if ( ! isset($min)) { |
|
600 | 600 | $min = $price['_give_amount']; |
601 | 601 | } else { |
602 | - $min = min( $min, give_sanitize_amount( $price['_give_amount'] ) ); |
|
602 | + $min = min($min, give_sanitize_amount($price['_give_amount'])); |
|
603 | 603 | } |
604 | 604 | |
605 | - if ( $price['_give_amount'] == $min ) { |
|
605 | + if ($price['_give_amount'] == $min) { |
|
606 | 606 | $min_id = $key; |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - $low = $prices[ $min_id ]['_give_amount']; |
|
610 | + $low = $prices[$min_id]['_give_amount']; |
|
611 | 611 | |
612 | 612 | } |
613 | 613 | |
614 | - return give_sanitize_amount( $low ); |
|
614 | + return give_sanitize_amount($low); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -623,41 +623,41 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @return float Amount of the highest price |
625 | 625 | */ |
626 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
626 | +function give_get_highest_price_option($form_id = 0) { |
|
627 | 627 | |
628 | - if ( empty( $form_id ) ) { |
|
628 | + if (empty($form_id)) { |
|
629 | 629 | $form_id = get_the_ID(); |
630 | 630 | } |
631 | 631 | |
632 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
633 | - return give_get_form_price( $form_id ); |
|
632 | + if ( ! give_has_variable_prices($form_id)) { |
|
633 | + return give_get_form_price($form_id); |
|
634 | 634 | } |
635 | 635 | |
636 | - $prices = give_get_variable_prices( $form_id ); |
|
636 | + $prices = give_get_variable_prices($form_id); |
|
637 | 637 | |
638 | 638 | $high = 0.00; |
639 | 639 | |
640 | - if ( ! empty( $prices ) ) { |
|
640 | + if ( ! empty($prices)) { |
|
641 | 641 | |
642 | 642 | $max = 0; |
643 | 643 | |
644 | - foreach ( $prices as $key => $price ) { |
|
645 | - if ( empty( $price['_give_amount'] ) ) { |
|
644 | + foreach ($prices as $key => $price) { |
|
645 | + if (empty($price['_give_amount'])) { |
|
646 | 646 | continue; |
647 | 647 | } |
648 | - $give_amount = give_sanitize_amount( $price['_give_amount'] ); |
|
648 | + $give_amount = give_sanitize_amount($price['_give_amount']); |
|
649 | 649 | |
650 | - $max = max( $max, $give_amount ); |
|
650 | + $max = max($max, $give_amount); |
|
651 | 651 | |
652 | - if ( $give_amount == $max ) { |
|
652 | + if ($give_amount == $max) { |
|
653 | 653 | $max_id = $key; |
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | - $high = $prices[ $max_id ]['_give_amount']; |
|
657 | + $high = $prices[$max_id]['_give_amount']; |
|
658 | 658 | } |
659 | 659 | |
660 | - return give_sanitize_amount( $high ); |
|
660 | + return give_sanitize_amount($high); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -669,15 +669,15 @@ discard block |
||
669 | 669 | * |
670 | 670 | * @return mixed string|int Price of the form |
671 | 671 | */ |
672 | -function give_get_form_price( $form_id = 0 ) { |
|
672 | +function give_get_form_price($form_id = 0) { |
|
673 | 673 | |
674 | - if ( empty( $form_id ) ) { |
|
674 | + if (empty($form_id)) { |
|
675 | 675 | return false; |
676 | 676 | } |
677 | 677 | |
678 | - $form = new Give_Donate_Form( $form_id ); |
|
678 | + $form = new Give_Donate_Form($form_id); |
|
679 | 679 | |
680 | - return $form->__get( 'price' ); |
|
680 | + return $form->__get('price'); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -689,15 +689,15 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @return mixed string|int Minimum price of the form |
691 | 691 | */ |
692 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
692 | +function give_get_form_minimum_price($form_id = 0) { |
|
693 | 693 | |
694 | - if ( empty( $form_id ) ) { |
|
694 | + if (empty($form_id)) { |
|
695 | 695 | return false; |
696 | 696 | } |
697 | 697 | |
698 | - $form = new Give_Donate_Form( $form_id ); |
|
698 | + $form = new Give_Donate_Form($form_id); |
|
699 | 699 | |
700 | - return $form->__get( 'minimum_price' ); |
|
700 | + return $form->__get('minimum_price'); |
|
701 | 701 | |
702 | 702 | } |
703 | 703 | |
@@ -712,52 +712,52 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @return int $formatted_price |
714 | 714 | */ |
715 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
715 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
716 | 716 | |
717 | - if ( empty( $form_id ) ) { |
|
717 | + if (empty($form_id)) { |
|
718 | 718 | $form_id = get_the_ID(); |
719 | 719 | } |
720 | 720 | |
721 | - if ( give_has_variable_prices( $form_id ) ) { |
|
721 | + if (give_has_variable_prices($form_id)) { |
|
722 | 722 | |
723 | - $prices = give_get_variable_prices( $form_id ); |
|
723 | + $prices = give_get_variable_prices($form_id); |
|
724 | 724 | |
725 | - if ( false !== $price_id ) { |
|
725 | + if (false !== $price_id) { |
|
726 | 726 | |
727 | 727 | //loop through multi-prices to see which is default |
728 | - foreach ( $prices as $price ) { |
|
728 | + foreach ($prices as $price) { |
|
729 | 729 | //this is the default price |
730 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
730 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
731 | 731 | $price = (float) $price['_give_amount']; |
732 | 732 | }; |
733 | 733 | } |
734 | 734 | |
735 | 735 | } else { |
736 | 736 | |
737 | - $price = give_get_lowest_price_option( $form_id ); |
|
737 | + $price = give_get_lowest_price_option($form_id); |
|
738 | 738 | } |
739 | 739 | |
740 | - $price = give_sanitize_amount( $price ); |
|
740 | + $price = give_sanitize_amount($price); |
|
741 | 741 | |
742 | 742 | } else { |
743 | 743 | |
744 | - $price = give_get_form_price( $form_id ); |
|
744 | + $price = give_get_form_price($form_id); |
|
745 | 745 | |
746 | 746 | } |
747 | 747 | |
748 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
749 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
750 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
748 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
749 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
750 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
751 | 751 | |
752 | - if ( $echo ) { |
|
752 | + if ($echo) { |
|
753 | 753 | echo $formatted_price; |
754 | 754 | } else { |
755 | 755 | return $formatted_price; |
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
759 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
760 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
759 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
760 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
761 | 761 | |
762 | 762 | |
763 | 763 | /** |
@@ -771,18 +771,18 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @return float $amount Amount of the price option |
773 | 773 | */ |
774 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
775 | - $prices = give_get_variable_prices( $form_id ); |
|
774 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
775 | + $prices = give_get_variable_prices($form_id); |
|
776 | 776 | |
777 | 777 | $amount = 0.00; |
778 | 778 | |
779 | - foreach ( $prices as $price ) { |
|
780 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] === $price_id ) { |
|
781 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
779 | + foreach ($prices as $price) { |
|
780 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] === $price_id) { |
|
781 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
782 | 782 | }; |
783 | 783 | } |
784 | 784 | |
785 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
785 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | * |
795 | 795 | * @return mixed string|int Goal of the form |
796 | 796 | */ |
797 | -function give_get_form_goal( $form_id = 0 ) { |
|
797 | +function give_get_form_goal($form_id = 0) { |
|
798 | 798 | |
799 | - if ( empty( $form_id ) ) { |
|
799 | + if (empty($form_id)) { |
|
800 | 800 | return false; |
801 | 801 | } |
802 | 802 | |
803 | - $form = new Give_Donate_Form( $form_id ); |
|
803 | + $form = new Give_Donate_Form($form_id); |
|
804 | 804 | |
805 | 805 | return $form->goal; |
806 | 806 | |
@@ -816,27 +816,27 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @return string $formatted_goal |
818 | 818 | */ |
819 | -function give_goal( $form_id = 0, $echo = true ) { |
|
819 | +function give_goal($form_id = 0, $echo = true) { |
|
820 | 820 | |
821 | - if ( empty( $form_id ) ) { |
|
821 | + if (empty($form_id)) { |
|
822 | 822 | $form_id = get_the_ID(); |
823 | 823 | } |
824 | 824 | |
825 | - $goal = give_get_form_goal( $form_id ); |
|
825 | + $goal = give_get_form_goal($form_id); |
|
826 | 826 | |
827 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
828 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
829 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
827 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
828 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
829 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
830 | 830 | |
831 | - if ( $echo ) { |
|
831 | + if ($echo) { |
|
832 | 832 | echo $formatted_goal; |
833 | 833 | } else { |
834 | 834 | return $formatted_goal; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | |
838 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
839 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
838 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
839 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
840 | 840 | |
841 | 841 | |
842 | 842 | /** |
@@ -846,13 +846,13 @@ discard block |
||
846 | 846 | * @global $give_options |
847 | 847 | * @return bool $ret Whether or not the logged_in_only setting is set |
848 | 848 | */ |
849 | -function give_logged_in_only( $form_id ) { |
|
849 | +function give_logged_in_only($form_id) { |
|
850 | 850 | |
851 | - $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
851 | + $form_option = get_post_meta($form_id, '_give_logged_in_only', true); |
|
852 | 852 | |
853 | - $ret = ! empty( $form_option ) ? $form_option : false; |
|
853 | + $ret = ! empty($form_option) ? $form_option : false; |
|
854 | 854 | |
855 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
855 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
856 | 856 | |
857 | 857 | } |
858 | 858 | |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @param $form_id |
866 | 866 | */ |
867 | -function give_show_login_register_option( $form_id ) { |
|
867 | +function give_show_login_register_option($form_id) { |
|
868 | 868 | |
869 | - $show_register_form = get_post_meta( $form_id, '_give_show_register_form', true ); |
|
869 | + $show_register_form = get_post_meta($form_id, '_give_show_register_form', true); |
|
870 | 870 | |
871 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
871 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
872 | 872 | |
873 | 873 | } |
874 | 874 | \ No newline at end of file |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function get_predefined_dates() { |
78 | 78 | $predefined = array( |
79 | - 'today' => __( 'Today', 'give' ), |
|
80 | - 'yesterday' => __( 'Yesterday', 'give' ), |
|
81 | - 'this_week' => __( 'This Week', 'give' ), |
|
82 | - 'last_week' => __( 'Last Week', 'give' ), |
|
83 | - 'this_month' => __( 'This Month', 'give' ), |
|
84 | - 'last_month' => __( 'Last Month', 'give' ), |
|
85 | - 'this_quarter' => __( 'This Quarter', 'give' ), |
|
86 | - 'last_quarter' => __( 'Last Quarter', 'give' ), |
|
87 | - 'this_year' => __( 'This Year', 'give' ), |
|
88 | - 'last_year' => __( 'Last Year', 'give' ) |
|
79 | + 'today' => __('Today', 'give'), |
|
80 | + 'yesterday' => __('Yesterday', 'give'), |
|
81 | + 'this_week' => __('This Week', 'give'), |
|
82 | + 'last_week' => __('Last Week', 'give'), |
|
83 | + 'this_month' => __('This Month', 'give'), |
|
84 | + 'last_month' => __('Last Month', 'give'), |
|
85 | + 'this_quarter' => __('This Quarter', 'give'), |
|
86 | + 'last_quarter' => __('Last Quarter', 'give'), |
|
87 | + 'this_year' => __('This Year', 'give'), |
|
88 | + 'last_year' => __('Last Year', 'give') |
|
89 | 89 | ); |
90 | 90 | |
91 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
91 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
107 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
108 | 108 | |
109 | - if ( empty( $_start_date ) ) { |
|
109 | + if (empty($_start_date)) { |
|
110 | 110 | $_start_date = 'this_month'; |
111 | 111 | } |
112 | 112 | |
113 | - if ( empty( $_end_date ) ) { |
|
113 | + if (empty($_end_date)) { |
|
114 | 114 | $_end_date = $_start_date; |
115 | 115 | } |
116 | 116 | |
117 | - $this->start_date = $this->convert_date( $_start_date ); |
|
118 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
117 | + $this->start_date = $this->convert_date($_start_date); |
|
118 | + $this->end_date = $this->convert_date($_end_date, true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,26 +125,26 @@ discard block |
||
125 | 125 | * @since 1.0 |
126 | 126 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned |
127 | 127 | */ |
128 | - public function convert_date( $date, $end_date = false ) { |
|
128 | + public function convert_date($date, $end_date = false) { |
|
129 | 129 | |
130 | 130 | $this->timestamp = false; |
131 | 131 | $second = $end_date ? 59 : 0; |
132 | 132 | $minute = $end_date ? 59 : 0; |
133 | 133 | $hour = $end_date ? 23 : 0; |
134 | 134 | $day = 1; |
135 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
136 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
135 | + $month = date('n', current_time('timestamp')); |
|
136 | + $year = date('Y', current_time('timestamp')); |
|
137 | 137 | |
138 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
138 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
139 | 139 | |
140 | 140 | // This is a predefined date rate, such as last_week |
141 | - switch ( $date ) { |
|
141 | + switch ($date) { |
|
142 | 142 | |
143 | 143 | case 'this_month' : |
144 | 144 | |
145 | - if ( $end_date ) { |
|
145 | + if ($end_date) { |
|
146 | 146 | |
147 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
147 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
148 | 148 | $hour = 23; |
149 | 149 | $minute = 59; |
150 | 150 | $second = 59; |
@@ -154,28 +154,28 @@ discard block |
||
154 | 154 | |
155 | 155 | case 'last_month' : |
156 | 156 | |
157 | - if ( $month == 1 ) { |
|
157 | + if ($month == 1) { |
|
158 | 158 | |
159 | 159 | $month = 12; |
160 | - $year --; |
|
160 | + $year--; |
|
161 | 161 | |
162 | 162 | } else { |
163 | 163 | |
164 | - $month --; |
|
164 | + $month--; |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | - if ( $end_date ) { |
|
169 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
168 | + if ($end_date) { |
|
169 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | break; |
173 | 173 | |
174 | 174 | case 'today' : |
175 | 175 | |
176 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
176 | + $day = date('d', current_time('timestamp')); |
|
177 | 177 | |
178 | - if ( $end_date ) { |
|
178 | + if ($end_date) { |
|
179 | 179 | $hour = 23; |
180 | 180 | $minute = 59; |
181 | 181 | $second = 59; |
@@ -185,23 +185,23 @@ discard block |
||
185 | 185 | |
186 | 186 | case 'yesterday' : |
187 | 187 | |
188 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
188 | + $day = date('d', current_time('timestamp')) - 1; |
|
189 | 189 | |
190 | 190 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
191 | - if ( $day < 1 ) { |
|
191 | + if ($day < 1) { |
|
192 | 192 | |
193 | 193 | // If current month is 1 |
194 | - if ( 1 == $month ) { |
|
194 | + if (1 == $month) { |
|
195 | 195 | |
196 | 196 | $year -= 1; // Today is January 1, so skip back to last day of December |
197 | 197 | $month = 12; |
198 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
198 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
199 | 199 | |
200 | 200 | } else { |
201 | 201 | |
202 | 202 | // Go back one month and get the last day of the month |
203 | 203 | $month -= 1; |
204 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
204 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | |
211 | 211 | case 'this_week' : |
212 | 212 | |
213 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
214 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
213 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
214 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
215 | 215 | |
216 | - if ( $today < $days_to_week_start ) { |
|
216 | + if ($today < $days_to_week_start) { |
|
217 | 217 | |
218 | - if ( $month > 1 ) { |
|
218 | + if ($month > 1) { |
|
219 | 219 | $month -= 1; |
220 | 220 | } else { |
221 | 221 | $month = 12; |
@@ -223,19 +223,19 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( ! $end_date ) { |
|
226 | + if ( ! $end_date) { |
|
227 | 227 | |
228 | 228 | // Getting the start day |
229 | 229 | |
230 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
231 | - $day += get_option( 'start_of_week' ); |
|
230 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
231 | + $day += get_option('start_of_week'); |
|
232 | 232 | |
233 | 233 | } else { |
234 | 234 | |
235 | 235 | // Getting the end day |
236 | 236 | |
237 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
238 | - $day += get_option( 'start_of_week' ) + 6; |
|
237 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
238 | + $day += get_option('start_of_week') + 6; |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | |
244 | 244 | case 'last_week' : |
245 | 245 | |
246 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
247 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
246 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
247 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
248 | 248 | |
249 | - if ( $today < $days_to_week_start ) { |
|
249 | + if ($today < $days_to_week_start) { |
|
250 | 250 | |
251 | - if ( $month > 1 ) { |
|
251 | + if ($month > 1) { |
|
252 | 252 | $month -= 1; |
253 | 253 | } else { |
254 | 254 | $month = 12; |
@@ -256,19 +256,19 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $end_date ) { |
|
259 | + if ( ! $end_date) { |
|
260 | 260 | |
261 | 261 | // Getting the start day |
262 | 262 | |
263 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
264 | - $day += get_option( 'start_of_week' ); |
|
263 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
264 | + $day += get_option('start_of_week'); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
268 | 268 | // Getting the end day |
269 | 269 | |
270 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
271 | - $day += get_option( 'start_of_week' ) + 6; |
|
270 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
271 | + $day += get_option('start_of_week') + 6; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -276,39 +276,39 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'this_quarter' : |
278 | 278 | |
279 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
279 | + $month_now = date('n', current_time('timestamp')); |
|
280 | 280 | |
281 | - if ( $month_now <= 3 ) { |
|
281 | + if ($month_now <= 3) { |
|
282 | 282 | |
283 | - if ( ! $end_date ) { |
|
283 | + if ( ! $end_date) { |
|
284 | 284 | $month = 1; |
285 | 285 | } else { |
286 | 286 | $month = 3; |
287 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
287 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
288 | 288 | $hour = 23; |
289 | 289 | $minute = 59; |
290 | 290 | $second = 59; |
291 | 291 | } |
292 | 292 | |
293 | - } else if ( $month_now <= 6 ) { |
|
293 | + } else if ($month_now <= 6) { |
|
294 | 294 | |
295 | - if ( ! $end_date ) { |
|
295 | + if ( ! $end_date) { |
|
296 | 296 | $month = 4; |
297 | 297 | } else { |
298 | 298 | $month = 6; |
299 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
299 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
300 | 300 | $hour = 23; |
301 | 301 | $minute = 59; |
302 | 302 | $second = 59; |
303 | 303 | } |
304 | 304 | |
305 | - } else if ( $month_now <= 9 ) { |
|
305 | + } else if ($month_now <= 9) { |
|
306 | 306 | |
307 | - if ( ! $end_date ) { |
|
307 | + if ( ! $end_date) { |
|
308 | 308 | $month = 7; |
309 | 309 | } else { |
310 | 310 | $month = 9; |
311 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
311 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
312 | 312 | $hour = 23; |
313 | 313 | $minute = 59; |
314 | 314 | $second = 59; |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | |
317 | 317 | } else { |
318 | 318 | |
319 | - if ( ! $end_date ) { |
|
319 | + if ( ! $end_date) { |
|
320 | 320 | $month = 10; |
321 | 321 | } else { |
322 | 322 | $month = 12; |
323 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
323 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
324 | 324 | $hour = 23; |
325 | 325 | $minute = 59; |
326 | 326 | $second = 59; |
@@ -332,40 +332,40 @@ discard block |
||
332 | 332 | |
333 | 333 | case 'last_quarter' : |
334 | 334 | |
335 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
335 | + $month_now = date('n', current_time('timestamp')); |
|
336 | 336 | |
337 | - if ( $month_now <= 3 ) { |
|
337 | + if ($month_now <= 3) { |
|
338 | 338 | |
339 | - if ( ! $end_date ) { |
|
339 | + if ( ! $end_date) { |
|
340 | 340 | $month = 10; |
341 | 341 | } else { |
342 | 342 | $year -= 1; |
343 | 343 | $month = 12; |
344 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
344 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
345 | 345 | $hour = 23; |
346 | 346 | $minute = 59; |
347 | 347 | $second = 59; |
348 | 348 | } |
349 | 349 | |
350 | - } else if ( $month_now <= 6 ) { |
|
350 | + } else if ($month_now <= 6) { |
|
351 | 351 | |
352 | - if ( ! $end_date ) { |
|
352 | + if ( ! $end_date) { |
|
353 | 353 | $month = 1; |
354 | 354 | } else { |
355 | 355 | $month = 3; |
356 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
356 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
357 | 357 | $hour = 23; |
358 | 358 | $minute = 59; |
359 | 359 | $second = 59; |
360 | 360 | } |
361 | 361 | |
362 | - } else if ( $month_now <= 9 ) { |
|
362 | + } else if ($month_now <= 9) { |
|
363 | 363 | |
364 | - if ( ! $end_date ) { |
|
364 | + if ( ! $end_date) { |
|
365 | 365 | $month = 4; |
366 | 366 | } else { |
367 | 367 | $month = 6; |
368 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
368 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
369 | 369 | $hour = 23; |
370 | 370 | $minute = 59; |
371 | 371 | $second = 59; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | |
374 | 374 | } else { |
375 | 375 | |
376 | - if ( ! $end_date ) { |
|
376 | + if ( ! $end_date) { |
|
377 | 377 | $month = 7; |
378 | 378 | } else { |
379 | 379 | $month = 9; |
380 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
380 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
381 | 381 | $hour = 23; |
382 | 382 | $minute = 59; |
383 | 383 | $second = 59; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | |
390 | 390 | case 'this_year' : |
391 | 391 | |
392 | - if ( ! $end_date ) { |
|
392 | + if ( ! $end_date) { |
|
393 | 393 | $month = 1; |
394 | 394 | } else { |
395 | 395 | $month = 12; |
396 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
396 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
397 | 397 | $hour = 23; |
398 | 398 | $minute = 59; |
399 | 399 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | case 'last_year' : |
405 | 405 | |
406 | 406 | $year -= 1; |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | - } else if ( is_numeric( $date ) ) { |
|
422 | + } else if (is_numeric($date)) { |
|
423 | 423 | |
424 | 424 | // return $date unchanged since it is a timestamp |
425 | 425 | $this->timestamp = true; |
426 | 426 | |
427 | - } else if ( false !== strtotime( $date ) ) { |
|
427 | + } else if (false !== strtotime($date)) { |
|
428 | 428 | |
429 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
430 | - $year = date( 'Y', $date ); |
|
431 | - $month = date( 'm', $date ); |
|
432 | - $day = date( 'd', $date ); |
|
429 | + $date = strtotime($date, current_time('timestamp')); |
|
430 | + $year = date('Y', $date); |
|
431 | + $month = date('m', $date); |
|
432 | + $day = date('d', $date); |
|
433 | 433 | |
434 | 434 | } else { |
435 | 435 | |
436 | - return new WP_Error( 'invalid_date', __( 'Improper date provided.', 'give' ) ); |
|
436 | + return new WP_Error('invalid_date', __('Improper date provided.', 'give')); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | - if ( false === $this->timestamp ) { |
|
440 | + if (false === $this->timestamp) { |
|
441 | 441 | // Create an exact timestamp |
442 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
442 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
443 | 443 | } |
444 | 444 | |
445 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
445 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -453,33 +453,33 @@ discard block |
||
453 | 453 | * @since 1.0 |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function count_where( $where = '' ) { |
|
456 | + public function count_where($where = '') { |
|
457 | 457 | // Only get payments in our date range |
458 | 458 | |
459 | 459 | $start_where = ''; |
460 | 460 | $end_where = ''; |
461 | 461 | |
462 | - if ( $this->start_date ) { |
|
462 | + if ($this->start_date) { |
|
463 | 463 | |
464 | - if ( $this->timestamp ) { |
|
464 | + if ($this->timestamp) { |
|
465 | 465 | $format = 'Y-m-d H:i:s'; |
466 | 466 | } else { |
467 | 467 | $format = 'Y-m-d 00:00:00'; |
468 | 468 | } |
469 | 469 | |
470 | - $start_date = date( $format, $this->start_date ); |
|
470 | + $start_date = date($format, $this->start_date); |
|
471 | 471 | $start_where = " AND p.post_date >= '{$start_date}'"; |
472 | 472 | } |
473 | 473 | |
474 | - if ( $this->end_date ) { |
|
474 | + if ($this->end_date) { |
|
475 | 475 | |
476 | - if ( $this->timestamp ) { |
|
476 | + if ($this->timestamp) { |
|
477 | 477 | $format = 'Y-m-d H:i:s'; |
478 | 478 | } else { |
479 | 479 | $format = 'Y-m-d 23:59:59'; |
480 | 480 | } |
481 | 481 | |
482 | - $end_date = date( $format, $this->end_date ); |
|
482 | + $end_date = date($format, $this->end_date); |
|
483 | 483 | |
484 | 484 | $end_where = " AND p.post_date <= '{$end_date}'"; |
485 | 485 | } |
@@ -499,34 +499,34 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public function payments_where( $where = '' ) { |
|
502 | + public function payments_where($where = '') { |
|
503 | 503 | |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | 506 | $start_where = ''; |
507 | 507 | $end_where = ''; |
508 | 508 | |
509 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
509 | + if ( ! is_wp_error($this->start_date)) { |
|
510 | 510 | |
511 | - if ( $this->timestamp ) { |
|
511 | + if ($this->timestamp) { |
|
512 | 512 | $format = 'Y-m-d H:i:s'; |
513 | 513 | } else { |
514 | 514 | $format = 'Y-m-d 00:00:00'; |
515 | 515 | } |
516 | 516 | |
517 | - $start_date = date( $format, $this->start_date ); |
|
517 | + $start_date = date($format, $this->start_date); |
|
518 | 518 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
519 | 519 | } |
520 | 520 | |
521 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
521 | + if ( ! is_wp_error($this->end_date)) { |
|
522 | 522 | |
523 | - if ( $this->timestamp ) { |
|
523 | + if ($this->timestamp) { |
|
524 | 524 | $format = 'Y-m-d 00:00:00'; |
525 | 525 | } else { |
526 | 526 | $format = 'Y-m-d 23:59:59'; |
527 | 527 | } |
528 | 528 | |
529 | - $end_date = date( $format, $this->end_date ); |
|
529 | + $end_date = date($format, $this->end_date); |
|
530 | 530 | |
531 | 531 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
532 | 532 | } |