Ich denke ich Ich muss eine Funktion erstellen, um diese Informationen über meinen eigenen add_action () auszugeben, damit ich sie korrekt positionieren kann. Info derzeit ist: < /p>
Code: Select all
// at the top of the page, already exists the following:
global $room;
$checkin = HTL()->session->get( 'checkin' );
$checkout = HTL()->session->get( 'checkout' );
$is_available = $room->is_available( $checkin, $checkout );
// then I added:
// echo 'check-in'
// I copied some code from another answer to format the $checkin and $checkout dates:
// echo 'check-out'
< /code>
Dies erstellt die gewünschten Informationen. Aber ich weiß nicht, wie ich dies in einer PHP -Funktion schreiben soll, um die Positionierung von add_action () zu nutzen. Was auch immer ich versuche, wirft immer wieder Fehler. Zum Beispiel fand ich Teile des obigen Code in der Klasse-HTL-booking.php
ist
Code: Select all
/**
* Output the booking details
*/
public function booking_details() {
$checkin = date_i18n( get_option( 'date_format' ), strtotime( $this->checkin ) ) . ' (' . HTL_Info::get_hotel_checkin() . ')';
$checkout = date_i18n( get_option( 'date_format' ), strtotime( $this->checkout ) ) . ' (' . HTL_Info::get_hotel_checkout() . ')';
$pets_message = HTL_Info::get_hotel_pets_message();
$cards = HTL_Info::get_hotel_accepted_credit_cards();
htl_get_template( 'booking/reservation-details.php', array(
'booking' => $this,
'checkin' => $checkin,
'checkout' => $checkout,
'pets_message' => $pets_message,
'cards' => $cards,
) );
}
< /code>
Aber damit herumspielen konnte ich nichts zum Laufen bringen. />function custom_checkin_checkout_dates() {
// I took the first 4 lines from the top of room-content.php
// as I think they help to create the data?
// but also tried without - neither worked.
global $room;
$checkin = HTL()->session->get( 'checkin' );
$checkout = HTL()->session->get( 'checkout' );
$is_available = $room->is_available( $checkin, $checkout );
// then tried the code from above
echo esc_html_e( 'Check-in', 'wp-hotelier' );
$custom_room_content_checkin = date('jS F Y', strtotime($checkin));
echo esc_html( $custom_room_content_checkin );
echo esc_html_e( 'Check-out', 'wp-hotelier' );
$custom_room_content_checkout = date('jS F Y', strtotime($checkout));
echo esc_html( $custom_room_content_checkout );
}
add_action( 'hotelier_room_list_item_price', 'custom_checkin_checkout_dates', 1, 3 );
< /code>
, aber den Fehler erhalten: < /p>
PHP Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "custom_checkin_checkout_dates" not found or invalid function name in .../wp-includes/class-wp-hook.php:324