-
Notifications
You must be signed in to change notification settings - Fork 4
/
checkfront.php
148 lines (128 loc) · 4.22 KB
/
checkfront.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/*
Plugin Name: Checkfront Online Booking System
Plugin URI: https://www.checkfront.com/wordpress
Description: Connects Wordpress to the Checkfront Online Booking System. Checkfront allows Tour, Activity, Accommodation, and Rental businesses to manage their availability, track inventories, centralize reservations, and process online payments. This plugin connects your WordPress site to your Checkfront account, and provides a powerful real-time booking interface – right within your existing website.
Version: 3.7
Author: Checkfront Inc.
Author URI: https://www.checkfront.com/
Copyright: 2008 - 2023 Checkfront Inc
*/
if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
/* ------------------------------------------------------
* Wordpress Required Functions
/* ------------------------------------------------------*/
//Shortcode [checkfront parameter="value"]
function checkfront_func($cnf, $content=null)
{
$cnf = shortcode_atts([
'category_id'=> '',
'item_id' => '',
'date' => '',
'start_date' => '',
'end_date' => '',
'tid' => '',
'discount' => '',
'options' => '',
'style' => '',
'host' => '',
'width' => '',
'theme' => '',
'lang_id' => '',
'partner_id' => '',
'popup' => '',
'widget_id' => '',
], $cnf);
return checkfront($cnf);
}
// Global shortcode call
function checkfront($cnf)
{
global $Checkfront;
if (is_page() || is_single()) {
// Wordpress will try and auto format paragraphs -- remove new lines
return str_replace("\n",'',$Checkfront->render($cnf));
}
}
// Wordpress Admin Hook
function checkfront_conf()
{
if (function_exists('add_submenu_page')) {
add_submenu_page('plugins.php', __('Checkfront'), __('Checkfront'), 'manage_options', 'checkfront', 'checkfront_setup');
}
add_filter('plugin_row_meta', 'checkfront_plugin_meta', 10, 2 );
}
// Wordpress Setup Page
function checkfront_setup()
{
global $Checkfront;
include(dirname(__FILE__).'/setup.php');
}
// include required js, if the page will use it
function checkfront_enqueue_scripts()
{
global $post, $Checkfront;
if (!isset($Checkfront->host)) {
return;
}
// does this page have any shortcode. If not, back out.
if (stripos($post->post_content, '[checkfront') === false) {
return;
}
wp_enqueue_script('cf/interface.js', "//{$Checkfront->host}/lib/interface--{$Checkfront->interface_version}.js", ['jquery']);
// Disable Comments
add_filter('comments_open', 'checkfront_comments_open_filter', 10, 2);
add_filter('comments_template', 'checkfront_comments_template_filter', 10, 1);
// disable auto p
// remove_filter ('the_content', 'wpautop');
// disable wptexturize
remove_filter('the_content', 'wptexturize');
}
// disable comments on booking page
function checkfront_comments_open_filter($open, $post_id=null)
{
return $open;
}
// disable comment include (required to clear)
function checkfront_comments_template_filter($file)
{
return dirname(__FILE__).'/xcomments.html';
}
// plugin init
function checkfront_init()
{
wp_enqueue_script('jquery');
add_action('wp_enqueue_scripts', 'checkfront_enqueue_scripts');
}
// Set admin meta
function checkfront_plugin_meta($links, $file)
{
// create link
if (basename($file, '.php') == 'checkfront') {
return array_merge(
$links,
[
'<a href="plugins.php?page=checkfront">' . __('Setup') . '</a>',
'<a href="https://www.checkfront.com/support/?src=wp-setup">' . __('Support') . '</a>',
'<a href="https://www.checkfront.com/login/?src=wp-setup">' . __('Login') . '</a>',
]
);
}
return $links;
}
/*
Create Checkfront class. If you wish to include this in a custom theme (not shortcode)
see the checkfront-custom-template-sample.php
*/
// Include Checkfront Widget Class
include_once(dirname(__FILE__).'/CheckfrontWidget.php');
$Checkfront = new CheckfrontWidget([
'host' => get_option('checkfront_host'),
'pipe_url' => '/' . basename(WP_CONTENT_URL) . '/plugins/' . basename(dirname(__FILE__)) . '/pipe.html',
'provider' => 'wordpress',
'load_msg' => __('Searching Availability'),
'continue_msg' => __('Continue to Secure Booking System'),
]);
add_shortcode('checkfront', 'checkfront_func');
add_action('admin_menu', 'checkfront_conf');
add_action('init', 'checkfront_init');