wc_ps_search_form

Wc_ps_search_form().

Description

wc_ps_search_form( (string) $ps_id = '', (string) $template = 'sidebar', (array) $args = array(), (bool) $echo = false ); 

Parameters (4)

0. $ps_id — Optional. (string) => ''
The ps id.
1. $template — Optional. (string) => 'sidebar'
The template.
2. $args — Optional. (array) => array()
The args.
3. $echo — Optional. (bool) => false
The echo.

Usage

  1. if ( !function_exists( 'wc_ps_search_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-predictive-search-lite/includes/wc-predictive-template-functions.php'; 
  3.  
  4. // The ps id. 
  5. $ps_id = ''; 
  6.  
  7. // The template. 
  8. $template = 'sidebar'; 
  9.  
  10. // The args. 
  11. $args = array(); 
  12.  
  13. // The echo. 
  14. $echo = false; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wc_ps_search_form($ps_id, $template, $args, $echo); 
  18.  

Defined (1)

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

/includes/wc-predictive-template-functions.php  
  1. function wc_ps_search_form( $ps_id = '', $template = 'sidebar', $args = array(), $echo = false ) { 
  2.  
  3. $ps_id = str_replace( 'products_predictive_search-', '', $ps_id ); 
  4. if ( empty( $ps_id ) ) { 
  5. $ps_id = rand( 100, 10000 ); 
  6.  
  7. ob_start(); 
  8.  
  9. // Custom Style for Individual Predictive Search Widget 
  10. $custom_style = ''; 
  11. if ( isset( $args['show_image'] ) && 0 == $args['show_image'] ) { 
  12. $custom_style .= ' 
  13. .ac_results_' . $ps_id . ' .rs_avatar { 
  14. display: none !important; 
  15. .predictive_results.ac_results_' . $ps_id . ' .rs_content_popup { 
  16. width: 100% !important; 
  17. }'; 
  18. if ( isset( $args['show_desc'] ) && 0 == $args['show_desc'] ) { 
  19. $custom_style .= ' 
  20. .ac_results_' . $ps_id . ' .rs_description { 
  21. display: none !important; 
  22. }'; 
  23.  
  24. if ( '' != trim( $custom_style ) ) { 
  25. echo '<style>' . $custom_style . '</style>'; 
  26.  
  27. if ( 'header' == $template ) { 
  28. wc_ps_search_form_header_tpl( $ps_id, $args ); 
  29. } else { 
  30. wc_ps_search_form_sidebar_tpl( $ps_id, $args ); 
  31.  
  32. $search_form = ob_get_clean(); 
  33.  
  34. if ( $echo ) { 
  35. echo $search_form; 
  36. } else { 
  37. return $search_form;