| 1 |
<?php |
| 2 |
|
| 3 |
use MPHB\Views\SingleRoomTypeView; |
| 4 |
|
| 5 |
class MPHB_Divi_Accommodation_Type_Price_Module extends MPHB_Divi_Abstract_Accommodation_Module { |
| 6 |
|
| 7 |
public $slug = 'mphb-divi-accommodation-type-price'; |
| 8 |
|
| 9 |
public function init() { |
| 10 |
$this->name = esc_html__( 'HB Acc. Type Price', 'mphb-divi' ); |
| 11 |
} |
| 12 |
|
| 13 |
public static function get_html($attrs = array()) { |
| 14 |
|
| 15 |
$current_room_type = MPHB()->getCurrentRoomType(); |
| 16 |
|
| 17 |
$id = isset( $attrs['accommodation_id'] ) && $attrs['accommodation_id'] !== 'current' ? (int) $attrs['accommodation_id'] : self::get_current_post_id(); |
| 18 |
|
| 19 |
if ( 'mphb_room_type' != get_post_type( $id ) ) { |
| 20 |
return ''; |
| 21 |
} |
| 22 |
|
| 23 |
MPHB()->setCurrentRoomType( $id ); |
| 24 |
|
| 25 |
$price_HTML = ''; |
| 26 |
ob_start(); |
| 27 |
|
| 28 |
SingleRoomTypeView::renderDefaultOrForDatesPrice(); |
| 29 |
|
| 30 |
$price_HTML = ob_get_clean(); |
| 31 |
|
| 32 |
MPHB()->setCurrentRoomType($current_room_type ? $current_room_type->getId() : self::get_current_post_id()); |
| 33 |
|
| 34 |
return $price_HTML; |
| 35 |
} |
| 36 |
|
| 37 |
} |
| 38 |
|
| 39 |
new MPHB_Divi_Accommodation_Type_Price_Module(); |
| 40 |
|
| 41 |
|