|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
3
|
|
|
* Admin Actions |
|
4
|
|
|
* |
|
5
|
|
|
* @package Give |
|
6
|
|
|
* @subpackage Admin/Actions |
|
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
|
8
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
|
9
|
|
|
* @since 1.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// Exit if accessed directly. |
|
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
14
|
|
|
exit; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Load wp editor by ajax. |
|
19
|
|
|
* |
|
20
|
|
|
* @since 1.8 |
|
21
|
|
|
*/ |
|
22
|
|
|
function give_load_wp_editor() { |
|
23
|
|
|
if ( ! isset( $_POST['wp_editor'] ) ) { |
|
24
|
|
|
die(); |
|
|
|
|
|
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
$wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
|
28
|
|
|
$wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
|
29
|
|
|
|
|
30
|
|
|
wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
|
31
|
|
|
|
|
32
|
|
|
die(); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
add_action( 'wp_ajax_give_load_wp_editor', 'give_load_wp_editor' ); |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Redirect admin to clean url give admin pages. |
|
40
|
|
|
* |
|
41
|
|
|
* @since 1.8 |
|
42
|
|
|
* |
|
43
|
|
|
* @return bool |
|
|
|
|
|
|
44
|
|
|
*/ |
|
45
|
|
|
function give_redirect_to_clean_url_admin_pages() { |
|
46
|
|
|
// Give admin pages. |
|
47
|
|
|
$give_pages = array( |
|
48
|
|
|
'give-payment-history', |
|
49
|
|
|
'give-donors', |
|
50
|
|
|
'give-reports' |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
// Get current page. |
|
54
|
|
|
$current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
|
55
|
|
|
|
|
56
|
|
|
// Bailout. |
|
57
|
|
|
if ( |
|
58
|
|
|
empty( $current_page ) |
|
59
|
|
|
|| empty( $_GET['_wp_http_referer'] ) |
|
60
|
|
|
|| ! in_array( $current_page, $give_pages ) |
|
61
|
|
|
) { |
|
62
|
|
|
return false; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Verify current page request. |
|
67
|
|
|
* |
|
68
|
|
|
* @since 1.8 |
|
69
|
|
|
*/ |
|
70
|
|
|
$redirect = apply_filters( "give_validate_{$current_page}", true ); |
|
71
|
|
|
|
|
72
|
|
|
if ( $redirect ) { |
|
73
|
|
|
// Redirect. |
|
74
|
|
|
wp_redirect( |
|
75
|
|
|
remove_query_arg( |
|
76
|
|
|
array( '_wp_http_referer', '_wpnonce' ), |
|
77
|
|
|
wp_unslash( $_SERVER['REQUEST_URI'] ) |
|
78
|
|
|
) |
|
79
|
|
|
); |
|
80
|
|
|
exit; |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Hide Outdated PHP Notice Shortly. |
|
89
|
|
|
* |
|
90
|
|
|
* This code is used with AJAX call to hide outdated PHP notice for a short period of time |
|
91
|
|
|
* |
|
92
|
|
|
* @since 1.8.9 |
|
93
|
|
|
* |
|
94
|
|
|
* @return void |
|
95
|
|
|
*/ |
|
96
|
|
|
function give_hide_outdated_php_notice() { |
|
97
|
|
|
|
|
98
|
|
|
if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
|
99
|
|
|
give_die(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// Transient key name. |
|
103
|
|
|
$transient_key = "_give_hide_outdated_php_notices_shortly"; |
|
104
|
|
|
|
|
105
|
|
|
if ( Give_Cache::get( $transient_key, true ) ) { |
|
106
|
|
|
return; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Hide notice for 24 hours. |
|
110
|
|
|
Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
|
111
|
|
|
|
|
112
|
|
|
give_die(); |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Register admin notices. |
|
120
|
|
|
* |
|
121
|
|
|
* @since 1.8.9 |
|
122
|
|
|
*/ |
|
123
|
|
|
function _give_register_admin_notices() { |
|
124
|
|
|
// Bailout. |
|
125
|
|
|
if( ! is_admin() ) { |
|
126
|
|
|
return; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
// Add ajax disabled notice. |
|
130
|
|
|
if ( ! give_test_ajax_works() && current_user_can( 'manage_give_settings' ) ) { |
|
131
|
|
|
// Delete notice render blocker. |
|
132
|
|
|
Give_Cache::delete( 'give_cache_' . Give()->notices->get_notice_key( 'give-ajax-not-working', 'permanent' ) ); |
|
133
|
|
|
|
|
134
|
|
|
// Set notice message |
|
135
|
|
|
$notice_desc = '<p>' . __( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
136
|
|
|
$notice_desc .= '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'http://docs.givewp.com/ajax-blocked' ) ) . '</p>'; |
|
137
|
|
|
$notice_desc .= sprintf( |
|
138
|
|
|
'<p>%s</p>', |
|
139
|
|
|
Give()->notices->get_dismiss_link(array( |
|
140
|
|
|
'title' => __( 'Dismiss Notice', 'give' ), |
|
141
|
|
|
'dismissible_type' => 'all', |
|
142
|
|
|
'dismiss_interval' => 'permanent', |
|
143
|
|
|
)) |
|
144
|
|
|
); |
|
145
|
|
|
|
|
146
|
|
|
Give()->notices->register_notice( array( |
|
147
|
|
|
'id' => 'give-ajax-not-working', |
|
148
|
|
|
'type' => 'updated', |
|
149
|
|
|
'description' => $notice_desc, |
|
150
|
|
|
'dismissible_type' => 'all', |
|
151
|
|
|
'dismiss_interval' => 'permanent', |
|
152
|
|
|
) ); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
// Add PHP version update notice |
|
156
|
|
|
if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
|
157
|
|
|
|
|
158
|
|
|
$notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
|
159
|
|
|
$notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>'; |
|
160
|
|
|
$notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>'; |
|
161
|
|
|
$notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
|
162
|
|
|
$notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>'; |
|
163
|
|
|
$notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
|
164
|
|
|
$notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>'; |
|
165
|
|
|
|
|
166
|
|
|
Give()->notices->register_notice( array( |
|
167
|
|
|
'id' => 'give-invalid-php-version', |
|
168
|
|
|
'type' => 'error', |
|
169
|
|
|
'description' => $notice_desc, |
|
170
|
|
|
'dismissible_type' => 'user', |
|
171
|
|
|
'dismiss_interval' => 'shortly', |
|
172
|
|
|
) ); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
// Add payment bulk notice. |
|
176
|
|
|
if ( |
|
177
|
|
|
current_user_can( 'edit_give_payments' ) |
|
178
|
|
|
&& isset( $_GET['action'] ) |
|
179
|
|
|
&& ! empty( $_GET['action'] ) |
|
180
|
|
|
&& isset( $_GET['payment'] ) |
|
181
|
|
|
&& ! empty( $_GET['payment'] ) |
|
182
|
|
|
) { |
|
183
|
|
|
$payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
|
184
|
|
|
|
|
185
|
|
|
switch ( $_GET['action'] ) { |
|
186
|
|
|
case 'delete': |
|
187
|
|
|
Give()->notices->register_notice( array( |
|
188
|
|
|
'id' => 'bulk_action_delete', |
|
189
|
|
|
'type' => 'updated', |
|
190
|
|
|
'description' => sprintf( |
|
191
|
|
|
_n( |
|
192
|
|
|
'Successfully deleted only one transaction.', |
|
193
|
|
|
'Successfully deleted %d number of transactions.', |
|
194
|
|
|
$payment_count, |
|
195
|
|
|
'give' |
|
196
|
|
|
), |
|
197
|
|
|
$payment_count ), |
|
198
|
|
|
'show' => true, |
|
199
|
|
|
) ); |
|
200
|
|
|
|
|
201
|
|
|
break; |
|
202
|
|
|
|
|
203
|
|
|
case 'resend-receipt': |
|
204
|
|
|
Give()->notices->register_notice( array( |
|
205
|
|
|
'id' => 'bulk_action_resend_receipt', |
|
206
|
|
|
'type' => 'updated', |
|
207
|
|
|
'description' => sprintf( |
|
208
|
|
|
_n( |
|
209
|
|
|
'Successfully send email receipt to only one recipient.', |
|
210
|
|
|
'Successfully send email receipts to %d recipients.', |
|
211
|
|
|
$payment_count, |
|
212
|
|
|
'give' |
|
213
|
|
|
), |
|
214
|
|
|
$payment_count |
|
215
|
|
|
), |
|
216
|
|
|
'show' => true, |
|
217
|
|
|
) ); |
|
218
|
|
|
break; |
|
219
|
|
|
} |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
// Add give message notices. |
|
223
|
|
|
if ( ! empty( $_GET['give-message'] ) ) { |
|
224
|
|
|
// Donation reports errors. |
|
225
|
|
|
if ( current_user_can( 'view_give_reports' ) ) { |
|
226
|
|
|
switch ( $_GET['give-message'] ) { |
|
227
|
|
|
case 'donation_deleted' : |
|
228
|
|
|
Give()->notices->register_notice( array( |
|
229
|
|
|
'id' => 'give-donation-deleted', |
|
230
|
|
|
'type' => 'updated', |
|
231
|
|
|
'description' => __( 'The donation has been deleted.', 'give' ), |
|
232
|
|
|
'show' => true, |
|
233
|
|
|
) ); |
|
234
|
|
|
break; |
|
235
|
|
|
case 'email_sent' : |
|
236
|
|
|
Give()->notices->register_notice( array( |
|
237
|
|
|
'id' => 'give-payment-sent', |
|
238
|
|
|
'type' => 'updated', |
|
239
|
|
|
'description' => __( 'The donation receipt has been resent.', 'give' ), |
|
240
|
|
|
'show' => true, |
|
241
|
|
|
) ); |
|
242
|
|
|
break; |
|
243
|
|
|
case 'refreshed-reports' : |
|
244
|
|
|
Give()->notices->register_notice( array( |
|
245
|
|
|
'id' => 'give-refreshed-reports', |
|
246
|
|
|
'type' => 'updated', |
|
247
|
|
|
'description' => __( 'The reports cache has been cleared.', 'give' ), |
|
248
|
|
|
'show' => true, |
|
249
|
|
|
) ); |
|
250
|
|
|
break; |
|
251
|
|
|
case 'donation-note-deleted' : |
|
252
|
|
|
Give()->notices->register_notice( array( |
|
253
|
|
|
'id' => 'give-donation-note-deleted', |
|
254
|
|
|
'type' => 'updated', |
|
255
|
|
|
'description' => __( 'The donation note has been deleted.', 'give' ), |
|
256
|
|
|
'show' => true, |
|
257
|
|
|
) ); |
|
258
|
|
|
break; |
|
259
|
|
|
} |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
// Give settings notices and errors. |
|
263
|
|
|
if ( current_user_can( 'manage_give_settings' ) ) { |
|
264
|
|
|
switch ( $_GET['give-message'] ) { |
|
265
|
|
|
case 'settings-imported' : |
|
266
|
|
|
Give()->notices->register_notice( array( |
|
267
|
|
|
'id' => 'give-settings-imported', |
|
268
|
|
|
'type' => 'updated', |
|
269
|
|
|
'description' => __( 'The settings have been imported.', 'give' ), |
|
270
|
|
|
'show' => true, |
|
271
|
|
|
) ); |
|
272
|
|
|
break; |
|
273
|
|
|
case 'api-key-generated' : |
|
274
|
|
|
Give()->notices->register_notice( array( |
|
275
|
|
|
'id' => 'give-api-key-generated', |
|
276
|
|
|
'type' => 'updated', |
|
277
|
|
|
'description' => __( 'API keys have been generated.', 'give' ), |
|
278
|
|
|
'show' => true, |
|
279
|
|
|
) ); |
|
280
|
|
|
break; |
|
281
|
|
|
case 'api-key-exists' : |
|
282
|
|
|
Give()->notices->register_notice( array( |
|
283
|
|
|
'id' => 'give-api-key-exists', |
|
284
|
|
|
'type' => 'updated', |
|
285
|
|
|
'description' => __( 'The specified user already has API keys.', 'give' ), |
|
286
|
|
|
'show' => true, |
|
287
|
|
|
) ); |
|
288
|
|
|
break; |
|
289
|
|
|
case 'api-key-regenerated' : |
|
290
|
|
|
Give()->notices->register_notice( array( |
|
291
|
|
|
'id' => 'give-api-key-regenerated', |
|
292
|
|
|
'type' => 'updated', |
|
293
|
|
|
'description' => __( 'API keys have been regenerated.', 'give' ), |
|
294
|
|
|
'show' => true, |
|
295
|
|
|
) ); |
|
296
|
|
|
break; |
|
297
|
|
|
case 'api-key-revoked' : |
|
298
|
|
|
Give()->notices->register_notice( array( |
|
299
|
|
|
'id' => 'give-api-key-revoked', |
|
300
|
|
|
'type' => 'updated', |
|
301
|
|
|
'description' => __( 'API keys have been revoked.', 'give' ), |
|
302
|
|
|
'show' => true, |
|
303
|
|
|
) ); |
|
304
|
|
|
break; |
|
305
|
|
|
case 'sent-test-email' : |
|
306
|
|
|
Give()->notices->register_notice( array( |
|
307
|
|
|
'id' => 'give-sent-test-email', |
|
308
|
|
|
'type' => 'updated', |
|
309
|
|
|
'description' => __( 'The test email has been sent.', 'give' ), |
|
310
|
|
|
'show' => true, |
|
311
|
|
|
) ); |
|
312
|
|
|
break; |
|
313
|
|
|
case 'matched-success-failure-page': |
|
314
|
|
|
Give()->notices->register_notice( array( |
|
315
|
|
|
'id' => 'give-matched-success-failure-page', |
|
316
|
|
|
'type' => 'updated', |
|
317
|
|
|
'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
|
318
|
|
|
'show' => true, |
|
319
|
|
|
) ); |
|
320
|
|
|
break; |
|
321
|
|
|
} |
|
322
|
|
|
} |
|
323
|
|
|
// Payments errors. |
|
324
|
|
|
if ( current_user_can( 'edit_give_payments' ) ) { |
|
325
|
|
|
switch ( $_GET['give-message'] ) { |
|
326
|
|
|
case 'note-added' : |
|
327
|
|
|
Give()->notices->register_notice( array( |
|
328
|
|
|
'id' => 'give-note-added', |
|
329
|
|
|
'type' => 'updated', |
|
330
|
|
|
'description' => __( 'The donation note has been added.', 'give' ), |
|
331
|
|
|
'show' => true, |
|
332
|
|
|
) ); |
|
333
|
|
|
break; |
|
334
|
|
|
case 'payment-updated' : |
|
335
|
|
|
Give()->notices->register_notice( array( |
|
336
|
|
|
'id' => 'give-payment-updated', |
|
337
|
|
|
'type' => 'updated', |
|
338
|
|
|
'description' => __( 'The donation has been updated.', 'give' ), |
|
339
|
|
|
'show' => true, |
|
340
|
|
|
) ); |
|
341
|
|
|
break; |
|
342
|
|
|
} |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
// Donor Notices. |
|
346
|
|
|
if ( current_user_can( 'edit_give_payments' ) ) { |
|
347
|
|
|
switch ( $_GET['give-message'] ) { |
|
348
|
|
|
case 'donor-deleted' : |
|
349
|
|
|
Give()->notices->register_notice( array( |
|
350
|
|
|
'id' => 'give-donor-deleted', |
|
351
|
|
|
'type' => 'updated', |
|
352
|
|
|
'description' => __( 'The donor has been deleted.', 'give' ), |
|
353
|
|
|
'show' => true, |
|
354
|
|
|
) ); |
|
355
|
|
|
break; |
|
356
|
|
|
|
|
357
|
|
|
case 'email-added' : |
|
358
|
|
|
Give()->notices->register_notice( array( |
|
359
|
|
|
'id' => 'give-donor-email-added', |
|
360
|
|
|
'type' => 'updated', |
|
361
|
|
|
'description' => __( 'Donor email added.', 'give' ), |
|
362
|
|
|
'show' => true, |
|
363
|
|
|
) ); |
|
364
|
|
|
break; |
|
365
|
|
|
|
|
366
|
|
|
case 'email-removed' : |
|
367
|
|
|
Give()->notices->register_notice( array( |
|
368
|
|
|
'id' => 'give-donor-email-removed', |
|
369
|
|
|
'type' => 'updated', |
|
370
|
|
|
'description' => __( 'Donor email removed.', 'give' ), |
|
371
|
|
|
'show' => true, |
|
372
|
|
|
) ); |
|
373
|
|
|
break; |
|
374
|
|
|
|
|
375
|
|
|
case 'email-remove-failed' : |
|
376
|
|
|
Give()->notices->register_notice( array( |
|
377
|
|
|
'id' => 'give-donor-email-remove-failed', |
|
378
|
|
|
'type' => 'updated', |
|
379
|
|
|
'description' => __( 'Failed to remove donor email.', 'give' ), |
|
380
|
|
|
'show' => true, |
|
381
|
|
|
) ); |
|
382
|
|
|
break; |
|
383
|
|
|
|
|
384
|
|
|
case 'primary-email-updated' : |
|
385
|
|
|
Give()->notices->register_notice( array( |
|
386
|
|
|
'id' => 'give-donor-primary-email-updated', |
|
387
|
|
|
'type' => 'updated', |
|
388
|
|
|
'description' => __( 'Primary email updated for donor.', 'give' ), |
|
389
|
|
|
'show' => true, |
|
390
|
|
|
) ); |
|
391
|
|
|
break; |
|
392
|
|
|
|
|
393
|
|
|
case 'primary-email-failed' : |
|
394
|
|
|
Give()->notices->register_notice( array( |
|
395
|
|
|
'id' => 'give-donor-primary-email-failed', |
|
396
|
|
|
'type' => 'updated', |
|
397
|
|
|
'description' => __( 'Failed to set primary email.', 'give' ), |
|
398
|
|
|
'show' => true, |
|
399
|
|
|
) ); |
|
400
|
|
|
break; |
|
401
|
|
|
} |
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
|
407
|
|
|
|
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* Display admin bar when active. |
|
411
|
|
|
* |
|
412
|
|
|
* @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference. |
|
413
|
|
|
* |
|
414
|
|
|
* @return bool |
|
415
|
|
|
*/ |
|
416
|
|
|
function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
|
417
|
|
|
$is_test_mode = ! empty( $_POST['test_mode'] ) ? |
|
418
|
|
|
give_is_setting_enabled( $_POST['test_mode'] ) : |
|
419
|
|
|
give_is_test_mode(); |
|
420
|
|
|
|
|
421
|
|
|
if ( |
|
422
|
|
|
! current_user_can( 'view_give_reports' ) || |
|
423
|
|
|
! $is_test_mode |
|
424
|
|
|
) { |
|
425
|
|
|
return false; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
// Add the main siteadmin menu item. |
|
429
|
|
|
$wp_admin_bar->add_menu( array( |
|
430
|
|
|
'id' => 'give-test-notice', |
|
431
|
|
|
'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
|
432
|
|
|
'parent' => 'top-secondary', |
|
433
|
|
|
'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
|
434
|
|
|
'meta' => array( 'class' => 'give-test-mode-active' ), |
|
435
|
|
|
) ); |
|
436
|
|
|
|
|
437
|
|
|
return true; |
|
438
|
|
|
} |
|
439
|
|
|
add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |
|
440
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.