Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public function form( $instance ) {
  2.  
  3. /* Set up some default widget settings. */
  4. $defaults = array( 'title' => 'Classes by Category' );
  5. $instance = wp_parse_args( (array) $instance, $defaults ); ?>
  6.  
  7. <!-- Widget Title -->
  8. <p>
  9. <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
  10. <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%;" />
  11. </p>
  12.  
  13. <!-- Categories Dropdown -->
  14. <p>
  15. <label for="<?php echo $this->get_field_id( 'cs-category' ); ?>">Choose Class Category:</label>
  16.  
  17. <?php
  18. $dropdown_args = array(
  19. 'taxonomy' => 'cs_categories',
  20. 'id' => $this->get_field_id( 'cs-category' ),
  21. 'show_option_none' => __( 'Select category' ),
  22. 'hide_empty' => true,
  23. 'hierarchical' => true,
  24. 'depth' => 2,
  25. 'echo' => 0,
  26. 'selected' => $instance[ 'cs-category' ],
  27. 'class' => 'widefat'
  28. );
  29.  
  30. echo wp_dropdown_categories( $dropdown_args );
  31. ?>
  32. </p>
  33.  
  34. <?php
  35. }
  36.  
  37. public function update( $new_instance, $old_instance ) {
  38. $instance = $old_instance;
  39. $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
  40. $instance[ 'cs-category' ] = filter_var( $new_instance[ 'cs-category' ], FILTER_SANITIZE_NUMBER_INT );
  41. return $instance;
  42. }
Add Comment
Please, Sign In to add comment