PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.3.4
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.3.4
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-user-notifications.php

class-user-notifications.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.3.4, at includes/class-user-notifications.php

118 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * User Notifications related functions
4 *
5 * All UsersWP related mails are sent via this class.
6 *
7 * @since 1.0.20
8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 */
10 class UsersWP_Notifications {
11
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){
21 if ($type == 'notifications') {
22 $user_id = get_current_user_id();
23 $design_style = uwp_get_option("design_style","bootstrap");
24 $bs_form_group = $design_style ? "form-group 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" : "";
28 echo '<div class="uwp-account-form uwp_wc_form">';
29 ?>
30 <div class="uwp-profile-extra">
31 <div class="uwp-profile-extra-div form-table">
32 <form class="uwp-account-form uwp_form" method="post">
33 <?php
34 $value = get_user_meta($user_id, 'uwp_mute_notifications', true);
35 $notifications_types = array();
36
37 if( 1 == uwp_get_option('enable_account_update_notification' )){
38 $notifications_types = array(
39 'account_update' => __('Disable account update notification.', 'userswp'),
40 );
41 }
42 $notifications_types = apply_filters('uwp_mute_notification_types', $notifications_types, $user_id);
43
44 if($notifications_types) {
45 foreach ($notifications_types as $id => $text) {
46 if(isset($value) && !empty($value) && isset($value[$id])){
47 $checked = $value[$id];
48 } else {
49 $checked = 0;
50 }
51 ?>
52 <div class="uwp-profile-extra-wrap uwp_mute_notification_items <?php echo $bs_form_group; ?>">
53 <div id="uwp_mute_<?php echo $id; ?>"
54 class="uwp_mute_notification_item uwp_mute_<?php echo $id; ?>">
55 <?php if(!empty($design_style)){ ?>
56 <label class="<?php echo $bs_sr_only; ?>">
57 <?php } ?>
58 <input name="uwp_mute_notifications[<?php echo $id; ?>]"
59 class="<?php echo $bs_form_control; ?>" <?php checked($checked, "1", true); ?> type="checkbox"
60 value="1"><?php echo $text; ?>
61 <?php if(!empty($design_style)){ ?>
62 </label>
63 <?php } ?>
64 </div>
65 </div>
66 <?php }
67 ?>
68 <input type="hidden" name="uwp_notification_nonce" value="<?php echo wp_create_nonce( 'uwp-notification-nonce' ); ?>" />
69 <input name="uwp_notification_submit" class="<?php echo $bs_btn_class; ?>" value="<?php echo __( 'Submit', 'userswp' ); ?>" type="submit">
70 <?php
71 } else {
72 echo aui()->alert(array(
73 'type'=>'info',
74 'content'=> __( 'You will see the options to disable the active notifications for UsersWP and it\'s add ons.', 'userswp' )
75 )
76 );
77 }?>
78 </form>
79 </div>
80 </div>
81 <?php
82 echo '</div>';
83 }
84 }
85
86 /**
87 * Handles the notifications form submission.
88 *
89 * @since 1.0.0
90 * @package userswp
91 *
92 * @return void
93 */
94 public function notification_submit_handler() {
95 if (isset($_POST['uwp_notification_submit'])) {
96 if( ! isset( $_POST['uwp_notification_nonce'] ) || ! wp_verify_nonce( $_POST['uwp_notification_nonce'], 'uwp-notification-nonce' ) ) {
97 return;
98 }
99
100 global $uwp_notices;
101 $user_id = get_current_user_id();
102 if (isset($_POST['uwp_mute_notifications']) && !empty($_POST['uwp_mute_notifications'])) {
103 update_user_meta($user_id, 'uwp_mute_notifications', array_map('uwp_clean', (array) $_POST['uwp_mute_notifications']));
104 }
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
114 do_action('uwp_handle_notification_submit', $user_id);
115
116 }
117 }
118 }