| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bricks Builder Property Search Form Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 9 |
|
| 10 |
class Bricks_Builder_Property_Search_Form_Widget extends \Bricks\Element { |
| 11 |
|
| 12 |
// Element properties |
| 13 |
public $category = 'propertyhive'; |
| 14 |
public $name = 'bricks-builder-property-search-form'; |
| 15 |
public $icon = 'fas fa-magnifying-glass'; |
| 16 |
public $scripts = ['toggleDepartmentFields']; |
| 17 |
|
| 18 |
public function get_label() |
| 19 |
{ |
| 20 |
return esc_html__( 'Search Form', 'propertyhive' ); |
| 21 |
} |
| 22 |
|
| 23 |
// Enqueue element styles and scripts |
| 24 |
public function enqueue_scripts() |
| 25 |
{ |
| 26 |
$suffix = ''; |
| 27 |
$assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/'; |
| 28 |
$frontend_script_path = $assets_path . 'js/frontend/'; |
| 29 |
|
| 30 |
wp_enqueue_script( 'propertyhive_search', $frontend_script_path . 'search' . $suffix . '.js', array( 'jquery' ), PH_VERSION, true ); |
| 31 |
} |
| 32 |
|
| 33 |
public function set_control_groups() |
| 34 |
{ |
| 35 |
/*$this->control_groups['form'] = [ |
| 36 |
'title' => esc_html__( 'Form', 'propertyhive' ), |
| 37 |
'tab' => 'content', // content / style |
| 38 |
];*/ |
| 39 |
} |
| 40 |
|
| 41 |
public function set_controls() |
| 42 |
{ |
| 43 |
$this->controls['form_id'] = [ // Unique control identifier (lowercase, no spaces) |
| 44 |
'tab' => 'content', // Control tab: content/style |
| 45 |
//'group' => 'form', // Show under control group |
| 46 |
'label' => esc_html__( 'Form ID', 'propertyhive' ), // Control label |
| 47 |
'type' => 'text', // Control type |
| 48 |
'default' => 'default', // Default setting |
| 49 |
]; |
| 50 |
} |
| 51 |
|
| 52 |
public function render() |
| 53 |
{ |
| 54 |
$root_classes[] = $this->name; |
| 55 |
|
| 56 |
// Add 'class' attribute to element root tag |
| 57 |
$this->set_attribute( '_root', 'class', $root_classes ); |
| 58 |
|
| 59 |
echo "<div {$this->render_attributes( '_root' )}>"; |
| 60 |
echo do_shortcode('[property_search_form id="' . $this->settings['form_id'] . '"]'); |
| 61 |
echo '</div>'; |
| 62 |
} |
| 63 |
} |