| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Calendar |
| 4 |
* @category Content of Add New Booking |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site https://wpbookingcalendar.com/ |
| 8 |
* @email info@wpbookingcalendar.com |
| 9 |
* |
| 10 |
* @modified 2015-10-31 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* Show Content |
| 18 |
* Update Content |
| 19 |
* Define Slug |
| 20 |
* Define where to show |
| 21 |
*/ |
| 22 |
class WPBC_Page_AddNewBooking extends WPBC_Page_Structure { |
| 23 |
|
| 24 |
|
| 25 |
public function in_page() { |
| 26 |
return 'wpbc'; |
| 27 |
} |
| 28 |
|
| 29 |
public function tabs() { |
| 30 |
|
| 31 |
$is_can_add_booking = WPBC_Add_Booking_Component::current_user_can_add_booking(); |
| 32 |
|
| 33 |
$tabs = array(); |
| 34 |
$tabs['add-booking'] = array( |
| 35 |
'is_show_top_path' => true, // true | false. By default value is: true. |
| 36 |
'is_show_top_navigation' => true, |
| 37 |
'left_navigation__default_view_mode' => 'min', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''. |
| 38 |
'page_title' => __( 'Add New Booking', 'booking' ), // Header - Title. If false, than hidden. |
| 39 |
'page_description' => __( 'Manually add new bookings from the Admin Panel.', 'booking' ), // Header - Title Description. If false, than hidden. |
| 40 |
'title' => __( 'Add booking', 'booking' ), // Title of TAB. |
| 41 |
'hint' => __( 'Add booking', 'booking' ), // Hint. |
| 42 |
'link' => '', // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link. |
| 43 |
'position' => '', // Can be: 'left' | 'right' | ''. |
| 44 |
'css_classes' => '', // this is CSS class(es). |
| 45 |
'icon' => '', // Icon - link to the real PNG img. |
| 46 |
'font_icon' => 'wpbc-bi-plus', // CSS definition of forn Icon. |
| 47 |
'default' => true, // Is this tab activated by default or not: true || false. |
| 48 |
'disabled' => ! $is_can_add_booking, // Is this tab disbaled: true || false. |
| 49 |
'hided' => ! $is_can_add_booking, // Is this tab hided: true || false. |
| 50 |
'subtabs' => array(), |
| 51 |
); |
| 52 |
|
| 53 |
return $tabs; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
public function content() { |
| 58 |
|
| 59 |
do_action( 'wpbc_hook_add_booking_page_header', 'add_booking' ); // Define Notices Section and show some static messages, if needed. |
| 60 |
|
| 61 |
if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { |
| 62 |
return false; // Check if MU user activated, otherwise show Warning message. |
| 63 |
} |
| 64 |
|
| 65 |
if ( ! WPBC_Add_Booking_Component::current_user_can_add_booking() ) { |
| 66 |
return false; |
| 67 |
} |
| 68 |
|
| 69 |
if ( ! wpbc_set_default_resource_to__get() ) { |
| 70 |
return false; // Define default booking resources for $_ GET and check if booking resource belong to user. |
| 71 |
} |
| 72 |
|
| 73 |
WPBC_Add_Booking_Component::render(); |
| 74 |
|
| 75 |
do_action( 'wpbc_hook_add_booking_page_footer', 'add_booking' ); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
/** |
| 80 |
* Get Calendar Options of specific User |
| 81 |
* |
| 82 |
* @return array (number of months, options parameter |
| 83 |
*/ |
| 84 |
function get_saved_user_calendar_options() { |
| 85 |
|
| 86 |
return WPBC_Add_Booking_Component::get_saved_user_calendar_options(); |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
add_action('wpbc_menu_created', array( new WPBC_Page_AddNewBooking() , '__construct') ); // Executed after creation of Menu |
| 91 |
|
| 92 |
/** |
| 93 |
* Redirect legacy/main-menu Add Booking page to the Add Booking tab under Bookings. |
| 94 |
* |
| 95 |
* @param string $page_tag Current menu page tag. |
| 96 |
* |
| 97 |
* @return void |
| 98 |
*/ |
| 99 |
function wpbc_add_booking_menu_page__redirect_to_add_booking_tab( $page_tag ) { |
| 100 |
|
| 101 |
if ( 'wpbc-new' !== $page_tag ) { |
| 102 |
return; |
| 103 |
} |
| 104 |
|
| 105 |
wpbc_redirect( wpbc_get_new_booking_url() ); |
| 106 |
} |
| 107 |
add_action( 'wpbc_page_structure_show', 'wpbc_add_booking_menu_page__redirect_to_add_booking_tab', 0 ); |
| 108 |
|