php 通过添加验证来检查服务提供商是否可用,以防止在WordPress仪表板中预订相同的时间段
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 通过添加验证来检查服务提供商是否可用,以防止在WordPress仪表板中预订相同的时间段相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: Disallow Duplicate Booking
Plugin URI: https://premium.wpmudev.org/
Description: Don't allow same time slot booking
Author: Lindeni Mahlalela @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Disallow_Duplicate_Booking' ) ) {
class Disallow_Duplicate_Booking {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ){
self::$_instance = new Disallow_Duplicate_Booking();
}
return self::$_instance;
}
private function __construct() {
add_action( 'appointments_inline_edit', array( $this, 'is_worker_booked' ), 10, 2 );
}
public function is_worker_booked( $app_id, $data){
$worker_args = array(
'worker_id' => $data['worker'],
'service_id' => $data['service']
//,'location_id' => $location
);
$start = strtotime( $data['date'] . ' ' . $data['time']);
$service = appointments_get_service( $data['service'] );
$is_busy = apppointments_is_range_busy( $start, $start + ( $service->duration * 60 ), $worker_args );
if ( $is_busy ) {
$result = array(
'app_id' => $app_id,
'message' => '<strong style="color:red;">The service provider is not availble on the selected time slot.</strong>'
);
wp_send_json( $result );
}
}
}
add_action( 'plugins_loaded', 'app_disallow_duplaicate_booking' );
function app_disallow_duplaicate_booking(){
$GLOBALS['Disallow_Duplicate_Booking'] = Disallow_Duplicate_Booking::get_instance();
}
}
以上是关于php 通过添加验证来检查服务提供商是否可用,以防止在WordPress仪表板中预订相同的时间段的主要内容,如果未能解决你的问题,请参考以下文章
zabbix通过php脚本模拟业务访问redis验证nosql的可用性
MSMQ 在 Azure 上是不是可用
澳洲信用卡地址验证系统
通过java api验证SMTP服务器身份验证(包括AUTH的Healthcheck)
使用JWT身份验证缓存API请求
检查电子邮件跳出率?就像neverbounce做啥?