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

profile-tabs.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.47, at widgets/profile-tabs.php

190 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5
6 /**
7 * UsersWP profile tabs widget.
8 *
9 * @since 1.1.2
10 */
11 class UWP_Profile_Tabs_Widget extends WP_Super_Duper {
12
13 /**
14 * Register the profile tabs widget with WordPress.
15 *
16 */
17 public function __construct() {
18
19
20 $options = array(
21 'textdomain' => 'userswp',
22 'block-icon' => 'admin-site',
23 'block-category'=> 'widgets',
24 'block-keywords'=> "['userswp','profile']",
25 'class_name' => __CLASS__,
26 'base_id' => 'uwp_profile_tabs',
27 'name' => __('UWP > Profile Tabs','userswp'),
28 //'no_wrap' => true,
29 'widget_ops' => array(
30 'classname' => 'uwp-profile-tabs bsui',
31 'description' => esc_html__('Displays profile tabs.','userswp'),
32 ),
33 'arguments' => array(
34 'title' => array(
35 'title' => __( 'Title', 'userswp' ),
36 'desc' => __( 'Enter widget title.', 'userswp' ),
37 'type' => 'text',
38 'desc_tip' => true,
39 'default' => '',
40 'advanced' => false
41 ),
42 'output' => array(
43 'title' => __('Output Type:', 'userswp'),
44 'desc' => __('What parts should be output.', 'userswp'),
45 'type' => 'select',
46 'options' => array(
47 "" => __('Default', 'userswp'),
48 "head" => __('Head only', 'userswp'),
49 "body" => __('Body only', 'userswp'),
50 "json" => __('JSON Array (developer option)', 'userswp'),
51 ),
52 'default' => '',
53 'desc_tip' => true,
54 'advanced' => true
55 ),
56 'disable_greedy' => array(
57 'title' => __('Disable Greedy Menu', 'userswp'),
58 'desc' => __('Greedy menu prevents a large menu falling onto another line by adding a dropdown select.', 'userswp'),
59 'type' => 'checkbox',
60 'desc_tip' => true,
61 'value' => '1',
62 'default' => '',
63 'advanced' => true,
64 ),
65 )
66
67 );
68
69
70 parent::__construct( $options );
71 }
72
73 /**
74 * The Super block output function.
75 *
76 * @param array $args
77 * @param array $widget_args
78 * @param string $content
79 *
80 * @return mixed|string|bool
81 */
82 public function output( $args = array(), $widget_args = array(), $content = '' ) {
83 global $userswp;
84
85 $user = uwp_get_user_by_author_slug();
86
87 if(!$user){
88 return '';
89 }
90
91 $defaults = array(
92 'output' => '',
93 );
94
95 $args = wp_parse_args( $args, $defaults );
96
97 $tabs_array = $userswp->profile->get_tabs();
98 $args['tabs_array'] = $tabs_array;
99 $active_tab = '';
100 if(!empty($tabs_array)){
101 if(!empty(get_query_var('uwp_tab'))){
102 foreach($tabs_array as $key => $tab){
103 if(get_query_var('uwp_tab')==$tab['tab_key']){
104 $active_tab = $tab['tab_key'];
105 }
106 }
107 }else{
108 $active_tab = $tabs_array[0]['tab_key'];
109 }
110
111 }
112
113 // error/warning messages
114 if (!$active_tab && isset($tabs_array[0]['tab_key']) ) {
115
116 $no_tab = $tabs_array[0];
117 $no_tab['tab_key'] = 'not_found';
118 $no_tab['tab_name'] = __("Not Found","userswp");
119 $no_tab['tab_icon'] = 'fas fa-exclamation-triangle';
120 $no_tab['tab_content'] = '';
121 $no_tab['tab_content_rendered'] = aui()->alert(array(
122 'type'=>'error',
123 'content'=> __('<strong>ERROR</strong>: This tab does not exist.', 'userswp')
124 )
125 );
126 $no_tab['tab_level'] = 0;
127 $no_tab['tab_parent'] = 0;
128
129 array_unshift( $tabs_array, $no_tab ); // push to start of array
130 $active_tab = $tabs_array[0]['tab_key']; // set it as active
131 $args['tabs_array'] = $tabs_array; // update the array
132
133 }elseif(!$active_tab){
134 if(current_user_can('manage_options' )){
135 $no_tab = array();
136 $no_tab['tab_key'] = 'no_tabs';
137 $no_tab['tab_name'] = __("No Tabs","userswp");
138 $no_tab['tab_icon'] = 'fas fa-exclamation-triangle';
139 $no_tab['tab_content'] = '';
140 $no_tab['tab_content_rendered'] = aui()->alert(array(
141 'type'=>'warning',
142 'content'=> sprintf( __('No content, please make sure tabs have been added %shere.%s', 'userswp'), "<a href='".admin_url( 'admin.php?page=uwp_form_builder&tab=profile-tabs')."'>","</a>" )
143 )
144 );
145 $no_tab['tab_level'] = 0;
146 $no_tab['tab_parent'] = 0;
147
148 array_unshift( $tabs_array, $no_tab ); // push to start of array
149 $active_tab = $tabs_array[0]['tab_key']; // set it as active
150 $args['tabs_array'] = $tabs_array; // update the array
151 }else{
152 $no_tab = array();
153 $no_tab['tab_key'] = 'no_tabs';
154 $no_tab['tab_name'] = __("No Tabs","userswp");
155 $no_tab['tab_icon'] = 'fas fa-exclamation-triangle';
156 $no_tab['tab_content'] = '';
157 $no_tab['tab_content_rendered'] = aui()->alert(array(
158 'type'=>'warning',
159 'content'=> __('No content found.', 'userswp')
160 )
161 );
162 $no_tab['tab_level'] = 0;
163 $no_tab['tab_parent'] = 0;
164
165 array_unshift( $tabs_array, $no_tab ); // push to start of array
166 $active_tab = $tabs_array[0]['tab_key']; // set it as active
167 $args['tabs_array'] = $tabs_array; // update the array
168 }
169
170 }
171
172 $args['active_tab'] = $active_tab;
173
174 // output JSON
175 if($args['output']=='json'){
176 return json_encode( $tabs_array );
177 }
178
179 ob_start();
180
181 $design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap');
182 $template = $design_style ? $design_style."/profile-tabs.php" : "profile-tabs.php";
183
184 uwp_get_template($template, $args);
185
186 return ob_get_clean();
187
188 }
189
190 }