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 +109 -125 1.0.161.2.74 View file →
@@ -61,89 +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 - $excerpt = strip_shortcodes(wp_trim_words( get_the_excerpt(), 15, '...' ));
124 - echo $excerpt;
125 - if ($excerpt) {
126 - ?>
127 - <a href="<?php echo get_the_permalink(); ?>" class="more-link"><?php echo __( 'Read More »', 'userswp' ); ?></a>
128 - <?php
129 - }
130 - ?>
131 - </div>
132 - </li>
133 - <?php
134 - }
135 - echo '</ul>';
136 - /* Restore original Post Data */
137 - wp_reset_postdata();
138 - } else {
139 - // no posts found
140 - echo "<p>".__('No '.$title.' Found', 'userswp')."</p>";
141 - }
142 - do_action('uwp_profile_pagination', $the_query->max_num_pages);
143 - ?>
144 - </div>
145 - <?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 +
146 110 }
147 111
148 112
149 113 /**
@@ -155,64 +119,84 @@
155 119 * @return array Account Tabs.
156 120 */
157 121 function uwp_account_get_available_tabs() {
158 122
159 - $tabs = array();
160 - $type = 'account';
161 - if (isset($_GET['type'])) {
162 - $type = strip_tags(esc_sql($_GET['type']));
163 - }
123 + $tabs = array(
124 + 'account' => array(
125 + 'title' => __( 'Edit Account', 'userswp' ),
126 + 'icon' => 'fas fa-user',
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 + );
164 141
165 - if('account' != $type){
166 - $tabs['account'] = array(
167 - 'title' => __( 'Edit Account', 'userswp' ),
168 - 'icon' => 'fa fa-user',
169 - );
170 - }
142 + $tabs = apply_filters( 'uwp_account_available_tabs', $tabs );
171 143
172 - if('privacy' != $type) {
173 - $tabs['privacy'] = array(
174 - 'title' => __('Privacy', 'userswp'),
175 - 'icon' => 'fa fa-lock',
176 - );
177 - }
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 + }
178 152
179 - 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 );
180 171 }
181 172
182 -/**
183 - * Returns the setting page tab list for each page.
184 - *
185 - * @since 1.0.0
186 - * @package userswp
187 - *
188 - * @return array Tabs list.
189 - */
190 -function uwp_get_settings_tabs() {
173 +function uwp_profile_add_tabs($tab_data){
191 174
192 - $tabs = array();
175 + $obj = new UsersWP_Settings_Profile_Tabs();
176 + $obj->tabs_field_save($tab_data);
193 177
194 - // wp-admin/admin.php?page=uwp
195 - $tabs['userswp'] = array(
196 - 'main' => __( 'General', 'userswp' ),
197 - 'register' => __( 'Register', 'userswp' ),
198 - 'login' => __( 'Login', 'userswp' ),
199 - 'change' => __( 'Change Password', 'userswp' ),
200 - 'profile' => __( 'Profile', 'userswp' ),
201 - 'users' => __( 'Users', 'userswp' ),
202 - 'import-export' => __( 'Import/Export', 'userswp' ),
203 - 'uninstall' => __( 'Uninstall', 'userswp' ),
204 - );
178 +}
205 179
206 - // wp-admin/admin.php?page=uwp_form_builder
207 - $tabs['uwp_form_builder'] = array(
208 - 'main' => __( 'Form Builder', 'userswp' ),
209 - );
180 +function uwp_get_tabs_privacy_by_user($user){
181 + global $wpdb;
210 182
211 - // wp-admin/admin.php?page=uwp_notifications
212 - $tabs['uwp_notifications'] = array(
213 - 'main' => __( 'Users', 'userswp' ),
214 - 'admin' => __( 'Admin', 'userswp' )
215 - );
183 + if(is_integer($user)){
184 + $user = get_userdata($user);
185 + }
216 186
217 - 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;
218 202 }