Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replace the content of the Booking Page when a form is successfully submitted.
<?php
/**
* Plugin Name: Replace Booking Page Content for Restaurant Reservations
* Plugin URI: http://themeofthecrop.com
* Description: Replace the content of the Booking Page when a form is successfully submitted.
* Version: 0.0.1
* Author: Theme of the Crop
* Author URI: http://themeofthecrop.com
* License: GNU General Public License v2.0 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! defined( 'ABSPATH' ) )
exit;
if ( !function_exists( 'rtb_replace_booking_page_content' ) ) {
add_filter( 'the_content', 'rtb_replace_booking_page_content', 11 );
function rtb_replace_booking_page_content( $content ) {
if ( !is_main_query() || !in_the_loop() ) {
return $content;
}
global $rtb_controller;
$booking_page = $rtb_controller->settings->get_setting( 'booking-page' );
if ( empty( $booking_page ) ) {
return $content;
}
global $post;
if ( $post->ID != $booking_page ) {
return $content;
}
if ( $rtb_controller->request->request_inserted !== true ) {
return $content;
}
ob_start();
?>
<div class="rtb-message">
<p><?php echo $rtb_controller->settings->get_setting( 'success-message' ); ?></p>
</div>
<?php
return ob_get_clean();
}
} // endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.