| @@ -8,15 +8,24 @@ | ||
| 8 | 8 | * @author GeoDirectory Team <info@wpgeodirectory.com> |
| 9 | 9 | */ |
| 10 | 10 | class UsersWP_Notifications { |
| 11 | 11 | |
| 12 | - public function __construct() { | |
| 13 | - | |
| 14 | - } | |
| 15 | - | |
| 16 | - public function uwp_user_notifications_form_front($type){ | |
| 12 | + /** | |
| 13 | + * Displays the notification form | |
| 14 | + * | |
| 15 | + * @since 1.0.0 | |
| 16 | + * | |
| 17 | + * @param array $type Type of the form | |
| 18 | + * | |
| 19 | + */ | |
| 20 | + public function user_notifications_form_front($type){ | |
| 17 | 21 | if ($type == 'notifications') { |
| 18 | 22 | $user_id = get_current_user_id(); |
| 23 | + $design_style = uwp_get_option("design_style","bootstrap"); | |
| 24 | + $bs_form_group = $design_style ? "form-group mb-3 form-check" : ""; | |
| 25 | + $bs_form_control = $design_style ? "form-check-input" : ""; | |
| 26 | + $bs_sr_only = $design_style ? "form-check-label" : ""; | |
| 27 | + $bs_btn_class = $design_style ? "btn btn-primary btn-block text-uppercase" : ""; | |
| 19 | 28 | echo '<div class="uwp-account-form uwp_wc_form">'; |
| 20 | 29 | ?> |
| 21 | 30 | <div class="uwp-profile-extra"> |
| 22 | 31 | <div class="uwp-profile-extra-div form-table"> |
| @@ -39,23 +48,33 @@ | ||
| 39 | 48 | } else { |
| 40 | 49 | $checked = 0; |
| 41 | 50 | } |
| 42 | 51 | ?> |
| 43 | - <div class="uwp-profile-extra-wrap uwp_mute_notification_items"> | |
| 44 | - <div id="uwp_mute_<?php echo $id; ?>" | |
| 45 | - class="uwp_mute_notification_item uwp_mute_<?php echo $id; ?>"> | |
| 46 | - <input name="uwp_mute_notifications[<?php echo $id; ?>]" | |
| 47 | - class="" <?php checked($checked, "1", true); ?> type="checkbox" | |
| 48 | - value="1"><?php echo $text; ?> | |
| 52 | + <div class="uwp-profile-extra-wrap uwp_mute_notification_items <?php echo esc_attr( $bs_form_group ); ?>"> | |
| 53 | + <div id="uwp_mute_<?php echo esc_attr( $id ); ?>" | |
| 54 | + class="uwp_mute_notification_item uwp_mute_<?php echo esc_attr( $id ); ?>"> | |
| 55 | + <?php if(!empty($design_style)){ ?> | |
| 56 | + <label class="<?php echo esc_attr( $bs_sr_only ); ?>"> | |
| 57 | + <?php } ?> | |
| 58 | + <input name="uwp_mute_notifications[<?php echo esc_attr( $id ); ?>]" | |
| 59 | + class="<?php echo esc_attr( $bs_form_control ); ?>" <?php checked($checked, "1", true); ?> type="checkbox" | |
| 60 | + value="1"><?php echo wp_kses_post( $text ); ?> | |
| 61 | + <?php if(!empty($design_style)){ ?> | |
| 62 | + </label> | |
| 63 | + <?php } ?> | |
| 49 | 64 | </div> |
| 50 | 65 | </div> |
| 51 | 66 | <?php } |
| 52 | 67 | ?> |
| 53 | - <input type="hidden" name="uwp_notification_nonce" value="<?php echo wp_create_nonce( 'uwp-notification-nonce' ); ?>" /> | |
| 54 | - <input name="uwp_notification_submit" value="<?php echo __( 'Submit', 'userswp' ); ?>" type="submit"> | |
| 68 | + <input type="hidden" name="uwp_notification_nonce" value="<?php echo esc_attr( wp_create_nonce( 'uwp-notification-nonce' ) ); ?>" /> | |
| 69 | + <input name="uwp_notification_submit" class="<?php echo esc_attr( $bs_btn_class ); ?>" value="<?php esc_attr_e( 'Submit', 'userswp' ); ?>" type="submit"> | |
| 55 | 70 | <?php |
| 56 | 71 | } else { |
| 57 | - echo '<p>'.__( 'You will see the options to disable the active notifications for UsersWP and it\'s add ons.', 'userswp' ).'</p>'; | |
| 72 | + echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 73 | + 'type'=>'info', | |
| 74 | + 'content'=> esc_attr__( 'You will see the options to disable the active notifications for UsersWP and it\'s add ons.', 'userswp' ) | |
| 75 | + ) | |
| 76 | + ); | |
| 58 | 77 | }?> |
| 59 | 78 | </form> |
| 60 | 79 | </div> |
| 61 | 80 | </div> |
| @@ -71,22 +90,29 @@ | ||
| 71 | 90 | * @package userswp |
| 72 | 91 | * |
| 73 | 92 | * @return void |
| 74 | 93 | */ |
| 75 | - public function uwp_notification_submit_handler() { | |
| 94 | + public function notification_submit_handler() { | |
| 76 | 95 | if (isset($_POST['uwp_notification_submit'])) { |
| 77 | 96 | if( ! isset( $_POST['uwp_notification_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_notification_nonce'], 'uwp-notification-nonce' ) ) { |
| 78 | 97 | return; |
| 79 | 98 | } |
| 80 | 99 | |
| 100 | + global $uwp_notices; | |
| 81 | 101 | $user_id = get_current_user_id(); |
| 82 | - if (isset($_POST['uwp_mute_notifications']) && !empty($_POST['uwp_mute_notifications'])) { | |
| 83 | - update_user_meta($user_id, 'uwp_mute_notifications', $_POST['uwp_mute_notifications']); | |
| 84 | - } | |
| 102 | + $uwp_mute_notifications = isset($_POST['uwp_mute_notifications']) ? $_POST['uwp_mute_notifications'] : array(); | |
| 85 | 103 | |
| 104 | + update_user_meta($user_id, 'uwp_mute_notifications', array_map('uwp_clean', $uwp_mute_notifications)); | |
| 105 | + | |
| 106 | + $message = apply_filters('uwp_notification_update_success_message', __('Notification settings updated successfully.', 'userswp')); | |
| 107 | + $message = aui()->alert(array( | |
| 108 | + 'type'=>'success', | |
| 109 | + 'content'=> $message | |
| 110 | + ) | |
| 111 | + ); | |
| 112 | + $uwp_notices[] = array('account' => $message); | |
| 113 | + | |
| 86 | 114 | do_action('uwp_handle_notification_submit', $user_id); |
| 87 | 115 | |
| 88 | 116 | } |
| 89 | 117 | } |
| 90 | - | |
| 91 | - | |
| 92 | 118 | } |