| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class Divi_Property_Reference_Number_Widget extends ET_Builder_Module |
| 7 |
{ |
| 8 |
public $slug = 'et_pb_property_reference_number_widget'; |
| 9 |
public $vb_support = 'partial'; |
| 10 |
public $icon = ''; |
| 11 |
|
| 12 |
public function init() { |
| 13 |
$this->name = esc_html__( 'Property Reference Number', 'propertyhive' ); |
| 14 |
$this->icon = '&'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_fields() |
| 18 |
{ |
| 19 |
$fields = array( |
| 20 |
'before' => array( |
| 21 |
'label' => __( 'Before', 'propertyhive' ), |
| 22 |
'type' => 'text', |
| 23 |
'toggle_slug' => 'main_content', |
| 24 |
), |
| 25 |
'after' => array( |
| 26 |
'label' => __( 'After', 'propertyhive' ), |
| 27 |
'type' => 'text', |
| 28 |
'toggle_slug' => 'main_content', |
| 29 |
), |
| 30 |
); |
| 31 |
|
| 32 |
return $fields; |
| 33 |
} |
| 34 |
|
| 35 |
public function render( $attrs, $content, $render_slug ) |
| 36 |
{ |
| 37 |
$post_id = get_the_ID(); |
| 38 |
|
| 39 |
$property = new PH_Property($post_id); |
| 40 |
|
| 41 |
if ( !isset($property->id) ) { |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
if ( $property->reference_number == '' ) |
| 46 |
{ |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
$return = ''; |
| 51 |
|
| 52 |
if ( isset($this->props['before']) && $this->props['before'] != '' ) { $return .= $this->props['before'] . ' '; } |
| 53 |
|
| 54 |
$return .= esc_html($property->reference_number); |
| 55 |
|
| 56 |
if ( isset($this->props['after']) && $this->props['after'] != '' ) { $return .= ' ' . $this->props['after']; } |
| 57 |
|
| 58 |
return $this->_render_module_wrapper( $return, $render_slug ); |
| 59 |
} |
| 60 |
} |