@@ -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,97 +68,97 @@ 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>'; |
|
| 74 | - echo '<p>' . sprintf( esc_attr__( 'Please see %1$sthis reference%2$s for possible solutions.', 'give' ), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>' ) . '</p>'; |
|
| 75 | - echo '<p><a href="' . add_query_arg( array( |
|
| 73 | + echo '<p>'.__('Your site appears to be blocking the WordPress ajax interface. This may cause issues with Give.', 'give').'</p>'; |
|
| 74 | + echo '<p>'.sprintf(esc_attr__('Please see %1$sthis reference%2$s for possible solutions.', 'give'), '<a href="https://givewp.com/documentation/core/troubleshooting/admin-ajax-blocked/" target="_blank">', '</a>').'</p>'; |
|
| 75 | + echo '<p><a href="'.add_query_arg(array( |
|
| 76 | 76 | 'give_action' => 'dismiss_notices', |
| 77 | 77 | 'give_notice' => 'admin_ajax_inaccessible' |
| 78 | - ) ) . '">' . esc_attr__( 'Dismiss Notice', 'give' ) . '</a></p>'; |
|
| 78 | + )).'">'.esc_attr__('Dismiss Notice', 'give').'</a></p>'; |
|
| 79 | 79 | echo '</div>'; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
| 83 | - if ( isset( $_GET['give-message'] ) ) { |
|
| 83 | + if (isset($_GET['give-message'])) { |
|
| 84 | 84 | |
| 85 | 85 | // Donation reports errors |
| 86 | - if ( current_user_can( 'view_give_reports' ) ) { |
|
| 87 | - switch ( $_GET['give-message'] ) { |
|
| 86 | + if (current_user_can('view_give_reports')) { |
|
| 87 | + switch ($_GET['give-message']) { |
|
| 88 | 88 | case 'payment_deleted' : |
| 89 | - $notices['updated']['give-payment-deleted'] = esc_attr__( 'The payment has been deleted.', 'give' ); |
|
| 89 | + $notices['updated']['give-payment-deleted'] = esc_attr__('The payment has been deleted.', 'give'); |
|
| 90 | 90 | break; |
| 91 | 91 | case 'email_sent' : |
| 92 | - $notices['updated']['give-payment-sent'] = esc_attr__( 'The donation receipt has been resent.', 'give' ); |
|
| 92 | + $notices['updated']['give-payment-sent'] = esc_attr__('The donation receipt has been resent.', 'give'); |
|
| 93 | 93 | break; |
| 94 | 94 | case 'refreshed-reports' : |
| 95 | - $notices['updated']['give-refreshed-reports'] = esc_attr__( 'The reports cache has been cleared.', 'give' ); |
|
| 95 | + $notices['updated']['give-refreshed-reports'] = esc_attr__('The reports cache has been cleared.', 'give'); |
|
| 96 | 96 | break; |
| 97 | 97 | case 'payment-note-deleted' : |
| 98 | - $notices['updated']['give-payment-note-deleted'] = esc_attr__( 'The payment note has been deleted.', 'give' ); |
|
| 98 | + $notices['updated']['give-payment-note-deleted'] = esc_attr__('The payment note has been deleted.', 'give'); |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Give settings notices and errors |
| 104 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 105 | - switch ( $_GET['give-message'] ) { |
|
| 104 | + if (current_user_can('manage_give_settings')) { |
|
| 105 | + switch ($_GET['give-message']) { |
|
| 106 | 106 | case 'settings-imported' : |
| 107 | - $notices['updated']['give-settings-imported'] = esc_attr__( 'The settings have been imported.', 'give' ); |
|
| 107 | + $notices['updated']['give-settings-imported'] = esc_attr__('The settings have been imported.', 'give'); |
|
| 108 | 108 | break; |
| 109 | 109 | case 'api-key-generated' : |
| 110 | - $notices['updated']['give-api-key-generated'] = esc_attr__( 'API keys successfully generated.', 'give' ); |
|
| 110 | + $notices['updated']['give-api-key-generated'] = esc_attr__('API keys successfully generated.', 'give'); |
|
| 111 | 111 | break; |
| 112 | 112 | case 'api-key-exists' : |
| 113 | - $notices['error']['give-api-key-exists'] = esc_attr__( 'The specified user already has API keys.', 'give' ); |
|
| 113 | + $notices['error']['give-api-key-exists'] = esc_attr__('The specified user already has API keys.', 'give'); |
|
| 114 | 114 | break; |
| 115 | 115 | case 'api-key-regenerated' : |
| 116 | - $notices['updated']['give-api-key-regenerated'] = esc_attr__( 'API keys successfully regenerated.', 'give' ); |
|
| 116 | + $notices['updated']['give-api-key-regenerated'] = esc_attr__('API keys successfully regenerated.', 'give'); |
|
| 117 | 117 | break; |
| 118 | 118 | case 'api-key-revoked' : |
| 119 | - $notices['updated']['give-api-key-revoked'] = esc_attr__( 'API keys successfully revoked.', 'give' ); |
|
| 119 | + $notices['updated']['give-api-key-revoked'] = esc_attr__('API keys successfully revoked.', 'give'); |
|
| 120 | 120 | break; |
| 121 | 121 | case 'sent-test-email' : |
| 122 | - $notices['updated']['give-sent-test-email'] = esc_attr__( 'The test email has been sent.', 'give' ); |
|
| 122 | + $notices['updated']['give-sent-test-email'] = esc_attr__('The test email has been sent.', 'give'); |
|
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | // Payments errors |
| 127 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 128 | - switch ( $_GET['give-message'] ) { |
|
| 127 | + if (current_user_can('edit_give_payments')) { |
|
| 128 | + switch ($_GET['give-message']) { |
|
| 129 | 129 | case 'note-added' : |
| 130 | - $notices['updated']['give-note-added'] = esc_attr__( 'The payment note has been added successfully.', 'give' ); |
|
| 130 | + $notices['updated']['give-note-added'] = esc_attr__('The payment note has been added successfully.', 'give'); |
|
| 131 | 131 | break; |
| 132 | 132 | case 'payment-updated' : |
| 133 | - $notices['updated']['give-payment-updated'] = esc_attr__( 'The payment has been successfully updated.', 'give' ); |
|
| 133 | + $notices['updated']['give-payment-updated'] = esc_attr__('The payment has been successfully updated.', 'give'); |
|
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Customer Notices |
| 139 | - if ( current_user_can( 'edit_give_payments' ) ) { |
|
| 140 | - switch ( $_GET['give-message'] ) { |
|
| 139 | + if (current_user_can('edit_give_payments')) { |
|
| 140 | + switch ($_GET['give-message']) { |
|
| 141 | 141 | case 'customer-deleted' : |
| 142 | - $notices['updated']['give-customer-deleted'] = esc_attr__( 'Donor successfully deleted', 'give' ); |
|
| 142 | + $notices['updated']['give-customer-deleted'] = esc_attr__('Donor successfully deleted', 'give'); |
|
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( count( $notices['updated'] ) > 0 ) { |
|
| 150 | - foreach ( $notices['updated'] as $notice => $message ) { |
|
| 151 | - add_settings_error( 'give-notices', $notice, $message, 'updated' ); |
|
| 149 | + if (count($notices['updated']) > 0) { |
|
| 150 | + foreach ($notices['updated'] as $notice => $message) { |
|
| 151 | + add_settings_error('give-notices', $notice, $message, 'updated'); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if ( count( $notices['error'] ) > 0 ) { |
|
| 156 | - foreach ( $notices['error'] as $notice => $message ) { |
|
| 157 | - add_settings_error( 'give-notices', $notice, $message, 'error' ); |
|
| 155 | + if (count($notices['error']) > 0) { |
|
| 156 | + foreach ($notices['error'] as $notice => $message) { |
|
| 157 | + add_settings_error('give-notices', $notice, $message, 'error'); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - settings_errors( 'give-notices' ); |
|
| 161 | + settings_errors('give-notices'); |
|
| 162 | 162 | |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @return void |
| 171 | 171 | */ |
| 172 | 172 | function give_admin_addons_notices() { |
| 173 | - 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' ); |
|
| 174 | - settings_errors( 'give-notices' ); |
|
| 173 | + 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'); |
|
| 174 | + settings_errors('give-notices'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | 184 | function dismiss_notices() { |
| 185 | - if ( isset( $_GET['give_notice'] ) ) { |
|
| 186 | - update_user_meta( get_current_user_id(), '_give_' . $_GET['give_notice'] . '_dismissed', 1 ); |
|
| 187 | - wp_redirect( remove_query_arg( array( 'give_action', 'give_notice' ) ) ); |
|
| 185 | + if (isset($_GET['give_notice'])) { |
|
| 186 | + update_user_meta(get_current_user_id(), '_give_'.$_GET['give_notice'].'_dismissed', 1); |
|
| 187 | + wp_redirect(remove_query_arg(array('give_action', 'give_notice'))); |
|
| 188 | 188 | exit; |
| 189 | 189 | } |
| 190 | 190 | } |