@@ -37,7 +37,7 @@ |
||
37 | 37 | * |
38 | 38 | * Display admin bar when active |
39 | 39 | * |
40 | - * @return bool |
|
40 | + * @return false|null |
|
41 | 41 | */ |
42 | 42 | public function give_admin_bar_menu() { |
43 | 43 | global $wp_admin_bar; |
@@ -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 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * @since 1.0 |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
31 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
32 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 ); |
|
30 | + add_action('admin_notices', array($this, 'show_notices')); |
|
31 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
32 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | public function give_admin_bar_menu() { |
43 | 43 | global $wp_admin_bar; |
44 | 44 | |
45 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
45 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | 49 | //Add the main siteadmin menu item |
50 | - $wp_admin_bar->add_menu( array( |
|
50 | + $wp_admin_bar->add_menu(array( |
|
51 | 51 | 'id' => 'give-test-notice', |
52 | - 'href' => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
52 | + 'href' => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
53 | 53 | 'parent' => 'top-secondary', |
54 | - 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
55 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
56 | - ) ); |
|
54 | + 'title' => esc_html__('Give Test Mode Active', 'give'), |
|
55 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
@@ -68,98 +68,98 @@ discard block |
||
68 | 68 | 'error' => array() |
69 | 69 | ); |
70 | 70 | |
71 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
71 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
72 | 72 | echo '<div class="error">'; |
73 | - echo '<p>' . esc_html__( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
73 | + echo '<p>'.esc_html__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
74 | 74 | /* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */ |
75 | - echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>'; |
|
76 | - echo '<p><a href="' . add_query_arg( array( |
|
75 | + echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>'; |
|
76 | + echo '<p><a href="'.add_query_arg(array( |
|
77 | 77 | 'give_action' => 'dismiss_notices', |
78 | 78 | 'give_notice' => 'admin_ajax_inaccessible' |
79 | - ) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
79 | + )).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>'; |
|
80 | 80 | echo '</div>'; |
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | - if ( isset( $_GET['give-message'] ) ) { |
|
84 | + if (isset($_GET['give-message'])) { |
|
85 | 85 | |
86 | 86 | // Donation reports errors |
87 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
88 | - switch ( $_GET['give-message'] ) { |
|
87 | + if (current_user_can('view_give_reports')) { |
|
88 | + switch ($_GET['give-message']) { |
|
89 | 89 | case 'payment_deleted' : |
90 | - $notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' ); |
|
90 | + $notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give'); |
|
91 | 91 | break; |
92 | 92 | case 'email_sent' : |
93 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
93 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
94 | 94 | break; |
95 | 95 | case 'refreshed-reports' : |
96 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
96 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
97 | 97 | break; |
98 | 98 | case 'payment-note-deleted' : |
99 | - $notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' ); |
|
99 | + $notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give'); |
|
100 | 100 | break; |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Give settings notices and errors |
105 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
106 | - switch ( $_GET['give-message'] ) { |
|
105 | + if (current_user_can('manage_give_settings')) { |
|
106 | + switch ($_GET['give-message']) { |
|
107 | 107 | case 'settings-imported' : |
108 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
108 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
109 | 109 | break; |
110 | 110 | case 'api-key-generated' : |
111 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' ); |
|
111 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give'); |
|
112 | 112 | break; |
113 | 113 | case 'api-key-exists' : |
114 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
114 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
115 | 115 | break; |
116 | 116 | case 'api-key-regenerated' : |
117 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' ); |
|
117 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give'); |
|
118 | 118 | break; |
119 | 119 | case 'api-key-revoked' : |
120 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' ); |
|
120 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give'); |
|
121 | 121 | break; |
122 | 122 | case 'sent-test-email' : |
123 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
123 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | // Payments errors |
128 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
129 | - switch ( $_GET['give-message'] ) { |
|
128 | + if (current_user_can('edit_give_payments')) { |
|
129 | + switch ($_GET['give-message']) { |
|
130 | 130 | case 'note-added' : |
131 | - $notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' ); |
|
131 | + $notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give'); |
|
132 | 132 | break; |
133 | 133 | case 'payment-updated' : |
134 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' ); |
|
134 | + $notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give'); |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Customer Notices |
140 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
141 | - switch ( $_GET['give-message'] ) { |
|
140 | + if (current_user_can('edit_give_payments')) { |
|
141 | + switch ($_GET['give-message']) { |
|
142 | 142 | case 'customer-deleted' : |
143 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted.', 'give' ); |
|
143 | + $notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted.', 'give'); |
|
144 | 144 | break; |
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
149 | 149 | |
150 | - if ( count( $notices['updated'] ) > 0 ) { |
|
151 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
152 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
150 | + if (count($notices['updated']) > 0) { |
|
151 | + foreach ($notices['updated'] as $notice => $message) { |
|
152 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - if ( count( $notices['error'] ) > 0 ) { |
|
157 | - foreach ( $notices['error'] as $notice => $message ) { |
|
158 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
156 | + if (count($notices['error']) > 0) { |
|
157 | + foreach ($notices['error'] as $notice => $message) { |
|
158 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - settings_errors( 'give-notices' ); |
|
162 | + settings_errors('give-notices'); |
|
163 | 163 | |
164 | 164 | } |
165 | 165 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return void |
172 | 172 | */ |
173 | 173 | function give_admin_addons_notices() { |
174 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
175 | - settings_errors( 'give-notices' ); |
|
174 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
175 | + settings_errors('give-notices'); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @return void |
184 | 184 | */ |
185 | 185 | function dismiss_notices() { |
186 | - if ( isset( $_GET['give_notice'] ) ) { |
|
187 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
188 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
186 | + if (isset($_GET['give_notice'])) { |
|
187 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
188 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
189 | 189 | exit; |
190 | 190 | } |
191 | 191 | } |
@@ -81,7 +81,6 @@ discard block |
||
81 | 81 | * @since 1.1 |
82 | 82 | * |
83 | 83 | * @param array $item Contains all the data of the keys |
84 | - * @param string $column_name The name of the column |
|
85 | 84 | * |
86 | 85 | * @return string Column Name |
87 | 86 | */ |
@@ -96,7 +95,6 @@ discard block |
||
96 | 95 | * @since 1.1 |
97 | 96 | * |
98 | 97 | * @param array $item Contains all the data of the keys |
99 | - * @param string $column_name The name of the column |
|
100 | 98 | * |
101 | 99 | * @return string Column Name |
102 | 100 | */ |
@@ -111,7 +109,6 @@ discard block |
||
111 | 109 | * @since 1.1 |
112 | 110 | * |
113 | 111 | * @param array $item Contains all the data of the keys |
114 | - * @param string $column_name The name of the column |
|
115 | 112 | * |
116 | 113 | * @return string Column Name |
117 | 114 | */ |
@@ -124,7 +121,7 @@ discard block |
||
124 | 121 | * |
125 | 122 | * @access public |
126 | 123 | * @since 1.1 |
127 | - * @return void |
|
124 | + * @return string |
|
128 | 125 | */ |
129 | 126 | public function column_user( $item ) { |
130 | 127 |
@@ -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,11 +50,11 @@ discard block |
||
50 | 50 | global $status, $page; |
51 | 51 | |
52 | 52 | // Set parent defaults |
53 | - parent::__construct( array( |
|
54 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
55 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
53 | + parent::__construct(array( |
|
54 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
55 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
56 | 56 | 'ajax' => false // Does this table support ajax? |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | |
59 | 59 | $this->query(); |
60 | 60 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return string Column Name |
72 | 72 | */ |
73 | - public function column_default( $item, $column_name ) { |
|
74 | - return $item[ $column_name ]; |
|
73 | + public function column_default($item, $column_name) { |
|
74 | + return $item[$column_name]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return string Column Name |
87 | 87 | */ |
88 | - public function column_key( $item ) { |
|
89 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
88 | + public function column_key($item) { |
|
89 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return string Column Name |
102 | 102 | */ |
103 | - public function column_token( $item ) { |
|
104 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
103 | + public function column_token($item) { |
|
104 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'view' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-reports', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'] |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate' |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke' |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function get_columns() { |
179 | 179 | $columns = array( |
180 | - 'user' => esc_html__( 'Username', 'give' ), |
|
181 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
182 | - 'token' => esc_html__( 'Token', 'give' ), |
|
183 | - 'secret' => esc_html__( 'Secret Key', 'give' ) |
|
180 | + 'user' => esc_html__('Username', 'give'), |
|
181 | + 'key' => esc_html__('Public Key', 'give'), |
|
182 | + 'token' => esc_html__('Token', 'give'), |
|
183 | + 'secret' => esc_html__('Secret Key', 'give') |
|
184 | 184 | ); |
185 | 185 | |
186 | 186 | return $columns; |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | * @access protected |
194 | 194 | * @param string $which |
195 | 195 | */ |
196 | - protected function display_tablenav( $which ) { |
|
197 | - if ( 'top' === $which ) { |
|
198 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
196 | + protected function display_tablenav($which) { |
|
197 | + if ('top' === $which) { |
|
198 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
199 | 199 | } |
200 | 200 | ?> |
201 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
201 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
202 | 202 | |
203 | 203 | <div class="alignleft actions bulkactions"> |
204 | - <?php $this->bulk_actions( $which ); ?> |
|
204 | + <?php $this->bulk_actions($which); ?> |
|
205 | 205 | </div> |
206 | 206 | |
207 | 207 | <?php |
208 | - $this->extra_tablenav( $which ); |
|
209 | - $this->pagination( $which ); |
|
208 | + $this->extra_tablenav($which); |
|
209 | + $this->pagination($which); |
|
210 | 210 | ?> |
211 | 211 | |
212 | 212 | <br class="clear" /> |
@@ -222,19 +222,19 @@ discard block |
||
222 | 222 | * @param string $which |
223 | 223 | * @return void |
224 | 224 | */ |
225 | - function bulk_actions( $which = '' ) { |
|
225 | + function bulk_actions($which = '') { |
|
226 | 226 | // These aren't really bulk actions but this outputs the markup in the right place |
227 | 227 | static $give_api_is_bottom; |
228 | 228 | |
229 | - if ( $give_api_is_bottom ) { |
|
229 | + if ($give_api_is_bottom) { |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | ?> |
233 | 233 | <input type="hidden" name="give_action" value="process_api_key"/> |
234 | 234 | <input type="hidden" name="give_api_process" value="generate"/> |
235 | - <?php wp_nonce_field( 'give-api-nonce' ); ?> |
|
235 | + <?php wp_nonce_field('give-api-nonce'); ?> |
|
236 | 236 | <?php echo Give()->html->ajax_user_search(); ?> |
237 | - <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
|
237 | + <?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?> |
|
238 | 238 | <?php |
239 | 239 | $give_api_is_bottom = true; |
240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return int Current page number |
248 | 248 | */ |
249 | 249 | public function get_paged() { |
250 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
250 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | * @return array |
259 | 259 | */ |
260 | 260 | public function query() { |
261 | - $users = get_users( array( |
|
261 | + $users = get_users(array( |
|
262 | 262 | 'meta_value' => 'give_user_secret_key', |
263 | 263 | 'number' => $this->per_page, |
264 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ) |
|
265 | - ) ); |
|
266 | - $keys = array(); |
|
267 | - |
|
268 | - foreach ( $users as $user ) { |
|
269 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
270 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
271 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
272 | - |
|
273 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
274 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
275 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
264 | + 'offset' => $this->per_page * ($this->get_paged() - 1) |
|
265 | + )); |
|
266 | + $keys = array(); |
|
267 | + |
|
268 | + foreach ($users as $user) { |
|
269 | + $keys[$user->ID]['id'] = $user->ID; |
|
270 | + $keys[$user->ID]['email'] = $user->user_email; |
|
271 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
272 | + |
|
273 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
274 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
275 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $keys; |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | public function total_items() { |
290 | 290 | global $wpdb; |
291 | 291 | |
292 | - if ( ! get_transient( 'give_total_api_keys' ) ) { |
|
293 | - $total_items = $wpdb->get_var( "SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_value='give_user_secret_key'" ); |
|
292 | + if ( ! get_transient('give_total_api_keys')) { |
|
293 | + $total_items = $wpdb->get_var("SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_value='give_user_secret_key'"); |
|
294 | 294 | |
295 | - set_transient( 'give_total_api_keys', $total_items, 60 * 60 ); |
|
295 | + set_transient('give_total_api_keys', $total_items, 60 * 60); |
|
296 | 296 | } |
297 | 297 | |
298 | - return get_transient( 'give_total_api_keys' ); |
|
298 | + return get_transient('give_total_api_keys'); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $hidden = array(); // No hidden columns |
312 | 312 | $sortable = array(); // Not sortable... for now |
313 | 313 | |
314 | - $this->_column_headers = array( $columns, $hidden, $sortable, 'id' ); |
|
314 | + $this->_column_headers = array($columns, $hidden, $sortable, 'id'); |
|
315 | 315 | |
316 | 316 | $data = $this->query(); |
317 | 317 | |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | |
320 | 320 | $this->items = $data; |
321 | 321 | |
322 | - $this->set_pagination_args( array( |
|
322 | + $this->set_pagination_args(array( |
|
323 | 323 | 'total_items' => $total_items, |
324 | 324 | 'per_page' => $this->per_page, |
325 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
325 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
326 | 326 | ) |
327 | 327 | ); |
328 | 328 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | * @uses api_request() |
68 | 68 | * |
69 | 69 | * @param array $_transient_data Update array build by WordPress. |
70 | - * @return array Modified update array with custom plugin data. |
|
70 | + * @return stdClass Modified update array with custom plugin data. |
|
71 | 71 | */ |
72 | 72 | function check_update( $_transient_data ) { |
73 | 73 |
@@ -4,7 +4,9 @@ discard block |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined( 'ABSPATH' ) ) { |
|
8 | + exit; |
|
9 | +} |
|
8 | 10 | |
9 | 11 | /** |
10 | 12 | * Allows plugins to use their own update API. |
@@ -273,11 +275,13 @@ discard block |
||
273 | 275 | |
274 | 276 | $data = array_merge( $this->api_data, $_data ); |
275 | 277 | |
276 | - if ( $data['slug'] != $this->slug ) |
|
277 | - return; |
|
278 | + if ( $data['slug'] != $this->slug ) { |
|
279 | + return; |
|
280 | + } |
|
278 | 281 | |
279 | - if ( empty( $data['license'] ) ) |
|
280 | - return; |
|
282 | + if ( empty( $data['license'] ) ) { |
|
283 | + return; |
|
284 | + } |
|
281 | 285 | |
282 | 286 | if( $this->api_url == home_url() ) { |
283 | 287 | return false; // Don't allow a plugin to ping itself |
@@ -13,330 +13,330 @@ |
||
13 | 13 | * @version 1.6 |
14 | 14 | */ |
15 | 15 | class EDD_SL_Plugin_Updater { |
16 | - private $api_url = ''; |
|
17 | - private $api_data = array(); |
|
18 | - private $name = ''; |
|
19 | - private $slug = ''; |
|
20 | - |
|
21 | - /** |
|
22 | - * Class constructor. |
|
23 | - * |
|
24 | - * @uses plugin_basename() |
|
25 | - * @uses hook() |
|
26 | - * |
|
27 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | - * @param string $_plugin_file Path to the plugin file. |
|
29 | - * @param array $_api_data Optional data to send with API calls. |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
34 | - $this->api_data = $_api_data; |
|
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | - $this->version = $_api_data['version']; |
|
38 | - |
|
39 | - // Set up hooks. |
|
40 | - $this->init(); |
|
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Set up WordPress filters to hook into WP's update process. |
|
46 | - * |
|
47 | - * @uses add_filter() |
|
48 | - * |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function init() { |
|
16 | + private $api_url = ''; |
|
17 | + private $api_data = array(); |
|
18 | + private $name = ''; |
|
19 | + private $slug = ''; |
|
20 | + |
|
21 | + /** |
|
22 | + * Class constructor. |
|
23 | + * |
|
24 | + * @uses plugin_basename() |
|
25 | + * @uses hook() |
|
26 | + * |
|
27 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
28 | + * @param string $_plugin_file Path to the plugin file. |
|
29 | + * @param array $_api_data Optional data to send with API calls. |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | + $this->api_url = trailingslashit( $_api_url ); |
|
34 | + $this->api_data = $_api_data; |
|
35 | + $this->name = plugin_basename( $_plugin_file ); |
|
36 | + $this->slug = basename( $_plugin_file, '.php' ); |
|
37 | + $this->version = $_api_data['version']; |
|
38 | + |
|
39 | + // Set up hooks. |
|
40 | + $this->init(); |
|
41 | + add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Set up WordPress filters to hook into WP's update process. |
|
46 | + * |
|
47 | + * @uses add_filter() |
|
48 | + * |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function init() { |
|
52 | 52 | |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
55 | 55 | |
56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | - } |
|
56 | + add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | - * |
|
62 | - * This function dives into the update API just when WordPress creates its update array, |
|
63 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | - * |
|
67 | - * @uses api_request() |
|
68 | - * |
|
69 | - * @param array $_transient_data Update array build by WordPress. |
|
70 | - * @return array Modified update array with custom plugin data. |
|
71 | - */ |
|
72 | - function check_update( $_transient_data ) { |
|
59 | + /** |
|
60 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
61 | + * |
|
62 | + * This function dives into the update API just when WordPress creates its update array, |
|
63 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
64 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
65 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
66 | + * |
|
67 | + * @uses api_request() |
|
68 | + * |
|
69 | + * @param array $_transient_data Update array build by WordPress. |
|
70 | + * @return array Modified update array with custom plugin data. |
|
71 | + */ |
|
72 | + function check_update( $_transient_data ) { |
|
73 | 73 | |
74 | - global $pagenow; |
|
74 | + global $pagenow; |
|
75 | 75 | |
76 | - if( ! is_object( $_transient_data ) ) { |
|
77 | - $_transient_data = new stdClass; |
|
78 | - } |
|
76 | + if( ! is_object( $_transient_data ) ) { |
|
77 | + $_transient_data = new stdClass; |
|
78 | + } |
|
79 | 79 | |
80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | - return $_transient_data; |
|
82 | - } |
|
80 | + if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | + return $_transient_data; |
|
82 | + } |
|
83 | 83 | |
84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
85 | 85 | |
86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
87 | 87 | |
88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
89 | 89 | |
90 | - $this->did_check = true; |
|
90 | + $this->did_check = true; |
|
91 | 91 | |
92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
92 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
93 | 93 | |
94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
94 | + $_transient_data->response[ $this->name ] = $version_info; |
|
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - $_transient_data->last_checked = time(); |
|
99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
98 | + $_transient_data->last_checked = time(); |
|
99 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | 100 | |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - return $_transient_data; |
|
106 | - } |
|
105 | + return $_transient_data; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | - * |
|
111 | - * @param string $file |
|
112 | - * @param array $plugin |
|
113 | - */ |
|
114 | - public function show_update_notification( $file, $plugin ) { |
|
108 | + /** |
|
109 | + * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! |
|
110 | + * |
|
111 | + * @param string $file |
|
112 | + * @param array $plugin |
|
113 | + */ |
|
114 | + public function show_update_notification( $file, $plugin ) { |
|
115 | 115 | |
116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | - return; |
|
118 | - } |
|
116 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
117 | + return; |
|
118 | + } |
|
119 | 119 | |
120 | - if( ! is_multisite() ) { |
|
121 | - return; |
|
122 | - } |
|
120 | + if( ! is_multisite() ) { |
|
121 | + return; |
|
122 | + } |
|
123 | 123 | |
124 | - if ( $this->name != $file ) { |
|
125 | - return; |
|
126 | - } |
|
124 | + if ( $this->name != $file ) { |
|
125 | + return; |
|
126 | + } |
|
127 | 127 | |
128 | - // Remove our filter on the site transient |
|
129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
128 | + // Remove our filter on the site transient |
|
129 | + remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
130 | 130 | |
131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
131 | + $update_cache = get_site_transient( 'update_plugins' ); |
|
132 | 132 | |
133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
133 | + if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
134 | 134 | |
135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | - $version_info = get_transient( $cache_key ); |
|
135 | + $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | + $version_info = get_transient( $cache_key ); |
|
137 | 137 | |
138 | - if( false === $version_info ) { |
|
138 | + if( false === $version_info ) { |
|
139 | 139 | |
140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
140 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
141 | 141 | |
142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
143 | - } |
|
142 | + set_transient( $cache_key, $version_info, 3600 ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - if( ! is_object( $version_info ) ) { |
|
147 | - return; |
|
148 | - } |
|
146 | + if( ! is_object( $version_info ) ) { |
|
147 | + return; |
|
148 | + } |
|
149 | 149 | |
150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
150 | + if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
151 | 151 | |
152 | - $update_cache->response[ $this->name ] = $version_info; |
|
152 | + $update_cache->response[ $this->name ] = $version_info; |
|
153 | 153 | |
154 | - } |
|
154 | + } |
|
155 | 155 | |
156 | - $update_cache->last_checked = time(); |
|
157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
156 | + $update_cache->last_checked = time(); |
|
157 | + $update_cache->checked[ $this->name ] = $this->version; |
|
158 | 158 | |
159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
159 | + set_site_transient( 'update_plugins', $update_cache ); |
|
160 | 160 | |
161 | - } else { |
|
161 | + } else { |
|
162 | 162 | |
163 | - $version_info = $update_cache->response[ $this->name ]; |
|
163 | + $version_info = $update_cache->response[ $this->name ]; |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - // Restore our filter |
|
168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
167 | + // Restore our filter |
|
168 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
169 | 169 | |
170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
170 | + if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
171 | 171 | |
172 | - // build a plugin list row, with update notification |
|
173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
172 | + // build a plugin list row, with update notification |
|
173 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | + echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
175 | 175 | |
176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
176 | + $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
177 | 177 | |
178 | - if ( empty( $version_info->download_link ) ) { |
|
179 | - printf( |
|
178 | + if ( empty( $version_info->download_link ) ) { |
|
179 | + printf( |
|
180 | 180 | /* translators: 1: name 2: changelog URL 3: version */ |
181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
182 | - esc_html( $version_info->name ), |
|
183 | - esc_url( $changelog_link ), |
|
184 | - esc_html( $version_info->new_version ) |
|
185 | - ); |
|
186 | - } else { |
|
187 | - printf( |
|
181 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
182 | + esc_html( $version_info->name ), |
|
183 | + esc_url( $changelog_link ), |
|
184 | + esc_html( $version_info->new_version ) |
|
185 | + ); |
|
186 | + } else { |
|
187 | + printf( |
|
188 | 188 | /* translators: 1: name 2: changelog URL 3: version 4: update URL */ |
189 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
190 | - esc_html( $version_info->name ), |
|
191 | - esc_url( $changelog_link ), |
|
192 | - esc_html( $version_info->new_version ), |
|
193 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
194 | - ); |
|
195 | - } |
|
196 | - |
|
197 | - echo '</div></td></tr>'; |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * Updates information on the "View version x.x details" page with custom data. |
|
204 | - * |
|
205 | - * @uses api_request() |
|
206 | - * |
|
207 | - * @param mixed $_data |
|
208 | - * @param string $_action |
|
209 | - * @param object $_args |
|
210 | - * @return object $_data |
|
211 | - */ |
|
212 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
213 | - |
|
214 | - |
|
215 | - if ( $_action != 'plugin_information' ) { |
|
216 | - |
|
217 | - return $_data; |
|
218 | - |
|
219 | - } |
|
220 | - |
|
221 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
222 | - |
|
223 | - return $_data; |
|
224 | - |
|
225 | - } |
|
226 | - |
|
227 | - $to_send = array( |
|
228 | - 'slug' => $this->slug, |
|
229 | - 'is_ssl' => is_ssl(), |
|
230 | - 'fields' => array( |
|
231 | - 'banners' => false, // These will be supported soon hopefully |
|
232 | - 'reviews' => false |
|
233 | - ) |
|
234 | - ); |
|
235 | - |
|
236 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
237 | - |
|
238 | - if ( false !== $api_response ) { |
|
239 | - $_data = $api_response; |
|
240 | - } |
|
241 | - |
|
242 | - return $_data; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * Disable SSL verification in order to prevent download update failures |
|
248 | - * |
|
249 | - * @param array $args |
|
250 | - * @param string $url |
|
251 | - * @return object $array |
|
252 | - */ |
|
253 | - function http_request_args( $args, $url ) { |
|
254 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
255 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
256 | - $args['sslverify'] = false; |
|
257 | - } |
|
258 | - return $args; |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
263 | - * |
|
264 | - * @uses get_bloginfo() |
|
265 | - * @uses wp_remote_post() |
|
266 | - * @uses is_wp_error() |
|
267 | - * |
|
268 | - * @param string $_action The requested action. |
|
269 | - * @param array $_data Parameters for the API action. |
|
270 | - * @return false||object |
|
271 | - */ |
|
272 | - private function api_request( $_action, $_data ) { |
|
273 | - |
|
274 | - global $wp_version; |
|
275 | - |
|
276 | - $data = array_merge( $this->api_data, $_data ); |
|
277 | - |
|
278 | - if ( $data['slug'] != $this->slug ) |
|
279 | - return; |
|
280 | - |
|
281 | - if ( empty( $data['license'] ) ) |
|
282 | - return; |
|
283 | - |
|
284 | - if( $this->api_url == home_url() ) { |
|
285 | - return false; // Don't allow a plugin to ping itself |
|
286 | - } |
|
287 | - |
|
288 | - $api_params = array( |
|
289 | - 'edd_action' => 'get_version', |
|
290 | - 'license' => $data['license'], |
|
291 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
292 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
293 | - 'slug' => $data['slug'], |
|
294 | - 'author' => $data['author'], |
|
295 | - 'url' => home_url() |
|
296 | - ); |
|
189 | + __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
190 | + esc_html( $version_info->name ), |
|
191 | + esc_url( $changelog_link ), |
|
192 | + esc_html( $version_info->new_version ), |
|
193 | + esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
194 | + ); |
|
195 | + } |
|
196 | + |
|
197 | + echo '</div></td></tr>'; |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * Updates information on the "View version x.x details" page with custom data. |
|
204 | + * |
|
205 | + * @uses api_request() |
|
206 | + * |
|
207 | + * @param mixed $_data |
|
208 | + * @param string $_action |
|
209 | + * @param object $_args |
|
210 | + * @return object $_data |
|
211 | + */ |
|
212 | + function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
213 | + |
|
214 | + |
|
215 | + if ( $_action != 'plugin_information' ) { |
|
216 | + |
|
217 | + return $_data; |
|
218 | + |
|
219 | + } |
|
220 | + |
|
221 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
222 | + |
|
223 | + return $_data; |
|
224 | + |
|
225 | + } |
|
226 | + |
|
227 | + $to_send = array( |
|
228 | + 'slug' => $this->slug, |
|
229 | + 'is_ssl' => is_ssl(), |
|
230 | + 'fields' => array( |
|
231 | + 'banners' => false, // These will be supported soon hopefully |
|
232 | + 'reviews' => false |
|
233 | + ) |
|
234 | + ); |
|
235 | + |
|
236 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
237 | + |
|
238 | + if ( false !== $api_response ) { |
|
239 | + $_data = $api_response; |
|
240 | + } |
|
241 | + |
|
242 | + return $_data; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * Disable SSL verification in order to prevent download update failures |
|
248 | + * |
|
249 | + * @param array $args |
|
250 | + * @param string $url |
|
251 | + * @return object $array |
|
252 | + */ |
|
253 | + function http_request_args( $args, $url ) { |
|
254 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
255 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
256 | + $args['sslverify'] = false; |
|
257 | + } |
|
258 | + return $args; |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
263 | + * |
|
264 | + * @uses get_bloginfo() |
|
265 | + * @uses wp_remote_post() |
|
266 | + * @uses is_wp_error() |
|
267 | + * |
|
268 | + * @param string $_action The requested action. |
|
269 | + * @param array $_data Parameters for the API action. |
|
270 | + * @return false||object |
|
271 | + */ |
|
272 | + private function api_request( $_action, $_data ) { |
|
273 | + |
|
274 | + global $wp_version; |
|
275 | + |
|
276 | + $data = array_merge( $this->api_data, $_data ); |
|
277 | + |
|
278 | + if ( $data['slug'] != $this->slug ) |
|
279 | + return; |
|
280 | + |
|
281 | + if ( empty( $data['license'] ) ) |
|
282 | + return; |
|
283 | + |
|
284 | + if( $this->api_url == home_url() ) { |
|
285 | + return false; // Don't allow a plugin to ping itself |
|
286 | + } |
|
287 | + |
|
288 | + $api_params = array( |
|
289 | + 'edd_action' => 'get_version', |
|
290 | + 'license' => $data['license'], |
|
291 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
292 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
293 | + 'slug' => $data['slug'], |
|
294 | + 'author' => $data['author'], |
|
295 | + 'url' => home_url() |
|
296 | + ); |
|
297 | 297 | |
298 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
298 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
299 | 299 | |
300 | - if ( ! is_wp_error( $request ) ) { |
|
301 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
302 | - } |
|
300 | + if ( ! is_wp_error( $request ) ) { |
|
301 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
302 | + } |
|
303 | 303 | |
304 | - if ( $request && isset( $request->sections ) ) { |
|
305 | - $request->sections = maybe_unserialize( $request->sections ); |
|
306 | - } else { |
|
307 | - $request = false; |
|
308 | - } |
|
304 | + if ( $request && isset( $request->sections ) ) { |
|
305 | + $request->sections = maybe_unserialize( $request->sections ); |
|
306 | + } else { |
|
307 | + $request = false; |
|
308 | + } |
|
309 | 309 | |
310 | - return $request; |
|
311 | - } |
|
310 | + return $request; |
|
311 | + } |
|
312 | 312 | |
313 | - public function show_changelog() { |
|
313 | + public function show_changelog() { |
|
314 | 314 | |
315 | 315 | |
316 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
317 | - return; |
|
318 | - } |
|
316 | + if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
317 | + return; |
|
318 | + } |
|
319 | 319 | |
320 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
321 | - return; |
|
322 | - } |
|
323 | - |
|
324 | - if( empty( $_REQUEST['slug'] ) ) { |
|
325 | - return; |
|
326 | - } |
|
327 | - |
|
328 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
329 | - wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'edd' ), esc_html__( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
330 | - } |
|
331 | - |
|
332 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
333 | - |
|
334 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
335 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - exit; |
|
340 | - } |
|
320 | + if( empty( $_REQUEST['plugin'] ) ) { |
|
321 | + return; |
|
322 | + } |
|
323 | + |
|
324 | + if( empty( $_REQUEST['slug'] ) ) { |
|
325 | + return; |
|
326 | + } |
|
327 | + |
|
328 | + if( ! current_user_can( 'update_plugins' ) ) { |
|
329 | + wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'edd' ), esc_html__( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
330 | + } |
|
331 | + |
|
332 | + $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
333 | + |
|
334 | + if( $response && isset( $response->sections['changelog'] ) ) { |
|
335 | + echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + exit; |
|
340 | + } |
|
341 | 341 | |
342 | 342 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined('ABSPATH')) exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Allows plugins to use their own update API. |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param array $_api_data Optional data to send with API calls. |
30 | 30 | * @return void |
31 | 31 | */ |
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
32 | + function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
33 | + $this->api_url = trailingslashit($_api_url); |
|
34 | 34 | $this->api_data = $_api_data; |
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
35 | + $this->name = plugin_basename($_plugin_file); |
|
36 | + $this->slug = basename($_plugin_file, '.php'); |
|
37 | 37 | $this->version = $_api_data['version']; |
38 | 38 | |
39 | 39 | // Set up hooks. |
40 | 40 | $this->init(); |
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
41 | + add_action('admin_init', array($this, 'show_changelog')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init() { |
52 | 52 | |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
54 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
55 | 55 | |
56 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
56 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -69,34 +69,34 @@ discard block |
||
69 | 69 | * @param array $_transient_data Update array build by WordPress. |
70 | 70 | * @return array Modified update array with custom plugin data. |
71 | 71 | */ |
72 | - function check_update( $_transient_data ) { |
|
72 | + function check_update($_transient_data) { |
|
73 | 73 | |
74 | 74 | global $pagenow; |
75 | 75 | |
76 | - if( ! is_object( $_transient_data ) ) { |
|
76 | + if ( ! is_object($_transient_data)) { |
|
77 | 77 | $_transient_data = new stdClass; |
78 | 78 | } |
79 | 79 | |
80 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
80 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
81 | 81 | return $_transient_data; |
82 | 82 | } |
83 | 83 | |
84 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
85 | 85 | |
86 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
87 | 87 | |
88 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
89 | 89 | |
90 | 90 | $this->did_check = true; |
91 | 91 | |
92 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
92 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
93 | 93 | |
94 | - $_transient_data->response[ $this->name ] = $version_info; |
|
94 | + $_transient_data->response[$this->name] = $version_info; |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | 98 | $_transient_data->last_checked = time(); |
99 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
99 | + $_transient_data->checked[$this->name] = $this->version; |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -111,86 +111,86 @@ discard block |
||
111 | 111 | * @param string $file |
112 | 112 | * @param array $plugin |
113 | 113 | */ |
114 | - public function show_update_notification( $file, $plugin ) { |
|
114 | + public function show_update_notification($file, $plugin) { |
|
115 | 115 | |
116 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
116 | + if ( ! current_user_can('update_plugins')) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | 119 | |
120 | - if( ! is_multisite() ) { |
|
120 | + if ( ! is_multisite()) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | - if ( $this->name != $file ) { |
|
124 | + if ($this->name != $file) { |
|
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | 128 | // Remove our filter on the site transient |
129 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
129 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
130 | 130 | |
131 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
131 | + $update_cache = get_site_transient('update_plugins'); |
|
132 | 132 | |
133 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
133 | + if ( ! is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
134 | 134 | |
135 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
136 | - $version_info = get_transient( $cache_key ); |
|
135 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
136 | + $version_info = get_transient($cache_key); |
|
137 | 137 | |
138 | - if( false === $version_info ) { |
|
138 | + if (false === $version_info) { |
|
139 | 139 | |
140 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
140 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
141 | 141 | |
142 | - set_transient( $cache_key, $version_info, 3600 ); |
|
142 | + set_transient($cache_key, $version_info, 3600); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - if( ! is_object( $version_info ) ) { |
|
146 | + if ( ! is_object($version_info)) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
150 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
151 | 151 | |
152 | - $update_cache->response[ $this->name ] = $version_info; |
|
152 | + $update_cache->response[$this->name] = $version_info; |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | 156 | $update_cache->last_checked = time(); |
157 | - $update_cache->checked[ $this->name ] = $this->version; |
|
157 | + $update_cache->checked[$this->name] = $this->version; |
|
158 | 158 | |
159 | - set_site_transient( 'update_plugins', $update_cache ); |
|
159 | + set_site_transient('update_plugins', $update_cache); |
|
160 | 160 | |
161 | 161 | } else { |
162 | 162 | |
163 | - $version_info = $update_cache->response[ $this->name ]; |
|
163 | + $version_info = $update_cache->response[$this->name]; |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | 167 | // Restore our filter |
168 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
168 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
169 | 169 | |
170 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
170 | + if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
171 | 171 | |
172 | 172 | // build a plugin list row, with update notification |
173 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
174 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
173 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
174 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
175 | 175 | |
176 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
176 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
177 | 177 | |
178 | - if ( empty( $version_info->download_link ) ) { |
|
178 | + if (empty($version_info->download_link)) { |
|
179 | 179 | printf( |
180 | 180 | /* translators: 1: name 2: changelog URL 3: version */ |
181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ), |
|
182 | - esc_html( $version_info->name ), |
|
183 | - esc_url( $changelog_link ), |
|
184 | - esc_html( $version_info->new_version ) |
|
181 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'), |
|
182 | + esc_html($version_info->name), |
|
183 | + esc_url($changelog_link), |
|
184 | + esc_html($version_info->new_version) |
|
185 | 185 | ); |
186 | 186 | } else { |
187 | 187 | printf( |
188 | 188 | /* translators: 1: name 2: changelog URL 3: version 4: update URL */ |
189 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ), |
|
190 | - esc_html( $version_info->name ), |
|
191 | - esc_url( $changelog_link ), |
|
192 | - esc_html( $version_info->new_version ), |
|
193 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
189 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd'), |
|
190 | + esc_html($version_info->name), |
|
191 | + esc_url($changelog_link), |
|
192 | + esc_html($version_info->new_version), |
|
193 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | * @param object $_args |
210 | 210 | * @return object $_data |
211 | 211 | */ |
212 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
212 | + function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
213 | 213 | |
214 | 214 | |
215 | - if ( $_action != 'plugin_information' ) { |
|
215 | + if ($_action != 'plugin_information') { |
|
216 | 216 | |
217 | 217 | return $_data; |
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
221 | + if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
222 | 222 | |
223 | 223 | return $_data; |
224 | 224 | |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
236 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
236 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
237 | 237 | |
238 | - if ( false !== $api_response ) { |
|
238 | + if (false !== $api_response) { |
|
239 | 239 | $_data = $api_response; |
240 | 240 | } |
241 | 241 | |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | * @param string $url |
251 | 251 | * @return object $array |
252 | 252 | */ |
253 | - function http_request_args( $args, $url ) { |
|
253 | + function http_request_args($args, $url) { |
|
254 | 254 | // If it is an https request and we are performing a package download, disable ssl verification |
255 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
255 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
256 | 256 | $args['sslverify'] = false; |
257 | 257 | } |
258 | 258 | return $args; |
@@ -269,40 +269,40 @@ discard block |
||
269 | 269 | * @param array $_data Parameters for the API action. |
270 | 270 | * @return false||object |
271 | 271 | */ |
272 | - private function api_request( $_action, $_data ) { |
|
272 | + private function api_request($_action, $_data) { |
|
273 | 273 | |
274 | 274 | global $wp_version; |
275 | 275 | |
276 | - $data = array_merge( $this->api_data, $_data ); |
|
276 | + $data = array_merge($this->api_data, $_data); |
|
277 | 277 | |
278 | - if ( $data['slug'] != $this->slug ) |
|
278 | + if ($data['slug'] != $this->slug) |
|
279 | 279 | return; |
280 | 280 | |
281 | - if ( empty( $data['license'] ) ) |
|
281 | + if (empty($data['license'])) |
|
282 | 282 | return; |
283 | 283 | |
284 | - if( $this->api_url == home_url() ) { |
|
284 | + if ($this->api_url == home_url()) { |
|
285 | 285 | return false; // Don't allow a plugin to ping itself |
286 | 286 | } |
287 | 287 | |
288 | 288 | $api_params = array( |
289 | 289 | 'edd_action' => 'get_version', |
290 | 290 | 'license' => $data['license'], |
291 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
292 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
291 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
292 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
293 | 293 | 'slug' => $data['slug'], |
294 | 294 | 'author' => $data['author'], |
295 | 295 | 'url' => home_url() |
296 | 296 | ); |
297 | 297 | |
298 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
298 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
299 | 299 | |
300 | - if ( ! is_wp_error( $request ) ) { |
|
301 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
300 | + if ( ! is_wp_error($request)) { |
|
301 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( $request && isset( $request->sections ) ) { |
|
305 | - $request->sections = maybe_unserialize( $request->sections ); |
|
304 | + if ($request && isset($request->sections)) { |
|
305 | + $request->sections = maybe_unserialize($request->sections); |
|
306 | 306 | } else { |
307 | 307 | $request = false; |
308 | 308 | } |
@@ -313,26 +313,26 @@ discard block |
||
313 | 313 | public function show_changelog() { |
314 | 314 | |
315 | 315 | |
316 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
316 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
317 | 317 | return; |
318 | 318 | } |
319 | 319 | |
320 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
320 | + if (empty($_REQUEST['plugin'])) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
324 | - if( empty( $_REQUEST['slug'] ) ) { |
|
324 | + if (empty($_REQUEST['slug'])) { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | |
328 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
329 | - wp_die( esc_html__( 'You do not have permission to install plugin updates.', 'edd' ), esc_html__( 'Error', 'edd' ), array( 'response' => 403 ) ); |
|
328 | + if ( ! current_user_can('update_plugins')) { |
|
329 | + wp_die(esc_html__('You do not have permission to install plugin updates.', 'edd'), esc_html__('Error', 'edd'), array('response' => 403)); |
|
330 | 330 | } |
331 | 331 | |
332 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
332 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
333 | 333 | |
334 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
335 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
334 | + if ($response && isset($response->sections['changelog'])) { |
|
335 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 |
@@ -321,7 +321,7 @@ |
||
321 | 321 | * |
322 | 322 | * @param int $post_id Download (Post) ID |
323 | 323 | * |
324 | - * @return void |
|
324 | + * @return null|integer |
|
325 | 325 | */ |
326 | 326 | function give_price_save_quick_edit( $post_id ) { |
327 | 327 | if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
@@ -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 | |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | * @return array $form_columns Updated array of forms columns |
28 | 28 | * Post Type List Table |
29 | 29 | */ |
30 | -function give_form_columns( $give_form_columns ) { |
|
30 | +function give_form_columns($give_form_columns) { |
|
31 | 31 | |
32 | 32 | //Standard columns |
33 | 33 | $give_form_columns = array( |
34 | 34 | 'cb' => '<input type="checkbox"/>', |
35 | - 'title' => esc_html__( 'Name', 'give' ), |
|
36 | - 'form_category' => esc_html__( 'Categories', 'give' ), |
|
37 | - 'form_tag' => esc_html__( 'Tags', 'give' ), |
|
38 | - 'price' => esc_html__( 'Price', 'give' ), |
|
39 | - 'goal' => esc_html__( 'Goal', 'give' ), |
|
40 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
41 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
42 | - 'shortcode' => esc_html__( 'Shortcode', 'give' ), |
|
43 | - 'date' => esc_html__( 'Date', 'give' ) |
|
35 | + 'title' => esc_html__('Name', 'give'), |
|
36 | + 'form_category' => esc_html__('Categories', 'give'), |
|
37 | + 'form_tag' => esc_html__('Tags', 'give'), |
|
38 | + 'price' => esc_html__('Price', 'give'), |
|
39 | + 'goal' => esc_html__('Goal', 'give'), |
|
40 | + 'donations' => esc_html__('Donations', 'give'), |
|
41 | + 'earnings' => esc_html__('Income', 'give'), |
|
42 | + 'shortcode' => esc_html__('Shortcode', 'give'), |
|
43 | + 'date' => esc_html__('Date', 'give') |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | //Does the user want categories / tags? |
47 | - if ( give_get_option( 'enable_categories' ) !== 'on' ) { |
|
48 | - unset( $give_form_columns['form_category'] ); |
|
47 | + if (give_get_option('enable_categories') !== 'on') { |
|
48 | + unset($give_form_columns['form_category']); |
|
49 | 49 | } |
50 | - if ( give_get_option( 'enable_tags' ) !== 'on' ) { |
|
51 | - unset( $give_form_columns['form_tag'] ); |
|
50 | + if (give_get_option('enable_tags') !== 'on') { |
|
51 | + unset($give_form_columns['form_tag']); |
|
52 | 52 | } |
53 | 53 | |
54 | - return apply_filters( 'give_forms_columns', $give_form_columns ); |
|
54 | + return apply_filters('give_forms_columns', $give_form_columns); |
|
55 | 55 | } |
56 | 56 | |
57 | -add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' ); |
|
57 | +add_filter('manage_edit-give_forms_columns', 'give_form_columns'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Render Give Form Columns |
@@ -66,60 +66,60 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return void |
68 | 68 | */ |
69 | -function give_render_form_columns( $column_name, $post_id ) { |
|
70 | - if ( get_post_type( $post_id ) == 'give_forms' ) { |
|
69 | +function give_render_form_columns($column_name, $post_id) { |
|
70 | + if (get_post_type($post_id) == 'give_forms') { |
|
71 | 71 | |
72 | - switch ( $column_name ) { |
|
72 | + switch ($column_name) { |
|
73 | 73 | case 'form_category': |
74 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
74 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
75 | 75 | break; |
76 | 76 | case 'form_tag': |
77 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
77 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
78 | 78 | break; |
79 | 79 | case 'price': |
80 | - if ( give_has_variable_prices( $post_id ) ) { |
|
81 | - echo give_price_range( $post_id ); |
|
80 | + if (give_has_variable_prices($post_id)) { |
|
81 | + echo give_price_range($post_id); |
|
82 | 82 | } else { |
83 | - echo give_price( $post_id, false ); |
|
84 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
83 | + echo give_price($post_id, false); |
|
84 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
85 | 85 | } |
86 | 86 | break; |
87 | 87 | case 'goal': |
88 | - $goal_option = get_post_meta( $post_id, '_give_goal_option', true ); |
|
89 | - if ( ! empty( $goal_option ) && $goal_option === 'yes' ) { |
|
90 | - echo give_goal( $post_id, false ); |
|
88 | + $goal_option = get_post_meta($post_id, '_give_goal_option', true); |
|
89 | + if ( ! empty($goal_option) && $goal_option === 'yes') { |
|
90 | + echo give_goal($post_id, false); |
|
91 | 91 | } else { |
92 | - echo esc_html__( 'No Goal Set', 'give' ); |
|
92 | + echo esc_html__('No Goal Set', 'give'); |
|
93 | 93 | } |
94 | 94 | |
95 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
95 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
96 | 96 | break; |
97 | 97 | case 'donations': |
98 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
99 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">'; |
|
100 | - echo give_get_form_sales_stats( $post_id ); |
|
98 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
99 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">'; |
|
100 | + echo give_get_form_sales_stats($post_id); |
|
101 | 101 | echo '</a>'; |
102 | 102 | } else { |
103 | 103 | echo '-'; |
104 | 104 | } |
105 | 105 | break; |
106 | 106 | case 'earnings': |
107 | - if ( current_user_can( 'view_give_form_stats', $post_id ) ) { |
|
108 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">'; |
|
109 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) ); |
|
107 | + if (current_user_can('view_give_form_stats', $post_id)) { |
|
108 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">'; |
|
109 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id))); |
|
110 | 110 | echo '</a>'; |
111 | 111 | } else { |
112 | 112 | echo '-'; |
113 | 113 | } |
114 | 114 | break; |
115 | 115 | case 'shortcode': |
116 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
116 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
117 | 117 | break; |
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
122 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Registers the sortable columns in the list table |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @return array $columns Array of sortable columns |
132 | 132 | */ |
133 | -function give_sortable_form_columns( $columns ) { |
|
133 | +function give_sortable_form_columns($columns) { |
|
134 | 134 | $columns['price'] = 'price'; |
135 | 135 | $columns['sales'] = 'sales'; |
136 | 136 | $columns['earnings'] = 'earnings'; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $columns; |
140 | 140 | } |
141 | 141 | |
142 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
142 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Sorts Columns in the Forms List Table |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return array $vars Array of all the sort variables |
152 | 152 | */ |
153 | -function give_sort_forms( $vars ) { |
|
153 | +function give_sort_forms($vars) { |
|
154 | 154 | // Check if we're viewing the "give_forms" post type |
155 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
155 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
156 | 156 | // Check if 'orderby' is set to "sales" |
157 | - if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) { |
|
157 | + if (isset($vars['orderby']) && 'sales' == $vars['orderby']) { |
|
158 | 158 | $vars = array_merge( |
159 | 159 | $vars, |
160 | 160 | array( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // Check if "orderby" is set to "earnings" |
168 | - if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) { |
|
168 | + if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) { |
|
169 | 169 | $vars = array_merge( |
170 | 170 | $vars, |
171 | 171 | array( |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | // Check if "orderby" is set to "price" |
179 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
179 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
180 | 180 | $vars = array_merge( |
181 | 181 | $vars, |
182 | 182 | array( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check if "orderby" is set to "goal" |
190 | - if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) { |
|
190 | + if (isset($vars['orderby']) && 'goal' == $vars['orderby']) { |
|
191 | 191 | $vars = array_merge( |
192 | 192 | $vars, |
193 | 193 | array( |
@@ -210,16 +210,16 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return array Array of all sort variables |
212 | 212 | */ |
213 | -function give_filter_forms( $vars ) { |
|
214 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
213 | +function give_filter_forms($vars) { |
|
214 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
215 | 215 | |
216 | 216 | // If an author ID was passed, use it |
217 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
217 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
218 | 218 | |
219 | 219 | $author_id = $_REQUEST['author']; |
220 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
220 | + if ((int) $author_id !== get_current_user_id()) { |
|
221 | 221 | // Tried to view the products of another person, sorry |
222 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
222 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
223 | 223 | } |
224 | 224 | $vars = array_merge( |
225 | 225 | $vars, |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | function give_forms_load() { |
247 | - add_filter( 'request', 'give_sort_forms' ); |
|
248 | - add_filter( 'request', 'give_filter_forms' ); |
|
247 | + add_filter('request', 'give_sort_forms'); |
|
248 | + add_filter('request', 'give_filter_forms'); |
|
249 | 249 | } |
250 | 250 | |
251 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
251 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Remove Forms Month Filter |
@@ -262,17 +262,17 @@ discard block |
||
262 | 262 | * @global $typenow The post type we are viewing |
263 | 263 | * @return array Empty array disables the dropdown |
264 | 264 | */ |
265 | -function give_remove_month_filter( $dates ) { |
|
265 | +function give_remove_month_filter($dates) { |
|
266 | 266 | global $typenow; |
267 | 267 | |
268 | - if ( $typenow == 'give_forms' ) { |
|
268 | + if ($typenow == 'give_forms') { |
|
269 | 269 | $dates = array(); |
270 | 270 | } |
271 | 271 | |
272 | 272 | return $dates; |
273 | 273 | } |
274 | 274 | |
275 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
275 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Adds price field to Quick Edit options |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return void |
286 | 286 | */ |
287 | -function give_price_field_quick_edit( $column_name, $post_type ) { |
|
288 | - if ( $column_name != 'price' || $post_type != 'give_forms' ) { |
|
287 | +function give_price_field_quick_edit($column_name, $post_type) { |
|
288 | + if ($column_name != 'price' || $post_type != 'give_forms') { |
|
289 | 289 | return; |
290 | 290 | } |
291 | 291 | ?> |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | <h4><?php |
295 | 295 | printf( |
296 | 296 | /* translators: %s: forms singular label */ |
297 | - esc_html__( '%s Configuration', 'give' ), |
|
297 | + esc_html__('%s Configuration', 'give'), |
|
298 | 298 | give_get_forms_label_singular() |
299 | 299 | ); |
300 | 300 | ?></h4> |
301 | 301 | <label> |
302 | - <span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span> |
|
302 | + <span class="title"><?php esc_html_e('Price', 'give'); ?></span> |
|
303 | 303 | <span class="input-text-wrap"> |
304 | 304 | <input type="text" name="_give_regprice" class="text regprice" /> |
305 | 305 | </span> |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | <?php |
311 | 311 | } |
312 | 312 | |
313 | -add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 ); |
|
314 | -add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 ); |
|
313 | +add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2); |
|
314 | +add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Updates price when saving post |
@@ -322,23 +322,23 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return void |
324 | 324 | */ |
325 | -function give_price_save_quick_edit( $post_id ) { |
|
326 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
325 | +function give_price_save_quick_edit($post_id) { |
|
326 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
329 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
330 | 330 | return $post_id; |
331 | 331 | } |
332 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
332 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
333 | 333 | return $post_id; |
334 | 334 | } |
335 | 335 | |
336 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
337 | - update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ); |
|
336 | + if (isset($_REQUEST['_give_regprice'])) { |
|
337 | + update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice']))); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
341 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
342 | 342 | |
343 | 343 | /** |
344 | 344 | * Process bulk edit actions via AJAX |
@@ -348,18 +348,18 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function give_save_bulk_edit() { |
350 | 350 | |
351 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
351 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
352 | 352 | |
353 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
354 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
355 | - foreach ( $post_ids as $post_id ) { |
|
353 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
354 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
355 | + foreach ($post_ids as $post_id) { |
|
356 | 356 | |
357 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
357 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
358 | 358 | continue; |
359 | 359 | } |
360 | 360 | |
361 | - if ( ! empty( $price ) ) { |
|
362 | - update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) ); |
|
361 | + if ( ! empty($price)) { |
|
362 | + update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price)); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | } |
@@ -367,4 +367,4 @@ discard block |
||
367 | 367 | die(); |
368 | 368 | } |
369 | 369 | |
370 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
370 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return mixed String if search is present, false otherwise |
|
160 | + * @return string|false String if search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -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 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ) |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give') |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox" title="<?php esc_attr_e( 'View Request Details', 'give' ); ?> "><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox" title="<?php esc_attr_e('View Request Details', 'give'); ?> "><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return mixed String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } else if ( is_email( $search ) ) { |
|
217 | + } else if (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | 'meta_query' => $this->get_meta_query() |
294 | 294 | ); |
295 | 295 | |
296 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
296 | + $logs = $give_logs->get_connected_logs($log_query); |
|
297 | 297 | |
298 | - if ( $logs ) { |
|
299 | - foreach ( $logs as $log ) { |
|
298 | + if ($logs) { |
|
299 | + foreach ($logs as $log) { |
|
300 | 300 | |
301 | 301 | $logs_data[] = array( |
302 | 302 | 'ID' => $log->ID, |
303 | - 'ip' => get_post_meta( $log->ID, '_give_log_request_ip', true ), |
|
303 | + 'ip' => get_post_meta($log->ID, '_give_log_request_ip', true), |
|
304 | 304 | 'date' => $log->post_date |
305 | 305 | ); |
306 | 306 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | $columns = $this->get_columns(); |
329 | 329 | $hidden = array(); // No hidden columns |
330 | 330 | $sortable = $this->get_sortable_columns(); |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | $this->items = $this->get_logs(); |
333 | - $total_items = $give_logs->get_log_count( 0, 'api_requests' ); |
|
333 | + $total_items = $give_logs->get_log_count(0, 'api_requests'); |
|
334 | 334 | |
335 | - $this->set_pagination_args( array( |
|
335 | + $this->set_pagination_args(array( |
|
336 | 336 | 'total_items' => $total_items, |
337 | 337 | 'per_page' => $this->per_page, |
338 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
338 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * |
144 | 144 | * @access public |
145 | 145 | * @since 1.0 |
146 | - * @return mixed string If search is present, false otherwise |
|
146 | + * @return string|false string If search is present, false otherwise |
|
147 | 147 | */ |
148 | 148 | public function get_search() { |
149 | 149 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -71,8 +71,8 @@ |
||
71 | 71 | |
72 | 72 | case 'user_id' : |
73 | 73 | return '<a href="' . |
74 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
75 | - '">' . $item['user_name'] . '</a>'; |
|
74 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
75 | + '">' . $item['user_name'] . '</a>'; |
|
76 | 76 | |
77 | 77 | case 'amount' : |
78 | 78 | return give_currency_filter( give_format_amount( $item['amount'] ) ); |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | 50 | 'ajax' => false // Does this table support ajax? |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,37 +64,37 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>'; |
|
73 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>'; |
|
74 | 74 | |
75 | 75 | case 'user_id' : |
76 | - return '<a href="' . |
|
77 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
78 | - '">' . $item['user_name'] . '</a>'; |
|
76 | + return '<a href="'. |
|
77 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
78 | + '">'.$item['user_name'].'</a>'; |
|
79 | 79 | |
80 | 80 | case 'amount' : |
81 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
81 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
82 | 82 | |
83 | 83 | case 'status' : |
84 | 84 | |
85 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
85 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
86 | 86 | |
87 | - if ( $payment->mode == 'test' ) { |
|
88 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This payment was made in test mode', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
87 | + if ($payment->mode == 'test') { |
|
88 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This payment was made in test mode', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $value; |
92 | 92 | |
93 | 93 | case 'payment_id' : |
94 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
94 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
95 | 95 | |
96 | 96 | default: |
97 | - return $item[ $column_name ]; |
|
97 | + return $item[$column_name]; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function get_columns() { |
109 | 109 | $columns = array( |
110 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
111 | - 'user_id' => esc_html__( 'Donor', 'give' ), |
|
110 | + 'ID' => esc_html__('Log ID', 'give'), |
|
111 | + 'user_id' => esc_html__('Donor', 'give'), |
|
112 | 112 | 'form' => give_get_forms_label_singular(), |
113 | - 'amount' => esc_html__( 'Donation Amount', 'give' ), |
|
114 | - 'status' => esc_html__( 'Status', 'give' ), |
|
115 | - 'payment_id' => esc_html__( 'Transaction ID', 'give' ), |
|
116 | - 'date' => esc_html__( 'Date', 'give' ) |
|
113 | + 'amount' => esc_html__('Donation Amount', 'give'), |
|
114 | + 'status' => esc_html__('Status', 'give'), |
|
115 | + 'payment_id' => esc_html__('Transaction ID', 'give'), |
|
116 | + 'date' => esc_html__('Date', 'give') |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | return $columns; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return int Current page number |
128 | 128 | */ |
129 | 129 | public function get_paged() { |
130 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
130 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return mixed int If User ID, string If Email/Login |
139 | 139 | */ |
140 | 140 | public function get_filtered_user() { |
141 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
141 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return int Download ID |
150 | 150 | */ |
151 | 151 | public function get_filtered_give_form() { |
152 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
152 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return mixed string If search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
179 | + protected function display_tablenav($which) { |
|
180 | 180 | |
181 | - if ( 'top' === $which ) { |
|
182 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
181 | + if ('top' === $which) { |
|
182 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
183 | 183 | } |
184 | 184 | ?> |
185 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
185 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
186 | 186 | |
187 | 187 | <div class="alignleft actions bulkactions"> |
188 | - <?php $this->bulk_actions( $which ); ?> |
|
188 | + <?php $this->bulk_actions($which); ?> |
|
189 | 189 | </div> |
190 | 190 | <?php |
191 | - $this->extra_tablenav( $which ); |
|
192 | - $this->pagination( $which ); |
|
191 | + $this->extra_tablenav($which); |
|
192 | + $this->pagination($which); |
|
193 | 193 | ?> |
194 | 194 | |
195 | 195 | <br class="clear"/> |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $meta_query = array(); |
214 | 214 | |
215 | - if ( $user ) { |
|
215 | + if ($user) { |
|
216 | 216 | // Show only logs from a specific user |
217 | 217 | $meta_query[] = array( |
218 | 218 | 'key' => '_give_log_user_id', |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | $search = $this->get_search(); |
224 | - if ( $search ) { |
|
225 | - if ( is_email( $search ) ) { |
|
224 | + if ($search) { |
|
225 | + if (is_email($search)) { |
|
226 | 226 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
227 | 227 | $key = '_give_log_user_info'; |
228 | 228 | $compare = 'LIKE'; |
@@ -231,32 +231,32 @@ discard block |
||
231 | 231 | $key = '_give_log_user_id'; |
232 | 232 | $compare = 'LIKE'; |
233 | 233 | |
234 | - if ( ! is_numeric( $search ) ) { |
|
234 | + if ( ! is_numeric($search)) { |
|
235 | 235 | // Searching for user by username |
236 | - $user = get_user_by( 'login', $search ); |
|
236 | + $user = get_user_by('login', $search); |
|
237 | 237 | |
238 | - if ( $user ) { |
|
238 | + if ($user) { |
|
239 | 239 | // Found one, set meta value to user's ID |
240 | 240 | $search = $user->ID; |
241 | 241 | } else { |
242 | 242 | // No user found so let's do a real search query |
243 | - $users = new WP_User_Query( array( |
|
243 | + $users = new WP_User_Query(array( |
|
244 | 244 | 'search' => $search, |
245 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
245 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
246 | 246 | 'number' => 1, |
247 | 247 | 'fields' => 'ids' |
248 | - ) ); |
|
248 | + )); |
|
249 | 249 | |
250 | 250 | $found_user = $users->get_results(); |
251 | 251 | |
252 | - if ( $found_user ) { |
|
252 | + if ($found_user) { |
|
253 | 253 | $search = $found_user[0]; |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( ! $this->file_search ) { |
|
259 | + if ( ! $this->file_search) { |
|
260 | 260 | // Meta query only works for non file name searche |
261 | 261 | $meta_query[] = array( |
262 | 262 | 'key' => $key, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @since 1.0 |
278 | 278 | * @return void |
279 | 279 | */ |
280 | - function bulk_actions( $which = '' ) { |
|
280 | + function bulk_actions($which = '') { |
|
281 | 281 | give_log_views(); |
282 | 282 | } |
283 | 283 | |
@@ -289,22 +289,22 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function give_forms_filter() { |
292 | - $give_forms = get_posts( array( |
|
292 | + $give_forms = get_posts(array( |
|
293 | 293 | 'post_type' => 'give_forms', |
294 | 294 | 'post_status' => 'any', |
295 | - 'posts_per_page' => - 1, |
|
295 | + 'posts_per_page' => -1, |
|
296 | 296 | 'orderby' => 'title', |
297 | 297 | 'order' => 'ASC', |
298 | 298 | 'fields' => 'ids', |
299 | 299 | 'update_post_meta_cache' => false, |
300 | 300 | 'update_post_term_cache' => false |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | |
303 | - if ( $give_forms ) { |
|
303 | + if ($give_forms) { |
|
304 | 304 | echo '<select name="form" id="give-log-form-filter">'; |
305 | - echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>'; |
|
306 | - foreach ( $give_forms as $form ) { |
|
307 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>'; |
|
305 | + echo '<option value="0">'.esc_html__('All', 'give').'</option>'; |
|
306 | + foreach ($give_forms as $form) { |
|
307 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>'; |
|
308 | 308 | } |
309 | 309 | echo '</select>'; |
310 | 310 | } |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | global $give_logs; |
323 | 323 | |
324 | 324 | // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs |
325 | - wp_suspend_cache_addition( true ); |
|
325 | + wp_suspend_cache_addition(true); |
|
326 | 326 | |
327 | 327 | $logs_data = array(); |
328 | 328 | $paged = $this->get_paged(); |
329 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
329 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
330 | 330 | $user = $this->get_filtered_user(); |
331 | 331 | |
332 | 332 | $log_query = array( |
@@ -336,26 +336,26 @@ discard block |
||
336 | 336 | 'meta_query' => $this->get_meta_query() |
337 | 337 | ); |
338 | 338 | |
339 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
339 | + $logs = $give_logs->get_connected_logs($log_query); |
|
340 | 340 | |
341 | - if ( $logs ) { |
|
342 | - foreach ( $logs as $log ) { |
|
343 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
341 | + if ($logs) { |
|
342 | + foreach ($logs as $log) { |
|
343 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
344 | 344 | |
345 | 345 | // Make sure this payment hasn't been deleted |
346 | - if ( get_post( $payment_id ) ) : |
|
347 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
348 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
349 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
346 | + if (get_post($payment_id)) : |
|
347 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
348 | + $payment_meta = give_get_payment_meta($payment_id); |
|
349 | + $payment_amount = give_get_payment_amount($payment_id); |
|
350 | 350 | |
351 | 351 | $logs_data[] = array( |
352 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
352 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
353 | 353 | 'payment_id' => $payment_id, |
354 | 354 | 'form' => $log->post_parent, |
355 | 355 | 'amount' => $payment_amount, |
356 | 356 | 'user_id' => $user_info['id'], |
357 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
358 | - 'date' => get_post_field( 'post_date', $payment_id ) |
|
357 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
358 | + 'date' => get_post_field('post_date', $payment_id) |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | endif; |
@@ -384,15 +384,15 @@ discard block |
||
384 | 384 | $columns = $this->get_columns(); |
385 | 385 | $hidden = array(); |
386 | 386 | $sortable = $this->get_sortable_columns(); |
387 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
387 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
388 | 388 | $current_page = $this->get_pagenum(); |
389 | 389 | $this->items = $this->get_logs(); |
390 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
390 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
391 | 391 | |
392 | - $this->set_pagination_args( array( |
|
392 | + $this->set_pagination_args(array( |
|
393 | 393 | 'total_items' => $total_items, |
394 | 394 | 'per_page' => $this->per_page, |
395 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
395 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
396 | 396 | ) |
397 | 397 | ); |
398 | 398 | } |
@@ -576,7 +576,7 @@ |
||
576 | 576 | * selected date-range (if any) |
577 | 577 | * |
578 | 578 | * @since 1.0 |
579 | - * @return array |
|
579 | + * @return integer|null |
|
580 | 580 | */ |
581 | 581 | function give_get_report_dates() { |
582 | 582 | $dates = array(); |
@@ -143,9 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | endwhile; |
145 | 145 | |
146 | - else : |
|
146 | + else { |
|
147 | + : |
|
147 | 148 | |
148 | 149 | $sales = give_get_sales_by_date( null, $i, $y ); |
150 | + } |
|
149 | 151 | $sales_totals += $sales; |
150 | 152 | |
151 | 153 | $earnings = give_get_earnings_by_date( null, $i, $y ); |
@@ -393,9 +395,11 @@ discard block |
||
393 | 395 | |
394 | 396 | endwhile; |
395 | 397 | |
396 | - else : |
|
398 | + else { |
|
399 | + : |
|
397 | 400 | |
398 | 401 | $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
402 | + } |
|
399 | 403 | |
400 | 404 | $date = mktime( 0, 0, 0, $i, 1, $y ); |
401 | 405 | $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $dates = give_get_report_dates(); |
26 | 26 | |
27 | 27 | // Determine graph options |
28 | - switch ( $dates['range'] ) : |
|
28 | + switch ($dates['range']) : |
|
29 | 29 | case 'today' : |
30 | 30 | case 'yesterday' : |
31 | 31 | $day_by_day = true; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $day_by_day = false; |
38 | 38 | break; |
39 | 39 | case 'other' : |
40 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
40 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
41 | 41 | $day_by_day = false; |
42 | 42 | } else { |
43 | 43 | $day_by_day = true; |
@@ -49,61 +49,61 @@ discard block |
||
49 | 49 | endswitch; |
50 | 50 | |
51 | 51 | $earnings_totals = 0.00; // Total earnings for time period shown |
52 | - $sales_totals = 0; // Total sales for time period shown |
|
52 | + $sales_totals = 0; // Total sales for time period shown |
|
53 | 53 | |
54 | 54 | $earnings_data = array(); |
55 | 55 | $sales_data = array(); |
56 | 56 | |
57 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
57 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
58 | 58 | // Hour by hour |
59 | 59 | $hour = 1; |
60 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
61 | - while ( $hour <= 23 ) : |
|
60 | + $month = date('n', current_time('timestamp')); |
|
61 | + while ($hour <= 23) : |
|
62 | 62 | |
63 | - $sales = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
64 | - $earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour ); |
|
63 | + $sales = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour); |
|
64 | + $earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour); |
|
65 | 65 | |
66 | 66 | $sales_totals += $sales; |
67 | 67 | $earnings_totals += $earnings; |
68 | 68 | |
69 | - $date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000; |
|
70 | - $sales_data[] = array( $date, $sales ); |
|
71 | - $earnings_data[] = array( $date, $earnings ); |
|
69 | + $date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000; |
|
70 | + $sales_data[] = array($date, $sales); |
|
71 | + $earnings_data[] = array($date, $earnings); |
|
72 | 72 | |
73 | - $hour ++; |
|
73 | + $hour++; |
|
74 | 74 | endwhile; |
75 | 75 | |
76 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
76 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
77 | 77 | |
78 | 78 | // Day by day |
79 | 79 | $day = $dates['day']; |
80 | 80 | $day_end = $dates['day_end']; |
81 | 81 | $month = $dates['m_start']; |
82 | - while ( $day <= $day_end ) : |
|
83 | - $sales = give_get_sales_by_date( $day, $month, $dates['year'] ); |
|
82 | + while ($day <= $day_end) : |
|
83 | + $sales = give_get_sales_by_date($day, $month, $dates['year']); |
|
84 | 84 | $sales_totals += $sales; |
85 | 85 | |
86 | - $earnings = give_get_earnings_by_date( $day, $month, $dates['year'] ); |
|
86 | + $earnings = give_get_earnings_by_date($day, $month, $dates['year']); |
|
87 | 87 | $earnings_totals += $earnings; |
88 | 88 | |
89 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000; |
|
90 | - $sales_data[] = array( $date, $sales ); |
|
91 | - $earnings_data[] = array( $date, $earnings ); |
|
92 | - $day ++; |
|
89 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000; |
|
90 | + $sales_data[] = array($date, $sales); |
|
91 | + $earnings_data[] = array($date, $earnings); |
|
92 | + $day++; |
|
93 | 93 | endwhile; |
94 | 94 | |
95 | 95 | } else { |
96 | 96 | |
97 | 97 | $y = $dates['year']; |
98 | - while ( $y <= $dates['year_end'] ) : |
|
98 | + while ($y <= $dates['year_end']) : |
|
99 | 99 | |
100 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
100 | + if ($dates['year'] == $dates['year_end']) { |
|
101 | 101 | $month_start = $dates['m_start']; |
102 | 102 | $month_end = $dates['m_end']; |
103 | - } elseif ( $y == $dates['year'] ) { |
|
103 | + } elseif ($y == $dates['year']) { |
|
104 | 104 | $month_start = $dates['m_start']; |
105 | 105 | $month_end = 12; |
106 | - } elseif ( $y == $dates['year_end'] ) { |
|
106 | + } elseif ($y == $dates['year_end']) { |
|
107 | 107 | $month_start = 1; |
108 | 108 | $month_end = $dates['m_end']; |
109 | 109 | } else { |
@@ -112,48 +112,48 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $i = $month_start; |
115 | - while ( $i <= $month_end ) : |
|
115 | + while ($i <= $month_end) : |
|
116 | 116 | |
117 | - if ( $day_by_day ) : |
|
117 | + if ($day_by_day) : |
|
118 | 118 | |
119 | - if ( $i == $month_end ) { |
|
119 | + if ($i == $month_end) { |
|
120 | 120 | |
121 | 121 | $num_of_days = $dates['day_end']; |
122 | 122 | |
123 | 123 | } else { |
124 | 124 | |
125 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
125 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | 129 | $d = $dates['day']; |
130 | 130 | |
131 | - while ( $d <= $num_of_days ) : |
|
131 | + while ($d <= $num_of_days) : |
|
132 | 132 | |
133 | - $sales = give_get_sales_by_date( $d, $i, $y ); |
|
133 | + $sales = give_get_sales_by_date($d, $i, $y); |
|
134 | 134 | $sales_totals += $sales; |
135 | 135 | |
136 | - $earnings = give_get_earnings_by_date( $d, $i, $y ); |
|
136 | + $earnings = give_get_earnings_by_date($d, $i, $y); |
|
137 | 137 | $earnings_totals += $earnings; |
138 | 138 | |
139 | - $date = mktime( 0, 0, 0, $i, $d, $y ) * 1000; |
|
140 | - $sales_data[] = array( $date, $sales ); |
|
141 | - $earnings_data[] = array( $date, $earnings ); |
|
142 | - $d ++; |
|
139 | + $date = mktime(0, 0, 0, $i, $d, $y) * 1000; |
|
140 | + $sales_data[] = array($date, $sales); |
|
141 | + $earnings_data[] = array($date, $earnings); |
|
142 | + $d++; |
|
143 | 143 | |
144 | 144 | endwhile; |
145 | 145 | |
146 | 146 | else : |
147 | 147 | |
148 | - $sales = give_get_sales_by_date( null, $i, $y ); |
|
148 | + $sales = give_get_sales_by_date(null, $i, $y); |
|
149 | 149 | $sales_totals += $sales; |
150 | 150 | |
151 | - $earnings = give_get_earnings_by_date( null, $i, $y ); |
|
151 | + $earnings = give_get_earnings_by_date(null, $i, $y); |
|
152 | 152 | $earnings_totals += $earnings; |
153 | 153 | |
154 | - if ( $i == $month_end ) { |
|
154 | + if ($i == $month_end) { |
|
155 | 155 | |
156 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
156 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | - $date = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000; |
|
165 | - $sales_data[] = array( $date, $sales ); |
|
166 | - $earnings_data[] = array( $date, $earnings ); |
|
164 | + $date = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000; |
|
165 | + $sales_data[] = array($date, $sales); |
|
166 | + $earnings_data[] = array($date, $earnings); |
|
167 | 167 | |
168 | 168 | endif; |
169 | 169 | |
170 | - $i ++; |
|
170 | + $i++; |
|
171 | 171 | |
172 | 172 | endwhile; |
173 | 173 | |
174 | - $y ++; |
|
174 | + $y++; |
|
175 | 175 | endwhile; |
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | 179 | $data = array( |
180 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
181 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
180 | + esc_html__('Income', 'give') => $earnings_data, |
|
181 | + esc_html__('Donations', 'give') => $sales_data |
|
182 | 182 | ); |
183 | 183 | |
184 | 184 | // start our own output buffer |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | <div class="postbox"> |
191 | 191 | <div class="inside"> |
192 | 192 | <?php |
193 | - $graph = new Give_Graph( $data ); |
|
194 | - $graph->set( 'x_mode', 'time' ); |
|
195 | - $graph->set( 'multiple_y_axes', true ); |
|
193 | + $graph = new Give_Graph($data); |
|
194 | + $graph->set('x_mode', 'time'); |
|
195 | + $graph->set('multiple_y_axes', true); |
|
196 | 196 | $graph->display(); |
197 | 197 | |
198 | - if ( 'this_month' == $dates['range'] ) { |
|
198 | + if ('this_month' == $dates['range']) { |
|
199 | 199 | $estimated = give_estimated_monthly_stats(); |
200 | 200 | } |
201 | 201 | ?> |
@@ -206,32 +206,32 @@ discard block |
||
206 | 206 | <tbody> |
207 | 207 | <tr> |
208 | 208 | <td class="row-title"> |
209 | - <label for="tablecell"><?php esc_html_e( 'Total income for period: ', 'give' ); ?></label></td> |
|
210 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
209 | + <label for="tablecell"><?php esc_html_e('Total income for period: ', 'give'); ?></label></td> |
|
210 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
211 | 211 | </tr> |
212 | 212 | <tr class="alternate"> |
213 | 213 | <td class="row-title"> |
214 | - <label for="tablecell"><?php esc_html_e( 'Total donations for period shown: ', 'give' ); ?></label> |
|
214 | + <label for="tablecell"><?php esc_html_e('Total donations for period shown: ', 'give'); ?></label> |
|
215 | 215 | </td> |
216 | 216 | <td><?php echo $sales_totals; ?></td> |
217 | 217 | </tr> |
218 | - <?php if ( 'this_month' == $dates['range'] ) : ?> |
|
218 | + <?php if ('this_month' == $dates['range']) : ?> |
|
219 | 219 | <tr> |
220 | 220 | <td class="row-title"> |
221 | - <label for="tablecell"><?php esc_html_e( 'Estimated monthly income: ', 'give' ); ?></label> |
|
221 | + <label for="tablecell"><?php esc_html_e('Estimated monthly income: ', 'give'); ?></label> |
|
222 | 222 | </td> |
223 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td> |
|
223 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td> |
|
224 | 224 | </tr> |
225 | 225 | <tr class="alternate"> |
226 | 226 | <td class="row-title"> |
227 | - <label for="tablecell"><?php esc_html_e( 'Estimated monthly donations: ', 'give' ); ?></label> |
|
227 | + <label for="tablecell"><?php esc_html_e('Estimated monthly donations: ', 'give'); ?></label> |
|
228 | 228 | </td> |
229 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
229 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
230 | 230 | </tr> |
231 | 231 | <?php endif; ?> |
232 | 232 | </table> |
233 | 233 | |
234 | - <?php do_action( 'give_reports_graph_additional_stats' ); ?> |
|
234 | + <?php do_action('give_reports_graph_additional_stats'); ?> |
|
235 | 235 | |
236 | 236 | </div> |
237 | 237 | </div> |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | * @since 1.0 |
250 | 250 | * @return void |
251 | 251 | */ |
252 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
252 | +function give_reports_graph_of_form($form_id = 0) { |
|
253 | 253 | // Retrieve the queried dates |
254 | 254 | $dates = give_get_report_dates(); |
255 | 255 | |
256 | 256 | // Determine graph options |
257 | - switch ( $dates['range'] ) : |
|
257 | + switch ($dates['range']) : |
|
258 | 258 | case 'today' : |
259 | 259 | case 'yesterday' : |
260 | 260 | $day_by_day = true; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $day_by_day = false; |
273 | 273 | break; |
274 | 274 | case 'other' : |
275 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
275 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
276 | 276 | $day_by_day = false; |
277 | 277 | } else { |
278 | 278 | $day_by_day = true; |
@@ -284,75 +284,75 @@ discard block |
||
284 | 284 | endswitch; |
285 | 285 | |
286 | 286 | $earnings_totals = (float) 0.00; // Total earnings for time period shown |
287 | - $sales_totals = 0; // Total sales for time period shown |
|
287 | + $sales_totals = 0; // Total sales for time period shown |
|
288 | 288 | |
289 | 289 | $earnings_data = array(); |
290 | 290 | $sales_data = array(); |
291 | 291 | $stats = new Give_Payment_Stats; |
292 | 292 | |
293 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
293 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
294 | 294 | |
295 | 295 | // Hour by hour |
296 | 296 | $month = $dates['m_start']; |
297 | 297 | $hour = 1; |
298 | 298 | $minute = 0; |
299 | 299 | $second = 0; |
300 | - while ( $hour <= 23 ) : |
|
300 | + while ($hour <= 23) : |
|
301 | 301 | |
302 | - if ( $hour == 23 ) { |
|
302 | + if ($hour == 23) { |
|
303 | 303 | $minute = $second = 59; |
304 | 304 | } |
305 | 305 | |
306 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
307 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
306 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
307 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
308 | 308 | |
309 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
309 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
310 | 310 | $sales_totals += $sales; |
311 | 311 | |
312 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
312 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
313 | 313 | $earnings_totals += $earnings; |
314 | 314 | |
315 | - $sales_data[] = array( $date * 1000, $sales ); |
|
316 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
315 | + $sales_data[] = array($date * 1000, $sales); |
|
316 | + $earnings_data[] = array($date * 1000, $earnings); |
|
317 | 317 | |
318 | - $hour ++; |
|
318 | + $hour++; |
|
319 | 319 | endwhile; |
320 | 320 | |
321 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
321 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
322 | 322 | |
323 | 323 | //Day by day |
324 | 324 | $day = $dates['day']; |
325 | 325 | $day_end = $dates['day_end']; |
326 | 326 | $month = $dates['m_start']; |
327 | - while ( $day <= $day_end ) : |
|
327 | + while ($day <= $day_end) : |
|
328 | 328 | |
329 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
330 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
331 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
329 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
330 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
331 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
332 | 332 | $sales_totals += $sales; |
333 | 333 | |
334 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
334 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
335 | 335 | $earnings_totals += $earnings; |
336 | 336 | |
337 | - $sales_data[] = array( $date * 1000, $sales ); |
|
338 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
337 | + $sales_data[] = array($date * 1000, $sales); |
|
338 | + $earnings_data[] = array($date * 1000, $earnings); |
|
339 | 339 | |
340 | - $day ++; |
|
340 | + $day++; |
|
341 | 341 | endwhile; |
342 | 342 | |
343 | 343 | } else { |
344 | 344 | |
345 | 345 | $y = $dates['year']; |
346 | 346 | |
347 | - while ( $y <= $dates['year_end'] ) : |
|
347 | + while ($y <= $dates['year_end']) : |
|
348 | 348 | |
349 | 349 | $last_year = false; |
350 | 350 | |
351 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
351 | + if ($dates['year'] == $dates['year_end']) { |
|
352 | 352 | $month_start = $dates['m_start']; |
353 | 353 | $month_end = $dates['m_end']; |
354 | 354 | $last_year = true; |
355 | - } elseif ( $y == $dates['year'] ) { |
|
355 | + } elseif ($y == $dates['year']) { |
|
356 | 356 | $month_start = $dates['m_start']; |
357 | 357 | $month_end = 12; |
358 | 358 | } else { |
@@ -361,75 +361,75 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | $i = $month_start; |
364 | - while ( $i <= $month_end ) : |
|
364 | + while ($i <= $month_end) : |
|
365 | 365 | |
366 | - if ( $day_by_day ) : |
|
366 | + if ($day_by_day) : |
|
367 | 367 | |
368 | - if ( $i == $month_end && $last_year ) { |
|
368 | + if ($i == $month_end && $last_year) { |
|
369 | 369 | |
370 | 370 | $num_of_days = $dates['day_end']; |
371 | 371 | |
372 | 372 | } else { |
373 | 373 | |
374 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
374 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
375 | 375 | |
376 | 376 | } |
377 | 377 | |
378 | 378 | $d = $dates['day']; |
379 | - while ( $d <= $num_of_days ) : |
|
379 | + while ($d <= $num_of_days) : |
|
380 | 380 | |
381 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
382 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
381 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
382 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
383 | 383 | |
384 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
384 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
385 | 385 | $sales_totals += $sales; |
386 | 386 | |
387 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
387 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
388 | 388 | $earnings_totals += $earnings; |
389 | 389 | |
390 | - $sales_data[] = array( $date * 1000, $sales ); |
|
391 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
392 | - $d ++; |
|
390 | + $sales_data[] = array($date * 1000, $sales); |
|
391 | + $earnings_data[] = array($date * 1000, $earnings); |
|
392 | + $d++; |
|
393 | 393 | |
394 | 394 | endwhile; |
395 | 395 | |
396 | 396 | else : |
397 | 397 | |
398 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
398 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
399 | 399 | |
400 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
401 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
400 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
401 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
402 | 402 | |
403 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
403 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
404 | 404 | $sales_totals += $sales; |
405 | 405 | |
406 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
406 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
407 | 407 | $earnings_totals += $earnings; |
408 | 408 | |
409 | - $sales_data[] = array( $date * 1000, $sales ); |
|
410 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
409 | + $sales_data[] = array($date * 1000, $sales); |
|
410 | + $earnings_data[] = array($date * 1000, $earnings); |
|
411 | 411 | endif; |
412 | 412 | |
413 | - $i ++; |
|
413 | + $i++; |
|
414 | 414 | |
415 | 415 | endwhile; |
416 | 416 | |
417 | - $y ++; |
|
417 | + $y++; |
|
418 | 418 | endwhile; |
419 | 419 | |
420 | 420 | } |
421 | 421 | |
422 | 422 | $data = array( |
423 | - esc_html__( 'Income', 'give' ) => $earnings_data, |
|
424 | - esc_html__( 'Donations', 'give' ) => $sales_data |
|
423 | + esc_html__('Income', 'give') => $earnings_data, |
|
424 | + esc_html__('Donations', 'give') => $sales_data |
|
425 | 425 | ); |
426 | 426 | |
427 | 427 | ?> |
428 | 428 | <h3><span><?php |
429 | 429 | printf( |
430 | 430 | /* translators: %s: form title */ |
431 | - esc_html__( 'Income Over Time for %s', 'give' ), |
|
432 | - get_the_title( $form_id ) |
|
431 | + esc_html__('Income Over Time for %s', 'give'), |
|
432 | + get_the_title($form_id) |
|
433 | 433 | ); |
434 | 434 | ?></span></h3> |
435 | 435 | |
@@ -437,9 +437,9 @@ discard block |
||
437 | 437 | <div class="postbox"> |
438 | 438 | <div class="inside"> |
439 | 439 | <?php |
440 | - $graph = new Give_Graph( $data ); |
|
441 | - $graph->set( 'x_mode', 'time' ); |
|
442 | - $graph->set( 'multiple_y_axes', true ); |
|
440 | + $graph = new Give_Graph($data); |
|
441 | + $graph->set('x_mode', 'time'); |
|
442 | + $graph->set('multiple_y_axes', true); |
|
443 | 443 | $graph->display(); |
444 | 444 | ?> |
445 | 445 | </div> |
@@ -449,26 +449,26 @@ discard block |
||
449 | 449 | <tbody> |
450 | 450 | <tr> |
451 | 451 | <td class="row-title"> |
452 | - <label for="tablecell"><?php esc_html_e( 'Total income for period: ', 'give' ); ?></label></td> |
|
453 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td> |
|
452 | + <label for="tablecell"><?php esc_html_e('Total income for period: ', 'give'); ?></label></td> |
|
453 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td> |
|
454 | 454 | </tr> |
455 | 455 | <tr class="alternate"> |
456 | 456 | <td class="row-title"> |
457 | - <label for="tablecell"><?php esc_html_e( 'Total donations for period: ', 'give' ); ?></label> |
|
457 | + <label for="tablecell"><?php esc_html_e('Total donations for period: ', 'give'); ?></label> |
|
458 | 458 | </td> |
459 | 459 | <td><?php echo $sales_totals; ?></td> |
460 | 460 | </tr> |
461 | 461 | <tr> |
462 | 462 | <td class="row-title"> |
463 | - <label for="tablecell"><?php esc_html_e( 'Average monthly income: ', 'give' ); ?></label> |
|
463 | + <label for="tablecell"><?php esc_html_e('Average monthly income: ', 'give'); ?></label> |
|
464 | 464 | </td> |
465 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td> |
|
465 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td> |
|
466 | 466 | </tr> |
467 | 467 | <tr class="alternate"> |
468 | 468 | <td class="row-title"> |
469 | - <label for="tablecell"><?php esc_html_e( 'Average monthly donations: ', 'give' ); ?></label> |
|
469 | + <label for="tablecell"><?php esc_html_e('Average monthly donations: ', 'give'); ?></label> |
|
470 | 470 | </td> |
471 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
471 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
472 | 472 | </tr> |
473 | 473 | </tbody> |
474 | 474 | </table> |
@@ -485,29 +485,29 @@ discard block |
||
485 | 485 | * @return void |
486 | 486 | */ |
487 | 487 | function give_reports_graph_controls() { |
488 | - $date_options = apply_filters( 'give_report_date_options', array( |
|
489 | - 'today' => esc_html__( 'Today', 'give' ), |
|
490 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
491 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
492 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
493 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
494 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
495 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
496 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
497 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
498 | - 'last_year' => esc_html__( 'Last Year', 'give' ), |
|
499 | - 'other' => esc_html__( 'Custom', 'give' ) |
|
500 | - ) ); |
|
488 | + $date_options = apply_filters('give_report_date_options', array( |
|
489 | + 'today' => esc_html__('Today', 'give'), |
|
490 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
491 | + 'this_week' => esc_html__('This Week', 'give'), |
|
492 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
493 | + 'this_month' => esc_html__('This Month', 'give'), |
|
494 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
495 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
496 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
497 | + 'this_year' => esc_html__('This Year', 'give'), |
|
498 | + 'last_year' => esc_html__('Last Year', 'give'), |
|
499 | + 'other' => esc_html__('Custom', 'give') |
|
500 | + )); |
|
501 | 501 | |
502 | 502 | $dates = give_get_report_dates(); |
503 | 503 | $display = $dates['range'] == 'other' ? '' : 'style="display:none;"'; |
504 | 504 | $view = give_get_reporting_view(); |
505 | 505 | |
506 | - if ( empty( $dates['day_end'] ) ) { |
|
507 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
506 | + if (empty($dates['day_end'])) { |
|
507 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
508 | 508 | } |
509 | 509 | |
510 | - do_action( 'give_report_graph_controls_before' ); |
|
510 | + do_action('give_report_graph_controls_before'); |
|
511 | 511 | ?> |
512 | 512 | <form id="give-graphs-filter" method="get" class="alignright"> |
513 | 513 | <div class="tablenav top alignright"> |
@@ -515,53 +515,53 @@ discard block |
||
515 | 515 | |
516 | 516 | <input type="hidden" name="post_type" value="give_forms" /> |
517 | 517 | <input type="hidden" name="page" value="give-reports" /> |
518 | - <input type="hidden" name="view" value="<?php echo esc_attr( $view ); ?>" /> |
|
518 | + <input type="hidden" name="view" value="<?php echo esc_attr($view); ?>" /> |
|
519 | 519 | |
520 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
521 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
520 | + <?php if (isset($_GET['form-id'])) : ?> |
|
521 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
522 | 522 | <?php endif; ?> |
523 | 523 | |
524 | 524 | <div id="give-graphs-date-options-wrap" class="alignright"> |
525 | 525 | <select id="give-graphs-date-options" name="range"> |
526 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
527 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
526 | + <?php foreach ($date_options as $key => $option) : ?> |
|
527 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
528 | 528 | <?php endforeach; ?> |
529 | 529 | </select> |
530 | 530 | |
531 | - <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" /> |
|
531 | + <input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" /> |
|
532 | 532 | </div> |
533 | 533 | |
534 | 534 | <div id="give-date-range-options" <?php echo $display; ?>> |
535 | - <span><?php esc_html_e( 'From', 'give' ); ?> </span> |
|
535 | + <span><?php esc_html_e('From', 'give'); ?> </span> |
|
536 | 536 | <select id="give-graphs-month-start" name="m_start"> |
537 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
538 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_start'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option> |
|
537 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
538 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_start']); ?>><?php echo give_month_num_to_name($i); ?></option> |
|
539 | 539 | <?php endfor; ?> |
540 | 540 | </select> |
541 | 541 | <select id="give-graphs-day-start" name="day"> |
542 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
543 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day'] ); ?>><?php echo $i; ?></option> |
|
542 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
543 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day']); ?>><?php echo $i; ?></option> |
|
544 | 544 | <?php endfor; ?> |
545 | 545 | </select> |
546 | 546 | <select id="give-graphs-year-start" name="year"> |
547 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
548 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year'] ); ?>><?php echo $i; ?></option> |
|
547 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
548 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year']); ?>><?php echo $i; ?></option> |
|
549 | 549 | <?php endfor; ?> |
550 | 550 | </select> |
551 | - <span><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
551 | + <span><?php esc_html_e('To', 'give'); ?> </span> |
|
552 | 552 | <select id="give-graphs-month-end" name="m_end"> |
553 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
554 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['m_end'] ); ?>><?php echo give_month_num_to_name( $i ); ?></option> |
|
553 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
554 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['m_end']); ?>><?php echo give_month_num_to_name($i); ?></option> |
|
555 | 555 | <?php endfor; ?> |
556 | 556 | </select> |
557 | 557 | <select id="give-graphs-day-end" name="day_end"> |
558 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
559 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['day_end'] ); ?>><?php echo $i; ?></option> |
|
558 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
559 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['day_end']); ?>><?php echo $i; ?></option> |
|
560 | 560 | <?php endfor; ?> |
561 | 561 | </select> |
562 | 562 | <select id="give-graphs-year-end" name="year_end"> |
563 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
564 | - <option value="<?php echo absint( $i ); ?>" <?php selected( $i, $dates['year_end'] ); ?>><?php echo $i; ?></option> |
|
563 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
564 | + <option value="<?php echo absint($i); ?>" <?php selected($i, $dates['year_end']); ?>><?php echo $i; ?></option> |
|
565 | 565 | <?php endfor; ?> |
566 | 566 | </select> |
567 | 567 | </div> |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | </div> |
572 | 572 | </form> |
573 | 573 | <?php |
574 | - do_action( 'give_report_graph_controls_after' ); |
|
574 | + do_action('give_report_graph_controls_after'); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -586,65 +586,65 @@ discard block |
||
586 | 586 | function give_get_report_dates() { |
587 | 587 | $dates = array(); |
588 | 588 | |
589 | - $current_time = current_time( 'timestamp' ); |
|
589 | + $current_time = current_time('timestamp'); |
|
590 | 590 | |
591 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
592 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
593 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
594 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
595 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
596 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
597 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
591 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
592 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
593 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
594 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
595 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
596 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
597 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
598 | 598 | |
599 | 599 | // Modify dates based on predefined ranges |
600 | - switch ( $dates['range'] ) : |
|
600 | + switch ($dates['range']) : |
|
601 | 601 | |
602 | 602 | case 'this_month' : |
603 | - $dates['m_start'] = date( 'n', $current_time ); |
|
604 | - $dates['m_end'] = date( 'n', $current_time ); |
|
603 | + $dates['m_start'] = date('n', $current_time); |
|
604 | + $dates['m_end'] = date('n', $current_time); |
|
605 | 605 | $dates['day'] = 1; |
606 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
607 | - $dates['year'] = date( 'Y' ); |
|
608 | - $dates['year_end'] = date( 'Y' ); |
|
606 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
607 | + $dates['year'] = date('Y'); |
|
608 | + $dates['year_end'] = date('Y'); |
|
609 | 609 | break; |
610 | 610 | |
611 | 611 | case 'last_month' : |
612 | - if ( date( 'n' ) == 1 ) { |
|
612 | + if (date('n') == 1) { |
|
613 | 613 | $dates['m_start'] = 12; |
614 | 614 | $dates['m_end'] = 12; |
615 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
616 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
615 | + $dates['year'] = date('Y', $current_time) - 1; |
|
616 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
617 | 617 | } else { |
618 | - $dates['m_start'] = date( 'n' ) - 1; |
|
619 | - $dates['m_end'] = date( 'n' ) - 1; |
|
618 | + $dates['m_start'] = date('n') - 1; |
|
619 | + $dates['m_end'] = date('n') - 1; |
|
620 | 620 | $dates['year_end'] = $dates['year']; |
621 | 621 | } |
622 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
622 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
623 | 623 | break; |
624 | 624 | |
625 | 625 | case 'today' : |
626 | - $dates['day'] = date( 'd', $current_time ); |
|
627 | - $dates['m_start'] = date( 'n', $current_time ); |
|
628 | - $dates['m_end'] = date( 'n', $current_time ); |
|
629 | - $dates['year'] = date( 'Y', $current_time ); |
|
626 | + $dates['day'] = date('d', $current_time); |
|
627 | + $dates['m_start'] = date('n', $current_time); |
|
628 | + $dates['m_end'] = date('n', $current_time); |
|
629 | + $dates['year'] = date('Y', $current_time); |
|
630 | 630 | break; |
631 | 631 | |
632 | 632 | case 'yesterday' : |
633 | 633 | |
634 | - $year = date( 'Y', $current_time ); |
|
635 | - $month = date( 'n', $current_time ); |
|
636 | - $day = date( 'd', $current_time ); |
|
634 | + $year = date('Y', $current_time); |
|
635 | + $month = date('n', $current_time); |
|
636 | + $day = date('d', $current_time); |
|
637 | 637 | |
638 | - if ( $month == 1 && $day == 1 ) { |
|
638 | + if ($month == 1 && $day == 1) { |
|
639 | 639 | |
640 | 640 | $year -= 1; |
641 | 641 | $month = 12; |
642 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
642 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
643 | 643 | |
644 | - } elseif ( $month > 1 && $day == 1 ) { |
|
644 | + } elseif ($month > 1 && $day == 1) { |
|
645 | 645 | |
646 | 646 | $month -= 1; |
647 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
647 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
648 | 648 | |
649 | 649 | } else { |
650 | 650 | |
@@ -660,91 +660,91 @@ discard block |
||
660 | 660 | break; |
661 | 661 | |
662 | 662 | case 'this_week' : |
663 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
664 | - $dates['day'] += get_option( 'start_of_week' ); |
|
663 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
664 | + $dates['day'] += get_option('start_of_week'); |
|
665 | 665 | $dates['day_end'] = $dates['day'] + 6; |
666 | - $dates['m_start'] = date( 'n', $current_time ); |
|
667 | - $dates['m_end'] = date( 'n', $current_time ); |
|
668 | - $dates['year'] = date( 'Y', $current_time ); |
|
666 | + $dates['m_start'] = date('n', $current_time); |
|
667 | + $dates['m_end'] = date('n', $current_time); |
|
668 | + $dates['year'] = date('Y', $current_time); |
|
669 | 669 | break; |
670 | 670 | |
671 | 671 | case 'last_week' : |
672 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
673 | - $dates['day'] += get_option( 'start_of_week' ); |
|
672 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
673 | + $dates['day'] += get_option('start_of_week'); |
|
674 | 674 | $dates['day_end'] = $dates['day'] + 6; |
675 | - $dates['year'] = date( 'Y' ); |
|
676 | - |
|
677 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
678 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
679 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
680 | - if ( $dates['m_start'] <= 1 ) { |
|
681 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
682 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
675 | + $dates['year'] = date('Y'); |
|
676 | + |
|
677 | + if (date('j', $current_time) <= 7) { |
|
678 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
679 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
680 | + if ($dates['m_start'] <= 1) { |
|
681 | + $dates['year'] = date('Y', $current_time) - 1; |
|
682 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
683 | 683 | } |
684 | 684 | } else { |
685 | - $dates['m_start'] = date( 'n', $current_time ); |
|
686 | - $dates['m_end'] = date( 'n', $current_time ); |
|
685 | + $dates['m_start'] = date('n', $current_time); |
|
686 | + $dates['m_end'] = date('n', $current_time); |
|
687 | 687 | } |
688 | 688 | break; |
689 | 689 | |
690 | 690 | case 'this_quarter' : |
691 | - $month_now = date( 'n', $current_time ); |
|
691 | + $month_now = date('n', $current_time); |
|
692 | 692 | |
693 | - if ( $month_now <= 3 ) { |
|
693 | + if ($month_now <= 3) { |
|
694 | 694 | |
695 | 695 | $dates['m_start'] = 1; |
696 | 696 | $dates['m_end'] = 4; |
697 | - $dates['year'] = date( 'Y', $current_time ); |
|
697 | + $dates['year'] = date('Y', $current_time); |
|
698 | 698 | |
699 | - } else if ( $month_now <= 6 ) { |
|
699 | + } else if ($month_now <= 6) { |
|
700 | 700 | |
701 | 701 | $dates['m_start'] = 4; |
702 | 702 | $dates['m_end'] = 7; |
703 | - $dates['year'] = date( 'Y', $current_time ); |
|
703 | + $dates['year'] = date('Y', $current_time); |
|
704 | 704 | |
705 | - } else if ( $month_now <= 9 ) { |
|
705 | + } else if ($month_now <= 9) { |
|
706 | 706 | |
707 | 707 | $dates['m_start'] = 7; |
708 | 708 | $dates['m_end'] = 10; |
709 | - $dates['year'] = date( 'Y', $current_time ); |
|
709 | + $dates['year'] = date('Y', $current_time); |
|
710 | 710 | |
711 | 711 | } else { |
712 | 712 | |
713 | 713 | $dates['m_start'] = 10; |
714 | 714 | $dates['m_end'] = 1; |
715 | - $dates['year'] = date( 'Y', $current_time ); |
|
716 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
715 | + $dates['year'] = date('Y', $current_time); |
|
716 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
717 | 717 | |
718 | 718 | } |
719 | 719 | break; |
720 | 720 | |
721 | 721 | case 'last_quarter' : |
722 | - $month_now = date( 'n' ); |
|
722 | + $month_now = date('n'); |
|
723 | 723 | |
724 | - if ( $month_now <= 3 ) { |
|
724 | + if ($month_now <= 3) { |
|
725 | 725 | |
726 | 726 | $dates['m_start'] = 10; |
727 | 727 | $dates['m_end'] = 12; |
728 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
729 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year |
|
728 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
729 | + $dates['year_end'] = date('Y', $current_time) - 1; // Previous year |
|
730 | 730 | |
731 | - } else if ( $month_now <= 6 ) { |
|
731 | + } else if ($month_now <= 6) { |
|
732 | 732 | |
733 | 733 | $dates['m_start'] = 1; |
734 | 734 | $dates['m_end'] = 3; |
735 | - $dates['year'] = date( 'Y', $current_time ); |
|
735 | + $dates['year'] = date('Y', $current_time); |
|
736 | 736 | |
737 | - } else if ( $month_now <= 9 ) { |
|
737 | + } else if ($month_now <= 9) { |
|
738 | 738 | |
739 | 739 | $dates['m_start'] = 4; |
740 | 740 | $dates['m_end'] = 6; |
741 | - $dates['year'] = date( 'Y', $current_time ); |
|
741 | + $dates['year'] = date('Y', $current_time); |
|
742 | 742 | |
743 | 743 | } else { |
744 | 744 | |
745 | 745 | $dates['m_start'] = 7; |
746 | 746 | $dates['m_end'] = 9; |
747 | - $dates['year'] = date( 'Y', $current_time ); |
|
747 | + $dates['year'] = date('Y', $current_time); |
|
748 | 748 | |
749 | 749 | } |
750 | 750 | break; |
@@ -752,19 +752,19 @@ discard block |
||
752 | 752 | case 'this_year' : |
753 | 753 | $dates['m_start'] = 1; |
754 | 754 | $dates['m_end'] = 12; |
755 | - $dates['year'] = date( 'Y', $current_time ); |
|
755 | + $dates['year'] = date('Y', $current_time); |
|
756 | 756 | break; |
757 | 757 | |
758 | 758 | case 'last_year' : |
759 | 759 | $dates['m_start'] = 1; |
760 | 760 | $dates['m_end'] = 12; |
761 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
762 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
761 | + $dates['year'] = date('Y', $current_time) - 1; |
|
762 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
763 | 763 | break; |
764 | 764 | |
765 | 765 | endswitch; |
766 | 766 | |
767 | - return apply_filters( 'give_report_dates', $dates ); |
|
767 | + return apply_filters('give_report_dates', $dates); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -774,17 +774,17 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param $data |
776 | 776 | */ |
777 | -function give_parse_report_dates( $data ) { |
|
777 | +function give_parse_report_dates($data) { |
|
778 | 778 | $dates = give_get_report_dates(); |
779 | 779 | |
780 | 780 | $view = give_get_reporting_view(); |
781 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
781 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
782 | 782 | |
783 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
783 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
784 | 784 | give_die(); |
785 | 785 | } |
786 | 786 | |
787 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
787 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
788 | 788 | |
789 | 789 | |
790 | 790 | /** |
@@ -796,16 +796,16 @@ discard block |
||
796 | 796 | */ |
797 | 797 | function give_reports_refresh_button() { |
798 | 798 | |
799 | - $url = wp_nonce_url( add_query_arg( array( |
|
799 | + $url = wp_nonce_url(add_query_arg(array( |
|
800 | 800 | 'give_action' => 'refresh_reports_transients', |
801 | 801 | 'give-message' => 'refreshed-reports' |
802 | - ) ), 'give-refresh-reports' ); |
|
802 | + )), 'give-refresh-reports'); |
|
803 | 803 | |
804 | - echo '<a href="' . $url . '" data-tooltip="' . esc_attr__( 'Clicking this will clear the reports cache.', 'give' ) . '" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">' . esc_html__( 'Refresh Reports', 'give' ) . '</a>'; |
|
804 | + echo '<a href="'.$url.'" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give').'" data-tooltip-my-position="right center" data-tooltip-target-position="left center" class="button alignright give-refresh-reports-button give-tooltip">'.esc_html__('Refresh Reports', 'give').'</a>'; |
|
805 | 805 | |
806 | 806 | } |
807 | 807 | |
808 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
808 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
809 | 809 | |
810 | 810 | /** |
811 | 811 | * Trigger the refresh of reports transients |
@@ -816,18 +816,18 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @return void |
818 | 818 | */ |
819 | -function give_run_refresh_reports_transients( $data ) { |
|
819 | +function give_run_refresh_reports_transients($data) { |
|
820 | 820 | |
821 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
821 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
822 | 822 | return; |
823 | 823 | } |
824 | 824 | |
825 | 825 | //Delete transients |
826 | - delete_transient( 'give_estimated_monthly_stats' ); |
|
827 | - delete_transient( 'give_earnings_total' ); |
|
828 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
829 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
826 | + delete_transient('give_estimated_monthly_stats'); |
|
827 | + delete_transient('give_earnings_total'); |
|
828 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
829 | + delete_transient(md5('give_earnings_todaytoday')); |
|
830 | 830 | |
831 | 831 | } |
832 | 832 | |
833 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
834 | 833 | \ No newline at end of file |
834 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
|
835 | 835 | \ No newline at end of file |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @access public |
213 | 213 | * @since 1.1 |
214 | - * @return array |
|
214 | + * @return string |
|
215 | 215 | */ |
216 | 216 | public function get_versions() { |
217 | 217 | return $this->versions; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @param array $args Arguments to override defaults |
664 | 664 | * |
665 | - * @return array $dates |
|
665 | + * @return integer|null $dates |
|
666 | 666 | */ |
667 | 667 | public function get_dates( $args = array() ) { |
668 | 668 | $dates = array(); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | * |
1713 | 1713 | * @param int $user_id User ID of user to revoke key for |
1714 | 1714 | * |
1715 | - * @return string |
|
1715 | + * @return boolean |
|
1716 | 1716 | */ |
1717 | 1717 | public function revoke_api_key( $user_id = 0 ) { |
1718 | 1718 |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | * Determines whether results should be displayed in XML or JSON |
1438 | 1438 | * |
1439 | 1439 | * @since 1.1 |
1440 | - * @access public |
|
1440 | + * @access public |
|
1441 | 1441 | * |
1442 | 1442 | * @return mixed|void |
1443 | 1443 | */ |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | * |
1456 | 1456 | * @access private |
1457 | 1457 | * @since 1.1 |
1458 | - * |
|
1458 | + * |
|
1459 | 1459 | * @global Give_Logging $give_logs |
1460 | 1460 | * @global WP_Query $wp_query |
1461 | 1461 | * |
@@ -1468,15 +1468,15 @@ discard block |
||
1468 | 1468 | return; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - /** |
|
1472 | - * @var Give_Logging $give_logs |
|
1473 | - */ |
|
1471 | + /** |
|
1472 | + * @var Give_Logging $give_logs |
|
1473 | + */ |
|
1474 | 1474 | global $give_logs; |
1475 | 1475 | |
1476 | - /** |
|
1477 | - * @var WP_Query $wp_query |
|
1478 | - */ |
|
1479 | - global $wp_query; |
|
1476 | + /** |
|
1477 | + * @var WP_Query $wp_query |
|
1478 | + */ |
|
1479 | + global $wp_query; |
|
1480 | 1480 | |
1481 | 1481 | $query = array( |
1482 | 1482 | 'give-api' => $wp_query->query_vars['give-api'], |
@@ -1534,9 +1534,9 @@ discard block |
||
1534 | 1534 | * @param int $status_code |
1535 | 1535 | */ |
1536 | 1536 | public function output( $status_code = 200 ) { |
1537 | - /** |
|
1538 | - * @var WP_Query $wp_query |
|
1539 | - */ |
|
1537 | + /** |
|
1538 | + * @var WP_Query $wp_query |
|
1539 | + */ |
|
1540 | 1540 | global $wp_query; |
1541 | 1541 | |
1542 | 1542 | $format = $this->get_output_format(); |
@@ -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 | |
@@ -140,27 +140,27 @@ discard block |
||
140 | 140 | 'v1' => 'GIVE_API_V1', |
141 | 141 | ); |
142 | 142 | |
143 | - foreach ( $this->get_versions() as $version => $class ) { |
|
144 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
143 | + foreach ($this->get_versions() as $version => $class) { |
|
144 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
145 | 145 | } |
146 | 146 | |
147 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
148 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
149 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
150 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
151 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
153 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
154 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
147 | + add_action('init', array($this, 'add_endpoint')); |
|
148 | + add_action('wp', array($this, 'process_query'), - 1); |
|
149 | + add_filter('query_vars', array($this, 'query_vars')); |
|
150 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
151 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('personal_options_update', array($this, 'update_key')); |
|
153 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
154 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
155 | 155 | |
156 | 156 | // Setup a backwards compatibility check for user API Keys |
157 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
157 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
158 | 158 | |
159 | 159 | // Determine if JSON_PRETTY_PRINT is available |
160 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
160 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
161 | 161 | |
162 | 162 | // Allow API request logging to be turned off |
163 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
163 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
164 | 164 | |
165 | 165 | // Setup Give_Payment_Stats instance |
166 | 166 | $this->stats = new Give_Payment_Stats; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @since 1.1 |
178 | 178 | */ |
179 | - public function add_endpoint( $rewrite_rules ) { |
|
180 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
179 | + public function add_endpoint($rewrite_rules) { |
|
180 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return string[] $vars New query vars |
192 | 192 | */ |
193 | - public function query_vars( $vars ) { |
|
193 | + public function query_vars($vars) { |
|
194 | 194 | |
195 | 195 | $vars[] = 'token'; |
196 | 196 | $vars[] = 'key'; |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function get_default_version() { |
243 | 243 | |
244 | - $version = get_option( 'give_default_api_version' ); |
|
244 | + $version = get_option('give_default_api_version'); |
|
245 | 245 | |
246 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
246 | + if (defined('GIVE_API_VERSION')) { |
|
247 | 247 | $version = GIVE_API_VERSION; |
248 | - } elseif ( ! $version ) { |
|
248 | + } elseif ( ! $version) { |
|
249 | 249 | $version = 'v1'; |
250 | 250 | } |
251 | 251 | |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | |
267 | 267 | $version = $wp_query->query_vars['give-api']; |
268 | 268 | |
269 | - if ( strpos( $version, '/' ) ) { |
|
269 | + if (strpos($version, '/')) { |
|
270 | 270 | |
271 | - $version = explode( '/', $version ); |
|
272 | - $version = strtolower( $version[0] ); |
|
271 | + $version = explode('/', $version); |
|
272 | + $version = strtolower($version[0]); |
|
273 | 273 | |
274 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
274 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
275 | 275 | |
276 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
276 | + if (array_key_exists($version, $this->versions)) { |
|
277 | 277 | |
278 | 278 | $this->queried_version = $version; |
279 | 279 | |
@@ -310,32 +310,32 @@ discard block |
||
310 | 310 | $this->override = false; |
311 | 311 | |
312 | 312 | // Make sure we have both user and api key |
313 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
313 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
314 | 314 | |
315 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
315 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
316 | 316 | $this->missing_auth(); |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Retrieve the user by public API key and ensure they exist |
320 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
320 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
321 | 321 | |
322 | 322 | $this->invalid_key(); |
323 | 323 | |
324 | 324 | } else { |
325 | 325 | |
326 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
327 | - $secret = $this->get_user_secret_key( $user ); |
|
328 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
326 | + $token = urldecode($wp_query->query_vars['token']); |
|
327 | + $secret = $this->get_user_secret_key($user); |
|
328 | + $public = urldecode($wp_query->query_vars['key']); |
|
329 | 329 | |
330 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
330 | + if (hash_equals(md5($secret.$public), $token)) { |
|
331 | 331 | $this->is_valid_request = true; |
332 | 332 | } else { |
333 | 333 | $this->invalid_auth(); |
334 | 334 | } |
335 | 335 | } |
336 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) { |
|
336 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') { |
|
337 | 337 | $this->is_valid_request = true; |
338 | - $wp_query->set( 'key', 'public' ); |
|
338 | + $wp_query->set('key', 'public'); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
@@ -351,25 +351,25 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool if user ID is found, false otherwise |
353 | 353 | */ |
354 | - public function get_user( $key = '' ) { |
|
354 | + public function get_user($key = '') { |
|
355 | 355 | global $wpdb, $wp_query; |
356 | 356 | |
357 | - if ( empty( $key ) ) { |
|
358 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
357 | + if (empty($key)) { |
|
358 | + $key = urldecode($wp_query->query_vars['key']); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( empty( $key ) ) { |
|
361 | + if (empty($key)) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
365 | - $user = get_transient( md5( 'give_api_user_' . $key ) ); |
|
365 | + $user = get_transient(md5('give_api_user_'.$key)); |
|
366 | 366 | |
367 | - if ( false === $user ) { |
|
368 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
369 | - set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS ); |
|
367 | + if (false === $user) { |
|
368 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
369 | + set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS); |
|
370 | 370 | } |
371 | 371 | |
372 | - if ( $user != null ) { |
|
372 | + if ($user != null) { |
|
373 | 373 | $this->user_id = $user; |
374 | 374 | |
375 | 375 | return $user; |
@@ -378,37 +378,37 @@ discard block |
||
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - public function get_user_public_key( $user_id = 0 ) { |
|
381 | + public function get_user_public_key($user_id = 0) { |
|
382 | 382 | global $wpdb; |
383 | 383 | |
384 | - if ( empty( $user_id ) ) { |
|
384 | + if (empty($user_id)) { |
|
385 | 385 | return ''; |
386 | 386 | } |
387 | 387 | |
388 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
389 | - $user_public_key = get_transient( $cache_key ); |
|
388 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
389 | + $user_public_key = get_transient($cache_key); |
|
390 | 390 | |
391 | - if ( empty( $user_public_key ) ) { |
|
392 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
393 | - set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS ); |
|
391 | + if (empty($user_public_key)) { |
|
392 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
393 | + set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return $user_public_key; |
397 | 397 | } |
398 | 398 | |
399 | - public function get_user_secret_key( $user_id = 0 ) { |
|
399 | + public function get_user_secret_key($user_id = 0) { |
|
400 | 400 | global $wpdb; |
401 | 401 | |
402 | - if ( empty( $user_id ) ) { |
|
402 | + if (empty($user_id)) { |
|
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
407 | - $user_secret_key = get_transient( $cache_key ); |
|
406 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
407 | + $user_secret_key = get_transient($cache_key); |
|
408 | 408 | |
409 | - if ( empty( $user_secret_key ) ) { |
|
410 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
411 | - set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS ); |
|
409 | + if (empty($user_secret_key)) { |
|
410 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
411 | + set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $user_secret_key; |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | */ |
425 | 425 | private function missing_auth() { |
426 | 426 | $error = array(); |
427 | - $error['error'] = esc_html__( 'You must specify both a token and API key!', 'give' ); |
|
427 | + $error['error'] = esc_html__('You must specify both a token and API key!', 'give'); |
|
428 | 428 | |
429 | 429 | $this->data = $error; |
430 | - $this->output( 401 ); |
|
430 | + $this->output(401); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | */ |
442 | 442 | private function invalid_auth() { |
443 | 443 | $error = array(); |
444 | - $error['error'] = esc_html__( 'Your request could not be authenticated!', 'give' ); |
|
444 | + $error['error'] = esc_html__('Your request could not be authenticated!', 'give'); |
|
445 | 445 | |
446 | 446 | $this->data = $error; |
447 | - $this->output( 403 ); |
|
447 | + $this->output(403); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | */ |
459 | 459 | private function invalid_key() { |
460 | 460 | $error = array(); |
461 | - $error['error'] = esc_html__( 'Invalid API key!', 'give' ); |
|
461 | + $error['error'] = esc_html__('Invalid API key!', 'give'); |
|
462 | 462 | |
463 | 463 | $this->data = $error; |
464 | - $this->output( 403 ); |
|
464 | + $this->output(403); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | */ |
475 | 475 | private function invalid_version() { |
476 | 476 | $error = array(); |
477 | - $error['error'] = esc_html__( 'Invalid API version!', 'give' ); |
|
477 | + $error['error'] = esc_html__('Invalid API version!', 'give'); |
|
478 | 478 | |
479 | 479 | $this->data = $error; |
480 | - $this->output( 404 ); |
|
480 | + $this->output(404); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | global $wp_query; |
494 | 494 | |
495 | 495 | // Start logging how long the request takes for logging |
496 | - $before = microtime( true ); |
|
496 | + $before = microtime(true); |
|
497 | 497 | |
498 | 498 | // Check for give-api var. Get out if not present |
499 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
499 | + if (empty($wp_query->query_vars['give-api'])) { |
|
500 | 500 | return; |
501 | 501 | } |
502 | 502 | |
@@ -510,45 +510,45 @@ discard block |
||
510 | 510 | $this->validate_request(); |
511 | 511 | |
512 | 512 | // Only proceed if no errors have been noted |
513 | - if ( ! $this->is_valid_request ) { |
|
513 | + if ( ! $this->is_valid_request) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | |
517 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
518 | - define( 'GIVE_DOING_API', true ); |
|
517 | + if ( ! defined('GIVE_DOING_API')) { |
|
518 | + define('GIVE_DOING_API', true); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | $data = array(); |
522 | 522 | $this->routes = new $this->versions[$this->get_queried_version()]; |
523 | 523 | $this->routes->validate_request(); |
524 | 524 | |
525 | - switch ( $this->endpoint ) : |
|
525 | + switch ($this->endpoint) : |
|
526 | 526 | |
527 | 527 | case 'stats' : |
528 | 528 | |
529 | - $data = $this->routes->get_stats( array( |
|
530 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
531 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
532 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
533 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
534 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null |
|
535 | - ) ); |
|
529 | + $data = $this->routes->get_stats(array( |
|
530 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
531 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
532 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
533 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
534 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null |
|
535 | + )); |
|
536 | 536 | |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'forms' : |
540 | 540 | |
541 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
541 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
542 | 542 | |
543 | - $data = $this->routes->get_forms( $form ); |
|
543 | + $data = $this->routes->get_forms($form); |
|
544 | 544 | |
545 | 545 | break; |
546 | 546 | |
547 | 547 | case 'donors' : |
548 | 548 | |
549 | - $customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
549 | + $customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
550 | 550 | |
551 | - $data = $this->routes->get_customers( $customer ); |
|
551 | + $data = $this->routes->get_customers($customer); |
|
552 | 552 | |
553 | 553 | break; |
554 | 554 | |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | endswitch; |
562 | 562 | |
563 | 563 | // Allow extensions to setup their own return data |
564 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
564 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
565 | 565 | |
566 | - $after = microtime( true ); |
|
567 | - $request_time = ( $after - $before ); |
|
566 | + $after = microtime(true); |
|
567 | + $request_time = ($after - $before); |
|
568 | 568 | $this->data['request_speed'] = $request_time; |
569 | 569 | |
570 | 570 | // Log this API request, if enabled. We log it here because we have access to errors. |
571 | - $this->log_request( $this->data ); |
|
571 | + $this->log_request($this->data); |
|
572 | 572 | |
573 | 573 | // Send out data to the output function |
574 | 574 | $this->output(); |
@@ -598,25 +598,25 @@ discard block |
||
598 | 598 | global $wp_query; |
599 | 599 | |
600 | 600 | // Whitelist our query options |
601 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
601 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
602 | 602 | 'stats', |
603 | 603 | 'forms', |
604 | 604 | 'donors', |
605 | 605 | 'donations' |
606 | - ) ); |
|
606 | + )); |
|
607 | 607 | |
608 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
609 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
608 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
609 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
610 | 610 | |
611 | 611 | $error = array(); |
612 | 612 | |
613 | 613 | // Make sure our query is valid |
614 | - if ( ! in_array( $query, $accepted ) ) { |
|
615 | - $error['error'] = esc_html__( 'Invalid query!', 'give' ); |
|
614 | + if ( ! in_array($query, $accepted)) { |
|
615 | + $error['error'] = esc_html__('Invalid query!', 'give'); |
|
616 | 616 | |
617 | 617 | $this->data = $error; |
618 | 618 | // 400 is Bad Request |
619 | - $this->output( 400 ); |
|
619 | + $this->output(400); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $this->endpoint = $query; |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | public function get_paged() { |
634 | 634 | global $wp_query; |
635 | 635 | |
636 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
636 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | |
@@ -648,13 +648,13 @@ discard block |
||
648 | 648 | public function per_page() { |
649 | 649 | global $wp_query; |
650 | 650 | |
651 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
651 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
652 | 652 | |
653 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
653 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
654 | 654 | $per_page = 99999999; |
655 | 655 | } // Customers query doesn't support -1 |
656 | 656 | |
657 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
657 | + return apply_filters('give_api_results_per_page', $per_page); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @return array $dates |
669 | 669 | */ |
670 | - public function get_dates( $args = array() ) { |
|
670 | + public function get_dates($args = array()) { |
|
671 | 671 | $dates = array(); |
672 | 672 | |
673 | 673 | $defaults = array( |
@@ -678,60 +678,60 @@ discard block |
||
678 | 678 | 'enddate' => null |
679 | 679 | ); |
680 | 680 | |
681 | - $args = wp_parse_args( $args, $defaults ); |
|
681 | + $args = wp_parse_args($args, $defaults); |
|
682 | 682 | |
683 | - $current_time = current_time( 'timestamp' ); |
|
683 | + $current_time = current_time('timestamp'); |
|
684 | 684 | |
685 | - if ( 'range' === $args['date'] ) { |
|
686 | - $startdate = strtotime( $args['startdate'] ); |
|
687 | - $enddate = strtotime( $args['enddate'] ); |
|
688 | - $dates['day_start'] = date( 'd', $startdate ); |
|
689 | - $dates['day_end'] = date( 'd', $enddate ); |
|
690 | - $dates['m_start'] = date( 'n', $startdate ); |
|
691 | - $dates['m_end'] = date( 'n', $enddate ); |
|
692 | - $dates['year'] = date( 'Y', $startdate ); |
|
693 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
685 | + if ('range' === $args['date']) { |
|
686 | + $startdate = strtotime($args['startdate']); |
|
687 | + $enddate = strtotime($args['enddate']); |
|
688 | + $dates['day_start'] = date('d', $startdate); |
|
689 | + $dates['day_end'] = date('d', $enddate); |
|
690 | + $dates['m_start'] = date('n', $startdate); |
|
691 | + $dates['m_end'] = date('n', $enddate); |
|
692 | + $dates['year'] = date('Y', $startdate); |
|
693 | + $dates['year_end'] = date('Y', $enddate); |
|
694 | 694 | } else { |
695 | 695 | // Modify dates based on predefined ranges |
696 | - switch ( $args['date'] ) : |
|
696 | + switch ($args['date']) : |
|
697 | 697 | |
698 | 698 | case 'this_month' : |
699 | 699 | $dates['day'] = null; |
700 | - $dates['m_start'] = date( 'n', $current_time ); |
|
701 | - $dates['m_end'] = date( 'n', $current_time ); |
|
702 | - $dates['year'] = date( 'Y', $current_time ); |
|
700 | + $dates['m_start'] = date('n', $current_time); |
|
701 | + $dates['m_end'] = date('n', $current_time); |
|
702 | + $dates['year'] = date('Y', $current_time); |
|
703 | 703 | break; |
704 | 704 | |
705 | 705 | case 'last_month' : |
706 | 706 | $dates['day'] = null; |
707 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
707 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
708 | 708 | $dates['m_end'] = $dates['m_start']; |
709 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
709 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
710 | 710 | break; |
711 | 711 | |
712 | 712 | case 'today' : |
713 | - $dates['day'] = date( 'd', $current_time ); |
|
714 | - $dates['m_start'] = date( 'n', $current_time ); |
|
715 | - $dates['m_end'] = date( 'n', $current_time ); |
|
716 | - $dates['year'] = date( 'Y', $current_time ); |
|
713 | + $dates['day'] = date('d', $current_time); |
|
714 | + $dates['m_start'] = date('n', $current_time); |
|
715 | + $dates['m_end'] = date('n', $current_time); |
|
716 | + $dates['year'] = date('Y', $current_time); |
|
717 | 717 | break; |
718 | 718 | |
719 | 719 | case 'yesterday' : |
720 | 720 | |
721 | - $year = date( 'Y', $current_time ); |
|
722 | - $month = date( 'n', $current_time ); |
|
723 | - $day = date( 'd', $current_time ); |
|
721 | + $year = date('Y', $current_time); |
|
722 | + $month = date('n', $current_time); |
|
723 | + $day = date('d', $current_time); |
|
724 | 724 | |
725 | - if ( $month == 1 && $day == 1 ) { |
|
725 | + if ($month == 1 && $day == 1) { |
|
726 | 726 | |
727 | 727 | $year -= 1; |
728 | 728 | $month = 12; |
729 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
729 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
730 | 730 | |
731 | - } elseif ( $month > 1 && $day == 1 ) { |
|
731 | + } elseif ($month > 1 && $day == 1) { |
|
732 | 732 | |
733 | 733 | $month -= 1; |
734 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
734 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
735 | 735 | |
736 | 736 | } else { |
737 | 737 | |
@@ -747,65 +747,65 @@ discard block |
||
747 | 747 | break; |
748 | 748 | |
749 | 749 | case 'this_quarter' : |
750 | - $month_now = date( 'n', $current_time ); |
|
750 | + $month_now = date('n', $current_time); |
|
751 | 751 | |
752 | 752 | $dates['day'] = null; |
753 | 753 | |
754 | - if ( $month_now <= 3 ) { |
|
754 | + if ($month_now <= 3) { |
|
755 | 755 | |
756 | 756 | $dates['m_start'] = 1; |
757 | 757 | $dates['m_end'] = 3; |
758 | - $dates['year'] = date( 'Y', $current_time ); |
|
758 | + $dates['year'] = date('Y', $current_time); |
|
759 | 759 | |
760 | - } else if ( $month_now <= 6 ) { |
|
760 | + } else if ($month_now <= 6) { |
|
761 | 761 | |
762 | 762 | $dates['m_start'] = 4; |
763 | 763 | $dates['m_end'] = 6; |
764 | - $dates['year'] = date( 'Y', $current_time ); |
|
764 | + $dates['year'] = date('Y', $current_time); |
|
765 | 765 | |
766 | - } else if ( $month_now <= 9 ) { |
|
766 | + } else if ($month_now <= 9) { |
|
767 | 767 | |
768 | 768 | $dates['m_start'] = 7; |
769 | 769 | $dates['m_end'] = 9; |
770 | - $dates['year'] = date( 'Y', $current_time ); |
|
770 | + $dates['year'] = date('Y', $current_time); |
|
771 | 771 | |
772 | 772 | } else { |
773 | 773 | |
774 | 774 | $dates['m_start'] = 10; |
775 | 775 | $dates['m_end'] = 12; |
776 | - $dates['year'] = date( 'Y', $current_time ); |
|
776 | + $dates['year'] = date('Y', $current_time); |
|
777 | 777 | |
778 | 778 | } |
779 | 779 | break; |
780 | 780 | |
781 | 781 | case 'last_quarter' : |
782 | - $month_now = date( 'n', $current_time ); |
|
782 | + $month_now = date('n', $current_time); |
|
783 | 783 | |
784 | 784 | $dates['day'] = null; |
785 | 785 | |
786 | - if ( $month_now <= 3 ) { |
|
786 | + if ($month_now <= 3) { |
|
787 | 787 | |
788 | 788 | $dates['m_start'] = 10; |
789 | 789 | $dates['m_end'] = 12; |
790 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
790 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
791 | 791 | |
792 | - } else if ( $month_now <= 6 ) { |
|
792 | + } else if ($month_now <= 6) { |
|
793 | 793 | |
794 | 794 | $dates['m_start'] = 1; |
795 | 795 | $dates['m_end'] = 3; |
796 | - $dates['year'] = date( 'Y', $current_time ); |
|
796 | + $dates['year'] = date('Y', $current_time); |
|
797 | 797 | |
798 | - } else if ( $month_now <= 9 ) { |
|
798 | + } else if ($month_now <= 9) { |
|
799 | 799 | |
800 | 800 | $dates['m_start'] = 4; |
801 | 801 | $dates['m_end'] = 6; |
802 | - $dates['year'] = date( 'Y', $current_time ); |
|
802 | + $dates['year'] = date('Y', $current_time); |
|
803 | 803 | |
804 | 804 | } else { |
805 | 805 | |
806 | 806 | $dates['m_start'] = 7; |
807 | 807 | $dates['m_end'] = 9; |
808 | - $dates['year'] = date( 'Y', $current_time ); |
|
808 | + $dates['year'] = date('Y', $current_time); |
|
809 | 809 | |
810 | 810 | } |
811 | 811 | break; |
@@ -814,14 +814,14 @@ discard block |
||
814 | 814 | $dates['day'] = null; |
815 | 815 | $dates['m_start'] = null; |
816 | 816 | $dates['m_end'] = null; |
817 | - $dates['year'] = date( 'Y', $current_time ); |
|
817 | + $dates['year'] = date('Y', $current_time); |
|
818 | 818 | break; |
819 | 819 | |
820 | 820 | case 'last_year' : |
821 | 821 | $dates['day'] = null; |
822 | 822 | $dates['m_start'] = null; |
823 | 823 | $dates['m_end'] = null; |
824 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
824 | + $dates['year'] = date('Y', $current_time) - 1; |
|
825 | 825 | break; |
826 | 826 | |
827 | 827 | endswitch; |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @param object $dates The dates used for retrieving earnings/donations |
836 | 836 | */ |
837 | 837 | |
838 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
838 | + return apply_filters('give_api_stat_dates', $dates); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -850,11 +850,11 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @return array $customers Multidimensional array of the customers |
852 | 852 | */ |
853 | - public function get_customers( $customer = null ) { |
|
853 | + public function get_customers($customer = null) { |
|
854 | 854 | |
855 | 855 | $customers = array(); |
856 | 856 | $error = array(); |
857 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
857 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
858 | 858 | return $customers; |
859 | 859 | } |
860 | 860 | |
@@ -862,64 +862,64 @@ discard block |
||
862 | 862 | |
863 | 863 | $paged = $this->get_paged(); |
864 | 864 | $per_page = $this->per_page(); |
865 | - $offset = $per_page * ( $paged - 1 ); |
|
865 | + $offset = $per_page * ($paged - 1); |
|
866 | 866 | |
867 | - if ( is_numeric( $customer ) ) { |
|
867 | + if (is_numeric($customer)) { |
|
868 | 868 | $field = 'id'; |
869 | 869 | } else { |
870 | 870 | $field = 'email'; |
871 | 871 | } |
872 | 872 | |
873 | - $customer_query = Give()->customers->get_customers( array( |
|
873 | + $customer_query = Give()->customers->get_customers(array( |
|
874 | 874 | 'number' => $per_page, |
875 | 875 | 'offset' => $offset, |
876 | 876 | $field => $customer |
877 | - ) ); |
|
877 | + )); |
|
878 | 878 | $customer_count = 0; |
879 | 879 | |
880 | - if ( $customer_query ) { |
|
880 | + if ($customer_query) { |
|
881 | 881 | |
882 | - foreach ( $customer_query as $customer_obj ) { |
|
882 | + foreach ($customer_query as $customer_obj) { |
|
883 | 883 | |
884 | - $names = explode( ' ', $customer_obj->name ); |
|
885 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
884 | + $names = explode(' ', $customer_obj->name); |
|
885 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
886 | 886 | $last_name = ''; |
887 | - if ( ! empty( $names[1] ) ) { |
|
888 | - unset( $names[0] ); |
|
889 | - $last_name = implode( ' ', $names ); |
|
887 | + if ( ! empty($names[1])) { |
|
888 | + unset($names[0]); |
|
889 | + $last_name = implode(' ', $names); |
|
890 | 890 | } |
891 | 891 | |
892 | - $customers['donors'][ $customer_count ]['info']['user_id'] = ''; |
|
893 | - $customers['donors'][ $customer_count ]['info']['username'] = ''; |
|
894 | - $customers['donors'][ $customer_count ]['info']['display_name'] = ''; |
|
895 | - $customers['donors'][ $customer_count ]['info']['customer_id'] = $customer_obj->id; |
|
896 | - $customers['donors'][ $customer_count ]['info']['first_name'] = $first_name; |
|
897 | - $customers['donors'][ $customer_count ]['info']['last_name'] = $last_name; |
|
898 | - $customers['donors'][ $customer_count ]['info']['email'] = $customer_obj->email; |
|
892 | + $customers['donors'][$customer_count]['info']['user_id'] = ''; |
|
893 | + $customers['donors'][$customer_count]['info']['username'] = ''; |
|
894 | + $customers['donors'][$customer_count]['info']['display_name'] = ''; |
|
895 | + $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; |
|
896 | + $customers['donors'][$customer_count]['info']['first_name'] = $first_name; |
|
897 | + $customers['donors'][$customer_count]['info']['last_name'] = $last_name; |
|
898 | + $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; |
|
899 | 899 | |
900 | - if ( ! empty( $customer_obj->user_id ) ) { |
|
900 | + if ( ! empty($customer_obj->user_id)) { |
|
901 | 901 | |
902 | - $user_data = get_userdata( $customer_obj->user_id ); |
|
902 | + $user_data = get_userdata($customer_obj->user_id); |
|
903 | 903 | |
904 | 904 | // Customer with registered account |
905 | - $customers['donors'][ $customer_count ]['info']['user_id'] = $customer_obj->user_id; |
|
906 | - $customers['donors'][ $customer_count ]['info']['username'] = $user_data->user_login; |
|
907 | - $customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name; |
|
905 | + $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; |
|
906 | + $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; |
|
907 | + $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; |
|
908 | 908 | |
909 | 909 | } |
910 | 910 | |
911 | - $customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
912 | - $customers['donors'][ $customer_count ]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
911 | + $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
912 | + $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
913 | 913 | |
914 | - $customer_count ++; |
|
914 | + $customer_count++; |
|
915 | 915 | |
916 | 916 | } |
917 | 917 | |
918 | - } elseif ( $customer ) { |
|
918 | + } elseif ($customer) { |
|
919 | 919 | |
920 | 920 | $error['error'] = sprintf( |
921 | 921 | /* translators: %s: customer */ |
922 | - esc_html__( 'Donor %s not found!', 'give' ), |
|
922 | + esc_html__('Donor %s not found!', 'give'), |
|
923 | 923 | $customer |
924 | 924 | ); |
925 | 925 | |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | |
928 | 928 | } else { |
929 | 929 | |
930 | - $error['error'] = esc_html__( 'No donors found!', 'give' ); |
|
930 | + $error['error'] = esc_html__('No donors found!', 'give'); |
|
931 | 931 | |
932 | 932 | return $error; |
933 | 933 | |
@@ -946,38 +946,38 @@ discard block |
||
946 | 946 | * |
947 | 947 | * @return array $customers Multidimensional array of the forms |
948 | 948 | */ |
949 | - public function get_forms( $form = null ) { |
|
949 | + public function get_forms($form = null) { |
|
950 | 950 | |
951 | 951 | $forms = array(); |
952 | 952 | $error = array(); |
953 | 953 | |
954 | - if ( $form == null ) { |
|
954 | + if ($form == null) { |
|
955 | 955 | $forms['forms'] = array(); |
956 | 956 | |
957 | - $form_list = get_posts( array( |
|
957 | + $form_list = get_posts(array( |
|
958 | 958 | 'post_type' => 'give_forms', |
959 | 959 | 'posts_per_page' => $this->per_page(), |
960 | 960 | 'suppress_filters' => true, |
961 | 961 | 'paged' => $this->get_paged() |
962 | - ) ); |
|
962 | + )); |
|
963 | 963 | |
964 | - if ( $form_list ) { |
|
964 | + if ($form_list) { |
|
965 | 965 | $i = 0; |
966 | - foreach ( $form_list as $form_info ) { |
|
967 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
968 | - $i ++; |
|
966 | + foreach ($form_list as $form_info) { |
|
967 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
968 | + $i++; |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | } else { |
972 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
973 | - $form_info = get_post( $form ); |
|
972 | + if (get_post_type($form) == 'give_forms') { |
|
973 | + $form_info = get_post($form); |
|
974 | 974 | |
975 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
975 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
976 | 976 | |
977 | 977 | } else { |
978 | 978 | $error['error'] = sprintf( |
979 | 979 | /* translators: %s: form */ |
980 | - esc_html__( 'Form %s not found!', 'give' ), |
|
980 | + esc_html__('Form %s not found!', 'give'), |
|
981 | 981 | $form |
982 | 982 | ); |
983 | 983 | |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return array Array of post data to return back in the API |
999 | 999 | */ |
1000 | - private function get_form_data( $form_info ) { |
|
1000 | + private function get_form_data($form_info) { |
|
1001 | 1001 | |
1002 | 1002 | $form = array(); |
1003 | 1003 | |
@@ -1007,46 +1007,46 @@ discard block |
||
1007 | 1007 | $form['info']['create_date'] = $form_info->post_date; |
1008 | 1008 | $form['info']['modified_date'] = $form_info->post_modified; |
1009 | 1009 | $form['info']['status'] = $form_info->post_status; |
1010 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1011 | - $form['info']['content'] = get_post_meta( $form_info->ID, '_give_form_content', true ); |
|
1012 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1010 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1011 | + $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true); |
|
1012 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1013 | 1013 | |
1014 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
1015 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1016 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1014 | + if (give_get_option('enable_categories') == 'on') { |
|
1015 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1016 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1017 | 1017 | } |
1018 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
1019 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1018 | + if (give_get_option('enable_tags') == 'on') { |
|
1019 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1023 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1024 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1025 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1026 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1022 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1023 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1024 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1025 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1026 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | $counter = 0; |
1030 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1031 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1032 | - $counter ++; |
|
1030 | + if (give_has_variable_prices($form_info->ID)) { |
|
1031 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1032 | + $counter++; |
|
1033 | 1033 | //muli-level item |
1034 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1035 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1034 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1035 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1036 | 1036 | |
1037 | 1037 | } |
1038 | 1038 | } else { |
1039 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1039 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1042 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1043 | 1043 | |
1044 | 1044 | //Sensitive data here |
1045 | - do_action( 'give_api_sensitive_data' ); |
|
1045 | + do_action('give_api_sensitive_data'); |
|
1046 | 1046 | |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1049 | + return apply_filters('give_api_forms_form', $form); |
|
1050 | 1050 | |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * |
1062 | 1062 | * @return array |
1063 | 1063 | */ |
1064 | - public function get_stats( $args = array() ) { |
|
1064 | + public function get_stats($args = array()) { |
|
1065 | 1065 | $defaults = array( |
1066 | 1066 | 'type' => null, |
1067 | 1067 | 'form' => null, |
@@ -1070,9 +1070,9 @@ discard block |
||
1070 | 1070 | 'enddate' => null |
1071 | 1071 | ); |
1072 | 1072 | |
1073 | - $args = wp_parse_args( $args, $defaults ); |
|
1073 | + $args = wp_parse_args($args, $defaults); |
|
1074 | 1074 | |
1075 | - $dates = $this->get_dates( $args ); |
|
1075 | + $dates = $this->get_dates($args); |
|
1076 | 1076 | |
1077 | 1077 | $stats = array(); |
1078 | 1078 | $earnings = array( |
@@ -1083,41 +1083,41 @@ discard block |
||
1083 | 1083 | ); |
1084 | 1084 | $error = array(); |
1085 | 1085 | |
1086 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1086 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1087 | 1087 | return $stats; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - if ( $args['type'] == 'donations' ) { |
|
1090 | + if ($args['type'] == 'donations') { |
|
1091 | 1091 | |
1092 | - if ( $args['form'] == null ) { |
|
1093 | - if ( $args['date'] == null ) { |
|
1092 | + if ($args['form'] == null) { |
|
1093 | + if ($args['date'] == null) { |
|
1094 | 1094 | $sales = $this->get_default_sales_stats(); |
1095 | - } elseif ( $args['date'] === 'range' ) { |
|
1095 | + } elseif ($args['date'] === 'range') { |
|
1096 | 1096 | // Return sales for a date range |
1097 | 1097 | |
1098 | 1098 | // Ensure the end date is later than the start date |
1099 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1100 | - $error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' ); |
|
1099 | + if ($args['enddate'] < $args['startdate']) { |
|
1100 | + $error['error'] = esc_html__('The end date must be later than the start date!', 'give'); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | // Ensure both the start and end date are specified |
1104 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1105 | - $error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' ); |
|
1104 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1105 | + $error['error'] = esc_html__('Invalid or no date range specified!', 'give'); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $total = 0; |
1109 | 1109 | |
1110 | 1110 | // Loop through the years |
1111 | 1111 | $y = $dates['year']; |
1112 | - while ( $y <= $dates['year_end'] ) : |
|
1112 | + while ($y <= $dates['year_end']) : |
|
1113 | 1113 | |
1114 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1114 | + if ($dates['year'] == $dates['year_end']) { |
|
1115 | 1115 | $month_start = $dates['m_start']; |
1116 | 1116 | $month_end = $dates['m_end']; |
1117 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1117 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1118 | 1118 | $month_start = $dates['m_start']; |
1119 | 1119 | $month_end = 12; |
1120 | - } elseif ( $y == $dates['year_end'] ) { |
|
1120 | + } elseif ($y == $dates['year_end']) { |
|
1121 | 1121 | $month_start = 1; |
1122 | 1122 | $month_end = $dates['m_end']; |
1123 | 1123 | } else { |
@@ -1126,113 +1126,113 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | $i = $month_start; |
1129 | - while ( $i <= $month_end ) : |
|
1129 | + while ($i <= $month_end) : |
|
1130 | 1130 | |
1131 | - if ( $i == $dates['m_start'] ) { |
|
1131 | + if ($i == $dates['m_start']) { |
|
1132 | 1132 | $d = $dates['day_start']; |
1133 | 1133 | } else { |
1134 | 1134 | $d = 1; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | - if ( $i == $dates['m_end'] ) { |
|
1137 | + if ($i == $dates['m_end']) { |
|
1138 | 1138 | $num_of_days = $dates['day_end']; |
1139 | 1139 | } else { |
1140 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1140 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | - while ( $d <= $num_of_days ) : |
|
1144 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1145 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1146 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
1147 | - $sales['sales'][ $date_key ] = 0; |
|
1143 | + while ($d <= $num_of_days) : |
|
1144 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1145 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1146 | + if ( ! isset($sales['sales'][$date_key])) { |
|
1147 | + $sales['sales'][$date_key] = 0; |
|
1148 | 1148 | } |
1149 | - $sales['sales'][ $date_key ] += $sale_count; |
|
1149 | + $sales['sales'][$date_key] += $sale_count; |
|
1150 | 1150 | $total += $sale_count; |
1151 | - $d ++; |
|
1151 | + $d++; |
|
1152 | 1152 | endwhile; |
1153 | - $i ++; |
|
1153 | + $i++; |
|
1154 | 1154 | endwhile; |
1155 | 1155 | |
1156 | - $y ++; |
|
1156 | + $y++; |
|
1157 | 1157 | endwhile; |
1158 | 1158 | |
1159 | 1159 | $sales['totals'] = $total; |
1160 | 1160 | } else { |
1161 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1161 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1162 | 1162 | $sales_count = 0; |
1163 | 1163 | |
1164 | 1164 | // Loop through the months |
1165 | 1165 | $month = $dates['m_start']; |
1166 | 1166 | |
1167 | - while ( $month <= $dates['m_end'] ) : |
|
1168 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1169 | - $month ++; |
|
1167 | + while ($month <= $dates['m_end']) : |
|
1168 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1169 | + $month++; |
|
1170 | 1170 | endwhile; |
1171 | 1171 | |
1172 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
1172 | + $sales['donations'][$args['date']] = $sales_count; |
|
1173 | 1173 | } else { |
1174 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1174 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1175 | 1175 | } |
1176 | 1176 | } |
1177 | - } elseif ( $args['form'] == 'all' ) { |
|
1178 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
1177 | + } elseif ($args['form'] == 'all') { |
|
1178 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
1179 | 1179 | $i = 0; |
1180 | - foreach ( $forms as $form_info ) { |
|
1181 | - $sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) ); |
|
1182 | - $i ++; |
|
1180 | + foreach ($forms as $form_info) { |
|
1181 | + $sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID)); |
|
1182 | + $i++; |
|
1183 | 1183 | } |
1184 | 1184 | } else { |
1185 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1186 | - $form_info = get_post( $args['form'] ); |
|
1187 | - $sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) ); |
|
1185 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1186 | + $form_info = get_post($args['form']); |
|
1187 | + $sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form'])); |
|
1188 | 1188 | } else { |
1189 | 1189 | $error['error'] = sprintf( |
1190 | 1190 | /* translators: %s: form */ |
1191 | - esc_html__( 'Product %s not found!', 'give' ), |
|
1191 | + esc_html__('Product %s not found!', 'give'), |
|
1192 | 1192 | $args['form'] |
1193 | 1193 | ); |
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ( ! empty( $error ) ) { |
|
1197 | + if ( ! empty($error)) { |
|
1198 | 1198 | return $error; |
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | return $sales; |
1202 | 1202 | |
1203 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1204 | - if ( $args['form'] == null ) { |
|
1205 | - if ( $args['date'] == null ) { |
|
1203 | + } elseif ($args['type'] == 'earnings') { |
|
1204 | + if ($args['form'] == null) { |
|
1205 | + if ($args['date'] == null) { |
|
1206 | 1206 | $earnings = $this->get_default_earnings_stats(); |
1207 | - } elseif ( $args['date'] === 'range' ) { |
|
1207 | + } elseif ($args['date'] === 'range') { |
|
1208 | 1208 | // Return sales for a date range |
1209 | 1209 | |
1210 | 1210 | // Ensure the end date is later than the start date |
1211 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1212 | - $error['error'] = esc_html__( 'The end date must be later than the start date!', 'give' ); |
|
1211 | + if ($args['enddate'] < $args['startdate']) { |
|
1212 | + $error['error'] = esc_html__('The end date must be later than the start date!', 'give'); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | // Ensure both the start and end date are specified |
1216 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1217 | - $error['error'] = esc_html__( 'Invalid or no date range specified!', 'give' ); |
|
1216 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1217 | + $error['error'] = esc_html__('Invalid or no date range specified!', 'give'); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | $total = (float) 0.00; |
1221 | 1221 | |
1222 | 1222 | // Loop through the years |
1223 | 1223 | $y = $dates['year']; |
1224 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1224 | + if ( ! isset($earnings['earnings'])) { |
|
1225 | 1225 | $earnings['earnings'] = array(); |
1226 | 1226 | } |
1227 | - while ( $y <= $dates['year_end'] ) : |
|
1227 | + while ($y <= $dates['year_end']) : |
|
1228 | 1228 | |
1229 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1229 | + if ($dates['year'] == $dates['year_end']) { |
|
1230 | 1230 | $month_start = $dates['m_start']; |
1231 | 1231 | $month_end = $dates['m_end']; |
1232 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1232 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1233 | 1233 | $month_start = $dates['m_start']; |
1234 | 1234 | $month_end = 12; |
1235 | - } elseif ( $y == $dates['year_end'] ) { |
|
1235 | + } elseif ($y == $dates['year_end']) { |
|
1236 | 1236 | $month_start = 1; |
1237 | 1237 | $month_end = $dates['m_end']; |
1238 | 1238 | } else { |
@@ -1241,92 +1241,92 @@ discard block |
||
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | $i = $month_start; |
1244 | - while ( $i <= $month_end ) : |
|
1244 | + while ($i <= $month_end) : |
|
1245 | 1245 | |
1246 | - if ( $i == $dates['m_start'] ) { |
|
1246 | + if ($i == $dates['m_start']) { |
|
1247 | 1247 | $d = $dates['day_start']; |
1248 | 1248 | } else { |
1249 | 1249 | $d = 1; |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - if ( $i == $dates['m_end'] ) { |
|
1252 | + if ($i == $dates['m_end']) { |
|
1253 | 1253 | $num_of_days = $dates['day_end']; |
1254 | 1254 | } else { |
1255 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1255 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | - while ( $d <= $num_of_days ) : |
|
1259 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1260 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1261 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1262 | - $earnings['earnings'][ $date_key ] = 0; |
|
1258 | + while ($d <= $num_of_days) : |
|
1259 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1260 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1261 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1262 | + $earnings['earnings'][$date_key] = 0; |
|
1263 | 1263 | } |
1264 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1264 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1265 | 1265 | $total += $earnings_stat; |
1266 | - $d ++; |
|
1266 | + $d++; |
|
1267 | 1267 | endwhile; |
1268 | 1268 | |
1269 | - $i ++; |
|
1269 | + $i++; |
|
1270 | 1270 | endwhile; |
1271 | 1271 | |
1272 | - $y ++; |
|
1272 | + $y++; |
|
1273 | 1273 | endwhile; |
1274 | 1274 | |
1275 | 1275 | $earnings['totals'] = $total; |
1276 | 1276 | } else { |
1277 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1277 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1278 | 1278 | $earnings_count = (float) 0.00; |
1279 | 1279 | |
1280 | 1280 | // Loop through the months |
1281 | 1281 | $month = $dates['m_start']; |
1282 | 1282 | |
1283 | - while ( $month <= $dates['m_end'] ) : |
|
1284 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1285 | - $month ++; |
|
1283 | + while ($month <= $dates['m_end']) : |
|
1284 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1285 | + $month++; |
|
1286 | 1286 | endwhile; |
1287 | 1287 | |
1288 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1288 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1289 | 1289 | } else { |
1290 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1290 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1291 | 1291 | } |
1292 | 1292 | } |
1293 | - } elseif ( $args['form'] == 'all' ) { |
|
1294 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
1293 | + } elseif ($args['form'] == 'all') { |
|
1294 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
1295 | 1295 | |
1296 | 1296 | $i = 0; |
1297 | - foreach ( $forms as $form_info ) { |
|
1298 | - $earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) ); |
|
1299 | - $i ++; |
|
1297 | + foreach ($forms as $form_info) { |
|
1298 | + $earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID)); |
|
1299 | + $i++; |
|
1300 | 1300 | } |
1301 | 1301 | } else { |
1302 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1303 | - $form_info = get_post( $args['form'] ); |
|
1304 | - $earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) ); |
|
1302 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1303 | + $form_info = get_post($args['form']); |
|
1304 | + $earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form'])); |
|
1305 | 1305 | } else { |
1306 | 1306 | $error['error'] = sprintf( |
1307 | 1307 | /* translators: %s: form */ |
1308 | - esc_html__( 'Form %s not found!', 'give' ), |
|
1308 | + esc_html__('Form %s not found!', 'give'), |
|
1309 | 1309 | $args['form'] |
1310 | 1310 | ); |
1311 | 1311 | } |
1312 | 1312 | } |
1313 | 1313 | |
1314 | - if ( ! empty( $error ) ) { |
|
1314 | + if ( ! empty($error)) { |
|
1315 | 1315 | return $error; |
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | return $earnings; |
1319 | - } elseif ( $args['type'] == 'donors' ) { |
|
1319 | + } elseif ($args['type'] == 'donors') { |
|
1320 | 1320 | $customers = new Give_DB_Customers(); |
1321 | 1321 | $stats['donations']['total_donors'] = $customers->count(); |
1322 | 1322 | |
1323 | 1323 | return $stats; |
1324 | 1324 | |
1325 | - } elseif ( empty( $args['type'] ) ) { |
|
1326 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1327 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1325 | + } elseif (empty($args['type'])) { |
|
1326 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1327 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1328 | 1328 | |
1329 | - return array( 'stats' => $stats ); |
|
1329 | + return array('stats' => $stats); |
|
1330 | 1330 | } |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1342,18 +1342,18 @@ discard block |
||
1342 | 1342 | |
1343 | 1343 | $sales = array(); |
1344 | 1344 | |
1345 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1345 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1346 | 1346 | return $sales; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1349 | + if (isset($wp_query->query_vars['id'])) { |
|
1350 | 1350 | $query = array(); |
1351 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1352 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1351 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1352 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1353 | 1353 | $query = array(); |
1354 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1355 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1356 | - $args = array( |
|
1354 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1355 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1356 | + $args = array( |
|
1357 | 1357 | 'fields' => 'ids', |
1358 | 1358 | 'meta_key' => '_give_payment_user_email', |
1359 | 1359 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | 'page' => $this->get_paged(), |
1362 | 1362 | 'status' => 'publish' |
1363 | 1363 | ); |
1364 | - $query = give_get_payments( $args ); |
|
1364 | + $query = give_get_payments($args); |
|
1365 | 1365 | } else { |
1366 | 1366 | $args = array( |
1367 | 1367 | 'fields' => 'ids', |
@@ -1369,14 +1369,14 @@ discard block |
||
1369 | 1369 | 'page' => $this->get_paged(), |
1370 | 1370 | 'status' => 'publish' |
1371 | 1371 | ); |
1372 | - $query = give_get_payments( $args ); |
|
1372 | + $query = give_get_payments($args); |
|
1373 | 1373 | } |
1374 | - if ( $query ) { |
|
1374 | + if ($query) { |
|
1375 | 1375 | $i = 0; |
1376 | - foreach ( $query as $payment ) { |
|
1376 | + foreach ($query as $payment) { |
|
1377 | 1377 | |
1378 | - if ( is_numeric( $payment ) ) { |
|
1379 | - $payment = new Give_Payment( $payment ); |
|
1378 | + if (is_numeric($payment)) { |
|
1379 | + $payment = new Give_Payment($payment); |
|
1380 | 1380 | $payment_meta = $payment->get_meta(); |
1381 | 1381 | $user_info = $payment->user_info; |
1382 | 1382 | } else { |
@@ -1386,40 +1386,40 @@ discard block |
||
1386 | 1386 | $payment_meta = $payment->get_meta(); |
1387 | 1387 | $user_info = $payment->user_info; |
1388 | 1388 | |
1389 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1390 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1391 | - |
|
1392 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
1393 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1394 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
1395 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
1396 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1397 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1398 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
1399 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
1400 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
1401 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
1402 | - |
|
1403 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1404 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1405 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1406 | - |
|
1407 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
1408 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1409 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
1410 | - |
|
1411 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1412 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1413 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1414 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1415 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1416 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1389 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1390 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1391 | + |
|
1392 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
1393 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1394 | + $sales['donations'][$i]['key'] = $payment->key; |
|
1395 | + $sales['donations'][$i]['total'] = $payment->total; |
|
1396 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
1397 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1398 | + $sales['donations'][$i]['fname'] = $first_name; |
|
1399 | + $sales['donations'][$i]['lname'] = $last_name; |
|
1400 | + $sales['donations'][$i]['email'] = $payment->email; |
|
1401 | + $sales['donations'][$i]['date'] = $payment->date; |
|
1402 | + |
|
1403 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1404 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1405 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1406 | + |
|
1407 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
1408 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1409 | + $sales['donations'][$i]['form']['price'] = $price; |
|
1410 | + |
|
1411 | + if (give_has_variable_prices($form_id)) { |
|
1412 | + if (isset($payment_meta['price_id'])) { |
|
1413 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1414 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
1415 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
1416 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1417 | 1417 | |
1418 | 1418 | } |
1419 | 1419 | } |
1420 | 1420 | |
1421 | 1421 | //Add custom meta to API |
1422 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1422 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1423 | 1423 | |
1424 | 1424 | $exceptions = array( |
1425 | 1425 | 'form_title', |
@@ -1432,19 +1432,19 @@ discard block |
||
1432 | 1432 | ); |
1433 | 1433 | |
1434 | 1434 | //Don't clutter up results with dupes |
1435 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1435 | + if (in_array($meta_key, $exceptions)) { |
|
1436 | 1436 | continue; |
1437 | 1437 | } |
1438 | 1438 | |
1439 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1439 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1440 | 1440 | |
1441 | 1441 | } |
1442 | 1442 | |
1443 | - $i ++; |
|
1443 | + $i++; |
|
1444 | 1444 | } |
1445 | 1445 | } |
1446 | 1446 | |
1447 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
1447 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | /** |
@@ -1460,9 +1460,9 @@ discard block |
||
1460 | 1460 | public function get_output_format() { |
1461 | 1461 | global $wp_query; |
1462 | 1462 | |
1463 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1463 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1464 | 1464 | |
1465 | - return apply_filters( 'give_api_output_format', $format ); |
|
1465 | + return apply_filters('give_api_output_format', $format); |
|
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | |
@@ -1479,8 +1479,8 @@ discard block |
||
1479 | 1479 | * |
1480 | 1480 | * @return void |
1481 | 1481 | */ |
1482 | - private function log_request( $data = array() ) { |
|
1483 | - if ( ! $this->log_requests ) { |
|
1482 | + private function log_request($data = array()) { |
|
1483 | + if ( ! $this->log_requests) { |
|
1484 | 1484 | return; |
1485 | 1485 | } |
1486 | 1486 | |
@@ -1496,36 +1496,36 @@ discard block |
||
1496 | 1496 | |
1497 | 1497 | $query = array( |
1498 | 1498 | 'give-api' => $wp_query->query_vars['give-api'], |
1499 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1500 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1501 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1502 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1503 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1504 | - 'customer' => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null, |
|
1505 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1506 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1507 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1508 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1509 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1510 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1499 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1500 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1501 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1502 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1503 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1504 | + 'customer' => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null, |
|
1505 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1506 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1507 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1508 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1509 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1510 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1511 | 1511 | ); |
1512 | 1512 | |
1513 | 1513 | $log_data = array( |
1514 | 1514 | 'log_type' => 'api_request', |
1515 | - 'post_excerpt' => http_build_query( $query ), |
|
1516 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1515 | + 'post_excerpt' => http_build_query($query), |
|
1516 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1517 | 1517 | ); |
1518 | 1518 | |
1519 | 1519 | $log_meta = array( |
1520 | 1520 | 'request_ip' => give_get_ip(), |
1521 | 1521 | 'user' => $this->user_id, |
1522 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1523 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1522 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1523 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1524 | 1524 | 'time' => $data['request_speed'], |
1525 | 1525 | 'version' => $this->get_queried_version() |
1526 | 1526 | ); |
1527 | 1527 | |
1528 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
1528 | + $give_logs->insert_log($log_data, $log_meta); |
|
1529 | 1529 | } |
1530 | 1530 | |
1531 | 1531 | |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | * |
1550 | 1550 | * @param int $status_code |
1551 | 1551 | */ |
1552 | - public function output( $status_code = 200 ) { |
|
1552 | + public function output($status_code = 200) { |
|
1553 | 1553 | /** |
1554 | 1554 | * @var WP_Query $wp_query |
1555 | 1555 | */ |
@@ -1557,27 +1557,27 @@ discard block |
||
1557 | 1557 | |
1558 | 1558 | $format = $this->get_output_format(); |
1559 | 1559 | |
1560 | - status_header( $status_code ); |
|
1560 | + status_header($status_code); |
|
1561 | 1561 | |
1562 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1562 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1563 | 1563 | |
1564 | - switch ( $format ) : |
|
1564 | + switch ($format) : |
|
1565 | 1565 | |
1566 | 1566 | case 'xml' : |
1567 | 1567 | |
1568 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1569 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1568 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1569 | + $xml = Array2XML::createXML('give', $this->data); |
|
1570 | 1570 | echo $xml->saveXML(); |
1571 | 1571 | |
1572 | 1572 | break; |
1573 | 1573 | |
1574 | 1574 | case 'json' : |
1575 | 1575 | |
1576 | - header( 'Content-Type: application/json' ); |
|
1577 | - if ( ! empty( $this->pretty_print ) ) { |
|
1578 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1576 | + header('Content-Type: application/json'); |
|
1577 | + if ( ! empty($this->pretty_print)) { |
|
1578 | + echo json_encode($this->data, $this->pretty_print); |
|
1579 | 1579 | } else { |
1580 | - echo json_encode( $this->data ); |
|
1580 | + echo json_encode($this->data); |
|
1581 | 1581 | } |
1582 | 1582 | |
1583 | 1583 | break; |
@@ -1586,13 +1586,13 @@ discard block |
||
1586 | 1586 | default : |
1587 | 1587 | |
1588 | 1588 | // Allow other formats to be added via extensions |
1589 | - do_action( 'give_api_output_' . $format, $this->data, $this ); |
|
1589 | + do_action('give_api_output_'.$format, $this->data, $this); |
|
1590 | 1590 | |
1591 | 1591 | break; |
1592 | 1592 | |
1593 | 1593 | endswitch; |
1594 | 1594 | |
1595 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1595 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1596 | 1596 | |
1597 | 1597 | give_die(); |
1598 | 1598 | } |
@@ -1609,37 +1609,37 @@ discard block |
||
1609 | 1609 | * |
1610 | 1610 | * @return void |
1611 | 1611 | */ |
1612 | - function user_key_field( $user ) { |
|
1612 | + function user_key_field($user) { |
|
1613 | 1613 | |
1614 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1615 | - $user = get_userdata( $user->ID ); |
|
1614 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1615 | + $user = get_userdata($user->ID); |
|
1616 | 1616 | ?> |
1617 | 1617 | <table class="form-table"> |
1618 | 1618 | <tbody> |
1619 | 1619 | <tr> |
1620 | 1620 | <th> |
1621 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
1621 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
1622 | 1622 | </th> |
1623 | 1623 | <td> |
1624 | 1624 | <?php |
1625 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1626 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1625 | + $public_key = $this->get_user_public_key($user->ID); |
|
1626 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1627 | 1627 | ?> |
1628 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1628 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1629 | 1629 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1630 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
1630 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
1631 | 1631 | <?php } else { ?> |
1632 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> </strong> |
|
1633 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
1632 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> </strong> |
|
1633 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
1634 | 1634 | <br/> |
1635 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> </strong> |
|
1636 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
1635 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> </strong> |
|
1636 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
1637 | 1637 | <br/> |
1638 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> </strong> |
|
1639 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
1638 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> </strong> |
|
1639 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
1640 | 1640 | <br/> |
1641 | 1641 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1642 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1642 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
1643 | 1643 | <?php } ?> |
1644 | 1644 | </td> |
1645 | 1645 | </tr> |
@@ -1658,69 +1658,69 @@ discard block |
||
1658 | 1658 | * |
1659 | 1659 | * @return void |
1660 | 1660 | */ |
1661 | - public function process_api_key( $args ) { |
|
1661 | + public function process_api_key($args) { |
|
1662 | 1662 | |
1663 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1663 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1664 | 1664 | |
1665 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
1665 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
1666 | 1666 | |
1667 | 1667 | } |
1668 | 1668 | |
1669 | - if ( empty( $args['user_id'] ) ) { |
|
1670 | - wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) ); |
|
1669 | + if (empty($args['user_id'])) { |
|
1670 | + wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401)); |
|
1671 | 1671 | } |
1672 | 1672 | |
1673 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1674 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1673 | + if (is_numeric($args['user_id'])) { |
|
1674 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1675 | 1675 | } else { |
1676 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1676 | + $userdata = get_user_by('login', $args['user_id']); |
|
1677 | 1677 | $user_id = $userdata->ID; |
1678 | 1678 | } |
1679 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1679 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1680 | 1680 | |
1681 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1681 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1682 | 1682 | wp_die( |
1683 | 1683 | sprintf( |
1684 | 1684 | /* translators: %s: process */ |
1685 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
1685 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
1686 | 1686 | $process |
1687 | 1687 | ), |
1688 | - esc_html__( 'Error', 'give' ), |
|
1689 | - array( 'response' => 403 ) |
|
1688 | + esc_html__('Error', 'give'), |
|
1689 | + array('response' => 403) |
|
1690 | 1690 | ); |
1691 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1691 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1692 | 1692 | wp_die( |
1693 | 1693 | sprintf( |
1694 | 1694 | /* translators: %s: process */ |
1695 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
1695 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
1696 | 1696 | $process |
1697 | 1697 | ), |
1698 | - esc_html__( 'Error', 'give' ), |
|
1699 | - array( 'response' => 403 ) |
|
1698 | + esc_html__('Error', 'give'), |
|
1699 | + array('response' => 403) |
|
1700 | 1700 | ); |
1701 | 1701 | } |
1702 | 1702 | |
1703 | - switch ( $process ) { |
|
1703 | + switch ($process) { |
|
1704 | 1704 | case 'generate': |
1705 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1706 | - delete_transient( 'give_total_api_keys' ); |
|
1707 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
1705 | + if ($this->generate_api_key($user_id)) { |
|
1706 | + delete_transient('give_total_api_keys'); |
|
1707 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
1708 | 1708 | exit(); |
1709 | 1709 | } else { |
1710 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
1710 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
1711 | 1711 | exit(); |
1712 | 1712 | } |
1713 | 1713 | break; |
1714 | 1714 | case 'regenerate': |
1715 | - $this->generate_api_key( $user_id, true ); |
|
1716 | - delete_transient( 'give_total_api_keys' ); |
|
1717 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
1715 | + $this->generate_api_key($user_id, true); |
|
1716 | + delete_transient('give_total_api_keys'); |
|
1717 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
1718 | 1718 | exit(); |
1719 | 1719 | break; |
1720 | 1720 | case 'revoke': |
1721 | - $this->revoke_api_key( $user_id ); |
|
1722 | - delete_transient( 'give_total_api_keys' ); |
|
1723 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
1721 | + $this->revoke_api_key($user_id); |
|
1722 | + delete_transient('give_total_api_keys'); |
|
1723 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
1724 | 1724 | exit(); |
1725 | 1725 | break; |
1726 | 1726 | default; |
@@ -1739,34 +1739,34 @@ discard block |
||
1739 | 1739 | * |
1740 | 1740 | * @return boolean True if (re)generated succesfully, false otherwise. |
1741 | 1741 | */ |
1742 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1742 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1743 | 1743 | |
1744 | - if ( empty( $user_id ) ) { |
|
1744 | + if (empty($user_id)) { |
|
1745 | 1745 | return false; |
1746 | 1746 | } |
1747 | 1747 | |
1748 | - $user = get_userdata( $user_id ); |
|
1748 | + $user = get_userdata($user_id); |
|
1749 | 1749 | |
1750 | - if ( ! $user ) { |
|
1750 | + if ( ! $user) { |
|
1751 | 1751 | return false; |
1752 | 1752 | } |
1753 | 1753 | |
1754 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1755 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1754 | + $public_key = $this->get_user_public_key($user_id); |
|
1755 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1756 | 1756 | |
1757 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
1758 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1759 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1757 | + if (empty($public_key) || $regenerate == true) { |
|
1758 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1759 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1760 | 1760 | } else { |
1761 | 1761 | return false; |
1762 | 1762 | } |
1763 | 1763 | |
1764 | - if ( $regenerate == true ) { |
|
1765 | - $this->revoke_api_key( $user->ID ); |
|
1764 | + if ($regenerate == true) { |
|
1765 | + $this->revoke_api_key($user->ID); |
|
1766 | 1766 | } |
1767 | 1767 | |
1768 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1769 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1768 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1769 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1770 | 1770 | |
1771 | 1771 | return true; |
1772 | 1772 | } |
@@ -1781,26 +1781,26 @@ discard block |
||
1781 | 1781 | * |
1782 | 1782 | * @return string |
1783 | 1783 | */ |
1784 | - public function revoke_api_key( $user_id = 0 ) { |
|
1784 | + public function revoke_api_key($user_id = 0) { |
|
1785 | 1785 | |
1786 | - if ( empty( $user_id ) ) { |
|
1786 | + if (empty($user_id)) { |
|
1787 | 1787 | return false; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $user = get_userdata( $user_id ); |
|
1790 | + $user = get_userdata($user_id); |
|
1791 | 1791 | |
1792 | - if ( ! $user ) { |
|
1792 | + if ( ! $user) { |
|
1793 | 1793 | return false; |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1797 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1798 | - if ( ! empty( $public_key ) ) { |
|
1799 | - delete_transient( md5( 'give_api_user_' . $public_key ) ); |
|
1800 | - delete_transient( md5( 'give_api_user_public_key' . $user_id ) ); |
|
1801 | - delete_transient( md5( 'give_api_user_secret_key' . $user_id ) ); |
|
1802 | - delete_user_meta( $user_id, $public_key ); |
|
1803 | - delete_user_meta( $user_id, $secret_key ); |
|
1796 | + $public_key = $this->get_user_public_key($user_id); |
|
1797 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1798 | + if ( ! empty($public_key)) { |
|
1799 | + delete_transient(md5('give_api_user_'.$public_key)); |
|
1800 | + delete_transient(md5('give_api_user_public_key'.$user_id)); |
|
1801 | + delete_transient(md5('give_api_user_secret_key'.$user_id)); |
|
1802 | + delete_user_meta($user_id, $public_key); |
|
1803 | + delete_user_meta($user_id, $secret_key); |
|
1804 | 1804 | } else { |
1805 | 1805 | return false; |
1806 | 1806 | } |
@@ -1825,22 +1825,22 @@ discard block |
||
1825 | 1825 | * |
1826 | 1826 | * @return void |
1827 | 1827 | */ |
1828 | - public function update_key( $user_id ) { |
|
1829 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
1828 | + public function update_key($user_id) { |
|
1829 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
1830 | 1830 | |
1831 | - $user = get_userdata( $user_id ); |
|
1831 | + $user = get_userdata($user_id); |
|
1832 | 1832 | |
1833 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1834 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1833 | + $public_key = $this->get_user_public_key($user_id); |
|
1834 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1835 | 1835 | |
1836 | - if ( empty( $public_key ) ) { |
|
1837 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1838 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1836 | + if (empty($public_key)) { |
|
1837 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1838 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1839 | 1839 | |
1840 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1841 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1840 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1841 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1842 | 1842 | } else { |
1843 | - $this->revoke_api_key( $user_id ); |
|
1843 | + $this->revoke_api_key($user_id); |
|
1844 | 1844 | } |
1845 | 1845 | } |
1846 | 1846 | } |
@@ -1855,9 +1855,9 @@ discard block |
||
1855 | 1855 | * |
1856 | 1856 | * @return string |
1857 | 1857 | */ |
1858 | - private function generate_public_key( $user_email = '' ) { |
|
1859 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1860 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1858 | + private function generate_public_key($user_email = '') { |
|
1859 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1860 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
1861 | 1861 | |
1862 | 1862 | return $public; |
1863 | 1863 | } |
@@ -1872,9 +1872,9 @@ discard block |
||
1872 | 1872 | * |
1873 | 1873 | * @return string |
1874 | 1874 | */ |
1875 | - private function generate_private_key( $user_id = 0 ) { |
|
1876 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1877 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
1875 | + private function generate_private_key($user_id = 0) { |
|
1876 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1877 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
1878 | 1878 | |
1879 | 1879 | return $secret; |
1880 | 1880 | } |
@@ -1889,8 +1889,8 @@ discard block |
||
1889 | 1889 | * |
1890 | 1890 | * @return string |
1891 | 1891 | */ |
1892 | - public function get_token( $user_id = 0 ) { |
|
1893 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
1892 | + public function get_token($user_id = 0) { |
|
1893 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
1894 | 1894 | } |
1895 | 1895 | |
1896 | 1896 | /** |
@@ -1904,9 +1904,9 @@ discard block |
||
1904 | 1904 | |
1905 | 1905 | // Default sales return |
1906 | 1906 | $sales = array(); |
1907 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
1908 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
1909 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
1907 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
1908 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
1909 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
1910 | 1910 | $sales['donations']['totals'] = give_get_total_sales(); |
1911 | 1911 | |
1912 | 1912 | return $sales; |
@@ -1923,9 +1923,9 @@ discard block |
||
1923 | 1923 | |
1924 | 1924 | // Default earnings return |
1925 | 1925 | $earnings = array(); |
1926 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
1927 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
1928 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
1926 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
1927 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
1928 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
1929 | 1929 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
1930 | 1930 | |
1931 | 1931 | return $earnings; |
@@ -1945,25 +1945,25 @@ discard block |
||
1945 | 1945 | * |
1946 | 1946 | * @return string The API key/secret for the user supplied |
1947 | 1947 | */ |
1948 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
1948 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
1949 | 1949 | |
1950 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
1950 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
1951 | 1951 | return $check; |
1952 | 1952 | } |
1953 | 1953 | |
1954 | 1954 | $return = $check; |
1955 | 1955 | |
1956 | - switch ( $meta_key ) { |
|
1956 | + switch ($meta_key) { |
|
1957 | 1957 | case 'give_user_public_key': |
1958 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
1958 | + $return = Give()->api->get_user_public_key($object_id); |
|
1959 | 1959 | break; |
1960 | 1960 | case 'give_user_secret_key': |
1961 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
1961 | + $return = Give()->api->get_user_secret_key($object_id); |
|
1962 | 1962 | break; |
1963 | 1963 | } |
1964 | 1964 | |
1965 | - if ( ! $single ) { |
|
1966 | - $return = array( $return ); |
|
1965 | + if ( ! $single) { |
|
1966 | + $return = array($return); |
|
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | return $return; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param array $args Arguments for display |
23 | 23 | * |
24 | - * @return string $purchase_form |
|
24 | + * @return false|null $purchase_form |
|
25 | 25 | */ |
26 | 26 | function give_get_donation_form( $args = array() ) { |
27 | 27 | |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | * @param int $form_id |
1151 | 1151 | * @param array $args |
1152 | 1152 | * |
1153 | - * @return mixed |
|
1153 | + * @return boolean |
|
1154 | 1154 | */ |
1155 | 1155 | |
1156 | 1156 | function give_show_goal_progress( $form_id, $args ) { |
@@ -790,8 +790,11 @@ |
||
790 | 790 | } |
791 | 791 | ?> |
792 | 792 | </select> |
793 | - <?php else : ?> |
|
794 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_html_e( 'State / Province', 'give' ); ?>"/> |
|
793 | + <?php else { |
|
794 | + : ?> |
|
795 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_html_e( 'State / Province', 'give' ); |
|
796 | +} |
|
797 | +?>"/> |
|
795 | 798 | <?php endif; ?> |
796 | 799 | </p> |
797 | 800 | <?php do_action( 'give_cc_billing_bottom' ); ?> |
@@ -1189,10 +1189,10 @@ |
||
1189 | 1189 | |
1190 | 1190 | function give_show_goal_progress( $form_id, $args ) { |
1191 | 1191 | |
1192 | - ob_start(); |
|
1193 | - give_get_template( 'shortcode-goal' , array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1192 | + ob_start(); |
|
1193 | + give_get_template( 'shortcode-goal' , array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1194 | 1194 | |
1195 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1195 | + echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1196 | 1196 | |
1197 | 1197 | return true; |
1198 | 1198 | } |
@@ -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,47 +23,47 @@ 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 = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = 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 | 62 | //Get the form wrap CSS classes. |
63 | - $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
63 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
64 | 64 | |
65 | 65 | //Get the <form> tag wrap CSS classes. |
66 | - $form_classes = $form->get_form_classes($args); |
|
66 | + $form_classes = $form->get_form_classes($args); |
|
67 | 67 | |
68 | 68 | ob_start(); |
69 | 69 | |
@@ -75,35 +75,35 @@ discard block |
||
75 | 75 | * @param int $form ->ID The current form ID |
76 | 76 | * @param array $args An array of form args |
77 | 77 | */ |
78 | - do_action( 'give_pre_form_output', $form->ID, $args ); ?> |
|
78 | + do_action('give_pre_form_output', $form->ID, $args); ?> |
|
79 | 79 | |
80 | 80 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
81 | 81 | |
82 | - <?php if ( $form->is_close_donation_form() ) { |
|
82 | + <?php if ($form->is_close_donation_form()) { |
|
83 | 83 | |
84 | 84 | //Get Goal thank you message. |
85 | - $display_thankyou_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
86 | - $display_thankyou_message = ! empty( $display_thankyou_message ) ? $display_thankyou_message : esc_html__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ); |
|
85 | + $display_thankyou_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
86 | + $display_thankyou_message = ! empty($display_thankyou_message) ? $display_thankyou_message : esc_html__('Thank you to all our donors, we have met our fundraising goal.', 'give'); |
|
87 | 87 | |
88 | 88 | //Print thank you message. |
89 | - apply_filters( 'give_goal_closed_output', give_output_error( $display_thankyou_message, true, 'success' ) ); |
|
89 | + apply_filters('give_goal_closed_output', give_output_error($display_thankyou_message, true, 'success')); |
|
90 | 90 | |
91 | 91 | } else { |
92 | 92 | |
93 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
93 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
94 | 94 | |
95 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
95 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | - do_action( 'give_pre_form', $form->ID, $args ); ?> |
|
99 | + do_action('give_pre_form', $form->ID, $args); ?> |
|
100 | 100 | |
101 | - <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
101 | + <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
102 | 102 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
103 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
104 | - <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
105 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
106 | - <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
103 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
104 | + <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
105 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
106 | + <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
107 | 107 | |
108 | 108 | <!-- The following field is for robots only, invisible to humans: --> |
109 | 109 | <span class="give-hidden" style="display: none !important;"> |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | <?php |
115 | 115 | |
116 | 116 | //Price ID hidden field for variable (mult-level) donation forms |
117 | - if ( give_has_variable_prices( $form_id ) ) { |
|
117 | + if (give_has_variable_prices($form_id)) { |
|
118 | 118 | //get default selected price ID |
119 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
119 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
120 | 120 | $price_id = 0; |
121 | 121 | //loop through prices |
122 | - foreach ( $prices as $price ) { |
|
123 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
122 | + foreach ($prices as $price) { |
|
123 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
124 | 124 | $price_id = $price['_give_id']['level_id']; |
125 | 125 | }; |
126 | 126 | } |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | <input type="hidden" name="give-price-id" value="<?php echo $price_id; ?>"/> |
129 | 129 | <?php } |
130 | 130 | |
131 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
131 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
132 | 132 | |
133 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
133 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
134 | 134 | |
135 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
135 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
136 | 136 | |
137 | 137 | ?> |
138 | 138 | </form> |
139 | 139 | |
140 | - <?php do_action( 'give_post_form', $form->ID, $args ); ?> |
|
140 | + <?php do_action('give_post_form', $form->ID, $args); ?> |
|
141 | 141 | |
142 | 142 | <?php } ?> |
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 | |
@@ -175,43 +175,43 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return string |
177 | 177 | */ |
178 | -function give_show_purchase_form( $form_id ) { |
|
178 | +function give_show_purchase_form($form_id) { |
|
179 | 179 | |
180 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
180 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
181 | 181 | |
182 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
182 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
183 | 183 | $form_id = $_POST['give_form_id']; |
184 | 184 | } |
185 | 185 | |
186 | - do_action( 'give_purchase_form_top', $form_id ); |
|
186 | + do_action('give_purchase_form_top', $form_id); |
|
187 | 187 | |
188 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
188 | + if (give_can_checkout() && isset($form_id)) { |
|
189 | 189 | |
190 | - do_action( 'give_purchase_form_before_register_login', $form_id ); |
|
190 | + do_action('give_purchase_form_before_register_login', $form_id); |
|
191 | 191 | |
192 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
192 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
193 | 193 | |
194 | - do_action( 'give_purchase_form_before_cc_form', $form_id ); |
|
194 | + do_action('give_purchase_form_before_cc_form', $form_id); |
|
195 | 195 | |
196 | 196 | // Load the credit card form and allow gateways to load their own if they wish |
197 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
198 | - do_action( 'give_' . $payment_mode . '_cc_form', $form_id ); |
|
197 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
198 | + do_action('give_'.$payment_mode.'_cc_form', $form_id); |
|
199 | 199 | } else { |
200 | - do_action( 'give_cc_form', $form_id ); |
|
200 | + do_action('give_cc_form', $form_id); |
|
201 | 201 | } |
202 | 202 | |
203 | - do_action( 'give_purchase_form_after_cc_form', $form_id ); |
|
203 | + do_action('give_purchase_form_after_cc_form', $form_id); |
|
204 | 204 | |
205 | 205 | } else { |
206 | 206 | // Can't checkout |
207 | - do_action( 'give_purchase_form_no_access', $form_id ); |
|
207 | + do_action('give_purchase_form_no_access', $form_id); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
211 | - do_action( 'give_purchase_form_bottom', $form_id ); |
|
211 | + do_action('give_purchase_form_bottom', $form_id); |
|
212 | 212 | } |
213 | 213 | |
214 | -add_action( 'give_purchase_form', 'give_show_purchase_form' ); |
|
214 | +add_action('give_purchase_form', 'give_show_purchase_form'); |
|
215 | 215 | |
216 | 216 | /** |
217 | 217 | * |
@@ -223,26 +223,26 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return void |
225 | 225 | */ |
226 | -function give_show_register_login_fields( $form_id ) { |
|
226 | +function give_show_register_login_fields($form_id) { |
|
227 | 227 | |
228 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
228 | + $show_register_form = give_show_login_register_option($form_id); |
|
229 | 229 | |
230 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
230 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
231 | 231 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
232 | - <?php do_action( 'give_purchase_form_register_fields', $form_id ); ?> |
|
232 | + <?php do_action('give_purchase_form_register_fields', $form_id); ?> |
|
233 | 233 | </div> |
234 | - <?php elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : ?> |
|
234 | + <?php elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : ?> |
|
235 | 235 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
236 | - <?php do_action( 'give_purchase_form_login_fields', $form_id ); ?> |
|
236 | + <?php do_action('give_purchase_form_login_fields', $form_id); ?> |
|
237 | 237 | </div> |
238 | 238 | <?php endif; ?> |
239 | 239 | |
240 | - <?php if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
241 | - do_action( 'give_purchase_form_after_user_info', $form_id ); |
|
240 | + <?php if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
241 | + do_action('give_purchase_form_after_user_info', $form_id); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | -add_action( 'give_purchase_form_register_login_fields', 'give_show_register_login_fields' ); |
|
245 | +add_action('give_purchase_form_register_login_fields', 'give_show_register_login_fields'); |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Donation Amount Field |
@@ -256,33 +256,33 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return void |
258 | 258 | */ |
259 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
259 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
260 | 260 | |
261 | 261 | global $give_options; |
262 | 262 | |
263 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
264 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
265 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
266 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
267 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
268 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
269 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
263 | + $variable_pricing = give_has_variable_prices($form_id); |
|
264 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
265 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
266 | + $symbol = give_currency_symbol(give_get_currency()); |
|
267 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
268 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
269 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
270 | 270 | |
271 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
271 | + do_action('give_before_donation_levels', $form_id, $args); |
|
272 | 272 | |
273 | 273 | //Set Price, No Custom Amount Allowed means hidden price field |
274 | - if ( $allow_custom_amount == 'no' ) { |
|
274 | + if ($allow_custom_amount == 'no') { |
|
275 | 275 | ?> |
276 | 276 | |
277 | - <label class="give-hidden" for="give-amount-hidden"><?php echo esc_html__( 'Donation Amount:', 'give' ); ?></label> |
|
277 | + <label class="give-hidden" for="give-amount-hidden"><?php echo esc_html__('Donation Amount:', 'give'); ?></label> |
|
278 | 278 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
279 | 279 | value="<?php echo $default_amount; ?>" required> |
280 | 280 | <div class="set-price give-donation-amount form-row-wide"> |
281 | - <?php if ( $currency_position == 'before' ) { |
|
281 | + <?php if ($currency_position == 'before') { |
|
282 | 282 | echo $currency_output; |
283 | 283 | } ?> |
284 | 284 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
285 | - <?php if ( $currency_position == 'after' ) { |
|
285 | + <?php if ($currency_position == 'after') { |
|
286 | 286 | echo $currency_output; |
287 | 287 | } ?> |
288 | 288 | </div> |
@@ -292,34 +292,34 @@ discard block |
||
292 | 292 | ?> |
293 | 293 | <div class="give-total-wrap"> |
294 | 294 | <div class="give-donation-amount form-row-wide"> |
295 | - <?php if ( $currency_position == 'before' ) { |
|
295 | + <?php if ($currency_position == 'before') { |
|
296 | 296 | echo $currency_output; |
297 | 297 | } ?> |
298 | - <label class="give-hidden" for="give-amount"><?php echo esc_html__( 'Donation Amount:', 'give' ); ?></label> |
|
298 | + <label class="give-hidden" for="give-amount"><?php echo esc_html__('Donation Amount:', 'give'); ?></label> |
|
299 | 299 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
300 | - <?php if ( $currency_position == 'after' ) { |
|
300 | + <?php if ($currency_position == 'after') { |
|
301 | 301 | echo $currency_output; |
302 | 302 | } ?> |
303 | 303 | </div> |
304 | 304 | </div> |
305 | 305 | <?php } |
306 | 306 | |
307 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
307 | + do_action('give_after_donation_amount', $form_id, $args); |
|
308 | 308 | |
309 | 309 | //Custom Amount Text |
310 | - if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?> |
|
310 | + if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?> |
|
311 | 311 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
312 | 312 | <?php } |
313 | 313 | |
314 | 314 | //Output Variable Pricing Levels |
315 | - if ( $variable_pricing ) { |
|
316 | - give_output_levels( $form_id ); |
|
315 | + if ($variable_pricing) { |
|
316 | + give_output_levels($form_id); |
|
317 | 317 | } |
318 | 318 | |
319 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
319 | + do_action('give_after_donation_levels', $form_id, $args); |
|
320 | 320 | } |
321 | 321 | |
322 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
322 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
323 | 323 | |
324 | 324 | |
325 | 325 | /** |
@@ -331,32 +331,32 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return string |
333 | 333 | */ |
334 | -function give_output_levels( $form_id ) { |
|
334 | +function give_output_levels($form_id) { |
|
335 | 335 | |
336 | 336 | //Get variable pricing |
337 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
338 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
339 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
340 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
341 | - if ( empty( $custom_amount_text ) ) { |
|
342 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
337 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
338 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
339 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
340 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
341 | + if (empty($custom_amount_text)) { |
|
342 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $output = ''; |
346 | 346 | $counter = 0; |
347 | 347 | |
348 | - switch ( $display_style ) { |
|
348 | + switch ($display_style) { |
|
349 | 349 | case 'buttons': |
350 | 350 | |
351 | 351 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
352 | 352 | |
353 | - foreach ( $prices as $price ) { |
|
354 | - $counter ++; |
|
355 | - $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 ); |
|
356 | - $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 ); |
|
353 | + foreach ($prices as $price) { |
|
354 | + $counter++; |
|
355 | + $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); |
|
356 | + $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); |
|
357 | 357 | |
358 | 358 | $output .= '<li>'; |
359 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
359 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
360 | 360 | $output .= $level_text; |
361 | 361 | $output .= '</button>'; |
362 | 362 | $output .= '</li>'; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | } |
365 | 365 | |
366 | 366 | //Custom Amount |
367 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
367 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
368 | 368 | $output .= '<li>'; |
369 | 369 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
370 | 370 | $output .= $custom_amount_text; |
@@ -380,23 +380,23 @@ discard block |
||
380 | 380 | |
381 | 381 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
382 | 382 | |
383 | - foreach ( $prices as $price ) { |
|
384 | - $counter ++; |
|
385 | - $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 ); |
|
386 | - $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 ); |
|
383 | + foreach ($prices as $price) { |
|
384 | + $counter++; |
|
385 | + $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); |
|
386 | + $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); |
|
387 | 387 | |
388 | 388 | $output .= '<li>'; |
389 | - $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'] ) . '">'; |
|
390 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
389 | + $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']).'">'; |
|
390 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
391 | 391 | $output .= '</li>'; |
392 | 392 | |
393 | 393 | } |
394 | 394 | |
395 | 395 | //Custom Amount |
396 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
396 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
397 | 397 | $output .= '<li>'; |
398 | 398 | $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">'; |
399 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
399 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
400 | 400 | $output .= '</li>'; |
401 | 401 | } |
402 | 402 | |
@@ -406,23 +406,23 @@ discard block |
||
406 | 406 | |
407 | 407 | case 'dropdown': |
408 | 408 | |
409 | - $output .= '<label for="give-donation-level" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
410 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
409 | + $output .= '<label for="give-donation-level" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
410 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
411 | 411 | |
412 | 412 | //first loop through prices |
413 | - foreach ( $prices as $price ) { |
|
414 | - $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 ); |
|
415 | - $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 ); |
|
413 | + foreach ($prices as $price) { |
|
414 | + $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); |
|
415 | + $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); |
|
416 | 416 | |
417 | - $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'] ) . '">'; |
|
417 | + $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 | 418 | $output .= $level_text; |
419 | 419 | $output .= '</option>'; |
420 | 420 | |
421 | 421 | } |
422 | 422 | |
423 | 423 | //Custom Amount |
424 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
425 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
424 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
425 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $output .= '</select>'; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | break; |
431 | 431 | } |
432 | 432 | |
433 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
433 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -442,26 +442,26 @@ discard block |
||
442 | 442 | * @param array $args |
443 | 443 | * |
444 | 444 | */ |
445 | -function give_display_checkout_button( $form_id, $args ) { |
|
445 | +function give_display_checkout_button($form_id, $args) { |
|
446 | 446 | |
447 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
447 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
448 | 448 | ? $args['display_style'] |
449 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
449 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
450 | 450 | |
451 | 451 | //no btn for onpage |
452 | - if ( $display_option === 'onpage' ) { |
|
452 | + if ($display_option === 'onpage') { |
|
453 | 453 | return; |
454 | 454 | } |
455 | 455 | |
456 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
457 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
456 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
457 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
458 | 458 | |
459 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
459 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
460 | 460 | |
461 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
461 | + echo apply_filters('give_display_checkout_button', $output); |
|
462 | 462 | } |
463 | 463 | |
464 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
464 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
465 | 465 | |
466 | 466 | /** |
467 | 467 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -472,71 +472,71 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return void |
474 | 474 | */ |
475 | -function give_user_info_fields( $form_id ) { |
|
475 | +function give_user_info_fields($form_id) { |
|
476 | 476 | |
477 | - if ( is_user_logged_in() ) : |
|
478 | - $user_data = get_userdata( get_current_user_id() ); |
|
477 | + if (is_user_logged_in()) : |
|
478 | + $user_data = get_userdata(get_current_user_id()); |
|
479 | 479 | endif; |
480 | 480 | |
481 | - do_action( 'give_purchase_form_before_personal_info', $form_id ); |
|
481 | + do_action('give_purchase_form_before_personal_info', $form_id); |
|
482 | 482 | ?> |
483 | 483 | <fieldset id="give_checkout_user_info"> |
484 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
484 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
485 | 485 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
486 | 486 | <label class="give-label" for="give-first"> |
487 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
488 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) { ?> |
|
487 | + <?php esc_html_e('First Name', 'give'); ?> |
|
488 | + <?php if (give_field_is_required('give_first', $form_id)) { ?> |
|
489 | 489 | <span class="give-required-indicator">*</span> |
490 | 490 | <?php } ?> |
491 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
491 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
492 | 492 | </label> |
493 | - <input class="give-input required" type="text" name="give_first" placeholder="<?php esc_html_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 ) ) { |
|
493 | + <input class="give-input required" type="text" name="give_first" placeholder="<?php esc_html_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 | 494 | echo ' required '; |
495 | 495 | } ?>/> |
496 | 496 | </p> |
497 | 497 | |
498 | 498 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
499 | 499 | <label class="give-label" for="give-last"> |
500 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
501 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) { ?> |
|
500 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
501 | + <?php if (give_field_is_required('give_last', $form_id)) { ?> |
|
502 | 502 | <span class="give-required-indicator">*</span> |
503 | 503 | <?php } ?> |
504 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
504 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
505 | 505 | </label> |
506 | 506 | |
507 | - <input class="give-input<?php if ( give_field_is_required( 'give_last', $form_id ) ) { |
|
507 | + <input class="give-input<?php if (give_field_is_required('give_last', $form_id)) { |
|
508 | 508 | echo ' required'; |
509 | - } ?>" type="text" name="give_last" id="give-last" placeholder="<?php esc_html_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 ) ) { |
|
509 | + } ?>" type="text" name="give_last" id="give-last" placeholder="<?php esc_html_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 | 510 | echo ' required '; |
511 | 511 | } ?> /> |
512 | 512 | </p> |
513 | 513 | |
514 | - <?php do_action( 'give_purchase_form_before_email', $form_id ); ?> |
|
514 | + <?php do_action('give_purchase_form_before_email', $form_id); ?> |
|
515 | 515 | <p id="give-email-wrap" class="form-row form-row-wide"> |
516 | 516 | <label class="give-label" for="give-email"> |
517 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
518 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
517 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
518 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
519 | 519 | <span class="give-required-indicator">*</span> |
520 | 520 | <?php } ?> |
521 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'We will send the purchase receipt to this address.', 'give' ); ?>"></span> |
|
521 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('We will send the purchase receipt to this address.', 'give'); ?>"></span> |
|
522 | 522 | </label> |
523 | 523 | |
524 | - <input class="give-input required" type="email" name="give_email" placeholder="<?php esc_html_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 ) ) { |
|
524 | + <input class="give-input required" type="email" name="give_email" placeholder="<?php esc_html_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 | 525 | echo ' required '; |
526 | 526 | } ?>/> |
527 | 527 | |
528 | 528 | </p> |
529 | - <?php do_action( 'give_purchase_form_after_email', $form_id ); ?> |
|
529 | + <?php do_action('give_purchase_form_after_email', $form_id); ?> |
|
530 | 530 | |
531 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
531 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
532 | 532 | </fieldset> |
533 | 533 | <?php |
534 | - do_action( 'give_purchase_form_after_personal_info', $form_id ); |
|
534 | + do_action('give_purchase_form_after_personal_info', $form_id); |
|
535 | 535 | |
536 | 536 | } |
537 | 537 | |
538 | -add_action( 'give_purchase_form_after_user_info', 'give_user_info_fields' ); |
|
539 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
538 | +add_action('give_purchase_form_after_user_info', 'give_user_info_fields'); |
|
539 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
540 | 540 | |
541 | 541 | /** |
542 | 542 | * Renders the credit card info form. |
@@ -547,73 +547,73 @@ discard block |
||
547 | 547 | * |
548 | 548 | * @return void |
549 | 549 | */ |
550 | -function give_get_cc_form( $form_id ) { |
|
550 | +function give_get_cc_form($form_id) { |
|
551 | 551 | |
552 | 552 | ob_start(); |
553 | 553 | |
554 | - do_action( 'give_before_cc_fields', $form_id ); ?> |
|
554 | + do_action('give_before_cc_fields', $form_id); ?> |
|
555 | 555 | |
556 | 556 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
557 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
558 | - <?php if ( is_ssl() ) : ?> |
|
557 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
558 | + <?php if (is_ssl()) : ?> |
|
559 | 559 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
560 | 560 | <span class="give-icon padlock"></span> |
561 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
561 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
562 | 562 | </div> |
563 | 563 | <?php endif; ?> |
564 | 564 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
565 | 565 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
566 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
566 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
567 | 567 | <span class="give-required-indicator">*</span> |
568 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
568 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
569 | 569 | <span class="card-type"></span> |
570 | 570 | </label> |
571 | 571 | |
572 | - <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_html_e( 'Card number', 'give' ); ?>" required/> |
|
572 | + <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_html_e('Card number', 'give'); ?>" required/> |
|
573 | 573 | </p> |
574 | 574 | |
575 | 575 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
576 | 576 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
577 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
577 | + <?php esc_html_e('CVC', 'give'); ?> |
|
578 | 578 | <span class="give-required-indicator">*</span> |
579 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
579 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
580 | 580 | </label> |
581 | 581 | |
582 | - <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 esc_html_e( 'Security code', 'give' ); ?>" required/> |
|
582 | + <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 esc_html_e('Security code', 'give'); ?>" required/> |
|
583 | 583 | </p> |
584 | 584 | |
585 | 585 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
586 | 586 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
587 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
587 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
588 | 588 | <span class="give-required-indicator">*</span> |
589 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
589 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
590 | 590 | </label> |
591 | 591 | |
592 | - <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_html_e( 'Card name', 'give' ); ?>" required/> |
|
592 | + <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_html_e('Card name', 'give'); ?>" required/> |
|
593 | 593 | </p> |
594 | - <?php do_action( 'give_before_cc_expiration' ); ?> |
|
594 | + <?php do_action('give_before_cc_expiration'); ?> |
|
595 | 595 | <p class="card-expiration form-row form-row-one-third"> |
596 | 596 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
597 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
597 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
598 | 598 | <span class="give-required-indicator">*</span> |
599 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
599 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
600 | 600 | </label> |
601 | 601 | |
602 | 602 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
603 | 603 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
604 | 604 | |
605 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_html_e( 'MM / YY', 'give' ); ?>" required/> |
|
605 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_html_e('MM / YY', 'give'); ?>" required/> |
|
606 | 606 | </p> |
607 | - <?php do_action( 'give_after_cc_expiration', $form_id ); ?> |
|
607 | + <?php do_action('give_after_cc_expiration', $form_id); ?> |
|
608 | 608 | |
609 | 609 | </fieldset> |
610 | 610 | <?php |
611 | - do_action( 'give_after_cc_fields', $form_id ); |
|
611 | + do_action('give_after_cc_fields', $form_id); |
|
612 | 612 | |
613 | 613 | echo ob_get_clean(); |
614 | 614 | } |
615 | 615 | |
616 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
616 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
617 | 617 | |
618 | 618 | /** |
619 | 619 | * Outputs the default credit card address fields |
@@ -624,110 +624,110 @@ discard block |
||
624 | 624 | * |
625 | 625 | * @return void |
626 | 626 | */ |
627 | -function give_default_cc_address_fields( $form_id ) { |
|
627 | +function give_default_cc_address_fields($form_id) { |
|
628 | 628 | |
629 | 629 | $logged_in = is_user_logged_in(); |
630 | 630 | |
631 | - if ( $logged_in ) { |
|
632 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
631 | + if ($logged_in) { |
|
632 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
633 | 633 | } |
634 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
635 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
636 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
637 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
634 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
635 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
636 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
637 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
638 | 638 | ob_start(); ?> |
639 | 639 | <fieldset id="give_cc_address" class="cc-address"> |
640 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
641 | - <?php do_action( 'give_cc_billing_top' ); ?> |
|
640 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
641 | + <?php do_action('give_cc_billing_top'); ?> |
|
642 | 642 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
643 | 643 | <label for="card_address" class="give-label"> |
644 | - <?php esc_html_e( 'Address', 'give' ); ?> |
|
644 | + <?php esc_html_e('Address', 'give'); ?> |
|
645 | 645 | <?php |
646 | - if ( give_field_is_required( 'card_address', $form_id ) ) { ?> |
|
646 | + if (give_field_is_required('card_address', $form_id)) { ?> |
|
647 | 647 | <span class="give-required-indicator">*</span> |
648 | 648 | <?php } ?> |
649 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
649 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
650 | 650 | </label> |
651 | 651 | |
652 | - <input type="text" id="card_address" name="card_address" class="card-address give-input<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
652 | + <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 | 653 | echo ' required'; |
654 | - } ?>" placeholder="<?php esc_html_e( 'Address line 1', 'give' ); ?>" value="<?php echo $line1; ?>"<?php if ( give_field_is_required( 'card_address', $form_id ) ) { |
|
654 | + } ?>" placeholder="<?php esc_html_e('Address line 1', 'give'); ?>" value="<?php echo $line1; ?>"<?php if (give_field_is_required('card_address', $form_id)) { |
|
655 | 655 | echo ' required '; |
656 | 656 | } ?>/> |
657 | 657 | </p> |
658 | 658 | |
659 | 659 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
660 | 660 | <label for="card_address_2" class="give-label"> |
661 | - <?php esc_html_e( 'Address Line 2', 'give' ); ?> |
|
662 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { ?> |
|
661 | + <?php esc_html_e('Address Line 2', 'give'); ?> |
|
662 | + <?php if (give_field_is_required('card_address_2', $form_id)) { ?> |
|
663 | 663 | <span class="give-required-indicator">*</span> |
664 | 664 | <?php } ?> |
665 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
665 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
666 | 666 | </label> |
667 | 667 | |
668 | - <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 ) ) { |
|
668 | + <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 | 669 | echo ' required'; |
670 | - } ?>" placeholder="<?php esc_html_e( 'Address line 2', 'give' ); ?>" value="<?php echo $line2; ?>"<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) { |
|
670 | + } ?>" placeholder="<?php esc_html_e('Address line 2', 'give'); ?>" value="<?php echo $line2; ?>"<?php if (give_field_is_required('card_address_2', $form_id)) { |
|
671 | 671 | echo ' required '; |
672 | 672 | } ?>/> |
673 | 673 | </p> |
674 | 674 | |
675 | 675 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
676 | 676 | <label for="card_city" class="give-label"> |
677 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
678 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) { ?> |
|
677 | + <?php esc_html_e('City', 'give'); ?> |
|
678 | + <?php if (give_field_is_required('card_city', $form_id)) { ?> |
|
679 | 679 | <span class="give-required-indicator">*</span> |
680 | 680 | <?php } ?> |
681 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
681 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The city for your billing address.', 'give'); ?>"></span> |
|
682 | 682 | </label> |
683 | - <input type="text" id="card_city" name="card_city" class="card-city give-input<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
683 | + <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 | 684 | echo ' required'; |
685 | - } ?>" placeholder="<?php esc_html_e( 'City', 'give' ); ?>" value="<?php echo $city; ?>"<?php if ( give_field_is_required( 'card_city', $form_id ) ) { |
|
685 | + } ?>" placeholder="<?php esc_html_e('City', 'give'); ?>" value="<?php echo $city; ?>"<?php if (give_field_is_required('card_city', $form_id)) { |
|
686 | 686 | echo ' required '; |
687 | 687 | } ?>/> |
688 | 688 | </p> |
689 | 689 | |
690 | 690 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
691 | 691 | <label for="card_zip" class="give-label"> |
692 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
693 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { ?> |
|
692 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
693 | + <?php if (give_field_is_required('card_zip', $form_id)) { ?> |
|
694 | 694 | <span class="give-required-indicator">*</span> |
695 | 695 | <?php } ?> |
696 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
696 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
697 | 697 | </label> |
698 | 698 | |
699 | - <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 ) ) { |
|
699 | + <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 | 700 | echo ' required'; |
701 | - } ?>" placeholder="<?php esc_html_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $zip; ?>" <?php if ( give_field_is_required( 'card_zip', $form_id ) ) { |
|
701 | + } ?>" placeholder="<?php esc_html_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $zip; ?>" <?php if (give_field_is_required('card_zip', $form_id)) { |
|
702 | 702 | echo ' required '; |
703 | 703 | } ?>/> |
704 | 704 | </p> |
705 | 705 | |
706 | 706 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
707 | 707 | <label for="billing_country" class="give-label"> |
708 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
709 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) { ?> |
|
708 | + <?php esc_html_e('Country', 'give'); ?> |
|
709 | + <?php if (give_field_is_required('billing_country', $form_id)) { ?> |
|
710 | 710 | <span class="give-required-indicator">*</span> |
711 | 711 | <?php } ?> |
712 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
712 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The country for your billing address.', 'give'); ?>"></span> |
|
713 | 713 | </label> |
714 | 714 | |
715 | - <select name="billing_country" id="billing_country" class="billing-country billing_country give-select<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
715 | + <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 | 716 | echo ' required'; |
717 | - } ?>"<?php if ( give_field_is_required( 'billing_country', $form_id ) ) { |
|
717 | + } ?>"<?php if (give_field_is_required('billing_country', $form_id)) { |
|
718 | 718 | echo ' required '; |
719 | 719 | } ?>> |
720 | 720 | <?php |
721 | 721 | |
722 | 722 | $selected_country = give_get_country(); |
723 | 723 | |
724 | - if ( $logged_in && ! empty( $user_address['country'] ) && '*' !== $user_address['country'] ) { |
|
724 | + if ($logged_in && ! empty($user_address['country']) && '*' !== $user_address['country']) { |
|
725 | 725 | $selected_country = $user_address['country']; |
726 | 726 | } |
727 | 727 | |
728 | 728 | $countries = give_get_country_list(); |
729 | - foreach ( $countries as $country_code => $country ) { |
|
730 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
729 | + foreach ($countries as $country_code => $country) { |
|
730 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
731 | 731 | } |
732 | 732 | ?> |
733 | 733 | </select> |
@@ -735,44 +735,44 @@ discard block |
||
735 | 735 | |
736 | 736 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
737 | 737 | <label for="card_state" class="give-label"> |
738 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
739 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) { ?> |
|
738 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
739 | + <?php if (give_field_is_required('card_state', $form_id)) { ?> |
|
740 | 740 | <span class="give-required-indicator">*</span> |
741 | 741 | <?php } ?> |
742 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
742 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
743 | 743 | </label> |
744 | 744 | |
745 | 745 | <?php |
746 | 746 | $selected_state = give_get_state(); |
747 | - $states = give_get_states( $selected_country ); |
|
747 | + $states = give_get_states($selected_country); |
|
748 | 748 | |
749 | - if ( $logged_in && ! empty( $user_address['state'] ) ) { |
|
749 | + if ($logged_in && ! empty($user_address['state'])) { |
|
750 | 750 | $selected_state = $user_address['state']; |
751 | 751 | } |
752 | 752 | |
753 | - if ( ! empty( $states ) ) : ?> |
|
754 | - <select name="card_state" id="card_state" class="card_state give-select<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
753 | + if ( ! empty($states)) : ?> |
|
754 | + <select name="card_state" id="card_state" class="card_state give-select<?php if (give_field_is_required('card_state', $form_id)) { |
|
755 | 755 | echo ' required'; |
756 | - } ?>"<?php if ( give_field_is_required( 'card_state', $form_id ) ) { |
|
756 | + } ?>"<?php if (give_field_is_required('card_state', $form_id)) { |
|
757 | 757 | echo ' required '; |
758 | 758 | } ?>> |
759 | 759 | <?php |
760 | - foreach ( $states as $state_code => $state ) { |
|
761 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
760 | + foreach ($states as $state_code => $state) { |
|
761 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
762 | 762 | } |
763 | 763 | ?> |
764 | 764 | </select> |
765 | 765 | <?php else : ?> |
766 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_html_e( 'State / Province', 'give' ); ?>"/> |
|
766 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_html_e('State / Province', 'give'); ?>"/> |
|
767 | 767 | <?php endif; ?> |
768 | 768 | </p> |
769 | - <?php do_action( 'give_cc_billing_bottom' ); ?> |
|
769 | + <?php do_action('give_cc_billing_bottom'); ?> |
|
770 | 770 | </fieldset> |
771 | 771 | <?php |
772 | 772 | echo ob_get_clean(); |
773 | 773 | } |
774 | 774 | |
775 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
775 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
776 | 776 | |
777 | 777 | |
778 | 778 | /** |
@@ -784,93 +784,93 @@ discard block |
||
784 | 784 | * |
785 | 785 | * @return string |
786 | 786 | */ |
787 | -function give_get_register_fields( $form_id ) { |
|
787 | +function give_get_register_fields($form_id) { |
|
788 | 788 | |
789 | 789 | global $user_ID; |
790 | 790 | |
791 | - if ( is_user_logged_in() ) { |
|
792 | - $user_data = get_userdata( $user_ID ); |
|
791 | + if (is_user_logged_in()) { |
|
792 | + $user_data = get_userdata($user_ID); |
|
793 | 793 | } |
794 | 794 | |
795 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
795 | + $show_register_form = give_show_login_register_option($form_id); |
|
796 | 796 | |
797 | 797 | ob_start(); ?> |
798 | 798 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
799 | 799 | |
800 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
800 | + <?php if ($show_register_form == 'both') { ?> |
|
801 | 801 | <div class="give-login-account-wrap"> |
802 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
803 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
802 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
803 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
804 | 804 | </p> |
805 | 805 | <p class="give-loading-text"> |
806 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></p> |
|
806 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></p> |
|
807 | 807 | </div> |
808 | 808 | <?php } ?> |
809 | 809 | |
810 | - <?php do_action( 'give_register_fields_before', $form_id ); ?> |
|
810 | + <?php do_action('give_register_fields_before', $form_id); ?> |
|
811 | 811 | |
812 | 812 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
813 | - <legend><?php echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
814 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
815 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
813 | + <legend><?php echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
814 | + if ( ! give_logged_in_only($form_id)) { |
|
815 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
816 | 816 | } ?></legend> |
817 | - <?php do_action( 'give_register_account_fields_before', $form_id ); ?> |
|
817 | + <?php do_action('give_register_account_fields_before', $form_id); ?> |
|
818 | 818 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
819 | 819 | <label for="give-user-login-<?php echo $form_id; ?>"> |
820 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
821 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
820 | + <?php esc_html_e('Username', 'give'); ?> |
|
821 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
822 | 822 | <span class="give-required-indicator">*</span> |
823 | 823 | <?php } ?> |
824 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
824 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
825 | 825 | </label> |
826 | 826 | |
827 | - <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
827 | + <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
828 | 828 | echo 'required '; |
829 | - } ?>give-input" type="text" placeholder="<?php esc_html_e( 'Username', 'give' ); ?>" title="<?php esc_html_e( 'Username', 'give' ); ?>"/> |
|
829 | + } ?>give-input" type="text" placeholder="<?php esc_html_e('Username', 'give'); ?>" title="<?php esc_html_e('Username', 'give'); ?>"/> |
|
830 | 830 | </div> |
831 | 831 | |
832 | 832 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
833 | 833 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
834 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
835 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
834 | + <?php esc_html_e('Password', 'give'); ?> |
|
835 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
836 | 836 | <span class="give-required-indicator">*</span> |
837 | 837 | <?php } ?> |
838 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
838 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('The password used to access your account.', 'give'); ?>"></span> |
|
839 | 839 | </label> |
840 | 840 | |
841 | - <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
841 | + <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if (give_logged_in_only($form_id)) { |
|
842 | 842 | echo 'required '; |
843 | - } ?>give-input" placeholder="<?php esc_html_e( 'Password', 'give' ); ?>" type="password"/> |
|
843 | + } ?>give-input" placeholder="<?php esc_html_e('Password', 'give'); ?>" type="password"/> |
|
844 | 844 | </div> |
845 | 845 | |
846 | 846 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third"> |
847 | 847 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
848 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
849 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
848 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
849 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
850 | 850 | <span class="give-required-indicator">*</span> |
851 | 851 | <?php } ?> |
852 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
852 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_html_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
853 | 853 | </label> |
854 | 854 | |
855 | - <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
855 | + <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 | 856 | echo 'required '; |
857 | - } ?>give-input" placeholder="<?php esc_html_e( 'Confirm password', 'give' ); ?>" type="password"/> |
|
857 | + } ?>give-input" placeholder="<?php esc_html_e('Confirm password', 'give'); ?>" type="password"/> |
|
858 | 858 | </div> |
859 | - <?php do_action( 'give_register_account_fields_after', $form_id ); ?> |
|
859 | + <?php do_action('give_register_account_fields_after', $form_id); ?> |
|
860 | 860 | </fieldset> |
861 | 861 | |
862 | - <?php do_action( 'give_register_fields_after', $form_id ); ?> |
|
862 | + <?php do_action('give_register_fields_after', $form_id); ?> |
|
863 | 863 | |
864 | 864 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
865 | 865 | |
866 | - <?php do_action( 'give_purchase_form_user_info', $form_id ); ?> |
|
866 | + <?php do_action('give_purchase_form_user_info', $form_id); ?> |
|
867 | 867 | |
868 | 868 | </fieldset> |
869 | 869 | <?php |
870 | 870 | echo ob_get_clean(); |
871 | 871 | } |
872 | 872 | |
873 | -add_action( 'give_purchase_form_register_fields', 'give_get_register_fields' ); |
|
873 | +add_action('give_purchase_form_register_fields', 'give_get_register_fields'); |
|
874 | 874 | |
875 | 875 | /** |
876 | 876 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -883,79 +883,79 @@ discard block |
||
883 | 883 | * |
884 | 884 | * @return string |
885 | 885 | */ |
886 | -function give_get_login_fields( $form_id ) { |
|
886 | +function give_get_login_fields($form_id) { |
|
887 | 887 | |
888 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
889 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
888 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
889 | + $show_register_form = give_show_login_register_option($form_id); |
|
890 | 890 | |
891 | 891 | ob_start(); |
892 | 892 | ?> |
893 | 893 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
894 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
895 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
896 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
894 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
895 | + if ( ! give_logged_in_only($form_id)) { |
|
896 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
897 | 897 | } ?> |
898 | 898 | </legend> |
899 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
899 | + <?php if ($show_register_form == 'both') { ?> |
|
900 | 900 | <p class="give-new-account-link"> |
901 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
902 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
903 | - <?php esc_html_e( 'Register', 'give' ); |
|
904 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
905 | - echo ' ' . esc_html__( 'or checkout as a guest »', 'give' ); |
|
901 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
902 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
903 | + <?php esc_html_e('Register', 'give'); |
|
904 | + if ( ! give_logged_in_only($form_id)) { |
|
905 | + echo ' '.esc_html__('or checkout as a guest »', 'give'); |
|
906 | 906 | } ?> |
907 | 907 | </a> |
908 | 908 | </p> |
909 | 909 | <p class="give-loading-text"> |
910 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?> </p> |
|
910 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?> </p> |
|
911 | 911 | <?php } ?> |
912 | - <?php do_action( 'give_checkout_login_fields_before', $form_id ); ?> |
|
912 | + <?php do_action('give_checkout_login_fields_before', $form_id); ?> |
|
913 | 913 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
914 | 914 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
915 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
916 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
915 | + <?php esc_html_e('Username', 'give'); ?> |
|
916 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
917 | 917 | <span class="give-required-indicator">*</span> |
918 | 918 | <?php } ?> |
919 | 919 | </label> |
920 | 920 | |
921 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
921 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
922 | 922 | echo 'required '; |
923 | - } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_html_e( 'Your username', 'give' ); ?>"/> |
|
923 | + } ?>give-input" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_html_e('Your username', 'give'); ?>"/> |
|
924 | 924 | </div> |
925 | 925 | |
926 | 926 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
927 | 927 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
928 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
929 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
928 | + <?php esc_html_e('Password', 'give'); ?> |
|
929 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
930 | 930 | <span class="give-required-indicator">*</span> |
931 | 931 | <?php } ?> |
932 | 932 | </label> |
933 | - <input class="<?php if ( give_logged_in_only( $form_id ) ) { |
|
933 | + <input class="<?php if (give_logged_in_only($form_id)) { |
|
934 | 934 | echo 'required '; |
935 | - } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_html_e( 'Your password', 'give' ); ?>"/> |
|
935 | + } ?>give-input" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_html_e('Your password', 'give'); ?>"/> |
|
936 | 936 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
937 | 937 | </div> |
938 | 938 | |
939 | 939 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
940 | 940 | <span class="give-forgot-password "> |
941 | - <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e( 'Reset password?' ) ?></a> |
|
941 | + <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e('Reset password?') ?></a> |
|
942 | 942 | </span> |
943 | 943 | </div> |
944 | 944 | |
945 | 945 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
946 | - <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_html_e( 'Login', 'give' ); ?>"/> |
|
947 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
948 | - <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 esc_html_e( 'Cancel', 'give' ); ?>"/> |
|
946 | + <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_html_e('Login', 'give'); ?>"/> |
|
947 | + <?php if ($show_register_form !== 'login') { ?> |
|
948 | + <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 esc_html_e('Cancel', 'give'); ?>"/> |
|
949 | 949 | <?php } ?> |
950 | 950 | <span class="give-loading-animation"></span> |
951 | 951 | </div> |
952 | - <?php do_action( 'give_checkout_login_fields_after', $form_id ); ?> |
|
952 | + <?php do_action('give_checkout_login_fields_after', $form_id); ?> |
|
953 | 953 | </fieldset><!--end #give-login-fields--> |
954 | 954 | <?php |
955 | 955 | echo ob_get_clean(); |
956 | 956 | } |
957 | 957 | |
958 | -add_action( 'give_purchase_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
958 | +add_action('give_purchase_form_login_fields', 'give_get_login_fields', 10, 1); |
|
959 | 959 | |
960 | 960 | /** |
961 | 961 | * Payment Mode Select |
@@ -971,49 +971,49 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @return void |
973 | 973 | */ |
974 | -function give_payment_mode_select( $form_id ) { |
|
974 | +function give_payment_mode_select($form_id) { |
|
975 | 975 | |
976 | 976 | $gateways = give_get_enabled_payment_gateways(); |
977 | 977 | |
978 | - do_action( 'give_payment_mode_top', $form_id ); ?> |
|
978 | + do_action('give_payment_mode_top', $form_id); ?> |
|
979 | 979 | |
980 | 980 | <fieldset id="give-payment-mode-select"> |
981 | - <?php do_action( 'give_payment_mode_before_gateways_wrap' ); ?> |
|
981 | + <?php do_action('give_payment_mode_before_gateways_wrap'); ?> |
|
982 | 982 | <div id="give-payment-mode-wrap"> |
983 | - <legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
984 | - <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></span> |
|
983 | + <legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
984 | + <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></span> |
|
985 | 985 | </legend> |
986 | 986 | <?php |
987 | 987 | |
988 | - do_action( 'give_payment_mode_before_gateways' ) ?> |
|
988 | + do_action('give_payment_mode_before_gateways') ?> |
|
989 | 989 | |
990 | 990 | <ul id="give-gateway-radio-list"> |
991 | - <?php foreach ( $gateways as $gateway_id => $gateway ) : |
|
992 | - $checked = checked( $gateway_id, give_get_default_gateway( $form_id ), false ); |
|
991 | + <?php foreach ($gateways as $gateway_id => $gateway) : |
|
992 | + $checked = checked($gateway_id, give_get_default_gateway($form_id), false); |
|
993 | 993 | $checked_class = $checked ? ' give-gateway-option-selected' : ''; |
994 | - 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 ) . '">'; |
|
995 | - 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'] ); |
|
994 | + 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).'">'; |
|
995 | + 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']); |
|
996 | 996 | echo '</label></li>'; |
997 | 997 | endforeach; ?> |
998 | 998 | </ul> |
999 | - <?php do_action( 'give_payment_mode_after_gateways' ); ?> |
|
999 | + <?php do_action('give_payment_mode_after_gateways'); ?> |
|
1000 | 1000 | </div> |
1001 | - <?php do_action( 'give_payment_mode_after_gateways_wrap' ); ?> |
|
1001 | + <?php do_action('give_payment_mode_after_gateways_wrap'); ?> |
|
1002 | 1002 | </fieldset> |
1003 | 1003 | |
1004 | - <?php do_action( 'give_payment_mode_bottom', $form_id ); ?> |
|
1004 | + <?php do_action('give_payment_mode_bottom', $form_id); ?> |
|
1005 | 1005 | |
1006 | 1006 | <div id="give_purchase_form_wrap"> |
1007 | 1007 | |
1008 | - <?php do_action( 'give_purchase_form', $form_id ); ?> |
|
1008 | + <?php do_action('give_purchase_form', $form_id); ?> |
|
1009 | 1009 | |
1010 | 1010 | </div><!-- the checkout fields are loaded into this--> |
1011 | 1011 | |
1012 | - <?php do_action( 'give_purchase_form_wrap_bottom', $form_id ); |
|
1012 | + <?php do_action('give_purchase_form_wrap_bottom', $form_id); |
|
1013 | 1013 | |
1014 | 1014 | } |
1015 | 1015 | |
1016 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1016 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | /** |
@@ -1027,36 +1027,36 @@ discard block |
||
1027 | 1027 | * |
1028 | 1028 | * @return void |
1029 | 1029 | */ |
1030 | -function give_terms_agreement( $form_id ) { |
|
1030 | +function give_terms_agreement($form_id) { |
|
1031 | 1031 | |
1032 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1033 | - $label = get_post_meta( $form_id, '_give_agree_label', true ); |
|
1034 | - $terms = get_post_meta( $form_id, '_give_agree_text', true ); |
|
1032 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1033 | + $label = get_post_meta($form_id, '_give_agree_label', true); |
|
1034 | + $terms = get_post_meta($form_id, '_give_agree_text', true); |
|
1035 | 1035 | |
1036 | - if ( $form_option === 'yes' && ! empty( $terms ) ) { ?> |
|
1036 | + if ($form_option === 'yes' && ! empty($terms)) { ?> |
|
1037 | 1037 | <fieldset id="give_terms_agreement"> |
1038 | - <div id="give_terms" class= "give_terms-<?php echo $form_id;?>" style="display:none;"> |
|
1038 | + <div id="give_terms" class= "give_terms-<?php echo $form_id; ?>" style="display:none;"> |
|
1039 | 1039 | <?php |
1040 | - do_action( 'give_before_terms' ); |
|
1041 | - echo wpautop( stripslashes( $terms ) ); |
|
1042 | - do_action( 'give_after_terms' ); |
|
1040 | + do_action('give_before_terms'); |
|
1041 | + echo wpautop(stripslashes($terms)); |
|
1042 | + do_action('give_after_terms'); |
|
1043 | 1043 | ?> |
1044 | 1044 | </div> |
1045 | 1045 | <div id="give_show_terms"> |
1046 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id;?>"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1047 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id;?>" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1046 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1047 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1048 | 1048 | </div> |
1049 | 1049 | |
1050 | 1050 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/> |
1051 | 1051 | <label |
1052 | - for="give_agree_to_terms"><?php echo ! empty( $label ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); ?></label> |
|
1052 | + for="give_agree_to_terms"><?php echo ! empty($label) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); ?></label> |
|
1053 | 1053 | |
1054 | 1054 | </fieldset> |
1055 | 1055 | <?php |
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | |
1059 | -add_action( 'give_purchase_form_before_submit', 'give_terms_agreement', 10, 1 ); |
|
1059 | +add_action('give_purchase_form_before_submit', 'give_terms_agreement', 10, 1); |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Checkout Final Total |
@@ -1069,27 +1069,27 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return void |
1071 | 1071 | */ |
1072 | -function give_checkout_final_total( $form_id ) { |
|
1072 | +function give_checkout_final_total($form_id) { |
|
1073 | 1073 | |
1074 | - if ( isset( $_POST['give_total'] ) ) { |
|
1075 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
1074 | + if (isset($_POST['give_total'])) { |
|
1075 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
1076 | 1076 | } else { |
1077 | 1077 | //default total |
1078 | - $total = give_get_default_form_amount( $form_id ); |
|
1078 | + $total = give_get_default_form_amount($form_id); |
|
1079 | 1079 | } |
1080 | 1080 | //Only proceed if give_total available |
1081 | - if ( empty( $total ) ) { |
|
1081 | + if (empty($total)) { |
|
1082 | 1082 | return; |
1083 | 1083 | } |
1084 | 1084 | ?> |
1085 | 1085 | <p id="give-final-total-wrap" class="form-wrap "> |
1086 | - <span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
1087 | - <span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
1086 | + <span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
1087 | + <span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
1088 | 1088 | </p> |
1089 | 1089 | <?php |
1090 | 1090 | } |
1091 | 1091 | |
1092 | -add_action( 'give_purchase_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1092 | +add_action('give_purchase_form_before_submit', 'give_checkout_final_total', 999); |
|
1093 | 1093 | |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1101,22 +1101,22 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * @return void |
1103 | 1103 | */ |
1104 | -function give_checkout_submit( $form_id ) { |
|
1104 | +function give_checkout_submit($form_id) { |
|
1105 | 1105 | ?> |
1106 | 1106 | <fieldset id="give_purchase_submit"> |
1107 | - <?php do_action( 'give_purchase_form_before_submit', $form_id ); ?> |
|
1107 | + <?php do_action('give_purchase_form_before_submit', $form_id); ?> |
|
1108 | 1108 | |
1109 | - <?php give_checkout_hidden_fields( $form_id ); ?> |
|
1109 | + <?php give_checkout_hidden_fields($form_id); ?> |
|
1110 | 1110 | |
1111 | - <?php echo give_checkout_button_purchase( $form_id ); ?> |
|
1111 | + <?php echo give_checkout_button_purchase($form_id); ?> |
|
1112 | 1112 | |
1113 | - <?php do_action( 'give_purchase_form_after_submit', $form_id ); ?> |
|
1113 | + <?php do_action('give_purchase_form_after_submit', $form_id); ?> |
|
1114 | 1114 | |
1115 | 1115 | </fieldset> |
1116 | 1116 | <?php |
1117 | 1117 | } |
1118 | 1118 | |
1119 | -add_action( 'give_purchase_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1119 | +add_action('give_purchase_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1120 | 1120 | |
1121 | 1121 | |
1122 | 1122 | /** |
@@ -1129,17 +1129,17 @@ discard block |
||
1129 | 1129 | * |
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | -function give_checkout_button_purchase( $form_id ) { |
|
1132 | +function give_checkout_button_purchase($form_id) { |
|
1133 | 1133 | |
1134 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
1135 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1134 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
1135 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1136 | 1136 | ob_start(); ?> |
1137 | 1137 | <div class="give-submit-button-wrap give-clearfix"> |
1138 | 1138 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" value="<?php echo $display_label; ?>"/> |
1139 | 1139 | <span class="give-loading-animation"></span> |
1140 | 1140 | </div> |
1141 | 1141 | <?php |
1142 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
1142 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | /** |
@@ -1152,18 +1152,18 @@ discard block |
||
1152 | 1152 | * |
1153 | 1153 | * @return void |
1154 | 1154 | */ |
1155 | -function give_agree_to_terms_js( $form_id ) { |
|
1155 | +function give_agree_to_terms_js($form_id) { |
|
1156 | 1156 | |
1157 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
1157 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
1158 | 1158 | |
1159 | - if ( $form_option === 'yes' ) { |
|
1159 | + if ($form_option === 'yes') { |
|
1160 | 1160 | ?> |
1161 | 1161 | <script type="text/javascript"> |
1162 | 1162 | jQuery(document).ready(function ($) { |
1163 | - $('body').on('click', '.give_terms_links-<?php echo $form_id;?>', function (e) { |
|
1163 | + $('body').on('click', '.give_terms_links-<?php echo $form_id; ?>', function (e) { |
|
1164 | 1164 | e.preventDefault(); |
1165 | - $('.give_terms-<?php echo $form_id;?>').slideToggle(); |
|
1166 | - $('.give_terms_links-<?php echo $form_id;?>').toggle(); |
|
1165 | + $('.give_terms-<?php echo $form_id; ?>').slideToggle(); |
|
1166 | + $('.give_terms_links-<?php echo $form_id; ?>').toggle(); |
|
1167 | 1167 | return false; |
1168 | 1168 | }); |
1169 | 1169 | }); |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | } |
1173 | 1173 | } |
1174 | 1174 | |
1175 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
1175 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
1176 | 1176 | |
1177 | 1177 | /** |
1178 | 1178 | * Show Give Goals |
@@ -1187,17 +1187,17 @@ discard block |
||
1187 | 1187 | * @return mixed |
1188 | 1188 | */ |
1189 | 1189 | |
1190 | -function give_show_goal_progress( $form_id, $args ) { |
|
1190 | +function give_show_goal_progress($form_id, $args) { |
|
1191 | 1191 | |
1192 | 1192 | ob_start(); |
1193 | - give_get_template( 'shortcode-goal' , array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1193 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1194 | 1194 | |
1195 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1195 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
1196 | 1196 | |
1197 | 1197 | return true; |
1198 | 1198 | } |
1199 | 1199 | |
1200 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1200 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1201 | 1201 | |
1202 | 1202 | /** |
1203 | 1203 | * Adds Actions to Render Form Content |
@@ -1209,19 +1209,19 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return void |
1211 | 1211 | */ |
1212 | -function give_form_content( $form_id, $args ) { |
|
1212 | +function give_form_content($form_id, $args) { |
|
1213 | 1213 | |
1214 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
1214 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
1215 | 1215 | ? $args['show_content'] |
1216 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
1216 | + : get_post_meta($form_id, '_give_content_option', true); |
|
1217 | 1217 | |
1218 | - if ( $show_content !== 'none' ) { |
|
1218 | + if ($show_content !== 'none') { |
|
1219 | 1219 | //add action according to value |
1220 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1220 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1221 | 1221 | } |
1222 | 1222 | } |
1223 | 1223 | |
1224 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1224 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1225 | 1225 | |
1226 | 1226 | /** |
1227 | 1227 | * Renders Post Form Content |
@@ -1233,24 +1233,24 @@ discard block |
||
1233 | 1233 | * @return void |
1234 | 1234 | * @since 1.0 |
1235 | 1235 | */ |
1236 | -function give_form_display_content( $form_id, $args ) { |
|
1236 | +function give_form_display_content($form_id, $args) { |
|
1237 | 1237 | |
1238 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
1239 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
1238 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
1239 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
1240 | 1240 | ? $args['show_content'] |
1241 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
1241 | + : get_post_meta($form_id, '_give_content_option', true); |
|
1242 | 1242 | |
1243 | - if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) { |
|
1244 | - $content = apply_filters( 'the_content', $content ); |
|
1243 | + if (give_get_option('disable_the_content_filter') !== 'on') { |
|
1244 | + $content = apply_filters('the_content', $content); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
1247 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
1248 | 1248 | |
1249 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1249 | + echo apply_filters('give_form_content_output', $output); |
|
1250 | 1250 | |
1251 | 1251 | //remove action to prevent content output on addition forms on page |
1252 | 1252 | //@see: https://github.com/WordImpress/Give/issues/634 |
1253 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1253 | + remove_action($show_content, 'give_form_display_content'); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | |
@@ -1263,16 +1263,16 @@ discard block |
||
1263 | 1263 | * |
1264 | 1264 | * @return void |
1265 | 1265 | */ |
1266 | -function give_checkout_hidden_fields( $form_id ) { |
|
1266 | +function give_checkout_hidden_fields($form_id) { |
|
1267 | 1267 | |
1268 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1269 | - if ( is_user_logged_in() ) { ?> |
|
1268 | + do_action('give_hidden_fields_before', $form_id); |
|
1269 | + if (is_user_logged_in()) { ?> |
|
1270 | 1270 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1271 | 1271 | <?php } ?> |
1272 | 1272 | <input type="hidden" name="give_action" value="purchase"/> |
1273 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1273 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1274 | 1274 | <?php |
1275 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1275 | + do_action('give_hidden_fields_after', $form_id); |
|
1276 | 1276 | |
1277 | 1277 | } |
1278 | 1278 | |
@@ -1287,20 +1287,20 @@ discard block |
||
1287 | 1287 | * |
1288 | 1288 | * @return string $content Filtered content |
1289 | 1289 | */ |
1290 | -function give_filter_success_page_content( $content ) { |
|
1290 | +function give_filter_success_page_content($content) { |
|
1291 | 1291 | |
1292 | 1292 | global $give_options; |
1293 | 1293 | |
1294 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1295 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1296 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1294 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1295 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1296 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1297 | 1297 | } |
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | return $content; |
1301 | 1301 | } |
1302 | 1302 | |
1303 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1303 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1312,14 +1312,14 @@ discard block |
||
1312 | 1312 | |
1313 | 1313 | function give_test_mode_frontend_warning() { |
1314 | 1314 | |
1315 | - $test_mode = give_get_option( 'test_mode' ); |
|
1315 | + $test_mode = give_get_option('test_mode'); |
|
1316 | 1316 | |
1317 | - if ( $test_mode == 'on' ) { |
|
1318 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice', 'give' ) . '</strong>: ' . esc_html__( 'Test mode is enabled. While in test mode no live transactions are processed.', 'give' ) . '</p></div>'; |
|
1317 | + if ($test_mode == 'on') { |
|
1318 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice', 'give').'</strong>: '.esc_html__('Test mode is enabled. While in test mode no live transactions are processed.', 'give').'</p></div>'; |
|
1319 | 1319 | } |
1320 | 1320 | } |
1321 | 1321 | |
1322 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1322 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1323 | 1323 | |
1324 | 1324 | |
1325 | 1325 | /** |
@@ -1335,21 +1335,21 @@ discard block |
||
1335 | 1335 | * @return string |
1336 | 1336 | */ |
1337 | 1337 | |
1338 | -function give_members_only_form( $final_output, $args ) { |
|
1338 | +function give_members_only_form($final_output, $args) { |
|
1339 | 1339 | |
1340 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1340 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1341 | 1341 | |
1342 | 1342 | //Sanity Check: Must have form_id & not be logged in |
1343 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1343 | + if (empty($form_id) || is_user_logged_in()) { |
|
1344 | 1344 | return $final_output; |
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | //Logged in only and Register / Login set to none |
1348 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1348 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1349 | 1349 | |
1350 | - $final_output = give_output_error( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1350 | + $final_output = give_output_error(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1351 | 1351 | |
1352 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1352 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1353 | 1353 | |
1354 | 1354 | } |
1355 | 1355 | |
@@ -1357,4 +1357,4 @@ discard block |
||
1357 | 1357 | |
1358 | 1358 | } |
1359 | 1359 | |
1360 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1360 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |