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

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

217 lines 6.8 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
161 $tabs['account'] = array(
162 'title' => __( 'Edit Account', 'userswp' ),
163 'icon' => 'fa fa-user',
164 );
165
166 $extra_where = "AND is_public='2'";
167 $fields = get_account_form_fields($extra_where);
168 $fields = apply_filters('uwp_account_privacy_fields', $fields);
169
170 $make_profile_private = uwp_can_make_profile_private();
171
172 if ((is_array($fields) && count($fields) > 0) || $make_profile_private) {
173 $tabs['privacy'] = array(
174 'title' => __( 'Privacy', 'userswp' ),
175 'icon' => 'fa fa-lock',
176 );
177 }
178
179 return apply_filters( 'uwp_account_available_tabs', $tabs );
180 }
181
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() {
191
192 $tabs = array();
193
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 'uninstall' => __( 'Uninstall', 'userswp' ),
203 );
204
205 // wp-admin/admin.php?page=uwp_form_builder
206 $tabs['uwp_form_builder'] = array(
207 'main' => __( 'Form Builder', 'userswp' ),
208 );
209
210 // wp-admin/admin.php?page=uwp_notifications
211 $tabs['uwp_notifications'] = array(
212 'main' => __( 'Users', 'userswp' ),
213 'admin' => __( 'Admin', 'userswp' )
214 );
215
216 return apply_filters( 'uwp_settings_tabs', $tabs );
217 }