@@ -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 | |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page; |
30 | 30 | |
31 | 31 | //Payments |
32 | - $give_payment = get_post_type_object( 'give_payment' ); |
|
33 | - $give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' ); |
|
32 | + $give_payment = get_post_type_object('give_payment'); |
|
33 | + $give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page'); |
|
34 | 34 | |
35 | 35 | //Donors |
36 | - $give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' ); |
|
36 | + $give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page'); |
|
37 | 37 | |
38 | 38 | //Reports` |
39 | - $give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donation Reports', 'give' ), esc_html__( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' ); |
|
39 | + $give_reports_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donation Reports', 'give'), esc_html__('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page'); |
|
40 | 40 | |
41 | 41 | //Settings |
42 | - $give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Settings', 'give' ), esc_html__( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array( |
|
42 | + $give_settings_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Settings', 'give'), esc_html__('Settings', 'give'), 'manage_give_settings', 'give-settings', array( |
|
43 | 43 | Give()->give_settings, |
44 | 44 | 'admin_page_display' |
45 | - ) ); |
|
45 | + )); |
|
46 | 46 | |
47 | 47 | //Add-ons |
48 | - $give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' ); |
|
48 | + $give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page'); |
|
49 | 49 | |
50 | 50 | //Upgrades |
51 | - $give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' ); |
|
51 | + $give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen'); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | } |
55 | 55 | |
56 | -add_action( 'admin_menu', 'give_add_options_links', 10 ); |
|
56 | +add_action('admin_menu', 'give_add_options_links', 10); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Determines whether the current admin page is a Give admin page. |
@@ -68,224 +68,224 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return bool True if Give admin page. |
70 | 70 | */ |
71 | -function give_is_admin_page( $passed_page = '', $passed_view = '' ) { |
|
71 | +function give_is_admin_page($passed_page = '', $passed_view = '') { |
|
72 | 72 | |
73 | 73 | global $pagenow, $typenow; |
74 | 74 | |
75 | 75 | $found = false; |
76 | - $post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false; |
|
77 | - $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false; |
|
78 | - $taxonomy = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false; |
|
79 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
80 | - $view = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false; |
|
81 | - $tab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false; |
|
76 | + $post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false; |
|
77 | + $action = isset($_GET['action']) ? strtolower($_GET['action']) : false; |
|
78 | + $taxonomy = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false; |
|
79 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
80 | + $view = isset($_GET['view']) ? strtolower($_GET['view']) : false; |
|
81 | + $tab = isset($_GET['tab']) ? strtolower($_GET['tab']) : false; |
|
82 | 82 | |
83 | - switch ( $passed_page ) { |
|
83 | + switch ($passed_page) { |
|
84 | 84 | case 'give_forms': |
85 | - switch ( $passed_view ) { |
|
85 | + switch ($passed_view) { |
|
86 | 86 | case 'list-table': |
87 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) { |
|
87 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') { |
|
88 | 88 | $found = true; |
89 | 89 | } |
90 | 90 | break; |
91 | 91 | case 'edit': |
92 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) { |
|
92 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') { |
|
93 | 93 | $found = true; |
94 | 94 | } |
95 | 95 | break; |
96 | 96 | case 'new': |
97 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) { |
|
97 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') { |
|
98 | 98 | $found = true; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | default: |
102 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) { |
|
102 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) { |
|
103 | 103 | $found = true; |
104 | 104 | } |
105 | 105 | break; |
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case 'categories': |
109 | - switch ( $passed_view ) { |
|
109 | + switch ($passed_view) { |
|
110 | 110 | case 'list-table': |
111 | 111 | case 'new': |
112 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) { |
|
112 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) { |
|
113 | 113 | $found = true; |
114 | 114 | } |
115 | 115 | break; |
116 | 116 | case 'edit': |
117 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) { |
|
117 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) { |
|
118 | 118 | $found = true; |
119 | 119 | } |
120 | 120 | break; |
121 | 121 | default: |
122 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) { |
|
122 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) { |
|
123 | 123 | $found = true; |
124 | 124 | } |
125 | 125 | break; |
126 | 126 | } |
127 | 127 | break; |
128 | 128 | case 'tags': |
129 | - switch ( $passed_view ) { |
|
129 | + switch ($passed_view) { |
|
130 | 130 | case 'list-table': |
131 | 131 | case 'new': |
132 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) { |
|
132 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) { |
|
133 | 133 | $found = true; |
134 | 134 | } |
135 | 135 | break; |
136 | 136 | case 'edit': |
137 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) { |
|
137 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) { |
|
138 | 138 | $found = true; |
139 | 139 | } |
140 | 140 | break; |
141 | 141 | default: |
142 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) { |
|
142 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) { |
|
143 | 143 | $found = true; |
144 | 144 | } |
145 | 145 | break; |
146 | 146 | } |
147 | 147 | break; |
148 | 148 | case 'payments': |
149 | - switch ( $passed_view ) { |
|
149 | + switch ($passed_view) { |
|
150 | 150 | case 'list-table': |
151 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) { |
|
151 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) { |
|
152 | 152 | $found = true; |
153 | 153 | } |
154 | 154 | break; |
155 | 155 | case 'edit': |
156 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) { |
|
156 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) { |
|
157 | 157 | $found = true; |
158 | 158 | } |
159 | 159 | break; |
160 | 160 | default: |
161 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) { |
|
161 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) { |
|
162 | 162 | $found = true; |
163 | 163 | } |
164 | 164 | break; |
165 | 165 | } |
166 | 166 | break; |
167 | 167 | case 'reports': |
168 | - switch ( $passed_view ) { |
|
168 | + switch ($passed_view) { |
|
169 | 169 | // If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ] |
170 | 170 | case 'earnings': |
171 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) { |
|
171 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) { |
|
172 | 172 | $found = true; |
173 | 173 | } |
174 | 174 | break; |
175 | 175 | case 'donors': |
176 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) { |
|
176 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) { |
|
177 | 177 | $found = true; |
178 | 178 | } |
179 | 179 | break; |
180 | 180 | case 'gateways': |
181 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) { |
|
181 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) { |
|
182 | 182 | $found = true; |
183 | 183 | } |
184 | 184 | break; |
185 | 185 | case 'export': |
186 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) { |
|
186 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) { |
|
187 | 187 | $found = true; |
188 | 188 | } |
189 | 189 | break; |
190 | 190 | case 'logs': |
191 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) { |
|
191 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) { |
|
192 | 192 | $found = true; |
193 | 193 | } |
194 | 194 | break; |
195 | 195 | default: |
196 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
196 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
197 | 197 | $found = true; |
198 | 198 | } |
199 | 199 | break; |
200 | 200 | } |
201 | 201 | break; |
202 | 202 | case 'settings': |
203 | - switch ( $passed_view ) { |
|
203 | + switch ($passed_view) { |
|
204 | 204 | case 'general': |
205 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) { |
|
205 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) { |
|
206 | 206 | $found = true; |
207 | 207 | } |
208 | 208 | break; |
209 | 209 | case 'gateways': |
210 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) { |
|
210 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) { |
|
211 | 211 | $found = true; |
212 | 212 | } |
213 | 213 | break; |
214 | 214 | case 'emails': |
215 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) { |
|
215 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) { |
|
216 | 216 | $found = true; |
217 | 217 | } |
218 | 218 | break; |
219 | 219 | case 'display': |
220 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) { |
|
220 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) { |
|
221 | 221 | $found = true; |
222 | 222 | } |
223 | 223 | break; |
224 | 224 | case 'licenses': |
225 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) { |
|
225 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) { |
|
226 | 226 | $found = true; |
227 | 227 | } |
228 | 228 | break; |
229 | 229 | case 'api': |
230 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) { |
|
230 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) { |
|
231 | 231 | $found = true; |
232 | 232 | } |
233 | 233 | break; |
234 | 234 | case 'advanced': |
235 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) { |
|
235 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) { |
|
236 | 236 | $found = true; |
237 | 237 | } |
238 | 238 | break; |
239 | 239 | case 'system_info': |
240 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) { |
|
240 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) { |
|
241 | 241 | $found = true; |
242 | 242 | } |
243 | 243 | break; |
244 | 244 | default: |
245 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) { |
|
245 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) { |
|
246 | 246 | $found = true; |
247 | 247 | } |
248 | 248 | break; |
249 | 249 | } |
250 | 250 | break; |
251 | 251 | case 'addons': |
252 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) { |
|
252 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) { |
|
253 | 253 | $found = true; |
254 | 254 | } |
255 | 255 | break; |
256 | 256 | case 'donors': |
257 | - switch ( $passed_view ) { |
|
257 | + switch ($passed_view) { |
|
258 | 258 | case 'list-table': |
259 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) { |
|
259 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) { |
|
260 | 260 | $found = true; |
261 | 261 | } |
262 | 262 | break; |
263 | 263 | case 'overview': |
264 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) { |
|
264 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) { |
|
265 | 265 | $found = true; |
266 | 266 | } |
267 | 267 | break; |
268 | 268 | case 'notes': |
269 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) { |
|
269 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) { |
|
270 | 270 | $found = true; |
271 | 271 | } |
272 | 272 | break; |
273 | 273 | default: |
274 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) { |
|
274 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) { |
|
275 | 275 | $found = true; |
276 | 276 | } |
277 | 277 | break; |
278 | 278 | } |
279 | 279 | break; |
280 | 280 | case 'reports': |
281 | - if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) { |
|
281 | + if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) { |
|
282 | 282 | $found = true; |
283 | 283 | } |
284 | 284 | break; |
285 | 285 | default: |
286 | 286 | global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page; |
287 | 287 | |
288 | - $admin_pages = apply_filters( 'give_admin_pages', array( |
|
288 | + $admin_pages = apply_filters('give_admin_pages', array( |
|
289 | 289 | $give_payments_page, |
290 | 290 | $give_settings_page, |
291 | 291 | $give_reports_page, |
@@ -294,18 +294,18 @@ discard block |
||
294 | 294 | $give_upgrades_screen, |
295 | 295 | $give_settings_export, |
296 | 296 | $give_customers_page |
297 | - ) ); |
|
298 | - if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) { |
|
297 | + )); |
|
298 | + if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) { |
|
299 | 299 | $found = true; |
300 | - if ( 'give-upgrades' === $page ) { |
|
300 | + if ('give-upgrades' === $page) { |
|
301 | 301 | $found = false; |
302 | 302 | } |
303 | - } elseif ( in_array( $pagenow, $admin_pages ) ) { |
|
303 | + } elseif (in_array($pagenow, $admin_pages)) { |
|
304 | 304 | $found = true; |
305 | 305 | } |
306 | 306 | break; |
307 | 307 | } |
308 | 308 | |
309 | - return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view ); |
|
309 | + return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view); |
|
310 | 310 | |
311 | 311 | } |
312 | 312 | \ No newline at end of file |
@@ -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 | |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function __construct() { |
81 | 81 | |
82 | - if ( 'none' === $this->get_template() ) { |
|
82 | + if ('none' === $this->get_template()) { |
|
83 | 83 | $this->html = false; |
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'give_email_send_before', array( $this, 'send_before' ) ); |
|
87 | - add_action( 'give_email_send_after', array( $this, 'send_after' ) ); |
|
86 | + add_action('give_email_send_before', array($this, 'send_before')); |
|
87 | + add_action('give_email_send_after', array($this, 'send_after')); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @since 1.0 |
95 | 95 | */ |
96 | - public function __set( $key, $value ) { |
|
96 | + public function __set($key, $value) { |
|
97 | 97 | $this->$key = $value; |
98 | 98 | } |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | 105 | public function get_from_name() { |
106 | - if ( ! $this->from_name ) { |
|
107 | - $this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) ); |
|
106 | + if ( ! $this->from_name) { |
|
107 | + $this->from_name = give_get_option('from_name', get_bloginfo('name')); |
|
108 | 108 | } |
109 | 109 | |
110 | - return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this ); |
|
110 | + return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | 118 | public function get_from_address() { |
119 | - if ( ! $this->from_address ) { |
|
120 | - $this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) ); |
|
119 | + if ( ! $this->from_address) { |
|
120 | + $this->from_address = give_get_option('from_email', get_option('admin_email')); |
|
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'give_email_from_address', $this->from_address, $this ); |
|
123 | + return apply_filters('give_email_from_address', $this->from_address, $this); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | */ |
131 | 131 | public function get_content_type() { |
132 | - if ( ! $this->content_type && $this->html ) { |
|
133 | - $this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this ); |
|
134 | - } else if ( ! $this->html ) { |
|
132 | + if ( ! $this->content_type && $this->html) { |
|
133 | + $this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this); |
|
134 | + } else if ( ! $this->html) { |
|
135 | 135 | $this->content_type = 'text/plain'; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( 'give_email_content_type', $this->content_type, $this ); |
|
138 | + return apply_filters('give_email_content_type', $this->content_type, $this); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * @since 1.0 |
145 | 145 | */ |
146 | 146 | public function get_headers() { |
147 | - if ( ! $this->headers ) { |
|
147 | + if ( ! $this->headers) { |
|
148 | 148 | $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n"; |
149 | 149 | $this->headers .= "Reply-To: {$this->get_from_address()}\r\n"; |
150 | 150 | $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n"; |
151 | 151 | } |
152 | 152 | |
153 | - return apply_filters( 'give_email_headers', $this->headers, $this ); |
|
153 | + return apply_filters('give_email_headers', $this->headers, $this); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_templates() { |
162 | 162 | $templates = array( |
163 | - 'default' => esc_html__( 'Default Template', 'give' ), |
|
164 | - 'none' => esc_html__( 'No template, plain text only', 'give' ) |
|
163 | + 'default' => esc_html__('Default Template', 'give'), |
|
164 | + 'none' => esc_html__('No template, plain text only', 'give') |
|
165 | 165 | ); |
166 | 166 | |
167 | - return apply_filters( 'give_email_templates', $templates ); |
|
167 | + return apply_filters('give_email_templates', $templates); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | * @since 1.0 |
174 | 174 | */ |
175 | 175 | public function get_template() { |
176 | - if ( ! $this->template ) { |
|
177 | - $this->template = give_get_option( 'email_template', 'default' ); |
|
176 | + if ( ! $this->template) { |
|
177 | + $this->template = give_get_option('email_template', 'default'); |
|
178 | 178 | } |
179 | 179 | |
180 | - return apply_filters( 'give_email_template', $this->template ); |
|
180 | + return apply_filters('give_email_template', $this->template); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | 188 | public function get_heading() { |
189 | - return apply_filters( 'give_email_heading', $this->heading ); |
|
189 | + return apply_filters('give_email_heading', $this->heading); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function parse_tags( $content ) { |
|
199 | + public function parse_tags($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
@@ -205,36 +205,36 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @since 1.0 |
207 | 207 | */ |
208 | - public function build_email( $message ) { |
|
208 | + public function build_email($message) { |
|
209 | 209 | |
210 | - if ( false === $this->html ) { |
|
211 | - return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this ); |
|
210 | + if (false === $this->html) { |
|
211 | + return apply_filters('give_email_message', wp_strip_all_tags($message), $this); |
|
212 | 212 | } |
213 | 213 | |
214 | - $message = $this->text_to_html( $message ); |
|
214 | + $message = $this->text_to_html($message); |
|
215 | 215 | |
216 | 216 | ob_start(); |
217 | 217 | |
218 | - give_get_template_part( 'emails/header', $this->get_template(), true ); |
|
218 | + give_get_template_part('emails/header', $this->get_template(), true); |
|
219 | 219 | |
220 | - do_action( 'give_email_header', $this ); |
|
220 | + do_action('give_email_header', $this); |
|
221 | 221 | |
222 | - if ( has_action( 'give_email_template_' . $this->get_template() ) ) { |
|
223 | - do_action( 'give_email_template_' . $this->get_template() ); |
|
222 | + if (has_action('give_email_template_'.$this->get_template())) { |
|
223 | + do_action('give_email_template_'.$this->get_template()); |
|
224 | 224 | } else { |
225 | - give_get_template_part( 'emails/body', $this->get_template(), true ); |
|
225 | + give_get_template_part('emails/body', $this->get_template(), true); |
|
226 | 226 | } |
227 | 227 | |
228 | - do_action( 'give_email_body', $this ); |
|
228 | + do_action('give_email_body', $this); |
|
229 | 229 | |
230 | - give_get_template_part( 'emails/footer', $this->get_template(), true ); |
|
230 | + give_get_template_part('emails/footer', $this->get_template(), true); |
|
231 | 231 | |
232 | - do_action( 'give_email_footer', $this ); |
|
232 | + do_action('give_email_footer', $this); |
|
233 | 233 | |
234 | 234 | $body = ob_get_clean(); |
235 | - $message = str_replace( '{email}', $message, $body ); |
|
235 | + $message = str_replace('{email}', $message, $body); |
|
236 | 236 | |
237 | - return apply_filters( 'give_email_message', $message, $this ); |
|
237 | + return apply_filters('give_email_message', $message, $this); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -247,26 +247,26 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return bool |
249 | 249 | */ |
250 | - public function send( $to, $subject, $message, $attachments = '' ) { |
|
250 | + public function send($to, $subject, $message, $attachments = '') { |
|
251 | 251 | |
252 | - if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) { |
|
253 | - _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null ); |
|
252 | + if ( ! did_action('init') && ! did_action('admin_init')) { |
|
253 | + _doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null); |
|
254 | 254 | |
255 | 255 | return false; |
256 | 256 | } |
257 | 257 | |
258 | - do_action( 'give_email_send_before', $this ); |
|
258 | + do_action('give_email_send_before', $this); |
|
259 | 259 | |
260 | - $subject = $this->parse_tags( $subject ); |
|
261 | - $message = $this->parse_tags( $message ); |
|
260 | + $subject = $this->parse_tags($subject); |
|
261 | + $message = $this->parse_tags($message); |
|
262 | 262 | |
263 | - $message = $this->build_email( $message ); |
|
263 | + $message = $this->build_email($message); |
|
264 | 264 | |
265 | - $attachments = apply_filters( 'give_email_attachments', $attachments, $this ); |
|
265 | + $attachments = apply_filters('give_email_attachments', $attachments, $this); |
|
266 | 266 | |
267 | - $sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments ); |
|
267 | + $sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments); |
|
268 | 268 | |
269 | - do_action( 'give_email_send_after', $this ); |
|
269 | + do_action('give_email_send_after', $this); |
|
270 | 270 | |
271 | 271 | return $sent; |
272 | 272 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | * @since 1.0 |
279 | 279 | */ |
280 | 280 | public function send_before() { |
281 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
282 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
283 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
281 | + add_filter('wp_mail_from', array($this, 'get_from_address')); |
|
282 | + add_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
283 | + add_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | * @since 1.0 |
290 | 290 | */ |
291 | 291 | public function send_after() { |
292 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
|
293 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
|
294 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
|
292 | + remove_filter('wp_mail_from', array($this, 'get_from_address')); |
|
293 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name')); |
|
294 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type')); |
|
295 | 295 | |
296 | 296 | // Reset heading to an empty string |
297 | 297 | $this->heading = ''; |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @since 1.0 |
304 | 304 | */ |
305 | - public function text_to_html( $message ) { |
|
305 | + public function text_to_html($message) { |
|
306 | 306 | |
307 | - if ( 'text/html' == $this->content_type || true === $this->html ) { |
|
308 | - $message = wpautop( $message ); |
|
307 | + if ('text/html' == $this->content_type || true === $this->html) { |
|
308 | + $message = wpautop($message); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | return $message; |
@@ -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,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return void |
25 | 25 | */ |
26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
26 | +function give_trigger_donation_receipt($payment_id) { |
|
27 | 27 | // Make sure we don't send a purchase receipt while editing a payment |
28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Send email |
33 | - give_email_donation_receipt( $payment_id ); |
|
33 | + give_email_donation_receipt($payment_id); |
|
34 | 34 | } |
35 | 35 | |
36 | -add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 ); |
|
36 | +add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Resend the Email Purchase Receipt. (This can be done from the Payment History page) |
@@ -44,29 +44,29 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return void |
46 | 46 | */ |
47 | -function give_resend_donation_receipt( $data ) { |
|
47 | +function give_resend_donation_receipt($data) { |
|
48 | 48 | |
49 | - $purchase_id = absint( $data['purchase_id'] ); |
|
49 | + $purchase_id = absint($data['purchase_id']); |
|
50 | 50 | |
51 | - if ( empty( $purchase_id ) ) { |
|
51 | + if (empty($purchase_id)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) { |
|
56 | - wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
55 | + if ( ! current_user_can('edit_give_payments', $purchase_id)) { |
|
56 | + wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
57 | 57 | } |
58 | 58 | |
59 | - give_email_donation_receipt( $purchase_id, false ); |
|
59 | + give_email_donation_receipt($purchase_id, false); |
|
60 | 60 | |
61 | - wp_redirect( add_query_arg( array( |
|
61 | + wp_redirect(add_query_arg(array( |
|
62 | 62 | 'give-message' => 'email_sent', |
63 | 63 | 'give-action' => false, |
64 | 64 | 'purchase_id' => false |
65 | - ) ) ); |
|
65 | + ))); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_email_links', 'give_resend_donation_receipt' ); |
|
69 | +add_action('give_email_links', 'give_resend_donation_receipt'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Trigger the sending of a Test Email |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return void |
79 | 79 | */ |
80 | -function give_send_test_email( $data ) { |
|
81 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) { |
|
80 | +function give_send_test_email($data) { |
|
81 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | give_email_test_donation_receipt(); |
87 | 87 | |
88 | 88 | // Remove the test email query arg |
89 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
89 | + wp_redirect(remove_query_arg('give_action')); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'give_send_test_email', 'give_send_test_email' ); |
|
93 | +add_action('give_send_test_email', 'give_send_test_email'); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $tag Email tag to be replace in email |
55 | 55 | * @param callable $func Hook to run when email tag is found |
56 | 56 | */ |
57 | - public function add( $tag, $description, $func ) { |
|
58 | - if ( is_callable( $func ) ) { |
|
59 | - $this->tags[ $tag ] = array( |
|
57 | + public function add($tag, $description, $func) { |
|
58 | + if (is_callable($func)) { |
|
59 | + $this->tags[$tag] = array( |
|
60 | 60 | 'tag' => $tag, |
61 | 61 | 'description' => $description, |
62 | 62 | 'func' => $func |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $tag Email tag to remove hook from |
73 | 73 | */ |
74 | - public function remove( $tag ) { |
|
75 | - unset( $this->tags[ $tag ] ); |
|
74 | + public function remove($tag) { |
|
75 | + unset($this->tags[$tag]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function email_tag_exists( $tag ) { |
|
88 | - return array_key_exists( $tag, $this->tags ); |
|
87 | + public function email_tag_exists($tag) { |
|
88 | + return array_key_exists($tag, $this->tags); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Content with email tags filtered out. |
111 | 111 | */ |
112 | - public function do_tags( $content, $payment_id ) { |
|
112 | + public function do_tags($content, $payment_id) { |
|
113 | 113 | |
114 | 114 | // Check if there is atleast one tag added |
115 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
115 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
116 | 116 | return $content; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->payment_id = $payment_id; |
120 | 120 | |
121 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
121 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
122 | 122 | |
123 | 123 | $this->payment_id = null; |
124 | 124 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function do_tag( $m ) { |
|
137 | + public function do_tag($m) { |
|
138 | 138 | |
139 | 139 | // Get tag |
140 | 140 | $tag = $m[1]; |
141 | 141 | |
142 | 142 | // Return tag if tag not set |
143 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
143 | + if ( ! $this->email_tag_exists($tag)) { |
|
144 | 144 | return $m[0]; |
145 | 145 | } |
146 | 146 | |
147 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
147 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $description Description of the email tag added |
159 | 159 | * @param callable $func Hook to run when email tag is found |
160 | 160 | */ |
161 | -function give_add_email_tag( $tag, $description, $func ) { |
|
162 | - Give()->email_tags->add( $tag, $description, $func ); |
|
161 | +function give_add_email_tag($tag, $description, $func) { |
|
162 | + Give()->email_tags->add($tag, $description, $func); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param string $tag Email tag to remove hook from |
171 | 171 | */ |
172 | -function give_remove_email_tag( $tag ) { |
|
173 | - Give()->email_tags->remove( $tag ); |
|
172 | +function give_remove_email_tag($tag) { |
|
173 | + Give()->email_tags->remove($tag); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | -function give_email_tag_exists( $tag ) { |
|
186 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
185 | +function give_email_tag_exists($tag) { |
|
186 | + return Give()->email_tags->email_tag_exists($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $email_tags = give_get_email_tags(); |
213 | 213 | |
214 | 214 | // Check |
215 | - if ( count( $email_tags ) > 0 ) { |
|
215 | + if (count($email_tags) > 0) { |
|
216 | 216 | |
217 | 217 | // Loop |
218 | - foreach ( $email_tags as $email_tag ) { |
|
218 | + foreach ($email_tags as $email_tag) { |
|
219 | 219 | |
220 | 220 | // Add email tag to list |
221 | - $list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>'; |
|
221 | + $list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>'; |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string Content with email tags filtered out. |
240 | 240 | */ |
241 | -function give_do_email_tags( $content, $payment_id ) { |
|
241 | +function give_do_email_tags($content, $payment_id) { |
|
242 | 242 | |
243 | 243 | // Replace all tags |
244 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
244 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
245 | 245 | |
246 | 246 | // Maintaining backwards compatibility |
247 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
247 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
248 | 248 | |
249 | 249 | // Return content |
250 | 250 | return $content; |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | * @since 1.0 |
257 | 257 | */ |
258 | 258 | function give_load_email_tags() { |
259 | - do_action( 'give_add_email_tags' ); |
|
259 | + do_action('give_add_email_tags'); |
|
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
262 | +add_action('init', 'give_load_email_tags', - 999); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Add default Give email template tags |
@@ -272,82 +272,82 @@ discard block |
||
272 | 272 | $email_tags = array( |
273 | 273 | array( |
274 | 274 | 'tag' => 'donation', |
275 | - 'description' => esc_html__( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ), |
|
275 | + 'description' => esc_html__('The name of completed donation form and the donation level chosen if applicable.', 'give'), |
|
276 | 276 | 'function' => 'give_email_tag_donation' |
277 | 277 | ), |
278 | 278 | array( |
279 | 279 | 'tag' => 'name', |
280 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
280 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
281 | 281 | 'function' => 'give_email_tag_first_name' |
282 | 282 | ), |
283 | 283 | array( |
284 | 284 | 'tag' => 'fullname', |
285 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
285 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
286 | 286 | 'function' => 'give_email_tag_fullname' |
287 | 287 | ), |
288 | 288 | array( |
289 | 289 | 'tag' => 'username', |
290 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
290 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
291 | 291 | 'function' => 'give_email_tag_username' |
292 | 292 | ), |
293 | 293 | array( |
294 | 294 | 'tag' => 'user_email', |
295 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
295 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
296 | 296 | 'function' => 'give_email_tag_user_email' |
297 | 297 | ), |
298 | 298 | array( |
299 | 299 | 'tag' => 'billing_address', |
300 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
300 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
301 | 301 | 'function' => 'give_email_tag_billing_address' |
302 | 302 | ), |
303 | 303 | array( |
304 | 304 | 'tag' => 'date', |
305 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
305 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
306 | 306 | 'function' => 'give_email_tag_date' |
307 | 307 | ), |
308 | 308 | array( |
309 | 309 | 'tag' => 'price', |
310 | - 'description' => esc_html__( 'The total price of the donation.', 'give' ), |
|
310 | + 'description' => esc_html__('The total price of the donation.', 'give'), |
|
311 | 311 | 'function' => 'give_email_tag_price' |
312 | 312 | ), |
313 | 313 | array( |
314 | 314 | 'tag' => 'payment_id', |
315 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
315 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
316 | 316 | 'function' => 'give_email_tag_payment_id' |
317 | 317 | ), |
318 | 318 | array( |
319 | 319 | 'tag' => 'receipt_id', |
320 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
320 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
321 | 321 | 'function' => 'give_email_tag_receipt_id' |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'payment_method', |
325 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
325 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_payment_method' |
327 | 327 | ), |
328 | 328 | array( |
329 | 329 | 'tag' => 'sitename', |
330 | - 'description' => esc_html__( 'Your site name', 'give' ), |
|
330 | + 'description' => esc_html__('Your site name', 'give'), |
|
331 | 331 | 'function' => 'give_email_tag_sitename' |
332 | 332 | ), |
333 | 333 | array( |
334 | 334 | 'tag' => 'receipt_link', |
335 | - 'description' => esc_html__( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ), |
|
335 | + 'description' => esc_html__('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'), |
|
336 | 336 | 'function' => 'give_email_tag_receipt_link' |
337 | 337 | ), |
338 | 338 | ); |
339 | 339 | |
340 | 340 | // Apply give_email_tags filter |
341 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
341 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
342 | 342 | |
343 | 343 | // Add email tags |
344 | - foreach ( $email_tags as $email_tag ) { |
|
345 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
344 | + foreach ($email_tags as $email_tag) { |
|
345 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
350 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
351 | 351 | |
352 | 352 | |
353 | 353 | /** |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string name |
360 | 360 | */ |
361 | -function give_email_tag_first_name( $payment_id ) { |
|
362 | - $payment = new Give_Payment( $payment_id ); |
|
361 | +function give_email_tag_first_name($payment_id) { |
|
362 | + $payment = new Give_Payment($payment_id); |
|
363 | 363 | $user_info = $payment->user_info; |
364 | 364 | |
365 | - if ( empty( $user_info ) ) { |
|
365 | + if (empty($user_info)) { |
|
366 | 366 | return ''; |
367 | 367 | } |
368 | 368 | |
369 | - $email_name = give_get_email_names( $user_info ); |
|
369 | + $email_name = give_get_email_names($user_info); |
|
370 | 370 | |
371 | 371 | return $email_name['name']; |
372 | 372 | } |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string fullname |
381 | 381 | */ |
382 | -function give_email_tag_fullname( $payment_id ) { |
|
383 | - $payment = new Give_Payment( $payment_id ); |
|
382 | +function give_email_tag_fullname($payment_id) { |
|
383 | + $payment = new Give_Payment($payment_id); |
|
384 | 384 | $user_info = $payment->user_info; |
385 | 385 | |
386 | - if ( empty( $user_info ) ) { |
|
386 | + if (empty($user_info)) { |
|
387 | 387 | return ''; |
388 | 388 | } |
389 | 389 | |
390 | - $email_name = give_get_email_names( $user_info ); |
|
390 | + $email_name = give_get_email_names($user_info); |
|
391 | 391 | |
392 | 392 | return $email_name['fullname']; |
393 | 393 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string username |
402 | 402 | */ |
403 | -function give_email_tag_username( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_username($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['username']; |
414 | 414 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string user_email |
423 | 423 | */ |
424 | -function give_email_tag_user_email( $payment_id ) { |
|
425 | - $payment = new Give_Payment( $payment_id ); |
|
424 | +function give_email_tag_user_email($payment_id) { |
|
425 | + $payment = new Give_Payment($payment_id); |
|
426 | 426 | |
427 | 427 | return $payment->email; |
428 | 428 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string billing_address |
437 | 437 | */ |
438 | -function give_email_tag_billing_address( $payment_id ) { |
|
438 | +function give_email_tag_billing_address($payment_id) { |
|
439 | 439 | |
440 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
441 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
440 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
441 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
442 | 442 | 'line1' => '', |
443 | 443 | 'line2' => '', |
444 | 444 | 'city' => '', |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | 'zip' => '' |
448 | 448 | ); |
449 | 449 | |
450 | - $return = $user_address['line1'] . "\n"; |
|
451 | - if ( ! empty( $user_address['line2'] ) ) { |
|
452 | - $return .= $user_address['line2'] . "\n"; |
|
450 | + $return = $user_address['line1']."\n"; |
|
451 | + if ( ! empty($user_address['line2'])) { |
|
452 | + $return .= $user_address['line2']."\n"; |
|
453 | 453 | } |
454 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
454 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
455 | 455 | $return .= $user_address['country']; |
456 | 456 | |
457 | 457 | return $return; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string date |
467 | 467 | */ |
468 | -function give_email_tag_date( $payment_id ) { |
|
469 | - $payment = new Give_Payment( $payment_id ); |
|
468 | +function give_email_tag_date($payment_id) { |
|
469 | + $payment = new Give_Payment($payment_id); |
|
470 | 470 | |
471 | - return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) ); |
|
471 | + return date_i18n(get_option('date_format'), strtotime($payment->date)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string price |
481 | 481 | */ |
482 | -function give_email_tag_price( $payment_id ) { |
|
483 | - $payment = new Give_Payment( $payment_id ); |
|
484 | - $price = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
482 | +function give_email_tag_price($payment_id) { |
|
483 | + $payment = new Give_Payment($payment_id); |
|
484 | + $price = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
485 | 485 | |
486 | - return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' ); |
|
486 | + return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return int payment_id |
496 | 496 | */ |
497 | -function give_email_tag_payment_id( $payment_id ) { |
|
498 | - $payment = new Give_Payment( $payment_id ); |
|
497 | +function give_email_tag_payment_id($payment_id) { |
|
498 | + $payment = new Give_Payment($payment_id); |
|
499 | 499 | |
500 | 500 | return $payment->number; |
501 | 501 | } |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string receipt_id |
510 | 510 | */ |
511 | -function give_email_tag_receipt_id( $payment_id ) { |
|
512 | - $payment = new Give_Payment( $payment_id ); |
|
511 | +function give_email_tag_receipt_id($payment_id) { |
|
512 | + $payment = new Give_Payment($payment_id); |
|
513 | 513 | |
514 | 514 | return $payment->key; |
515 | 515 | } |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @return string $form_title |
525 | 525 | */ |
526 | -function give_email_tag_donation( $payment_id ) { |
|
527 | - $payment = new Give_Payment( $payment_id ); |
|
528 | - $form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) ); |
|
526 | +function give_email_tag_donation($payment_id) { |
|
527 | + $payment = new Give_Payment($payment_id); |
|
528 | + $form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-')); |
|
529 | 529 | |
530 | - return ! empty( $form_title ) ? $form_title : esc_html__( 'There was an error retrieving this donation title.', 'give' ); |
|
530 | + return ! empty($form_title) ? $form_title : esc_html__('There was an error retrieving this donation title.', 'give'); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string gateway |
541 | 541 | */ |
542 | -function give_email_tag_payment_method( $payment_id ) { |
|
543 | - $payment = new Give_Payment( $payment_id ); |
|
542 | +function give_email_tag_payment_method($payment_id) { |
|
543 | + $payment = new Give_Payment($payment_id); |
|
544 | 544 | |
545 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
545 | + return give_get_gateway_checkout_label($payment->gateway); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return string sitename |
555 | 555 | */ |
556 | -function give_email_tag_sitename( $payment_id ) { |
|
557 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
556 | +function give_email_tag_sitename($payment_id) { |
|
557 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return string receipt_link |
568 | 568 | */ |
569 | -function give_email_tag_receipt_link( $payment_id ) { |
|
569 | +function give_email_tag_receipt_link($payment_id) { |
|
570 | 570 | |
571 | - $receipt_url = esc_url( add_query_arg( array( |
|
572 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
571 | + $receipt_url = esc_url(add_query_arg(array( |
|
572 | + 'payment_key' => give_get_payment_key($payment_id), |
|
573 | 573 | 'give_action' => 'view_receipt' |
574 | - ), home_url() ) ); |
|
575 | - $formatted = sprintf( |
|
574 | + ), home_url())); |
|
575 | + $formatted = sprintf( |
|
576 | 576 | '<a href="%1$s">%2$s</a>', |
577 | 577 | $receipt_url, |
578 | - esc_html__( 'View it in your browser', 'give' ) |
|
578 | + esc_html__('View it in your browser', 'give') |
|
579 | 579 | ); |
580 | 580 | |
581 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
581 | + if (give_get_option('email_template') !== 'none') { |
|
582 | 582 | return $formatted; |
583 | 583 | } else { |
584 | 584 | return $receipt_url; |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
15 | +if ( ! class_exists('Give_License')) : |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_License Class |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param string $_optname |
39 | 39 | * @param string $_api_url |
40 | 40 | */ |
41 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { |
|
41 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) { |
|
42 | 42 | global $give_options; |
43 | 43 | |
44 | 44 | $this->file = $_file; |
45 | 45 | $this->item_name = $_item_name; |
46 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
46 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
47 | 47 | $this->version = $_version; |
48 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
48 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
49 | 49 | $this->author = $_author; |
50 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
50 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | // Setup hooks |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | private function includes() { |
66 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
66 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
67 | 67 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
68 | 68 | } |
69 | 69 | } |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | private function hooks() { |
78 | 78 | |
79 | 79 | // Register settings |
80 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
80 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
81 | 81 | |
82 | 82 | // Activate license key on settings save |
83 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
83 | + add_action('admin_init', array($this, 'activate_license')); |
|
84 | 84 | |
85 | 85 | // Deactivate license key |
86 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
86 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
87 | 87 | |
88 | 88 | // Updater |
89 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
89 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
90 | 90 | |
91 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
91 | + add_action('admin_notices', array($this, 'notices')); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function auto_updater() { |
102 | 102 | |
103 | - if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) { |
|
103 | + if ('valid' !== get_option($this->item_shortname.'_license_active')) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public function settings( $settings ) { |
|
130 | + public function settings($settings) { |
|
131 | 131 | |
132 | 132 | $give_license_settings = array( |
133 | 133 | array( |
134 | 134 | 'name' => $this->item_name, |
135 | - 'id' => $this->item_shortname . '_license_key', |
|
135 | + 'id' => $this->item_shortname.'_license_key', |
|
136 | 136 | 'desc' => '', |
137 | 137 | 'type' => 'license_key', |
138 | - 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ), |
|
138 | + 'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'), |
|
139 | 139 | 'size' => 'regular' |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | |
143 | - return array_merge( $settings, $give_license_settings ); |
|
143 | + return array_merge($settings, $give_license_settings); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array |
154 | 154 | */ |
155 | - public function license_settings_content( $settings ) { |
|
155 | + public function license_settings_content($settings) { |
|
156 | 156 | |
157 | 157 | $give_license_settings = array( |
158 | 158 | array( |
159 | - 'name' => esc_html__( 'Add-on Licenses', 'give' ), |
|
159 | + 'name' => esc_html__('Add-on Licenses', 'give'), |
|
160 | 160 | 'desc' => '<hr>', |
161 | 161 | 'type' => 'give_title', |
162 | 162 | 'id' => 'give_title' |
163 | 163 | ), |
164 | 164 | ); |
165 | 165 | |
166 | - return array_merge( $settings, $give_license_settings ); |
|
166 | + return array_merge($settings, $give_license_settings); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,34 +175,34 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function activate_license() { |
177 | 177 | |
178 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
178 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - foreach ( $_POST as $key => $value ) { |
|
183 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
182 | + foreach ($_POST as $key => $value) { |
|
183 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
184 | 184 | // Don't activate a key when deactivating a different key |
185 | 185 | return; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
189 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
190 | 190 | |
191 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
191 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
195 | + if ( ! current_user_can('manage_give_settings')) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) { |
|
199 | + if ('valid' === get_option($this->item_shortname.'_license_active')) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
203 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
204 | 204 | |
205 | - if ( empty( $license ) ) { |
|
205 | + if (empty($license)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $api_params = array( |
211 | 211 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
212 | 212 | 'license' => $license, |
213 | - 'item_name' => urlencode( $this->item_name ), |
|
213 | + 'item_name' => urlencode($this->item_name), |
|
214 | 214 | 'url' => home_url() |
215 | 215 | ); |
216 | 216 | |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | ); |
226 | 226 | |
227 | 227 | // Make sure there are no errors |
228 | - if ( is_wp_error( $response ) ) { |
|
228 | + if (is_wp_error($response)) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Tell WordPress to look for updates |
233 | - set_site_transient( 'update_plugins', null ); |
|
233 | + set_site_transient('update_plugins', null); |
|
234 | 234 | |
235 | 235 | // Decode license data |
236 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
236 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
237 | 237 | |
238 | - update_option( $this->item_shortname . '_license_active', $license_data->license ); |
|
238 | + update_option($this->item_shortname.'_license_active', $license_data->license); |
|
239 | 239 | |
240 | - if ( ! (bool) $license_data->success ) { |
|
241 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
240 | + if ( ! (bool) $license_data->success) { |
|
241 | + set_transient('give_license_error', $license_data, 1000); |
|
242 | 242 | } else { |
243 | - delete_transient( 'give_license_error' ); |
|
243 | + delete_transient('give_license_error'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function deactivate_license() { |
255 | 255 | |
256 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
256 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
260 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
261 | 261 | |
262 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
262 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
266 | + if ( ! current_user_can('manage_give_settings')) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Run on deactivate button press |
271 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
271 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
272 | 272 | |
273 | 273 | // Data to send to the API |
274 | 274 | $api_params = array( |
275 | 275 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
276 | 276 | 'license' => $this->license, |
277 | - 'item_name' => urlencode( $this->item_name ), |
|
277 | + 'item_name' => urlencode($this->item_name), |
|
278 | 278 | 'url' => home_url() |
279 | 279 | ); |
280 | 280 | |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | // Make sure there are no errors |
293 | - if ( is_wp_error( $response ) ) { |
|
293 | + if (is_wp_error($response)) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Decode the license data |
298 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
298 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
299 | 299 | |
300 | - delete_option( $this->item_shortname . '_license_active' ); |
|
300 | + delete_option($this->item_shortname.'_license_active'); |
|
301 | 301 | |
302 | - if ( ! (bool) $license_data->success ) { |
|
303 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
302 | + if ( ! (bool) $license_data->success) { |
|
303 | + set_transient('give_license_error', $license_data, 1000); |
|
304 | 304 | } else { |
305 | - delete_transient( 'give_license_error' ); |
|
305 | + delete_transient('give_license_error'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -316,44 +316,44 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function notices() { |
318 | 318 | |
319 | - if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) { |
|
319 | + if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) { |
|
323 | + if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $license_error = get_transient( 'give_license_error' ); |
|
327 | + $license_error = get_transient('give_license_error'); |
|
328 | 328 | |
329 | - if ( false === $license_error ) { |
|
329 | + if (false === $license_error) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | - if ( ! empty( $license_error->error ) ) { |
|
333 | + if ( ! empty($license_error->error)) { |
|
334 | 334 | |
335 | - switch ( $license_error->error ) { |
|
335 | + switch ($license_error->error) { |
|
336 | 336 | |
337 | 337 | case 'item_name_mismatch' : |
338 | 338 | |
339 | - $message = esc_html__( 'This license does not belong to the product you have entered it for.', 'give' ); |
|
339 | + $message = esc_html__('This license does not belong to the product you have entered it for.', 'give'); |
|
340 | 340 | break; |
341 | 341 | |
342 | 342 | case 'no_activations_left' : |
343 | 343 | |
344 | - $message = esc_html__( 'This license does not have any activations left.', 'give' ); |
|
344 | + $message = esc_html__('This license does not have any activations left.', 'give'); |
|
345 | 345 | break; |
346 | 346 | |
347 | 347 | case 'expired' : |
348 | 348 | |
349 | - $message = esc_html__( 'This license key is expired. Please renew it.', 'give' ); |
|
349 | + $message = esc_html__('This license key is expired. Please renew it.', 'give'); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | default : |
353 | 353 | |
354 | 354 | $message = sprintf( |
355 | 355 | /* translators: %s: license error */ |
356 | - esc_html__( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ), |
|
356 | + esc_html__('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'), |
|
357 | 357 | $license_error->error |
358 | 358 | ); |
359 | 359 | break; |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $message ) ) { |
|
365 | + if ( ! empty($message)) { |
|
366 | 366 | |
367 | 367 | echo '<div class="error">'; |
368 | - echo '<p>' . $message . '</p>'; |
|
368 | + echo '<p>'.$message.'</p>'; |
|
369 | 369 | echo '</div>'; |
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | - delete_transient( 'give_license_error' ); |
|
373 | + delete_transient('give_license_error'); |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | } |
@@ -42,16 +42,16 @@ |
||
42 | 42 | 'minWidth' => 320, |
43 | 43 | 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ), |
44 | 44 | ), |
45 | - array( |
|
46 | - 'type' => 'container', |
|
47 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ), |
|
48 | - ), |
|
49 | - array( |
|
50 | - 'type' => 'textbox', |
|
51 | - 'name' => 'logout-redirect', |
|
52 | - 'minWidth' => 320, |
|
53 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ), |
|
54 | - ), |
|
45 | + array( |
|
46 | + 'type' => 'container', |
|
47 | + 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ), |
|
48 | + ), |
|
49 | + array( |
|
50 | + 'type' => 'textbox', |
|
51 | + 'name' => 'logout-redirect', |
|
52 | + 'minWidth' => 320, |
|
53 | + 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ), |
|
54 | + ), |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.3.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) or exit; |
|
12 | +defined('ABSPATH') or exit; |
|
13 | 13 | |
14 | 14 | class Give_Shortcode_Login extends Give_Shortcode_Generator { |
15 | 15 | |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | 20 | |
21 | - $this->shortcode['title'] = esc_html__( 'Login', 'give' ); |
|
22 | - $this->shortcode['label'] = esc_html__( 'Login', 'give' ); |
|
21 | + $this->shortcode['title'] = esc_html__('Login', 'give'); |
|
22 | + $this->shortcode['label'] = esc_html__('Login', 'give'); |
|
23 | 23 | |
24 | - parent::__construct( 'give_login' ); |
|
24 | + parent::__construct('give_login'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -34,23 +34,23 @@ discard block |
||
34 | 34 | return array( |
35 | 35 | array( |
36 | 36 | 'type' => 'container', |
37 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Login Redirect URL (optional):', 'give' ) ), |
|
37 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Login Redirect URL (optional):', 'give')), |
|
38 | 38 | ), |
39 | 39 | array( |
40 | 40 | 'type' => 'textbox', |
41 | 41 | 'name' => 'login-redirect', |
42 | 42 | 'minWidth' => 320, |
43 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after login.', 'give' ), |
|
43 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after login.', 'give'), |
|
44 | 44 | ), |
45 | 45 | array( |
46 | 46 | 'type' => 'container', |
47 | - 'html' => sprintf( '<p class="no-margin">%s</p>', esc_html__( 'Logout Redirect URL (optional):', 'give' ) ), |
|
47 | + 'html' => sprintf('<p class="no-margin">%s</p>', esc_html__('Logout Redirect URL (optional):', 'give')), |
|
48 | 48 | ), |
49 | 49 | array( |
50 | 50 | 'type' => 'textbox', |
51 | 51 | 'name' => 'logout-redirect', |
52 | 52 | 'minWidth' => 320, |
53 | - 'tooltip' => esc_attr__( 'Enter an URL here to redirect to after logout.', 'give' ), |
|
53 | + 'tooltip' => esc_attr__('Enter an URL here to redirect to after logout.', 'give'), |
|
54 | 54 | ), |
55 | 55 | ); |
56 | 56 | } |
@@ -248,8 +248,8 @@ |
||
248 | 248 | |
249 | 249 | // do not reindex array! |
250 | 250 | $field['options'] = array( |
251 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
252 | - ) + $field['options']; |
|
251 | + '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
252 | + ) + $field['options']; |
|
253 | 253 | |
254 | 254 | foreach ( $field['options'] as $value => $text ) { |
255 | 255 | $new_listbox['values'][] = array( |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @since 1.3 |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) or exit; |
|
13 | +defined('ABSPATH') or exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class Give_Shortcode_Generator |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @since 1.0 |
61 | 61 | */ |
62 | - public function __construct( $shortcode ) { |
|
62 | + public function __construct($shortcode) { |
|
63 | 63 | |
64 | 64 | |
65 | 65 | $this->shortcode_tag = $shortcode; |
66 | 66 | |
67 | - add_action( 'admin_init', array( $this, 'init' ) ); |
|
67 | + add_action('admin_init', array($this, 'init')); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function init() { |
77 | 77 | |
78 | - if ( $this->shortcode_tag ) { |
|
78 | + if ($this->shortcode_tag) { |
|
79 | 79 | |
80 | - $this->self = get_class( $this ); |
|
80 | + $this->self = get_class($this); |
|
81 | 81 | |
82 | 82 | $this->errors = array(); |
83 | 83 | $this->required = array(); |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | $fields = $this->get_fields(); |
87 | 87 | |
88 | 88 | $defaults = array( |
89 | - 'btn_close' => esc_html__( 'Close', 'give' ), |
|
90 | - 'btn_okay' => esc_html__( 'Insert Shortcode', 'give' ), |
|
89 | + 'btn_close' => esc_html__('Close', 'give'), |
|
90 | + 'btn_okay' => esc_html__('Insert Shortcode', 'give'), |
|
91 | 91 | 'errors' => $this->errors, |
92 | 92 | 'fields' => $fields, |
93 | - 'label' => '[' . $this->shortcode_tag . ']', |
|
93 | + 'label' => '['.$this->shortcode_tag.']', |
|
94 | 94 | 'required' => $this->required, |
95 | - 'title' => esc_html__( 'Insert Shortcode', 'give' ), |
|
95 | + 'title' => esc_html__('Insert Shortcode', 'give'), |
|
96 | 96 | ); |
97 | 97 | |
98 | - if ( user_can_richedit() ) { |
|
98 | + if (user_can_richedit()) { |
|
99 | 99 | |
100 | - Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults ); |
|
100 | + Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | - protected function generate_fields( $defined_fields ) { |
|
129 | + protected function generate_fields($defined_fields) { |
|
130 | 130 | |
131 | 131 | $fields = array(); |
132 | 132 | |
133 | - if ( is_array( $defined_fields ) ) { |
|
133 | + if (is_array($defined_fields)) { |
|
134 | 134 | |
135 | - foreach ( $defined_fields as $field ) { |
|
135 | + foreach ($defined_fields as $field) { |
|
136 | 136 | |
137 | 137 | $defaults = array( |
138 | 138 | 'label' => false, |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | 'type' => '', |
144 | 144 | ); |
145 | 145 | |
146 | - $field = wp_parse_args( (array) $field, $defaults ); |
|
147 | - $method = 'generate_' . strtolower( $field['type'] ); |
|
146 | + $field = wp_parse_args((array) $field, $defaults); |
|
147 | + $method = 'generate_'.strtolower($field['type']); |
|
148 | 148 | |
149 | - if ( method_exists( $this, $method ) ) { |
|
149 | + if (method_exists($this, $method)) { |
|
150 | 150 | |
151 | - $field = call_user_func( array( $this, $method ), $field ); |
|
151 | + $field = call_user_func(array($this, $method), $field); |
|
152 | 152 | |
153 | - if ( $field ) { |
|
153 | + if ($field) { |
|
154 | 154 | $fields[] = $field; |
155 | 155 | } |
156 | 156 | } |
@@ -170,22 +170,22 @@ discard block |
||
170 | 170 | protected function get_fields() { |
171 | 171 | |
172 | 172 | $defined_fields = $this->define_fields(); |
173 | - $generated_fields = $this->generate_fields( $defined_fields ); |
|
173 | + $generated_fields = $this->generate_fields($defined_fields); |
|
174 | 174 | |
175 | 175 | $errors = array(); |
176 | 176 | |
177 | - if ( ! empty( $this->errors ) ) { |
|
178 | - foreach ( $this->required as $name => $alert ) { |
|
179 | - if ( false === array_search( $name, array_column( $generated_fields, 'name' ) ) ) { |
|
177 | + if ( ! empty($this->errors)) { |
|
178 | + foreach ($this->required as $name => $alert) { |
|
179 | + if (false === array_search($name, array_column($generated_fields, 'name'))) { |
|
180 | 180 | |
181 | - $errors[] = $this->errors[ $name ]; |
|
181 | + $errors[] = $this->errors[$name]; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | 185 | $this->errors = $errors; |
186 | 186 | } |
187 | 187 | |
188 | - if ( ! empty( $errors ) ) { |
|
188 | + if ( ! empty($errors)) { |
|
189 | 189 | |
190 | 190 | return $errors; |
191 | 191 | } |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @since 1.0 |
204 | 204 | */ |
205 | - protected function generate_container( $field ) { |
|
205 | + protected function generate_container($field) { |
|
206 | 206 | |
207 | - if ( array_key_exists( 'html', $field ) ) { |
|
207 | + if (array_key_exists('html', $field)) { |
|
208 | 208 | |
209 | 209 | return array( |
210 | 210 | 'type' => $field['type'], |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @since 1.0 |
226 | 226 | */ |
227 | - protected function generate_listbox( $field ) { |
|
227 | + protected function generate_listbox($field) { |
|
228 | 228 | |
229 | - $listbox = shortcode_atts( array( |
|
229 | + $listbox = shortcode_atts(array( |
|
230 | 230 | 'label' => '', |
231 | 231 | 'minWidth' => '', |
232 | 232 | 'name' => false, |
233 | 233 | 'tooltip' => '', |
234 | 234 | 'type' => '', |
235 | 235 | 'value' => '', |
236 | - ), $field ); |
|
236 | + ), $field); |
|
237 | 237 | |
238 | - if ( $this->validate( $field ) ) { |
|
238 | + if ($this->validate($field)) { |
|
239 | 239 | |
240 | 240 | $new_listbox = array(); |
241 | 241 | |
242 | - foreach ( $listbox as $key => $value ) { |
|
242 | + foreach ($listbox as $key => $value) { |
|
243 | 243 | |
244 | - if ( $key == 'value' && empty( $value ) ) { |
|
245 | - $new_listbox[ $key ] = $listbox['name']; |
|
246 | - } else if ( $value ) { |
|
247 | - $new_listbox[ $key ] = $value; |
|
244 | + if ($key == 'value' && empty($value)) { |
|
245 | + $new_listbox[$key] = $listbox['name']; |
|
246 | + } else if ($value) { |
|
247 | + $new_listbox[$key] = $value; |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | // do not reindex array! |
252 | 252 | $field['options'] = array( |
253 | - '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ), |
|
253 | + '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')), |
|
254 | 254 | ) + $field['options']; |
255 | 255 | |
256 | - foreach ( $field['options'] as $value => $text ) { |
|
256 | + foreach ($field['options'] as $value => $text) { |
|
257 | 257 | $new_listbox['values'][] = array( |
258 | 258 | 'text' => $text, |
259 | 259 | 'value' => $value, |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @since 1.0 |
277 | 277 | */ |
278 | - protected function generate_post( $field ) { |
|
278 | + protected function generate_post($field) { |
|
279 | 279 | |
280 | 280 | $args = array( |
281 | 281 | 'post_type' => 'post', |
@@ -284,23 +284,23 @@ discard block |
||
284 | 284 | 'posts_per_page' => 30, |
285 | 285 | ); |
286 | 286 | |
287 | - $args = wp_parse_args( (array) $field['query_args'], $args ); |
|
288 | - $posts = get_posts( $args ); |
|
287 | + $args = wp_parse_args((array) $field['query_args'], $args); |
|
288 | + $posts = get_posts($args); |
|
289 | 289 | $options = array(); |
290 | 290 | |
291 | - if ( $posts ) { |
|
292 | - foreach ( $posts as $post ) { |
|
293 | - $options[ absint( $post->ID ) ] = esc_html( $post->post_title ); |
|
291 | + if ($posts) { |
|
292 | + foreach ($posts as $post) { |
|
293 | + $options[absint($post->ID)] = esc_html($post->post_title); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $field['type'] = 'listbox'; |
297 | 297 | $field['options'] = $options; |
298 | 298 | |
299 | - return $this->generate_listbox( $field ); |
|
299 | + return $this->generate_listbox($field); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // perform validation here before returning false |
303 | - $this->validate( $field ); |
|
303 | + $this->validate($field); |
|
304 | 304 | |
305 | 305 | return false; |
306 | 306 | } |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @since 1.0 |
316 | 316 | */ |
317 | - protected function generate_textbox( $field ) { |
|
317 | + protected function generate_textbox($field) { |
|
318 | 318 | |
319 | - $textbox = shortcode_atts( array( |
|
319 | + $textbox = shortcode_atts(array( |
|
320 | 320 | 'label' => '', |
321 | 321 | 'maxLength' => '', |
322 | 322 | 'minHeight' => '', |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | 'tooltip' => '', |
327 | 327 | 'type' => '', |
328 | 328 | 'value' => '', |
329 | - ), $field ); |
|
329 | + ), $field); |
|
330 | 330 | |
331 | - if ( $this->validate( $field ) ) { |
|
332 | - return array_filter( $textbox, array( $this, 'return_textbox_value' ) ); |
|
331 | + if ($this->validate($field)) { |
|
332 | + return array_filter($textbox, array($this, 'return_textbox_value')); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | return false; |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return bool |
344 | 344 | */ |
345 | - function return_textbox_value( $value ) { |
|
345 | + function return_textbox_value($value) { |
|
346 | 346 | return $value !== ''; |
347 | 347 | } |
348 | 348 | |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.0 |
360 | 360 | */ |
361 | - protected function validate( $field ) { |
|
361 | + protected function validate($field) { |
|
362 | 362 | |
363 | - extract( shortcode_atts( |
|
363 | + extract(shortcode_atts( |
|
364 | 364 | array( |
365 | 365 | 'name' => false, |
366 | 366 | 'required' => false, |
@@ -368,36 +368,36 @@ discard block |
||
368 | 368 | ), $field ) |
369 | 369 | ); |
370 | 370 | |
371 | - if ( $name ) { |
|
371 | + if ($name) { |
|
372 | 372 | |
373 | - if ( isset( $required['error'] ) ) { |
|
373 | + if (isset($required['error'])) { |
|
374 | 374 | |
375 | 375 | $error = array( |
376 | 376 | 'type' => 'container', |
377 | 377 | 'html' => $required['error'], |
378 | 378 | ); |
379 | 379 | |
380 | - $this->errors[ $name ] = $this->generate_container( $error ); |
|
380 | + $this->errors[$name] = $this->generate_container($error); |
|
381 | 381 | } |
382 | 382 | |
383 | - if ( ! ! $required || is_array( $required ) ) { |
|
383 | + if ( ! ! $required || is_array($required)) { |
|
384 | 384 | |
385 | - $alert = esc_html__( 'Some of the shortcode options are required.', 'give' ); |
|
385 | + $alert = esc_html__('Some of the shortcode options are required.', 'give'); |
|
386 | 386 | |
387 | - if ( isset( $required['alert'] ) ) { |
|
387 | + if (isset($required['alert'])) { |
|
388 | 388 | |
389 | 389 | $alert = $required['alert']; |
390 | 390 | |
391 | - } else if ( ! empty( $label ) ) { |
|
391 | + } else if ( ! empty($label)) { |
|
392 | 392 | |
393 | 393 | $alert = sprintf( |
394 | 394 | /* translators: %s: option label */ |
395 | - esc_html__( 'The "%s" option is required.', 'give' ), |
|
396 | - str_replace( ':', '', $label ) |
|
395 | + esc_html__('The "%s" option is required.', 'give'), |
|
396 | + str_replace(':', '', $label) |
|
397 | 397 | ); |
398 | 398 | } |
399 | 399 | |
400 | - $this->required[ $name ] = $alert; |
|
400 | + $this->required[$name] = $alert; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | return true; |
@@ -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,67 +66,67 @@ 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 | global $give_options; |
72 | 72 | |
73 | - $style = isset( $give_options['button_style'] ) ? $give_options['button_style'] : 'button'; |
|
74 | - $color = isset( $give_options['checkout_color'] ) ? $give_options['checkout_color'] : 'blue'; |
|
75 | - $color = ( $color == 'inherit' ) ? '' : $color; |
|
73 | + $style = isset($give_options['button_style']) ? $give_options['button_style'] : 'button'; |
|
74 | + $color = isset($give_options['checkout_color']) ? $give_options['checkout_color'] : 'blue'; |
|
75 | + $color = ($color == 'inherit') ? '' : $color; |
|
76 | 76 | |
77 | - $purchase_text = ! empty( $give_options['add_to_cart_text'] ) ? $give_options['add_to_cart_text'] : esc_html__( 'Purchase', 'give' ); |
|
77 | + $purchase_text = ! empty($give_options['add_to_cart_text']) ? $give_options['add_to_cart_text'] : esc_html__('Purchase', 'give'); |
|
78 | 78 | |
79 | - switch ( $column_name ) { |
|
79 | + switch ($column_name) { |
|
80 | 80 | case 'form_category': |
81 | - echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' ); |
|
81 | + echo get_the_term_list($post_id, 'give_forms_category', '', ', ', ''); |
|
82 | 82 | break; |
83 | 83 | case 'form_tag': |
84 | - echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' ); |
|
84 | + echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', ''); |
|
85 | 85 | break; |
86 | 86 | case 'price': |
87 | - if ( give_has_variable_prices( $post_id ) ) { |
|
88 | - echo give_price_range( $post_id ); |
|
87 | + if (give_has_variable_prices($post_id)) { |
|
88 | + echo give_price_range($post_id); |
|
89 | 89 | } else { |
90 | - echo give_price( $post_id, false ); |
|
91 | - echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />'; |
|
90 | + echo give_price($post_id, false); |
|
91 | + echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />'; |
|
92 | 92 | } |
93 | 93 | break; |
94 | 94 | case 'goal': |
95 | - $goal_option = get_post_meta( $post_id, '_give_goal_option', true ); |
|
96 | - if ( ! empty( $goal_option ) && $goal_option === 'yes' ) { |
|
97 | - echo give_goal( $post_id, false ); |
|
95 | + $goal_option = get_post_meta($post_id, '_give_goal_option', true); |
|
96 | + if ( ! empty($goal_option) && $goal_option === 'yes') { |
|
97 | + echo give_goal($post_id, false); |
|
98 | 98 | } else { |
99 | - echo esc_html__( 'No Goal Set', 'give' ); |
|
99 | + echo esc_html__('No Goal Set', 'give'); |
|
100 | 100 | } |
101 | 101 | |
102 | - echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />'; |
|
102 | + echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />'; |
|
103 | 103 | break; |
104 | 104 | case 'donations': |
105 | - if ( current_user_can( 'view_give_forms_stats', $post_id ) ) { |
|
106 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">'; |
|
107 | - echo give_get_form_sales_stats( $post_id ); |
|
105 | + if (current_user_can('view_give_forms_stats', $post_id)) { |
|
106 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">'; |
|
107 | + echo give_get_form_sales_stats($post_id); |
|
108 | 108 | echo '</a>'; |
109 | 109 | } else { |
110 | 110 | echo '-'; |
111 | 111 | } |
112 | 112 | break; |
113 | 113 | case 'earnings': |
114 | - if ( current_user_can( 'view_give_forms_stats', $post_id ) ) { |
|
115 | - echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">'; |
|
116 | - echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) ); |
|
114 | + if (current_user_can('view_give_forms_stats', $post_id)) { |
|
115 | + echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">'; |
|
116 | + echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id))); |
|
117 | 117 | echo '</a>'; |
118 | 118 | } else { |
119 | 119 | echo '-'; |
120 | 120 | } |
121 | 121 | break; |
122 | 122 | case 'shortcode': |
123 | - echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="' . absint( $post_id ) . '"]">'; |
|
123 | + echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id="'.absint($post_id).'"]">'; |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | -add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 ); |
|
129 | +add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2); |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * Registers the sortable columns in the list table |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return array $columns Array of sortable columns |
139 | 139 | */ |
140 | -function give_sortable_form_columns( $columns ) { |
|
140 | +function give_sortable_form_columns($columns) { |
|
141 | 141 | $columns['price'] = 'price'; |
142 | 142 | $columns['sales'] = 'sales'; |
143 | 143 | $columns['earnings'] = 'earnings'; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | return $columns; |
147 | 147 | } |
148 | 148 | |
149 | -add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' ); |
|
149 | +add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns'); |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Sorts Columns in the Forms List Table |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return array $vars Array of all the sort variables |
159 | 159 | */ |
160 | -function give_sort_forms( $vars ) { |
|
160 | +function give_sort_forms($vars) { |
|
161 | 161 | // Check if we're viewing the "give_forms" post type |
162 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
162 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
163 | 163 | // Check if 'orderby' is set to "sales" |
164 | - if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) { |
|
164 | + if (isset($vars['orderby']) && 'sales' == $vars['orderby']) { |
|
165 | 165 | $vars = array_merge( |
166 | 166 | $vars, |
167 | 167 | array( |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | // Check if "orderby" is set to "earnings" |
175 | - if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) { |
|
175 | + if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) { |
|
176 | 176 | $vars = array_merge( |
177 | 177 | $vars, |
178 | 178 | array( |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | // Check if "orderby" is set to "price" |
186 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
186 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
187 | 187 | $vars = array_merge( |
188 | 188 | $vars, |
189 | 189 | array( |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | // Check if "orderby" is set to "goal" |
197 | - if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) { |
|
197 | + if (isset($vars['orderby']) && 'goal' == $vars['orderby']) { |
|
198 | 198 | $vars = array_merge( |
199 | 199 | $vars, |
200 | 200 | array( |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return array Array of all sort variables |
219 | 219 | */ |
220 | -function give_filter_forms( $vars ) { |
|
221 | - if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) { |
|
220 | +function give_filter_forms($vars) { |
|
221 | + if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) { |
|
222 | 222 | |
223 | 223 | // If an author ID was passed, use it |
224 | - if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) { |
|
224 | + if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) { |
|
225 | 225 | |
226 | 226 | $author_id = $_REQUEST['author']; |
227 | - if ( (int) $author_id !== get_current_user_id() ) { |
|
227 | + if ((int) $author_id !== get_current_user_id()) { |
|
228 | 228 | // Tried to view the products of another person, sorry |
229 | - wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
229 | + wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
230 | 230 | } |
231 | 231 | $vars = array_merge( |
232 | 232 | $vars, |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | * @return void |
252 | 252 | */ |
253 | 253 | function give_forms_load() { |
254 | - add_filter( 'request', 'give_sort_forms' ); |
|
255 | - add_filter( 'request', 'give_filter_forms' ); |
|
254 | + add_filter('request', 'give_sort_forms'); |
|
255 | + add_filter('request', 'give_filter_forms'); |
|
256 | 256 | } |
257 | 257 | |
258 | -add_action( 'load-edit.php', 'give_forms_load', 9999 ); |
|
258 | +add_action('load-edit.php', 'give_forms_load', 9999); |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Remove Forms Month Filter |
@@ -269,17 +269,17 @@ discard block |
||
269 | 269 | * @global $typenow The post type we are viewing |
270 | 270 | * @return array Empty array disables the dropdown |
271 | 271 | */ |
272 | -function give_remove_month_filter( $dates ) { |
|
272 | +function give_remove_month_filter($dates) { |
|
273 | 273 | global $typenow; |
274 | 274 | |
275 | - if ( $typenow == 'give_forms' ) { |
|
275 | + if ($typenow == 'give_forms') { |
|
276 | 276 | $dates = array(); |
277 | 277 | } |
278 | 278 | |
279 | 279 | return $dates; |
280 | 280 | } |
281 | 281 | |
282 | -add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 ); |
|
282 | +add_filter('months_dropdown_results', 'give_remove_month_filter', 99); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Adds price field to Quick Edit options |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @return void |
293 | 293 | */ |
294 | -function give_price_field_quick_edit( $column_name, $post_type ) { |
|
295 | - if ( $column_name != 'price' || $post_type != 'give_forms' ) { |
|
294 | +function give_price_field_quick_edit($column_name, $post_type) { |
|
295 | + if ($column_name != 'price' || $post_type != 'give_forms') { |
|
296 | 296 | return; |
297 | 297 | } |
298 | 298 | ?> |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | <h4><?php |
302 | 302 | printf( |
303 | 303 | /* translators: %s: forms singular label */ |
304 | - esc_html__( '%s Configuration', 'give' ), |
|
304 | + esc_html__('%s Configuration', 'give'), |
|
305 | 305 | give_get_forms_label_singular() |
306 | 306 | ); |
307 | 307 | ?></h4> |
308 | 308 | <label> |
309 | - <span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span> |
|
309 | + <span class="title"><?php esc_html_e('Price', 'give'); ?></span> |
|
310 | 310 | <span class="input-text-wrap"> |
311 | 311 | <input type="text" name="_give_regprice" class="text regprice" /> |
312 | 312 | </span> |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | <?php |
318 | 318 | } |
319 | 319 | |
320 | -add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 ); |
|
321 | -add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 ); |
|
320 | +add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2); |
|
321 | +add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2); |
|
322 | 322 | |
323 | 323 | /** |
324 | 324 | * Updates price when saving post |
@@ -329,23 +329,23 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @return void |
331 | 331 | */ |
332 | -function give_price_save_quick_edit( $post_id ) { |
|
333 | - if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) { |
|
332 | +function give_price_save_quick_edit($post_id) { |
|
333 | + if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
336 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
337 | 337 | return $post_id; |
338 | 338 | } |
339 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
339 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
340 | 340 | return $post_id; |
341 | 341 | } |
342 | 342 | |
343 | - if ( isset( $_REQUEST['_give_regprice'] ) ) { |
|
344 | - update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) ); |
|
343 | + if (isset($_REQUEST['_give_regprice'])) { |
|
344 | + update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice']))); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | -add_action( 'save_post', 'give_price_save_quick_edit' ); |
|
348 | +add_action('save_post', 'give_price_save_quick_edit'); |
|
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Process bulk edit actions via AJAX |
@@ -355,18 +355,18 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function give_save_bulk_edit() { |
357 | 357 | |
358 | - $post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array(); |
|
358 | + $post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); |
|
359 | 359 | |
360 | - if ( ! empty( $post_ids ) && is_array( $post_ids ) ) { |
|
361 | - $price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0; |
|
362 | - foreach ( $post_ids as $post_id ) { |
|
360 | + if ( ! empty($post_ids) && is_array($post_ids)) { |
|
361 | + $price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0; |
|
362 | + foreach ($post_ids as $post_id) { |
|
363 | 363 | |
364 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
364 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
365 | 365 | continue; |
366 | 366 | } |
367 | 367 | |
368 | - if ( ! empty( $price ) ) { |
|
369 | - update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) ); |
|
368 | + if ( ! empty($price)) { |
|
369 | + update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price)); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
@@ -374,4 +374,4 @@ discard block |
||
374 | 374 | die(); |
375 | 375 | } |
376 | 376 | |
377 | -add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' ); |
|
377 | +add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit'); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_system_info_callback() { |
26 | 26 | |
27 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
27 | + if ( ! current_user_can('manage_give_settings')) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | ?> |
31 | - <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give' ); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
31 | + <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" title="<?php esc_attr_e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give'); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
32 | 32 | <p class="submit"> |
33 | 33 | <input type="hidden" name="give-action" value="download_sysinfo"/> |
34 | - <?php submit_button( esc_html__( 'Download System Info File', 'give' ), 'secondary', 'give-download-sysinfo', false ); ?> |
|
34 | + <?php submit_button(esc_html__('Download System Info File', 'give'), 'secondary', 'give-download-sysinfo', false); ?> |
|
35 | 35 | </p> |
36 | 36 | <?php |
37 | 37 | } |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @return bool |
48 | 48 | */ |
49 | 49 | function give_allow_sessions_for_sysinfo() { |
50 | - if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
|
50 | + if (is_admin() && (isset($_GET['page']) && isset($_GET['tab'])) && ($_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings')) { |
|
51 | 51 | return true; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -add_filter( 'give_start_session', 'give_allow_sessions_for_sysinfo' ); |
|
55 | +add_filter('give_start_session', 'give_allow_sessions_for_sysinfo'); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -67,63 +67,63 @@ discard block |
||
67 | 67 | function give_tools_sysinfo_get() { |
68 | 68 | global $wpdb, $give_options; |
69 | 69 | |
70 | - if ( ! class_exists( 'Browser' ) ) { |
|
71 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; |
|
70 | + if ( ! class_exists('Browser')) { |
|
71 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $browser = new Browser(); |
75 | 75 | |
76 | 76 | // Get theme info |
77 | - if ( get_bloginfo( 'version' ) < '3.4' ) { |
|
78 | - $theme_data = wp_get_theme( get_stylesheet_directory() . '/style.css' ); |
|
79 | - $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; |
|
77 | + if (get_bloginfo('version') < '3.4') { |
|
78 | + $theme_data = wp_get_theme(get_stylesheet_directory().'/style.css'); |
|
79 | + $theme = $theme_data['Name'].' '.$theme_data['Version']; |
|
80 | 80 | } else { |
81 | 81 | $theme_data = wp_get_theme(); |
82 | - $theme = $theme_data->Name . ' ' . $theme_data->Version; |
|
82 | + $theme = $theme_data->Name.' '.$theme_data->Version; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Try to identify the hosting provider |
86 | 86 | $host = give_get_host(); |
87 | 87 | |
88 | - $return = '### Begin System Info ###' . "\n\n"; |
|
88 | + $return = '### Begin System Info ###'."\n\n"; |
|
89 | 89 | |
90 | 90 | // Start with the basics... |
91 | - $return .= '-- Site Info' . "\n\n"; |
|
92 | - $return .= 'Site URL: ' . site_url() . "\n"; |
|
93 | - $return .= 'Home URL: ' . home_url() . "\n"; |
|
94 | - $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n"; |
|
91 | + $return .= '-- Site Info'."\n\n"; |
|
92 | + $return .= 'Site URL: '.site_url()."\n"; |
|
93 | + $return .= 'Home URL: '.home_url()."\n"; |
|
94 | + $return .= 'Multisite: '.(is_multisite() ? 'Yes' : 'No')."\n"; |
|
95 | 95 | |
96 | - $return = apply_filters( 'give_sysinfo_after_site_info', $return ); |
|
96 | + $return = apply_filters('give_sysinfo_after_site_info', $return); |
|
97 | 97 | |
98 | 98 | // Can we determine the site's host? |
99 | - if ( $host ) { |
|
100 | - $return .= "\n" . '-- Hosting Provider' . "\n\n"; |
|
101 | - $return .= 'Host: ' . $host . "\n"; |
|
99 | + if ($host) { |
|
100 | + $return .= "\n".'-- Hosting Provider'."\n\n"; |
|
101 | + $return .= 'Host: '.$host."\n"; |
|
102 | 102 | |
103 | - $return = apply_filters( 'give_sysinfo_after_host_info', $return ); |
|
103 | + $return = apply_filters('give_sysinfo_after_host_info', $return); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // The local users' browser information, handled by the Browser class |
107 | - $return .= "\n" . '-- User Browser' . "\n\n"; |
|
107 | + $return .= "\n".'-- User Browser'."\n\n"; |
|
108 | 108 | $return .= $browser; |
109 | 109 | |
110 | - $return = apply_filters( 'give_sysinfo_after_user_browser', $return ); |
|
110 | + $return = apply_filters('give_sysinfo_after_user_browser', $return); |
|
111 | 111 | |
112 | 112 | // WordPress configuration |
113 | - $return .= "\n" . '-- WordPress Configuration' . "\n\n"; |
|
114 | - $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n"; |
|
115 | - $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; |
|
116 | - $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n"; |
|
117 | - $return .= 'Active Theme: ' . $theme . "\n"; |
|
118 | - $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n"; |
|
113 | + $return .= "\n".'-- WordPress Configuration'."\n\n"; |
|
114 | + $return .= 'Version: '.get_bloginfo('version')."\n"; |
|
115 | + $return .= 'Language: '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n"; |
|
116 | + $return .= 'Permalink Structure: '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n"; |
|
117 | + $return .= 'Active Theme: '.$theme."\n"; |
|
118 | + $return .= 'Show On Front: '.get_option('show_on_front')."\n"; |
|
119 | 119 | |
120 | 120 | // Only show page specs if frontpage is set to 'page' |
121 | - if ( get_option( 'show_on_front' ) == 'page' ) { |
|
122 | - $front_page_id = get_option( 'page_on_front' ); |
|
123 | - $blog_page_id = get_option( 'page_for_posts' ); |
|
121 | + if (get_option('show_on_front') == 'page') { |
|
122 | + $front_page_id = get_option('page_on_front'); |
|
123 | + $blog_page_id = get_option('page_for_posts'); |
|
124 | 124 | |
125 | - $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; |
|
126 | - $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; |
|
125 | + $return .= 'Page On Front: '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n"; |
|
126 | + $return .= 'Page For Posts: '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n"; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // Make sure wp_remote_post() is working |
@@ -132,205 +132,205 @@ discard block |
||
132 | 132 | $params = array( |
133 | 133 | 'sslverify' => false, |
134 | 134 | 'timeout' => 60, |
135 | - 'user-agent' => 'Give/' . GIVE_VERSION, |
|
135 | + 'user-agent' => 'Give/'.GIVE_VERSION, |
|
136 | 136 | 'body' => $request |
137 | 137 | ); |
138 | 138 | |
139 | - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
139 | + $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); |
|
140 | 140 | |
141 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
141 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
142 | 142 | $WP_REMOTE_POST = 'wp_remote_post() works'; |
143 | 143 | } else { |
144 | 144 | $WP_REMOTE_POST = 'wp_remote_post() does not work'; |
145 | 145 | } |
146 | 146 | |
147 | - $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; |
|
148 | - $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; |
|
149 | - $return .= 'Admin AJAX: ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n"; |
|
150 | - $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n"; |
|
151 | - $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; |
|
152 | - $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n"; |
|
147 | + $return .= 'Remote Post: '.$WP_REMOTE_POST."\n"; |
|
148 | + $return .= 'Table Prefix: '.'Length: '.strlen($wpdb->prefix).' Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n"; |
|
149 | + $return .= 'Admin AJAX: '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n"; |
|
150 | + $return .= 'WP_DEBUG: '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n"; |
|
151 | + $return .= 'Memory Limit: '.WP_MEMORY_LIMIT."\n"; |
|
152 | + $return .= 'Registered Post Stati: '.implode(', ', get_post_stati())."\n"; |
|
153 | 153 | |
154 | - $return = apply_filters( 'give_sysinfo_after_wordpress_config', $return ); |
|
154 | + $return = apply_filters('give_sysinfo_after_wordpress_config', $return); |
|
155 | 155 | |
156 | 156 | // GIVE configuration |
157 | - $return .= "\n" . '-- Give Configuration' . "\n\n"; |
|
158 | - $return .= 'Version: ' . GIVE_VERSION . "\n"; |
|
159 | - $return .= 'Upgraded From: ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n"; |
|
160 | - $return .= 'Test Mode: ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" ); |
|
161 | - $return .= 'Currency Code: ' . give_get_currency() . "\n"; |
|
162 | - $return .= 'Currency Position: ' . give_get_option( 'currency_position', 'before' ) . "\n"; |
|
163 | - $return .= 'Decimal Separator: ' . give_get_option( 'decimal_separator', '.' ) . "\n"; |
|
164 | - $return .= 'Thousands Separator: ' . give_get_option( 'thousands_separator', ',' ) . "\n"; |
|
157 | + $return .= "\n".'-- Give Configuration'."\n\n"; |
|
158 | + $return .= 'Version: '.GIVE_VERSION."\n"; |
|
159 | + $return .= 'Upgraded From: '.get_option('give_version_upgraded_from', 'None')."\n"; |
|
160 | + $return .= 'Test Mode: '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n"); |
|
161 | + $return .= 'Currency Code: '.give_get_currency()."\n"; |
|
162 | + $return .= 'Currency Position: '.give_get_option('currency_position', 'before')."\n"; |
|
163 | + $return .= 'Decimal Separator: '.give_get_option('decimal_separator', '.')."\n"; |
|
164 | + $return .= 'Thousands Separator: '.give_get_option('thousands_separator', ',')."\n"; |
|
165 | 165 | |
166 | - $return = apply_filters( 'give_sysinfo_after_give_config', $return ); |
|
166 | + $return = apply_filters('give_sysinfo_after_give_config', $return); |
|
167 | 167 | |
168 | 168 | // GIVE pages |
169 | - $return .= "\n" . '-- Give Page Configuration' . "\n\n"; |
|
170 | - $return .= 'Success Page: ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" ); |
|
171 | - $return .= 'Failure Page: ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" ); |
|
172 | - $return .= 'Give Forms Slug: ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" ); |
|
169 | + $return .= "\n".'-- Give Page Configuration'."\n\n"; |
|
170 | + $return .= 'Success Page: '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n"); |
|
171 | + $return .= 'Failure Page: '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n"); |
|
172 | + $return .= 'Give Forms Slug: '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n"); |
|
173 | 173 | |
174 | - $return = apply_filters( 'give_sysinfo_after_give_pages', $return ); |
|
174 | + $return = apply_filters('give_sysinfo_after_give_pages', $return); |
|
175 | 175 | |
176 | 176 | // GIVE gateways |
177 | - $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; |
|
177 | + $return .= "\n".'-- Give Gateway Configuration'."\n\n"; |
|
178 | 178 | |
179 | 179 | $active_gateways = give_get_enabled_payment_gateways(); |
180 | - if ( $active_gateways ) { |
|
181 | - $default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) ); |
|
182 | - if ( $default_gateway_is_active ) { |
|
183 | - $default_gateway = give_get_default_gateway( null ); |
|
184 | - $default_gateway = $active_gateways[ $default_gateway ]['admin_label']; |
|
180 | + if ($active_gateways) { |
|
181 | + $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); |
|
182 | + if ($default_gateway_is_active) { |
|
183 | + $default_gateway = give_get_default_gateway(null); |
|
184 | + $default_gateway = $active_gateways[$default_gateway]['admin_label']; |
|
185 | 185 | } else { |
186 | 186 | $default_gateway = 'Test Payment'; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $gateways = array(); |
190 | - foreach ( $active_gateways as $gateway ) { |
|
190 | + foreach ($active_gateways as $gateway) { |
|
191 | 191 | $gateways[] = $gateway['admin_label']; |
192 | 192 | } |
193 | 193 | |
194 | - $return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n"; |
|
195 | - $return .= 'Default Gateway: ' . $default_gateway . "\n"; |
|
194 | + $return .= 'Enabled Gateways: '.implode(', ', $gateways)."\n"; |
|
195 | + $return .= 'Default Gateway: '.$default_gateway."\n"; |
|
196 | 196 | } else { |
197 | - $return .= 'Enabled Gateways: None' . "\n"; |
|
197 | + $return .= 'Enabled Gateways: None'."\n"; |
|
198 | 198 | } |
199 | 199 | |
200 | - $return = apply_filters( 'give_sysinfo_after_give_gateways', $return ); |
|
200 | + $return = apply_filters('give_sysinfo_after_give_gateways', $return); |
|
201 | 201 | |
202 | 202 | // GIVE Templates |
203 | - $dir = get_stylesheet_directory() . '/give_templates/*'; |
|
204 | - if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) { |
|
205 | - $return .= "\n" . '-- Give Template Overrides' . "\n\n"; |
|
203 | + $dir = get_stylesheet_directory().'/give_templates/*'; |
|
204 | + if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) { |
|
205 | + $return .= "\n".'-- Give Template Overrides'."\n\n"; |
|
206 | 206 | |
207 | - foreach ( glob( $dir ) as $file ) { |
|
208 | - $return .= 'Filename: ' . basename( $file ) . "\n"; |
|
207 | + foreach (glob($dir) as $file) { |
|
208 | + $return .= 'Filename: '.basename($file)."\n"; |
|
209 | 209 | } |
210 | 210 | |
211 | - $return = apply_filters( 'give_sysinfo_after_give_templates', $return ); |
|
211 | + $return = apply_filters('give_sysinfo_after_give_templates', $return); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Must-use plugins |
215 | 215 | $muplugins = get_mu_plugins(); |
216 | - if ( count( $muplugins > 0 ) ) { |
|
217 | - $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; |
|
216 | + if (count($muplugins > 0)) { |
|
217 | + $return .= "\n".'-- Must-Use Plugins'."\n\n"; |
|
218 | 218 | |
219 | - foreach ( $muplugins as $plugin => $plugin_data ) { |
|
220 | - $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
|
219 | + foreach ($muplugins as $plugin => $plugin_data) { |
|
220 | + $return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n"; |
|
221 | 221 | } |
222 | 222 | |
223 | - $return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return ); |
|
223 | + $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | // WordPress active plugins |
227 | - $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; |
|
227 | + $return .= "\n".'-- WordPress Active Plugins'."\n\n"; |
|
228 | 228 | |
229 | 229 | $plugins = get_plugins(); |
230 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
230 | + $active_plugins = get_option('active_plugins', array()); |
|
231 | 231 | |
232 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
233 | - if ( ! in_array( $plugin_path, $active_plugins ) ) { |
|
232 | + foreach ($plugins as $plugin_path => $plugin) { |
|
233 | + if ( ! in_array($plugin_path, $active_plugins)) { |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
237 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
238 | 238 | } |
239 | 239 | |
240 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return ); |
|
240 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); |
|
241 | 241 | |
242 | 242 | // WordPress inactive plugins |
243 | - $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
|
243 | + $return .= "\n".'-- WordPress Inactive Plugins'."\n\n"; |
|
244 | 244 | |
245 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
246 | - if ( in_array( $plugin_path, $active_plugins ) ) { |
|
245 | + foreach ($plugins as $plugin_path => $plugin) { |
|
246 | + if (in_array($plugin_path, $active_plugins)) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
250 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
251 | 251 | } |
252 | 252 | |
253 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return ); |
|
253 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); |
|
254 | 254 | |
255 | - if ( is_multisite() ) { |
|
255 | + if (is_multisite()) { |
|
256 | 256 | // WordPress Multisite active plugins |
257 | - $return .= "\n" . '-- Network Active Plugins' . "\n\n"; |
|
257 | + $return .= "\n".'-- Network Active Plugins'."\n\n"; |
|
258 | 258 | |
259 | 259 | $plugins = wp_get_active_network_plugins(); |
260 | - $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); |
|
260 | + $active_plugins = get_site_option('active_sitewide_plugins', array()); |
|
261 | 261 | |
262 | - foreach ( $plugins as $plugin_path ) { |
|
263 | - $plugin_base = plugin_basename( $plugin_path ); |
|
262 | + foreach ($plugins as $plugin_path) { |
|
263 | + $plugin_base = plugin_basename($plugin_path); |
|
264 | 264 | |
265 | - if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
|
265 | + if ( ! array_key_exists($plugin_base, $active_plugins)) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | - $plugin = get_plugin_data( $plugin_path ); |
|
270 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
269 | + $plugin = get_plugin_data($plugin_path); |
|
270 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
271 | 271 | } |
272 | 272 | |
273 | - $return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return ); |
|
273 | + $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Server configuration (really just versioning) |
277 | - $return .= "\n" . '-- Webserver Configuration' . "\n\n"; |
|
278 | - $return .= 'PHP Version: ' . PHP_VERSION . "\n"; |
|
279 | - $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; |
|
280 | - $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
277 | + $return .= "\n".'-- Webserver Configuration'."\n\n"; |
|
278 | + $return .= 'PHP Version: '.PHP_VERSION."\n"; |
|
279 | + $return .= 'MySQL Version: '.$wpdb->db_version()."\n"; |
|
280 | + $return .= 'Webserver Info: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
|
281 | 281 | |
282 | - $return = apply_filters( 'give_sysinfo_after_webserver_config', $return ); |
|
282 | + $return = apply_filters('give_sysinfo_after_webserver_config', $return); |
|
283 | 283 | |
284 | 284 | // PHP configs... now we're getting to the important stuff |
285 | - $return .= "\n" . '-- PHP Configuration' . "\n\n"; |
|
286 | - $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" ); |
|
287 | - $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n"; |
|
288 | - $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
289 | - $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n"; |
|
290 | - $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
291 | - $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n"; |
|
292 | - $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n"; |
|
293 | - $return .= 'URL-aware fopen: ' . ( ini_get( 'allow_url_fopen' ) ? 'On (' . ini_get( 'allow_url_fopen' ) . ')' : 'N/A' ) . "\n"; |
|
294 | - $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n"; |
|
295 | - |
|
296 | - $return = apply_filters( 'give_sysinfo_after_php_config', $return ); |
|
285 | + $return .= "\n".'-- PHP Configuration'."\n\n"; |
|
286 | + $return .= 'Safe Mode: '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n"); |
|
287 | + $return .= 'Memory Limit: '.ini_get('memory_limit')."\n"; |
|
288 | + $return .= 'Upload Max Size: '.ini_get('upload_max_filesize')."\n"; |
|
289 | + $return .= 'Post Max Size: '.ini_get('post_max_size')."\n"; |
|
290 | + $return .= 'Upload Max Filesize: '.ini_get('upload_max_filesize')."\n"; |
|
291 | + $return .= 'Time Limit: '.ini_get('max_execution_time')."\n"; |
|
292 | + $return .= 'Max Input Vars: '.ini_get('max_input_vars')."\n"; |
|
293 | + $return .= 'URL-aware fopen: '.(ini_get('allow_url_fopen') ? 'On ('.ini_get('allow_url_fopen').')' : 'N/A')."\n"; |
|
294 | + $return .= 'Display Errors: '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n"; |
|
295 | + |
|
296 | + $return = apply_filters('give_sysinfo_after_php_config', $return); |
|
297 | 297 | |
298 | 298 | // PHP extensions and such |
299 | - $return .= "\n" . '-- PHP Extensions' . "\n\n"; |
|
300 | - $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
299 | + $return .= "\n".'-- PHP Extensions'."\n\n"; |
|
300 | + $return .= 'cURL: '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n"; |
|
301 | 301 | |
302 | 302 | //cURL version |
303 | - if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) { |
|
303 | + if (function_exists('curl_init') && function_exists('curl_version')) { |
|
304 | 304 | $curl_values = curl_version(); |
305 | - $return .= 'cURL Version: ' . $curl_values["version"] . "\n"; |
|
305 | + $return .= 'cURL Version: '.$curl_values["version"]."\n"; |
|
306 | 306 | } |
307 | - $return .= 'zlib: ' . ( function_exists( 'gzcompress' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
308 | - $return .= 'GD: ' . ( ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
309 | - $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
310 | - $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
311 | - $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
312 | - $return .= 'DOM: ' . ( extension_loaded( 'dom' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
313 | - $return .= 'MBString: ' . ( extension_loaded( 'mbstring' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
307 | + $return .= 'zlib: '.(function_exists('gzcompress') ? 'Supported' : 'Not Supported')."\n"; |
|
308 | + $return .= 'GD: '.((extension_loaded('gd') && function_exists('gd_info')) ? 'Supported' : 'Not Supported')."\n"; |
|
309 | + $return .= 'fsockopen: '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n"; |
|
310 | + $return .= 'SOAP Client: '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n"; |
|
311 | + $return .= 'Suhosin: '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n"; |
|
312 | + $return .= 'DOM: '.(extension_loaded('dom') ? 'Installed' : 'Not Installed')."\n"; |
|
313 | + $return .= 'MBString: '.(extension_loaded('mbstring') ? 'Installed' : 'Not Installed')."\n"; |
|
314 | 314 | |
315 | - $return = apply_filters( 'give_sysinfo_after_php_ext', $return ); |
|
315 | + $return = apply_filters('give_sysinfo_after_php_ext', $return); |
|
316 | 316 | |
317 | 317 | // Session stuff |
318 | - $return .= "\n" . '-- Session Configuration' . "\n\n"; |
|
319 | - $return .= 'Give Use Sessions: ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n"; |
|
320 | - $return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; |
|
318 | + $return .= "\n".'-- Session Configuration'."\n\n"; |
|
319 | + $return .= 'Give Use Sessions: '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n"; |
|
320 | + $return .= 'Session: '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n"; |
|
321 | 321 | |
322 | 322 | // The rest of this is only relevant is session is enabled |
323 | - if ( isset( $_SESSION ) ) { |
|
324 | - $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n"; |
|
325 | - $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n"; |
|
326 | - $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n"; |
|
327 | - $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
328 | - $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
323 | + if (isset($_SESSION)) { |
|
324 | + $return .= 'Session Name: '.esc_html(ini_get('session.name'))."\n"; |
|
325 | + $return .= 'Cookie Path: '.esc_html(ini_get('session.cookie_path'))."\n"; |
|
326 | + $return .= 'Save Path: '.esc_html(ini_get('session.save_path'))."\n"; |
|
327 | + $return .= 'Use Cookies: '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n"; |
|
328 | + $return .= 'Use Only Cookies: '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n"; |
|
329 | 329 | } |
330 | 330 | |
331 | - $return = apply_filters( 'give_sysinfo_after_session_config', $return ); |
|
331 | + $return = apply_filters('give_sysinfo_after_session_config', $return); |
|
332 | 332 | |
333 | - $return .= "\n" . '### End System Info ###'; |
|
333 | + $return .= "\n".'### End System Info ###'; |
|
334 | 334 | |
335 | 335 | return $return; |
336 | 336 | } |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | */ |
345 | 345 | function give_tools_sysinfo_download() { |
346 | 346 | |
347 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
347 | + if ( ! current_user_can('manage_give_settings')) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | 351 | nocache_headers(); |
352 | 352 | |
353 | - header( 'Content-Type: text/plain' ); |
|
354 | - header( 'Content-Disposition: attachment; filename="give-system-info.txt"' ); |
|
353 | + header('Content-Type: text/plain'); |
|
354 | + header('Content-Disposition: attachment; filename="give-system-info.txt"'); |
|
355 | 355 | |
356 | - echo wp_strip_all_tags( $_POST['give-sysinfo'] ); |
|
356 | + echo wp_strip_all_tags($_POST['give-sysinfo']); |
|
357 | 357 | give_die(); |
358 | 358 | } |
359 | 359 | |
360 | -add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' ); |
|
361 | 360 | \ No newline at end of file |
361 | +add_action('give_download_sysinfo', 'give_tools_sysinfo_download'); |
|
362 | 362 | \ No newline at end of file |