Created
February 5, 2018 12:45
-
-
Save wpmudev-sls/88ce46b3fb45086d4f4522d5289d5387 to your computer and use it in GitHub Desktop.
Specify default appointment service from shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of use: [app_services default="2"]