Changeset 2383945
- Timestamp:
- 09/17/2020 07:06:36 PM (6 years ago)
- Location:
- checkfront-wp-booking/trunk
- Files:
-
- 2 edited
-
checkfront.php (modified) (12 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
checkfront-wp-booking/trunk/checkfront.php
r2112483 r2383945 1 <?php 2 /* 1 <?php 2 3 /* 3 4 Plugin Name: Checkfront Online Booking System 4 5 Plugin URI: https://www.checkfront.com/wordpress 5 6 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. 6 Version: 3. 37 Version: 3.4 7 8 Author: Checkfront Inc. 8 9 Author URI: https://www.checkfront.com/ 9 Copyright: 2008 - 20 19 Checkfront Inc10 Copyright: 2008 - 2020 Checkfront Inc 10 11 */ 11 12 … … 17 18 18 19 //Shortcode [checkfront parameter="value"] 19 function checkfront_func($cnf, $content=null) { 20 $cnf=shortcode_atts(array( 20 function checkfront_func($cnf, $content=null) 21 { 22 $cnf = shortcode_atts([ 21 23 'category_id'=> '', 22 24 'item_id' => '', … … 34 36 'partner_id' => '', 35 37 'popup' => '', 36 ), $cnf);38 ], $cnf); 37 39 return checkfront($cnf); 38 40 } 39 41 40 42 // Global shortcode call 41 function checkfront($cnf) { 42 global $Checkfront; 43 if(is_page() or is_single()) { 43 function checkfront($cnf) 44 { 45 global $Checkfront; 46 if (is_page() || is_single()) { 44 47 // Wordpress will try and auto format paragraphs -- remove new lines 45 48 return str_replace("\n",'',$Checkfront->render($cnf)); … … 48 51 49 52 // Wordpress Admin Hook 50 function checkfront_conf() { 51 if ( function_exists('add_submenu_page') ) { 53 function checkfront_conf() 54 { 55 if (function_exists('add_submenu_page')) { 52 56 add_submenu_page('plugins.php', __('Checkfront'), __('Checkfront'), 'manage_options', 'checkfront', 'checkfront_setup'); 53 57 } … … 57 61 58 62 // Wordpress Setup Page 59 function checkfront_setup() { 63 function checkfront_setup() 64 { 60 65 global $Checkfront; 61 66 wp_enqueue_script('jquery'); … … 65 70 66 71 // Init Checkfront, include any required js / css only when required 67 function checkfront_head() {68 72 function checkfront_head() 73 { 69 74 $embedded = 0; 70 75 71 $Checkfront->arg['widget'] = 0;72 73 76 global $post, $Checkfront; 74 if(!isset($Checkfront->host)) return; 77 if (!isset($Checkfront->host)) { 78 return; 79 } 75 80 76 // does this page have any shortcode. If not, back out. 77 if($pos = stripos($post->post_content,'[checkfront') or $pos === 0) $embedded = 1; 81 // does this page have any shortcode. If not, back out. 82 $pos = stripos($post->post_content, '[checkfront'); 83 if ($pos || $pos === 0) { 84 $embedded = 1; 85 } 78 86 79 87 // calendar widget 80 if ($Checkfront->arg['widget']) {88 if ($Checkfront->arg['widget']) { 81 89 $checkfront_widget_post = get_option("checkfront_widget_post"); 82 90 $checkfront_widget_page = get_option("checkfront_widget_page"); 83 $checkfront_widget_booking = get_option("checkfront_widget_booking");84 85 if ($embedded and!$checkfront_widget_booking) {91 $checkfront_widget_booking = get_option("checkfront_widget_booking"); 92 93 if ($embedded && !$checkfront_widget_booking) { 86 94 $Checkfront->arg['widget'] = 0; 87 95 } else { 88 if(is_page() and !$checkfront_widget_page) $Checkfront->arg['widget'] = 0; 89 if(is_single() and !$checkfront_widget_post) $Checkfront->arg['widget'] = 0; 90 96 if (is_page() && !$checkfront_widget_page) { 97 $Checkfront->arg['widget'] = 0; 98 } 99 if (is_single() && !$checkfront_widget_post) { 100 $Checkfront->arg['widget'] = 0; 101 } 91 102 } 92 103 } 93 104 94 if ($Checkfront->arg['widget'] or$embedded) {105 if ($Checkfront->arg['widget'] || $embedded) { 95 106 echo ' <script src="//' . $Checkfront->host . '/lib/interface--' . $Checkfront->interface_version . '.js" type="text/javascript"></script>' ."\n"; 96 if ($embedded) {107 if ($embedded) { 97 108 // Disable Comments 98 109 add_filter('comments_open', 'checkfront_comments_open_filter', 10, 2); 99 110 add_filter('comments_template', 'checkfront_comments_template_filter', 10, 1); 100 111 101 // disable auto p102 // remove_filter ('the_content', 'wpautop');103 104 // //disable wptexturize112 // disable auto p 113 // remove_filter ('the_content', 'wpautop'); 114 115 // disable wptexturize 105 116 remove_filter('the_content', 'wptexturize'); 106 117 } … … 109 120 110 121 // disable comments on booking pagfe 111 function checkfront_comments_open_filter($open, $post_id=null) { 112 return $open; 122 function checkfront_comments_open_filter($open, $post_id=null) 123 { 124 return $open; 113 125 } 114 126 115 127 // disable comment include (required to clear) 116 function checkfront_comments_template_filter($file) { 117 return dirname(__FILE__).'/xcomments.html'; 128 function checkfront_comments_template_filter($file) 129 { 130 return dirname(__FILE__).'/xcomments.html'; 118 131 } 119 132 120 133 // plugin init 121 function checkfront_init() { 122 global $Checkfront; 123 wp_register_sidebar_widget('checkfront_widget', 'Checkfront', 'checkfront_widget',array('description' => __('Availability calendar and search'))); 134 function checkfront_init() 135 { 136 global $Checkfront; 137 wp_register_sidebar_widget( 138 'checkfront_widget', 139 'Checkfront', 140 'checkfront_widget', 141 ['description' => __('Availability calendar and search')] 142 ); 143 124 144 wp_register_widget_control('checkfront_widget', 'Checkfront', 'checkfront_widget_ctrl'); 125 145 add_action('wp_head', 'checkfront_head'); 126 #required includes146 // required includes 127 147 wp_enqueue_script('jquery'); 128 148 $Checkfront->arg['widget'] = (is_active_widget('checkfront_widget')) ? 1 : 0; … … 130 150 131 151 // Set admin meta 132 function checkfront_plugin_meta($links, $file) {133 152 function checkfront_plugin_meta($links, $file) 153 { 134 154 // create link 135 if (basename($file, '.php') == 'checkfront') {155 if (basename($file, '.php') == 'checkfront') { 136 156 return array_merge( 137 157 $links, 138 array(158 [ 139 159 '<a href="plugins.php?page=checkfront">' . __('Setup') . '</a>', 140 160 '<a href="https://www.checkfront.com/support/?src=wp-setup">' . __('Support') . '</a>', 141 161 '<a href="https://www.checkfront.com/login/?src=wp-setup">' . __('Login') . '</a>', 142 )162 ] 143 163 ); 144 164 } … … 147 167 148 168 // Show widget 149 function checkfront_widget() { 150 global $Checkfront; 151 if(!$Checkfront->arg['widget']) return; 169 function checkfront_widget() 170 { 171 global $Checkfront; 172 if (!$Checkfront->arg['widget']) { 173 return; 174 } 152 175 $checkfront_widget_title = get_option("checkfront_widget_title"); 153 if($checkfront_book_url = get_option("checkfront_book_url")) { 154 155 if(!(strpos('http',$checkfront_book_url) === 0)) { 176 if ($checkfront_book_url = get_option("checkfront_book_url")) { 177 if (!(strpos('http', $checkfront_book_url) === 0)) { 156 178 $checkfront_book_url = 'http://' . $_SERVER['HTTP_HOST'] . $checkfront_book_url; 157 179 } 158 180 } 159 if(!empty($checkfront_widget_title)) echo '<h2 class="widgettitle">' . $checkfront_widget_title . '</h2>'; 181 if (!empty($checkfront_widget_title)) { 182 echo '<h2 class="widgettitle">' . $checkfront_widget_title . '</h2>'; 183 } 160 184 echo '<div id="checkfront-cal"><iframe allowTransparency=true border=0 style="border:0; height: 260px;" src="//' . $Checkfront->host . '/reserve/widget/calendar/?return=' . urlencode($checkfront_book_url) . '"></iframe></div>'; 161 185 } 162 186 163 187 // Widget control 164 function checkfront_widget_ctrl() {165 166 if ($_POST['checkfront_update']) {188 function checkfront_widget_ctrl() 189 { 190 if ($_POST['checkfront_update']) { 167 191 update_option("checkfront_book_url", $_POST['checkfront_book_url']); 168 192 update_option("checkfront_widget_title", $_POST['checkfront_widget_title']); … … 174 198 $checkfront_book_url = get_option("checkfront_book_url"); 175 199 176 // try and find booking page in content 177 if (!$checkfront_book_url) {200 // try and find booking page in content 201 if (!$checkfront_book_url) { 178 202 global $wpdb; 179 203 $checkfront_book_url = $wpdb->get_var("select guid FROM `{$wpdb->prefix}posts` where post_content like '%[checkfront%' and post_type = 'page' limit 1"); … … 198 222 199 223 /* 200 Create Check ront class.If you wish to include this in a custom theme (not shortcode)224 Create Checkfront class. If you wish to include this in a custom theme (not shortcode) 201 225 see the checkfront-custom-template-sample.php 202 226 */ … … 204 228 include_once(dirname(__FILE__).'/CheckfrontWidget.php'); 205 229 206 $Checkfront = new CheckfrontWidget( 207 array( 208 'host'=>get_option('checkfront_host'), 209 'pipe_url'=>'/' . basename(WP_CONTENT_URL) . '/plugins/' .basename(dirname(__FILE__)) . '/pipe.html', 210 'provider' =>'wordpress', 211 'load_msg'=>__('Searching Availability'), 212 'continue_msg'=>__('Continue to Secure Booking System'), 213 ) 214 ); 230 $Checkfront = new CheckfrontWidget([ 231 'host' => get_option('checkfront_host'), 232 'pipe_url' => '/' . basename(WP_CONTENT_URL) . '/plugins/' . basename(dirname(__FILE__)) . '/pipe.html', 233 'provider' => 'wordpress', 234 'load_msg' => __('Searching Availability'), 235 'continue_msg' => __('Continue to Secure Booking System'), 236 ]); 215 237 216 238 add_shortcode('checkfront', 'checkfront_func'); 217 239 add_action('admin_menu', 'checkfront_conf'); 218 240 add_action('init', 'checkfront_init'); 241 219 242 ?> -
checkfront-wp-booking/trunk/readme.txt
r2357472 r2383945 73 73 ### Changelog 74 74 75 * *September 17th 2020:* 76 * Added better compatibility with PHP v7.3 75 77 * *July 27th 2018:* 76 78 * Added Guest Form information to readme
Note: See TracChangeset
for help on using the changeset viewer.