ravinderk /
Give
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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'] ) ) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 24 | die(); |
||
| 25 | } |
||
| 26 | |||
| 27 | $wp_editor = json_decode( base64_decode( $_POST['wp_editor'] ), true ); |
||
|
0 ignored issues
–
show
|
|||
| 28 | $wp_editor[2]['textarea_name'] = $_POST['textarea_name']; |
||
|
0 ignored issues
–
show
|
|||
| 29 | |||
| 30 | wp_editor( $wp_editor[0], $_POST['wp_editor_id'], $wp_editor[2] ); |
||
|
0 ignored issues
–
show
|
|||
| 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 | 'give-tools' |
||
|
0 ignored issues
–
show
|
|||
| 52 | ); |
||
| 53 | |||
| 54 | // Get current page. |
||
| 55 | $current_page = isset( $_GET['page'] ) ? esc_attr( $_GET['page'] ) : ''; |
||
|
0 ignored issues
–
show
|
|||
| 56 | |||
| 57 | // Bailout. |
||
| 58 | if ( |
||
| 59 | empty( $current_page ) |
||
| 60 | || empty( $_GET['_wp_http_referer'] ) |
||
|
0 ignored issues
–
show
|
|||
| 61 | || ! in_array( $current_page, $give_pages ) |
||
| 62 | ) { |
||
| 63 | return false; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Verify current page request. |
||
| 68 | * |
||
| 69 | * @since 1.8 |
||
| 70 | */ |
||
| 71 | $redirect = apply_filters( "give_validate_{$current_page}", true ); |
||
| 72 | |||
| 73 | if ( $redirect ) { |
||
| 74 | // Redirect. |
||
| 75 | wp_redirect( |
||
| 76 | remove_query_arg( |
||
| 77 | array( '_wp_http_referer', '_wpnonce' ), |
||
| 78 | wp_unslash( $_SERVER['REQUEST_URI'] ) |
||
|
0 ignored issues
–
show
|
|||
| 79 | ) |
||
| 80 | ); |
||
| 81 | exit; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | add_action( 'admin_init', 'give_redirect_to_clean_url_admin_pages' ); |
||
| 86 | |||
| 87 | |||
| 88 | /** |
||
| 89 | * Hide Outdated PHP Notice Shortly. |
||
| 90 | * |
||
| 91 | * This code is used with AJAX call to hide outdated PHP notice for a short period of time |
||
| 92 | * |
||
| 93 | * @since 1.8.9 |
||
| 94 | * |
||
| 95 | * @return void |
||
| 96 | */ |
||
| 97 | function give_hide_outdated_php_notice() { |
||
| 98 | |||
| 99 | if ( ! isset( $_POST['_give_hide_outdated_php_notices_shortly'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 100 | give_die(); |
||
| 101 | } |
||
| 102 | |||
| 103 | // Transient key name. |
||
| 104 | $transient_key = "_give_hide_outdated_php_notices_shortly"; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
_give_hide_outdated_php_notices_shortly does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 105 | |||
| 106 | if ( Give_Cache::get( $transient_key, true ) ) { |
||
| 107 | return; |
||
| 108 | } |
||
| 109 | |||
| 110 | // Hide notice for 24 hours. |
||
| 111 | Give_Cache::set( $transient_key, true, DAY_IN_SECONDS, true ); |
||
| 112 | |||
| 113 | give_die(); |
||
| 114 | |||
| 115 | } |
||
| 116 | |||
| 117 | add_action( 'wp_ajax_give_hide_outdated_php_notice', 'give_hide_outdated_php_notice' ); |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Register admin notices. |
||
| 121 | * |
||
| 122 | * @since 1.8.9 |
||
| 123 | */ |
||
| 124 | function _give_register_admin_notices() { |
||
| 125 | // Bailout. |
||
| 126 | if( ! is_admin() ) { |
||
|
0 ignored issues
–
show
|
|||
| 127 | return; |
||
| 128 | } |
||
| 129 | |||
| 130 | // Add PHP version update notice |
||
| 131 | if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) { |
||
| 132 | |||
| 133 | $notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>'; |
||
| 134 | $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>'; |
||
| 135 | $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>'; |
||
| 136 | $notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>'; |
||
| 137 | $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>'; |
||
| 138 | $notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>'; |
||
| 139 | $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>'; |
||
| 140 | |||
| 141 | Give()->notices->register_notice( array( |
||
| 142 | 'id' => 'give-invalid-php-version', |
||
| 143 | 'type' => 'error', |
||
| 144 | 'description' => $notice_desc, |
||
| 145 | 'dismissible_type' => 'user', |
||
| 146 | 'dismiss_interval' => 'shortly', |
||
| 147 | ) ); |
||
| 148 | } |
||
| 149 | |||
| 150 | // Add payment bulk notice. |
||
| 151 | if ( |
||
| 152 | current_user_can( 'edit_give_payments' ) |
||
| 153 | && isset( $_GET['action'] ) |
||
| 154 | && ! empty( $_GET['action'] ) |
||
| 155 | && isset( $_GET['payment'] ) |
||
| 156 | && ! empty( $_GET['payment'] ) |
||
| 157 | ) { |
||
| 158 | $payment_count = isset( $_GET['payment'] ) ? count( $_GET['payment'] ) : 0; |
||
|
0 ignored issues
–
show
|
|||
| 159 | |||
| 160 | switch ( $_GET['action'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 161 | View Code Duplication | case 'delete': |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 162 | Give()->notices->register_notice( array( |
||
| 163 | 'id' => 'bulk_action_delete', |
||
| 164 | 'type' => 'updated', |
||
| 165 | 'description' => sprintf( |
||
| 166 | _n( |
||
| 167 | 'Successfully deleted one transaction.', |
||
| 168 | 'Successfully deleted %d transactions.', |
||
| 169 | $payment_count, |
||
| 170 | 'give' |
||
| 171 | ), |
||
| 172 | $payment_count ), |
||
|
0 ignored issues
–
show
|
|||
| 173 | 'show' => true, |
||
| 174 | ) ); |
||
| 175 | |||
| 176 | break; |
||
| 177 | |||
| 178 | View Code Duplication | case 'resend-receipt': |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 179 | Give()->notices->register_notice( array( |
||
| 180 | 'id' => 'bulk_action_resend_receipt', |
||
| 181 | 'type' => 'updated', |
||
| 182 | 'description' => sprintf( |
||
| 183 | _n( |
||
| 184 | 'Successfully sent email receipt to one recipient.', |
||
| 185 | 'Successfully sent email receipts to %d recipients.', |
||
| 186 | $payment_count, |
||
| 187 | 'give' |
||
| 188 | ), |
||
| 189 | $payment_count |
||
| 190 | ), |
||
| 191 | 'show' => true, |
||
| 192 | ) ); |
||
| 193 | break; |
||
| 194 | } |
||
| 195 | } |
||
| 196 | |||
| 197 | // Add give message notices. |
||
| 198 | if ( ! empty( $_GET['give-message'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 199 | // Donation reports errors. |
||
| 200 | if ( current_user_can( 'view_give_reports' ) ) { |
||
| 201 | switch ( $_GET['give-message'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 202 | View Code Duplication | case 'donation_deleted' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 203 | Give()->notices->register_notice( array( |
||
| 204 | 'id' => 'give-donation-deleted', |
||
| 205 | 'type' => 'updated', |
||
| 206 | 'description' => __( 'The donation has been deleted.', 'give' ), |
||
| 207 | 'show' => true, |
||
| 208 | ) ); |
||
| 209 | break; |
||
| 210 | View Code Duplication | case 'email_sent' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 211 | Give()->notices->register_notice( array( |
||
| 212 | 'id' => 'give-payment-sent', |
||
| 213 | 'type' => 'updated', |
||
| 214 | 'description' => __( 'The donation receipt has been resent.', 'give' ), |
||
| 215 | 'show' => true, |
||
| 216 | ) ); |
||
| 217 | break; |
||
| 218 | View Code Duplication | case 'refreshed-reports' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 219 | Give()->notices->register_notice( array( |
||
| 220 | 'id' => 'give-refreshed-reports', |
||
| 221 | 'type' => 'updated', |
||
| 222 | 'description' => __( 'The reports cache has been cleared.', 'give' ), |
||
| 223 | 'show' => true, |
||
| 224 | ) ); |
||
| 225 | break; |
||
| 226 | View Code Duplication | case 'donation-note-deleted' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 227 | Give()->notices->register_notice( array( |
||
| 228 | 'id' => 'give-donation-note-deleted', |
||
| 229 | 'type' => 'updated', |
||
| 230 | 'description' => __( 'The donation note has been deleted.', 'give' ), |
||
| 231 | 'show' => true, |
||
| 232 | ) ); |
||
| 233 | break; |
||
| 234 | } |
||
| 235 | } |
||
| 236 | |||
| 237 | // Give settings notices and errors. |
||
| 238 | if ( current_user_can( 'manage_give_settings' ) ) { |
||
| 239 | switch ( $_GET['give-message'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 240 | View Code Duplication | case 'settings-imported' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 241 | Give()->notices->register_notice( array( |
||
| 242 | 'id' => 'give-settings-imported', |
||
| 243 | 'type' => 'updated', |
||
| 244 | 'description' => __( 'The settings have been imported.', 'give' ), |
||
| 245 | 'show' => true, |
||
| 246 | ) ); |
||
| 247 | break; |
||
| 248 | View Code Duplication | case 'api-key-generated' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 249 | Give()->notices->register_notice( array( |
||
| 250 | 'id' => 'give-api-key-generated', |
||
| 251 | 'type' => 'updated', |
||
| 252 | 'description' => __( 'API keys have been generated.', 'give' ), |
||
| 253 | 'show' => true, |
||
| 254 | ) ); |
||
| 255 | break; |
||
| 256 | View Code Duplication | case 'api-key-exists' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 257 | Give()->notices->register_notice( array( |
||
| 258 | 'id' => 'give-api-key-exists', |
||
| 259 | 'type' => 'updated', |
||
| 260 | 'description' => __( 'The specified user already has API keys.', 'give' ), |
||
| 261 | 'show' => true, |
||
| 262 | ) ); |
||
| 263 | break; |
||
| 264 | View Code Duplication | case 'api-key-regenerated' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 265 | Give()->notices->register_notice( array( |
||
| 266 | 'id' => 'give-api-key-regenerated', |
||
| 267 | 'type' => 'updated', |
||
| 268 | 'description' => __( 'API keys have been regenerated.', 'give' ), |
||
| 269 | 'show' => true, |
||
| 270 | ) ); |
||
| 271 | break; |
||
| 272 | View Code Duplication | case 'api-key-revoked' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 273 | Give()->notices->register_notice( array( |
||
| 274 | 'id' => 'give-api-key-revoked', |
||
| 275 | 'type' => 'updated', |
||
| 276 | 'description' => __( 'API keys have been revoked.', 'give' ), |
||
| 277 | 'show' => true, |
||
| 278 | ) ); |
||
| 279 | break; |
||
| 280 | View Code Duplication | case 'sent-test-email' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 281 | Give()->notices->register_notice( array( |
||
| 282 | 'id' => 'give-sent-test-email', |
||
| 283 | 'type' => 'updated', |
||
| 284 | 'description' => __( 'The test email has been sent.', 'give' ), |
||
| 285 | 'show' => true, |
||
| 286 | ) ); |
||
| 287 | break; |
||
| 288 | View Code Duplication | case 'matched-success-failure-page': |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 289 | Give()->notices->register_notice( array( |
||
| 290 | 'id' => 'give-matched-success-failure-page', |
||
| 291 | 'type' => 'updated', |
||
| 292 | 'description' => __( 'You cannot set the success and failed pages to the same page', 'give' ), |
||
| 293 | 'show' => true, |
||
| 294 | ) ); |
||
| 295 | break; |
||
| 296 | } |
||
| 297 | } |
||
| 298 | // Payments errors. |
||
| 299 | if ( current_user_can( 'edit_give_payments' ) ) { |
||
| 300 | switch ( $_GET['give-message'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 301 | View Code Duplication | case 'note-added' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 302 | Give()->notices->register_notice( array( |
||
| 303 | 'id' => 'give-note-added', |
||
| 304 | 'type' => 'updated', |
||
| 305 | 'description' => __( 'The donation note has been added.', 'give' ), |
||
| 306 | 'show' => true, |
||
| 307 | ) ); |
||
| 308 | break; |
||
| 309 | View Code Duplication | case 'payment-updated' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 310 | Give()->notices->register_notice( array( |
||
| 311 | 'id' => 'give-payment-updated', |
||
| 312 | 'type' => 'updated', |
||
| 313 | 'description' => __( 'The donation has been updated.', 'give' ), |
||
| 314 | 'show' => true, |
||
| 315 | ) ); |
||
| 316 | break; |
||
| 317 | } |
||
| 318 | } |
||
| 319 | |||
| 320 | // Donor Notices. |
||
| 321 | if ( current_user_can( 'edit_give_payments' ) ) { |
||
| 322 | switch ( $_GET['give-message'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 323 | View Code Duplication | case 'donor-deleted' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 324 | Give()->notices->register_notice( array( |
||
| 325 | 'id' => 'give-donor-deleted', |
||
| 326 | 'type' => 'updated', |
||
| 327 | 'description' => __( 'The donor has been deleted.', 'give' ), |
||
| 328 | 'show' => true, |
||
| 329 | ) ); |
||
| 330 | break; |
||
| 331 | |||
| 332 | View Code Duplication | case 'email-added' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 333 | Give()->notices->register_notice( array( |
||
| 334 | 'id' => 'give-donor-email-added', |
||
| 335 | 'type' => 'updated', |
||
| 336 | 'description' => __( 'Donor email added.', 'give' ), |
||
| 337 | 'show' => true, |
||
| 338 | ) ); |
||
| 339 | break; |
||
| 340 | |||
| 341 | View Code Duplication | case 'email-removed' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 342 | Give()->notices->register_notice( array( |
||
| 343 | 'id' => 'give-donor-email-removed', |
||
| 344 | 'type' => 'updated', |
||
| 345 | 'description' => __( 'Donor email removed.', 'give' ), |
||
| 346 | 'show' => true, |
||
| 347 | ) ); |
||
| 348 | break; |
||
| 349 | |||
| 350 | View Code Duplication | case 'email-remove-failed' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 351 | Give()->notices->register_notice( array( |
||
| 352 | 'id' => 'give-donor-email-remove-failed', |
||
| 353 | 'type' => 'updated', |
||
| 354 | 'description' => __( 'Failed to remove donor email.', 'give' ), |
||
| 355 | 'show' => true, |
||
| 356 | ) ); |
||
| 357 | break; |
||
| 358 | |||
| 359 | View Code Duplication | case 'primary-email-updated' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 360 | Give()->notices->register_notice( array( |
||
| 361 | 'id' => 'give-donor-primary-email-updated', |
||
| 362 | 'type' => 'updated', |
||
| 363 | 'description' => __( 'Primary email updated for donor.', 'give' ), |
||
| 364 | 'show' => true, |
||
| 365 | ) ); |
||
| 366 | break; |
||
| 367 | |||
| 368 | View Code Duplication | case 'primary-email-failed' : |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 369 | Give()->notices->register_notice( array( |
||
| 370 | 'id' => 'give-donor-primary-email-failed', |
||
| 371 | 'type' => 'updated', |
||
| 372 | 'description' => __( 'Failed to set primary email.', 'give' ), |
||
| 373 | 'show' => true, |
||
| 374 | ) ); |
||
| 375 | break; |
||
| 376 | } |
||
| 377 | } |
||
| 378 | } |
||
| 379 | } |
||
| 380 | |||
| 381 | add_action( 'admin_notices', '_give_register_admin_notices', - 1 ); |
||
| 382 | |||
| 383 | |||
| 384 | /** |
||
| 385 | * Display admin bar when active. |
||
| 386 | * |
||
| 387 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference. |
||
| 388 | * |
||
| 389 | * @return bool |
||
| 390 | */ |
||
| 391 | function _give_show_test_mode_notice_in_admin_bar( $wp_admin_bar ) { |
||
| 392 | $is_test_mode = ! empty( $_POST['test_mode'] ) ? |
||
|
0 ignored issues
–
show
|
|||
| 393 | give_is_setting_enabled( $_POST['test_mode'] ) : |
||
|
0 ignored issues
–
show
|
|||
| 394 | give_is_test_mode(); |
||
| 395 | |||
| 396 | if ( |
||
| 397 | ! current_user_can( 'view_give_reports' ) || |
||
| 398 | ! $is_test_mode |
||
| 399 | ) { |
||
| 400 | return false; |
||
| 401 | } |
||
| 402 | |||
| 403 | // Add the main siteadmin menu item. |
||
| 404 | $wp_admin_bar->add_menu( array( |
||
| 405 | 'id' => 'give-test-notice', |
||
| 406 | 'href' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ), |
||
| 407 | 'parent' => 'top-secondary', |
||
| 408 | 'title' => esc_html__( 'Give Test Mode Active', 'give' ), |
||
| 409 | 'meta' => array( 'class' => 'give-test-mode-active' ), |
||
| 410 | ) ); |
||
| 411 | |||
| 412 | return true; |
||
| 413 | } |
||
| 414 | add_action( 'admin_bar_menu', '_give_show_test_mode_notice_in_admin_bar', 1000, 1 ); |