Hotel Raxa - Advanced Booking System Implementation
🏨 Hotel Booking Enhancements: - Implemented Eagle Booking Advanced Pricing add-on - Added Booking.com-style rate management system - Created professional calendar interface for pricing - Integrated deals and discounts functionality 💰 Advanced Pricing Features: - Dynamic pricing models (per room, per person, per adult) - Base rates, adult rates, and child rates management - Length of stay discounts and early bird deals - Mobile rates and secret deals implementation - Seasonal promotions and flash sales 📅 Availability Management: - Real-time availability tracking - Stop sell and restriction controls - Closed to arrival/departure functionality - Minimum/maximum stay requirements - Automatic sold-out management 💳 Payment Integration: - Maintained Redsys payment gateway integration - Seamless integration with existing Eagle Booking - No modifications to core Eagle Booking plugin 🛠️ Technical Implementation: - Custom database tables for advanced pricing - WordPress hooks and filters integration - AJAX-powered admin interface - Data migration from existing Eagle Booking - Professional calendar view for revenue management 📊 Admin Interface: - Booking.com-style management dashboard - Visual rate and availability calendar - Bulk operations for date ranges - Statistics and analytics dashboard - Modal dialogs for quick editing 🔧 Code Quality: - WordPress coding standards compliance - Secure database operations with prepared statements - Proper input validation and sanitization - Error handling and logging - Responsive admin interface 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
185
wp-content/plugins/eagle-booking/core/admin/admin-menu.php
Normal file
185
wp-content/plugins/eagle-booking/core/admin/admin-menu.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Eagle Booking Admin Menu Class
|
||||
* @since 1.2.8
|
||||
* @modified 1.2.8.5
|
||||
* @author Jomin Muskaj
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
class EB_ADMIN_MENU {
|
||||
|
||||
/**
|
||||
* Autoload method
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action('admin_menu', array($this, 'eb_register_menu_sub_menu') );
|
||||
// add_action('admin_pages', array($this, 'eb_load_admin_pages') );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Submenu Pages
|
||||
* @return void
|
||||
*/
|
||||
|
||||
// public function eb_load_admin_pages() {
|
||||
|
||||
// $this-> eb_taxes_fees_page();
|
||||
|
||||
// $this-> eb_bookings_page();
|
||||
// $this-> eb_calendar_page();
|
||||
// $this-> eb_edit_page();
|
||||
// $this-> eb_new_page();
|
||||
// $this-> eb_sync_calendars_page();
|
||||
|
||||
// }
|
||||
|
||||
/**
|
||||
* Register Menu & Sub Menus
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function eb_register_menu_sub_menu() {
|
||||
|
||||
// Main Menu
|
||||
add_menu_page(
|
||||
'Eagle Booking',
|
||||
'Eagle Booking',
|
||||
'edit_pages',
|
||||
'eb_bookings',
|
||||
array($this, 'eb_bookings_page'),
|
||||
plugin_dir_url(dirname( __DIR__ )). '/assets/images/icons/eagle_booking.png',
|
||||
75
|
||||
);
|
||||
|
||||
// Sub Menu - Bookings
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Bookings', 'eagle-booking'),
|
||||
__('Bookings', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'eb_bookings',
|
||||
array($this, 'eb_register_menu_sub_menu')
|
||||
);
|
||||
|
||||
// Sub Menu - Calendar
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Calendar', 'eagle-booking'),
|
||||
__('Calendar', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'eb_calendar',
|
||||
array($this, 'eb_calendar_page')
|
||||
);
|
||||
|
||||
// Sub Menu - Rooms
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Rooms', 'eagle-booking'),
|
||||
__('Rooms', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_rooms'
|
||||
);
|
||||
|
||||
// Sub Menu - Branches
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Branches', 'eagle-booking'),
|
||||
__('Branches', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit-tags.php?taxonomy=eagle_branch'
|
||||
);
|
||||
|
||||
// Sub Menu - Services
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Services', 'eagle-booking'),
|
||||
__('Services', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_services'
|
||||
);
|
||||
|
||||
// Sub Menu - Exceptions
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Exceptions', 'eagle-booking'),
|
||||
__('Exceptions', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_exceptions'
|
||||
);
|
||||
|
||||
// Coupons
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Coupons', 'eagle-booking'),
|
||||
__('Coupons', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_coupons'
|
||||
);
|
||||
|
||||
// Sub Menu - Reviews
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Reviews', 'eagle-booking'),
|
||||
__('Reviews', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_reviews'
|
||||
);
|
||||
|
||||
// Sub Menu - Places
|
||||
add_submenu_page(
|
||||
'eb_bookings',
|
||||
__('Places', 'eagle-booking'),
|
||||
__('Places', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'edit.php?post_type=eagle_places'
|
||||
);
|
||||
|
||||
// Edit Booking (Hidden)
|
||||
add_submenu_page(
|
||||
'eb_edit_booking',
|
||||
__('Edit Booking', 'eagle-booking'),
|
||||
__('Edit Booking', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'eb_edit_booking',
|
||||
array($this, 'eb_edit_page')
|
||||
);
|
||||
|
||||
// New Booking (Hidden)
|
||||
add_submenu_page(
|
||||
'eb_new_booking',
|
||||
__('New Booking', 'eagle-booking'),
|
||||
__('New Booking', 'eagle-booking'),
|
||||
'edit_pages',
|
||||
'eb_new_booking',
|
||||
array($this, 'eb_new_page')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Calendar Page Callback
|
||||
public function eb_calendar_page() {
|
||||
include EB_PATH."/core/admin/bookings/include/calendar.php";
|
||||
}
|
||||
|
||||
// Bookings Page Callback
|
||||
public function eb_bookings_page() {
|
||||
include EB_PATH."/core/admin/bookings/include/bookings.php";
|
||||
}
|
||||
|
||||
// Edit Booking Page Callback
|
||||
public function eb_edit_page() {
|
||||
include EB_PATH."/core/admin/bookings/include/edit.php";
|
||||
}
|
||||
|
||||
// New Booking Page Callback
|
||||
public function eb_new_page() {
|
||||
include EB_PATH."/core/admin/bookings/include/new.php";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
new EB_ADMIN_MENU;
|
||||
298
wp-content/plugins/eagle-booking/core/admin/bookings/booking.php
Normal file
298
wp-content/plugins/eagle-booking/core/admin/bookings/booking.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Eagle Booking Manage Booking [Admin]
|
||||
* @since 1.2.8
|
||||
* @author Jomin Muskaj
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class EB_ADMIN_BOOKING {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
// Add Javascript and CSS back-end
|
||||
add_action('admin_enqueue_scripts', array($this,'enqueue'));
|
||||
|
||||
// Add ajax function that will receive the call back for logged in users
|
||||
add_action( 'wp_ajax_admin_availability', array( $this, 'availability') );
|
||||
add_action( 'wp_ajax_admin_create', array( $this, 'create') );
|
||||
add_action( 'wp_ajax_admin_delete', array( $this, 'delete') );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the required scripts
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
// EnqueUE JS
|
||||
wp_enqueue_script( 'eb-admin-booking', EB_URL .'assets/js/admin/bookings.js', array( 'jquery' ), EB_VERSION, true );
|
||||
|
||||
// Enqueue AJAX
|
||||
wp_localize_script( 'eb-admin-booking', 'booking_variables', array(
|
||||
'ajaxurl' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('nonce')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
// Check Availability
|
||||
function availability() {
|
||||
|
||||
// Check if Ajax response and get Ajax variables
|
||||
if (! empty($_POST['room_id'])) {
|
||||
|
||||
$nonce = sanitize_text_field( $_POST['nonce'] );
|
||||
$room_id = sanitize_text_field( $_POST['room_id'] );
|
||||
$checkin = sanitize_text_field( $_POST['checkin'] );
|
||||
$checkout = sanitize_text_field( $_POST['checkout'] );
|
||||
$room_title = get_the_title($room_id);
|
||||
|
||||
// Format dates for the system
|
||||
$checkin = eagle_booking_system_date_format($checkin);
|
||||
$checkout = eagle_booking_system_date_format($checkout);
|
||||
|
||||
// Check nonce
|
||||
if ( !wp_verify_nonce($nonce, 'nonce') ) {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('Invalid Nonce', 'eagle-booking');
|
||||
|
||||
// // If everything is ok then proceed to the creation
|
||||
} else {
|
||||
|
||||
// Let letch check the availability
|
||||
if ( eagle_booking_is_qnt_available( eb_room_availability( $room_id, $checkin, $checkout), $checkin, $checkout, $room_id ) == 1 ) {
|
||||
|
||||
$return_data['status'] = 'available';
|
||||
$return_data['heading'] = __('Room is Available', 'eagle-booking');
|
||||
$return_data['text'] = sprintf( __('The room %1$s is available on the requested dates. Do you want to submit the booking?', 'eagle-booking'), $room_title);
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'notavailable';
|
||||
$return_data['heading'] = __('Room is not Available', 'eagle-booking');
|
||||
$return_data['text'] = sprintf( __('The room %1$s is not available on the requested dates.', 'eagle-booking'), $room_title);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('No ID', 'eagle-booking');
|
||||
}
|
||||
|
||||
// Return all data to json
|
||||
wp_send_json( $return_data );
|
||||
wp_die();
|
||||
|
||||
}
|
||||
|
||||
// Create Booking
|
||||
function create() {
|
||||
|
||||
// Check if Ajax response and get Ajax variables
|
||||
if (! empty($_POST['room_id'])) {
|
||||
|
||||
$nonce = sanitize_text_field( $_POST['nonce'] );
|
||||
$room_id = sanitize_text_field( $_POST['room_id'] );
|
||||
$checkin = sanitize_text_field( $_POST['checkin'] );
|
||||
$checkout = sanitize_text_field( $_POST['checkout'] );
|
||||
$price = sanitize_text_field( $_POST['price'] );
|
||||
$deposit = sanitize_text_field( $_POST['deposit'] );
|
||||
$firstname = sanitize_text_field( $_POST['firstname'] );
|
||||
$lastname = sanitize_text_field( $_POST['lastname'] );
|
||||
$email = sanitize_text_field( $_POST['email'] );
|
||||
$phone = sanitize_text_field( $_POST['phone'] );
|
||||
$address = sanitize_text_field( $_POST['address'] );
|
||||
$city = sanitize_text_field( $_POST['city'] );
|
||||
$country = sanitize_text_field( $_POST['country'] );
|
||||
$zip = sanitize_text_field( $_POST['zip'] );
|
||||
$arrival = sanitize_text_field( $_POST['arrival'] );
|
||||
$services = sanitize_text_field( $_POST['services'] );
|
||||
$requests = sanitize_text_field( $_POST['requests'] );
|
||||
$status = sanitize_text_field( $_POST['status'] );
|
||||
$payment = sanitize_text_field( $_POST['payment'] );
|
||||
$source = 'admin';
|
||||
|
||||
|
||||
$room_title = get_the_title($room_id);
|
||||
$booking_date = date('H:m:s F j Y');
|
||||
$transaction_id = rand(100000000,999999999);
|
||||
$user_id = 0;
|
||||
$user_ip = 0;
|
||||
$coupon = '';
|
||||
$currency = '$';
|
||||
|
||||
// Set deposit to 0 if is not set
|
||||
if( $deposit == '' ) $deposit = 0;
|
||||
|
||||
// Check guests type
|
||||
if( eb_get_option('eb_adults_children') == true ) {
|
||||
|
||||
$adults = sanitize_text_field( $_POST['adults'] );
|
||||
$children = sanitize_text_field( $_POST['children'] );
|
||||
$guests = $adults + $children;
|
||||
|
||||
} else {
|
||||
|
||||
$adults = '';
|
||||
$children = '';
|
||||
$guests = sanitize_text_field( $_POST['guests'] );
|
||||
|
||||
}
|
||||
|
||||
// Format dates for the system
|
||||
$checkin = eagle_booking_system_date_format( $checkin );
|
||||
$checkout = eagle_booking_system_date_format( $checkout );
|
||||
|
||||
// Check nonce
|
||||
if ( !wp_verify_nonce($nonce, 'nonce') ) {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('Invalid Nonce', 'eagle-booking');
|
||||
|
||||
// // If everything is ok then proceed to the creation
|
||||
} else {
|
||||
|
||||
// Let letch check the availability
|
||||
if ( eagle_booking_is_qnt_available( eb_room_availability( $room_id, $checkin, $checkout), $checkin, $checkout, $room_id ) == 1 ) {
|
||||
|
||||
// Enter the reservation into the db
|
||||
$insert_booking = eb_insert_booking_into_db(
|
||||
$room_id,
|
||||
$room_title,
|
||||
$booking_date,
|
||||
$checkin,
|
||||
$checkout,
|
||||
$guests,
|
||||
$adults,
|
||||
$children,
|
||||
$price,
|
||||
$price,
|
||||
$deposit,
|
||||
$services,
|
||||
$user_id,
|
||||
$firstname,
|
||||
$lastname,
|
||||
$email,
|
||||
$user_ip,
|
||||
$phone,
|
||||
$address.' '.$zip,
|
||||
$city,
|
||||
$country,
|
||||
$requests,
|
||||
$arrival,
|
||||
$coupon,
|
||||
$status,
|
||||
$currency,
|
||||
$transaction_id,
|
||||
$payment,
|
||||
$source
|
||||
);
|
||||
|
||||
// Get the last ID
|
||||
global $eb_booking_id;
|
||||
|
||||
// if success redirect to edit booking page
|
||||
if ( $insert_booking == true ) {
|
||||
|
||||
$return_data['status'] = 'success';
|
||||
$return_data['mssg'] = 'Booking Created Successfully';
|
||||
$return_data['redirect_url'] = 'admin.php?page=eb_edit_booking&id='.$eb_booking_id;
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['mssg'] = 'Something went wrong';
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'success';
|
||||
$return_data['class'] = 'eb-not-available';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('No ID', 'eagle-booking');
|
||||
|
||||
}
|
||||
|
||||
// Return all data to json
|
||||
wp_send_json( $return_data );
|
||||
|
||||
// wp_die();
|
||||
|
||||
}
|
||||
|
||||
// Delete Booking
|
||||
function delete() {
|
||||
|
||||
// Check if Ajax response and get Ajax variables
|
||||
if (! empty($_POST['booking_id'])) {
|
||||
|
||||
$booking_id = sanitize_text_field( $_POST['booking_id'] ) ;
|
||||
$nonce = sanitize_text_field( $_POST['nonce'] );
|
||||
|
||||
// Check nonce
|
||||
if ( !wp_verify_nonce($nonce, 'nonce') ) {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('Invalid Nonce', 'eagle-booking');
|
||||
|
||||
// // If everything is ok let's proceed to the deletion
|
||||
} else {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Delete Booking
|
||||
$delete_qry = $wpdb->delete( EAGLE_BOOKING_TABLE, array( 'ID' => $booking_id ) );
|
||||
|
||||
// Delete Booking Meta
|
||||
$delete_data_qry = $wpdb->delete( EAGLE_BOOKING_TABLE_META, array( 'booking_id' => $booking_id ) );
|
||||
|
||||
if ( $delete_qry == true ) {
|
||||
|
||||
$return_data['status'] = 'success';
|
||||
$return_data['mssg'] = __('Booking Deleted Successfully', 'eagle-booking');
|
||||
$return_data['redirect_url'] = 'admin.php?page=eb_bookings';
|
||||
|
||||
|
||||
flush_rewrite_rules(true);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'success';
|
||||
$return_data['mssg'] = __('Oops Something Went Wrong', 'eagle-booking');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$return_data['status'] = 'failed';
|
||||
$return_data['mssg'] = __('No ID', 'eagle-booking');
|
||||
|
||||
}
|
||||
|
||||
// Return all data to json
|
||||
wp_send_json($return_data);
|
||||
wp_die();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$bookings = new EB_ADMIN_BOOKING();
|
||||
@@ -0,0 +1,17 @@
|
||||
<div class="eb-admin-header">
|
||||
|
||||
<div class="eb-admin-brand">
|
||||
<a href="https://eagle-booking.com/?utm_source=eb_header_logo" target="_blank" class="eb-admin-logo">
|
||||
<img src="<?php echo EB_URL ?>assets/images/admin/logo_light.svg" alt="Eagle Booking">
|
||||
</a>
|
||||
<div class="eb-admin-slogan">
|
||||
<span><?php echo "Eagle Booking" ?></sapn>
|
||||
<span><?php echo "Hotel Booking Plugin"?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="eb-admin-help">
|
||||
<a href="http://docs.eagle-booking.com/?utm_source=eb_header_docs" target="_blank"><i class="far fa-life-ring"></i></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php if (eb_get_option('eb_admin_booking_stats') == true ) : ?>
|
||||
|
||||
<div class="eagle-booking-stats">
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-revenue">
|
||||
<div class="stat-icon">
|
||||
<i class="fas fa-money-bill-wave"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Total Revenue", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php if ( eb_currency_position() == 'before' ) : ?>
|
||||
<?php echo eb_currency() .eagle_booking_total_earnings()?>
|
||||
<?php else : ?>
|
||||
<?php echo eagle_booking_total_earnings() .eb_currency() ?>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-total">
|
||||
<div class="stat-icon">
|
||||
<i class="far fa-calendar-alt"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Total Bookings", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php echo count($eb_bookings_num_status) ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-completed">
|
||||
<div class="stat-icon">
|
||||
<i class="far fa-calendar-check"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Completed Bookings", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php echo count($eb_bookings_num_status_completed) ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-pending-payment">
|
||||
<div class="stat-icon">
|
||||
<i class="far fa-calendar"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Pending Payment Bookings", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php echo count($eb_bookings_num_status_pending_payment) ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-pending">
|
||||
<div class="stat-icon">
|
||||
<i class="far fa-calendar-minus"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Pending Bookings", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php echo count($eb_bookings_num_status_pending) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- item -->
|
||||
<div class="stat-item stat-canceled">
|
||||
<div class="stat-icon">
|
||||
<i class="far fa-calendar-times"></i>
|
||||
</div>
|
||||
<div class="stat-title">
|
||||
<?php echo esc_html__("Canceled Bookings", 'eagle-booking') ?>
|
||||
</div>
|
||||
<div class="stat-value">
|
||||
<?php echo count($eb_bookings_num_status_canceled) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,491 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Bookings Pges
|
||||
* Author: Eagle Themes
|
||||
* @since 1.0.0
|
||||
* @modified 1.3.3
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
$eb_bookings_per_page = eb_get_option('eb_bookings_per_page');
|
||||
|
||||
if ( $eb_bookings_per_page == '' ) $eb_bookings_per_page = 20;
|
||||
|
||||
if ( isset($_GET["page_no"]) ) {
|
||||
|
||||
$eb_page_no = $_GET["page_no"];
|
||||
|
||||
} else {
|
||||
|
||||
$eb_page_no = 1;
|
||||
|
||||
}
|
||||
|
||||
$eb_bookings_start = $eb_bookings_per_page * ( (float)$eb_page_no - 1 );
|
||||
|
||||
// Sorting Filter
|
||||
if ( isset( $_GET['sortby'] ) ) {
|
||||
|
||||
$eb_sort_by = $_GET['sortby'];
|
||||
|
||||
} else {
|
||||
|
||||
$eb_sort_by = 'id';
|
||||
|
||||
}
|
||||
|
||||
// Status Filter
|
||||
if (isset($_GET["status"])) {
|
||||
$eb_booking_status = $_GET["status"];
|
||||
} else {
|
||||
$eb_booking_status = '';
|
||||
}
|
||||
|
||||
// Branch Filter
|
||||
if ( isset( $_GET['branch_id'] ) ) {
|
||||
|
||||
$eb_selected_branch_id = $_GET['branch_id'];
|
||||
|
||||
} else {
|
||||
|
||||
$eb_selected_branch_id = '';
|
||||
|
||||
}
|
||||
|
||||
// DB QUERY
|
||||
global $wpdb;
|
||||
|
||||
$eagle_booking_booking_id = get_the_ID();
|
||||
$eagle_booking_table_name = $wpdb->prefix . 'eagle_booking';
|
||||
$eb_table_meta_name = $wpdb->prefix . 'eagle_booking_meta';
|
||||
|
||||
// Bookings
|
||||
if ( empty($eb_booking_status) ) {
|
||||
|
||||
$eb_bookings = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name ORDER BY $eb_sort_by DESC LIMIT $eb_bookings_start, $eb_bookings_per_page");
|
||||
|
||||
} else {
|
||||
|
||||
$eb_bookings = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = '$eb_booking_status' ORDER BY $eb_sort_by DESC LIMIT $eb_bookings_start, $eb_bookings_per_page");
|
||||
|
||||
}
|
||||
|
||||
// Search Query
|
||||
if (isset($_GET["search"])) {
|
||||
$eb_search = $_GET["search"];
|
||||
$eb_bookings = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = '$eb_booking_status' AND user_first_name LIKE '%$eb_search%' OR user_last_name LIKE '%$eb_search%' OR title_post LIKE '%$eb_search%' OR id LIKE '%$eb_search%' OR paypal_tx LIKE '%$eb_search%' ORDER BY $eb_sort_by");
|
||||
|
||||
}
|
||||
|
||||
$eb_bookings_num_status = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name");
|
||||
$eb_bookings_num_status_pending = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = 'Pending'");
|
||||
$eb_bookings_num_status_pending_payment = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = 'Pending Payment'");
|
||||
$eb_bookings_num_status_canceled = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = 'Canceled'");
|
||||
$eb_bookings_num_status_completed = $wpdb->get_results( "SELECT * FROM $eagle_booking_table_name WHERE paypal_payment_status = 'Completed'");
|
||||
|
||||
?>
|
||||
<div class="eb-admin eb-wrapper">
|
||||
|
||||
<?php include EB_PATH.''."core/admin/bookings/elements/admin-header.php"; ?>
|
||||
|
||||
<div class="eb-admin-title">
|
||||
|
||||
<div>
|
||||
<h1 class="wp-heading-inline"><?php echo __('Bookings','eagle-booking') ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="eb-admin-new-booking">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=eb_new_booking') ?>" class="eb-new-booking-btn"><?php echo __('Add New Booking','eagle-booking') ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
if ($eb_bookings) {
|
||||
|
||||
/**
|
||||
* Include Stats
|
||||
*
|
||||
* @since 1.2.9.6
|
||||
*/
|
||||
|
||||
include_once EB_PATH . 'core/admin/bookings/include/bookings-stats.php';
|
||||
|
||||
?>
|
||||
|
||||
<div class="booking-search">
|
||||
|
||||
<label><?php echo __('Sort by','eagle-booking') ?></label>
|
||||
<select class="eb_bookings_filter" style="margin-right: 20px">
|
||||
<option <?php if ($eb_sort_by == '' || $eb_sort_by == 'id') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&sortby=id&<?php echo $eb_booking_status ?>&branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('ID','eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_sort_by == 'date_from') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&sortby=date_from&<?php echo $eb_booking_status ?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __ ('Check In', 'eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_sort_by == 'date_to') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&sortby=date_to&<?php echo $eb_booking_status ?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __ ('Check Out', 'eagle-booking') ?>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<label><?php echo __('Status','eagle-booking') ?></label>
|
||||
<select class="eb_bookings_filter" style="margin-right: 20px">
|
||||
<option <?php if ($eb_booking_status == '') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&status&sortby=<?php echo $eb_sort_by?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('All','eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_booking_status == 'Pending') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&status=Pending&sortby=<?php echo $eb_sort_by?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('Pending','eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_booking_status == 'Pending Payment') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&status=Pending Payment&sortby=<?php echo $eb_sort_by?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('Pending Payment','eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_booking_status == 'Completed') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&status=Completed&sortby=<?php echo $eb_sort_by?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('Completed','eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($eb_booking_status == 'Canceled') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&status=Canceled&sortby=<?php echo $eb_sort_by?> &branch_id=<?php echo $eb_selected_branch_id ?>">
|
||||
<?php echo __('Canceled','eagle-booking') ?>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<label><?php echo __('Branch','eagle-booking') ?></label>
|
||||
<select class="eb_bookings_filter">
|
||||
|
||||
<option <?php if ($eb_booking_status == '') { echo 'selected="slected"'; } ?> value="admin.php?page=eb_bookings&branch_id=&sortby=<?php echo $eb_sort_by?>&status=<?php echo $eb_booking_status ?>">
|
||||
<?php echo __('All','eagle-booking') ?>
|
||||
</option>
|
||||
|
||||
<?php
|
||||
|
||||
$args = array(
|
||||
'taxonomy' => 'eagle_branch',
|
||||
'hide_empty' => false,
|
||||
);
|
||||
|
||||
$branch_query = new WP_Term_Query($args);
|
||||
|
||||
if ( !empty( $branch_query->terms ) ) {
|
||||
|
||||
foreach ( $branch_query->terms as $eb_branch ) {
|
||||
|
||||
$eb_branch_id = $eb_branch->term_id;
|
||||
$eb_branch_name = get_term_field( 'name', $eb_branch );
|
||||
|
||||
echo '<option value="admin.php?page=eb_bookings&branch_id='.$eb_branch_id.'&sortby='.$eb_sort_by.'&status='.$eb_booking_status.'" '.($eb_selected_branch_id == $eb_branch_id ? "selected='selected'" : "" ).' >'.$eb_branch_name.'</option>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</select>
|
||||
|
||||
<div class="bookings-search" name="eb-bookings-search">
|
||||
<form method="GET">
|
||||
<input type="hidden" name="page" value="eb_bookings">
|
||||
<input type="hidden" name="status" value="<?php echo $eb_booking_status ?>">
|
||||
<input type="hidden" name="sortby" value="<?php echo $eb_sort_by ?>">
|
||||
<input type="text" name="search" class="search-box" placeholder="<?php echo esc_html__('Search Bookings by ID, Name, Surname or Transaction ID', 'eagle-booking') ?>">
|
||||
<button class="button search-button"><?php echo esc_html__('Search', 'eagle-booking') ?></button>
|
||||
<form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="bookings-table">
|
||||
<tbody>
|
||||
<tr class="thead">
|
||||
<td width="3%"><?php echo __('ID','eagle-booking') ?></td>
|
||||
<td width="20%"><?php echo __('Room','eagle-booking') ?></td>
|
||||
<!--
|
||||
<?php if ( !empty( $branch_query->terms ) ) : ?>
|
||||
<td width="7%"><?php echo __('Branch','eagle-booking') ?></td>
|
||||
<?php endif ?> -->
|
||||
|
||||
<td width="10%"><?php echo __('Booking Dates','eagle-booking') ?></td>
|
||||
<td width="10%"><?php echo __('Total Price','eagle-booking') ?></td>
|
||||
<td width="12%"><?php echo __('Full Name','eagle-booking') ?></td>
|
||||
<td width="5%"><?php echo __('Guests','eagle-booking') ?></td>
|
||||
<td width="10%"><?php echo __('Payment Method','eagle-booking') ?></td>
|
||||
<td class="booking-status-col" width="10%"><?php echo __('Status','eagle-booking') ?></td>
|
||||
<td width="10%"><?php echo __('Source','eagle-booking') ?></td>
|
||||
<td width="10%"><?php echo __('Action','eagle-booking') ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach ( $eb_bookings as $eb_booking ) {
|
||||
|
||||
$branches = get_the_terms( $eb_booking->id_post, 'eagle_branch' );
|
||||
|
||||
if ( $branches ) {
|
||||
|
||||
foreach ( $branches as $branch ) {
|
||||
|
||||
$eb_room_branch_id = $branch->term_id;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$eb_room_branch_id = '';
|
||||
|
||||
}
|
||||
|
||||
if ( ( $eb_selected_branch_id == '' ) || ( $eb_selected_branch_id == $eb_room_branch_id ) ) {
|
||||
|
||||
|
||||
// Booking Status & Class
|
||||
if ( $eb_booking->paypal_payment_status == 'Pending Payment' ) {
|
||||
$eb_booking_status_text = __('Pending Payment', 'eagle-booking');
|
||||
$eb_booking_status_class = 'pending-payment';
|
||||
|
||||
} elseif ( $eb_booking->paypal_payment_status == 'Pending' ){
|
||||
$eb_booking_status_text = __('Pending', 'eagle-booking');
|
||||
$eb_booking_status_class = 'pending';
|
||||
|
||||
} elseif ( $eb_booking->paypal_payment_status == 'Canceled' ){
|
||||
$eb_booking_status_text = __('Canceled', 'eagle-booking');
|
||||
$eb_booking_status_class = 'canceled';
|
||||
|
||||
} else {
|
||||
$eb_booking_status_text = __('Completed', 'eagle-booking');
|
||||
$eb_booking_status_class = 'completed';
|
||||
}
|
||||
|
||||
// Get the payment method text
|
||||
if( $eb_booking->action_type === 'payment_on_arrive' ) {
|
||||
|
||||
$eb_booking_payment_method_text = __('Payment on Arrival', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === '2checkout') {
|
||||
|
||||
$eb_booking_payment_method_text = __('2Checkout', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'bank_transfer') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Bank Transfer', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'PayU') {
|
||||
|
||||
$eb_booking_payment_method_text = __('PayU', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'paystack') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Paystack', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'flutterwave') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Flutterwave', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'vivawallet') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Viva Wallet', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'razorpay') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Razorpay', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'booking_request') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Booking Request', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'stripe') {
|
||||
|
||||
$eb_booking_payment_method_text = __('Stripe', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'paypal') {
|
||||
|
||||
$eb_booking_payment_method_text = __('PayPal', 'eagle-booking');
|
||||
|
||||
} elseif ($eb_booking->action_type === 'external') {
|
||||
|
||||
$eb_booking_payment_method_text = __('External Payment ', 'eagle-booking');
|
||||
|
||||
}
|
||||
|
||||
// Room Image
|
||||
$eb_booking_id = $eb_booking->id;
|
||||
$eb_room_id = $eb_booking->id_post;
|
||||
$eagle_booking_image_id = get_post_thumbnail_id($eb_room_id);
|
||||
$eagle_booking_image_attributes = wp_get_attachment_image_src( $eagle_booking_image_id, 'thumbnail' );
|
||||
$eagle_booking_room_img_src = $eagle_booking_image_attributes[0];
|
||||
$eagle_booking_booking_id = $eb_booking->id_user;
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<tr class="eb-booking-line" data-booking-id="<?php echo $eb_booking_id ?>">
|
||||
<td>
|
||||
<?php echo $eb_booking_id ?>
|
||||
</td>
|
||||
<td>
|
||||
<div style="display:flex;">
|
||||
<div style="width:80px; vertical-align:middle;">
|
||||
<a href="<?php echo get_edit_post_link( $eb_booking->id_post ) ?>" target="_blank">
|
||||
<img width="50" src="<?php echo $eagle_booking_room_img_src ?>" style="border-radius: 2px; display: block">
|
||||
</a>
|
||||
</div>
|
||||
<div class="room-details">
|
||||
<h2 class="room-title">
|
||||
<a href="<?php echo get_edit_post_link( $eb_booking->id_post ) ?>" target="_blank"><?php echo $eb_booking->title_post ?></a>
|
||||
</h2>
|
||||
|
||||
|
||||
<?php if ( !empty( $branch_query->terms ) ) : ?>
|
||||
<div class="room-branch"><?php echo eb_room_branch($eb_booking->id_post) ?></div>
|
||||
<?php endif ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<?php if ( !empty( $branch_query->terms ) ) : ?>
|
||||
<td><?php echo eb_room_branch($eb_booking->id_post) ?></td>
|
||||
<?php endif ?> -->
|
||||
|
||||
|
||||
|
||||
<td>
|
||||
<span> <?php echo eagle_booking_displayd_date_format($eb_booking->date_from) ?></span> →
|
||||
<span> <?php echo eagle_booking_displayd_date_format($eb_booking->date_to) ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ( eb_currency_position() == 'before' ) : ?>
|
||||
<?php echo eb_currency() ?><?php eb_formatted_price($eb_booking->final_trip_price) ?>
|
||||
<?php else : ?>
|
||||
<?php eb_formatted_price($eb_booking->final_trip_price) ?><?php echo eb_currency() ?>
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<span><?php echo $eb_booking->user_first_name.' '.$eb_booking->user_last_name ?></span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $eb_booking->guests ?>
|
||||
</td>
|
||||
<td><span><?php echo $eb_booking_payment_method_text ?></span></td>
|
||||
<td class="booking-status-col"><span class="booking-status status-<?php echo esc_attr($eb_booking_status_class) ?>"><?php echo $eb_booking_status_text ?></span></td>
|
||||
<td><?php echo eb_booking_source( $eb_booking_id, true ) ?></td>
|
||||
<td>
|
||||
<div class="eb-action-buttons">
|
||||
|
||||
|
||||
<?php if ( eb_booking_source($eb_booking_id) === 'direct' || eb_booking_source($eb_booking_id) === 'admin' || eb_booking_source($eb_booking_id) === '' ) : ?>
|
||||
|
||||
<a href="admin.php?page=eb_edit_booking&id=<?php echo $eb_booking_id ?>" class="eb-edit-action"><i class="far fa-edit"></i></a>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<span data-eb-tooltip="<?php echo __('External Bookings can NOT be edited!', 'eagle-booking') ?>" class="eb-edit-action"><i class="far fa-edit"></i></span>
|
||||
|
||||
<?php endif ?>
|
||||
|
||||
<span class="eb-delete-action eb-delete-booking" data-booking-id="<?php echo $eb_booking_id ?>" ><i class="far fa-trash-alt"></i></span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
|
||||
// Get total pages based on status filter
|
||||
|
||||
if ( $eb_booking_status == 'Pending' ) {
|
||||
|
||||
$eb_total_pages_num = ceil( count( $eb_bookings_num_status_pending ) / $eb_bookings_per_page ) ;
|
||||
|
||||
} elseif ( $eb_booking_status == 'Pending Payment' ) {
|
||||
|
||||
$eb_total_pages_num = ceil( count( $eb_bookings_num_status_pending_payment ) / $eb_bookings_per_page ) ;
|
||||
|
||||
} elseif ( $eb_booking_status == 'Completed' ) {
|
||||
|
||||
$eb_total_pages_num = ceil( count( $eb_bookings_num_status_completed ) / $eb_bookings_per_page ) ;
|
||||
|
||||
} else {
|
||||
|
||||
$eb_total_pages_num = ceil( count( $eb_bookings_num_status ) / $eb_bookings_per_page ) ;
|
||||
|
||||
}
|
||||
|
||||
$current_page = (float)$eb_page_no;
|
||||
|
||||
|
||||
// Calculate pages to output.
|
||||
$end_size = 2;
|
||||
$mid_size = 2;
|
||||
$start_pages = range( 1, $end_size );
|
||||
$end_pages = range( $eb_total_pages_num - $end_size + 1, $eb_total_pages_num );
|
||||
$mid_pages = range( $current_page - $mid_size, $current_page + $mid_size );
|
||||
$pages = array_intersect( range( 1, $eb_total_pages_num ), array_merge( $start_pages, $end_pages, $mid_pages ) );
|
||||
$prev_page = 0;
|
||||
|
||||
?>
|
||||
<nav class="eb-pagination">
|
||||
<ul>
|
||||
<?php if ( $current_page && $current_page > 1 ) : ?>
|
||||
<li><a href="?page=eb_bookings&page_no=<?php echo $current_page - 1 ?><?php echo '&status='.$eb_booking_status.'&branch_id='.$eb_selected_branch_id.'&sortby='.$eb_sort_by ?>" data-page="<?php echo esc_attr( $current_page - 1 ); ?>">←</a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
foreach ( $pages as $page ) {
|
||||
if ( $prev_page != $page - 1 ) {
|
||||
echo '<li><span>...</span></li>';
|
||||
}
|
||||
if ( $current_page == $page ) {
|
||||
echo '<li class="current"><a data-page="' . esc_attr( $page ) . '">' . esc_html( $page ) . '</a></li>';
|
||||
} else {
|
||||
echo '<li><a href="?page=eb_bookings&page_no='. $page .'&status='.$eb_booking_status.'&branch_id='.$eb_selected_branch_id.'&sortby='.$eb_sort_by.'" data-page="' . esc_attr( $page ) . '">' . esc_html( $page ) . '</a></li>';
|
||||
}
|
||||
$prev_page = $page;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( $current_page && $current_page < $eb_total_pages_num ) : ?>
|
||||
<li><a href="?page=eb_bookings&page_no=<?php echo $current_page + 1 ?><?php echo '&status='.$eb_booking_status.'&branch_id='.$eb_selected_branch_id.'&sortby='.$eb_sort_by ?>" data-page="<?php echo esc_attr( $current_page + 1 ); ?>">→</a></li>
|
||||
<?php endif; ?>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="eb-popup">
|
||||
<div class="eb-popup-inner">
|
||||
<span class="eb-close-popup"><i class="fas fa-times"></i></span>
|
||||
<div class="eb-popup-icon failed">
|
||||
<i class="far fa-trash-alt"></i>
|
||||
</div>
|
||||
<h3 class="title"><?php echo __('Delete Booking', 'eagle-booking') ?> #<span id="eb_booking_id_text"></span></h3>
|
||||
<p><?php echo __('This action cannot be undone. Are you sure you want to delete this booking?', 'eagle-booking') ?></p>
|
||||
<button class="btn btn-delete" id="eb_delete_booking_confirmation" data-booking-id="">
|
||||
<span class="eb-btn-text"><?php echo __('Yes, delete this booking', 'eagle-booking') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- No Results -->
|
||||
<?php } else { ?>
|
||||
|
||||
<div class="eb-no-bookings">
|
||||
<i class="far fa-frown"></i>
|
||||
<p><?php echo __('You do not have any booking yet.', 'eagle-booking')?></p>
|
||||
<a href="<?php echo admin_url( 'admin.php?page=eb_new_booking') ?>"><?php echo __('Add New Booking', 'eagle-booking') ?></a>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
|
||||
// Check if the cal_days_in_month function is enabled
|
||||
if ( function_exists( 'cal_days_in_month' ) ) {
|
||||
|
||||
// Prev / Next Month
|
||||
function eb_next_prev_month_year($eb_date, $eb_month_year, $eb_next_prev) {
|
||||
|
||||
if ($eb_next_prev == 'next') {
|
||||
$eb_get_next_month_year = date('Y-m-d', strtotime($eb_date.' + 1 month'));
|
||||
} else {
|
||||
$eb_get_next_month_year = date('Y-m-d', strtotime($eb_date.' - 1 month'));
|
||||
}
|
||||
|
||||
if ($eb_month_year == 'month') {
|
||||
$eb_next_m_y = date_format(new DateTime($eb_get_next_month_year), 'm');
|
||||
} else {
|
||||
$eb_next_m_y = date_format(new DateTime($eb_get_next_month_year), 'Y');
|
||||
}
|
||||
|
||||
return $eb_next_m_y;
|
||||
}
|
||||
|
||||
// Month Name (include translation)
|
||||
function eb_month_name($eb_date) {
|
||||
|
||||
$eb_month_name = date('Y-m-d', strtotime($eb_date));
|
||||
$eb_month = date_format(new DateTime($eb_month_name),'F');
|
||||
|
||||
$search = array(
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
__('January', 'eagle-booking'),
|
||||
__('February', 'eagle-booking'),
|
||||
__('March', 'eagle-booking'),
|
||||
__('April', 'eagle-booking'),
|
||||
__('May', 'eagle-booking'),
|
||||
__('June', 'eagle-booking'),
|
||||
__('July', 'eagle-booking'),
|
||||
__('August', 'eagle-booking'),
|
||||
__('September', 'eagle-booking'),
|
||||
__('October', 'eagle-booking'),
|
||||
__('November', 'eagle-booking'),
|
||||
__('December', 'eagle-booking'),
|
||||
);
|
||||
|
||||
$eb_month = str_replace($search, $replace, $eb_month);
|
||||
|
||||
return $eb_month;
|
||||
}
|
||||
|
||||
// Check if month isset
|
||||
if (isset($_POST['eb_month'])) {
|
||||
|
||||
$eb_month = sanitize_text_field($_POST['eb_month']);
|
||||
$eb_year = sanitize_text_field($_POST['eb_year']);
|
||||
$eb_new_date = $eb_year.'-'.$eb_month.'-1';
|
||||
$eb_today = $eb_month;
|
||||
$eb_year = $eb_year;
|
||||
$eb_tot_days = cal_days_in_month(CAL_GREGORIAN, $eb_today, $eb_year);
|
||||
|
||||
$eb_next_month = eb_next_prev_month_year($eb_new_date, 'month','next');
|
||||
$eb_next_year = eb_next_prev_month_year($eb_new_date, 'year','next');
|
||||
$eb_prev_month = eb_next_prev_month_year($eb_new_date, 'month','prev');
|
||||
$eb_prev_year = eb_next_prev_month_year($eb_new_date, 'year','prev');
|
||||
|
||||
// Current / Default Month
|
||||
} else {
|
||||
|
||||
$eb_today = date('n');
|
||||
$eb_year = date('Y');
|
||||
$eb_tot_days = cal_days_in_month(CAL_GREGORIAN, $eb_today, $eb_year);
|
||||
$eb_next_month = eb_next_prev_month_year(date('Y-m-d'),'month','next');
|
||||
$eb_next_year = eb_next_prev_month_year(date('Y-m-d'),'year','next');
|
||||
$eb_prev_month = eb_next_prev_month_year(date('Y-m-d'),'month','prev');
|
||||
$eb_prev_year = eb_next_prev_month_year(date('Y-m-d'),'year','prev');
|
||||
}
|
||||
|
||||
$eb_month_name_date = $eb_year.'-'.$eb_today.'-1';
|
||||
$eb_short_month_name = mb_substr(eb_month_name($eb_month_name_date), 0, 3);
|
||||
|
||||
|
||||
$args = array(
|
||||
'taxonomy' => 'eagle_branch',
|
||||
'hide_empty' => false,
|
||||
);
|
||||
|
||||
$branch_query = new WP_Term_Query($args);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="eb-wrapper">
|
||||
|
||||
<?php include EB_PATH.''."core/admin/bookings/elements/admin-header.php"; ?>
|
||||
|
||||
<div class="eb-admin-title">
|
||||
|
||||
<div>
|
||||
<h1 class="wp-heading-inline"><?php echo __('Calendar','eagle-booking') ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="eb-admin-new-booking">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=eb_new_booking') ?>" class="eb-new-booking-btn"><?php echo __('Add New Booking','eagle-booking') ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="eb-calendar-view">
|
||||
|
||||
<div class="calendar-month">
|
||||
<span>
|
||||
<form method="POST" action="admin.php?page=eb_calendar">
|
||||
<input type="hidden" name="eb_month" value="<?php echo $eb_prev_month ?>">
|
||||
<input type="hidden" name="eb_year" value="<?php echo $eb_prev_year ?>">
|
||||
<button type="submit"><i class="fas fa-chevron-left"></i></button>
|
||||
</form>
|
||||
</span>
|
||||
<span>
|
||||
<h2><?php echo eb_month_name($eb_month_name_date).' '.$eb_year ?></h2>
|
||||
</span>
|
||||
<span>
|
||||
<form method="POST" action="admin.php?page=eb_calendar">
|
||||
<input type="hidden" name="eb_month" value="<?php echo $eb_next_month ?>">
|
||||
<input type="hidden" name="eb_year" value="<?php echo $eb_next_year ?>">
|
||||
<button type="submit"><i class="fas fa-chevron-right"></i></button>
|
||||
</form>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<table class="calendar-days">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%"><strong><?php echo __('Room Title', 'eagle-booking') ?></strong></th>
|
||||
<?php for ($eb_i = 1; $eb_i <= $eb_tot_days; $eb_i++) :
|
||||
$eb_date = $eb_today.'/'.$eb_i.'/'.$eb_year;
|
||||
|
||||
$day_name = date( "D",strtotime($eb_date) );
|
||||
|
||||
$search = array(
|
||||
'Mon',
|
||||
'Tue',
|
||||
'Wed',
|
||||
'Thu',
|
||||
'Fri',
|
||||
'Sat',
|
||||
'Sun',
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
__('Mon', 'eagle-booking'),
|
||||
__('Tue', 'eagle-booking'),
|
||||
__('Wed', 'eagle-booking'),
|
||||
__('Thu', 'eagle-booking'),
|
||||
__('Fri', 'eagle-booking'),
|
||||
__('Sat', 'eagle-booking'),
|
||||
__('Sun', 'eagle-booking'),
|
||||
);
|
||||
|
||||
$day_name = str_replace($search, $replace, $day_name);
|
||||
|
||||
?>
|
||||
<th class="calendar-day">
|
||||
<span><strong><?php echo $day_name ?></strong></span>
|
||||
<span><strong><?php echo $eb_i ?></strong></span>
|
||||
<span><?php echo $eb_short_month_name ?></span>
|
||||
<span><?php echo $eb_year ?></span>
|
||||
</th>
|
||||
<?php endfor ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'eagle_rooms',
|
||||
'posts_per_page' => -1
|
||||
);
|
||||
|
||||
$the_query = new WP_Query( $args );
|
||||
|
||||
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
|
||||
|
||||
<?php
|
||||
// Defaults
|
||||
$eb_room_title = get_the_title();
|
||||
$eb_room_id = get_the_ID();
|
||||
$eb_room_url = get_edit_post_link( $eb_room_id );
|
||||
$eb_room_qnt = get_post_meta( $eb_room_id, 'eagle_booking_mtb_room_quantity', true );
|
||||
?>
|
||||
|
||||
<tr class="calendar-room">
|
||||
|
||||
<td class="room-title">
|
||||
|
||||
<h3><a href="<?php echo esc_url($eb_room_url) ?>" target="_blank"><?php echo $eb_room_title ?> <span class="room-qnt"><?php echo $eb_room_qnt ?></span></a></h3>
|
||||
|
||||
<?php if ( !empty( $branch_query->terms ) ) : ?>
|
||||
<div class="room-branch"><?php echo eb_room_branch($eb_room_id) ?></div>
|
||||
<?php endif ?>
|
||||
|
||||
</td>
|
||||
|
||||
<?php
|
||||
|
||||
for ($eb_i = 1; $eb_i <= $eb_tot_days; $eb_i++) :
|
||||
|
||||
// Dates
|
||||
$eb_date_from = $eb_today.'/'.$eb_i.'/'.$eb_year;
|
||||
$eb_date_to = date('m/d/Y', strtotime($eb_date_from.' + 1 days'));
|
||||
$eb_date = date('m/d/Y', strtotime($eb_date_to.' - 1 days'));
|
||||
|
||||
// Check Availability
|
||||
$eb_availability = eagle_booking_is_qnt_available( eb_room_availability($eb_room_id, $eb_date_from, $eb_date_to), $eb_date_from, $eb_date_to, $eb_room_id );
|
||||
|
||||
$eb_availability_block = eb_room_is_available_block( $eb_room_id, $eb_date_from, $eb_date_to );
|
||||
|
||||
if ( $eb_availability == 0 ) {
|
||||
|
||||
// Booked / Not Available
|
||||
$eb_date_class = 'eb-room-booked eb-room-not-available';
|
||||
|
||||
|
||||
} elseif ( $eb_availability_block == 0 ) {
|
||||
|
||||
// Blocked
|
||||
$eb_date_class = 'eb-room-blocked';
|
||||
|
||||
} else {
|
||||
|
||||
if ( eb_room_availability($eb_room_id, $eb_date_from, $eb_date_to) != '' ) {
|
||||
|
||||
// Booked / Available
|
||||
$eb_date_class = 'eb-room-booked eb-room-still-available';
|
||||
|
||||
} else {
|
||||
|
||||
// Not Booked
|
||||
$eb_date_class = '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="eb-room-availability <?php echo esc_attr($eb_date_class) ?>" data-date="<?php echo $eb_date ?>" data-room-id="<?php echo $eb_room_id ?>" data-room-title="<?php echo $eb_room_title ?>" data-displayed-date="<?php echo eagle_booking_displayd_date_format($eb_date) ?>"></td>
|
||||
|
||||
<?php endfor ?>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
<!-- Calendar Bookings Footer -->
|
||||
<div class="calendar-bookings-footer">
|
||||
<ul class="">
|
||||
<li><span class="room-qnt"></span> <?php echo __('Room Quantity', 'eagle-booking') ?></li>
|
||||
</ul>
|
||||
<ul class="availability-calendar-list-availability eb-pull-right">
|
||||
<li><span class="available"></span><?php echo __('Booked / Available', 'eagle-booking') ?></li>
|
||||
<li><span class="not-available"></span><?php echo __('Booked / Not Available', 'eagle-booking') ?> </li>
|
||||
<li><span class="blocked"></span><?php echo __('Blocked / Not Available', 'eagle-booking') ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Create a popup here and tigger it on date hover -->
|
||||
<div id="eb-room-availability-popup" class="eb-popover" style="display: none">
|
||||
<div class="inner">
|
||||
<h2 id="eb-calendar-title-loading"><?php echo __('Loading...', 'eagle-booking') ?></h2>
|
||||
<h2 id="eb-calendar-title"><?php echo __('Bookings for', 'eagle-booking') ?> <span id="eb-calendar-room-title"></span> <?php echo __('on', 'eagle-booking' )?> <span id="eb-calendar-date"></span></h2>
|
||||
<div id="content"></div>
|
||||
<div class="popup-footer">
|
||||
<ul class="booking-status-explanation">
|
||||
<li><span class="status completed"></span><?php echo __('Completed', 'eagle-booking' ) ?></li>
|
||||
<li><span class="status pending-payment"></span><?php echo __('Pending Payment', 'eagle-booking') ?></li>
|
||||
<li><span class="status pending"></span><?php echo __('Pending', 'eagle-booking') ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Popup -->
|
||||
<div class="eb-popup">
|
||||
<div class="eb-popup-inner">
|
||||
<span class="eb-close-popup"><i class="fas fa-times"></i></span>
|
||||
<div class="eb-popup-icon failed">
|
||||
<i class="far fa-trash-alt"></i>
|
||||
</div>
|
||||
<h3 class="title"><?php echo __('Delete Booking', 'eagle-booking') ?> #<span id="eb_booking_id_text"></span></h3>
|
||||
<p><?php echo __('This action cannot be undone. Are you sure you want to delete this booking?', 'eagle-booking') ?></p>
|
||||
<button class="btn btn-delete" id="eb_delete_booking_confirmation" data-booking-id="">
|
||||
<span class="eb-btn-text"><?php echo __('Yes, delete this booking', 'eagle-booking') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } else {
|
||||
|
||||
echo '<div class="error"><h3>Eagle Booking</h3><p>It seems that the PHP core function <strong>cal_days_in_month()</strong> is disabled. To display the calendar this function is mandatory. Please get in touch with your hosting provider and ask them to enable the cal_days_in_month() function. <a href="https://www.php.net/manual/en/function.cal-days-in-month.php" target="_blank">More details.</a></p></div>';
|
||||
}
|
||||
@@ -0,0 +1,589 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Edit Booking
|
||||
* @ since 1.0.0
|
||||
* @ modified 1.3.3
|
||||
---------------------------------------------------------------------------*/
|
||||
if ( isset($_GET["id"]) && $_GET['id'] != '' ) {
|
||||
|
||||
$eagle_booking_booking_id = $_GET['id'];
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$eagle_booking_table_name = $wpdb->prefix . 'eagle_booking';
|
||||
$eb_table_meta_name = $wpdb->prefix . 'eagle_booking_meta';
|
||||
$eagle_booking_booking_update = 0;
|
||||
|
||||
// UPDATE BOOKING
|
||||
if (isset($_POST['eagle_booking_booking_id'])) {
|
||||
$eagle_booking_booking_id = sanitize_text_field($_POST['eagle_booking_booking_id']);
|
||||
$eagle_booking_checkin = sanitize_text_field($_POST['eagle_booking_booking_date_from']);
|
||||
$eagle_booking_checkout = sanitize_text_field($_POST['eagle_booking_booking_date_to']);
|
||||
|
||||
// Guests
|
||||
if (eb_get_option('eb_adults_children') == true) {
|
||||
$eagle_booking_adults = sanitize_text_field($_POST['eagle_booking_booking_adults']);
|
||||
$eagle_booking_children = sanitize_text_field($_POST['eagle_booking_booking_children']);
|
||||
$eagle_booking_guests = $eagle_booking_adults + $eagle_booking_children;
|
||||
} else {
|
||||
$eagle_booking_adults = 0;
|
||||
$eagle_booking_children = 0;
|
||||
$eagle_booking_guests = sanitize_text_field($_POST['eagle_booking_booking_guests']);
|
||||
}
|
||||
|
||||
// Deposit Amount
|
||||
if (eb_get_option('eagle_booking_deposit_amount') < 100) {
|
||||
$eb_deposit_amount = sanitize_text_field($_POST['eagle_booking_deposit_amount']);
|
||||
} else {
|
||||
$eb_deposit_amount = sanitize_text_field($_POST['eagle_booking_booking_final_trip_price']);
|
||||
}
|
||||
|
||||
$eagle_booking_edit_booking = $wpdb->update(
|
||||
$eagle_booking_table_name,
|
||||
array(
|
||||
'id' => sanitize_text_field($_POST['eagle_booking_booking_id']),
|
||||
'id_post' => sanitize_text_field($_POST['eagle_booking_booking_id_post']),
|
||||
'title_post' => sanitize_text_field($_POST['eagle_booking_booking_title_post']),
|
||||
'date' => sanitize_text_field($_POST['eagle_booking_booking_date']),
|
||||
'date_from' => eagle_booking_system_date_format($eagle_booking_checkin),
|
||||
'date_to' => eagle_booking_system_date_format($eagle_booking_checkout),
|
||||
'guests' => $eagle_booking_guests,
|
||||
'adults' => $eagle_booking_adults,
|
||||
'children' => $eagle_booking_children,
|
||||
'final_trip_price' => sanitize_text_field($_POST['eagle_booking_booking_final_trip_price']),
|
||||
'extra_services' => sanitize_text_field($_POST['eagle_booking_booking_extra_services']),
|
||||
'id_user' => sanitize_text_field($_POST['eagle_booking_booking_id_user']),
|
||||
'user_ip' => sanitize_text_field($_POST['eb_user_ip']),
|
||||
'user_first_name' => sanitize_text_field($_POST['eagle_booking_booking_user_first_name']),
|
||||
'user_last_name' => sanitize_text_field($_POST['eagle_booking_booking_user_last_name']),
|
||||
'paypal_email' => sanitize_text_field($_POST['eagle_booking_booking_paypal_email']),
|
||||
'user_phone' => sanitize_text_field($_POST['eagle_booking_booking_user_phone']),
|
||||
'user_address' => sanitize_text_field($_POST['eagle_booking_booking_user_address']),
|
||||
'user_city' => sanitize_text_field($_POST['eagle_booking_booking_user_city']),
|
||||
'user_country' => sanitize_text_field($_POST['eagle_booking_booking_user_country']),
|
||||
'deposit_amount' => $eb_deposit_amount,
|
||||
'user_message' => sanitize_text_field($_POST['eagle_booking_booking_user_message']),
|
||||
'user_arrival' => sanitize_text_field($_POST['eagle_booking_booking_user_arrival']),
|
||||
'user_coupon' => sanitize_text_field($_POST['eagle_booking_booking_user_coupon']),
|
||||
'paypal_payment_status' => sanitize_text_field($_POST['eagle_booking_booking_paypal_payment_status']),
|
||||
'paypal_currency' => sanitize_text_field($_POST['eagle_booking_booking_paypal_currency']),
|
||||
'paypal_tx' => sanitize_text_field($_POST['eagle_booking_booking_paypal_tx']),
|
||||
'action_type' => sanitize_text_field($_POST['eagle_booking_booking_action_type']),
|
||||
),
|
||||
array( 'ID' => sanitize_text_field($_POST['eagle_booking_booking_id']) )
|
||||
);
|
||||
|
||||
$eagle_booking_booking_update = 1;
|
||||
}
|
||||
|
||||
// SELECT BOOKINGS
|
||||
$bookings = $wpdb->get_results("SELECT * FROM $eagle_booking_table_name WHERE id = $eagle_booking_booking_id");
|
||||
|
||||
if (empty($bookings)) : ?>
|
||||
|
||||
<p><?php echo __('There was a DB error', 'eagle-booking') ?></p>
|
||||
|
||||
<?php else :
|
||||
|
||||
foreach ($bookings as $booking) :
|
||||
|
||||
$eagle_booking_id = $booking->id_post;
|
||||
$eagle_booking_image_id = get_post_thumbnail_id($eagle_booking_id);
|
||||
$eagle_booking_image_attributes = wp_get_attachment_image_src($eagle_booking_image_id, 'thumbnail');
|
||||
$eagle_booking_room_img_src = $eagle_booking_image_attributes[0];
|
||||
|
||||
$eb_user_id = $booking->id_user;
|
||||
if ($eb_user_id) {
|
||||
$eb_user_name = get_user_by('id', $eb_user_id)->user_login;
|
||||
}
|
||||
|
||||
|
||||
// Get the payment method text
|
||||
if ($booking->action_type === 'payment_on_arrive') {
|
||||
$eb_new_action_type_text = __('Payment on Arrival', 'eagle-booking');
|
||||
} elseif ($booking->action_type === '2checkout') {
|
||||
$eb_new_action_type_text = __('2Checkout', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'bank_transfer') {
|
||||
$eb_new_action_type_text = __('Bank Transfer', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'PayU') {
|
||||
$eb_new_action_type_text = __('PayU', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'paystack') {
|
||||
$eb_new_action_type_text = __('Paystack', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'flutterwave') {
|
||||
$eb_new_action_type_text = __('Flutterwave', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'vivawallet') {
|
||||
$eb_new_action_type_text = __('Viva Wallet', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'razorpay') {
|
||||
$eb_new_action_type_text = __('Razorpay', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'booking_request') {
|
||||
$eb_new_action_type_text = __('Booking Request', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'stripe') {
|
||||
$eb_new_action_type_text = __('Stripe', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'paypal') {
|
||||
$eb_new_action_type_text = __('PayPal', 'eagle-booking');
|
||||
} elseif ($booking->action_type === 'external') {
|
||||
$eb_new_action_type_text = __('External Payment', 'eagle-booking');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="eb-wrapper eb-admin-page eb-admin-booking-details">
|
||||
|
||||
<?php
|
||||
|
||||
// Print Logo - too be removed
|
||||
$eb_hotel_logo = eb_get_option('hotel_logo'); ?>
|
||||
|
||||
<div class="hotel-logo-print">
|
||||
<?php
|
||||
if (!empty($eb_hotel_logo)) {
|
||||
echo "<img src=".$eb_hotel_logo." height='25px'>";
|
||||
} else {
|
||||
echo get_bloginfo('name');
|
||||
} ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include EB_PATH.''."core/admin/bookings/elements/admin-header.php"; ?>
|
||||
|
||||
<div class="eb-admin-title">
|
||||
|
||||
<div>
|
||||
<h1 class="wp-heading-inline"><?php echo __('Edit Booking', 'eagle-booking').' #'.$eagle_booking_booking_id ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="eb-admin-new-booking">
|
||||
<a href="<?php echo admin_url('admin.php?page=eb_new_booking') ?>" class="eb-new-booking-btn"><?php echo __('Add New Booking', 'eagle-booking') ?></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<div class="eb-booking-details-page">
|
||||
|
||||
<div class="eb-main-details">
|
||||
|
||||
<?php
|
||||
if ($eagle_booking_booking_update == 1) { ?>
|
||||
<div class="update-mssg success" style="margin-bottom: 40px">
|
||||
<p>
|
||||
<strong><?php echo __('Booking Updated Successfully', 'eagle-booking') ?></strong>
|
||||
</p>
|
||||
<button type="button" class="notice-dismiss">
|
||||
<span class="screen-reader-text"><?php echo __('Dismiss this notice.', 'eagle-booking') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
// $wpdb->show_errors();
|
||||
// $wpdb->print_error();
|
||||
|
||||
} ?>
|
||||
|
||||
<input readonly name="eagle_booking_booking_id" style="display: none;" type="text" value="<?php echo $booking->id ?>">
|
||||
<input readonly name="eagle_booking_booking_id_post" style="display: none;" type="text" value="<?php echo $booking->id_post ?>">
|
||||
<input readonly name="eagle_booking_booking_title_post" style="display: none;" type="text" value="<?php echo $booking->title_post ?>">
|
||||
|
||||
<div class="eb-form">
|
||||
|
||||
<input readonly name="eagle_booking_booking_date" type="hidden" value="<?php echo $booking->date ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Check In', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_date_from" type="text" value="<?php echo eagle_booking_displayd_date_format($booking->date_from) ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Check Out', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_date_to" type="text" value="<?php echo eagle_booking_displayd_date_format($booking->date_to) ?>">
|
||||
</div>
|
||||
|
||||
<?php if (eb_get_option('eb_adults_children') == false) : ?>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Guests', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_guests" type="text" value="<?php echo $booking->guests ?>">
|
||||
</div>
|
||||
<?php else : ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Adults', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_adults" type="text" value="<?php echo $booking->adults ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Children', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_children" type="text" value="<?php echo $booking->children ?>">
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Arrival', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_arrival" type="text" value="<?php echo $booking->user_arrival ?>">
|
||||
</div>
|
||||
|
||||
<input readonly name="eagle_booking_booking_id_user"style="display: none;" type="text" value="<?php echo $booking->id_user ?>">
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Name', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_first_name" type="text" value="<?php echo $booking->user_first_name ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Surname', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_last_name" type="text" value="<?php echo $booking->user_last_name ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Email', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_paypal_email" type="text" value="<?php echo $booking->paypal_email ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Phone', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_phone" type="text" value="<?php echo $booking->user_phone ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Address', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_address" type="text" value="<?php echo $booking->user_address ?>">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('City', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_city" type="text" value="<?php echo $booking->user_city ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Country', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_booking_user_country" type="text" value="<?php echo $booking->user_country ?>">
|
||||
</div>
|
||||
|
||||
<?php if (eb_get_option('eagle_booking_deposit_amount') < 100) : ?>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Deposit Amount', 'eagle-booking') ?></label>
|
||||
<input name="eagle_booking_deposit_amount" type="text" value="<?php echo $booking->deposit_amount ?>">
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="customer-comments" style="clear: both;">
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Requests', 'eagle-booking') ?></label>
|
||||
<textarea style="width: 100%; min-height: 80px;" name="eagle_booking_booking_user_message"><?php echo $booking->user_message ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="booking-price">
|
||||
<input name="eagle_booking_booking_final_trip_price" type="hidden" value="<?php echo $booking->final_trip_price ?>">
|
||||
<input name="eagle_booking_booking_paypal_currency" type="hidden" value="<?php echo $booking->paypal_currency ?>">
|
||||
<input name="eagle_booking_booking_extra_services" type="hidden" value="<?php echo $booking->extra_services ?>">
|
||||
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<th style="width:95%;"><?php echo __('Description', 'eagle-booking') ?></th>
|
||||
<th style="width:5%;"><?php echo __('Amount', 'eagle-booking') ?></th>
|
||||
</thead>
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Additional Service
|
||||
*/
|
||||
$eagle_booking_services_array = explode(',', $booking->extra_services);
|
||||
|
||||
$eagle_booking_tot_services = 0;
|
||||
$eb_services_total_price = 0;
|
||||
|
||||
for ($eagle_booking_services_array_i = 0; $eagle_booking_services_array_i < count($eagle_booking_services_array)-1; $eagle_booking_services_array_i++) {
|
||||
|
||||
$eagle_booking_service_array = explode('[', $eagle_booking_services_array[$eagle_booking_services_array_i]);
|
||||
$eagle_booking_service_id = $eagle_booking_service_array[0];
|
||||
$eagle_booking_service_name = get_the_title($eagle_booking_service_id);
|
||||
$eagle_booking_mtb_service_price_type_1 = get_post_meta($eagle_booking_service_id, 'eagle_booking_mtb_service_price_type_1', true);
|
||||
$eagle_booking_mtb_service_price_type_2 = get_post_meta($eagle_booking_service_id, 'eagle_booking_mtb_service_price_type_2', true);
|
||||
|
||||
$eb_service_price = get_post_meta($eagle_booking_service_id, 'eagle_booking_mtb_service_price', true);
|
||||
|
||||
$eagle_booking_service_price = str_replace(']', '', $eagle_booking_service_array[1]);
|
||||
|
||||
if (empty($eagle_booking_service_price)) {
|
||||
$eagle_booking_service_price = 0;
|
||||
}
|
||||
|
||||
if ($eagle_booking_mtb_service_price_type_1 == 'guest') {
|
||||
$eagle_booking_price_type_1 = $booking->guests;
|
||||
} else {
|
||||
$eagle_booking_price_type_1 = 1;
|
||||
}
|
||||
if ($eagle_booking_mtb_service_price_type_2 == 'night') {
|
||||
$eagle_booking_price_type_2 = eb_total_booking_nights($booking->date_from, $booking->date_to);
|
||||
} else {
|
||||
$eagle_booking_price_type_2 = 1;
|
||||
}
|
||||
|
||||
$eb_service_price = $eagle_booking_service_price / $eagle_booking_price_type_1 / $eagle_booking_price_type_2;
|
||||
|
||||
if (empty($eagle_booking_service_price_initial)) {
|
||||
$eagle_booking_service_price_initial = 0;
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td style="width:70%;">
|
||||
<?php echo $eagle_booking_service_name ?>
|
||||
</td>
|
||||
<td style="width:10%;">
|
||||
|
||||
<?php
|
||||
|
||||
if ( $eagle_booking_service_price == 0 ) {
|
||||
|
||||
echo __('Free', 'eagle-booking');
|
||||
|
||||
} else {
|
||||
|
||||
echo eb_price( $eagle_booking_service_price );
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$eb_services_total_price += $eagle_booking_tot_services + $eagle_booking_service_price;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fees & Taxes
|
||||
*/
|
||||
$fees = get_option('eb_fees');
|
||||
$taxes = get_option('eb_taxes');
|
||||
$booking_taxes = $wpdb->get_results("SELECT * FROM $eb_table_meta_name WHERE booking_id = $eagle_booking_booking_id AND meta_key = 'tax' ");
|
||||
$booking_fees = $wpdb->get_results("SELECT * FROM $eb_table_meta_name WHERE booking_id = $eagle_booking_booking_id AND meta_key = 'fee' ");
|
||||
$room_price = $wpdb->get_row( "SELECT * FROM $eb_table_meta_name WHERE booking_id = $eagle_booking_booking_id AND meta_key = 'room_price' " );
|
||||
|
||||
$room_price = $room_price->meta_value;
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $booking->title_post ?></td>
|
||||
<td><?php echo eb_price( $room_price ); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
// echo '<pre>'; print_r($eb_fees); echo '</pre>';
|
||||
|
||||
if ( $booking_fees ) {
|
||||
|
||||
$html = '';
|
||||
|
||||
foreach( $booking_fees as $key => $booking_fee ) {
|
||||
|
||||
foreach ( $fees as $key => $item ) {
|
||||
|
||||
if ( $booking_fee->meta_value == $item['id'] ) {
|
||||
|
||||
$type = !empty( $item["type"] ) ? $item["type"] : '';
|
||||
|
||||
$amount = $item['amount'];
|
||||
|
||||
// Calculate the fee total
|
||||
if ( $type === 'per_booking' ) {
|
||||
|
||||
$fee_amount = $amount;
|
||||
|
||||
} elseif ( $type === 'per_booking_nights' ) {
|
||||
|
||||
$fee_amount = $amount * eb_total_booking_nights($booking->date_from, $booking->date_to);
|
||||
|
||||
} elseif ( $type === 'per_booking_nights_guests' ) {
|
||||
|
||||
$fee_amount = $amount * $booking->guests * eb_total_booking_nights($booking->date_from, $booking->date_to);
|
||||
|
||||
} else {
|
||||
|
||||
$fee_amount = $amount * $booking->guests;
|
||||
|
||||
}
|
||||
|
||||
$html .= '<td>'.$item['title'].'</td>';
|
||||
$html .= '<td>'.eb_price( $fee_amount ).'</td>';
|
||||
$html .= "</tr>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "<tr>";
|
||||
|
||||
}
|
||||
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
if ( $booking_taxes ) {
|
||||
|
||||
$html = '';
|
||||
|
||||
foreach( $booking_taxes as $key => $booking_tax ) {
|
||||
|
||||
foreach ( $taxes as $key => $tax ) {
|
||||
|
||||
if ( $booking_tax->meta_value == $tax['id'] ) {
|
||||
|
||||
|
||||
$services = !empty( $tax["services"] ) ? $tax["services"] : '';
|
||||
|
||||
// Check if the tax is applied on services
|
||||
if ( $services == true ) {
|
||||
|
||||
$room_tax = round($tax['amount'] * $room_price / 100);
|
||||
$services_tax = round( $tax['amount'] * $eb_services_total_price / 100 );
|
||||
|
||||
$tax_amount = $room_tax + $services_tax;
|
||||
|
||||
} else {
|
||||
|
||||
$tax_amount = $tax['amount'] * $room_price / 100;
|
||||
|
||||
}
|
||||
|
||||
$html .= '<td>'.$tax['title'].'</td>';
|
||||
$html .= '<td>'.eb_price( $tax_amount ).'</td>';
|
||||
$html .= "</tr>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "<tr>";
|
||||
|
||||
}
|
||||
|
||||
echo $html;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
<div style="border-top:1px dashed #e3e3e3; margin-top: 10px">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td style="width:95%;">
|
||||
<h4><?php echo __('Total', 'eagle-booking') ?></h4>
|
||||
</td>
|
||||
<td style="width:5%;"><?php echo eb_price( $booking->final_trip_price ) ?></h4>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="eb-booking-details">
|
||||
<div class="inner">
|
||||
<div class="booking-details-header">
|
||||
<div class="room-image">
|
||||
<img src="<?php echo $eagle_booking_room_img_src ?>">
|
||||
</div>
|
||||
<div class="room-title">
|
||||
<h2><?php echo $booking->title_post ?> <?php if ( eb_room_branch( $eagle_booking_id ) ) echo " - " ?><?php echo eb_room_branch( $eagle_booking_id ) ?></h2>
|
||||
<span><?php echo __('on', 'eagle-booking').' '.$booking->date ?> </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="booking-details-form">
|
||||
|
||||
<?php if (!empty($booking->user_coupon)) : ?>
|
||||
<label><?php echo __('Coupon', 'eagle-booking') ?></label>
|
||||
<input readonly name="eagle_booking_booking_user_coupon" type="text" value="<?php echo $booking->user_coupon ?>">
|
||||
<?php else : ?>
|
||||
<input readonly name="eagle_booking_booking_user_coupon" type="hidden" value="<?php echo $booking->user_coupon ?>">
|
||||
<?php endif ?>
|
||||
|
||||
<label><?php echo __('Transaction ID', 'eagle-booking') ?></label>
|
||||
<input readonly name="eagle_booking_booking_paypal_tx" type="text" value="<?php echo $booking->paypal_tx ?>">
|
||||
|
||||
<label><?php echo __('Customer IP', 'eagle-booking') ?></label>
|
||||
<input readonly name="eb_user_ip" type="text" value="<?php echo $booking->user_ip ?>">
|
||||
|
||||
<label><?php echo __('Payment Method', 'eagle-booking') ?></label>
|
||||
<input readonly type="text" value="<?php echo $eb_new_action_type_text ?>">
|
||||
<input name="eagle_booking_booking_action_type" type="hidden" value="<?php echo $booking->action_type ?>">
|
||||
|
||||
<label><?php echo __('Status', 'eagle-booking') ?></label>
|
||||
<select name="eagle_booking_booking_paypal_payment_status">
|
||||
<option <?php if ($booking->paypal_payment_status == 'Pending') echo 'selected="slected"' ?> value="Pending">
|
||||
<?php echo __('Pending', 'eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($booking->paypal_payment_status == 'Pending Payment') echo 'selected="slected"' ?> value="Pending Payment">
|
||||
<?php echo __('Pending Payment', 'eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($booking->paypal_payment_status == 'Completed') echo 'selected="slected"' ?> value="Completed">
|
||||
<?php echo __('Completed', 'eagle-booking') ?>
|
||||
</option>
|
||||
<option <?php if ($booking->paypal_payment_status == 'Canceled') echo 'selected="slected"' ?> value="Canceled">
|
||||
<?php echo __('Canceled', 'eagle-booking') ?>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="status-button">
|
||||
<button class="btn" type="submit"><?php echo __('Update Booking', 'eagle-booking') ?></button>
|
||||
<button class="btn btn-delete" id="eb_delete_booking"><i class="far fa-trash-alt"></i></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="room-buttons">
|
||||
<?php if ($eb_user_id != 0) : ?>
|
||||
<a href="<?php echo admin_url('user-edit.php?user_id=' . $eb_user_id); ?>" class="action-button">
|
||||
<i class="fas fa-user"></i>
|
||||
<?php echo __('User Profile', 'eagle-booking') ?>
|
||||
</a>
|
||||
<?php endif ?>
|
||||
<a href="mailto:<?php echo $booking->paypal_email ?>" class="action-button">
|
||||
<i class="far fa-envelope"></i>
|
||||
<?php echo __('Contact Customer', 'eagle-booking') ?>
|
||||
</a>
|
||||
<a onClick="window.print()" class="action-button">
|
||||
<i class="fa fa-print" aria-hidden="true"></i>
|
||||
<?php echo __('Print Booking Details', 'eagle-booking') ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="eb-popup">
|
||||
<div class="eb-popup-inner">
|
||||
<span class="eb-close-popup"><i class="fas fa-times"></i></span>
|
||||
<div class="eb-popup-icon failed">
|
||||
<i class="far fa-trash-alt"></i>
|
||||
</div>
|
||||
<h3 class="title"><?php echo __('Delete Booking', 'eagle-booking') ?> #<span id="eb_booking_id_text"><?php echo $eagle_booking_booking_id ?></span></h3>
|
||||
<p><?php echo __('This action cannot be undone. Are you sure you want to delete this booking?', 'eagle-booking') ?></p>
|
||||
<button class="btn btn-delete" id="eb_delete_booking_confirmation" data-booking-id="<?php echo $eagle_booking_booking_id ?>">
|
||||
<span class="eb-btn-text"><?php echo __('Yes, delete this booking', 'eagle-booking') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
endforeach;
|
||||
|
||||
endif;
|
||||
|
||||
} else {
|
||||
echo "Please Select Booking";
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Add new booking (Admin)
|
||||
* Author: Eagle Themes
|
||||
* Since 1.0.0
|
||||
* Modified 1.2.9
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
?>
|
||||
|
||||
<div class="eb-wrapper eb-admin-page">
|
||||
|
||||
<?php include EB_PATH.''."core/admin/bookings/elements/admin-header.php"; ?>
|
||||
<div class="eb-admin-title">
|
||||
<div>
|
||||
<h1 class="wp-heading-inline"><?php echo __('New Booking','eagle-booking') ?></h1>
|
||||
</div>
|
||||
<div class="eb-admin-new-booking">
|
||||
<a href="<?php echo admin_url( 'admin.php?page=eb_new_booking') ?>" class="eb-new-booking-btn"><?php echo __('Add New Booking','eagle-booking') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST">
|
||||
<div class="eb-new-booking-page">
|
||||
<div class="eb-main-details">
|
||||
<input type="hidden" name="eb_new_booking_added" value="1">
|
||||
<div class="eb-form">
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Room','eagle-booking') ?></label>
|
||||
<select id="eb_room_id">
|
||||
<?php
|
||||
$eagle_booking_rooms_args = array( 'posts_per_page' => -1, 'post_type'=> 'eagle_rooms', 'suppress_filters' => false );
|
||||
|
||||
$eagle_rooms = get_posts($eagle_booking_rooms_args);
|
||||
$eagle_booking_dates = '';
|
||||
$eagle_booking_guests = 2;
|
||||
$eagle_booking_adults = 1;
|
||||
$eagle_booking_children = 0;
|
||||
$eagle_booking_checkin_param = 'eb_checkin';
|
||||
$eagle_booking_checkout_param = 'eb_checkout';
|
||||
|
||||
foreach ($eagle_rooms as $eagle_booking_room) : ?>
|
||||
|
||||
<option value="<?php echo $eagle_booking_room->ID; ?>">
|
||||
<?php
|
||||
|
||||
if ( eb_room_has_branch( $eagle_booking_room->ID ) ) {
|
||||
|
||||
echo $eagle_booking_room->post_title.' - '.eb_room_branch( $eagle_booking_room->ID );
|
||||
|
||||
} else {
|
||||
|
||||
echo $eagle_booking_room->post_title;
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</option>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<?php include EB_PATH . 'templates/elements/dates-picker.php' ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<?php include EB_PATH . 'templates/elements/guests-picker.php' ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Name','eagle-booking') ?></label>
|
||||
<input id="eb_firstname" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Surname','eagle-booking') ?></label>
|
||||
<input id="eb_lastname" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Email','eagle-booking') ?></label>
|
||||
<input id="eb_email" type="email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Total Price','eagle-booking') ?></label>
|
||||
<input id="eb_price" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Deposit Amount','eagle-booking') ?></label>
|
||||
<input id="eb_deposit" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Phone','eagle-booking') ?></label>
|
||||
<input id="eb_phone" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Address','eagle-booking') ?></label>
|
||||
<input id="eb_address" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('City','eagle-booking') ?></label>
|
||||
<input id="eb_city" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Country','eagle-booking') ?></label>
|
||||
<input id="eb_country" type="text">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?php echo __('ZIP','eagle-booking') ?></label>
|
||||
<input id="eb_zip" type="text">
|
||||
</div>
|
||||
|
||||
<!-- Arrival -->
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Arrival','eagle-booking') ?></label>
|
||||
<select id="eb_arrival">
|
||||
<option><?php echo __('I do not know','eagle-booking'); ?></option>
|
||||
<option>12:00 - 1:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>1:00 - 2:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>2:00 - 3:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>3:00 - 4:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>4:00 - 5:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>5:00 - 6:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>6:00 - 7:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>7:00 - 8:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>8:00 - 9:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>9:00 - 10:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>10:00 - 11:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>11:00 - 12:00 <?php echo __('am','eagle-booking'); ?></option>
|
||||
<option>12:00 - 1:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>1:00 - 2:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>2:00 - 3:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>3:00 - 4:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>4:00 - 5:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>5:00 - 6:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>6:00 - 7:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>7:00 - 8:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>8:00 - 9:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>9:00 - 10:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>10:00 - 11:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
<option>11:00 - 12:00 <?php echo __('pm','eagle-booking'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label><?php echo __('Requests','eagle-booking') ?></label>
|
||||
<textarea id="eb_requests"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-top: 30px;">
|
||||
<label><?php echo __('Additional Services','eagle-booking') ?> :</label>
|
||||
<?php
|
||||
$eagle_booking_services_args = array( 'posts_per_page' => -1, 'post_type'=> 'eagle_services', 'suppress_filters' => false );
|
||||
$eagle_booking_services = get_posts($eagle_booking_services_args);
|
||||
?>
|
||||
<?php foreach ($eagle_booking_services as $eagle_booking_service) : ?>
|
||||
<?php
|
||||
$eagle_booking_service_type = get_post_meta( $eagle_booking_service->ID, 'eagle_booking_mtb_service_type', true );
|
||||
if ( $eagle_booking_service_type == 'additional' ) :
|
||||
?>
|
||||
<div class="eb-new-booking-service">
|
||||
<input id="<?php echo $eagle_booking_service->ID; ?>" class="eb-additional-service" type="checkbox" value="<?php echo $eagle_booking_service->ID; ?><?php echo '[0]' ?>, ">
|
||||
<label for="<?php echo $eagle_booking_service->ID; ?>"><?php echo $eagle_booking_service->post_title; ?></label>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endforeach; ?>
|
||||
<input type="hidden" id="eb_services">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="eb-booking-details">
|
||||
<div class="inner">
|
||||
<div class="booking-details-form">
|
||||
|
||||
<label><?php echo __('Status','eagle-booking') ?></label>
|
||||
<select id="eb_status">
|
||||
<option value="Pending Payment"><?php echo __('Pending Payment','eagle-booking'); ?></option>
|
||||
<option value="Pending"><?php echo __('Pending','eagle-booking'); ?></option>
|
||||
<option value="Completed"><?php echo __('Completed','eagle-booking'); ?></option>
|
||||
</select>
|
||||
|
||||
<label><?php echo __('Payment Method','eagle-booking') ?></label>
|
||||
<select id="eb_payment_method">
|
||||
<option value="bank_transfer"><?php echo __('Bank Transfer','eagle-booking'); ?></option>
|
||||
<option value="payment_on_arrive"><?php echo __('Payment on Arrival','eagle-booking'); ?></option>
|
||||
<option value="booking_request"><?php echo __('Booking Request','eagle-booking'); ?></option>
|
||||
<option value="paypal"><?php echo __('Paypal','eagle-booking'); ?></option>
|
||||
<option value="stripe"><?php echo __('Stripe','eagle-booking'); ?></option>
|
||||
<option value="PayU"><?php echo __('PayU','eagle-booking'); ?></option>
|
||||
<option value="paystack"><?php echo __('Paystack','eagle-booking'); ?></option>
|
||||
<option value="razorpay"><?php echo __('Razorpay','eagle-booking'); ?></option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="status-button" style="display: block">
|
||||
|
||||
<button id="eb_check_availability" class="btn" value="true">
|
||||
<span class="eb-btn-text"><?php echo __('Check Availability','eagle-booking'); ?></span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="eb-admin-warning"> <?php echo __('Please note: min/max guests number and min/max booking nights restrictions are not taken into consideration on the admin submission. The cost of the additional services is included in the total price.', 'eagle-booking') ?> </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Popup -->
|
||||
<div class="eb-popup">
|
||||
<div class="eb-popup-inner">
|
||||
<span class="eb-close-popup"><i class="fas fa-times"></i></span>
|
||||
<h3 id="eb_popup_heading" class="title"></h3>
|
||||
<p id="eb_popup_text"></p>
|
||||
<button class="btn btn-create" id="eb_create_booking_confirmation">
|
||||
<span class="eb-btn-text"><?php echo __('Yes, submit new booking', 'eagle-booking') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Include Admin Bookings Page
|
||||
* Author: Eagle Themes (Jomin Muskaj)
|
||||
* @since 1.0.0
|
||||
* @modified 1.2.8
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
if ( isset($_GET['delete_booking']) OR isset($_GET['eagle_booking_delete_booking_id']) ) {
|
||||
|
||||
include "include/delete.php";
|
||||
}
|
||||
|
||||
|
||||
// include "include/new.php";
|
||||
105
wp-content/plugins/eagle-booking/core/admin/calendar.php
Normal file
105
wp-content/plugins/eagle-booking/core/admin/calendar.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* @ EB Admin
|
||||
* @ Bookings Calendar View [Admin]
|
||||
* @ Since 1.1.6
|
||||
* @ Author: Eagle Themes
|
||||
* @ Developer: Jomin Muskaj
|
||||
---------------------------------------------------------------------------*/
|
||||
function eb_calendar_availability() {
|
||||
|
||||
// Data
|
||||
$eb_date = $_GET['eb_date'];
|
||||
$eb_room_id = $_GET['eb_room_id'];
|
||||
|
||||
// Verify nonce
|
||||
$eb_calendar_nonce = $_GET['eb_calendar_nonce'];
|
||||
|
||||
if ( !wp_verify_nonce($eb_calendar_nonce, 'eb_admin_nonce') ) {
|
||||
|
||||
$eb_return_data['message'] = 'Invalid Nonce';
|
||||
|
||||
} else {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Get the bookings
|
||||
$eb_calendar_bookings = $wpdb->get_results( "SELECT * FROM ".EAGLE_BOOKING_TABLE." WHERE id_post = $eb_room_id");
|
||||
|
||||
if ( $eb_calendar_bookings ) {
|
||||
|
||||
$eb_output = '<table class="eb-popover-bookings">';
|
||||
$eb_output .= '<thead>';
|
||||
$eb_output .= '<tr>';
|
||||
$eb_output .= '<th>'.__('ID', 'eagle-booking').'</th>';
|
||||
$eb_output .= '<th>'.__('Booking Dates', 'eagle-booking').'</th>';
|
||||
$eb_output .= '<th>'.__('Status', 'eagle-booking').'</th>';
|
||||
$eb_output .= '<th>'.__('Source', 'eagle-booking').'</th>';
|
||||
$eb_output .= '<th>'.__('Action', 'eagle-booking').'</th>';
|
||||
$eb_output .= '</tr>';
|
||||
$eb_output .= '</thead>';
|
||||
$eb_output .= '<tbody id="bookings">';
|
||||
|
||||
foreach ( $eb_calendar_bookings as $eb_calendar_booking ) {
|
||||
|
||||
// Get the booking details
|
||||
$eb_booking_id = $eb_calendar_booking->id;
|
||||
$eb_booking_checkin = $eb_calendar_booking->date_from;
|
||||
$eb_booking_checkout = $eb_calendar_booking->date_to;
|
||||
$eb_booking_status_class = strtolower( preg_replace('/\s+/', '-', $eb_calendar_booking->paypal_payment_status) );
|
||||
|
||||
// Get the total number of booking nights based on the checkin & checkout
|
||||
$eb_nights = eb_total_booking_nights($eb_booking_checkin, $eb_booking_checkout);
|
||||
|
||||
$eb_checked_date = $eb_booking_checkin;
|
||||
|
||||
// Loop for each date that is included in the booking range
|
||||
for ($eb_i = 1; $eb_i <= $eb_nights; $eb_i++ ) {
|
||||
|
||||
if ( $eb_date == $eb_checked_date ) {
|
||||
|
||||
$eb_booking = '<tr class="eb-popover-booking" data-booking-id="'.$eb_booking_id.'">';
|
||||
$eb_booking .= '<td>' .$eb_booking_id. '</td>';
|
||||
$eb_booking .= '<td>' .eagle_booking_displayd_date_format($eb_booking_checkin). ' → ' .eagle_booking_displayd_date_format($eb_booking_checkout). '</td>';
|
||||
$eb_booking .= '<td> <span class="status '.esc_attr($eb_booking_status_class).'"></span> </td>';
|
||||
$eb_booking .= '<td> <span class="">'.eb_booking_source( $eb_booking_id, true ).'</span> </td>';
|
||||
|
||||
$eb_booking .= '<td>';
|
||||
|
||||
if ( eb_booking_source($eb_booking_id) === 'direct' || eb_booking_source($eb_booking_id) === 'admin' ) {
|
||||
|
||||
$eb_booking .= '<a href="admin.php?page=eb_edit_booking&id='.$eb_booking_id.'" class="action-icon" target="_blank"><i class="far fa-edit"></i></a>';
|
||||
$eb_booking .= '<a href="#" id="eb_delete_booking" data-booking-id="'.$eb_booking_id.'" class="action-icon" target="_blank"><i class="far fa-trash-alt"></i></a>';
|
||||
$eb_booking .= '</td>';
|
||||
|
||||
}
|
||||
|
||||
$eb_booking .= '</tr>';
|
||||
|
||||
$eb_bookings[] = $eb_booking;
|
||||
|
||||
}
|
||||
|
||||
// Check the next date
|
||||
$eb_checked_date = date('m/d/Y', strtotime($eb_checked_date.' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$eb_output .= '</tbody>';
|
||||
$eb_output .= '</table>';
|
||||
|
||||
$eb_return_data['output'] = $eb_output;
|
||||
$eb_return_data['bookings'] = $eb_bookings;
|
||||
|
||||
}
|
||||
|
||||
wp_send_json($eb_return_data);
|
||||
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_eb_admin_calendar_action', 'eb_calendar_availability' );
|
||||
125
wp-content/plugins/eagle-booking/core/admin/class-install.php
Normal file
125
wp-content/plugins/eagle-booking/core/admin/class-install.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* EAGLE BOOKING INSTALL CLASS
|
||||
---------------------------------------------------------------------------*/
|
||||
class EB_Install {
|
||||
|
||||
// Install Eagle Booking
|
||||
public static function install() {
|
||||
|
||||
// Create Table
|
||||
self::create_tables();
|
||||
|
||||
// Create user role 'eb_guest'
|
||||
self::create_user_role();
|
||||
|
||||
}
|
||||
|
||||
// On Update Eagle Booking
|
||||
public static function update() {
|
||||
|
||||
// Check if there is a new version of the DB
|
||||
if ( get_site_option( 'eagle_booking_db_version' ) != EB_DB_VERSION ) {
|
||||
|
||||
// Update Table (Re-create Table)
|
||||
self::create_tables();
|
||||
|
||||
// Create user role 'eb_guest'
|
||||
self::create_user_role();
|
||||
|
||||
// Update DB Version
|
||||
update_option( 'eagle_booking_db_version', EB_DB_VERSION );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set up the database tables which Eagle Booking needs to function.
|
||||
private static function create_tables() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// $wpdb->hide_errors();
|
||||
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||
dbDelta( self::get_schema() );
|
||||
|
||||
// Set DB Version
|
||||
add_option( 'eagle_booking_db_version', EB_DB_VERSION );
|
||||
|
||||
}
|
||||
|
||||
// Create 'Hotel Guest' user role
|
||||
private static function create_user_role() {
|
||||
|
||||
add_role(
|
||||
'eb_guest',
|
||||
__( 'Hotel Guest', 'eagle-booking' ),
|
||||
array(
|
||||
'read' => true,
|
||||
'edit_posts' => false,
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Eagle Booking Create/Update Table
|
||||
public static function get_schema() {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Tables
|
||||
$eb_main_table = $wpdb->prefix . 'eagle_booking';
|
||||
$eb_meta_table = $wpdb->prefix . 'eagle_booking_meta';
|
||||
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
// Create the Booking Main Table
|
||||
$eb_meta_sql = "CREATE TABLE $eb_main_table (
|
||||
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
id_post int(11) NOT NULL,
|
||||
title_post varchar(255) NOT NULL,
|
||||
date varchar(255) NOT NULL,
|
||||
date_from varchar(255) NOT NULL,
|
||||
date_to varchar(255) NOT NULL,
|
||||
guests int(11) NOT NULL,
|
||||
adults int(11) NOT NULL,
|
||||
children int(11) NOT NULL,
|
||||
final_trip_price int(11) NOT NULL,
|
||||
deposit_amount int(11) NOT NULL,
|
||||
extra_services varchar(255) NOT NULL,
|
||||
id_user int(11) NOT NULL,
|
||||
user_first_name varchar(255) NOT NULL,
|
||||
user_last_name varchar(255) NOT NULL,
|
||||
paypal_email varchar(255) NOT NULL,
|
||||
user_ip varchar(45) NOT NULL,
|
||||
user_phone varchar(255) NOT NULL,
|
||||
user_address varchar(255) NOT NULL,
|
||||
user_city varchar(255) NOT NULL,
|
||||
user_country varchar(255) NOT NULL,
|
||||
user_message text(1000) NOT NULL,
|
||||
user_arrival varchar(255) NOT NULL,
|
||||
user_coupon varchar(255) NOT NULL,
|
||||
paypal_payment_status varchar(255) NOT NULL,
|
||||
paypal_currency varchar(255) NOT NULL,
|
||||
paypal_tx varchar(255) NOT NULL,
|
||||
action_type varchar(255) NOT NULL,
|
||||
UNIQUE KEY id (id)
|
||||
|
||||
) $charset_collate;";
|
||||
|
||||
// Create the Booking Meta Table
|
||||
$eb_meta_sql .= "CREATE TABLE $eb_meta_table (
|
||||
|
||||
meta_id int(11) NOT NULL AUTO_INCREMENT,
|
||||
booking_id int(11) NOT NULL,
|
||||
meta_key varchar(255) NOT NULL,
|
||||
meta_value varchar(255) NOT NULL,
|
||||
UNIQUE KEY meta_id (meta_id)
|
||||
|
||||
) $charset_collate;";
|
||||
|
||||
return $eb_meta_sql;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
29
wp-content/plugins/eagle-booking/core/admin/cpt/coupons.php
Normal file
29
wp-content/plugins/eagle-booking/core/admin/cpt/coupons.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Coupons CPT
|
||||
* @since 1.0.5
|
||||
---------------------------------------------------------------------------*/
|
||||
function eagle_booking_create_post_type_coupons() {
|
||||
|
||||
register_post_type('eagle_coupons',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Coupons', 'eagle-booking'),
|
||||
'singular_name' => __('Coupons', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Coupon', 'eagle-booking'),
|
||||
'add_new_item' => __( 'Add New Coupon', 'eagle-booking'),
|
||||
'edit_item' => __( 'Edit Coupon', 'eagle-booking'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'rewrite' => array('slug' => 'coupons' ),
|
||||
'menu_icon' => 'dashicons-forms',
|
||||
'supports' => array('title' )
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action('init', 'eagle_booking_create_post_type_coupons');
|
||||
14
wp-content/plugins/eagle-booking/core/admin/cpt/cpts.php
Normal file
14
wp-content/plugins/eagle-booking/core/admin/cpt/cpts.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Include all CPT required by EB
|
||||
* @since 1.2.9.1
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
require_once EB_PATH . '/core/admin/cpt/coupons.php';
|
||||
require_once EB_PATH . '/core/admin/cpt/exceptions.php';
|
||||
require_once EB_PATH . '/core/admin/cpt/places.php';
|
||||
require_once EB_PATH . '/core/admin/cpt/reviews.php';
|
||||
require_once EB_PATH . '/core/admin/cpt/rooms.php';
|
||||
require_once EB_PATH . '/core/admin/cpt/services.php';
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Exceptions CPT
|
||||
* @since 1.0.4
|
||||
---------------------------------------------------------------------------*/
|
||||
function eagle_booking_create_post_type_exceptions() {
|
||||
|
||||
register_post_type('eagle_exceptions',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Exceptions', 'eagle-booking'),
|
||||
'singular_name' => __('Exceptions', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Exception', 'eagle-booking'),
|
||||
'add_new_item' => __( 'Add New Exception', 'eagle-booking'),
|
||||
'edit_item' => __( 'Edit Exception', 'eagle-booking'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'rewrite' => array('slug' => 'exceptions' ),
|
||||
'menu_icon' => 'dashicons-forms',
|
||||
'supports' => array('title' )
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action('init', 'eagle_booking_create_post_type_exceptions');
|
||||
61
wp-content/plugins/eagle-booking/core/admin/cpt/places.php
Normal file
61
wp-content/plugins/eagle-booking/core/admin/cpt/places.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Places CPT
|
||||
* @since 1.0.0
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
// REGISTER CPT PLACES
|
||||
if (!function_exists('eagle_create_post_type_places')) :
|
||||
function eagle_create_post_type_places() {
|
||||
register_post_type('eagle_places',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Places', 'eagle-booking'),
|
||||
'singular_name' => __('Places', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Item', 'eagle-booking' ),
|
||||
'add_new_item' => __( 'Add New Item', 'eagle-booking' ),
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => false,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'exclude_from_search' => true,
|
||||
'menu_icon' => 'dashicons-location',
|
||||
'rewrite' => array('slug' => eb_get_option('eagle_booking_places_slug')),
|
||||
'supports' => array('title', 'thumbnail', 'editor', 'page-attributes')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action('init', 'eagle_create_post_type_places');
|
||||
|
||||
endif;
|
||||
|
||||
|
||||
// ADD CUSTOM ROWS TO DASHBOARD
|
||||
add_image_size( 'admin-list-thumb', 80, 80, false );
|
||||
|
||||
function eagle_places_dashboard_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'featured_thumb' => __('Thumbnail', 'eagle-booking'),
|
||||
'title' => __('Title', 'eagle-booking'),
|
||||
'date' => 'Date'
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function eagle_places_dashboard_columns_data( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'featured_thumb':
|
||||
echo '<a href="' . get_edit_post_link() . '">';
|
||||
echo the_post_thumbnail( 'admin-list-thumb' );
|
||||
echo '</a>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( function_exists( 'add_theme_support' ) ) {
|
||||
add_filter( 'manage_eagle_places_posts_columns' , 'eagle_places_dashboard_columns' );
|
||||
add_action( 'manage_eagle_places_posts_custom_column' , 'eagle_places_dashboard_columns_data', 10, 2 );
|
||||
}
|
||||
57
wp-content/plugins/eagle-booking/core/admin/cpt/reviews.php
Normal file
57
wp-content/plugins/eagle-booking/core/admin/cpt/reviews.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Reviews CPT
|
||||
* @since 1.0.0
|
||||
---------------------------------------------------------------------------*/
|
||||
function eagle_create_post_type_reviews() {
|
||||
register_post_type('eagle_reviews',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Reviews', 'eagle-booking'),
|
||||
'singular_name' => __('Reviews (Testimonials)', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Item', 'eagle-booking' ),
|
||||
'add_new_item' => __( 'Add New Item', 'eagle-booking' ),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'has_archive' => true,
|
||||
'exclude_from_search' => true,
|
||||
'menu_icon' => 'dashicons-testimonial',
|
||||
'supports' => array('title', 'thumbnail')
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action('init', 'eagle_create_post_type_reviews');
|
||||
|
||||
/*---------------------------------------------------------------------------------
|
||||
CUSTOM DASHBOARD COLUMNS
|
||||
-----------------------------------------------------------------------------------*/
|
||||
function eagle_reviews_dashboard_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __('Title', 'eagle-booking'),
|
||||
'testimonial_quote' => __('Author Quote', 'eagle-booking'),
|
||||
'testimonial_author' => __('Author Name', 'eagle-booking'),
|
||||
'date' => __('Date', 'eagle-booking')
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function eagle_reviews_dashboard_columns_data( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'testimonial_quote':
|
||||
echo get_post_meta( get_the_ID(), 'eagle_booking_mtb_review_quote', true );
|
||||
break;
|
||||
|
||||
case 'testimonial_author':
|
||||
echo get_post_meta( get_the_ID(), 'eagle_booking_mtb_review_author', true );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( function_exists( 'add_theme_support' ) ) {
|
||||
add_filter( 'manage_eagle_reviews_posts_columns' , 'eagle_reviews_dashboard_columns' );
|
||||
add_action( 'manage_eagle_reviews_posts_custom_column' , 'eagle_reviews_dashboard_columns_data', 10, 2 );
|
||||
}
|
||||
92
wp-content/plugins/eagle-booking/core/admin/cpt/rooms.php
Normal file
92
wp-content/plugins/eagle-booking/core/admin/cpt/rooms.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Rooms CPT
|
||||
* @since 1.0.0
|
||||
---------------------------------------------------------------------------*/
|
||||
function eagle_booking_create_post_type_rooms() {
|
||||
|
||||
register_post_type('eagle_rooms',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Rooms', 'eagle-booking'),
|
||||
'singular_name' => __('Rooms', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Room', 'eagle-booking'),
|
||||
'add_new_item' => __( 'Add New Room', 'eagle-booking'),
|
||||
'edit_item' => __( 'Edit Room', 'eagle-booking'),
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'exclude_from_search' => true,
|
||||
'show_in_admin_bar' => true,
|
||||
//'show_in_rest' => true,
|
||||
'rewrite' => array('slug' => eb_get_option('eagle_booking_rooms_slug')),
|
||||
'menu_icon' => 'dashicons-admin-multisite',
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' )
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action('init', 'eagle_booking_create_post_type_rooms');
|
||||
|
||||
|
||||
|
||||
// ADD CUSTOM ROWS TO DASHBOARD
|
||||
add_image_size( 'admin-list-thumb', 80, 80, false );
|
||||
|
||||
function eagle_rooms_dashboard_columns( $columns ) {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'featured_thumb' => esc_html__('Thumbnail', 'eagle-booking'),
|
||||
'title' => esc_html__('Title', 'eagle-booking'),
|
||||
'price' => esc_html__('Price', 'eagle-booking'),
|
||||
'date' => esc_html__('Date', 'eagle-booking'),
|
||||
'taxonomy-eagle_branch' => esc_html__('Branch', 'eagle-booking')
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function eb_rooms_dashboard_columns_data( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
|
||||
case 'featured_thumb':
|
||||
echo '<a href="' . get_edit_post_link() . '">';
|
||||
echo the_post_thumbnail( array(60, 60) );
|
||||
echo '</a>';
|
||||
break;
|
||||
|
||||
case 'price':
|
||||
|
||||
if ( eb_currency_position() === 'before' ) {
|
||||
|
||||
echo eb_currency().''.eagle_booking_room_min_price( $post_id );
|
||||
|
||||
} else {
|
||||
|
||||
echo eagle_booking_room_min_price( $post_id ).''.eb_currency();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
if ( function_exists( 'add_theme_support' ) ) {
|
||||
add_filter( 'manage_eagle_rooms_posts_columns' , 'eagle_rooms_dashboard_columns' );
|
||||
add_action( 'manage_eagle_rooms_posts_custom_column' , 'eb_rooms_dashboard_columns_data', 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
// Keep the admin menu open on editting eagle_rooms CPT
|
||||
function eb_keep_cpt_menu_open($parent_file) {
|
||||
|
||||
global $current_screen, $post_type;
|
||||
|
||||
if ( $post_type == 'eagle_rooms' ) $parent_file = 'eb_bookings';
|
||||
|
||||
return $parent_file;
|
||||
|
||||
}
|
||||
|
||||
add_action('parent_file', 'eb_keep_cpt_menu_open' );
|
||||
29
wp-content/plugins/eagle-booking/core/admin/cpt/services.php
Normal file
29
wp-content/plugins/eagle-booking/core/admin/cpt/services.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Services CPT
|
||||
* @since 1.0.0
|
||||
---------------------------------------------------------------------------*/
|
||||
function eagle_booking_create_post_type_services() {
|
||||
|
||||
register_post_type('eagle_services',
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __('Services', 'eagle-booking'),
|
||||
'singular_name' => __('Services', 'eagle-booking'),
|
||||
'add_new' => __( 'Add New Service', 'eagle-booking'),
|
||||
'add_new_item' => __( 'Add New Service', 'eagle-booking'),
|
||||
'edit_item' => __( 'Edit Service', 'eagle-booking'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'rewrite' => array('slug' => 'services' ),
|
||||
'menu_icon' => 'dashicons-awards',
|
||||
'supports' => array('title' )
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action('init', 'eagle_booking_create_post_type_services');
|
||||
217
wp-content/plugins/eagle-booking/core/admin/email.php
Normal file
217
wp-content/plugins/eagle-booking/core/admin/email.php
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Email Admin & Customer
|
||||
* @since 1.0.0
|
||||
* @modified 1.3.3
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
function eb_send_message(
|
||||
$eagle_booking_room_id,
|
||||
$eagle_booking_title_post,
|
||||
$eagle_booking_date,
|
||||
$eagle_booking_checkin,
|
||||
$eagle_booking_checkout,
|
||||
$eagle_booking_guests,
|
||||
$eagle_booking_adults,
|
||||
$eagle_booking_children,
|
||||
$eagle_booking_final_trip_price,
|
||||
$eagle_booking_deposit_amount,
|
||||
$eagle_booking_extra_services,
|
||||
$eagle_booking_id_user,
|
||||
$eagle_booking_user_first_name,
|
||||
$eagle_booking_user_last_name,
|
||||
$eagle_booking_user_email,
|
||||
$eb_user_ip,
|
||||
$eagle_booking_user_phone,
|
||||
$eagle_booking_user_address,
|
||||
$eagle_booking_user_city,
|
||||
$eagle_booking_user_country,
|
||||
$eagle_booking_user_message,
|
||||
$eb_customer_arrival,
|
||||
$eagle_booking_user_coupon,
|
||||
$eagle_booking_paypal_payment_status,
|
||||
$eagle_booking_paypal_currency,
|
||||
$eagle_booking_transaction_id,
|
||||
$eagle_booking_checkout_payment_type
|
||||
) {
|
||||
|
||||
// Email Settings
|
||||
$eagle_booking_message_admin = eb_get_option('eagle_booking_message')['email_admin'];
|
||||
$eagle_booking_message_guest = eb_get_option('eagle_booking_message')['email_guest'];
|
||||
|
||||
// Email Logo
|
||||
$eb_hotel_logo = eb_get_option('hotel_logo');
|
||||
|
||||
// Email Details
|
||||
$eb_email_customer_text = eb_get_option('email_customer_text');
|
||||
|
||||
// Footer Links
|
||||
$eagle_booking_message_facebook_url = eb_get_option( 'eagle_booking_message_template_facebook_url' );
|
||||
$eagle_booking_message_twitter_url = eb_get_option( 'eagle_booking_message_template_twitter_url' );
|
||||
$eagle_booking_message_instagram_url = eb_get_option( 'eagle_booking_message_template_instagram_url' );
|
||||
|
||||
// Eamil template design
|
||||
$eagle_booking_message_template_bg = eb_get_option( 'eagle_booking_message_template_bg' );
|
||||
$eagle_booking_message_template_border = eb_get_option( 'eagle_booking_message_template_border' );
|
||||
$eagle_booking_message_template_color = eb_get_option( 'eagle_booking_message_template_color' );
|
||||
$eagle_booking_message_template_link_color = eb_get_option( 'eagle_booking_message_template_link_color' );
|
||||
$eagle_booking_message_template_header_bg = eb_get_option( 'eagle_booking_message_template_header_bg' );
|
||||
$eagle_booking_message_template_header_color = eb_get_option( 'eagle_booking_message_template_header_color' );
|
||||
$eagle_booking_message_template_footer_bg = eb_get_option( 'eagle_booking_message_template_footer_bg' );
|
||||
$eagle_booking_message_template_footer_color = eb_get_option( 'eagle_booking_message_template_footer_color' );
|
||||
$eagle_booking_message_template_footer_border = eb_get_option( 'eagle_booking_message_template_footer_border' );
|
||||
|
||||
// Total & Deposit Amount
|
||||
$eb_email_total_amount = eb_price( $eagle_booking_final_trip_price, false );
|
||||
$eb_email_deposit_amount = eb_price( $eagle_booking_deposit_amount, false );
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* GET HOTEL INFO
|
||||
---------------------------------------------------------------------------*/
|
||||
$eagle_booking_hotel_name = eb_get_option('eagle_booking_message_sender_name');
|
||||
$eagle_booking_hotel_url = get_site_url();
|
||||
|
||||
if ( eb_get_option('email_hotel_logo') == true && !empty( $eb_hotel_logo )) {
|
||||
$eagle_booking_hotel_logo = '<img src="'.esc_url($eb_hotel_logo).'">';
|
||||
} else {
|
||||
$eagle_booking_hotel_logo = get_bloginfo( 'name' );
|
||||
}
|
||||
|
||||
// Sender email
|
||||
$eagle_booking_sender_email = eb_get_option('eagle_booking_message_sender_email');
|
||||
|
||||
// Get the booking status text
|
||||
if ( $eagle_booking_paypal_payment_status == 'Pending Payment' ) {
|
||||
$eb_booking_status = __('Pending Payment', 'eagle-booking');
|
||||
|
||||
} elseif ( $eagle_booking_paypal_payment_status == 'Pending' ){
|
||||
$eb_booking_status = __('Pending', 'eagle-booking');
|
||||
|
||||
} elseif ( $eagle_booking_paypal_payment_status == 'Canceled' ){
|
||||
$eb_booking_status = __('Canceled', 'eagle-booking');
|
||||
|
||||
} else {
|
||||
$eb_booking_status = __('Completed', 'eagle-booking');
|
||||
}
|
||||
|
||||
// Get the payment method text
|
||||
if( $eagle_booking_checkout_payment_type === 'payment_on_arrive' ) {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Payment on Arrival', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === '2checkout') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('2Checkout', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'bank_transfer') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Bank Transfer', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'PayU') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('PayU', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'paystack') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Paystack', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'flutterwave') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Flutterave', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'razorpay') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Razorpay', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'booking_request') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Booking Request', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'stripe') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Stripe', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'paypal') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('PayPal', 'eagle-booking');
|
||||
|
||||
} elseif ($eagle_booking_checkout_payment_type === 'vivawallet') {
|
||||
|
||||
$eagle_booking_checkout_payment_type_text = __('Viva Wallet', 'eagle-booking');
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Additional Services
|
||||
---------------------------------------------------------------------------*/
|
||||
$eb_email_additional_services = '';
|
||||
|
||||
if ( empty($eagle_booking_extra_services) ) {
|
||||
|
||||
$eb_email_additional_services = '';
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_services_array = explode(',', $eagle_booking_extra_services );
|
||||
|
||||
for ($eagle_booking_services_array_i = 0; $eagle_booking_services_array_i < count($eagle_booking_services_array)-1; $eagle_booking_services_array_i++) {
|
||||
|
||||
$eagle_booking_service_array = explode('[', $eagle_booking_services_array[$eagle_booking_services_array_i] );
|
||||
$eagle_booking_service_id = $eagle_booking_service_array[0];
|
||||
$eagle_booking_service_title = get_the_title($eagle_booking_service_id);
|
||||
$eagle_booking_service_price = str_replace(']','', $eagle_booking_service_array[1]);
|
||||
|
||||
$eb_email_additional_services .= '<p>'.$eagle_booking_service_title.'</p>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Admin Email
|
||||
---------------------------------------------------------------------------*/
|
||||
$eagle_booking_admin_email = eb_get_option('eagle_booking_message_admin_email');
|
||||
$eagle_booking_admin_subject = __('New Reservation','eagle-booking');
|
||||
|
||||
ob_start();
|
||||
include eb_load_template('email/admin.php');
|
||||
$eagle_booking_admin_template = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// Admin email headers
|
||||
$eagle_booking_admin_headers = array(
|
||||
'Content-Type: text/html; charset=UTF-8',
|
||||
'From: '.$eagle_booking_hotel_name.' <'.$eagle_booking_sender_email.'>',
|
||||
'Reply-To: '.$eagle_booking_user_first_name.' '.$eagle_booking_user_last_name.' <'.$eagle_booking_user_email.'>',
|
||||
);
|
||||
|
||||
// Send email to admin
|
||||
if ( $eagle_booking_message_admin == true ) :
|
||||
wp_mail( $eagle_booking_admin_email, $eagle_booking_admin_subject, $eagle_booking_admin_template, $eagle_booking_admin_headers );
|
||||
endif;
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Customer Email
|
||||
---------------------------------------------------------------------------*/
|
||||
$eagle_booking_customer_subject = __('Your Reservation','eagle-booking');
|
||||
$eagle_booking_customer_headers = array(
|
||||
'Content-Type: text/html; charset=UTF-8',
|
||||
'From: '.$eagle_booking_hotel_name.' <'.$eagle_booking_sender_email.'>',
|
||||
'Reply-To: '.$eagle_booking_hotel_name.' <'.$eagle_booking_sender_email.'>',
|
||||
);
|
||||
|
||||
ob_start();
|
||||
include eb_load_template('email/customer.php');
|
||||
$eagle_booking_customer_template = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// Send email to customer
|
||||
if ($eagle_booking_message_guest == true ) :
|
||||
wp_mail( $eagle_booking_user_email, $eagle_booking_customer_subject, $eagle_booking_customer_template, $eagle_booking_customer_headers );
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
// Send email after reservation added into the DB
|
||||
add_action('eb_insert_booking_in_db','eb_send_message', 10 ,27);
|
||||
130
wp-content/plugins/eagle-booking/core/admin/form-parameters.php
Normal file
130
wp-content/plugins/eagle-booking/core/admin/form-parameters.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Set defaults
|
||||
*/
|
||||
$eb_room_id = get_the_ID();
|
||||
$eagle_booking_dates = '';
|
||||
|
||||
/**
|
||||
* Set default values if not provided
|
||||
*/
|
||||
if( !isset( $_GET['eb_guests']) && !isset( $_GET['eb_adults'] ) ) {
|
||||
|
||||
$eagle_booking_guests = eb_get_option('eb_default_guests');
|
||||
$eagle_booking_adults = eb_get_option('eb_default_adults');
|
||||
$eagle_booking_children = eb_get_option('eb_default_children');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults Guests (or adults & children)
|
||||
*/
|
||||
if( eb_get_option('eb_adults_children') == true ) {
|
||||
|
||||
$eb_default_guests = $eagle_booking_adults + $eagle_booking_children;
|
||||
|
||||
} else {
|
||||
|
||||
$eb_default_guests = $eagle_booking_guests;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* External Booking target
|
||||
*/
|
||||
if (eb_get_option('booking_type') != 'builtin' && eb_get_option('eagle_booking_external_target')) {
|
||||
$eagle_booking_target = '_blank';
|
||||
} else {
|
||||
$eagle_booking_target = '_self';
|
||||
}
|
||||
|
||||
/**
|
||||
* Guests Parameters
|
||||
*/
|
||||
if ( is_singular( 'eagle_rooms' ) ) {
|
||||
|
||||
$eb_max_guests = get_post_meta( $eb_room_id, 'eagle_booking_mtb_room_maxguests', true );
|
||||
$eb_max_adults = get_post_meta( $eb_room_id, 'eagle_booking_mtb_room_max_adults', true );
|
||||
$eb_max_children = get_post_meta( $eb_room_id, 'eagle_booking_mtb_room_max_children', true );
|
||||
|
||||
if ( $eb_max_guests < $eagle_booking_guests ) $eagle_booking_guests = $eb_max_guests;
|
||||
if ( $eb_max_adults < $eagle_booking_adults ) $eagle_booking_adults = $eb_max_adults;
|
||||
if ( $eb_max_children < $eagle_booking_children ) $eagle_booking_children = $eb_max_children;
|
||||
|
||||
} else {
|
||||
|
||||
$eb_max_guests = eb_get_option('eb_max_guests');
|
||||
$eb_max_adults = eb_get_option('eb_max_adults');
|
||||
$eb_max_children = eb_get_option('eb_max_children');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Form Action Based on Booking System
|
||||
*/
|
||||
if ( eb_get_option('booking_type') == 'builtin' ) {
|
||||
|
||||
// Action for the form on single room
|
||||
if ( is_singular( 'eagle_rooms' ) ) {
|
||||
|
||||
$eagle_booking_action = eb_booking_page();
|
||||
$eagle_booking_action_method = 'POST';
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_action = eb_search_page();
|
||||
$eagle_booking_action_method = 'GET';
|
||||
|
||||
}
|
||||
|
||||
$eagle_booking_checkin_param = 'eb_checkin';
|
||||
$eagle_booking_checkout_param = 'eb_checkout';
|
||||
$eagle_booking_guests_param = 'eb_guests';
|
||||
$eagle_booking_adults_param = 'eb_adults';
|
||||
$eagle_booking_children_param = 'eb_children';
|
||||
|
||||
} elseif ( eb_get_option('booking_type') == 'custom' ) {
|
||||
|
||||
$eagle_booking_action = eb_get_option('booking_type_custom_action');
|
||||
$eagle_booking_action_method = 'GET';
|
||||
$eagle_booking_hotel_id_param = eb_get_option('booking_type_custom_hotel_id_param');
|
||||
$eagle_booking_hotel_id = eb_get_option('booking_type_custom_hotel_id');
|
||||
$eagle_booking_additional_param = eb_get_option('booking_type_custom_additional_param');
|
||||
$eagle_booking_additional_id = eb_get_option('booking_type_custom_additional_id');
|
||||
$eagle_booking_room_param = eb_get_option('booking_type_custom_room_param');
|
||||
$eagle_booking_checkin_param = eb_get_option('booking_type_custom_checkin_param');
|
||||
$eagle_booking_checkout_param = eb_get_option('booking_type_custom_checkout_param');
|
||||
$eagle_booking_guests_param = eb_get_option('booking_type_custom_guests_param');
|
||||
$eagle_booking_adults_param = eb_get_option('booking_type_custom_adults_param');
|
||||
$eagle_booking_children_param = eb_get_option('booking_type_custom_children_param');
|
||||
|
||||
} elseif ( eb_get_option('booking_type') == 'booking' ) {
|
||||
$eagle_booking_action = eb_get_option('booking_type_booking_action').'#hp_availability_style_changes';
|
||||
$eagle_booking_action_method = 'GET';
|
||||
$eagle_booking_checkin_param = 'checkin';
|
||||
$eagle_booking_checkout_param = 'checkout';
|
||||
$eagle_booking_guests_param = 'group_adults';
|
||||
$eagle_booking_adults_param = 'group_adults';
|
||||
$eagle_booking_children_param = 'group_children';
|
||||
|
||||
} elseif ( eb_get_option('booking_type') == 'airbnb' ) {
|
||||
$eagle_booking_action = eb_get_option('booking_type_airbnb_action');
|
||||
$eagle_booking_action_method = 'GET';
|
||||
$eagle_booking_checkin_param = 'check_in';
|
||||
$eagle_booking_checkout_param = 'check_out';
|
||||
$eagle_booking_guests_param = 'guests';
|
||||
$eagle_booking_adults_param = 'adults';
|
||||
$eagle_booking_children_param = 'children';
|
||||
|
||||
} elseif ( eb_get_option('booking_type') == 'tripadvisor' ) {
|
||||
$eagle_booking_action = eb_get_option('booking_type_tripadvisor_action');
|
||||
$eagle_booking_action_method = 'GET';
|
||||
$eagle_booking_checkin_param = 'checkin';
|
||||
$eagle_booking_checkout_param = 'checkout';
|
||||
$eagle_booking_guests_param = 'group_adults';
|
||||
$eagle_booking_adults_param = 'adults';
|
||||
$eagle_booking_children_param = 'children';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Eagle Booking / Calendar Availability
|
||||
* Author: Eagle Themes (Jomin Muskaj)
|
||||
* Since: 1.1.5
|
||||
* Modified: 1.3.3.8
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
function eb_availability_calendar($eb_room_id, $eb_checkin, $eb_checkout) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
/**
|
||||
* Room ID based on used multi-language plugin (WPML or Polylang)
|
||||
*/
|
||||
if ( function_exists('wpml_loaded') ) {
|
||||
|
||||
$eb_room_id = apply_filters('wpml_object_id', $eb_room_id, 'eagle_rooms', true, apply_filters('wpml_default_language', NULL ));
|
||||
|
||||
} elseif ( function_exists('pll_the_languages') ) {
|
||||
|
||||
$eb_room_id = pll_get_post( $eb_room_id, pll_default_language() );
|
||||
|
||||
} else {
|
||||
|
||||
$eb_room_id = $eb_room_id ;
|
||||
|
||||
}
|
||||
|
||||
// Get Room Exceptions
|
||||
$eagle_booking_exceptions_array = get_post_meta($eb_room_id, 'eagle_booking_mtb_room_block_exceptions', true);
|
||||
|
||||
// Room Quantity
|
||||
$eagle_booking_meta_box_qnt = get_post_meta($eb_room_id, 'eagle_booking_mtb_room_quantity', true);
|
||||
if (empty($eagle_booking_meta_box_qnt)) {
|
||||
$eagle_booking_meta_box_qnt = 1;
|
||||
}
|
||||
|
||||
// Set the check circle
|
||||
$eagle_booking_check_start_date_format = DateTime::createFromFormat("Y/m/d", $eb_checkin)->format('m/d/Y');
|
||||
$eagle_booking_check_end_date_format = DateTime::createFromFormat("Y/m/d", $eb_checkout)->format('m/d/Y');
|
||||
$eagle_booking_check_circle = eb_total_booking_nights($eagle_booking_check_start_date_format, $eagle_booking_check_end_date_format);
|
||||
|
||||
// DB Query
|
||||
$eagle_booking_booked_dates = $wpdb->get_results("SELECT date_from, date_to FROM ".EAGLE_BOOKING_TABLE." WHERE id_post = $eb_room_id AND (paypal_payment_status = 'Completed' OR paypal_payment_status = 'Pending Payment') ");
|
||||
|
||||
$eagle_booking_avaiability_string = '';
|
||||
|
||||
if ($eagle_booking_booked_dates) {
|
||||
|
||||
foreach ($eagle_booking_booked_dates as $eagle_booking_booked_date) {
|
||||
|
||||
// Checked Checkin
|
||||
$eagle_booking_check_start_date = DateTime::createFromFormat("Y/m/d", $eb_checkin)->format('Y/m/d');
|
||||
|
||||
// Booked Checkin & Checkout
|
||||
$eagle_booking_booked_checkin = $eagle_booking_booked_date->date_from;
|
||||
$eagle_booking_booked_checkout = $eagle_booking_booked_date->date_to;
|
||||
|
||||
// Set the booked circle
|
||||
$eagle_booking_booked_circle = eb_total_booking_nights($eagle_booking_booked_checkin, $eagle_booking_booked_checkout);
|
||||
|
||||
// Start loop the sheck dates
|
||||
for ($eagle_booking_i_1 = 1; $eagle_booking_i_1 <= $eagle_booking_check_circle; $eagle_booking_i_1++) {
|
||||
|
||||
$eagle_booking_booked_start_date = DateTime::createFromFormat("m/d/Y", $eagle_booking_booked_checkin)->format('Y/m/d');
|
||||
|
||||
// Start Check the booked date
|
||||
for ($eagle_booking_i_2 = 1; $eagle_booking_i_2 <= $eagle_booking_booked_circle; $eagle_booking_i_2++) {
|
||||
|
||||
if ($eagle_booking_check_start_date == $eagle_booking_booked_start_date) {
|
||||
|
||||
$eagle_booking_avaiability_string .= $eagle_booking_booked_start_date . '-';
|
||||
|
||||
}
|
||||
|
||||
// Add 1 day to check the next booked date
|
||||
$eagle_booking_booked_start_date = date('Y/m/d', strtotime($eagle_booking_booked_start_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
// Add 1 day to check the next check date
|
||||
$eagle_booking_check_start_date = date('Y/m/d', strtotime($eagle_booking_check_start_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$eagle_booking_avaiability_count = $eagle_booking_avaiability_string;
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_avaiability_count = '';
|
||||
|
||||
}
|
||||
|
||||
$booked_dates = [];
|
||||
|
||||
// Check the Room Quantity
|
||||
$eagle_booking_quantity_availability = $eb_checkin;
|
||||
|
||||
for ($eagle_booking_i = 1; $eagle_booking_i <= $eagle_booking_check_circle; $eagle_booking_i++) {
|
||||
|
||||
$eagle_booking_num_reservations_per_day = substr_count($eagle_booking_avaiability_count, $eagle_booking_quantity_availability);
|
||||
|
||||
if ($eagle_booking_num_reservations_per_day >= $eagle_booking_meta_box_qnt) {
|
||||
|
||||
$booked_dates[] = $eagle_booking_quantity_availability;
|
||||
}
|
||||
|
||||
$eagle_booking_quantity_availability = date('Y/m/d', strtotime($eagle_booking_quantity_availability . ' + 1 days'));
|
||||
}
|
||||
|
||||
// Check the Room Blocks
|
||||
if (!empty($eagle_booking_exceptions_array)) {
|
||||
|
||||
for ($eagle_booking_exceptions_array_i = 0; $eagle_booking_exceptions_array_i < count($eagle_booking_exceptions_array); $eagle_booking_exceptions_array_i++) {
|
||||
|
||||
// Get exception path
|
||||
$eagle_booking_page_by_path = get_post($eagle_booking_exceptions_array[$eagle_booking_exceptions_array_i], OBJECT, 'eagle_exceptions');
|
||||
|
||||
// Exceptions MTB
|
||||
$eagle_booking_exception_id = $eagle_booking_page_by_path->ID;
|
||||
$eagle_booking_exception_name = get_the_title($eagle_booking_exception_id);
|
||||
$eagle_booking_mtb_exception_date_from = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_date_from', true);
|
||||
$eagle_booking_mtb_exception_date_to = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_date_to', true);
|
||||
// $eagle_booking_mbt_exception_repeat = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_repeat', true);
|
||||
|
||||
// Check if the exception still exists (in case it get deleted without updating the room)
|
||||
if ( !empty( $eagle_booking_mtb_exception_date_from ) && !empty( $eagle_booking_mtb_exception_date_to ) ) {
|
||||
|
||||
// Get the total blocked booking nights
|
||||
$eagle_booking_blocked_booking_nights = eb_total_booking_nights($eagle_booking_mtb_exception_date_from, $eagle_booking_mtb_exception_date_to);
|
||||
|
||||
// Format Exception Dates
|
||||
$eagle_booking_new_date_from_ex_format = DateTime::createFromFormat("m/d/Y", $eagle_booking_mtb_exception_date_from)->format('Y/m/d');
|
||||
$eagle_booking_new_date_to_ex_format = DateTime::createFromFormat("m/d/Y", $eagle_booking_mtb_exception_date_to)->format('Y/m/d');
|
||||
|
||||
// Set the check circle
|
||||
$eagle_booking_checked_date = DateTime::createFromFormat("Y/m/d", $eb_checkin)->format('m/d/Y');
|
||||
|
||||
//Bug: Further investigation needed (it check checkin + 1)
|
||||
$eagle_booking_checked_date = date('m/d/Y', strtotime($eagle_booking_checked_date . ' - 1 days'));
|
||||
|
||||
for ($eagle_booking_i_1 = 0; $eagle_booking_i_1 <= $eagle_booking_check_circle; $eagle_booking_i_1++) {
|
||||
|
||||
$eagle_booking_blocked_date = $eagle_booking_new_date_from_ex_format;
|
||||
|
||||
for ($eagle_booking_i_2 = 0; $eagle_booking_i_2 <= $eagle_booking_blocked_booking_nights; $eagle_booking_i_2++) {
|
||||
|
||||
|
||||
if ($eagle_booking_checked_date == $eagle_booking_blocked_date) {
|
||||
|
||||
$booked_dates[] = $eagle_booking_checked_date;
|
||||
|
||||
}
|
||||
|
||||
$eagle_booking_blocked_date = date('Y/m/d', strtotime($eagle_booking_blocked_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
$eagle_booking_checked_date = date('Y/m/d', strtotime($eagle_booking_checked_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return the booked & blocked dates (remove the first date to allow it as a checkout date of the previous booking: further instigation needed)
|
||||
return array_slice($booked_dates, 0);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Eagle Booking / Dates Exceptions
|
||||
* Author: Eagle Themes
|
||||
* Since: 1.0.4
|
||||
* Modified: 1.2.4.5
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
function eb_room_is_available_block($eb_room_id, $eb_checkin, $eb_checkout) {
|
||||
|
||||
if ( $eb_checkin && $eb_checkout ) {
|
||||
|
||||
// Get Room Exceptions
|
||||
$eb_exceptions_array = get_post_meta($eb_room_id, 'eagle_booking_mtb_room_block_exceptions', true);
|
||||
|
||||
// Set the check circle
|
||||
$eb_check_start_date_format = DateTime::createFromFormat("m/d/Y", $eb_checkin)->format('m/d/Y');
|
||||
$eb_check_end_date_format = DateTime::createFromFormat("m/d/Y", $eb_checkout)->format('m/d/Y');
|
||||
$eb_check_circle = eb_total_booking_nights($eb_check_start_date_format, $eb_check_end_date_format);
|
||||
|
||||
// Initialize
|
||||
$eb_is_available_block = true;
|
||||
|
||||
// Check the Room Blocks
|
||||
if (!empty($eb_exceptions_array)) {
|
||||
|
||||
for ($eb_exceptions_array_i = 0; $eb_exceptions_array_i < count($eb_exceptions_array); $eb_exceptions_array_i++) {
|
||||
|
||||
// Get exception path
|
||||
$eb_page_by_path = get_post($eb_exceptions_array[$eb_exceptions_array_i], OBJECT, 'eagle_exceptions');
|
||||
|
||||
if ( $eb_page_by_path ) {
|
||||
|
||||
// Exceptions MTB
|
||||
$eb_exception_id = $eb_page_by_path->ID;
|
||||
|
||||
$eb_exception_name = get_the_title($eb_exception_id);
|
||||
$eb_mtb_exception_date_from = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_date_from', true);
|
||||
$eb_mtb_exception_date_to = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_date_to', true);
|
||||
//$eb_mbt_exception_repeat = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_repeat', true);
|
||||
|
||||
// Check if the exception still exists (in case it get deleted without updating the room)
|
||||
if ( !empty( $eb_mtb_exception_date_from ) && !empty( $eb_mtb_exception_date_to ) ) {
|
||||
|
||||
// Get the total blocked booking nights
|
||||
$eb_blocked_booking_nights = eb_total_booking_nights($eb_mtb_exception_date_from, $eb_mtb_exception_date_to);
|
||||
|
||||
// Format Exception Dates
|
||||
$eb_new_date_from_ex_format = DateTime::createFromFormat("m/d/Y", $eb_mtb_exception_date_from)->format('Y/m/d');
|
||||
$eb_new_date_to_ex_format = DateTime::createFromFormat("m/d/Y", $eb_mtb_exception_date_to)->format('Y/m/d');
|
||||
|
||||
// Set the check circle
|
||||
$eb_checked_date = DateTime::createFromFormat("m/d/Y", $eb_checkin)->format('m/d/Y');
|
||||
|
||||
|
||||
//Bug: Further investigation needed (it check checkin + 1)
|
||||
$eb_checked_date = date('m/d/Y', strtotime($eb_checked_date . ' - 1 days'));
|
||||
|
||||
for ($eb_i_1 = 0; $eb_i_1 <= $eb_check_circle; $eb_i_1++) {
|
||||
|
||||
|
||||
$eb_blocked_date = $eb_new_date_from_ex_format;
|
||||
|
||||
for ($eb_i_2 = 0; $eb_i_2 <= $eb_blocked_booking_nights; $eb_i_2++) {
|
||||
|
||||
|
||||
if ($eb_checked_date == $eb_blocked_date) {
|
||||
|
||||
// echo $eb_checked_date .' = '. $eb_blocked_date;
|
||||
$eb_is_available_block = false;
|
||||
|
||||
}
|
||||
|
||||
$eb_blocked_date = date('Y/m/d', strtotime($eb_blocked_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
$eb_checked_date = date('Y/m/d', strtotime($eb_checked_date . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $eb_is_available_block;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Insert booking into the db
|
||||
* @since 1.0.0
|
||||
* modified 1.3.3
|
||||
---------------------------------------------------------------------------*/
|
||||
function eb_insert_booking_into_db(
|
||||
|
||||
$eb_room_id,
|
||||
$eb_room_title,
|
||||
$eb_date,
|
||||
$eb_checkin,
|
||||
$eb_checkout,
|
||||
$eb_guests,
|
||||
$eb_adults,
|
||||
$eb_children,
|
||||
$eb_room_price,
|
||||
$eb_final_trip_price,
|
||||
$eb_deposit_amount,
|
||||
$eb_extra_services,
|
||||
$eb_user_id,
|
||||
$eb_user_first_name,
|
||||
$eb_user_last_name,
|
||||
$eb_user_email,
|
||||
$eb_user_ip,
|
||||
$eb_user_phone,
|
||||
$eb_user_address,
|
||||
$eb_user_city,
|
||||
$eb_user_country,
|
||||
$eb_user_message,
|
||||
$eb_user_arrival,
|
||||
$eb_user_coupon,
|
||||
$eb_payment_status,
|
||||
$eb_payment_currency,
|
||||
$eb_transaction_id,
|
||||
$eb_action_type,
|
||||
$eb_source
|
||||
|
||||
) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Tables
|
||||
$eb_main_table = $wpdb->prefix . 'eagle_booking';
|
||||
$eb_meta_table = $wpdb->prefix . 'eagle_booking_meta';
|
||||
|
||||
/**
|
||||
* Insert Booking Details into the Eagle Booking Main Table
|
||||
*/
|
||||
$eb_insert_booking_into_db = $wpdb->insert(
|
||||
|
||||
$eb_main_table,
|
||||
|
||||
array(
|
||||
'id_post' => $eb_room_id,
|
||||
'title_post' => $eb_room_title,
|
||||
'date' => $eb_date,
|
||||
'date_from' => $eb_checkin,
|
||||
'date_to' => $eb_checkout,
|
||||
'guests' => $eb_guests,
|
||||
'adults' => $eb_adults,
|
||||
'children' => $eb_children,
|
||||
'final_trip_price' => $eb_final_trip_price,
|
||||
'deposit_amount' => $eb_deposit_amount,
|
||||
'extra_services' => $eb_extra_services,
|
||||
'id_user' => $eb_user_id,
|
||||
'user_first_name' => $eb_user_first_name,
|
||||
'user_last_name' => $eb_user_last_name,
|
||||
'paypal_email' => $eb_user_email,
|
||||
'user_ip' => $eb_user_ip,
|
||||
'user_phone' => $eb_user_phone,
|
||||
'user_address' => $eb_user_address,
|
||||
'user_city' => $eb_user_city,
|
||||
'user_country' => $eb_user_country,
|
||||
'user_message' => $eb_user_message,
|
||||
'user_arrival' => $eb_user_arrival,
|
||||
'user_coupon' => $eb_user_coupon,
|
||||
'paypal_payment_status' => $eb_payment_status,
|
||||
'paypal_currency' => $eb_payment_currency,
|
||||
'paypal_tx' => $eb_transaction_id,
|
||||
'action_type' => $eb_action_type,
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
global $eb_booking_id;
|
||||
|
||||
/**
|
||||
* Insert Booking Details into the Eagle Booking Meta Table
|
||||
*/
|
||||
$eb_booking_id = $wpdb->insert_id;
|
||||
$eb_taxes = eb_room_taxes( $eb_room_id );
|
||||
$eb_fees = eb_room_fees( $eb_room_id );
|
||||
|
||||
// Insert Room Taxes
|
||||
if ( $eb_taxes ) foreach( $eb_taxes as $key => $tax ) {
|
||||
|
||||
$entry_id = $tax;
|
||||
|
||||
$eb_insert_booking_into_db = $wpdb->insert(
|
||||
|
||||
$eb_meta_table,
|
||||
array(
|
||||
'booking_id' => $eb_booking_id,
|
||||
'meta_key' => 'tax',
|
||||
'meta_value' => $entry_id,
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Insert Room Fees into the Eagle Booking Meta Table
|
||||
if ( $eb_fees ) foreach( $eb_fees as $key => $fee ) {
|
||||
|
||||
$entry_id = $fee[0];
|
||||
|
||||
$eb_insert_booking_into_db = $wpdb->insert(
|
||||
|
||||
$eb_meta_table,
|
||||
array(
|
||||
'booking_id' => $eb_booking_id,
|
||||
'meta_key' => 'fee',
|
||||
'meta_value' => $entry_id,
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Insert Room Price Without Taxes/Fees into the Eagle Booking Meta Table
|
||||
if ( $eb_room_price ) {
|
||||
|
||||
$eb_insert_booking_into_db = $wpdb->insert(
|
||||
|
||||
$eb_meta_table,
|
||||
array(
|
||||
'booking_id' => $eb_booking_id,
|
||||
'meta_key' => 'room_price',
|
||||
'meta_value' => $eb_room_price,
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
// Insert Booking Source into the Eagle Booking Meta Table [1.3.3.8.2]
|
||||
if ( $eb_source ) {
|
||||
|
||||
$eb_insert_booking_into_db = $wpdb->insert(
|
||||
|
||||
$eb_meta_table,
|
||||
array(
|
||||
'booking_id' => $eb_booking_id,
|
||||
'meta_key' => 'booking_source',
|
||||
'meta_value' => $eb_source,
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
// Add booking into DB
|
||||
if ($eb_insert_booking_into_db) {
|
||||
do_action(
|
||||
'eb_insert_booking_in_db',
|
||||
$eb_room_id,
|
||||
$eb_room_title,
|
||||
$eb_date,
|
||||
$eb_checkin,
|
||||
$eb_checkout,
|
||||
$eb_guests,
|
||||
$eb_adults,
|
||||
$eb_children,
|
||||
$eb_final_trip_price,
|
||||
$eb_deposit_amount,
|
||||
$eb_extra_services,
|
||||
$eb_user_id,
|
||||
$eb_user_first_name,
|
||||
$eb_user_last_name,
|
||||
$eb_user_email,
|
||||
$eb_user_ip,
|
||||
$eb_user_phone,
|
||||
$eb_user_address,
|
||||
$eb_user_city,
|
||||
$eb_user_country,
|
||||
$eb_user_message,
|
||||
$eb_user_arrival,
|
||||
$eb_user_coupon,
|
||||
$eb_payment_status,
|
||||
$eb_payment_currency,
|
||||
$eb_transaction_id,
|
||||
$eb_action_type
|
||||
);
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
// $postarr['ID'] = $post->$eb_room_id;
|
||||
// $postarr['post_modified'] = $post->post_modified;
|
||||
|
||||
// // update default post
|
||||
// wp_update_post($postarr);
|
||||
|
||||
// $data = array();
|
||||
|
||||
// $post = array(
|
||||
// 'ID' => $eb_room_id,
|
||||
// 'post_status' => 'publish',
|
||||
// 'edit_date' => true // what is edit_date?
|
||||
// );
|
||||
|
||||
// $result = wp_update_post( $post, true );
|
||||
// if ( $result && ! is_wp_error( $result ) ) {
|
||||
// $data[] = $post_id;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// Add a debug option in the plugin settings
|
||||
|
||||
// // Debug
|
||||
// $wpdb->print_error();
|
||||
// $wpdb->show_errors();
|
||||
//
|
||||
//
|
||||
|
||||
// echo $wpdb->last_query;
|
||||
// echo $wpdb->last_error;
|
||||
|
||||
// foreach ( $wpdb->get_col( "DESC " . $eb_main_table, 0 ) as $column_name ) {
|
||||
// echo $column_name;
|
||||
// echo "<br/>";
|
||||
// }
|
||||
|
||||
// if($wpdb->get_var("SHOW TABLES LIKE '$eb_main_table'") != $eb_main_table) {
|
||||
// echo "Table Doesn't Exist";
|
||||
// }
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Get final price
|
||||
* @ since 1.0.0
|
||||
* @ modified 1.3.3
|
||||
* return room total price (without taxes, fees, additional services)
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
function eb_room_total_price($room_id, $dates) {
|
||||
|
||||
// Initialize
|
||||
$room_total_price = '';
|
||||
|
||||
// Date Format
|
||||
$eagle_booking_new_date = new DateTime($dates);
|
||||
|
||||
$eagle_booking_new_date_format_n = date_format($eagle_booking_new_date, 'N');
|
||||
|
||||
// Rooms Price
|
||||
$room_price = get_post_meta($room_id, 'eagle_booking_mtb_room_price', true);
|
||||
|
||||
// Room Week Price
|
||||
$room_price_mon = get_post_meta($room_id, 'eagle_booking_mtb_room_price_mon', true);
|
||||
$room_price_tue = get_post_meta($room_id, 'eagle_booking_mtb_room_price_tue', true);
|
||||
$room_price_wed = get_post_meta($room_id, 'eagle_booking_mtb_room_price_wed', true);
|
||||
$room_price_thu = get_post_meta($room_id, 'eagle_booking_mtb_room_price_thu', true);
|
||||
$room_price_fri = get_post_meta($room_id, 'eagle_booking_mtb_room_price_fri', true);
|
||||
$room_price_sat = get_post_meta($room_id, 'eagle_booking_mtb_room_price_sat', true);
|
||||
$room_price_sun = get_post_meta($room_id, 'eagle_booking_mtb_room_price_sun', true);
|
||||
|
||||
$room_price_week = array($room_price_mon, $room_price_tue, $room_price_wed, $room_price_thu, $room_price_fri, $room_price_sat, $room_price_sun);
|
||||
|
||||
/**
|
||||
* Check Room Exceptions
|
||||
*/
|
||||
$room_price_exceptions = get_post_meta($room_id, 'eagle_booking_mtb_room_price_exceptions', true);
|
||||
|
||||
if (!empty($room_price_exceptions)) {
|
||||
|
||||
for ($eagle_booking_exceptions_array_i = 0; $eagle_booking_exceptions_array_i < count($room_price_exceptions); $eagle_booking_exceptions_array_i++) {
|
||||
|
||||
$eagle_booking_page_by_path = get_post($room_price_exceptions[$eagle_booking_exceptions_array_i], OBJECT, 'eagle_exceptions');
|
||||
$eagle_booking_exception_id = $eagle_booking_page_by_path->ID;
|
||||
|
||||
// EXCEPTION MTB
|
||||
$eagle_booking_mbt_exception_type = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_type', true);
|
||||
if (empty($eagle_booking_mbt_exception_type)) {
|
||||
$eagle_booking_mbt_exception_type = 'price';
|
||||
}
|
||||
|
||||
$eagle_booking_mtb_exception_price = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_price', true);
|
||||
$eagle_booking_mtb_exception_date_from = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_date_from', true);
|
||||
$eagle_booking_mtb_exception_date_to = get_post_meta($eagle_booking_exception_id, 'eagle_booking_mtb_exception_date_to', true);
|
||||
|
||||
// DATE FORMAT
|
||||
$eagle_booking_new_date_from = new DateTime($eagle_booking_mtb_exception_date_from);
|
||||
$eagle_booking_new_date_from_format = date_format($eagle_booking_new_date_from, 'm/d');
|
||||
$eagle_booking_new_date_to = new DateTime($eagle_booking_mtb_exception_date_to);
|
||||
$eagle_booking_new_date_to = date_modify($eagle_booking_new_date_to, '-1 day');
|
||||
$eagle_booking_new_date_to_format = date_format($eagle_booking_new_date_to, 'm/d');
|
||||
$eagle_booking_date_new = new DateTime($dates);
|
||||
$eagle_booking_date_new_format = date_format($eagle_booking_date_new, 'm/d');
|
||||
|
||||
if ($eagle_booking_date_new_format >= $eagle_booking_new_date_from_format && $eagle_booking_date_new_format <= $eagle_booking_new_date_to_format and $eagle_booking_mbt_exception_type == 'price') {
|
||||
|
||||
$room_total_price = $eagle_booking_mtb_exception_price;
|
||||
|
||||
return $room_total_price;
|
||||
|
||||
} else {
|
||||
|
||||
if ($room_price_week[$eagle_booking_new_date_format_n - 1] != '') {
|
||||
|
||||
$room_total_price = $room_price_week[$eagle_booking_new_date_format_n - 1];
|
||||
|
||||
} else {
|
||||
|
||||
$room_total_price = $room_price;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $room_total_price;
|
||||
|
||||
} else {
|
||||
|
||||
if ($room_price_week[$eagle_booking_new_date_format_n - 1] != '') {
|
||||
|
||||
$room_total_price = $room_price_week[$eagle_booking_new_date_format_n - 1];
|
||||
|
||||
} else {
|
||||
|
||||
$room_total_price = $room_price;
|
||||
|
||||
}
|
||||
|
||||
return $room_total_price;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
* Check room date availability
|
||||
* Return Room Available Dates (String)
|
||||
* @since 1.0.0
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
function eb_room_availability($eb_room_id, $eagle_booking_checkin, $eagle_booking_checkout) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// DB Query
|
||||
$eagle_booking_booked_dates = $wpdb->get_results("SELECT date_from, date_to FROM ".EAGLE_BOOKING_TABLE." WHERE id_post = $eb_room_id AND (paypal_payment_status = 'Completed' OR paypal_payment_status = 'Pending Payment') ");
|
||||
|
||||
// Checked Period
|
||||
$eagle_booking_checked_period = eb_total_booking_nights($eagle_booking_checkin, $eagle_booking_checkout);
|
||||
|
||||
$eagle_booking_room_available_dates = '';
|
||||
|
||||
if (!empty($eagle_booking_booked_dates)) {
|
||||
|
||||
foreach ($eagle_booking_booked_dates as $eagle_booking_booked_date) {
|
||||
|
||||
// Checked Checkin
|
||||
$eagle_booking_checked_checkin = DateTime::createFromFormat("m/d/Y", $eagle_booking_checkin)->format('Y/m/d');
|
||||
|
||||
// Booked Checkin & Checkout
|
||||
$eagle_booking_booked_checkin = $eagle_booking_booked_date->date_from;
|
||||
$eagle_booking_booked_checkout = $eagle_booking_booked_date->date_to;
|
||||
|
||||
// Booked Period
|
||||
$eagle_booking_booked_period = eb_total_booking_nights($eagle_booking_booked_checkin, $eagle_booking_booked_checkout);
|
||||
|
||||
// Start Checked Period
|
||||
for ($eagle_booking_checked_period_count = 1; $eagle_booking_checked_period_count <= $eagle_booking_checked_period; $eagle_booking_checked_period_count++) {
|
||||
|
||||
$eagle_booking_booked_checkin_new = DateTime::createFromFormat("m/d/Y", $eagle_booking_booked_checkin)->format('Y/m/d');
|
||||
|
||||
// Start Booked Period
|
||||
for ($eagle_booking_booked_period_count = 1; $eagle_booking_booked_period_count <= $eagle_booking_booked_period; $eagle_booking_booked_period_count++) {
|
||||
|
||||
if ($eagle_booking_checked_checkin == $eagle_booking_booked_checkin_new) {
|
||||
$eagle_booking_room_available_dates .= $eagle_booking_checked_checkin . '-';
|
||||
}
|
||||
|
||||
$eagle_booking_booked_checkin_new = date('Y/m/d', strtotime($eagle_booking_booked_checkin_new . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
$eagle_booking_checked_checkin = date('Y/m/d', strtotime($eagle_booking_checked_checkin . ' + 1 days'));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $eagle_booking_room_available_dates;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/* --------------------------------------------------------------------------
|
||||
* Package: Room Price / Eagle Booking Core
|
||||
* Since 1.2.2
|
||||
* Modified: 1.3.3
|
||||
^ Author: Eagle Themes (Jomin Muskaj)
|
||||
---------------------------------------------------------------------------*/
|
||||
if ( ! function_exists( 'eb_room_price' ) ) {
|
||||
|
||||
function eb_room_price( $eb_room_id, $eb_room_per_night_text ) {
|
||||
|
||||
if( eagle_booking_room_min_price( $eb_room_id ) && eb_get_option('show_price') == true && eb_get_option('eb_show_room_price') == true ) {
|
||||
|
||||
$eb_text_before_price = eb_get_option('eagle_booking_before_price');
|
||||
$room_price = eagle_booking_room_min_price( $eb_room_id );
|
||||
|
||||
/**
|
||||
* Add Taxes to Room Normal Price
|
||||
*/
|
||||
$eb_taxes = get_option('eb_taxes');
|
||||
$eb_room_taxes = get_post_meta( $eb_room_id, 'eagle_booking_mtb_room_taxes', true );
|
||||
|
||||
if ( empty( $eb_room_taxes ) ) $eb_room_taxes = array();
|
||||
|
||||
if ( $eb_taxes && eb_get_option('price_taxes') === 'including' ) {
|
||||
|
||||
$eb_tax_price = 0;
|
||||
$entry_id = '';
|
||||
|
||||
foreach( $eb_taxes as $key => $item ) {
|
||||
|
||||
$entry_id = !empty( $item["id"] ) ? $item["id"] : '';
|
||||
$global = !empty( $item["global"] ) ? $item["global"] : '';
|
||||
$amount = !empty( $item["amount"] ) ? $item["amount"] : '';
|
||||
|
||||
// Lets check if the tax is global or if is asigned to the room and if tax is aplied on services
|
||||
if ( ( $global == true || in_array( $entry_id, $eb_room_taxes) ) ) {
|
||||
|
||||
$eb_tax_price += $amount;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add the tax price to the normal price
|
||||
$room_price = $room_price + $eb_tax_price * $room_price / 100;
|
||||
|
||||
} else {
|
||||
|
||||
$room_price = $room_price;
|
||||
|
||||
}
|
||||
|
||||
$eb_room_price = '<span class="normal-price"><strong>'.eb_price( $room_price ).'</strong></span>';
|
||||
|
||||
if ( $eb_text_before_price != '' ) {
|
||||
|
||||
$eb_room_text = '<span class="text-before-price">'.$eb_text_before_price.'</span>'.' ';
|
||||
|
||||
} else {
|
||||
|
||||
$eb_room_text = '';
|
||||
|
||||
}
|
||||
|
||||
echo '<div class="room-price">';
|
||||
echo $eb_room_text.$eb_room_price;
|
||||
echo '<span class="per-night-text">'.' ' .$eb_room_per_night_text. '</span>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* 2Checkout Payment Gateway
|
||||
* Author Eagle Themes (Jomin Muskaj)
|
||||
* Package Eagle Booking
|
||||
* Version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( isset($_GET['sid']) ) :
|
||||
|
||||
// Data
|
||||
$eagle_booking_form_date_from = $_GET['eagle_booking_checkout_form_date_from'];
|
||||
$eagle_booking_form_date_to = $_GET['eagle_booking_checkout_form_date_to'];
|
||||
$eagle_booking_form_guests = $_GET['eagle_booking_checkout_form_guests'];
|
||||
$eagle_booking_form_adults = $_GET['eagle_booking_checkout_form_adults'];
|
||||
$eagle_booking_form_children = $_GET['eagle_booking_checkout_form_children'];
|
||||
|
||||
$eb_room_price = $_GET['eb_room_price'];
|
||||
|
||||
$eagle_booking_form_final_price = $_GET['eagle_booking_checkout_form_final_price'];
|
||||
$eagle_booking_deposit_amount = $_GET['eagle_booking_deposit_amount'];
|
||||
$eagle_booking_room_id = $_GET['eagle_booking_room_id'];
|
||||
$eagle_booking_room_title = $_GET['eagle_booking_room_title'];
|
||||
$eagle_booking_form_name = $_GET['eagle_booking_checkout_form_name'];
|
||||
$eagle_booking_form_surname = $_GET['eagle_booking_checkout_form_surname'];
|
||||
$eagle_booking_form_email = $_GET['eagle_booking_checkout_form_email'];
|
||||
$eagle_booking_form_phone = $_GET['eagle_booking_checkout_form_phone'];
|
||||
$eagle_booking_form_address = $_GET['eagle_booking_checkout_form_address'];
|
||||
$eagle_booking_form_city = $_GET['eagle_booking_checkout_form_city'];
|
||||
$eagle_booking_form_country = $_GET['eagle_booking_checkout_form_country'];
|
||||
$eagle_booking_form_zip = $_GET['eagle_booking_checkout_form_zip'];
|
||||
$eagle_booking_form_requests = $_GET['eagle_booking_checkout_form_requets'];
|
||||
$eagle_booking_form_arrival = $_GET['eagle_booking_checkout_form_arrival'];
|
||||
$eagle_booking_form_coupon = $_GET['eagle_booking_form_coupon'];
|
||||
$eagle_booking_form_services = $_GET['eagle_booking_form_services'];
|
||||
$eagle_booking_form_action_type = $_GET['eagle_booking_form_action_type'];
|
||||
$eagle_booking_form_payment_status = $_GET['eagle_booking_form_payment_status'];
|
||||
|
||||
|
||||
// Defaults
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
|
||||
$hashSecretWord = eb_get_option('eagle_booking_2checkout_secret_word'); // 2Checkout Secret Word
|
||||
$hashSid = eb_get_option('eagle_booking_2checkout_account_number'); // 2Checkout account number
|
||||
|
||||
// 2Ceckout Mode
|
||||
if ($_REQUEST['demo'] == 'Y') {
|
||||
$order_number = 1;
|
||||
} else {
|
||||
$order_number = $_REQUEST['order_number'];
|
||||
}
|
||||
|
||||
// Transaction ID
|
||||
$eagle_booking_transaction_id = $order_number;
|
||||
|
||||
// Status
|
||||
$compare_string = $hashSecretWord . $hashSid . $order_number . $_REQUEST['total'];
|
||||
$compare_hash1 = strtoupper(md5($compare_string));
|
||||
$compare_hash2 = $_REQUEST['key'];
|
||||
|
||||
if ($compare_hash1 == $compare_hash2) {
|
||||
|
||||
$eagle_booking_form_payment_status = 'Completed';
|
||||
$eagle_booking_payment_completed = true;
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['2checkout'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_2checkout_tab">
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('eagle_booking_2checkout_mssg')) ?></p>
|
||||
|
||||
<?php eb_get_option('eagle_booking_2checkout_sandbox_mode') == true ? $eb_demo_mode = 'Y' : $eb_demo_mode = ''; ?>
|
||||
|
||||
<form accept-charset="UTF-8" action="https://www.2checkout.com/checkout/purchase" id="2checkout" method="post">
|
||||
|
||||
<!-- Booking Details -->
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="2checkout">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_from" value="<?php echo $eagle_booking_form_date_from ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_to" value="<?php echo $eagle_booking_form_date_to ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_guests" value="<?php echo $eagle_booking_form_guests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_adults" value="<?php echo $eagle_booking_form_adults ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_children" value="<?php echo $eagle_booking_form_children ?>">
|
||||
|
||||
<input type="hidden" name="eb_room_price" value="<?php echo $eb_room_price ?>">
|
||||
|
||||
<input type="hidden" name="eagle_booking_checkout_form_final_price" value="<?php echo $eagle_booking_form_final_price ?>">
|
||||
<input type="hidden" name="eagle_booking_deposit_amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="eagle_booking_room_id" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="eagle_booking_room_title" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_name" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_surname" value="<?php echo $eagle_booking_form_surname ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_phone" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_address" value="<?php echo $eagle_booking_form_address ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_city" value="<?php echo $eagle_booking_form_city ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_country" value="<?php echo $eagle_booking_form_country ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_zip" value="<?php echo $eagle_booking_form_zip ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_requets" value="<?php echo $eagle_booking_form_requests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_arrival" value="<?php echo $eagle_booking_form_arrival ?>">
|
||||
<input type="hidden" name="eagle_booking_form_services" value="<?php echo $eagle_booking_form_services ?>">
|
||||
<input type="hidden" name="eagle_booking_form_coupon" value="<?php echo $eagle_booking_form_coupon ?>">
|
||||
<input type="hidden" name="eagle_booking_form_action_type" value="2checkout">
|
||||
<input type="hidden" name="eagle_booking_form_payment_status" value="Pending Payment">
|
||||
|
||||
<!-- 2Checkout Parameters -->
|
||||
<input id="sid" name="sid" type="hidden" value="<?php echo esc_html(eb_get_option('eagle_booking_2checkout_account_number')) ?>" />
|
||||
<input type='hidden' name='demo' value='<?php echo $eb_demo_mode ?>' />
|
||||
<input id="mode" name="mode" type="hidden" value="2CO" />
|
||||
<input id="merchant_order_id" name="merchant_order_id" type="hidden" value="<?php echo $eagle_booking_room_id ?>" />
|
||||
<input id="li_0_product_id" name="li_0_product_id" type="hidden" value="<?php echo $eagle_booking_room_id ?>" />
|
||||
<input id="li_0_name" name="li_0_name" type="hidden" value="<?php echo $eagle_booking_room_title ?>" />
|
||||
<input id="li_0_price" name="li_0_price" type="hidden" value="<?php echo $eagle_booking_deposit_amount ?>" />
|
||||
<input type='hidden' name='currency_code' value='<?php echo esc_html( eb_get_option('eagle_booking_2checkout_currency') ) ?>' >
|
||||
<input id="card_holder_name" name="card_holder_name" type="hidden" value="<?php echo $eagle_booking_form_name .' '.$eagle_booking_form_surname ?>" />
|
||||
<input id="street_address" name="street_address" type="hidden" value="<?php echo $eagle_booking_form_address ?>" />
|
||||
<input id="city" name="city" type="hidden" value="<?php echo $eagle_booking_form_city ?>" />
|
||||
<input id="zip" name="zip" type="hidden" value="<?php echo $eagle_booking_form_zip ?>" />
|
||||
<input id="country" name="country" type="hidden" value="<?php echo $eagle_booking_form_country ?>" />
|
||||
<input id="email" name="email" type="hidden" value="<?php echo $eagle_booking_form_email ?>" />
|
||||
<input id="phone" name="phone" type="hidden" value="<?php echo $eagle_booking_form_phone ?>" />
|
||||
<input type='hidden' name='x_receipt_link_url' value='<?php echo esc_url( eb_checkout_page() ) ?>' />
|
||||
<button type="submit" class="btn eb-btn btn-2checkout"><?php echo esc_html__('Checkout Now','eagle-booking') ?></button>
|
||||
</form>
|
||||
<script src="https://www.2checkout.com/static/checkout/javascript/direct.min.js"></script>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['2checkout'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_2checkout_tab">
|
||||
<i class="fa fa-credit-card" aria-hidden="true"></i><?php echo esc_html__('Credit Card','eagle-booking') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* Payment On Arrival
|
||||
* author Eagle Themes (Jomin Muskaj)
|
||||
* package Eagle Booking
|
||||
* version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( $eagle_booking_payment_method == 'payment_on_arrive') :
|
||||
|
||||
// PAYPAL VALUES
|
||||
$eagle_booking_transaction_id = rand(100000000,999999999);
|
||||
|
||||
// FORM VALUES
|
||||
$eagle_booking_form_date_from = $_POST['eagle_booking_checkout_form_date_from'];
|
||||
$eagle_booking_form_date_to = $_POST['eagle_booking_checkout_form_date_to'];
|
||||
$eagle_booking_form_guests = $_POST['eagle_booking_checkout_form_guests'];
|
||||
$eagle_booking_form_adults = $_POST['eagle_booking_checkout_form_adults'];
|
||||
$eagle_booking_form_children = $_POST['eagle_booking_checkout_form_children'];
|
||||
|
||||
$eb_room_price = $_POST['eb_room_price'];
|
||||
|
||||
$eagle_booking_form_final_price = $_POST['eagle_booking_checkout_form_final_price'];
|
||||
$eagle_booking_deposit_amount = $_POST['eagle_booking_deposit_amount'];
|
||||
$eagle_booking_room_id = $_POST['eagle_booking_checkout_room_id'];
|
||||
$eagle_booking_room_title = $_POST['eagle_booking_checkout_form_post_title'];
|
||||
$eagle_booking_form_name = $_POST['eagle_booking_checkout_form_name'];
|
||||
$eagle_booking_form_surname = $_POST['eagle_booking_checkout_form_surname'];
|
||||
$eagle_booking_form_email = $_POST['eagle_booking_checkout_form_email'];
|
||||
$eagle_booking_form_phone = $_POST['eagle_booking_checkout_form_phone'];
|
||||
$eagle_booking_form_address = $_POST['eagle_booking_checkout_form_address'];
|
||||
$eagle_booking_form_city = $_POST['eagle_booking_checkout_form_city'];
|
||||
$eagle_booking_form_country = $_POST['eagle_booking_checkout_form_country'];
|
||||
$eagle_booking_form_zip = $_POST['eagle_booking_checkout_form_zip'];
|
||||
$eagle_booking_form_requests = $_POST['eagle_booking_checkout_form_requets'];
|
||||
$eagle_booking_form_arrival = $_POST['eagle_booking_checkout_form_arrival'];
|
||||
$eagle_booking_form_coupon = $_POST['eagle_booking_form_coupon'];
|
||||
$eagle_booking_form_services = $_POST['eagle_booking_form_services'];
|
||||
$eagle_booking_form_action_type = $_POST['eagle_booking_form_action_type'];
|
||||
$eagle_booking_form_payment_status = $_POST['eagle_booking_form_payment_status'];
|
||||
|
||||
// DEFAULTS
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
|
||||
// PAYMENT COMPLETED
|
||||
$eagle_booking_payment_completed = true;
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['arrive'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_arrive_tab">
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('eagle_booking_arrive_mssg')) ?></p>
|
||||
<form action="<?php echo eb_checkout_page() ?>" method="post">
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="payment_on_arrive">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_from" value="<?php echo $eagle_booking_form_date_from ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_to" value="<?php echo $eagle_booking_form_date_to ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_guests" value="<?php echo $eagle_booking_form_guests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_adults" value="<?php echo $eagle_booking_form_adults ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_children" value="<?php echo $eagle_booking_form_children ?>">
|
||||
|
||||
<input type="hidden" name="eb_room_price" value="<?php echo $eb_room_price ?>">
|
||||
|
||||
<input type="hidden" name="eagle_booking_checkout_form_final_price" value="<?php echo $eagle_booking_form_final_price ?>">
|
||||
<input type="hidden" name="eagle_booking_deposit_amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_room_id" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_post_title" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_name" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_surname" value="<?php echo $eagle_booking_form_surname ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_phone" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_address" value="<?php echo $eagle_booking_form_address ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_city" value="<?php echo $eagle_booking_form_city ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_country" value="<?php echo $eagle_booking_form_country ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_zip" value="<?php echo $eagle_booking_form_zip ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_requets" value="<?php echo $eagle_booking_form_requests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_arrival" value="<?php echo $eagle_booking_form_arrival ?>">
|
||||
<input type="hidden" name="eagle_booking_form_services" value="<?php echo $eagle_booking_form_services ?>">
|
||||
<input type="hidden" name="eagle_booking_form_coupon" value="<?php echo $eagle_booking_form_coupon ?>">
|
||||
<input type="hidden" name="eagle_booking_form_action_type" value="payment_on_arrive">
|
||||
<input type="hidden" name="eagle_booking_form_payment_status" value="Pending Payment">
|
||||
<button type="submit" class="btn eb-btn btn-arrive"> <?php echo esc_html__('Book Now', 'eagle-booking') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['arrive'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_arrive_tab">
|
||||
<i class="ion-cash" aria-hidden="true"></i><?php echo esc_html__('Payment On Arrival','eagle-booking') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* Bank Transfer
|
||||
* author Eagle Themes (Jomin Muskaj)
|
||||
* package Eagle Booking
|
||||
* version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( $eagle_booking_payment_method == 'bank') :
|
||||
|
||||
// PAYPAL VALUES
|
||||
$eagle_booking_transaction_id = rand(100000000,999999999);
|
||||
|
||||
// FORM VALUES
|
||||
$eagle_booking_form_date_from = $_POST['eagle_booking_checkout_form_date_from'];
|
||||
$eagle_booking_form_date_to = $_POST['eagle_booking_checkout_form_date_to'];
|
||||
$eagle_booking_form_guests = $_POST['eagle_booking_checkout_form_guests'];
|
||||
$eagle_booking_form_adults = $_POST['eagle_booking_checkout_form_adults'];
|
||||
$eagle_booking_form_children = $_POST['eagle_booking_checkout_form_children'];
|
||||
|
||||
$eb_room_price = $_POST['eb_room_price'];
|
||||
|
||||
$eagle_booking_form_final_price = $_POST['eagle_booking_checkout_form_final_price'];
|
||||
$eagle_booking_deposit_amount = $_POST['eagle_booking_deposit_amount'];
|
||||
$eagle_booking_room_id = $_POST['eagle_booking_room_id'];
|
||||
$eagle_booking_room_title = $_POST['eagle_booking_room_title'];
|
||||
$eagle_booking_form_name = $_POST['eagle_booking_checkout_form_name'];
|
||||
$eagle_booking_form_surname = $_POST['eagle_booking_checkout_form_surname'];
|
||||
$eagle_booking_form_email = $_POST['eagle_booking_checkout_form_email'];
|
||||
$eagle_booking_form_phone = $_POST['eagle_booking_checkout_form_phone'];
|
||||
$eagle_booking_form_address = $_POST['eagle_booking_checkout_form_address'];
|
||||
$eagle_booking_form_city = $_POST['eagle_booking_checkout_form_city'];
|
||||
$eagle_booking_form_country = $_POST['eagle_booking_checkout_form_country'];
|
||||
$eagle_booking_form_zip = $_POST['eagle_booking_checkout_form_zip'];
|
||||
$eagle_booking_form_requests = $_POST['eagle_booking_checkout_form_requets'];
|
||||
$eagle_booking_form_arrival = $_POST['eagle_booking_checkout_form_arrival'];
|
||||
$eagle_booking_form_coupon = $_POST['eagle_booking_form_coupon'];
|
||||
$eagle_booking_form_services = $_POST['eagle_booking_form_services'];
|
||||
$eagle_booking_form_action_type = $_POST['eagle_booking_form_action_type'];
|
||||
$eagle_booking_form_payment_status = $_POST['eagle_booking_form_payment_status'];
|
||||
|
||||
// DEFAULTS
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
|
||||
// PAYMENT COMPLETED
|
||||
$eagle_booking_payment_completed = true;
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['bank'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_bank_tab">
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('eagle_booking_bank_mssg')) ?></p>
|
||||
<form action="<?php echo eb_checkout_page() ?>" method="post">
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="bank">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_from" value="<?php echo $eagle_booking_form_date_from ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_to" value="<?php echo $eagle_booking_form_date_to ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_guests" value="<?php echo $eagle_booking_form_guests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_adults" value="<?php echo $eagle_booking_form_adults ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_children" value="<?php echo $eagle_booking_form_children ?>">
|
||||
|
||||
<input type="hidden" name="eb_room_price" value="<?php echo $eb_room_price ?>">
|
||||
|
||||
<input type="hidden" name="eagle_booking_checkout_form_final_price" value="<?php echo $eagle_booking_form_final_price ?>">
|
||||
<input type="hidden" name="eagle_booking_deposit_amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="eagle_booking_room_id" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="eagle_booking_room_title" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_name" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_surname" value="<?php echo $eagle_booking_form_surname ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_phone" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_address" value="<?php echo $eagle_booking_form_address ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_city" value="<?php echo $eagle_booking_form_city ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_country" value="<?php echo $eagle_booking_form_country ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_zip" value="<?php echo $eagle_booking_form_zip ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_requets" value="<?php echo $eagle_booking_form_requests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_arrival" value="<?php echo $eagle_booking_form_arrival ?>">
|
||||
<input type="hidden" name="eagle_booking_form_services" value="<?php echo $eagle_booking_form_services ?>">
|
||||
<input type="hidden" name="eagle_booking_form_coupon" value="<?php echo $eagle_booking_form_coupon ?>">
|
||||
<input type="hidden" name="eagle_booking_form_action_type" value="bank_transfer">
|
||||
<input type="hidden" name="eagle_booking_form_payment_status" value="Pending Payment">
|
||||
<button type="submit" class="btn eb-btn btn-bank"><?php echo esc_html__('Book Now','eagle-booking') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['bank'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_bank_tab">
|
||||
<i class="fa fa-university" aria-hidden="true"></i><?php echo esc_html__('Bank Transfer','eagle-booking') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
* Flutterwave Payment Gateway
|
||||
* Author Eagle Themes (Jomin Muskaj)
|
||||
* Package Eagle Booking
|
||||
* Version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( isset($_POST['tx_ref']) ):
|
||||
// Data
|
||||
$eagle_booking_form_date_from = $_POST['eagle_booking_checkout_form_date_from'];
|
||||
$eagle_booking_form_date_to = $_POST['eagle_booking_checkout_form_date_to'];
|
||||
$eagle_booking_form_guests = $_POST['eagle_booking_checkout_form_guests'];
|
||||
$eagle_booking_form_adults = $_POST['eagle_booking_checkout_form_adults'];
|
||||
$eagle_booking_form_children = $_POST['eagle_booking_checkout_form_children'];
|
||||
$eb_room_price = $_POST['eb_room_price'];
|
||||
$eagle_booking_form_final_price = $_POST['eagle_booking_checkout_form_final_price'];
|
||||
$eagle_booking_deposit_amount = $_POST['eagle_booking_deposit_amount'];
|
||||
$eagle_booking_room_id = $_POST['eagle_booking_room_id'];
|
||||
$eagle_booking_room_title = $_POST['eagle_booking_room_title'];
|
||||
$eagle_booking_form_name = $_POST['eagle_booking_checkout_form_name'];
|
||||
$eagle_booking_form_surname = $_POST['eagle_booking_checkout_form_surname'];
|
||||
$eagle_booking_form_email = $_POST['eagle_booking_checkout_form_email'];
|
||||
$eagle_booking_form_phone = $_POST['eagle_booking_checkout_form_phone'];
|
||||
$eagle_booking_form_address = $_POST['eagle_booking_checkout_form_address'];
|
||||
$eagle_booking_form_city = $_POST['eagle_booking_checkout_form_city'];
|
||||
$eagle_booking_form_country = $_POST['eagle_booking_checkout_form_country'];
|
||||
$eagle_booking_form_zip = $_POST['eagle_booking_checkout_form_zip'];
|
||||
$eagle_booking_form_requests = $_POST['eagle_booking_checkout_form_requets'];
|
||||
$eagle_booking_form_arrival = $_POST['eagle_booking_checkout_form_arrival'];
|
||||
$eagle_booking_form_coupon = $_POST['eagle_booking_form_coupon'];
|
||||
$eagle_booking_form_services = $_POST['eagle_booking_form_services'];
|
||||
$eagle_booking_form_action_type = $_POST['eagle_booking_form_action_type'];
|
||||
$eagle_booking_form_payment_status = $_POST['eagle_booking_form_payment_status'];
|
||||
|
||||
// Retrive Flutterwave Token
|
||||
$flutterwave_secret_key = eb_get_option('flutterwave_secret_key');
|
||||
$transaction_id = $_POST['transaction_id'];
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://api.flutterwave.com/v3/transactions/$transaction_id/verify",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "GET",
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Content-Type: application/json",
|
||||
"Authorization: Bearer $flutterwave_secret_key"
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
|
||||
|
||||
|
||||
$error = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($error) {
|
||||
echo "cURL Error #:" . $error;
|
||||
}
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if( !empty( $transaction_id ) || $error ){
|
||||
|
||||
if( $response['status'] == 'success' ){
|
||||
|
||||
$eagle_booking_payment_completed = true;
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
$eagle_booking_form_payment_status = 'Completed';
|
||||
$eagle_booking_transaction_id = $transaction_id;
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['flutterwave'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_flutterwave_tab">
|
||||
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('flutterwave_mssg')) ?></p>
|
||||
|
||||
<form accept-charset="UTF-8" action="<?php echo eb_checkout_page() ?>" id="flutterwave" method="POST">
|
||||
|
||||
<!-- Booking Details -->
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="flutterwave">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_from" value="<?php echo $eagle_booking_form_date_from ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_to" value="<?php echo $eagle_booking_form_date_to ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_guests" value="<?php echo $eagle_booking_form_guests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_adults" value="<?php echo $eagle_booking_form_adults ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_children" value="<?php echo $eagle_booking_form_children ?>">
|
||||
<input type="hidden" name="eb_room_price" value="<?php echo $eb_room_price ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_final_price" value="<?php echo $eagle_booking_form_final_price ?>">
|
||||
<input type="hidden" name="eagle_booking_deposit_amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="eagle_booking_room_id" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="eagle_booking_room_title" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_name" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_surname" value="<?php echo $eagle_booking_form_surname ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_phone" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_address" value="<?php echo $eagle_booking_form_address ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_city" value="<?php echo $eagle_booking_form_city ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_country" value="<?php echo $eagle_booking_form_country ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_zip" value="<?php echo $eagle_booking_form_zip ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_requets" value="<?php echo $eagle_booking_form_requests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_arrival" value="<?php echo $eagle_booking_form_arrival ?>">
|
||||
<input type="hidden" name="eagle_booking_form_services" value="<?php echo $eagle_booking_form_services ?>">
|
||||
<input type="hidden" name="eagle_booking_form_coupon" value="<?php echo $eagle_booking_form_coupon ?>">
|
||||
<input type="hidden" name="eagle_booking_form_action_type" value="flutterwave">
|
||||
<input type="hidden" name="eagle_booking_form_payment_status" value="Completed">
|
||||
|
||||
<input type="hidden" id="tx_ref" name="tx_ref">
|
||||
<input type="hidden" id="transaction_id" name="transaction_id">
|
||||
|
||||
<!-- Flutterwave Parameters -->
|
||||
<button class="btn eb-btn" type="button" onClick="makePayment()"><?php echo __('Checkout Now','eagle-booking') ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="https://checkout.flutterwave.com/v3.js"></script>
|
||||
<script>
|
||||
|
||||
function makePayment() {
|
||||
|
||||
FlutterwaveCheckout({
|
||||
|
||||
public_key: "<?php echo eb_get_option('flutterwave_public_key') ?>",
|
||||
tx_ref: "eb-<?php echo rand( )?>",
|
||||
amount: "<?php echo $eagle_booking_deposit_amount ?>",
|
||||
currency: "<?php echo eb_get_option('flutterwave_currency')?>",
|
||||
customer: {
|
||||
email: "<?php echo $eagle_booking_form_email ?>",
|
||||
phone_number: "<?php echo $eagle_booking_form_phone ?>",
|
||||
name: "<?php echo $eagle_booking_form_name.' '.$eagle_booking_form_surname ?>",
|
||||
},
|
||||
|
||||
callback: function (data) {
|
||||
|
||||
jQuery('#tx_ref').val(data.tx_ref);
|
||||
jQuery('#transaction_id').val(data.transaction_id);
|
||||
|
||||
// Form Submit
|
||||
jQuery('#flutterwave').submit();
|
||||
|
||||
},
|
||||
|
||||
// close modal
|
||||
onclose: function() {
|
||||
|
||||
},
|
||||
|
||||
customizations: {
|
||||
title: "<?php echo get_bloginfo( 'name' ); ?>",
|
||||
description: "<?php __('Payment for Booking', 'eagle-booking') ?>",
|
||||
logo: "<?php echo eb_get_option( 'hotel_logo' ); ?>",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['flutterwave'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_flutterwave_tab">
|
||||
<i class="fa fa-credit-card" aria-hidden="true"></i><?php echo do_shortcode( eb_get_option('flutterwave_title') ) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Include payment content - Sorting
|
||||
*/
|
||||
|
||||
$eb_payment_methods = eb_get_option('eagle_booking_payment_method');
|
||||
|
||||
foreach ($eb_payment_methods as $eb_payment_method=>$value) {
|
||||
switch($eb_payment_method) {
|
||||
|
||||
case 'paypal': include_once 'paypal/tab-content.php';
|
||||
break;
|
||||
case 'stripe': include_once 'stripe/tab-content.php';
|
||||
break;
|
||||
case '2checkout': include_once '2checkout/tab-content.php';
|
||||
break;
|
||||
case 'payu': include_once 'payu/tab-content.php';
|
||||
break;
|
||||
case 'paystack': include_once 'paystack/tab-content.php';
|
||||
break;
|
||||
case 'flutterwave': include_once 'flutterwave/tab-content.php';
|
||||
break;
|
||||
case 'razorpay': include_once 'razorpay/tab-content.php';
|
||||
break;
|
||||
case 'vivawallet': include_once 'vivawallet/tab-content.php';
|
||||
break;
|
||||
case 'bank': include_once 'bank/tab-content.php';
|
||||
break;
|
||||
case 'arrive': include_once 'arrive/tab-content.php';
|
||||
break;
|
||||
case 'request': include_once 'request/tab-content.php';
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Include payment tabs - Sorting
|
||||
*/
|
||||
|
||||
$eb_payment_methods = eb_get_option('eagle_booking_payment_method');
|
||||
|
||||
foreach ($eb_payment_methods as $eb_payment_method=>$value) {
|
||||
switch($eb_payment_method) {
|
||||
|
||||
case 'paypal': include_once 'paypal/tab.php';
|
||||
break;
|
||||
case 'stripe': include_once 'stripe/tab.php';
|
||||
break;
|
||||
case '2checkout': include_once '2checkout/tab.php';
|
||||
break;
|
||||
case 'payu': include_once 'payu/tab.php';
|
||||
break;
|
||||
case 'paystack': include_once 'paystack/tab.php';
|
||||
break;
|
||||
case 'flutterwave': include_once 'flutterwave/tab.php';
|
||||
break;
|
||||
case 'razorpay': include_once 'razorpay/tab.php';
|
||||
break;
|
||||
case 'vivawallet': include_once 'vivawallet/tab.php';
|
||||
break;
|
||||
case 'bank': include_once 'bank/tab.php';
|
||||
break;
|
||||
case 'arrive': include_once 'arrive/tab.php';
|
||||
break;
|
||||
case 'request': include_once 'request/tab.php';
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/*
|
||||
* PayPal Payment Gateway
|
||||
* author Eagle Themes (Jomin Muskaj)
|
||||
* package Eagle Booking
|
||||
* version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( isset($_GET['tx']) ) :
|
||||
|
||||
// PLUGIN OPTIONS
|
||||
$eagle_booking_paypal_email = eb_get_option('eagle_booking_paypal_id');
|
||||
$eagle_booking_paypal_currency = eb_currency();
|
||||
$eagle_booking_paypal_token = eb_get_option('eagle_booking_paypal_token');
|
||||
$eagle_booking_paypal_developer = eb_get_option('eagle_booking_paypal_developer_mode');
|
||||
|
||||
if ( $eagle_booking_paypal_developer == true) {
|
||||
$eagle_booking_paypal_action_1 = 'https://www.sandbox.paypal.com/cgi-bin';
|
||||
$eagle_booking_paypal_action_2 = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
||||
} else {
|
||||
$eagle_booking_paypal_action_1 = 'https://www.paypal.com/cgi-bin';
|
||||
$eagle_booking_paypal_action_2 = 'https://www.paypal.com/cgi-bin/webscr';
|
||||
}
|
||||
|
||||
// PAYPAL DEFAULTS
|
||||
$eagle_booking_transaction_id = $_GET['tx'];
|
||||
$eagle_booking_request = curl_init();
|
||||
|
||||
// PAYPAL REQUEST OPTIONS
|
||||
curl_setopt_array($eagle_booking_request, array
|
||||
(
|
||||
CURLOPT_URL => $eagle_booking_paypal_action_2,
|
||||
CURLOPT_POST => TRUE,
|
||||
CURLOPT_POSTFIELDS => http_build_query(array
|
||||
(
|
||||
'cmd' => '_notify-synch',
|
||||
'tx' => $eagle_booking_transaction_id,
|
||||
'at' => $eagle_booking_paypal_token,
|
||||
)),
|
||||
CURLOPT_RETURNTRANSFER => TRUE,
|
||||
CURLOPT_HEADER => FALSE,
|
||||
));
|
||||
|
||||
$eagle_booking_response = curl_exec($eagle_booking_request);
|
||||
$eagle_booking_status = curl_getinfo($eagle_booking_request, CURLINFO_HTTP_CODE);
|
||||
|
||||
// CLOSE CONNECTION
|
||||
curl_close($eagle_booking_request);
|
||||
|
||||
// PAYPAL PAYMENT STATUS
|
||||
if($eagle_booking_status == 200 AND strpos($eagle_booking_response, 'SUCCESS') === 0){
|
||||
|
||||
// DECODE RESPONSE
|
||||
$eagle_booking_response = substr($eagle_booking_response, 7);
|
||||
$eagle_booking_response = urldecode($eagle_booking_response);
|
||||
preg_match_all('/^([^=\s]++)=(.*+)/m', $eagle_booking_response, $m, PREG_PATTERN_ORDER);
|
||||
$eagle_booking_response = array_combine($m[1], $m[2]);
|
||||
|
||||
$eagle_booking_room_id = $eagle_booking_response['item_number'];
|
||||
$eagle_booking_room_title = $eagle_booking_response['item_name'];
|
||||
|
||||
// PAYPAL USER INFO
|
||||
$eagle_booking_paypal_name = $eagle_booking_response['first_name'];
|
||||
$eagle_booking_paypal_surname = $eagle_booking_response['last_name'];
|
||||
$eagle_booking_paypal_email = $eagle_booking_response['payer_email'];
|
||||
$eagle_booking_paypal_address = $eagle_booking_response['address_street'];
|
||||
$eagle_booking_paypal_city = $eagle_booking_response['address_city'];
|
||||
$eagle_booking_paypal_country = $eagle_booking_response['address_country'];
|
||||
$eagle_booking_paypal_zip = $eagle_booking_response['address_zip'];
|
||||
|
||||
// PAYPAL PAYMENT DETAILS
|
||||
$eagle_booking_date = $eagle_booking_response['payment_date'];
|
||||
$eagle_booking_deposit_amount = $eagle_booking_response['mc_gross'];
|
||||
$eagle_booking_form_currency = $eagle_booking_response['mc_currency'];
|
||||
$eagle_booking_form_action_type = 'paypal';
|
||||
$eagle_booking_form_payment_status = $eagle_booking_response['payment_status'];
|
||||
|
||||
// EXTRACT CUSTOM FIELD FROM 'CUSTOM'
|
||||
$eagle_booking_custom_field_array = explode('[eb]', $eagle_booking_response['custom']);
|
||||
$eagle_booking_form_date_from = $eagle_booking_custom_field_array[0];
|
||||
$eagle_booking_form_date_to = $eagle_booking_custom_field_array[1];
|
||||
$eagle_booking_form_guests = $eagle_booking_custom_field_array[2];
|
||||
$eagle_booking_form_adults = $eagle_booking_custom_field_array[3];
|
||||
$eagle_booking_form_children = $eagle_booking_custom_field_array[4];
|
||||
$eagle_booking_form_name = $eagle_booking_custom_field_array[5];
|
||||
$eagle_booking_form_surname = $eagle_booking_custom_field_array[6];
|
||||
$eagle_booking_form_email = $eagle_booking_custom_field_array[7];
|
||||
$eagle_booking_form_phone = $eagle_booking_custom_field_array[8];
|
||||
$eagle_booking_form_address = $eagle_booking_custom_field_array[9];
|
||||
$eagle_booking_form_zip = $eagle_booking_custom_field_array[10];
|
||||
$eagle_booking_form_city = $eagle_booking_custom_field_array[11];
|
||||
$eagle_booking_form_country = $eagle_booking_custom_field_array[12];
|
||||
$eagle_booking_form_services = $eagle_booking_custom_field_array[13];
|
||||
$eagle_booking_form_requests = $eagle_booking_custom_field_array[14];
|
||||
$eagle_booking_form_arrival = $eagle_booking_custom_field_array[15];
|
||||
$eagle_booking_form_coupon = $eagle_booking_custom_field_array[16];
|
||||
$eagle_booking_form_final_price = $eagle_booking_custom_field_array[17];
|
||||
|
||||
$eb_room_price = $eagle_booking_custom_field_array[18];
|
||||
|
||||
// PAYMENT COMPLETED
|
||||
$eagle_booking_payment_completed = true;
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['paypal'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_paypal_tab">
|
||||
<?php
|
||||
// PLUGIN OPTIONS
|
||||
$eagle_booking_paypal_email = eb_get_option('eagle_booking_paypal_id');
|
||||
$eagle_booking_paypal_currency = eb_get_option('eagle_booking_paypal_currency');
|
||||
$eagle_booking_paypal_token = eb_get_option('eagle_booking_paypal_token');
|
||||
|
||||
$eagle_booking_paypal_developer = eb_get_option('eagle_booking_paypal_developer_mode');
|
||||
if ( $eagle_booking_paypal_developer == true ) {
|
||||
$eagle_booking_paypal_action_1 = 'https://www.sandbox.paypal.com/cgi-bin';
|
||||
$eagle_booking_paypal_action_2 = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
||||
} else {
|
||||
$eagle_booking_paypal_action_1 = 'https://www.paypal.com/cgi-bin';
|
||||
$eagle_booking_paypal_action_2 = 'https://www.paypal.com/cgi-bin/webscr';
|
||||
}
|
||||
?>
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('eagle_booking_paypal_mssg')) ?></p>
|
||||
<form target="paypal" action="<?php echo $eagle_booking_paypal_action_1 ?>" method="post" >
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="paypal">
|
||||
<input type="hidden" name="cmd" value="_xclick">
|
||||
<input type="hidden" name="business" value="<?php echo $eagle_booking_paypal_email ?>">
|
||||
<input type="hidden" name="lc" value="">
|
||||
<input type="hidden" name="item_name" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="item_number" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="custom" value="<?php echo $eagle_booking_form_date_from.'[eb]'.$eagle_booking_form_date_to.'[eb]'.$eagle_booking_form_guests.'[eb]'.$eagle_booking_form_adults.'[eb]'.$eagle_booking_form_adults.'[eb]'.$eagle_booking_form_name.'[eb]'.$eagle_booking_form_surname.'[eb]'.$eagle_booking_form_email.'[eb]'.$eagle_booking_form_phone.'[eb]'.$eagle_booking_form_address.'[eb]'.$eagle_booking_form_zip.'[eb]'.$eagle_booking_form_city.'[eb]'.$eagle_booking_form_country.'[eb]'.$eagle_booking_form_services.'[eb]'.$eagle_booking_form_requests.'[eb]'.$eagle_booking_form_arrival.'[eb]'.$eagle_booking_form_coupon.'[eb]'.$eagle_booking_form_final_price.'[eb]'.$eb_room_price ?>">
|
||||
<input type="hidden" name="amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="currency_code" value="<?php echo $eagle_booking_paypal_currency ?>">
|
||||
<input type="hidden" name="rm" value="2" />
|
||||
<input type="hidden" name="return" value="<?php echo esc_url( eb_checkout_page() ) ?>" />
|
||||
<input type="hidden" name="cancel_return" value="" />
|
||||
<input type="hidden" name="button_subtype" value="services">
|
||||
<input type="hidden" name="no_note" value="0">
|
||||
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
|
||||
<button class="btn eb-btn btn-paypal" type="submit"><?php echo esc_html__('Checkout with PayPal','eagle-booking') ?></button>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['paypal'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_paypal_tab">
|
||||
<i class="icon-paypal" aria-hidden="true"></i><?php echo esc_html__('PayPal','eagle-booking')?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
* 2Checkout Payment Gateway
|
||||
* Author Eagle Themes (Jomin Muskaj)
|
||||
* Package Eagle Booking
|
||||
* Version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if ( isset($_POST['paystack_reference']) ) :
|
||||
|
||||
// Data
|
||||
$eagle_booking_form_date_from = $_POST['eagle_booking_checkout_form_date_from'];
|
||||
$eagle_booking_form_date_to = $_POST['eagle_booking_checkout_form_date_to'];
|
||||
$eagle_booking_form_guests = $_POST['eagle_booking_checkout_form_guests'];
|
||||
$eagle_booking_form_adults = $_POST['eagle_booking_checkout_form_adults'];
|
||||
$eagle_booking_form_children = $_POST['eagle_booking_checkout_form_children'];
|
||||
|
||||
$eb_room_price = $_POST['eb_room_price'];
|
||||
|
||||
$eagle_booking_form_final_price = $_POST['eagle_booking_checkout_form_final_price'];
|
||||
$eagle_booking_deposit_amount = $_POST['eagle_booking_deposit_amount'];
|
||||
$eagle_booking_room_id = $_POST['eagle_booking_room_id'];
|
||||
$eagle_booking_room_title = $_POST['eagle_booking_room_title'];
|
||||
$eagle_booking_form_name = $_POST['eagle_booking_checkout_form_name'];
|
||||
$eagle_booking_form_surname = $_POST['eagle_booking_checkout_form_surname'];
|
||||
$eagle_booking_form_email = $_POST['eagle_booking_checkout_form_email'];
|
||||
$eagle_booking_form_phone = $_POST['eagle_booking_checkout_form_phone'];
|
||||
$eagle_booking_form_address = $_POST['eagle_booking_checkout_form_address'];
|
||||
$eagle_booking_form_city = $_POST['eagle_booking_checkout_form_city'];
|
||||
$eagle_booking_form_country = $_POST['eagle_booking_checkout_form_country'];
|
||||
$eagle_booking_form_zip = $_POST['eagle_booking_checkout_form_zip'];
|
||||
$eagle_booking_form_requests = $_POST['eagle_booking_checkout_form_requets'];
|
||||
$eagle_booking_form_arrival = $_POST['eagle_booking_checkout_form_arrival'];
|
||||
$eagle_booking_form_coupon = $_POST['eagle_booking_form_coupon'];
|
||||
$eagle_booking_form_services = $_POST['eagle_booking_form_services'];
|
||||
$eagle_booking_form_action_type = $_POST['eagle_booking_form_action_type'];
|
||||
$eagle_booking_form_payment_status = $_POST['eagle_booking_form_payment_status'];
|
||||
|
||||
// Retrive Paystack Token
|
||||
$paystack_secret_key = eb_get_option('paystack_secret_key');
|
||||
$eb_paystack_token = $_POST['paystack_reference'];
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://api.paystack.co/transaction/verify/$eb_paystack_token",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "GET",
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"Authorization: Bearer $paystack_secret_key",
|
||||
"Cache-Control: no-cache",
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$error = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($error) {
|
||||
echo "cURL Error #:" . $error;
|
||||
}
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if( !empty( $eb_paystack_token ) || $error ){
|
||||
|
||||
if( $response['data']['status'] == 'success' ){
|
||||
|
||||
$eagle_booking_payment_completed = true;
|
||||
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
$eagle_booking_form_payment_status = 'Completed';
|
||||
$eagle_booking_transaction_id = $response['data']['id'];
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['paystack'] ) : ?>
|
||||
<div id="eagle_booking_checkout_payment_paystack_tab">
|
||||
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('paystack_mssg')) ?></p>
|
||||
|
||||
<form accept-charset="UTF-8" action="<?php echo eb_checkout_page() ?>" id="paystack" method="POST">
|
||||
|
||||
<!-- Booking Details -->
|
||||
<input type="hidden" name="eagle_booking_payment_method" value="paystack">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_from" value="<?php echo $eagle_booking_form_date_from ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_date_to" value="<?php echo $eagle_booking_form_date_to ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_guests" value="<?php echo $eagle_booking_form_guests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_adults" value="<?php echo $eagle_booking_form_adults ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_children" value="<?php echo $eagle_booking_form_children ?>">
|
||||
|
||||
<input type="hidden" name="eb_room_price" value="<?php echo $eb_room_price ?>">
|
||||
|
||||
<input type="hidden" name="eagle_booking_checkout_form_final_price" value="<?php echo $eagle_booking_form_final_price ?>">
|
||||
<input type="hidden" name="eagle_booking_deposit_amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" name="eagle_booking_room_id" value="<?php echo $eagle_booking_room_id ?>">
|
||||
<input type="hidden" name="eagle_booking_room_title" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_name" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_surname" value="<?php echo $eagle_booking_form_surname ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_phone" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_address" value="<?php echo $eagle_booking_form_address ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_city" value="<?php echo $eagle_booking_form_city ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_country" value="<?php echo $eagle_booking_form_country ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_zip" value="<?php echo $eagle_booking_form_zip ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_requets" value="<?php echo $eagle_booking_form_requests ?>">
|
||||
<input type="hidden" name="eagle_booking_checkout_form_arrival" value="<?php echo $eagle_booking_form_arrival ?>">
|
||||
<input type="hidden" name="eagle_booking_form_services" value="<?php echo $eagle_booking_form_services ?>">
|
||||
<input type="hidden" name="eagle_booking_form_coupon" value="<?php echo $eagle_booking_form_coupon ?>">
|
||||
<input type="hidden" name="eagle_booking_form_action_type" value="paystack">
|
||||
<input type="hidden" name="eagle_booking_form_payment_status" value="Completed">
|
||||
|
||||
<!-- Paystack Parameters -->
|
||||
<input type="hidden" id="email-address" value="<?php echo $eagle_booking_form_email ?>" />
|
||||
<input type="hidden" id="amount" value="<?php echo $eagle_booking_deposit_amount ?>" />
|
||||
<button id="card-button" class="btn eb-btn" type="submit" onclick="payWithPaystack(event)"><?php echo __('Checkout Now','eagle-booking') ?></button>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="https://js.paystack.co/v1/inline.js"></script>
|
||||
<script>
|
||||
|
||||
var Form = document.getElementById('paystack');
|
||||
Form.addEventListener('submit', payWithPaystack, false);
|
||||
function payWithPaystack(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
let handler = PaystackPop.setup({
|
||||
key: '<?php echo eb_get_option('paystack_public_key') ?>',
|
||||
email: document.getElementById("email-address").value,
|
||||
amount: document.getElementById("amount").value * 100,
|
||||
currency: '<?php echo eb_get_option('paystack_currency') ?>',
|
||||
onClose: function(){
|
||||
},
|
||||
callback: function(response){
|
||||
|
||||
//Create Token
|
||||
var hiddenInput = document.createElement("input");
|
||||
hiddenInput.setAttribute("type", "hidden");
|
||||
hiddenInput.setAttribute("name", "paystack_reference");
|
||||
hiddenInput.setAttribute("value", response.reference);
|
||||
Form.appendChild(hiddenInput);
|
||||
|
||||
// Submit Form
|
||||
Form.submit();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
handler.openIframe();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['paystack'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_paystack_tab">
|
||||
<i class="fa fa-credit-card" aria-hidden="true"></i><?php echo __('Paystack','eagle-booking') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* Package: Core / PayU Payment Gateway
|
||||
* Author: Eagle Themes (Jomin Muskaj)
|
||||
* Version 1.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (isset($_POST ['key'])) :
|
||||
|
||||
// PayU
|
||||
$eb_payu_merchant_key = eb_get_option('eb_payu_merchant_key');
|
||||
$eb_payu_merchant_salt = eb_get_option('eb_payu_merchant_salt');
|
||||
$eb_payu_transaction_id = $_POST['txnid'];
|
||||
$eagle_booking_deposit_amount = $_POST['amount'];
|
||||
$eagle_booking_room_title = $_POST['productinfo'];
|
||||
$eagle_booking_form_name = $_POST['firstname'];
|
||||
$eagle_booking_form_email = $_POST['email'];
|
||||
$mihpayid = $_POST['mihpayid'];
|
||||
$status = $_POST['status'];
|
||||
$resphash = $_POST['hash'];
|
||||
|
||||
// Get custom parameters
|
||||
$eb_payu_udf5 = $_POST['udf5'];
|
||||
|
||||
// Explode parameters
|
||||
$eb_custom_field_array = explode('[eb]', $eb_payu_udf5);
|
||||
$eagle_booking_room_id = $eb_custom_field_array[0];
|
||||
$eagle_booking_form_date_from = $eb_custom_field_array[1];
|
||||
$eagle_booking_form_date_to = $eb_custom_field_array[2];
|
||||
$eagle_booking_form_guests = $eb_custom_field_array[3];
|
||||
$eagle_booking_form_adults = $eb_custom_field_array[4];
|
||||
$eagle_booking_form_children = $eb_custom_field_array[5];
|
||||
$eagle_booking_form_name = $eb_custom_field_array[6];
|
||||
$eagle_booking_form_surname = $eb_custom_field_array[7];
|
||||
$eagle_booking_form_email = $eb_custom_field_array[8];
|
||||
$eagle_booking_form_phone = $eb_custom_field_array[9];
|
||||
$eagle_booking_form_address = $eb_custom_field_array[10];
|
||||
$eagle_booking_form_zip = $eb_custom_field_array[11];
|
||||
$eagle_booking_form_city = $eb_custom_field_array[12];
|
||||
$eagle_booking_form_country = $eb_custom_field_array[13];
|
||||
$eagle_booking_form_services = $eb_custom_field_array[14];
|
||||
$eagle_booking_form_requests = $eb_custom_field_array[15];
|
||||
$eagle_booking_form_arrival = $eb_custom_field_array[16];
|
||||
$eagle_booking_form_coupon = $eb_custom_field_array[17];
|
||||
$eagle_booking_form_final_price = $eb_custom_field_array[18];
|
||||
|
||||
// Defaults
|
||||
$eagle_booking_form_currency = eb_currency();
|
||||
$eagle_booking_date = date('H:m:s F j Y');
|
||||
$eagle_booking_form_payment_status = 'Completed';
|
||||
$eagle_booking_transaction_id = $eb_payu_transaction_id;
|
||||
$eagle_booking_form_action_type = 'PayU';
|
||||
|
||||
// Calculate response hash to verify
|
||||
$keyString = $eb_payu_merchant_key.'|'.$eb_payu_transaction_id.'|'.$eagle_booking_deposit_amount.'|'.$eagle_booking_room_title.'|'.$eagle_booking_form_name.'|'.$eagle_booking_form_email.'|||||'.$eb_payu_udf5.'|||||';
|
||||
$keyArray = explode("|",$keyString);
|
||||
$reverseKeyArray = array_reverse($keyArray);
|
||||
$reverseKeyString = implode("|",$reverseKeyArray);
|
||||
$CalcHashString = strtolower(hash('sha512', $eb_payu_merchant_salt.'|'.$status.'|'.$reverseKeyString));
|
||||
|
||||
|
||||
if ($status == 'success' && $resphash == $CalcHashString) {
|
||||
|
||||
$eagle_booking_payment_completed = true;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
$eagle_booking_payment_completed = false;
|
||||
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['payu'] ) : ?>
|
||||
|
||||
<div id="eagle_booking_checkout_payment_payu_tab">
|
||||
|
||||
<p class="checkout-mssg"><?php echo do_shortcode(eb_get_option('eb_payu_checkout_mssg')) ?></p>
|
||||
|
||||
<?php
|
||||
$eb_payu_merchant_key = eb_get_option('eb_payu_merchant_key');
|
||||
$eb_payu_merchant_salt = eb_get_option('eb_payu_merchant_salt');
|
||||
$eb_payu_transaction_id = 'Txn'.rand(10000, 99999999);
|
||||
|
||||
// Pass parameters as array
|
||||
$eb_payu_udf5 = $eagle_booking_room_id .'[eb]'.$eagle_booking_form_date_from.'[eb]'.$eagle_booking_form_date_to.'[eb]'.$eagle_booking_form_guests.'[eb]'.$eagle_booking_form_adults.'[eb]'.$eagle_booking_form_adults.'[eb]'.$eagle_booking_form_name.'[eb]'.$eagle_booking_form_surname.'[eb]'.$eagle_booking_form_email.'[eb]'.$eagle_booking_form_phone.'[eb]'.$eagle_booking_form_address.'[eb]'.$eagle_booking_form_zip.'[eb]'.$eagle_booking_form_city.'[eb]'.$eagle_booking_form_country.'[eb]'.$eagle_booking_form_services.'[eb]'.$eagle_booking_form_requests.'[eb]'.$eagle_booking_form_arrival.'[eb]'.$eagle_booking_form_coupon.'[eb]'.$eagle_booking_form_final_price;
|
||||
|
||||
$eb_payu_hash = hash('sha512', $eb_payu_merchant_key.'|'.$eb_payu_transaction_id.'|'.$eagle_booking_deposit_amount.'|'.$eagle_booking_room_title.'|'.$eagle_booking_form_name.'|'.$eagle_booking_form_email.'|||||'.$eb_payu_udf5.'||||||'.$eb_payu_merchant_salt);
|
||||
|
||||
?>
|
||||
|
||||
<form action="#" id="payu_form">
|
||||
<input type="hidden" id="surl" name="surl" value="<?php echo eb_checkout_page() ?>" />
|
||||
<input type="hidden" id="key" name="key" value="<?php echo $eb_payu_merchant_key ?>" />
|
||||
<input type="hidden" id="salt" name="salt" value="<?php echo $eb_payu_merchant_salt ?>" />
|
||||
<input type="hidden" id="txnid" name="txnid" value="<?php echo $eb_payu_transaction_id ?>" />
|
||||
<input type="hidden" id="amount" name="amount" value="<?php echo $eagle_booking_deposit_amount ?>">
|
||||
<input type="hidden" id="pinfo" name="pinfo" value="<?php echo $eagle_booking_room_title ?>">
|
||||
<input type="hidden" id="email" name="email" value="<?php echo $eagle_booking_form_email ?>">
|
||||
<input type="hidden" id="mobile" name="mobile" value="<?php echo $eagle_booking_form_phone ?>">
|
||||
<input type="hidden" id="fname" name="fname" value="<?php echo $eagle_booking_form_name ?>">
|
||||
<input type="hidden" id="udf5" name="udf5" value="<?php echo $eb_payu_udf5 ?>">
|
||||
<input type="hidden" id="hash" name="hash" value="<?php echo $eb_payu_hash ?>" />
|
||||
<button id="payu-button" class="btn eb-btn btn-payu" type="submit"><?php echo __('Checkout Now','eagle-booking') ?></button>
|
||||
</form>
|
||||
|
||||
<?php if ( eb_get_option('eb_payu_sandbox') == true ) : ?>
|
||||
<script id="bolt" src="https://sboxcheckout-static.citruspay.com/bolt/run/bolt.min.js" bolt-color="19a1f7" bolt-logo="https://boltiswatching.com/wp-content/uploads/2015/09/Bolt-Logo-e14421724859591.png"></script>
|
||||
<?php else : ?>
|
||||
<script id="bolt" src="https://checkout-static.citruspay.com/bolt/run/bolt.min.js" bolt-color="19a1f7" bolt-logo="http://boltiswatching.com/wp-content/uploads/2015/09/Bolt-Logo-e14421724859591.png"></script>
|
||||
<?php endif ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
|
||||
$(document).on('submit','#payu_form',function(e){
|
||||
launchBOLT();
|
||||
e.preventDefault();
|
||||
|
||||
});
|
||||
|
||||
function launchBOLT() {
|
||||
bolt.launch({
|
||||
key: $('#key').val(),
|
||||
salt: $('#salt').val(),
|
||||
txnid: $('#txnid').val(),
|
||||
hash: $('#hash').val(),
|
||||
amount: $('#amount').val(),
|
||||
firstname: $('#fname').val(),
|
||||
email: $('#email').val(),
|
||||
phone: $('#mobile').val(),
|
||||
productinfo: $('#pinfo').val(),
|
||||
udf5: $('#udf5').val(),
|
||||
surl : $('#surl').val(),
|
||||
furl: $('#surl').val(),
|
||||
mode: 'dropout'
|
||||
},
|
||||
{
|
||||
responseHandler: function(BOLT){
|
||||
console.log( BOLT.response.txnStatus );
|
||||
if(BOLT.response.txnStatus != 'CANCEL') {
|
||||
var fr = '<form action=\"'+$('#surl').val()+'\" method=\"post\">' +
|
||||
'<input type=\"hidden\" name=\"key\" value=\"'+BOLT.response.key+'\" />' +
|
||||
'<input type=\"hidden\" name=\"txnid\" value=\"'+BOLT.response.txnid+'\" />' +
|
||||
'<input type=\"hidden\" name=\"amount\" value=\"'+BOLT.response.amount+'\" />' +
|
||||
'<input type=\"hidden\" name=\"productinfo\" value=\"'+BOLT.response.productinfo+'\" />' +
|
||||
'<input type=\"hidden\" name=\"firstname\" value=\"'+BOLT.response.firstname+'\" />' +
|
||||
'<input type=\"hidden\" name=\"email\" value=\"'+BOLT.response.email+'\" />' +
|
||||
'<input type=\"hidden\" name=\"udf5\" value=\"'+BOLT.response.udf5+'\" />' +
|
||||
'<input type=\"hidden\" name=\"mihpayid\" value=\"'+BOLT.response.mihpayid+'\" />' +
|
||||
'<input type=\"hidden\" name=\"status\" value=\"'+BOLT.response.status+'\" />' +
|
||||
'<input type=\"hidden\" name=\"hash\" value=\"'+BOLT.response.hash+'\" />' +
|
||||
'</form>';
|
||||
var form = jQuery(fr);
|
||||
jQuery('body').append(form);
|
||||
form.submit();
|
||||
}
|
||||
},
|
||||
catchException: function(BOLT){
|
||||
alert( BOLT.message );
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php if ( eb_get_option('eagle_booking_payment_method')['payu'] ) : ?>
|
||||
<li class="payment-tab-item">
|
||||
<a href="#eagle_booking_checkout_payment_payu_tab">
|
||||
<i class="fa fa-credit-card" aria-hidden="true"></i><?php echo esc_html__('Credit Card','eagle-booking') ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
@@ -0,0 +1,14 @@
|
||||
# This file is for unifying the coding style for different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[**.php]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
@@ -0,0 +1,39 @@
|
||||
name: feature.md
|
||||
description: Submit a proposal for a new feature
|
||||
title: '[Feature]: '
|
||||
labels: [':rocket: Feature Request']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Thank you for taking the time to suggest a new feature!
|
||||
We kindly ask that you search to see if an issue [already exists](https://github.com/razorpay/razorpay-php/issues?q=is%3Aissue+sort%3Acreated-desc+) for your feature.
|
||||
We are also happy to accept contributions from our users.
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: '🚀 Feature Proposal'
|
||||
description:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Suggested Solution
|
||||
description:
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description:
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: extra
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description:
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,62 @@
|
||||
name: issue.md
|
||||
description: Create a report to help us improve
|
||||
labels: ["issue"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this issue report!
|
||||
- type: textarea
|
||||
id: repro-steps
|
||||
attributes:
|
||||
label: Steps to reproduce the behavior
|
||||
description:
|
||||
placeholder: |
|
||||
1. Fetch a '...'
|
||||
2. Update the '....'
|
||||
3. See error
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual-behavior
|
||||
attributes:
|
||||
label: Actual behavior
|
||||
description: A clear and concise description of what actually happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: code-snippets
|
||||
attributes:
|
||||
label: Code snippets
|
||||
description: If applicable, add code snippets to help explain your problem.
|
||||
render: Php
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: language-version
|
||||
attributes:
|
||||
label: Php version
|
||||
placeholder: Php v7.4
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: lib-version
|
||||
attributes:
|
||||
label: Library version
|
||||
placeholder: razorpay-php v2.8.4
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: Add any other information about the problem here.
|
||||
validations:
|
||||
required: false
|
||||
8
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/dependabot.yml
vendored
Normal file
8
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: composer
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "04:00"
|
||||
timezone: Asia/Calcutta
|
||||
@@ -0,0 +1,8 @@
|
||||
## Note :- Please follow the below points while attaching test cases document link below:
|
||||
### - If label `Tested` is added then test cases document URL is mandatory.
|
||||
### - Link added should be a valid URL and accessible throughout the org.
|
||||
### - If the branch name contains hotfix / revert by default the BVT workflow check will pass.
|
||||
|
||||
| Test Case Document URL |
|
||||
|-----------------------------------------------|
|
||||
| Please paste test case document link here.... |
|
||||
37
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/workflows/ci.yml
vendored
Normal file
37
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- v[0-9]+.[0-9]+.[0-9]+*
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up php 8.0
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
- name: 'Create env file'
|
||||
run: |
|
||||
touch ${{ github.workspace }}/tests/.env
|
||||
echo RAZORPAY_API_KEY=${{ secrets.RAZORPAY_API_KEY }} >> ${{ github.workspace }}/tests/.env
|
||||
echo RAZORPAY_API_SECRET=${{ secrets.RAZORPAY_API_SECRET }} >> ${{ github.workspace }}/tests/.env
|
||||
cat ${{ github.workspace }}/tests/.env
|
||||
- name: Install dependencies
|
||||
run: composer self-update && composer install && composer require vlucas/phpdotenv && composer dump-autoload
|
||||
- name: Run tests and collect coverage
|
||||
run: vendor/bin/phpunit ./tests/CoverageTest.php --coverage-clover coverage.xml .
|
||||
env:
|
||||
RAZORPAY_API_KEY: ${{ secrets.RAZORPAY_API_KEY }}
|
||||
RAZORPAY_API_SECRET: ${{ secrets.RAZORPAY_API_SECRET }}
|
||||
RAZORPAY_PARTNER_API_KEY: ${{ secrets.RAZORPAY_PARTNER_API_KEY }}
|
||||
RAZORPAY_PARTNER_API_SECRET: ${{ secrets.RAZORPAY_PARTNER_API_SECRET }}
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
51
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/workflows/security.yml
vendored
Normal file
51
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.github/workflows/security.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
name: SecurityChecks
|
||||
on:
|
||||
pull_request: {}
|
||||
push:
|
||||
branches: ["master"]
|
||||
schedule:
|
||||
- cron: '30 20 * * *'
|
||||
jobs:
|
||||
semgrep:
|
||||
name: Semgrep
|
||||
runs-on: [ubuntu-latest]
|
||||
container:
|
||||
image: returntocorp/semgrep
|
||||
steps:
|
||||
- uses: actions/checkout@v4.0.0
|
||||
- name: Run semgrep
|
||||
run: semgrep ci
|
||||
env:
|
||||
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
|
||||
workflow_status:
|
||||
runs-on: [ ubuntu-latest ] # nosemgrep : semgrep.dev/s/swati31196:github_provided_runner
|
||||
name: Update Status Check
|
||||
needs: [ semgrep ]
|
||||
if: always()
|
||||
env:
|
||||
githubCommit: ${{ github.event.pull_request.head.sha }}
|
||||
steps:
|
||||
- name: Set github commit id
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "push" ] || [ "${{ github.event_name }}" = "schedule" ]; then
|
||||
echo "githubCommit=${{ github.sha }}" >> $GITHUB_ENV
|
||||
fi
|
||||
exit 0
|
||||
- name: Failed
|
||||
id: failed
|
||||
if: (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && github.ref != 'refs/heads/master'
|
||||
run: |
|
||||
echo 'Failing the workflow for github security status check.'
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
||||
-d '{ "state" : "failure" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
|
||||
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
|
||||
exit 1
|
||||
- name: Success
|
||||
if: steps.failed.conclusion == 'skipped' || github.ref != 'refs/heads/master'
|
||||
run: |
|
||||
echo 'Status check has passed!'
|
||||
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
||||
-d '{ "state" : "success" , "context" : "github/security-status-check" , "description" : "github/security-status-check", "target_url" : "https://github.com/${{ github.repository }}" }' \
|
||||
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.githubCommit }}
|
||||
exit 0
|
||||
5
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.gitignore
vendored
Normal file
5
wp-content/plugins/eagle-booking/core/admin/gateways/razorpay/api/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
vendor/
|
||||
reports/
|
||||
**/.DS_Store
|
||||
@@ -0,0 +1,45 @@
|
||||
dist: precise
|
||||
language: php
|
||||
php:
|
||||
- 7.3
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
|
||||
install: composer install
|
||||
before_script:
|
||||
- cp phpunit.xml.dist phpunit.xml
|
||||
# These two are required in the build step for non-composer-tests
|
||||
- mkdir -p libs
|
||||
- cd libs && wget https://github.com/rmccue/Requests/archive/v2.0.4.zip -O requests.zip && unzip requests.zip && rm requests.zip && cd ..
|
||||
- rm -rf libs/Requests-2.0.4/examples libs/Requests-2.0.4/docs libs/Requests-2.0.4/bin libs/Requests-2.0.4/tests
|
||||
script:
|
||||
# Run a syntax validation check on all PHP files
|
||||
- find . -path ./vendor -prune -o -iname '*.php' |xargs -n1 php -l
|
||||
- ./vendor/bin/phpunit
|
||||
|
||||
notifications:
|
||||
slack:
|
||||
secure: fLT1x7BCXi8+sP1Qk1lP74+60JIBCw2clUTSOmB0OuoQGWYIJ4qelKcGH5FFsADGuC1GX2pf0fKRiLdavVrGpBkD4MGFPpyYKPYb0S/FyArN3PjdaNvAqE1VgQCtKkbugP5bHH9bp631+lo2EGQVLWTjlwiijWbCEyDu3L0YVMY=
|
||||
# We are doing the releases for non-composer folks
|
||||
# So this includes the vendor directory
|
||||
before_deploy:
|
||||
- echo $TRAVIS_TAG > version.txt
|
||||
- cat release.txt |zip -r@ "razorpay-php.zip"
|
||||
deploy:
|
||||
provider: releases
|
||||
# Otherwise, we lose the vendor/ directory
|
||||
skip_cleanup: true
|
||||
api_key:
|
||||
secure: bHcu1jUASH6aVSD1LmzXdjQC4hc0o8EBbVs9X8e5j+/OC7+UuBBRu+jh6gQje/XWu9Nj1W2LkWhv0IKX1tJbcs0uRstggx+xC0ZayRzkscsqErqeM4WeyJjxe5ewb2eeGujtl9+WWFB3wpUQJtxXaaPuGYtroYGGYuI23wzKN4A=
|
||||
# travis doesn't support multi file deployes yet, not that we need them
|
||||
file: razorpay-php.zip
|
||||
on:
|
||||
# Only do the release for one build every tag
|
||||
php: 7.3
|
||||
# GitHub refuses to accept releases that are not tagged
|
||||
tags: true
|
||||
# Allow builds for non-master branches as well
|
||||
all_branches: true
|
||||
# Only do the releases if the repo is not a fork
|
||||
repo: razorpay/razorpay-php
|
||||
@@ -0,0 +1,260 @@
|
||||
# Change Log
|
||||
|
||||
Changelog for Razorpay-PHP SDK. Follows [keepachangelog.com](https://keepachangelog.com/en/1.0.0/) for formatting.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## [2.9.0] - 2023-12-18
|
||||
feat: Added new API endpoints
|
||||
|
||||
* Added support for `addBankAccount`, `deleteBankAccount`, `requestEligibilityCheck` & `fetchEligibility` on customer
|
||||
* Added support for `uploadAccountDoc` & `fetchAccountDoc` on account
|
||||
* Added support for [Dispute](https://razorpay.com/docs/api/disputes/)
|
||||
* Added support for [Document](https://razorpay.com/docs/api/documents/)
|
||||
* Added support for fetch all IINs Supporting native otps & fetch all IINs with business sub-type using `all`
|
||||
* Added support for `viewRtoReview` & `editFulfillment` on order
|
||||
* Added support for fetch a payment (emi/ offer/ card/ upi) using `expandedDetails` on payments
|
||||
* Added support for `uploadStakeholderDoc` & `fetchStakeholderDoc` on stakeholder
|
||||
|
||||
|
||||
## [2.8.7] - 2023-09-11
|
||||
[#357](https://github.com/razorpay/razorpay-php/pull/357) [`b29754f`](https://github.com/razorpay/razorpay-php/commit/b29754f8892e0c2035055cf73fd7ab132de18e52) Chore: Changed Content-Type `application/json` for `order create` API from default `application/x-www-form-urlencoded`
|
||||
|
||||
|
||||
## [2.8.6] - 2023-06-16
|
||||
[#348](https://github.com/razorpay/razorpay-php/pull/348) [`68b2028`](https://github.com/razorpay/razorpay-php/commit/68b2028bafda49af970a098d6d11aa8e5a575d40) feat: Added new API endpoints
|
||||
|
||||
* Added account onboarding API (create, fetch, edit, delete)
|
||||
* Added stakeholders API (create, fetch, fetchAll, edit)
|
||||
* Added product configuration API (requestProductConfiguration, fetch, edit, fetchTnc)
|
||||
* Added webhooks API (create, fetch, fetchAll, edit, delete)
|
||||
* Added token sharing API (create, fetch, delete, processPaymentOnAlternatePAorPG)
|
||||
|
||||
## [2.8.5] - 2022-10-19
|
||||
|
||||
### Added
|
||||
- Update [Request](https://github.com/WordPress/Requests/tree/v2.0.4) library to v2.0.4
|
||||
|
||||
## [2.8.4] - 2022-06-28
|
||||
|
||||
- New APIs for Third party validation (createUpi, validateVpa, fetchPaymentMethods)
|
||||
- Update documentation
|
||||
|
||||
## [2.8.3] - 2022-04-29
|
||||
|
||||
- PHP v8.1 is officially supported
|
||||
- Update [Request](https://github.com/WordPress/Requests/tree/v2.0.0) library to v2.0
|
||||
- Improve documentation
|
||||
- Add PHPUnit v9
|
||||
|
||||
## [2.8.2] - 2022-03-08
|
||||
|
||||
- Change name convention to standard in Unit test
|
||||
- Removed test api key due to security concern from test cases
|
||||
|
||||
## [2.8.1] - 2021-11-08
|
||||
|
||||
### Added
|
||||
|
||||
- Added Item Api
|
||||
- Added Unit Tests
|
||||
|
||||
## [2.8.0][2.8.0] - 2021-10-07
|
||||
|
||||
### Added
|
||||
- QR code end point API [[#235](https://github.com/razorpay/razorpay-php/pull/235)]
|
||||
- Update, cancel, create subscription link,fetch details of a Pending Update,cancel, pause and resume subscription API[[#236](https://github.com/razorpay/razorpay-php/pull/236)]
|
||||
- Smart Collect(Virtual Account) TPV API's [[#238](https://github.com/razorpay/razorpay-php/pull/238)]
|
||||
- Add/Delete TPV Bank Account [[#239](https://github.com/razorpay/razorpay-php/pull/239)]
|
||||
- Card end point api [[#240](https://github.com/razorpay/razorpay-php/pull/240)]
|
||||
- Route end point api [[#241](https://github.com/razorpay/razorpay-php/pull/241)]
|
||||
- Register emandate and charge first payment together [[#245](https://github.com/razorpay/razorpay-php/pull/245)]
|
||||
- PaperNACH/Register NACH and charge first payment together [[#246](https://github.com/razorpay/razorpay-php/pull/246)]
|
||||
- Added payment and Settlements methods [[#247](https://github.com/razorpay/razorpay-php/pull/247)]
|
||||
- Added edit and notify API's for payment links [[#248](https://github.com/razorpay/razorpay-php/pull/248)]
|
||||
- Added fetch, fetch multiple refund,edit and notify API's for refunds [[#250](https://github.com/razorpay/razorpay-php/pull/250)]
|
||||
- Added edit order API [[#251](https://github.com/razorpay/razorpay-php/pull/251)]
|
||||
- Fund API's end point [[#252](https://github.com/razorpay/razorpay-php/pull/252)]
|
||||
- UPI [[#253](https://github.com/razorpay/razorpay-php/pull/253)]
|
||||
- Added payment link paymentverification [[#255](https://github.com/razorpay/razorpay-php/pull/255)]
|
||||
- Update readme file [[#254](https://github.com/razorpay/razorpay-php/pull/254)]
|
||||
|
||||
## [2.7.1][2.7.1] - 2021-09-16
|
||||
|
||||
### Added
|
||||
|
||||
- Added Payment Link end point API [[#233](https://github.com/razorpay/razorpay-php/pull/233)]
|
||||
|
||||
## [2.7.0][2.7.0] - 2021-05-07
|
||||
|
||||
### Added
|
||||
|
||||
- Adds support for payment page enity API [[#224](https://github.com/razorpay/razorpay-php/pull/224)]
|
||||
|
||||
## [2.6.1][2.6.1] - 2021-04-30
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrades [requests](https://github.com/rmccue/Requests/) to v1.8. [[#221](https://github.com/razorpay/razorpay-php/pull/221)]
|
||||
|
||||
## [2.6.0][2.6.0] - 2021-04-05
|
||||
|
||||
### Added
|
||||
|
||||
- Adds support for webhook enity API [[#212](https://github.com/razorpay/razorpay-php/pull/212)]
|
||||
|
||||
## [2.4.0-beta][2.4.0-beta] - 2018-11-28
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgrades [requests](https://github.com/rmccue/Requests/) to v1.7. [[#89](https://github.com/razorpay/razorpay-php/pull/89)]
|
||||
- Enforces TLS1.1+ for all requests. Workaround for a bug in RHEL 6. [[#76](https://github.com/razorpay/razorpay-php/pull/76)]
|
||||
|
||||
## [2.3.0][2.3.0] - 2018-09-15
|
||||
|
||||
### Added
|
||||
|
||||
- Add parameters to Subscription Cancel API
|
||||
- Support for fetching Settlements
|
||||
|
||||
## [2.2.1][2.2.1] - 2018-05-28
|
||||
|
||||
### Added
|
||||
|
||||
- Support for fetching all customer entities
|
||||
|
||||
## [2.2.0][2.2.0] - 2017-10-23
|
||||
|
||||
### Added
|
||||
|
||||
- Support for VirtualAccount entity
|
||||
- Support for Subscriptions
|
||||
|
||||
## [2.1.0][2.1.0] - 2017-10-10
|
||||
|
||||
### Added
|
||||
|
||||
- Support for new actions(cancel, notifyBy, edit, issue, delete) on invoices
|
||||
- Removes PHP 5.3 from list of versions to test build against
|
||||
|
||||
## [2.0.2][2.0.2] - 2017-08-03
|
||||
|
||||
### Added
|
||||
|
||||
- Support for creating and fetching Transfers
|
||||
- Support for creating Reversals on transfers
|
||||
|
||||
## [2.0.1][2.0.1] - 2017-07-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Webhook signature verification
|
||||
- Conditional require of Request class
|
||||
|
||||
## [2.0.0][2.0.0] - 2017-03-07
|
||||
|
||||
### Added
|
||||
|
||||
- Support for custom Application header
|
||||
- Support for card entity
|
||||
- Support for Webhook and Order Signature verification
|
||||
- Support for direct refund creation via Razorpay\Api\Refund::create()
|
||||
- Support for Utility functions via Razorpay\Api\Utility::verifyPaymentSignature and Razorpay\Api\Utility::verifyWebhookSignature
|
||||
- Support for case insensitive error codes
|
||||
- Support for 2xx HTTP status codes
|
||||
|
||||
### Changed
|
||||
|
||||
- Razorpay\Api\Payment::refunds() now returns a Razorpay\Api\Collection object instead of Razorpay\Api\Refund object
|
||||
- Razorpay\Api\Api::$baseUrl, Razorpay\Api\Api::$key and Razorpay\Api\Api::$secret are now `protected` instead of `public`
|
||||
|
||||
## [1.2.9][1.2.9] - 2017-01-03
|
||||
|
||||
### Added
|
||||
|
||||
- Support for creating and fetching Invoices
|
||||
|
||||
## [1.2.8][1.2.8] - 2016-10-12
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Customer and Token entities
|
||||
|
||||
## [1.2.7][1.2.7] - 2016-09-21
|
||||
|
||||
### Added
|
||||
|
||||
- Increases the request timeout to 30 seconds for all requests.
|
||||
|
||||
## [1.2.6][1.2.6] - 2016-03-28
|
||||
|
||||
### Added
|
||||
|
||||
- Adds better tracing when client is not able to recognize server response.
|
||||
|
||||
## [1.2.5][1.2.5] - 2016-03-28
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for overriding request headers via setHeader
|
||||
|
||||
## [1.2.3][1.2.3] - 2016-02-24
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for Orders
|
||||
|
||||
## [1.2.2][1.2.2] - 2016-02-17
|
||||
|
||||
### Changed
|
||||
|
||||
- Razorpay\Api\Request::checkErrors is now `protected` instead of `private`
|
||||
- The final build is now leaner and includes just requests, instead of entire vendor directory
|
||||
|
||||
## [1.2.1][1.2.1] - 2016-01-21
|
||||
|
||||
### Added
|
||||
|
||||
- Add version.txt in release with current git tag
|
||||
- This changelog file
|
||||
- `Api\Request::getHeaders()` method
|
||||
|
||||
## [1.2.0][1.2.0] - 2015-10-23
|
||||
|
||||
### Added
|
||||
|
||||
- Add version string to User Agent
|
||||
|
||||
### Changed
|
||||
|
||||
- New release process that pushes pre-packaged zip files to GitHub
|
||||
|
||||
## 1.0.0 - 2015-01-18
|
||||
|
||||
### Added
|
||||
|
||||
- Initial Release
|
||||
|
||||
[unreleased]: https://github.com/razorpay/razorpay-php/compare/2.5.0...HEAD
|
||||
[1.2.1]: https://github.com/razorpay/razorpay-php/compare/1.2.0...1.2.1
|
||||
[1.2.0]: https://github.com/razorpay/razorpay-php/compare/1.1.0...1.2.0
|
||||
[1.2.2]: https://github.com/razorpay/razorpay-php/compare/1.2.1...1.2.2
|
||||
[1.2.3]: https://github.com/razorpay/razorpay-php/compare/1.2.2...1.2.3
|
||||
[1.2.4]: https://github.com/razorpay/razorpay-php/compare/1.2.3...1.2.4
|
||||
[1.2.5]: https://github.com/razorpay/razorpay-php/compare/1.2.4...1.2.5
|
||||
[1.2.6]: https://github.com/razorpay/razorpay-php/compare/1.2.5...1.2.6
|
||||
[1.2.7]: https://github.com/razorpay/razorpay-php/compare/1.2.6...1.2.7
|
||||
[1.2.8]: https://github.com/razorpay/razorpay-php/compare/1.2.7...1.2.8
|
||||
[1.2.9]: https://github.com/razorpay/razorpay-php/compare/1.2.8...1.2.9
|
||||
[2.0.0]: https://github.com/razorpay/razorpay-php/compare/1.2.9...2.0.0
|
||||
[2.0.1]: https://github.com/razorpay/razorpay-php/compare/2.0.0...2.0.1
|
||||
[2.0.2]: https://github.com/razorpay/razorpay-php/compare/2.0.1...2.0.2
|
||||
[2.1.0]: https://github.com/razorpay/razorpay-php/compare/2.0.2...2.1.0
|
||||
[2.2.0]: https://github.com/razorpay/razorpay-php/compare/2.1.0...2.2.0
|
||||
[2.2.1]: https://github.com/razorpay/razorpay-php/compare/2.2.0...2.2.1
|
||||
[2.3.0]: https://github.com/razorpay/razorpay-php/compare/2.2.1...2.3.0
|
||||
[2.4.0-beta]: https://github.com/razorpay/razorpay-php/compare/2.3.0...2.4.0-beta
|
||||
[2.5.0]: https://github.com/razorpay/razorpay-php/compare/2.4.0-beta...2.5.0
|
||||
[2.8.0]: https://github.com/razorpay/razorpay-php/compare/2.7.1...2.8.0
|
||||
[2.8.1]: https://github.com/razorpay/razorpay-php/compare/2.8.0...2.8.1
|
||||
[2.8.2]: https://github.com/razorpay/razorpay-php/compare/2.8.0...2.8.2
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Backwards compatibility layer for Requests.
|
||||
*
|
||||
* Allows for Composer to autoload the old PSR-0 classes via the custom autoloader.
|
||||
* This prevents issues with _extending final classes_ (which was the previous solution).
|
||||
*
|
||||
* Please see the Changelog for the 2.0.4 release for upgrade notes.
|
||||
*
|
||||
* @package Requests
|
||||
*
|
||||
* @deprecated 2.0.4 Use the PSR-4 class names instead.
|
||||
*/
|
||||
define("REQUESTS_SILENCE_PSR0_DEPRECATIONS",true);
|
||||
|
||||
if (class_exists('WpOrg\Requests\Autoload') === false) {
|
||||
require_once __DIR__. 'libs/Requests-2.0.4/src/Autoload.php';
|
||||
}
|
||||
|
||||
WpOrg\Requests\Autoload::register();
|
||||
@@ -0,0 +1,7 @@
|
||||
Copyright 2019 Razorpay
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,106 @@
|
||||
# razorpay-php
|
||||
|
||||
[](https://travis-ci.org/razorpay/razorpay-php) [](https://packagist.org/packages/razorpay/razorpay#2.8.0) [](https://packagist.org/packages/razorpay/razorpay)
|
||||
|
||||
Official PHP library for [Razorpay API](https://docs.razorpay.com/docs/payments).
|
||||
|
||||
Read up here for getting started and understanding the payment flow with Razorpay: <https://docs.razorpay.com/docs/getting-started>
|
||||
|
||||
### Prerequisites
|
||||
- A minimum of PHP 7.3 upto 8.1
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
- If your project using composer, run the below command
|
||||
|
||||
```
|
||||
composer require razorpay/razorpay:2.*
|
||||
```
|
||||
|
||||
- If you are not using composer, download the latest release from [the releases section](https://github.com/razorpay/razorpay-php/releases).
|
||||
**You should download the `razorpay-php.zip` file**.
|
||||
After that, include `Razorpay.php` in your application and you can use the API as usual.
|
||||
|
||||
##Note:
|
||||
This PHP library follows the following practices:
|
||||
|
||||
- Namespaced under `Razorpay\Api`
|
||||
- API throws exceptions instead of returning errors
|
||||
- Options are passed as an array instead of multiple arguments wherever possible
|
||||
- All requests and responses are communicated over JSON
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation of Razorpay's API and their usage is available at <https://docs.razorpay.com>
|
||||
|
||||
## Basic Usage
|
||||
|
||||
Instantiate the razorpay php instance with `key_id` & `key_secret`. You can obtain the keys from the dashboard app ([https://dashboard.razorpay.com/#/app/keys](https://dashboard.razorpay.com/#/app/keys))
|
||||
|
||||
```php
|
||||
use Razorpay\Api\Api;
|
||||
|
||||
$api = new Api($api_key, $api_secret);
|
||||
```
|
||||
|
||||
The resources can be accessed via the `$api` object. All the methods invocations follows the following pattern
|
||||
|
||||
```php
|
||||
// $api->class->function() to access the API
|
||||
//Example
|
||||
$api->payment->fetch($paymentId);
|
||||
```
|
||||
## Supported Resources
|
||||
- [Account](documents/account.md)
|
||||
- [Customer](documents/customer.md)
|
||||
- [Dispute](documents/dispute.md)
|
||||
- [Document](documents/document.md)
|
||||
- [Token](documents/token.md)
|
||||
- [Order](documents/order.md)
|
||||
- [Payments](documents/payment.md)
|
||||
- [Settlements](documents/settlement.md)
|
||||
- [Refunds](documents/refund.md)
|
||||
- [Fund](documents/fund.md)
|
||||
- [Invoice](documents/invoice.md)
|
||||
- [Iin](documents/Iin.md)
|
||||
- [Plan](documents/plan.md)
|
||||
- [Item](documents/item.md)
|
||||
- [Subscriptions](documents/subscription.md)
|
||||
- [Add-on](documents/addon.md)
|
||||
- [Payment Links](documents/paymentLink.md)
|
||||
- [Product Configuration](documents/productConfiguration.md)
|
||||
- [Smart Collect](documents/virtualaccount.md)
|
||||
- [Stakeholder](documents/stakeholder.md)
|
||||
- [Transfer](documents/transfer.md)
|
||||
- [QR Code](documents/qrcode.md)
|
||||
- [Emandate](documents/emandate.md)
|
||||
- [Cards](documents/card.md)
|
||||
- [Paper NACH](documents/papernach.md)
|
||||
- [UPI](documents/upi.md)
|
||||
- [Register Emandate and Charge First Payment Together](documents/registeremandate.md)
|
||||
- [Register NACH and Charge First Payment Together](documents/registernach.md)
|
||||
- [Payment Verification](documents/paymentVerfication.md)
|
||||
- [Webhook](documents/webhook.md)
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
See the [doc.md](doc.md) file for getting started with development.
|
||||
|
||||
## Release
|
||||
|
||||
Steps to follow for a release:
|
||||
|
||||
0. Merge the branch with the new code to master.
|
||||
1. Bump the Version in `src/Api.php`.
|
||||
2. Rename Unreleased to the new tag in `CHANGELOG.md`
|
||||
3. Add a new empty "Unreleased" section at the top of `CHANGELOG.md`
|
||||
4. Fix links at bottom in `CHANGELOG.md`
|
||||
5. Commit
|
||||
6. Tag the release and push to GitHub
|
||||
7. A release should automatically be created once the travis build passes. Edit the release to add some description.
|
||||
|
||||
## License
|
||||
|
||||
The Razorpay PHP SDK is released under the MIT License. See [LICENSE](LICENSE) file for more details.
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
// Include Requests only if not already defined
|
||||
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS'))
|
||||
{
|
||||
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
|
||||
}
|
||||
|
||||
if (class_exists('WpOrg\Requests\Autoload') === false)
|
||||
{
|
||||
require_once __DIR__.'/libs/Requests-2.0.4/src/Autoload.php';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
WpOrg\Requests\Autoload::register();
|
||||
|
||||
if (version_compare(Requests::VERSION, '1.6.0') === -1)
|
||||
{
|
||||
throw new Exception('Requests class found but did not match');
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new Exception('Requests class found but did not match');
|
||||
}
|
||||
|
||||
spl_autoload_register(function ($class)
|
||||
{
|
||||
// project-specific namespace prefix
|
||||
$prefix = 'Razorpay\Api';
|
||||
|
||||
// base directory for the namespace prefix
|
||||
$base_dir = __DIR__ . '/src/';
|
||||
|
||||
// does the class use the namespace prefix?
|
||||
$len = strlen($prefix);
|
||||
|
||||
if (strncmp($prefix, $class, $len) !== 0)
|
||||
{
|
||||
// no, move to the next registered autoloader
|
||||
return;
|
||||
}
|
||||
|
||||
// get the relative class name
|
||||
$relative_class = substr($class, $len);
|
||||
|
||||
//
|
||||
// replace the namespace prefix with the base directory,
|
||||
// replace namespace separators with directory separators
|
||||
// in the relative class name, append with .php
|
||||
//
|
||||
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
|
||||
|
||||
// if the file exists, require it
|
||||
if (file_exists($file))
|
||||
{
|
||||
require $file;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "razorpay/razorpay",
|
||||
"description": "Razorpay PHP Client Library",
|
||||
"keywords": ["razorpay", "api", "php", "client"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Abhay Rana",
|
||||
"email": "nemo@razorpay.com",
|
||||
"homepage": "https://captnemo.in",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Shashank Kumar",
|
||||
"email": "shashank@razorpay.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "contact@razorpay.com",
|
||||
"issues": "https://github.com/Razorpay/razorpay-php/issues",
|
||||
"source": "https://github.com/Razorpay/razorpay-php"
|
||||
},
|
||||
"homepage": "https://docs.razorpay.com",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=7.3",
|
||||
"rmccue/requests": "^2.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"raveren/kint": "1.*",
|
||||
"phpunit/phpunit": "^9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Razorpay\\Api\\": "src/",
|
||||
"Razorpay\\Tests\\": "tests/"
|
||||
},
|
||||
"files" : ["Deprecated.php"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
This document talks about the implementation of the code for the Api.
|
||||
|
||||
Everything comes under namespace Razorpay\Api\.
|
||||
Namespaces put a requirement of PHP 5.3 minimum
|
||||
|
||||
```php
|
||||
namespace Razorpay\
|
||||
|
||||
class Api
|
||||
{
|
||||
|
||||
// Contains a __get function that returns the appropriate
|
||||
// class object when one tries to access them.
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace Razorpay\
|
||||
|
||||
class Client
|
||||
{
|
||||
// Handles request and response
|
||||
// Uses Composer:Requests internally
|
||||
}
|
||||
|
||||
class Payment
|
||||
{
|
||||
public function get($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function fetch($options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function capture($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function refund($id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,15 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
Requests
|
||||
========
|
||||
|
||||
Copyright (c) 2010-2012 Ryan McCue and contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
ComplexPie IRI Parser
|
||||
=====================
|
||||
|
||||
Copyright (c) 2007-2010, Geoffrey Sneddon and Steve Minutillo.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the SimplePie Team nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,168 @@
|
||||
Requests for PHP
|
||||
================
|
||||
|
||||
[](https://github.com/WordPress/Requests/actions/workflows/cs.yml)
|
||||
[](https://github.com/WordPress/Requests/actions/workflows/lint.yml)
|
||||
[](https://github.com/WordPress/Requests/actions/workflows/test.yml)
|
||||
[](https://codecov.io/gh/WordPress/Requests?branch=stable)
|
||||
|
||||
Requests is a HTTP library written in PHP, for human beings. It is roughly
|
||||
based on the API from the excellent [Requests Python
|
||||
library](http://python-requests.org/). Requests is [ISC
|
||||
Licensed](https://github.com/WordPress/Requests/blob/stable/LICENSE) (similar to
|
||||
the new BSD license) and has no dependencies, except for PHP 5.6+.
|
||||
|
||||
Despite PHP's use as a language for the web, its tools for sending HTTP requests
|
||||
are severely lacking. cURL has an
|
||||
[interesting API](https://www.php.net/curl-setopt), to say the
|
||||
least, and you can't always rely on it being available. Sockets provide only low
|
||||
level access, and require you to build most of the HTTP response parsing
|
||||
yourself.
|
||||
|
||||
We all have better things to do. That's why Requests was born.
|
||||
|
||||
```php
|
||||
$headers = array('Accept' => 'application/json');
|
||||
$options = array('auth' => array('user', 'pass'));
|
||||
$request = WpOrg\Requests\Requests::get('https://api.github.com/gists', $headers, $options);
|
||||
|
||||
var_dump($request->status_code);
|
||||
// int(200)
|
||||
|
||||
var_dump($request->headers['content-type']);
|
||||
// string(31) "application/json; charset=utf-8"
|
||||
|
||||
var_dump($request->body);
|
||||
// string(26891) "[...]"
|
||||
```
|
||||
|
||||
Requests allows you to send **HEAD**, **GET**, **POST**, **PUT**, **DELETE**,
|
||||
and **PATCH** HTTP requests. You can add headers, form data, multipart files,
|
||||
and parameters with basic arrays, and access the response data in the same way.
|
||||
Requests uses cURL and fsockopen, depending on what your system has available,
|
||||
but abstracts all the nasty stuff out of your way, providing a consistent API.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- International Domains and URLs
|
||||
- Browser-style SSL Verification
|
||||
- Basic/Digest Authentication
|
||||
- Automatic Decompression
|
||||
- Connection Timeouts
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### Install with Composer
|
||||
If you're using [Composer](https://getcomposer.org/) to manage
|
||||
dependencies, you can add Requests with it.
|
||||
|
||||
```sh
|
||||
composer require rmccue/requests
|
||||
```
|
||||
|
||||
or
|
||||
```json
|
||||
{
|
||||
"require": {
|
||||
"rmccue/requests": "^2.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Install source from GitHub
|
||||
To install the source code:
|
||||
```bash
|
||||
$ git clone git://github.com/WordPress/Requests.git
|
||||
```
|
||||
|
||||
Next, include the autoloader in your scripts:
|
||||
```php
|
||||
require_once '/path/to/Requests/src/Autoload.php';
|
||||
```
|
||||
|
||||
You'll probably also want to register the autoloader:
|
||||
```php
|
||||
WpOrg\Requests\Autoload::register();
|
||||
```
|
||||
|
||||
### Install source from zip/tarball
|
||||
Alternatively, you can fetch a [tarball][] or [zipball][]:
|
||||
|
||||
```bash
|
||||
$ curl -L https://github.com/WordPress/Requests/tarball/stable | tar xzv
|
||||
(or)
|
||||
$ wget https://github.com/WordPress/Requests/tarball/stable -O - | tar xzv
|
||||
```
|
||||
|
||||
[tarball]: https://github.com/WordPress/Requests/tarball/stable
|
||||
[zipball]: https://github.com/WordPress/Requests/zipball/stable
|
||||
|
||||
|
||||
### Using a Class Loader
|
||||
If you're using a class loader (e.g., [Symfony Class Loader][]) for
|
||||
[PSR-4][]-style class loading:
|
||||
```php
|
||||
$loader = new Psr4ClassLoader();
|
||||
$loader->addPrefix('WpOrg\\Requests\\', 'path/to/vendor/Requests/src');
|
||||
$loader->register();
|
||||
```
|
||||
|
||||
[Symfony Class Loader]: https://github.com/symfony/ClassLoader
|
||||
[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4.md
|
||||
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
The best place to start is our [prose-based documentation][], which will guide
|
||||
you through using Requests.
|
||||
|
||||
After that, take a look at [the documentation for
|
||||
`\WpOrg\Requests\Requests::request()`][request_method], where all the parameters are fully
|
||||
documented.
|
||||
|
||||
Requests is [100% documented with PHPDoc](https://requests.ryanmccue.info/api-2.x/).
|
||||
If you find any problems with it, [create a new
|
||||
issue](https://github.com/WordPress/Requests/issues/new)!
|
||||
|
||||
[prose-based documentation]: https://github.com/WordPress/Requests/blob/stable/docs/README.md
|
||||
[request_method]: https://requests.ryanmccue.info/api-2.x/classes/WpOrg-Requests-Requests.html#method_request
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
Requests strives to have 100% code-coverage of the library with an extensive
|
||||
set of tests. We're not quite there yet, but [we're getting close][codecov].
|
||||
|
||||
[codecov]: https://codecov.io/github/WordPress/Requests/
|
||||
|
||||
To run the test suite, first check that you have the [PHP
|
||||
JSON extension ](https://www.php.net/book.json) enabled. Then
|
||||
simply:
|
||||
```bash
|
||||
$ phpunit
|
||||
```
|
||||
|
||||
If you'd like to run a single set of tests, specify just the name:
|
||||
```bash
|
||||
$ phpunit Transport/cURL
|
||||
```
|
||||
|
||||
Contribute
|
||||
----------
|
||||
|
||||
1. Check for open issues or open a new issue for a feature request or a bug.
|
||||
2. Fork [the repository][] on Github to start making your changes to the
|
||||
`develop` branch (or branch off of it).
|
||||
3. Write one or more tests which show that the bug was fixed or that the feature works as expected.
|
||||
4. Send in a pull request.
|
||||
|
||||
If you have questions while working on your contribution and you use Slack, there is
|
||||
a [#core-http-api] channel available in the [WordPress Slack] in which contributions can be discussed.
|
||||
|
||||
[the repository]: https://github.com/WordPress/Requests
|
||||
[#core-http-api]: https://wordpress.slack.com/archives/C02BBE29V42
|
||||
[WordPress Slack]: https://make.wordpress.org/chat/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
6ed95025fba2aef0ce7b647607225745624497f876d74ef6ec22b26e73e9de77 cacert.pem
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"name": "rmccue/requests",
|
||||
"description": "A HTTP library written in PHP, for human beings.",
|
||||
"homepage": "https://requests.ryanmccue.info/",
|
||||
"license": "ISC",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"http",
|
||||
"idna",
|
||||
"iri",
|
||||
"ipv6",
|
||||
"curl",
|
||||
"sockets",
|
||||
"fsockopen"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Ryan McCue",
|
||||
"homepage": "https://rmccue.io/"
|
||||
},
|
||||
{
|
||||
"name": "Alain Schlesser",
|
||||
"homepage": "https://github.com/schlessera"
|
||||
},
|
||||
{
|
||||
"name": "Juliette Reinders Folmer",
|
||||
"homepage": "https://github.com/jrfnl"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/WordPress/Requests/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/WordPress/Requests/issues",
|
||||
"source": "https://github.com/WordPress/Requests",
|
||||
"docs": "https://requests.ryanmccue.info/"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"requests/test-server": "dev-main",
|
||||
"squizlabs/php_codesniffer": "^3.6",
|
||||
"phpcompatibility/php-compatibility": "^9.0",
|
||||
"wp-coding-standards/wpcs": "^2.0",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3.1",
|
||||
"php-parallel-lint/php-console-highlighter": "^0.5.0",
|
||||
"yoast/phpunit-polyfills": "^1.0.0",
|
||||
"roave/security-advisories": "dev-latest"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"WpOrg\\Requests\\": "src/"
|
||||
},
|
||||
"classmap": ["library/Requests.php"],
|
||||
"files": ["library/Deprecated.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"WpOrg\\Requests\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"lint": [
|
||||
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
|
||||
],
|
||||
"checkcs": [
|
||||
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
|
||||
],
|
||||
"fixcs": [
|
||||
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
|
||||
],
|
||||
"test": [
|
||||
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
|
||||
],
|
||||
"coverage": [
|
||||
"@php ./vendor/phpunit/phpunit/phpunit"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Backwards compatibility layer for Requests.
|
||||
*
|
||||
* Allows for Composer to autoload the old PSR-0 classes via the custom autoloader.
|
||||
* This prevents issues with _extending final classes_ (which was the previous solution).
|
||||
*
|
||||
* Please see the Changelog for the 2.0.0 release for upgrade notes.
|
||||
*
|
||||
* @package Requests
|
||||
*
|
||||
* @deprecated 2.0.0 Use the PSR-4 class names instead.
|
||||
*/
|
||||
|
||||
if (class_exists('WpOrg\Requests\Autoload') === false) {
|
||||
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
|
||||
}
|
||||
|
||||
WpOrg\Requests\Autoload::register();
|
||||
@@ -0,0 +1,6 @@
|
||||
## The Library directory is deprecated.
|
||||
|
||||
The files in this directory are only still in place to provide backward compatibility with Requests 1.x.
|
||||
Please see the release notes of Requests 2.0.0 on how to upgrade.
|
||||
|
||||
This directory will be removed in Requests v 4.0.0.
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Requests for PHP
|
||||
*
|
||||
* Inspired by Requests for Python.
|
||||
*
|
||||
* Based on concepts from SimplePie_File, RequestCore and WP_Http.
|
||||
*
|
||||
* @package Requests
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Integrators who cannot yet upgrade to the PSR-4 class names can silence deprecations
|
||||
* by defining a `REQUESTS_SILENCE_PSR0_DEPRECATIONS` constant and setting it to `true`.
|
||||
* The constant needs to be defined before this class is required.
|
||||
*/
|
||||
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS') || REQUESTS_SILENCE_PSR0_DEPRECATIONS !== true) {
|
||||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
|
||||
trigger_error(
|
||||
'The PSR-0 `Requests_...` class names in the Request library are deprecated.'
|
||||
. ' Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
// Prevent the deprecation notice from being thrown twice.
|
||||
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
|
||||
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
|
||||
}
|
||||
}
|
||||
|
||||
require_once dirname(__DIR__) . '/src/Requests.php'; // nosemgrep : https://semgrep.dev/s/e5El
|
||||
|
||||
/**
|
||||
* Requests for PHP
|
||||
*
|
||||
* Inspired by Requests for Python.
|
||||
*
|
||||
* Based on concepts from SimplePie_File, RequestCore and WP_Http.
|
||||
*
|
||||
* @package Requests
|
||||
*
|
||||
* @deprecated 2.0.0 Use `WpOrg\Requests\Requests` instead for the actual functionality and
|
||||
* use `WpOrg\Requests\Autoload` for the autoloading.
|
||||
*/
|
||||
class Requests extends WpOrg\Requests\Requests {
|
||||
|
||||
/**
|
||||
* Deprecated autoloader for Requests.
|
||||
*
|
||||
* @deprecated 2.0.0 Use the `WpOrg\Requests\Autoload::load()` method instead.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $class Class name to load
|
||||
*/
|
||||
public static function autoloader($class) {
|
||||
if (class_exists('WpOrg\Requests\Autoload') === false) {
|
||||
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
|
||||
}
|
||||
|
||||
return WpOrg\Requests\Autoload::load($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the built-in autoloader
|
||||
*
|
||||
* @deprecated 2.0.0 Include the `WpOrg\Requests\Autoload` class and
|
||||
* call `WpOrg\Requests\Autoload::register()` instead.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function register_autoloader() {
|
||||
require_once dirname(__DIR__) . '/src/Autoload.php'; // nosemgrep : https://semgrep.dev/s/e5El
|
||||
WpOrg\Requests\Autoload::register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Authentication provider interface
|
||||
*
|
||||
* @package Requests\Authentication
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests;
|
||||
|
||||
use WpOrg\Requests\Hooks;
|
||||
|
||||
/**
|
||||
* Authentication provider interface
|
||||
*
|
||||
* Implement this interface to act as an authentication provider.
|
||||
*
|
||||
* Parameters should be passed via the constructor where possible, as this
|
||||
* makes it much easier for users to use your provider.
|
||||
*
|
||||
* @see \WpOrg\Requests\Hooks
|
||||
*
|
||||
* @package Requests\Authentication
|
||||
*/
|
||||
interface Auth {
|
||||
/**
|
||||
* Register hooks as needed
|
||||
*
|
||||
* This method is called in {@see \WpOrg\Requests\Requests::request()} when the user
|
||||
* has set an instance as the 'auth' option. Use this callback to register all the
|
||||
* hooks you'll need.
|
||||
*
|
||||
* @see \WpOrg\Requests\Hooks::register()
|
||||
* @param \WpOrg\Requests\Hooks $hooks Hook system
|
||||
*/
|
||||
public function register(Hooks $hooks);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Basic Authentication provider
|
||||
*
|
||||
* @package Requests\Authentication
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Auth;
|
||||
|
||||
use WpOrg\Requests\Auth;
|
||||
use WpOrg\Requests\Exception\ArgumentCount;
|
||||
use WpOrg\Requests\Exception\InvalidArgument;
|
||||
use WpOrg\Requests\Hooks;
|
||||
|
||||
/**
|
||||
* Basic Authentication provider
|
||||
*
|
||||
* Provides a handler for Basic HTTP authentication via the Authorization
|
||||
* header.
|
||||
*
|
||||
* @package Requests\Authentication
|
||||
*/
|
||||
class Basic implements Auth {
|
||||
/**
|
||||
* Username
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Password
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $pass;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 2.0 Throws an `InvalidArgument` exception.
|
||||
* @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception.
|
||||
*
|
||||
* @param array|null $args Array of user and password. Must have exactly two elements
|
||||
*
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null.
|
||||
* @throws \WpOrg\Requests\Exception\ArgumentCount On incorrect number of array elements (`authbasicbadargs`).
|
||||
*/
|
||||
public function __construct($args = null) {
|
||||
if (is_array($args)) {
|
||||
if (count($args) !== 2) {
|
||||
throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs');
|
||||
}
|
||||
|
||||
list($this->user, $this->pass) = $args;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($args !== null) {
|
||||
throw InvalidArgument::create(1, '$args', 'array|null', gettype($args));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the necessary callbacks
|
||||
*
|
||||
* @see \WpOrg\Requests\Auth\Basic::curl_before_send()
|
||||
* @see \WpOrg\Requests\Auth\Basic::fsockopen_header()
|
||||
* @param \WpOrg\Requests\Hooks $hooks Hook system
|
||||
*/
|
||||
public function register(Hooks $hooks) {
|
||||
$hooks->register('curl.before_send', [$this, 'curl_before_send']);
|
||||
$hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cURL parameters before the data is sent
|
||||
*
|
||||
* @param resource|\CurlHandle $handle cURL handle
|
||||
*/
|
||||
public function curl_before_send(&$handle) {
|
||||
curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($handle, CURLOPT_USERPWD, $this->getAuthString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add extra headers to the request before sending
|
||||
*
|
||||
* @param string $out HTTP header string
|
||||
*/
|
||||
public function fsockopen_header(&$out) {
|
||||
$out .= sprintf("Authorization: Basic %s\r\n", base64_encode($this->getAuthString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authentication string (user:pass)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthString() {
|
||||
return $this->user . ':' . $this->pass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* Autoloader for Requests for PHP.
|
||||
*
|
||||
* Include this file if you'd like to avoid having to create your own autoloader.
|
||||
*
|
||||
* @package Requests
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests;
|
||||
|
||||
/*
|
||||
* Ensure the autoloader is only declared once.
|
||||
* This safeguard is in place as this is the typical entry point for this library
|
||||
* and this file being required unconditionally could easily cause
|
||||
* fatal "Class already declared" errors.
|
||||
*/
|
||||
if (class_exists('WpOrg\Requests\Autoload') === false) {
|
||||
|
||||
/**
|
||||
* Autoloader for Requests for PHP.
|
||||
*
|
||||
* This autoloader supports the PSR-4 based Requests 2.0.0 classes in a case-sensitive manner
|
||||
* as the most common server OS-es are case-sensitive and the file names are in mixed case.
|
||||
*
|
||||
* For the PSR-0 Requests 1.x BC-layer, requested classes will be treated case-insensitively.
|
||||
*
|
||||
* @package Requests
|
||||
*/
|
||||
final class Autoload {
|
||||
|
||||
/**
|
||||
* List of the old PSR-0 class names in lowercase as keys with their PSR-4 case-sensitive name as a value.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $deprecated_classes = [
|
||||
// Interfaces.
|
||||
'requests_auth' => '\WpOrg\Requests\Auth',
|
||||
'requests_hooker' => '\WpOrg\Requests\HookManager',
|
||||
'requests_proxy' => '\WpOrg\Requests\Proxy',
|
||||
'requests_transport' => '\WpOrg\Requests\Transport',
|
||||
|
||||
// Classes.
|
||||
'requests_cookie' => '\WpOrg\Requests\Cookie',
|
||||
'requests_exception' => '\WpOrg\Requests\Exception',
|
||||
'requests_hooks' => '\WpOrg\Requests\Hooks',
|
||||
'requests_idnaencoder' => '\WpOrg\Requests\IdnaEncoder',
|
||||
'requests_ipv6' => '\WpOrg\Requests\Ipv6',
|
||||
'requests_iri' => '\WpOrg\Requests\Iri',
|
||||
'requests_response' => '\WpOrg\Requests\Response',
|
||||
'requests_session' => '\WpOrg\Requests\Session',
|
||||
'requests_ssl' => '\WpOrg\Requests\Ssl',
|
||||
'requests_auth_basic' => '\WpOrg\Requests\Auth\Basic',
|
||||
'requests_cookie_jar' => '\WpOrg\Requests\Cookie\Jar',
|
||||
'requests_proxy_http' => '\WpOrg\Requests\Proxy\Http',
|
||||
'requests_response_headers' => '\WpOrg\Requests\Response\Headers',
|
||||
'requests_transport_curl' => '\WpOrg\Requests\Transport\Curl',
|
||||
'requests_transport_fsockopen' => '\WpOrg\Requests\Transport\Fsockopen',
|
||||
'requests_utility_caseinsensitivedictionary' => '\WpOrg\Requests\Utility\CaseInsensitiveDictionary',
|
||||
'requests_utility_filterediterator' => '\WpOrg\Requests\Utility\FilteredIterator',
|
||||
'requests_exception_http' => '\WpOrg\Requests\Exception\Http',
|
||||
'requests_exception_transport' => '\WpOrg\Requests\Exception\Transport',
|
||||
'requests_exception_transport_curl' => '\WpOrg\Requests\Exception\Transport\Curl',
|
||||
'requests_exception_http_304' => '\WpOrg\Requests\Exception\Http\Status304',
|
||||
'requests_exception_http_305' => '\WpOrg\Requests\Exception\Http\Status305',
|
||||
'requests_exception_http_306' => '\WpOrg\Requests\Exception\Http\Status306',
|
||||
'requests_exception_http_400' => '\WpOrg\Requests\Exception\Http\Status400',
|
||||
'requests_exception_http_401' => '\WpOrg\Requests\Exception\Http\Status401',
|
||||
'requests_exception_http_402' => '\WpOrg\Requests\Exception\Http\Status402',
|
||||
'requests_exception_http_403' => '\WpOrg\Requests\Exception\Http\Status403',
|
||||
'requests_exception_http_404' => '\WpOrg\Requests\Exception\Http\Status404',
|
||||
'requests_exception_http_405' => '\WpOrg\Requests\Exception\Http\Status405',
|
||||
'requests_exception_http_406' => '\WpOrg\Requests\Exception\Http\Status406',
|
||||
'requests_exception_http_407' => '\WpOrg\Requests\Exception\Http\Status407',
|
||||
'requests_exception_http_408' => '\WpOrg\Requests\Exception\Http\Status408',
|
||||
'requests_exception_http_409' => '\WpOrg\Requests\Exception\Http\Status409',
|
||||
'requests_exception_http_410' => '\WpOrg\Requests\Exception\Http\Status410',
|
||||
'requests_exception_http_411' => '\WpOrg\Requests\Exception\Http\Status411',
|
||||
'requests_exception_http_412' => '\WpOrg\Requests\Exception\Http\Status412',
|
||||
'requests_exception_http_413' => '\WpOrg\Requests\Exception\Http\Status413',
|
||||
'requests_exception_http_414' => '\WpOrg\Requests\Exception\Http\Status414',
|
||||
'requests_exception_http_415' => '\WpOrg\Requests\Exception\Http\Status415',
|
||||
'requests_exception_http_416' => '\WpOrg\Requests\Exception\Http\Status416',
|
||||
'requests_exception_http_417' => '\WpOrg\Requests\Exception\Http\Status417',
|
||||
'requests_exception_http_418' => '\WpOrg\Requests\Exception\Http\Status418',
|
||||
'requests_exception_http_428' => '\WpOrg\Requests\Exception\Http\Status428',
|
||||
'requests_exception_http_429' => '\WpOrg\Requests\Exception\Http\Status429',
|
||||
'requests_exception_http_431' => '\WpOrg\Requests\Exception\Http\Status431',
|
||||
'requests_exception_http_500' => '\WpOrg\Requests\Exception\Http\Status500',
|
||||
'requests_exception_http_501' => '\WpOrg\Requests\Exception\Http\Status501',
|
||||
'requests_exception_http_502' => '\WpOrg\Requests\Exception\Http\Status502',
|
||||
'requests_exception_http_503' => '\WpOrg\Requests\Exception\Http\Status503',
|
||||
'requests_exception_http_504' => '\WpOrg\Requests\Exception\Http\Status504',
|
||||
'requests_exception_http_505' => '\WpOrg\Requests\Exception\Http\Status505',
|
||||
'requests_exception_http_511' => '\WpOrg\Requests\Exception\Http\Status511',
|
||||
'requests_exception_http_unknown' => '\WpOrg\Requests\Exception\Http\StatusUnknown',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the autoloader.
|
||||
*
|
||||
* Note: the autoloader is *prepended* in the autoload queue.
|
||||
* This is done to ensure that the Requests 2.0 autoloader takes precedence
|
||||
* over a potentially (dependency-registered) Requests 1.x autoloader.
|
||||
*
|
||||
* @internal This method contains a safeguard against the autoloader being
|
||||
* registered multiple times. This safeguard uses a global constant to
|
||||
* (hopefully/in most cases) still function correctly, even if the
|
||||
* class would be renamed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register() {
|
||||
if (defined('REQUESTS_AUTOLOAD_REGISTERED') === false) {
|
||||
spl_autoload_register([self::class, 'load'], true);
|
||||
define('REQUESTS_AUTOLOAD_REGISTERED', true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoloader.
|
||||
*
|
||||
* @param string $class_name Name of the class name to load.
|
||||
*
|
||||
* @return bool Whether a class was loaded or not.
|
||||
*/
|
||||
public static function load($class_name) {
|
||||
// Check that the class starts with "Requests" (PSR-0) or "WpOrg\Requests" (PSR-4).
|
||||
$psr_4_prefix_pos = strpos($class_name, 'WpOrg\\Requests\\');
|
||||
|
||||
if (stripos($class_name, 'Requests') !== 0 && $psr_4_prefix_pos !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$class_lower = strtolower($class_name);
|
||||
|
||||
if ($class_lower === 'requests') {
|
||||
// Reference to the original PSR-0 Requests class.
|
||||
$file = dirname(__DIR__) . '/library/Requests.php';
|
||||
} elseif ($psr_4_prefix_pos === 0) {
|
||||
// PSR-4 classname.
|
||||
$file = __DIR__ . '/' . strtr(substr($class_name, 15), '\\', '/') . '.php';
|
||||
}
|
||||
|
||||
if (isset($file) && file_exists($file)) {
|
||||
include $file; // nosemgrep : https://semgrep.dev/s/e5El
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Okay, so the class starts with "Requests", but we couldn't find the file.
|
||||
* If this is one of the deprecated/renamed PSR-0 classes being requested,
|
||||
* let's alias it to the new name and throw a deprecation notice.
|
||||
*/
|
||||
if (isset(self::$deprecated_classes[$class_lower])) {
|
||||
/*
|
||||
* Integrators who cannot yet upgrade to the PSR-4 class names can silence deprecations
|
||||
* by defining a `REQUESTS_SILENCE_PSR0_DEPRECATIONS` constant and setting it to `true`.
|
||||
* The constant needs to be defined before the first deprecated class is requested
|
||||
* via this autoloader.
|
||||
*/
|
||||
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS') || REQUESTS_SILENCE_PSR0_DEPRECATIONS !== true) {
|
||||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
|
||||
trigger_error(
|
||||
'The PSR-0 `Requests_...` class names in the Request library are deprecated.'
|
||||
. ' Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
// Prevent the deprecation notice from being thrown twice.
|
||||
if (!defined('REQUESTS_SILENCE_PSR0_DEPRECATIONS')) {
|
||||
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an alias and let the autoloader recursively kick in to load the PSR-4 class.
|
||||
return class_alias(self::$deprecated_classes[$class_lower], $class_name, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Capability interface declaring the known capabilities.
|
||||
*
|
||||
* @package Requests\Utilities
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests;
|
||||
|
||||
/**
|
||||
* Capability interface declaring the known capabilities.
|
||||
*
|
||||
* This is used as the authoritative source for which capabilities can be queried.
|
||||
*
|
||||
* @package Requests\Utilities
|
||||
*/
|
||||
interface Capability {
|
||||
|
||||
/**
|
||||
* Support for SSL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SSL = 'ssl';
|
||||
|
||||
/**
|
||||
* Collection of all capabilities supported in Requests.
|
||||
*
|
||||
* Note: this does not automatically mean that the capability will be supported for your chosen transport!
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
const ALL = [
|
||||
self::SSL,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,522 @@
|
||||
<?php
|
||||
/**
|
||||
* Cookie storage object
|
||||
*
|
||||
* @package Requests\Cookies
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests;
|
||||
|
||||
use WpOrg\Requests\Exception\InvalidArgument;
|
||||
use WpOrg\Requests\Iri;
|
||||
use WpOrg\Requests\Response\Headers;
|
||||
use WpOrg\Requests\Utility\CaseInsensitiveDictionary;
|
||||
use WpOrg\Requests\Utility\InputValidator;
|
||||
|
||||
/**
|
||||
* Cookie storage object
|
||||
*
|
||||
* @package Requests\Cookies
|
||||
*/
|
||||
class Cookie {
|
||||
/**
|
||||
* Cookie name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Cookie value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Cookie attributes
|
||||
*
|
||||
* Valid keys are (currently) path, domain, expires, max-age, secure and
|
||||
* httponly.
|
||||
*
|
||||
* @var \WpOrg\Requests\Utility\CaseInsensitiveDictionary|array Array-like object
|
||||
*/
|
||||
public $attributes = [];
|
||||
|
||||
/**
|
||||
* Cookie flags
|
||||
*
|
||||
* Valid keys are (currently) creation, last-access, persistent and
|
||||
* host-only.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $flags = [];
|
||||
|
||||
/**
|
||||
* Reference time for relative calculations
|
||||
*
|
||||
* This is used in place of `time()` when calculating Max-Age expiration and
|
||||
* checking time validity.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $reference_time = 0;
|
||||
|
||||
/**
|
||||
* Create a new cookie object
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array|\WpOrg\Requests\Utility\CaseInsensitiveDictionary $attributes Associative array of attribute data
|
||||
* @param array $flags
|
||||
* @param int|null $reference_time
|
||||
*
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $name argument is not a string.
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $value argument is not a string.
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $attributes argument is not an array or iterable object with array access.
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $flags argument is not an array.
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $reference_time argument is not an integer or null.
|
||||
*/
|
||||
public function __construct($name, $value, $attributes = [], $flags = [], $reference_time = null) {
|
||||
if (is_string($name) === false) {
|
||||
throw InvalidArgument::create(1, '$name', 'string', gettype($name));
|
||||
}
|
||||
|
||||
if (is_string($value) === false) {
|
||||
throw InvalidArgument::create(2, '$value', 'string', gettype($value));
|
||||
}
|
||||
|
||||
if (InputValidator::has_array_access($attributes) === false || InputValidator::is_iterable($attributes) === false) {
|
||||
throw InvalidArgument::create(3, '$attributes', 'array|ArrayAccess&Traversable', gettype($attributes));
|
||||
}
|
||||
|
||||
if (is_array($flags) === false) {
|
||||
throw InvalidArgument::create(4, '$flags', 'array', gettype($flags));
|
||||
}
|
||||
|
||||
if ($reference_time !== null && is_int($reference_time) === false) {
|
||||
throw InvalidArgument::create(5, '$reference_time', 'integer|null', gettype($reference_time));
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
$this->attributes = $attributes;
|
||||
$default_flags = [
|
||||
'creation' => time(),
|
||||
'last-access' => time(),
|
||||
'persistent' => false,
|
||||
'host-only' => true,
|
||||
];
|
||||
$this->flags = array_merge($default_flags, $flags);
|
||||
|
||||
$this->reference_time = time();
|
||||
if ($reference_time !== null) {
|
||||
$this->reference_time = $reference_time;
|
||||
}
|
||||
|
||||
$this->normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie value
|
||||
*
|
||||
* Attributes and other data can be accessed via methods.
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie is expired.
|
||||
*
|
||||
* Checks the age against $this->reference_time to determine if the cookie
|
||||
* is expired.
|
||||
*
|
||||
* @return boolean True if expired, false if time is valid.
|
||||
*/
|
||||
public function is_expired() {
|
||||
// RFC6265, s. 4.1.2.2:
|
||||
// If a cookie has both the Max-Age and the Expires attribute, the Max-
|
||||
// Age attribute has precedence and controls the expiration date of the
|
||||
// cookie.
|
||||
if (isset($this->attributes['max-age'])) {
|
||||
$max_age = $this->attributes['max-age'];
|
||||
return $max_age < $this->reference_time;
|
||||
}
|
||||
|
||||
if (isset($this->attributes['expires'])) {
|
||||
$expires = $this->attributes['expires'];
|
||||
return $expires < $this->reference_time;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie is valid for a given URI
|
||||
*
|
||||
* @param \WpOrg\Requests\Iri $uri URI to check
|
||||
* @return boolean Whether the cookie is valid for the given URI
|
||||
*/
|
||||
public function uri_matches(Iri $uri) {
|
||||
if (!$this->domain_matches($uri->host)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->path_matches($uri->path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return empty($this->attributes['secure']) || $uri->scheme === 'https';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie is valid for a given domain
|
||||
*
|
||||
* @param string $domain Domain to check
|
||||
* @return boolean Whether the cookie is valid for the given domain
|
||||
*/
|
||||
public function domain_matches($domain) {
|
||||
if (is_string($domain) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->attributes['domain'])) {
|
||||
// Cookies created manually; cookies created by Requests will set
|
||||
// the domain to the requested domain
|
||||
return true;
|
||||
}
|
||||
|
||||
$cookie_domain = $this->attributes['domain'];
|
||||
if ($cookie_domain === $domain) {
|
||||
// The cookie domain and the passed domain are identical.
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the cookie is marked as host-only and we don't have an exact
|
||||
// match, reject the cookie
|
||||
if ($this->flags['host-only'] === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen($domain) <= strlen($cookie_domain)) {
|
||||
// For obvious reasons, the cookie domain cannot be a suffix if the passed domain
|
||||
// is shorter than the cookie domain
|
||||
return false;
|
||||
}
|
||||
|
||||
if (substr($domain, -1 * strlen($cookie_domain)) !== $cookie_domain) {
|
||||
// The cookie domain should be a suffix of the passed domain.
|
||||
return false;
|
||||
}
|
||||
|
||||
$prefix = substr($domain, 0, strlen($domain) - strlen($cookie_domain));
|
||||
if (substr($prefix, -1) !== '.') {
|
||||
// The last character of the passed domain that is not included in the
|
||||
// domain string should be a %x2E (".") character.
|
||||
return false;
|
||||
}
|
||||
|
||||
// The passed domain should be a host name (i.e., not an IP address).
|
||||
return !preg_match('#^(.+\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cookie is valid for a given path
|
||||
*
|
||||
* From the path-match check in RFC 6265 section 5.1.4
|
||||
*
|
||||
* @param string $request_path Path to check
|
||||
* @return boolean Whether the cookie is valid for the given path
|
||||
*/
|
||||
public function path_matches($request_path) {
|
||||
if (empty($request_path)) {
|
||||
// Normalize empty path to root
|
||||
$request_path = '/';
|
||||
}
|
||||
|
||||
if (!isset($this->attributes['path'])) {
|
||||
// Cookies created manually; cookies created by Requests will set
|
||||
// the path to the requested path
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_scalar($request_path) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cookie_path = $this->attributes['path'];
|
||||
|
||||
if ($cookie_path === $request_path) {
|
||||
// The cookie-path and the request-path are identical.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) {
|
||||
if (substr($cookie_path, -1) === '/') {
|
||||
// The cookie-path is a prefix of the request-path, and the last
|
||||
// character of the cookie-path is %x2F ("/").
|
||||
return true;
|
||||
}
|
||||
|
||||
if (substr($request_path, strlen($cookie_path), 1) === '/') {
|
||||
// The cookie-path is a prefix of the request-path, and the
|
||||
// first character of the request-path that is not included in
|
||||
// the cookie-path is a %x2F ("/") character.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize cookie and attributes
|
||||
*
|
||||
* @return boolean Whether the cookie was successfully normalized
|
||||
*/
|
||||
public function normalize() {
|
||||
foreach ($this->attributes as $key => $value) {
|
||||
$orig_value = $value;
|
||||
$value = $this->normalize_attribute($key, $value);
|
||||
if ($value === null) {
|
||||
unset($this->attributes[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value !== $orig_value) {
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an individual cookie attribute
|
||||
*
|
||||
* Handles parsing individual attributes from the cookie values.
|
||||
*
|
||||
* @param string $name Attribute name
|
||||
* @param string|boolean $value Attribute value (string value, or true if empty/flag)
|
||||
* @return mixed Value if available, or null if the attribute value is invalid (and should be skipped)
|
||||
*/
|
||||
protected function normalize_attribute($name, $value) {
|
||||
switch (strtolower($name)) {
|
||||
case 'expires':
|
||||
// Expiration parsing, as per RFC 6265 section 5.2.1
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$expiry_time = strtotime($value);
|
||||
if ($expiry_time === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $expiry_time;
|
||||
|
||||
case 'max-age':
|
||||
// Expiration parsing, as per RFC 6265 section 5.2.2
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Check that we have a valid age
|
||||
if (!preg_match('/^-?\d+$/', $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$delta_seconds = (int) $value;
|
||||
if ($delta_seconds <= 0) {
|
||||
$expiry_time = 0;
|
||||
} else {
|
||||
$expiry_time = $this->reference_time + $delta_seconds;
|
||||
}
|
||||
|
||||
return $expiry_time;
|
||||
|
||||
case 'domain':
|
||||
// Domains are not required as per RFC 6265 section 5.2.3
|
||||
if (empty($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Domain normalization, as per RFC 6265 section 5.2.3
|
||||
if ($value[0] === '.') {
|
||||
$value = substr($value, 1);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a cookie for a Cookie header
|
||||
*
|
||||
* This is used when sending cookies to a server.
|
||||
*
|
||||
* @return string Cookie formatted for Cookie header
|
||||
*/
|
||||
public function format_for_header() {
|
||||
return sprintf('%s=%s', $this->name, $this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a cookie for a Set-Cookie header
|
||||
*
|
||||
* This is used when sending cookies to clients. This isn't really
|
||||
* applicable to client-side usage, but might be handy for debugging.
|
||||
*
|
||||
* @return string Cookie formatted for Set-Cookie header
|
||||
*/
|
||||
public function format_for_set_cookie() {
|
||||
$header_value = $this->format_for_header();
|
||||
if (!empty($this->attributes)) {
|
||||
$parts = [];
|
||||
foreach ($this->attributes as $key => $value) {
|
||||
// Ignore non-associative attributes
|
||||
if (is_numeric($key)) {
|
||||
$parts[] = $value;
|
||||
} else {
|
||||
$parts[] = sprintf('%s=%s', $key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$header_value .= '; ' . implode('; ', $parts);
|
||||
}
|
||||
|
||||
return $header_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a cookie string into a cookie object
|
||||
*
|
||||
* Based on Mozilla's parsing code in Firefox and related projects, which
|
||||
* is an intentional deviation from RFC 2109 and RFC 2616. RFC 6265
|
||||
* specifies some of this handling, but not in a thorough manner.
|
||||
*
|
||||
* @param string $cookie_header Cookie header value (from a Set-Cookie header)
|
||||
* @param string $name
|
||||
* @param int|null $reference_time
|
||||
* @return \WpOrg\Requests\Cookie Parsed cookie object
|
||||
*
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $cookie_header argument is not a string.
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $name argument is not a string.
|
||||
*/
|
||||
public static function parse($cookie_header, $name = '', $reference_time = null) {
|
||||
if (is_string($cookie_header) === false) {
|
||||
throw InvalidArgument::create(1, '$cookie_header', 'string', gettype($cookie_header));
|
||||
}
|
||||
|
||||
if (is_string($name) === false) {
|
||||
throw InvalidArgument::create(2, '$name', 'string', gettype($name));
|
||||
}
|
||||
|
||||
$parts = explode(';', $cookie_header);
|
||||
$kvparts = array_shift($parts);
|
||||
|
||||
if (!empty($name)) {
|
||||
$value = $cookie_header;
|
||||
} elseif (strpos($kvparts, '=') === false) {
|
||||
// Some sites might only have a value without the equals separator.
|
||||
// Deviate from RFC 6265 and pretend it was actually a blank name
|
||||
// (`=foo`)
|
||||
//
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=169091
|
||||
$name = '';
|
||||
$value = $kvparts;
|
||||
} else {
|
||||
list($name, $value) = explode('=', $kvparts, 2);
|
||||
}
|
||||
|
||||
$name = trim($name);
|
||||
$value = trim($value);
|
||||
|
||||
// Attribute keys are handled case-insensitively
|
||||
$attributes = new CaseInsensitiveDictionary();
|
||||
|
||||
if (!empty($parts)) {
|
||||
foreach ($parts as $part) {
|
||||
if (strpos($part, '=') === false) {
|
||||
$part_key = $part;
|
||||
$part_value = true;
|
||||
} else {
|
||||
list($part_key, $part_value) = explode('=', $part, 2);
|
||||
$part_value = trim($part_value);
|
||||
}
|
||||
|
||||
$part_key = trim($part_key);
|
||||
$attributes[$part_key] = $part_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new static($name, $value, $attributes, [], $reference_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse all Set-Cookie headers from request headers
|
||||
*
|
||||
* @param \WpOrg\Requests\Response\Headers $headers Headers to parse from
|
||||
* @param \WpOrg\Requests\Iri|null $origin URI for comparing cookie origins
|
||||
* @param int|null $time Reference time for expiration calculation
|
||||
* @return array
|
||||
*/
|
||||
public static function parse_from_headers(Headers $headers, Iri $origin = null, $time = null) {
|
||||
$cookie_headers = $headers->getValues('Set-Cookie');
|
||||
if (empty($cookie_headers)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cookies = [];
|
||||
foreach ($cookie_headers as $header) {
|
||||
$parsed = self::parse($header, '', $time);
|
||||
|
||||
// Default domain/path attributes
|
||||
if (empty($parsed->attributes['domain']) && !empty($origin)) {
|
||||
$parsed->attributes['domain'] = $origin->host;
|
||||
$parsed->flags['host-only'] = true;
|
||||
} else {
|
||||
$parsed->flags['host-only'] = false;
|
||||
}
|
||||
|
||||
$path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/');
|
||||
if (!$path_is_valid && !empty($origin)) {
|
||||
$path = $origin->path;
|
||||
|
||||
// Default path normalization as per RFC 6265 section 5.1.4
|
||||
if (substr($path, 0, 1) !== '/') {
|
||||
// If the uri-path is empty or if the first character of
|
||||
// the uri-path is not a %x2F ("/") character, output
|
||||
// %x2F ("/") and skip the remaining steps.
|
||||
$path = '/';
|
||||
} elseif (substr_count($path, '/') === 1) {
|
||||
// If the uri-path contains no more than one %x2F ("/")
|
||||
// character, output %x2F ("/") and skip the remaining
|
||||
// step.
|
||||
$path = '/';
|
||||
} else {
|
||||
// Output the characters of the uri-path from the first
|
||||
// character up to, but not including, the right-most
|
||||
// %x2F ("/").
|
||||
$path = substr($path, 0, strrpos($path, '/'));
|
||||
}
|
||||
|
||||
$parsed->attributes['path'] = $path;
|
||||
}
|
||||
|
||||
// Reject invalid cookie domains
|
||||
if (!empty($origin) && !$parsed->domain_matches($origin->host)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cookies[$parsed->name] = $parsed;
|
||||
}
|
||||
|
||||
return $cookies;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* Cookie holder object
|
||||
*
|
||||
* @package Requests\Cookies
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Cookie;
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayIterator;
|
||||
use IteratorAggregate;
|
||||
use ReturnTypeWillChange;
|
||||
use WpOrg\Requests\Cookie;
|
||||
use WpOrg\Requests\Exception;
|
||||
use WpOrg\Requests\Exception\InvalidArgument;
|
||||
use WpOrg\Requests\HookManager;
|
||||
use WpOrg\Requests\Iri;
|
||||
use WpOrg\Requests\Response;
|
||||
|
||||
/**
|
||||
* Cookie holder object
|
||||
*
|
||||
* @package Requests\Cookies
|
||||
*/
|
||||
class Jar implements ArrayAccess, IteratorAggregate {
|
||||
/**
|
||||
* Actual item data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cookies = [];
|
||||
|
||||
/**
|
||||
* Create a new jar
|
||||
*
|
||||
* @param array $cookies Existing cookie values
|
||||
*
|
||||
* @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array.
|
||||
*/
|
||||
public function __construct($cookies = []) {
|
||||
if (is_array($cookies) === false) {
|
||||
throw InvalidArgument::create(1, '$cookies', 'array', gettype($cookies));
|
||||
}
|
||||
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalise cookie data into a \WpOrg\Requests\Cookie
|
||||
*
|
||||
* @param string|\WpOrg\Requests\Cookie $cookie
|
||||
* @return \WpOrg\Requests\Cookie
|
||||
*/
|
||||
public function normalize_cookie($cookie, $key = '') {
|
||||
if ($cookie instanceof Cookie) {
|
||||
return $cookie;
|
||||
}
|
||||
|
||||
return Cookie::parse($cookie, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given item exists
|
||||
*
|
||||
* @param string $offset Item key
|
||||
* @return boolean Does the item exist?
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->cookies[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for the item
|
||||
*
|
||||
* @param string $offset Item key
|
||||
* @return string|null Item value (null if offsetExists is false)
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet($offset) {
|
||||
if (!isset($this->cookies[$offset])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->cookies[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given item
|
||||
*
|
||||
* @param string $offset Item name
|
||||
* @param string $value Item value
|
||||
*
|
||||
* @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value) {
|
||||
if ($offset === null) {
|
||||
throw new Exception('Object is a dictionary, not a list', 'invalidset');
|
||||
}
|
||||
|
||||
$this->cookies[$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the given header
|
||||
*
|
||||
* @param string $offset
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->cookies[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator for the data
|
||||
*
|
||||
* @return \ArrayIterator
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getIterator() {
|
||||
return new ArrayIterator($this->cookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the cookie handler with the request's hooking system
|
||||
*
|
||||
* @param \WpOrg\Requests\HookManager $hooks Hooking system
|
||||
*/
|
||||
public function register(HookManager $hooks) {
|
||||
$hooks->register('requests.before_request', [$this, 'before_request']);
|
||||
$hooks->register('requests.before_redirect_check', [$this, 'before_redirect_check']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Cookie header to a request if we have any
|
||||
*
|
||||
* As per RFC 6265, cookies are separated by '; '
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $headers
|
||||
* @param array $data
|
||||
* @param string $type
|
||||
* @param array $options
|
||||
*/
|
||||
public function before_request($url, &$headers, &$data, &$type, &$options) {
|
||||
if (!$url instanceof Iri) {
|
||||
$url = new Iri($url);
|
||||
}
|
||||
|
||||
if (!empty($this->cookies)) {
|
||||
$cookies = [];
|
||||
foreach ($this->cookies as $key => $cookie) {
|
||||
$cookie = $this->normalize_cookie($cookie, $key);
|
||||
|
||||
// Skip expired cookies
|
||||
if ($cookie->is_expired()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($cookie->domain_matches($url->host)) {
|
||||
$cookies[] = $cookie->format_for_header();
|
||||
}
|
||||
}
|
||||
|
||||
$headers['Cookie'] = implode('; ', $cookies);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse all cookies from a response and attach them to the response
|
||||
*
|
||||
* @param \WpOrg\Requests\Response $response
|
||||
*/
|
||||
public function before_redirect_check(Response $response) {
|
||||
$url = $response->url;
|
||||
if (!$url instanceof Iri) {
|
||||
$url = new Iri($url);
|
||||
}
|
||||
|
||||
$cookies = Cookie::parse_from_headers($response->headers, $url);
|
||||
$this->cookies = array_merge($this->cookies, $cookies);
|
||||
$response->cookies = $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for HTTP requests
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests;
|
||||
|
||||
use Exception as PHPException;
|
||||
|
||||
/**
|
||||
* Exception for HTTP requests
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
class Exception extends PHPException {
|
||||
/**
|
||||
* Type of exception
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Data associated with the exception
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Create a new exception
|
||||
*
|
||||
* @param string $message Exception message
|
||||
* @param string $type Exception type
|
||||
* @param mixed $data Associated data
|
||||
* @param integer $code Exception numerical code, if applicable
|
||||
*/
|
||||
public function __construct($message, $type, $data = null, $code = 0) {
|
||||
parent::__construct($message, $code);
|
||||
|
||||
$this->type = $type;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@see \Exception::getCode()}, but a string code.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives any relevant data
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return mixed
|
||||
*/
|
||||
public function getData() {
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace WpOrg\Requests\Exception;
|
||||
|
||||
use WpOrg\Requests\Exception;
|
||||
|
||||
/**
|
||||
* Exception for when an incorrect number of arguments are passed to a method.
|
||||
*
|
||||
* Typically, this exception is used when all arguments for a method are optional,
|
||||
* but certain arguments need to be passed together, i.e. a method which can be called
|
||||
* with no arguments or with two arguments, but not with one argument.
|
||||
*
|
||||
* Along the same lines, this exception is also used if a method expects an array
|
||||
* with a certain number of elements and the provided number of elements does not comply.
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
* @since 2.0.0
|
||||
*/
|
||||
final class ArgumentCount extends Exception {
|
||||
|
||||
/**
|
||||
* Create a new argument count exception with a standardized text.
|
||||
*
|
||||
* @param string $expected The argument count expected as a phrase.
|
||||
* For example: `at least 2 arguments` or `exactly 1 argument`.
|
||||
* @param int $received The actual argument count received.
|
||||
* @param string $type Exception type.
|
||||
*
|
||||
* @return \WpOrg\Requests\Exception\ArgumentCount
|
||||
*/
|
||||
public static function create($expected, $received, $type) {
|
||||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
|
||||
$stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||
|
||||
return new self(
|
||||
sprintf(
|
||||
'%s::%s() expects %s, %d given',
|
||||
$stack[1]['class'],
|
||||
$stack[1]['function'],
|
||||
$expected,
|
||||
$received
|
||||
),
|
||||
$type
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception based on HTTP response
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception;
|
||||
|
||||
use WpOrg\Requests\Exception;
|
||||
use WpOrg\Requests\Exception\Http\StatusUnknown;
|
||||
|
||||
/**
|
||||
* Exception based on HTTP response
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
class Http extends Exception {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 0;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Unknown';
|
||||
|
||||
/**
|
||||
* Create a new exception
|
||||
*
|
||||
* There is no mechanism to pass in the status code, as this is set by the
|
||||
* subclass used. Reason phrases can vary, however.
|
||||
*
|
||||
* @param string|null $reason Reason phrase
|
||||
* @param mixed $data Associated data
|
||||
*/
|
||||
public function __construct($reason = null, $data = null) {
|
||||
if ($reason !== null) {
|
||||
$this->reason = $reason;
|
||||
}
|
||||
|
||||
$message = sprintf('%d %s', $this->code, $this->reason);
|
||||
parent::__construct($message, 'httpresponse', $data, $this->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getReason() {
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct exception class for a given error code
|
||||
*
|
||||
* @param int|bool $code HTTP status code, or false if unavailable
|
||||
* @return string Exception class name to use
|
||||
*/
|
||||
public static function get_class($code) {
|
||||
if (!$code) {
|
||||
return StatusUnknown::class;
|
||||
}
|
||||
|
||||
$class = sprintf('\WpOrg\Requests\Exception\Http\Status%d', $code);
|
||||
if (class_exists($class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return StatusUnknown::class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 304 Not Modified responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 304 Not Modified responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status304 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 304;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Not Modified';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 305 Use Proxy responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 305 Use Proxy responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status305 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 305;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Use Proxy';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 306 Switch Proxy responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 306 Switch Proxy responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status306 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 306;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Switch Proxy';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 400 Bad Request responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 400 Bad Request responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status400 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 400;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Bad Request';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 401 Unauthorized responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 401 Unauthorized responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status401 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 401;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Unauthorized';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 402 Payment Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 402 Payment Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status402 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 402;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Payment Required';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 403 Forbidden responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 403 Forbidden responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status403 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 403;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Forbidden';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 404 Not Found responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 404 Not Found responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status404 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 404;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Not Found';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 405 Method Not Allowed responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 405 Method Not Allowed responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status405 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 405;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Method Not Allowed';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 406 Not Acceptable responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 406 Not Acceptable responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status406 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 406;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Not Acceptable';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 407 Proxy Authentication Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 407 Proxy Authentication Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status407 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 407;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Proxy Authentication Required';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 408 Request Timeout responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 408 Request Timeout responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status408 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 408;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Request Timeout';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 409 Conflict responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 409 Conflict responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status409 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 409;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Conflict';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 410 Gone responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 410 Gone responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status410 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 410;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Gone';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception for 411 Length Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
|
||||
namespace WpOrg\Requests\Exception\Http;
|
||||
|
||||
use WpOrg\Requests\Exception\Http;
|
||||
|
||||
/**
|
||||
* Exception for 411 Length Required responses
|
||||
*
|
||||
* @package Requests\Exceptions
|
||||
*/
|
||||
final class Status411 extends Http {
|
||||
/**
|
||||
* HTTP status code
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $code = 411;
|
||||
|
||||
/**
|
||||
* Reason phrase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $reason = 'Length Required';
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user