@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | * @since 1.0 |
| 28 | 28 | */ |
| 29 | 29 | public function __construct() { |
| 30 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 31 | - add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) ); |
|
| 32 | - add_action( 'admin_bar_menu', array( $this, 'give_admin_bar_menu' ), 1000 ); |
|
| 30 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 31 | + add_action('give_dismiss_notices', array($this, 'dismiss_notices')); |
|
| 32 | + add_action('admin_bar_menu', array($this, 'give_admin_bar_menu'), 1000); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -42,18 +42,18 @@ discard block |
||
| 42 | 42 | public function give_admin_bar_menu() { |
| 43 | 43 | global $wp_admin_bar; |
| 44 | 44 | |
| 45 | - if ( ! give_is_test_mode() || ! current_user_can( 'view_give_reports' ) ) { |
|
| 45 | + if ( ! give_is_test_mode() || ! current_user_can('view_give_reports')) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | //Add the main siteadmin menu item |
| 50 | - $wp_admin_bar->add_menu( array( |
|
| 50 | + $wp_admin_bar->add_menu(array( |
|
| 51 | 51 | 'id' => 'give-test-notice', |
| 52 | - 'href' => admin_url() . 'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
| 52 | + 'href' => admin_url().'edit.php?post_type=give_forms&page=give-settings&tab=gateways', |
|
| 53 | 53 | 'parent' => 'top-secondary', |
| 54 | - 'title' => __( 'Give Test Mode Active', 'give' ), |
|
| 55 | - 'meta' => array( 'class' => 'give-test-mode-active' ), |
|
| 56 | - ) ); |
|
| 54 | + 'title' => __('Give Test Mode Active', 'give'), |
|
| 55 | + 'meta' => array('class' => 'give-test-mode-active'), |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,98 +68,98 @@ discard block |
||
| 68 | 68 | 'error' => array() |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | - if ( ! give_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_give_settings' ) ) { |
|
| 71 | + if ( ! give_test_ajax_works() && ! get_user_meta(get_current_user_id(), '_give_admin_ajax_inaccessible_dismissed', true) && current_user_can('manage_give_settings')) { |
|
| 72 | 72 | echo '<div class="error">'; |
| 73 | - echo '<p>' . __( 'Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give' ) . '</p>'; |
|
| 73 | + echo '<p>'.__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
| 74 | 74 | /* translators: %s: https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/ */ |
| 75 | - echo '<p>' . sprintf( __( 'Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give' ), esc_url( 'https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/' ) ) . '</p>'; |
|
| 76 | - echo '<p><a href="' . add_query_arg( array( |
|
| 75 | + echo '<p>'.sprintf(__('Please see <a href="%s" target="_blank">this reference</a> for possible solutions.', 'give'), esc_url('https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/')).'</p>'; |
|
| 76 | + echo '<p><a href="'.add_query_arg(array( |
|
| 77 | 77 | 'give_action' => 'dismiss_notices', |
| 78 | 78 | 'give_notice' => 'admin_ajax_inaccessible' |
| 79 | - ) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
| 79 | + )).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>'; |
|
| 80 | 80 | echo '</div>'; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
| 84 | - if ( isset( $_GET['give-message'] ) ) { |
|
| 84 | + if (isset($_GET['give-message'])) { |
|
| 85 | 85 | |
| 86 | 86 | // Donation reports errors |
| 87 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
| 88 | - switch ( $_GET['give-message'] ) { |
|
| 87 | + if (current_user_can('view_give_reports')) { |
|
| 88 | + switch ($_GET['give-message']) { |
|
| 89 | 89 | case 'payment_deleted' : |
| 90 | - $notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' ); |
|
| 90 | + $notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give'); |
|
| 91 | 91 | break; |
| 92 | 92 | case 'email_sent' : |
| 93 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
| 93 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
| 94 | 94 | break; |
| 95 | 95 | case 'refreshed-reports' : |
| 96 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
| 96 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
| 97 | 97 | break; |
| 98 | 98 | case 'payment-note-deleted' : |
| 99 | - $notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' ); |
|
| 99 | + $notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give'); |
|
| 100 | 100 | break; |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Give settings notices and errors |
| 105 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 106 | - switch ( $_GET['give-message'] ) { |
|
| 105 | + if (current_user_can('manage_give_settings')) { |
|
| 106 | + switch ($_GET['give-message']) { |
|
| 107 | 107 | case 'settings-imported' : |
| 108 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
| 108 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
| 109 | 109 | break; |
| 110 | 110 | case 'api-key-generated' : |
| 111 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' ); |
|
| 111 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give'); |
|
| 112 | 112 | break; |
| 113 | 113 | case 'api-key-exists' : |
| 114 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
| 114 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
| 115 | 115 | break; |
| 116 | 116 | case 'api-key-regenerated' : |
| 117 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' ); |
|
| 117 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give'); |
|
| 118 | 118 | break; |
| 119 | 119 | case 'api-key-revoked' : |
| 120 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' ); |
|
| 120 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give'); |
|
| 121 | 121 | break; |
| 122 | 122 | case 'sent-test-email' : |
| 123 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
| 123 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | // Payments errors |
| 128 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 129 | - switch ( $_GET['give-message'] ) { |
|
| 128 | + if (current_user_can('edit_give_payments')) { |
|
| 129 | + switch ($_GET['give-message']) { |
|
| 130 | 130 | case 'note-added' : |
| 131 | - $notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' ); |
|
| 131 | + $notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give'); |
|
| 132 | 132 | break; |
| 133 | 133 | case 'payment-updated' : |
| 134 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' ); |
|
| 134 | + $notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give'); |
|
| 135 | 135 | break; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Customer Notices |
| 140 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 141 | - switch ( $_GET['give-message'] ) { |
|
| 140 | + if (current_user_can('edit_give_payments')) { |
|
| 141 | + switch ($_GET['give-message']) { |
|
| 142 | 142 | case 'customer-deleted' : |
| 143 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted.', 'give' ); |
|
| 143 | + $notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted.', 'give'); |
|
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ( count( $notices['updated'] ) > 0 ) { |
|
| 151 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
| 152 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
| 150 | + if (count($notices['updated']) > 0) { |
|
| 151 | + foreach ($notices['updated'] as $notice => $message) { |
|
| 152 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( count( $notices['error'] ) > 0 ) { |
|
| 157 | - foreach ( $notices['error'] as $notice => $message ) { |
|
| 158 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
| 156 | + if (count($notices['error']) > 0) { |
|
| 157 | + foreach ($notices['error'] as $notice => $message) { |
|
| 158 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - settings_errors( 'give-notices' ); |
|
| 162 | + settings_errors('give-notices'); |
|
| 163 | 163 | |
| 164 | 164 | } |
| 165 | 165 | |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | 173 | function give_admin_addons_notices() { |
| 174 | - add_settings_error( 'give-notices', 'give-addons-feed-error', esc_attr__( 'There seems to be an issue with the server. Please try again in a few minutes.', 'give' ), 'error' ); |
|
| 175 | - settings_errors( 'give-notices' ); |
|
| 174 | + add_settings_error('give-notices', 'give-addons-feed-error', esc_attr__('There seems to be an issue with the server. Please try again in a few minutes.', 'give'), 'error'); |
|
| 175 | + settings_errors('give-notices'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * @return void |
| 184 | 184 | */ |
| 185 | 185 | function dismiss_notices() { |
| 186 | - if ( isset( $_GET['give_notice'] ) ) { |
|
| 187 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
| 188 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
| 186 | + if (isset($_GET['give_notice'])) { |
|
| 187 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
| 188 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
| 189 | 189 | exit; |
| 190 | 190 | } |
| 191 | 191 | } |