PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.20
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.20
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.20, at includes/helpers/tabs.php

225 lines 7.0 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 $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
146 }
147
148
149 /**
150 * Adds Privacy tab to available account tabs if privacy enabled.
151 *
152 * @since 1.0.0
153 * @package userswp
154 *
155 * @return array Account Tabs.
156 */
157 function uwp_account_get_available_tabs() {
158
159 $tabs = array();
160 $type = 'account';
161 if (isset($_GET['type'])) {
162 $type = strip_tags(esc_sql($_GET['type']));
163 }
164
165 if('account' != $type){
166 $tabs['account'] = array(
167 'title' => __( 'Edit Account', 'userswp' ),
168 'icon' => 'fas fa-user',
169 );
170 }
171
172 if('notifications' != $type){
173 $tabs['notifications'] = array(
174 'title' => __( 'Notifications', 'userswp' ),
175 'icon' => 'fas fa-bell',
176 );
177 }
178
179 if('privacy' != $type) {
180 $tabs['privacy'] = array(
181 'title' => __('Privacy', 'userswp'),
182 'icon' => 'fas fa-lock',
183 );
184 }
185
186 return apply_filters( 'uwp_account_available_tabs', $tabs );
187 }
188
189 /**
190 * Returns the setting page tab list for each page.
191 *
192 * @since 1.0.0
193 * @package userswp
194 *
195 * @return array Tabs list.
196 */
197 function uwp_get_settings_tabs() {
198
199 $tabs = array();
200
201 // wp-admin/admin.php?page=uwp
202 $tabs['userswp'] = array(
203 'main' => __( 'General', 'userswp' ),
204 'register' => __( 'Register', 'userswp' ),
205 'login' => __( 'Login', 'userswp' ),
206 'change' => __( 'Change Password', 'userswp' ),
207 'profile' => __( 'Profile', 'userswp' ),
208 'users' => __( 'Users', 'userswp' ),
209 'import-export' => __( 'Import/Export', 'userswp' ),
210 'uninstall' => __( 'Uninstall', 'userswp' ),
211 );
212
213 // wp-admin/admin.php?page=uwp_form_builder
214 $tabs['uwp_form_builder'] = array(
215 'main' => __( 'Form Builder', 'userswp' ),
216 );
217
218 // wp-admin/admin.php?page=uwp_notifications
219 $tabs['uwp_notifications'] = array(
220 'main' => __( 'Users', 'userswp' ),
221 'admin' => __( 'Admin', 'userswp' )
222 );
223
224 return apply_filters( 'uwp_settings_tabs', $tabs );
225 }