PluginProbe
Themify Event Post / trunk
Themify Event Post vtrunk
1.3.7 trunk 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6
themify-event-post / templates / widget-categories.php

widget-categories.php in Themify Event Post trunk, at templates/widget-categories.php

74 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template to display Event Categories widget
4 *
5 * To override this file copy it to <your_theme>/themify-event-post/widget-categories.php
6 *
7 * @var $args
8 * @var $instance
9 * @var $widget
10 *
11 * @package Themify Event Post
12 */
13 $themify_this_widget_id_pre = isset( $args['widget_id'] ) ? $args['widget_id'] : '';
14 $themify_widget_id = $themify_this_widget_id_pre . '-cats';
15 /* User-selected settings. */
16 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $widget->id_base );
17 $parent = isset( $instance['parent'] ) ? $instance['parent'] : null;
18 $depth = isset( $instance['depth'] ) ? $instance['depth'] : null;
19 $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : null;
20 $exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : null;
21 $show_dropdown = isset( $instance['show_dropdown'] ) ? $instance['show_dropdown'] : false;
22 $show_counts = isset( $instance['show_counts'] ) ? $instance['show_counts'] : false;
23 $show_hierarchy = isset( $instance['show_hierarchy'] ) ? $instance['show_hierarchy'] : false;
24
25 /* Before widget (defined by themes). */
26 echo $args['before_widget'];
27
28 /* Title of widget (before and after defined by themes). */
29 if ( $title ) {
30 echo $args['before_title'] , $title , $args['after_title'];
31 }
32
33 $_args = array(
34 'taxonomy' => 'event-category',
35 'orderby' => $orderby,
36 'show_count' => $show_counts,
37 'child_of' => $parent,
38 'exclude' => $exclude,
39 'hierarchical' => $show_hierarchy,
40 'depth' => $depth,
41 'title_li' => '',
42 'id' => $themify_widget_id,
43 );
44
45 if ( $show_dropdown ) {
46 $_args['show_option_none'] = __( 'Select Category', 'themify-event-post' );
47 wp_dropdown_categories( $_args );
48 ?>
49
50 <script type='text/javascript'>
51 /* <![CDATA[ */
52 function onCatChange() {
53 var dropdown = document.getElementById('<?php echo esc_js( $themify_widget_id ); ?>'),
54 catSelected = dropdown.options[dropdown.selectedIndex].value;
55 if ( catSelected > 0 ) {
56 location.href = "<?php echo home_url(); ?>/?cat="+catSelected;
57 }
58 }
59 document.getElementById('<?php echo esc_js( $themify_widget_id ); ?>').onchange = onCatChange;
60 /* ]]> */
61 </script>
62
63 <?php
64 } else {
65 echo '<ul>';
66
67 wp_list_categories( $_args );
68
69 echo '</ul>';
70 }
71
72 /* After widget (defined by themes). */
73 echo $args['after_widget'];
74