Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function form( $instance ) {
- /* Set up some default widget settings. */
- $defaults = array( 'title' => 'Classes by Category' );
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
- <!-- Widget Title -->
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
- <input type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
- </p>
- <!-- Categories Dropdown -->
- <p>
- <label for="<?php echo $this->get_field_id( 'cs-category' ); ?>">Choose Class Category:</label>
- <?php
- $dropdown_args = array(
- 'taxonomy' => 'cs_categories',
- 'id' => $this->get_field_id( 'cs-category' ),
- 'show_option_none' => __( 'Select category' ),
- 'hide_empty' => true,
- 'hierarchical' => true,
- 'depth' => 2,
- 'echo' => 0,
- 'selected' => $instance[ 'cs-category' ],
- 'class' => 'widefat'
- );
- echo wp_dropdown_categories( $dropdown_args );
- ?>
- </p>
- <?php
- }
- public function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
- $instance[ 'cs-category' ] = filter_var( $new_instance[ 'cs-category' ], FILTER_SANITIZE_NUMBER_INT );
- return $instance;
- }
Add Comment
Please, Sign In to add comment