BWS_Search_Widget

The Bootstrap Widget Styling BWS Search Widget class.

Defined (1)

The class is defined in the following location(s).

/includes/class-bws-search-widget.php  
  1. class BWS_Search_Widget { 
  2.  
  3. private static $instance ; 
  4. private $markup ; 
  5.  
  6. private function __construct( $markup ) { 
  7. $this->markup = $markup ; 
  8.  
  9. public static function filter( $markup ) { 
  10. self::$instance = new self( $markup ) ; 
  11. return self::$instance->maybe_filter_markup() ; 
  12.  
  13. private function maybe_filter_markup() { 
  14. if ( ! $this->theme_has_a_search_template() ) { 
  15. $this->filter_search_markup() ; 
  16. return $this->markup ; 
  17.  
  18. function theme_has_a_search_template() { 
  19. $template = locate_template( 'searchform.php' ) ; 
  20. return ( '' != $template ) ; 
  21.  
  22. function filter_search_markup() { 
  23. $this->add_input_group_class_to_opening_div() ; 
  24. $this->remove_label() ; 
  25. $this->add_form_control_class_to_text_input() ; 
  26. $this->add_class_to_submit_button() ; 
  27. $this->wrap_submit_button_in_div() ; 
  28.  
  29. function add_input_group_class_to_opening_div() { 
  30. $this->markup = str_replace( '<div>' , '<div class="input-group">' , $this->markup ) ; 
  31.  
  32. function remove_label() { 
  33. $this->markup = preg_replace( '/<label.*?<\/label>/' , '' , $this->markup ) ; 
  34.  
  35. function add_form_control_class_to_text_input() { 
  36. $this->markup = str_replace( '<input type="text"' , '<input type="text" class="form-control"' , $this->markup ) ; 
  37.  
  38. function add_class_to_submit_button() { 
  39. $this->markup = str_replace( '<input type="submit"' , '<input type="submit" class="btn btn-primary btn-med"' , $this->markup ) ; 
  40.  
  41. function wrap_submit_button_in_div() { 
  42. $this->markup = preg_replace( '/(<input type="submit".*?>)/' , '<div class="input-group-btn">$1</div>' , $this->markup ) ; 
  43.  
  44. } /** End BWS_Search_Widget */