Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created February 6, 2015 00:39
Show Gist options
  • Save bappi-d-great/4fe7925f0bb75f7897b4 to your computer and use it in GitHub Desktop.
Save bappi-d-great/4fe7925f0bb75f7897b4 to your computer and use it in GitHub Desktop.
WPMU Appointments+ tabify service calendar add on
<?php
/*
Plugin Name: Tabify Services
Description: Create a tab or services
Plugin URI: http://premium.wpmudev.org/project/appointments-plus/
Version: 1.0
AddonType: ShortCode
Author: WPMU DEV
*/
class App_Tabify_Service {
private function __construct () {}
public static function serve () {
$me = new App_Tabify_Service;
$me->_add_hooks();
}
private function _add_hooks () {
add_action( 'wp_enqueue_scripts', array( $this, 'app_ui_scripts' ) );
add_action( 'wp_footer', array( $this, 'app_tabify_script' ) );
add_shortcode( 'app_tabify_service', array( $this, 'app_tabify_service_cb' ) );
}
public function app_tabify_service_cb () {
global $appointments;
$services = $appointments->get_services();
$lists = $items = '';
$i = 0;
foreach( $services as $service ){
$lists .= '<li><a href="#tabs-' . ++$i . '">' . $service->name . '</a></li>';
$items .= '<div id="tabs-' . $i . '">' . do_shortcode( '[app_monthly_schedule service="' . $service->ID . '"]' ) . '</div>';
}
$html = '<div id="app_tabs"><ul>';
$html .= $lists;
$html .= '</ul>' . $items . '</div>';
$element = '<table><tbody><tr><td colspan="2">[app_my_appointments allow_cancel="1"]</td></tr><tr><td colspan="2">' . $html . '</td></tr><tr><td colspan="2">[app_pagination month="1"]</td></tr><tr><td colspan="2">[app_login]</td></tr><tr><td colspan="2">[app_confirmation title="text" button_text="Hello"]</td></tr><tr><td colspan="2">[app_paypal]</td></tr></tbody></table>';
return do_shortcode( $element );
}
public function app_tabify_script() {
?>
<script type="text/javascript">
jQuery(function($) {
$( "#app_tabs" ).tabs();
});
</script>
<?php
}
public function app_ui_scripts() {
wp_enqueue_script( 'jquery-ui-tabs' );
wp_enqueue_style( 'app-tabs-ui', '//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
}
}
App_Tabify_Service::serve();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment