Plugin Directory

Changeset 2383945


Ignore:
Timestamp:
09/17/2020 07:06:36 PM (6 years ago)
Author:
checkfront
Message:

Added better compatibility with PHP v7.3

Location:
checkfront-wp-booking/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • checkfront-wp-booking/trunk/checkfront.php

    r2112483 r2383945  
    1 <?php
    2 /*
     1<?php
     2
     3/*
    34Plugin Name: Checkfront Online Booking System
    45Plugin URI: https://www.checkfront.com/wordpress
    56Description: 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.3
     7Version: 3.4
    78Author: Checkfront Inc.
    89Author URI: https://www.checkfront.com/
    9 Copyright: 2008 - 2019 Checkfront Inc
     10Copyright: 2008 - 2020 Checkfront Inc
    1011*/
    1112
     
    1718
    1819//Shortcode [checkfront parameter="value"]
    19 function checkfront_func($cnf, $content=null) {
    20     $cnf=shortcode_atts(array(
     20function checkfront_func($cnf, $content=null)
     21{
     22    $cnf = shortcode_atts([
    2123        'category_id'=> '',
    2224        'item_id'    => '',
     
    3436        'partner_id' => '',
    3537        'popup'      => '',
    36     ), $cnf);
     38    ], $cnf);
    3739    return checkfront($cnf);
    3840}
    3941
    4042// Global shortcode call
    41 function checkfront($cnf) {
    42     global $Checkfront;
    43     if(is_page() or is_single()) {
     43function checkfront($cnf)
     44{
     45    global $Checkfront;
     46    if (is_page() || is_single()) {
    4447        // Wordpress will try and auto format paragraphs -- remove new lines
    4548        return str_replace("\n",'',$Checkfront->render($cnf));
     
    4851
    4952// Wordpress Admin Hook
    50 function checkfront_conf() {
    51     if ( function_exists('add_submenu_page') ) {
     53function checkfront_conf()
     54{
     55    if (function_exists('add_submenu_page')) {
    5256        add_submenu_page('plugins.php', __('Checkfront'), __('Checkfront'), 'manage_options', 'checkfront', 'checkfront_setup');
    5357    }
     
    5761
    5862// Wordpress Setup Page
    59 function checkfront_setup() {
     63function checkfront_setup()
     64{
    6065    global $Checkfront;
    6166    wp_enqueue_script('jquery');
     
    6570
    6671// Init Checkfront, include any required js / css only when required
    67 function checkfront_head() {
    68 
     72function checkfront_head()
     73{
    6974    $embedded = 0;
    7075
    71     $Checkfront->arg['widget'] = 0;
    72 
    7376    global $post, $Checkfront;
    74     if(!isset($Checkfront->host)) return;
     77    if (!isset($Checkfront->host)) {
     78        return;
     79    }
    7580   
    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    }
    7886
    7987    // calendar widget
    80     if($Checkfront->arg['widget']) {
     88    if ($Checkfront->arg['widget']) {
    8189        $checkfront_widget_post = get_option("checkfront_widget_post");
    8290        $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) {
    8694            $Checkfront->arg['widget'] = 0;
    8795        } 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            }
    91102        }
    92103    }
    93104
    94     if ($Checkfront->arg['widget']  or $embedded) {
     105    if ($Checkfront->arg['widget'] || $embedded) {
    95106        echo ' <script src="//' . $Checkfront->host . '/lib/interface--' . $Checkfront->interface_version . '.js" type="text/javascript"></script>' ."\n";
    96         if($embedded) {
     107        if ($embedded) {
    97108            // Disable Comments
    98109            add_filter('comments_open', 'checkfront_comments_open_filter', 10, 2);
    99110            add_filter('comments_template', 'checkfront_comments_template_filter', 10, 1);
    100111
    101             //disable auto p
    102             //remove_filter ('the_content', 'wpautop');
    103 
    104             ////disable wptexturize
     112            // disable auto p
     113            // remove_filter ('the_content', 'wpautop');
     114
     115            // disable wptexturize
    105116            remove_filter('the_content', 'wptexturize');
    106117        }
     
    109120
    110121// disable comments on booking pagfe
    111 function checkfront_comments_open_filter($open, $post_id=null) {
    112      return $open;
     122function checkfront_comments_open_filter($open, $post_id=null)
     123{
     124    return $open;
    113125}
    114126
    115127// disable comment include (required to clear)
    116 function checkfront_comments_template_filter($file) {
    117     return dirname(__FILE__).'/xcomments.html';
     128function checkfront_comments_template_filter($file)
     129{
     130    return dirname(__FILE__).'/xcomments.html';
    118131}
    119132
    120133// 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')));
     134function 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
    124144    wp_register_widget_control('checkfront_widget', 'Checkfront', 'checkfront_widget_ctrl');
    125145    add_action('wp_head', 'checkfront_head');
    126     # required includes
     146    // required includes
    127147    wp_enqueue_script('jquery');
    128148    $Checkfront->arg['widget'] = (is_active_widget('checkfront_widget')) ? 1 : 0;
     
    130150
    131151// Set admin meta
    132 function checkfront_plugin_meta($links, $file) {
    133 
     152function checkfront_plugin_meta($links, $file)
     153{
    134154    // create link
    135     if (basename($file,'.php') == 'checkfront') {
     155    if (basename($file, '.php') == 'checkfront') {
    136156        return array_merge(
    137157            $links,
    138             array(
     158            [
    139159                '<a href="plugins.php?page=checkfront">' . __('Setup') . '</a>',
    140160                '<a href="https://www.checkfront.com/support/?src=wp-setup">' . __('Support') . '</a>',
    141161                '<a href="https://www.checkfront.com/login/?src=wp-setup">' . __('Login') . '</a>',
    142         )
     162            ]
    143163        );
    144164    }
     
    147167
    148168// Show widget
    149 function checkfront_widget() {
    150     global $Checkfront;
    151     if(!$Checkfront->arg['widget']) return;
     169function checkfront_widget()
     170{
     171    global $Checkfront;
     172    if (!$Checkfront->arg['widget']) {
     173        return;
     174    }
    152175    $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)) {
    156178            $checkfront_book_url = 'http://' . $_SERVER['HTTP_HOST'] . $checkfront_book_url;
    157179        }
    158180    }
    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    }
    160184    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>';
    161185}
    162186
    163187// Widget control
    164 function checkfront_widget_ctrl() {
    165 
    166     if($_POST['checkfront_update']) {
     188function checkfront_widget_ctrl()
     189{
     190    if ($_POST['checkfront_update']) {
    167191        update_option("checkfront_book_url", $_POST['checkfront_book_url']);
    168192        update_option("checkfront_widget_title", $_POST['checkfront_widget_title']);
     
    174198    $checkfront_book_url = get_option("checkfront_book_url");
    175199
    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) {
    178202        global $wpdb;
    179203        $checkfront_book_url = $wpdb->get_var("select guid FROM `{$wpdb->prefix}posts` where post_content like '%[checkfront%' and post_type = 'page' limit 1");
     
    198222
    199223/*
    200  Create Checkront 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)
    201225 see the checkfront-custom-template-sample.php
    202226*/
     
    204228include_once(dirname(__FILE__).'/CheckfrontWidget.php');
    205229
    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]);
    215237
    216238add_shortcode('checkfront', 'checkfront_func');
    217239add_action('admin_menu', 'checkfront_conf');
    218240add_action('init', 'checkfront_init');
     241
    219242?>
  • checkfront-wp-booking/trunk/readme.txt

    r2357472 r2383945  
    7373### Changelog
    7474
     75* *September 17th 2020:*
     76  * Added better compatibility with PHP v7.3
    7577* *July 27th 2018:*
    7678  * Added Guest Form information to readme
Note: See TracChangeset for help on using the changeset viewer.