PluginProbe ʕ •ᴥ•ʔ
Booqable Rental Plugin / 2.4.15
Booqable Rental Plugin v2.4.15
trunk 2.1.0 2.1.1 2.2.0 2.2.1 2.3.0 2.3.1 2.3.2 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 2.4.22 2.4.23 2.4.24 2.4.25 2.4.26 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9
booqable-rental-reservations / booqable.php
booqable-rental-reservations Last commit date
admin 3 years ago assets 3 years ago booqable.php 3 years ago index.php 8 years ago readme.txt 3 years ago release.sh 3 years ago
booqable.php
266 lines
1 <?php
2 /**
3 * @wordpress-plugin
4 * Plugin Name: Booqable Rental Plugin
5 * Description: Rental plugin for WordPress. Turn your website into a complete online rental store by connecting your Booqable account to WordPress.
6 * Author: Booqable Rental Software
7 * Version: 2.4.15
8 * Author URI: https://booqable.com
9 * Copyright: 2023 Booqable
10 */
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 //
18 // Admin
19 //
20
21 // Include admin settings page
22 function booqable_admin() {
23 include('admin/booqable_admin.php');
24 }
25
26 function booqable_admin_actions() {
27 add_options_page("Booqable", "Booqable", 'administrator', "Booqable", "booqable_admin");
28 }
29
30 function admin_resources($hook) {
31 // Load only on ?page=mypluginname
32 if($hook != 'settings_page_Booqable') {
33 return;
34 }
35 wp_enqueue_style( 'booqable-admin', plugins_url('assets/booqable-admin.css', __FILE__) );
36 }
37
38 function admin_settings_link($links) {
39 $settings_link = '<a href="options-general.php?page=Booqable">' . __( 'Settings' ) . '</a>';
40 array_unshift( $links, $settings_link );
41 return $links;
42 }
43
44 function admin_notice() {
45 global $hook_suffix;
46
47 if ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config' ) ) ) {
48 // This page manages the notices and puts them inline where they make sense.
49 return;
50 }
51
52 if ( $hook_suffix == 'plugins.php' && trim(get_option('booqable_company_name')) == false ) {
53 include('admin/booqable_notice.php');
54 }
55 }
56
57 //
58 // Assets
59 //
60
61 // Load client script
62 function add_booqable_js() {
63 $asset_url = 'https://' . esc_attr(get_option('booqable_company_name')) . '.assets.booqable.com/v2/booqable.js';
64 wp_enqueue_script('booqable_v2', $asset_url, array(), '2.0.0', true);
65 }
66
67 // Insert client configuration
68 function add_booqable_client_configuration_js() {
69 ?>
70 <script>var booqableOptions = { company: '<?php echo esc_attr(get_option('booqable_company_name')); ?>', storeProvider: 'wordpress' };</script>
71 <?php
72 }
73
74 //
75 // BBcodes
76 //
77
78 // Convert shortcode options to data-{key}={value}
79 function shortcode_options_to_data($options) {
80 $data = implode(' ', array_map(
81 function ($v, $k) {
82 if (! empty($v)) {
83 return sprintf("data-%s=\"%s\"", $k, esc_attr($v));
84 }
85 },
86 $options,
87 array_keys($options)
88 ));
89
90 return $data;
91 }
92
93 // BBcode for embedding a product
94 // [booqable_card id="ipad"]
95 function booqable_card_bb($params) {
96 $options = shortcode_atts(array(
97 'id' => NULL
98 ), $params);
99
100 return '<div class="booqable-product" ' . shortcode_options_to_data($options) . '></div>';
101 }
102
103 // BBcode for embedding a product button
104 // [booqable_button id="ipad"]
105 function booqable_button_bb($params) {
106 $options = shortcode_atts(array(
107 'id' => NULL
108 ), $params);
109
110 return '<div class="booqable-product-button" ' . shortcode_options_to_data($options) . '></div>';
111 }
112
113 // BBcode for embedding a product detail view
114 // [booqable_detail id="ipad"]
115 function booqable_detail_bb($params) {
116 $options = shortcode_atts(array(
117 'id' => NULL
118 ), $params);
119
120 return '<div class="booqable-product-detail" ' . shortcode_options_to_data($options) . '></div>';
121 }
122
123 // BBcode for embedding a product list
124 // [booqable_list]
125 // [booqable_list tags="tablets"]
126 // [booqable_list categories="apple"]
127 function booqable_list_bb($params) {
128 $options = shortcode_atts(array(
129 'tags' => NULL,
130 'categories' => NULL,
131 'per' => NULL,
132 'limit' => NULL,
133 'show-search' => NULL,
134 'search-key' => NULL
135 ), $params);
136
137 return '<div class="booqable-product-list" ' . shortcode_options_to_data($options) . '></div>';
138 }
139
140 // BBcode for embedding a product search
141 // [booqable_search]
142 // [booqable_search search-key="only-tablets"]
143 function booqable_search_bb($params) {
144 $options = shortcode_atts(array(
145 'search-key' => NULL
146 ), $params);
147
148 return '<div class="booqable-product-search" ' . shortcode_options_to_data($options) . '></div>';
149 }
150
151 // BBcode for datepicker
152 // [booqable_datepicker]
153 function booqable_datepicker_bb($params) {
154 $options = shortcode_atts(array(), $params);
155
156 return '<div class="booqable-datepicker" ' . shortcode_options_to_data($options) . '></div>';
157 }
158 add_shortcode('booqable_datepicker', 'booqable_datepicker_bb');
159
160 // BBcode for embedding a cart button
161 // [booqable_cart_button]
162 function booqable_cart_button_bb($params) {
163 $options = shortcode_atts(array(
164 'href' => NULL
165 ), $params);
166
167 return '<div class="booqable-cart-button" ' . shortcode_options_to_data($options) . '></div>';
168 }
169
170 // BBcode for embedding the embeddable cart
171 // [booqable_embeddable_cart]
172 function booqable_embeddable_cart_bb($params) {
173 return '<div class="booqable-embeddable-cart"></div>';
174 }
175
176 // BBcode for embedding the embeddable cart lines
177 // [booqable_embeddable_cart_lines]
178 function booqable_embeddable_cart_lines_bb($params) {
179 $options = shortcode_atts(array(
180 'compact' => NULL
181 ), $params);
182
183 return '<div class="booqable-embeddable-cart-lines" ' . shortcode_options_to_data($options) . '></div>';
184 }
185
186 // BBcode for embedding the embeddable cart sidebar
187 // [booqable_embeddable_cart_sidebar]
188 function booqable_embeddable_cart_sidebar_bb($params) {
189 $options = shortcode_atts(array(
190 'continue-shopping' => NULL,
191 'datepicker' => NULL
192 ), $params);
193
194 return '<div class="booqable-embeddable-cart-sidebar" ' . shortcode_options_to_data($options) . '></div>';
195 }
196
197 // BBcode for embedding a sidebar with datepicker and categories
198 // [booqable_sidebar]
199 function booqable_sidebar_bb($params) {
200 return '<div class="booqable-sidebar"></div>';
201 }
202
203 // BBcode for embedding a sorting select
204 // [booqable_sort]
205 // [booqable_sort search-key="only-tablets"]
206 function booqable_sort_bb($params) {
207 $options = shortcode_atts(array(
208 'search-key' => NULL
209 ), $params);
210
211 return '<div class="booqable-sort" ' . shortcode_options_to_data($options) . '></div>';
212 }
213
214 // BBcode for embedding a bar with search and sorting select
215 // [booqable_bar]
216 // [booqable_bar search-key="only-tablets"]
217 function booqable_bar_bb($params) {
218 $options = shortcode_atts(array(
219 'search-key' => NULL,
220 ), $params);
221
222 return '<div class="booqable-bar" ' . shortcode_options_to_data($options) . '></div>';
223 }
224
225 // BBcode for embedding a category list
226 // [booqable_categories]
227 // [booqable_categories search-key="only-tablets"]
228 function booqable_categories_bb($params) {
229 $options = shortcode_atts(array(
230 'search-key' => NULL
231 ), $params);
232
233 return '<div class="booqable-categories" ' . shortcode_options_to_data($options) . '></div>';
234 }
235
236
237 function initialize() {
238 add_action('admin_menu', 'booqable_admin_actions');
239 add_action('admin_notices', 'admin_notice');
240 add_action('admin_enqueue_scripts', 'admin_resources');
241
242 $plugin = plugin_basename( __FILE__ );
243 add_filter("plugin_action_links_$plugin", 'admin_settings_link' );
244
245 add_action('wp_enqueue_scripts', 'add_booqable_js');
246 add_action('wp_head', 'add_booqable_client_configuration_js');
247
248 add_shortcode('booqable_card', 'booqable_card_bb');
249 add_shortcode('booqable_button', 'booqable_button_bb');
250 add_shortcode('booqable_product', 'booqable_button_bb');
251 add_shortcode('booqable_detail', 'booqable_detail_bb');
252 add_shortcode('booqable_list', 'booqable_list_bb');
253 add_shortcode('booqable_search', 'booqable_search_bb');
254 add_shortcode('booqable_cart_button', 'booqable_cart_button_bb');
255 add_shortcode('booqable_embeddable_cart', 'booqable_embeddable_cart_bb');
256 add_shortcode('booqable_embeddable_cart_sidebar', 'booqable_embeddable_cart_sidebar_bb');
257 add_shortcode('booqable_embeddable_cart_lines', 'booqable_embeddable_cart_lines_bb');
258 add_shortcode('booqable_sidebar', 'booqable_sidebar_bb');
259 add_shortcode('booqable_sort', 'booqable_sort_bb');
260 add_shortcode('booqable_bar', 'booqable_bar_bb');
261 add_shortcode('booqable_categories', 'booqable_categories_bb');
262 }
263 initialize();
264
265 ?>
266