Do you like the appointment scheduler on the front page? Have you seen it? If not, here is an example.
In this tutorial, we are going to build a simple plugin that makes this work. It uses a couple hooks that you can use to modify any styles of any shortcode enabled output.
Make sure you have the following things taken care of before you begin.
ssa-popup
$attr['type']
consultation-phone-call
<?php /* * Plugin Name: SS Popup * Plugin URI: https://brunstar.com/ * Description: A simple plugin to show a popup for scheduling appointments. * Version: 1.0 * Author: Anthony Brunson * Author URI: https://brunstar.com/ */ add_action( 'wp_enqueue_scripts', 'ss_p_register_my_scripts' ); add_filter( 'do_shortcode_tag', 'ss_p_enqueue_my_script', 10, 3 ); function ss_p_register_my_scripts(){ wp_register_script('simply-schedule-appointments-js', plugins_url( '/ssa-popup/simply_schedule_appointments.js' )); wp_register_style('simply-schedule-appointments-css', plugins_url( '/ssa-popup/simply_schedule_appointments.css' )); } function ss_p_enqueue_my_script($output, $tag, $attr){ if('ssa_booking' != $tag){ //make sure it is the right shortcode return $output; } if(!isset($attr['type']) && $attr['type'] != 'consultation-phone-call'){ //you can even check for specific attributes return $output; } wp_enqueue_style('simply-schedule-appointments-css'); wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array(), null, true); wp_enqueue_script('simply-schedule-appointments-js'); return $output; } ?>
/* * Plugin Name: SS Popup * Plugin URI: https://brunstar.com/ * Description: A simple plugin to show a popup for scheduling appointments. * Version: 1.0 * Author: Anthony Brunson * Author URI: https://brunstar.com/ */
Once you finish creating the plugin file, you will create 2 more files. The first is a .js file. This will store the javascript you will need to make this work. Upload the file to the location identified in the header of the code block.
jQuery(document).ready(function(){ document.getElementById('btn_schedule_demo').onclick = function() { document.getElementById('modal_scheduler').style.display='block'; }; // Get the modal var modal = document.getElementById('modal_scheduler'); // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } console.log(event.target); } });
The final file is your css file. This will allow you to define all of the styles that affect the visibility of the element on the screen, along with anything else you choose to modify. Upload the file to the location identified in the header of the code block.
.modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 2; /* Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ } /* Add Zoom Animation */ .animate { -webkit-animation: animatezoom 0.6s; animation: animatezoom 0.6s; } @-webkit-keyframes animatezoom { from {-webkit-transform: scale(0)} to {-webkit-transform: scale(1)} } @keyframes animatezoom { from {transform: scale(0)} to {transform: scale(1)} }
This tutorial is not going to go over how to set your availability in the scheduler. Once the plugin is installed, you should have walked through that already. Now that you have the plugin code complete, you can add the scheduler to your page in the location of your choice.
IMPORTANT:
We will be configuring a few sections here.
First, the animate class we created above will be applied to the column that contains the scheduler.
Next we will apply the modal id to the modal, along with the modal class which will hide the modal. The modal is at the section level, so make sure that is selected.
btn_schedule_demo
Now you can test your creation. Once complete, you should be able to click the button, and see something like this. Go ahead and click it.
Powered by BetterDocs
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.