WordPress.org

Ready to get started?Download WordPress

Forums

Booking Calendar
[resolved] Conditional datepick.js (5 posts)

  1. crdunst
    Member
    Posted 1 year ago #

    Hi, firstly, great plugin, thanks.

    I'm trying to implement the calendar to display bookings only, without giving visitors the option to click and book.

    I edited \js\datepick\jquery.datepick.js to remove the onclick/onmouseover/onmouseout attributes, but I then realised the same file is called from admin, and I couldn't add a booking from admin as a result of editing the file :/

    I then thought I would create a duplicate, edited copy of jquery.datepick.js, and call it conditionally using e.g. is_admin(). Is this possible? if so, where is the js file called from when in admin?

    I'm proficient enough using php, but js isn't my strong point, so any pointers would be appreciated.

    Thanks in advance.

    http://wordpress.org/extend/plugins/booking/

  2. wpdevelop
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,
    you can insert into the post or page only the "calendar" without the booking form", so your visitors in this case can see the reservations but can not make new one. You can configure how to insert the booking form or availability calendar only at the popup configuration dialog, after pressing at the "booking" button (with calendar icon) at the edit toolbar in the edit post page, during inserting the booking shortcode into the post or page.
    Please note, if you will modify the source code of the Booking Calendar, we will not guaranteed the correct work of plugin and do not support it.

  3. crdunst
    Member
    Posted 1 year ago #

    Hi, thanks for the reply.

    On my site I already have the calendar displaying without the booking form, but the code still inserts the click/hover behaviours on the calendar dates. This is what I'm trying to prevent, as from a UI perspective, the users will wonder what is happening if they are able to select dates, and nothing happens after that point.

    I don't like to edit plugins as a general rule, and I tried to remove the click/hover behaviours on the client side using js rather than change the plugin, but this didn't work (see above).

    I reluctantly therefore have looked at changing the plugin, and need to just make a duplicate of a file, remove the click/hover behaviours on the duplicate version, and add a simple conditional to show one version or the other depending on whether the user is admin or not.

    It is the location of where to insert the conditional that has me stumped, as the plugin is very js heavy.

    Just to reiterate - your plugin is great, and I'm tweaking it reluctantly...

    Thanks

  4. wpdevelop
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,
    you will need to make this modifications. We will integrate it into the next update of the plugin.
    1) Please open the ../booking/lib/wpdev-booking-class.php file.
    Find this function declaration: booking_calendar_only_shortcode
    Inside of content of that function find this code:
    return $res ;
    and replace it to this code

    $start_script_code = "<div id='calendar_booking_unselectable".$my_boook_type."'></div>";
                return $start_script_code. $res ;

    2) Then please open this file: ../booking/js/wpdev.bk.js
    Find this function declaration: applyCSStoDays
    Inside of content of that function find this code:

    if ( time_return_value !== false )  return time_return_value;
                    else                                return [true, 'cal4date-' + class_day +' reserved_days_count' + reserved_days_count + ' ' ];

    and replace it to this code

    var is_datepick_unselectable = '';
                    var is_calendar_booking_unselectable= jQuery('#calendar_booking_unselectable' + bk_type);
                    if (is_calendar_booking_unselectable.length != 0 ) {
                        is_datepick_unselectable = 'datepick-unselectable';
                    }
    
                    if ( time_return_value !== false )  return time_return_value;
                    else                                return [true, 'cal4date-' + class_day +' reserved_days_count' + reserved_days_count + ' '  + is_datepick_unselectable + ' '];
  5. crdunst
    Member
    Posted 1 year ago #

    That's perfect, thanks for taking the time to respond, it's much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.