| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Calendar |
| 5 |
* @category A c t i v a t e & D e a c t i v a t e |
| 6 |
* @author wpdevelop |
| 7 |
* |
| 8 |
* @web-site https://wpbookingcalendar.com/ |
| 9 |
* @email info@wpbookingcalendar.com |
| 10 |
* @modified 2022-11-23 |
| 11 |
* |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; // Exit if accessed directly. |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* A c t i v a t e - Create new DB Table, for booking dates properties |
| 21 |
* |
| 22 |
* booking date property can be relative to: prop_name = 'unavailable', 'available', 'rate', 'allow_start_day_selection', 'allow_days_number_to_select', 'availability_count', ... |
| 23 |
* |
| 24 |
* ?: prop_name = 'date_status' -> prop_value = 'unavailable', 'available', 'pending', 'approved' |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
function wpbc_activation__dates_availability() { |
| 29 |
// FixIn: 9.3.1.2. |
| 30 |
|
| 31 |
global $wpdb; |
| 32 |
$charset_collate = ( ! empty( $wpdb->charset ) ) ? "DEFAULT CHARACTER SET $wpdb->charset" : ''; |
| 33 |
$charset_collate .= ( ! empty( $wpdb->collate ) ) ? " COLLATE $wpdb->collate" : ''; |
| 34 |
|
| 35 |
if ( ! wpbc_is_table_exists( 'booking_dates_props' ) ) { |
| 36 |
$simple_sql = "CREATE TABLE {$wpdb->prefix}booking_dates_props ( |
| 37 |
booking_dates_prop_id bigint(20) unsigned NOT NULL auto_increment, |
| 38 |
resource_id bigint(10) NOT NULL default 1, |
| 39 |
calendar_date datetime NOT NULL default '0000-00-00 00:00:00', |
| 40 |
prop_name varchar(200) NOT NULL default '', |
| 41 |
prop_value text, |
| 42 |
PRIMARY KEY (booking_dates_prop_id) |
| 43 |
) {$charset_collate}"; |
| 44 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 45 |
$wpdb->query( $simple_sql ); |
| 46 |
} |
| 47 |
} |
| 48 |
add_bk_action( 'wpbc_free_version_activation', 'wpbc_activation__dates_availability' ); |
| 49 |
|
| 50 |
|
| 51 |
/** |
| 52 |
* D e a c t i v a t e |
| 53 |
*/ |
| 54 |
function wpbc_deactivation__dates_availability() { |
| 55 |
|
| 56 |
global $wpdb; |
| 57 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange |
| 58 |
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}booking_dates_props" ); |
| 59 |
} |
| 60 |
add_bk_action( 'wpbc_free_version_deactivation', 'wpbc_deactivation__dates_availability' ); |
| 61 |
|