PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 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 All 174 releases
← All changes | includes/helpers/tabs.php +107 -127 1.0.211.2.74 View file →
@@ -61,86 +61,53 @@
61 61 * @param array|bool $post_ids Post ids for post__in. Optional
62 62 *
63 63 * @return void
64 64 */
65 -function uwp_generic_tab_content($user, $post_type = false, $title, $post_ids = false) {
66 - ?>
67 - <h3><?php echo $title; ?></h3>
68 - <div class="uwp-profile-item-block">
69 - <?php
70 - $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
65 +function uwp_generic_tab_content($user, $post_type = false, $title = '', $post_ids = false) {
71 66
72 - $args = array(
73 - 'post_status' => 'publish',
74 - 'posts_per_page' => uwp_get_option('profile_no_of_items', 10),
75 - 'author' => $user->ID,
76 - 'paged' => $paged,
77 - );
67 + $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
78 68
79 - if ($post_type) {
80 - $args['post_type'] = $post_type;
81 - }
69 + $query_args = array(
70 + 'post_status' => 'publish',
71 + 'posts_per_page' => uwp_get_option('profile_no_of_items', 10),
72 + 'author' => $user->ID,
73 + 'paged' => $paged,
74 + );
82 75
83 - if (is_array($post_ids)) {
84 - if (!empty($post_ids)) {
85 - $args['post__in'] = $post_ids;
86 - } else {
87 - // no posts found
88 - echo "<p>".__('No '.$title.' Found', 'userswp')."</p>";
89 - return;
90 - }
91 - }
92 - // The Query
93 - $the_query = new WP_Query($args);
76 + if ($post_type) {
77 + $query_args['post_type'] = $post_type;
78 + }
94 79
95 - // The Loop
96 - if ($the_query->have_posts()) {
97 - echo '<ul class="uwp-profile-item-ul">';
98 - while ($the_query->have_posts()) {
99 - $the_query->the_post();
100 - ?>
101 - <li class="uwp-profile-item-li uwp-profile-item-clearfix">
102 - <div class="uwp_generic_thumb_wrap">
103 - <a class="uwp-profile-item-img" href="<?php echo get_the_permalink(); ?>">
104 - <?php
105 - if ( has_post_thumbnail() ) {
106 - $thumb_url = get_the_post_thumbnail_url(get_the_ID(), array(80, 80));
107 - } else {
108 - $thumb_url = USERSWP_PLUGIN_URL."/public/assets/images/no_thumb.png";
109 - }
110 - ?>
111 - <img class="uwp-profile-item-alignleft uwp-profile-item-thumb" src="<?php echo $thumb_url; ?>">
112 - </a>
113 - </div>
80 + if (is_array($post_ids)) {
81 + if (!empty($post_ids)) {
82 + $query_args['post__in'] = $post_ids;
83 + } else {
84 + // no posts found
85 + echo aui()->alert( array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
86 + 'type'=>'info',
87 + 'content'=> esc_html( wp_sprintf( __( 'No %s found', 'userswp' ), strtolower( $title ) ) )
88 + ) );
114 89
115 - <h3 class="uwp-profile-item-title">
116 - <a href="<?php echo get_the_permalink(); ?>"><?php echo get_the_title(); ?></a>
117 - </h3>
118 - <time class="uwp-profile-item-time published" datetime="<?php echo get_the_time('c'); ?>">
119 - <?php echo get_the_date(); ?>
120 - </time>
121 - <div class="uwp-profile-item-summary">
122 - <?php
123 - do_action('uwp_before_profile_summary', get_the_ID(), $user, $post_type);
124 - $excerpt = strip_shortcodes(wp_trim_words( get_the_excerpt(), 15, '...' ));
125 - echo $excerpt;
126 - do_action('uwp_after_profile_summary', get_the_ID(), $user, $post_type);
127 - ?>
128 - </div>
129 - </li>
130 - <?php
131 - }
132 - echo '</ul>';
133 - /* Restore original Post Data */
134 - wp_reset_postdata();
135 - } else {
136 - // no posts found
137 - echo "<p>".__('No '.$title.' Found', 'userswp')."</p>";
138 - }
139 - do_action('uwp_profile_pagination', $the_query->max_num_pages);
140 - ?>
141 - </div>
142 - <?php
90 + return;
91 + }
92 + }
93 +
94 + // The Query
95 + $the_query = new WP_Query($query_args);
96 +
97 + $args = array();
98 + $args['template_args']= array(
99 + 'the_query' => $the_query,
100 + 'user' => $user,
101 + 'post_type' => $post_type,
102 + 'title' => $title,
103 + 'post_ids' => $post_ids,
104 + );
105 +
106 + $design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap');
107 + $template = $design_style ? $design_style."/loop-posts.php" : "loop-posts.php";
108 + uwp_get_template($template, $args);
109 +
143 110 }
144 111
145 112
146 113 /**
@@ -152,71 +119,84 @@
152 119 * @return array Account Tabs.
153 120 */
154 121 function uwp_account_get_available_tabs() {
155 122
156 - $tabs = array();
157 - $type = 'account';
158 - if (isset($_GET['type'])) {
159 - $type = strip_tags(esc_sql($_GET['type']));
160 - }
161 -
162 - if('account' != $type){
163 - $tabs['account'] = array(
123 + $tabs = array(
124 + 'account' => array(
164 125 'title' => __( 'Edit Account', 'userswp' ),
165 126 'icon' => 'fas fa-user',
166 - );
167 - }
127 + ),
128 + 'change-password' => array(
129 + 'title' => __( 'Change Password', 'userswp' ),
130 + 'icon' => 'fas fa-asterisk',
131 + ),
132 + 'notifications' => array(
133 + 'title' => __( 'Notifications', 'userswp' ),
134 + 'icon' => 'fas fa-envelope',
135 + ),
136 + 'privacy' => array(
137 + 'title' => __('Privacy', 'userswp'),
138 + 'icon' => 'fas fa-lock',
139 + ),
140 + );
168 141
169 - if('notifications' != $type){
170 - $tabs['notifications'] = array(
171 - 'title' => __( 'Notifications', 'userswp' ),
172 - 'icon' => 'fas fa-bell',
173 - );
174 - }
142 + $tabs = apply_filters( 'uwp_account_available_tabs', $tabs );
175 143
176 - if('privacy' != $type) {
177 - $tabs['privacy'] = array(
178 - 'title' => __('Privacy', 'userswp'),
179 - 'icon' => 'fas fa-lock',
180 - );
181 - }
144 + if(class_exists('\WP2FA\WP2FA')){
145 + if(1 != uwp_get_option('disable_wp_2fa')) {
146 + $tabs['wp2fa'] = array(
147 + 'title' => __( 'WP - 2FA', 'userswp' ),
148 + 'icon' => 'fas fa-user-lock',
149 + );
150 + }
151 + }
182 152
183 - return apply_filters( 'uwp_account_available_tabs', $tabs );
153 + // Keep delete account and logout last
154 + if(1 != uwp_get_option('disable_account_delete') && !current_user_can('administrator')){
155 + $tabs['delete-account'] = array(
156 + 'title' => __('Delete Account', 'userswp'),
157 + 'icon' => 'fas fa-user-times',
158 + );
159 + }
160 +
161 + $template = new UsersWP_Templates();
162 + $logout_url = $template->uwp_logout_url();
163 +
164 + $tabs['logout'] = array(
165 + 'title' => __('Logout', 'userswp'),
166 + 'icon' => 'fas fa-sign-out-alt',
167 + 'link' => $logout_url,
168 + );
169 +
170 + return apply_filters( 'uwp_account_all_tabs', $tabs );
184 171 }
185 172
186 -/**
187 - * Returns the setting page tab list for each page.
188 - *
189 - * @since 1.0.0
190 - * @package userswp
191 - *
192 - * @return array Tabs list.
193 - */
194 -function uwp_get_settings_tabs() {
173 +function uwp_profile_add_tabs($tab_data){
195 174
196 - $tabs = array();
175 + $obj = new UsersWP_Settings_Profile_Tabs();
176 + $obj->tabs_field_save($tab_data);
197 177
198 - // wp-admin/admin.php?page=uwp
199 - $tabs['userswp'] = array(
200 - 'main' => __( 'General', 'userswp' ),
201 - 'register' => __( 'Register', 'userswp' ),
202 - 'login' => __( 'Login', 'userswp' ),
203 - 'change' => __( 'Change Password', 'userswp' ),
204 - 'profile' => __( 'Profile', 'userswp' ),
205 - 'users' => __( 'Users', 'userswp' ),
206 - 'import-export' => __( 'Import/Export', 'userswp' ),
207 - 'uninstall' => __( 'Uninstall', 'userswp' ),
208 - );
178 +}
209 179
210 - // wp-admin/admin.php?page=uwp_form_builder
211 - $tabs['uwp_form_builder'] = array(
212 - 'main' => __( 'Form Builder', 'userswp' ),
213 - );
180 +function uwp_get_tabs_privacy_by_user($user){
181 + global $wpdb;
214 182
215 - // wp-admin/admin.php?page=uwp_notifications
216 - $tabs['uwp_notifications'] = array(
217 - 'main' => __( 'Users', 'userswp' ),
218 - 'admin' => __( 'Admin', 'userswp' )
219 - );
183 + if(is_integer($user)){
184 + $user = get_userdata($user);
185 + }
220 186
221 - return apply_filters( 'uwp_settings_tabs', $tabs );
187 + $tabs_privacy = array();
188 + $meta_table = get_usermeta_table_prefix() . 'uwp_usermeta';
189 + $obj_key = $user->ID.'_tabs_privacy';
190 + $user_meta_info = wp_cache_get( $obj_key, 'uwp_usermeta_tabs_privacy' );
191 +
192 + if ( ! $user_meta_info ) {
193 + $user_meta_info = $wpdb->get_row($wpdb->prepare("SELECT tabs_privacy FROM {$meta_table} WHERE user_id = %d", $user->ID), ARRAY_A); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
194 + wp_cache_set( $obj_key, $user_meta_info, 'uwp_usermeta_tabs_privacy' );
195 + }
196 +
197 + if(isset($user_meta_info['tabs_privacy']) && !empty($user_meta_info['tabs_privacy'])){
198 + $tabs_privacy = maybe_unserialize($user_meta_info['tabs_privacy']);
199 + }
200 +
201 + return $tabs_privacy;
222 202 }