PluginProbe
WP Team – WordPress Team Member Plugin / trunk
WP Team – WordPress Team Member Plugin vtrunk
trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
ht-team-member / include / default_widgets.php

default_widgets.php in WP Team – WordPress Team Member Plugin trunk, at include/default_widgets.php

304 lines 15.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !class_exists('htteammember_default_widgets') ) {
4 class htteammember_default_widgets extends WP_Widget{
5
6 function __construct(){
7
8 add_action( 'load-widgets.php', array( $this, 'htteammember_widgets_assest') );
9
10 $widget_options = array(
11 'description' => esc_html__('WP TeamMember', 'ht-teammember'),
12 'customize_selective_refresh' => true,
13 );
14
15 parent:: __construct('htteammember_default_widgets', esc_html__( 'HT : TeamMember', 'ht-teammember'), $widget_options );
16
17 }
18
19 public function htteammember_widgets_assest() {
20 wp_enqueue_style( 'wp-color-picker' );
21 wp_enqueue_script( 'wp-color-picker' );
22 }
23
24 /**
25 * Front-end display of widget.
26 *
27 * @see WP_Widget::widget()
28 *
29 * @param array $args Widget arguments.
30 * @param array $instance Saved values from database.
31 */
32 public function widget($args, $instance){
33
34 $title = isset( $instance['title'] ) ? $instance['title'] : '';
35 $limit = isset( $instance['limit'] ) ? $instance['limit'] : 1;
36 $column = isset( $instance['column'] ) ? $instance['column'] : 1;
37 $layout = isset( $instance['layout'] ) ? $instance['layout'] : 1;
38 $order = isset( $instance['order'] ) ? $instance['order'] : 'DESC';
39 $show_name = isset( $instance['show_name'] ) ? $instance['show_name'] : '';
40 $show_designation = isset( $instance['show_designation'] ) ? $instance['show_designation'] : '';
41 $show_bio = isset( $instance['show_bio'] ) ? $instance['show_bio'] : '';
42 $show_socialmedia = isset( $instance['show_socialmedia'] ) ? $instance['show_socialmedia'] : '';
43 $teams_list = isset( $instance['teams_list'] ) ? $instance['teams_list'] : '';
44
45 $name_color = isset( $instance['name_color'] ) ? $instance['name_color'] : '';
46 $bio_color = isset( $instance['bio_color'] ) ? $instance['bio_color'] : '';
47 $desi_color = isset( $instance['desi_color'] ) ? $instance['desi_color'] : '';
48 $social_color = isset( $instance['social_color'] ) ? $instance['social_color'] : '';
49 $social_hovcolor = isset( $instance['social_hovcolor'] ) ? $instance['social_hovcolor'] : '';
50
51 // Slider Options value
52 $slideron = htteammember_get_option( 'slideron', 'htteam_widgets_options_tabs' );
53 $slarrows = htteammember_get_option( 'slarrows', 'htteam_widgets_options_tabs' );
54 $sldots = htteammember_get_option( 'sldots', 'htteam_widgets_options_tabs' );
55 $slautolay = htteammember_get_option( 'slautolay', 'htteam_widgets_options_tabs' );
56 $slautoplay_speed = htteammember_get_option( 'slautoplay_speed', 'htteam_widgets_options_tabs' );
57 $slanimation_speed = htteammember_get_option( 'slanimation_speed', 'htteam_widgets_options_tabs' );
58 $slcentermode = htteammember_get_option( 'slcentermode', 'htteam_widgets_options_tabs' );
59 $slcenterpadding = htteammember_get_option( 'slcenterpadding', 'htteam_widgets_options_tabs' );
60 $slitems = htteammember_get_option( 'slitems', 'htteam_widgets_options_tabs' );
61 $slrows = htteammember_get_option( 'slrows', 'htteam_widgets_options_tabs' );
62 $sltablet_display_columns = htteammember_get_option( 'sltablet_display_columns', 'htteam_widgets_options_tabs' );
63 $slmobile_display_columns = htteammember_get_option( 'slmobile_display_columns', 'htteam_widgets_options_tabs' );
64
65 $shortcode_atts = [
66 'limit' => 'limit="'.$limit.'"',
67 'column' => 'column="'.$column.'"',
68 'layout' => 'layout="'.$layout.'"',
69 'order' => 'order="'.$order.'"',
70 'show_name' => 'show_name="'.$show_name.'"',
71 'show_designation' => 'show_designation="'.$show_designation.'"',
72 'show_bio' => 'show_bio="'.$show_bio.'"',
73 'show_socialmedia' => 'show_socialmedia="'.$show_socialmedia.'"',
74 'teams_list' => 'teams_list="'.$teams_list.'"',
75
76 'slideron' => 'slideron="'.( $slideron == 'on' ? 'yes' : 'no' ).'"',
77 'slarrows' => 'slarrows="'.( $slarrows == 'on' ? 'yes' : 'no' ).'"',
78 'slprevicon' => 'slprevicon="fa fa-angle-left"',
79 'slnexticon' => 'slnexticon="fa fa-angle-right"',
80 'sldots' => 'sldots="'.( $sldots == 'on' ? 'yes' : 'no' ).'"',
81 'slautolay' => 'slautolay="'.( $slautolay == 'on' ? 'yes' : 'no' ).'"',
82 'slautoplay_speed' => 'slautoplay_speed="'.$slautoplay_speed.'"',
83 'slanimation_speed' => 'slanimation_speed="'.$slanimation_speed.'"',
84 'slcentermode' => 'slcentermode="'.( $slcentermode == 'on' ? 'yes' : 'no' ).'"',
85 'slcenterpadding' => 'slcenterpadding="'.$slcenterpadding.'"',
86 'slitems' => 'slitems="'.( $slitems <= 0 ? 1 : $slitems ).'"',
87 'slrows' => 'slrows="'.( $slrows <= 0 ? 1 : $slrows ).'"',
88 'slscroll_columns' => 'slscroll_columns="1"',
89 'sltablet_width' => 'sltablet_width="750"',
90 'sltablet_display_columns' => 'sltablet_display_columns="'.( $sltablet_display_columns <= 0 ? 1 : $sltablet_display_columns).'"',
91 'sltablet_scroll_columns' => 'sltablet_scroll_columns="1"',
92 'slmobile_width' => 'slmobile_width="480"',
93 'slmobile_display_columns' => 'slmobile_display_columns="'.( $slmobile_display_columns <= 0 ? 1 : $slmobile_display_columns ).'"',
94 'slmobile_scroll_columns' => 'slmobile_scroll_columns="1"',
95
96 'name_color' => 'name_color="'.$name_color.'"',
97 'bio_color' => 'bio_color="'.$bio_color.'"',
98 'desi_color' => 'desi_color="'.$desi_color.'"',
99 'social_color' => 'social_color="'.$social_color.'"',
100 'social_hovcolor' => 'social_hovcolor="'.$social_hovcolor.'"',
101 ];
102
103 // Render Html
104 echo $args['before_widget'];
105 if ( !empty( $title ) ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; }
106 ?>
107 <div class="htteammember-widgets">
108 <?php echo do_shortcode( sprintf( '[htteamember %s]', implode(' ', $shortcode_atts ) ) ); ?>
109 </div>
110 <?php echo $args['after_widget'];
111 }
112
113
114 /**
115 * Sanitize widget form values as they are saved.
116 *
117 * @see WP_Widget::update()
118 *
119 * @param array $new_instance Values just sent to be saved.
120 * @param array $old_instance Previously saved values from database.
121 *
122 * @return array Updated safe values to be saved.
123 */
124
125 public function update( $new_instance, $old_instance ) {
126 $instance = $old_instance;
127 $instance['title'] = strip_tags($new_instance['title']);
128 $instance['limit'] = $new_instance['limit'];
129 $instance['column'] = $new_instance['column'];
130 $instance['layout'] = $new_instance['layout'];
131 $instance['order'] = $new_instance['order'];
132 $instance['show_name'] = $new_instance['show_name'];
133 $instance['show_designation'] = $new_instance['show_designation'];
134 $instance['show_bio'] = $new_instance['show_bio'];
135 $instance['show_socialmedia'] = $new_instance['show_socialmedia'];
136 $instance['teams_list'] = $new_instance['teams_list'];
137
138 $instance['name_color'] = $new_instance['name_color'];
139 $instance['bio_color'] = $new_instance['bio_color'];
140 $instance['desi_color'] = $new_instance['desi_color'];
141 $instance['social_color'] = $new_instance['social_color'];
142 $instance['social_hovcolor'] = $new_instance['social_hovcolor'];
143 return $instance;
144 }
145
146 /**
147 * Back-end widget form.
148 *
149 * @see WP_Widget::form()
150 *
151 * @param array $instance Previously saved values from database.
152 */
153
154 public function form( $instance ){
155
156 $array_default = array(
157 'title' => 'HT TeamMember'
158 ,'limit' => 1
159 ,'column' => 1
160 ,'layout' => 1
161 ,'order' => 'ASC'
162 ,'show_name' => 'yes'
163 ,'show_designation' => 'yes'
164 ,'show_bio' => 'yes'
165 ,'show_socialmedia' => 'yes'
166 ,'teams_list' => ''
167
168 ,'name_color' => ''
169 ,'bio_color' => ''
170 ,'desi_color' => ''
171 ,'social_color' => ''
172 ,'social_hovcolor' => ''
173 );
174 $instance = wp_parse_args( (array) $instance, $array_default );
175
176 ?>
177
178
179 <p>
180 <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Enter your title', 'ht-teammember'); ?> </label>
181 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
182 </p>
183
184 <p>
185 <label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php echo esc_html__('Item Limit:' ,'ht-teammember') ?></label>
186 <input id="<?php echo esc_attr($this->get_field_id('limit')); ?>" name="<?php echo esc_attr($this->get_field_name('limit')); ?>" type="number" class="widefat" value="<?php echo esc_attr($instance['limit']); ?>">
187 </p>
188
189 <p>
190 <label for="<?php echo $this->get_field_id('layout'); ?>"><?php esc_html_e('Layout', 'ht-teammember'); ?> </label>
191 <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>" name="<?php echo $this->get_field_name('layout'); ?>" >
192 <?php for( $i = 1; $i <= 5; $i++ ): ?>
193 <option value="<?php echo $i; ?>" <?php selected( $instance['layout'], $i ); ?> ><?php echo 'Layout '.$i; ?></option>
194 <?php endfor; ?>
195 </select>
196 </p>
197
198 <p>
199 <label for="<?php echo $this->get_field_id('column'); ?>"><?php esc_html_e('Column', 'ht-teammember'); ?> </label>
200 <select class="widefat" id="<?php echo $this->get_field_id('column'); ?>" name="<?php echo $this->get_field_name('column'); ?>" >
201 <?php for( $i = 1; $i <= 6; $i++ ): ?>
202 <option value="<?php echo $i; ?>" <?php selected($instance['column'], $i); ?> ><?php echo $i; ?></option>
203 <?php endfor; ?>
204 </select>
205 </p>
206
207 <p>
208 <label for="<?php echo $this->get_field_id('order'); ?>"><?php esc_html_e('Order', 'ht-teammember'); ?> </label>
209 <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" >
210 <option value="ASC" <?php selected($instance['order'], 'ASC'); ?> >Ascending</option>
211 <option value="DESC" <?php selected($instance['order'], 'DESC'); ?> >Descending</option>
212 </select>
213 </p>
214
215 <p>
216 <label for="<?php echo $this->get_field_id('show_name'); ?>"><?php esc_html_e('Show Name', 'ht-teammember'); ?> </label>
217 <select class="widefat" id="<?php echo $this->get_field_id('show_name'); ?>" name="<?php echo $this->get_field_name('show_name'); ?>" >
218 <option value="yes" <?php selected($instance['show_name'], 'yes'); ?> ><?php esc_html_e('Yes','ht-teammember');?></option>
219 <option value="no" <?php selected($instance['show_name'], 'no'); ?> ><?php esc_html_e('No','ht-teammember');?></option>
220 </select>
221 </p>
222
223 <p>
224 <label for="<?php echo $this->get_field_id('show_designation'); ?>"><?php esc_html_e('Show Designation', 'ht-teammember'); ?> </label>
225 <select class="widefat" id="<?php echo $this->get_field_id('show_designation'); ?>" name="<?php echo $this->get_field_name('show_designation'); ?>" >
226 <option value="yes" <?php selected($instance['show_designation'], 'yes'); ?> ><?php esc_html_e('Yes','ht-teammember');?></option>
227 <option value="no" <?php selected($instance['show_designation'], 'no'); ?> ><?php esc_html_e('No','ht-teammember');?></option>
228 </select>
229 </p>
230
231 <p>
232 <label for="<?php echo $this->get_field_id('show_bio'); ?>"><?php esc_html_e('Show Bio', 'ht-teammember'); ?> </label>
233 <select class="widefat" id="<?php echo $this->get_field_id('show_bio'); ?>" name="<?php echo $this->get_field_name('show_bio'); ?>" >
234 <option value="yes" <?php selected($instance['show_bio'], 'yes'); ?> ><?php esc_html_e('Yes','ht-teammember');?></option>
235 <option value="no" <?php selected($instance['show_bio'], 'no'); ?> ><?php esc_html_e('No','ht-teammember');?></option>
236 </select>
237 </p>
238
239 <p>
240 <label for="<?php echo $this->get_field_id('show_socialmedia'); ?>"><?php esc_html_e('Show Social Media', 'ht-teammember'); ?> </label>
241 <select class="widefat" id="<?php echo $this->get_field_id('show_socialmedia'); ?>" name="<?php echo $this->get_field_name('show_socialmedia'); ?>" >
242 <option value="yes" <?php selected($instance['show_socialmedia'], 'yes'); ?> ><?php esc_html_e('Yes','ht-teammember');?></option>
243 <option value="no" <?php selected($instance['show_socialmedia'], 'no'); ?> ><?php esc_html_e('No','ht-teammember');?></option>
244 </select>
245 </p>
246
247 <p>
248 <label for="<?php echo $this->get_field_id('teams_list'); ?>"><?php esc_html_e('Individual Id', 'ht-teammember'); ?> </label>
249 <input class="widefat" id="<?php echo $this->get_field_id('teams_list'); ?>" name="<?php echo $this->get_field_name('teams_list'); ?>" type="text" value="<?php echo esc_attr($instance['teams_list']); ?>" />
250 </p>
251
252 <p>
253 <label><?php esc_html_e( 'Style Area', 'ht-teammember' ); ?></label>
254 </p><hr/>
255
256 <table width="100%">
257
258 <tr>
259 <td><label for="<?php echo $this->get_field_id( 'name_color' ); ?>"><?php esc_html_e( 'Name Color', 'ht-teammember' ); ?></label></td>
260 <td><input class="ht-color-picker" type="text" id="<?php echo $this->get_field_id( 'name_color' ); ?>" name="<?php echo $this->get_field_name( 'name_color' ); ?>" value="<?php echo esc_attr( $instance['name_color'] ); ?>" /></td>
261 </tr>
262
263 <tr>
264 <td><label for="<?php echo $this->get_field_id( 'bio_color' ); ?>"><?php esc_html_e( 'Bio Color', 'ht-teammember' ); ?></label></td>
265 <td><input class="ht-color-picker" type="text" id="<?php echo $this->get_field_id( 'bio_color' ); ?>" name="<?php echo $this->get_field_name( 'bio_color' ); ?>" value="<?php echo esc_attr( $instance['bio_color'] ); ?>" /></td>
266 </tr>
267
268 <tr>
269 <td><label for="<?php echo $this->get_field_id( 'desi_color' ); ?>"><?php esc_html_e( 'Designation Color', 'ht-teammember' ); ?></label></td>
270 <td><input class="ht-color-picker" type="text" id="<?php echo $this->get_field_id( 'desi_color' ); ?>" name="<?php echo $this->get_field_name( 'desi_color' ); ?>" value="<?php echo esc_attr( $instance['desi_color'] ); ?>" /></td>
271 </tr>
272
273 <tr>
274 <td><label for="<?php echo $this->get_field_id( 'social_color' ); ?>"><?php esc_html_e( 'Social Icon Color', 'ht-teammember' ); ?></label></td>
275 <td><input class="ht-color-picker" type="text" id="<?php echo $this->get_field_id( 'social_color' ); ?>" name="<?php echo $this->get_field_name( 'social_color' ); ?>" value="<?php echo esc_attr( $instance['social_color'] ); ?>" /></td>
276 </tr>
277
278 <tr>
279 <td><label for="<?php echo $this->get_field_id( 'social_hovcolor' ); ?>"><?php esc_html_e( 'Social icon Hover Color', 'ht-teammember' ); ?></label></td>
280 <td><input class="ht-color-picker" type="text" id="<?php echo $this->get_field_id( 'social_hovcolor' ); ?>" name="<?php echo $this->get_field_name( 'social_hovcolor' ); ?>" value="<?php echo esc_attr( $instance['social_hovcolor'] ); ?>" /></td>
281 </tr>
282
283 </table>
284
285 <script type='text/javascript'>
286 jQuery(document).ready(function($) {
287 $('.ht-color-picker').wpColorPicker();
288 });
289 </script>
290
291 <?php }
292
293 } // end extends class
294 } // end exists class
295
296
297 // Register Author information widget.
298
299 function htteammember_default_widgets() {
300 register_widget( 'htteammember_default_widgets' );
301 }
302 add_action( 'widgets_init', 'htteammember_default_widgets' );
303
304