PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.21
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.21
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 1.0.22 All 173 releases
userswp / includes / helpers / tabs.php

tabs.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.21, at includes/helpers/tabs.php

222 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Checks the current page is a UsersWP profile tab page.
4 *
5 * @since 1.0.0
6 * @package userswp
7 * @param string|bool $tab Tab slug.
8 * @return bool True when success. False when failure.
9 */
10 function is_uwp_profile_tab($tab = false) {
11 global $wp_query;
12 if (is_uwp_profile_page()) {
13 if (isset($wp_query->query_vars['uwp_tab']) && !empty($wp_query->query_vars['uwp_tab'])) {
14 if ($wp_query->query_vars['uwp_tab'] == $tab) {
15 return true;
16 } else {
17 return false;
18 }
19 } else {
20 return false;
21 }
22 } else {
23 return false;
24 }
25 }
26
27 /**
28 * Checks the current page is a UsersWP profile subtab page.
29 *
30 * @since 1.0.0
31 * @package userswp
32 * @param string|bool $subtab Subtab slug.
33 * @return bool True when success. False when failure.
34 */
35 function is_uwp_profile_subtab($subtab = false) {
36 global $wp_query;
37 if (is_uwp_profile_page()) {
38 if (isset($wp_query->query_vars['uwp_subtab']) && !empty($wp_query->query_vars['uwp_subtab'])) {
39 if ($wp_query->query_vars['uwp_subtab'] == $subtab) {
40 return true;
41 } else {
42 return false;
43 }
44 } else {
45 return false;
46 }
47 } else {
48 return false;
49 }
50 }
51
52 /**
53 * Prints the tab content based on post type.
54 *
55 * @since 1.0.0
56 * @package userswp
57 *
58 * @param object $user User object.
59 * @param bool $post_type Post type.
60 * @param string $title Tab title
61 * @param array|bool $post_ids Post ids for post__in. Optional
62 *
63 * @return void
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;
71
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 );
78
79 if ($post_type) {
80 $args['post_type'] = $post_type;
81 }
82
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);
94
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>
114
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
143 }
144
145
146 /**
147 * Adds Privacy tab to available account tabs if privacy enabled.
148 *
149 * @since 1.0.0
150 * @package userswp
151 *
152 * @return array Account Tabs.
153 */
154 function uwp_account_get_available_tabs() {
155
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(
164 'title' => __( 'Edit Account', 'userswp' ),
165 'icon' => 'fas fa-user',
166 );
167 }
168
169 if('notifications' != $type){
170 $tabs['notifications'] = array(
171 'title' => __( 'Notifications', 'userswp' ),
172 'icon' => 'fas fa-bell',
173 );
174 }
175
176 if('privacy' != $type) {
177 $tabs['privacy'] = array(
178 'title' => __('Privacy', 'userswp'),
179 'icon' => 'fas fa-lock',
180 );
181 }
182
183 return apply_filters( 'uwp_account_available_tabs', $tabs );
184 }
185
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() {
195
196 $tabs = array();
197
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 );
209
210 // wp-admin/admin.php?page=uwp_form_builder
211 $tabs['uwp_form_builder'] = array(
212 'main' => __( 'Form Builder', 'userswp' ),
213 );
214
215 // wp-admin/admin.php?page=uwp_notifications
216 $tabs['uwp_notifications'] = array(
217 'main' => __( 'Users', 'userswp' ),
218 'admin' => __( 'Admin', 'userswp' )
219 );
220
221 return apply_filters( 'uwp_settings_tabs', $tabs );
222 }