Specify default appointment service from shortcode
<?php
/**
* Plugin Name: Specify Default Appointment Service
* Plugin URI: https://premium.wpmudev.org/
* Description: Specify default appointment service from shortcode
* Author: Ariful Islam @ WPMUDEV
* Author URI: https://premium.wpmudev.org/profile/itsarifulislam
* License: GPLv2 or later
*/
/*
*
* Example of use: [app_services default="2"]
*
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Appointment_Default_Service' ) ) {
class Appointment_Default_Service {
private static $_instance = null;
public static function get_instance() {
if( is_null( self::$_instance ) ) {
self::$_instance = new Appointment_Default_Service();
}
return self::$_instance;
}
private function __construct() {
add_filter('appointments_services_shortcode_selected_service', array( $this, 'appointments_services_shortcode_selected_service' ), 10, 2);
}
public function appointments_services_shortcode_selected_service( $selected_service, $args ) {
if ( isset( $args['default'] ) ) {
$selected_service = $args['default'];
}
return $selected_service;
}
}
function render_appointment_default_service(){
$GLOBALS['Appointment_Default_Service'] = Appointment_Default_Service::get_instance();
}
add_action( 'plugins_loaded', 'render_appointment_default_service' );
}