booked-frontend-agents.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /*
  3. Plugin Name: Booked Add-On: Front-End Agents
  4. Plugin URI: https://getbooked.io
  5. Description: Adds the ability for Booking Agents to manage their appointments on the front-end.
  6. Version: 1.1.15
  7. Author: Boxy Studio
  8. Author URI: https://boxystudio.com
  9. Text Domain: booked-frontend-agents
  10. */
  11. define('BOOKEDFEA_PLUGIN_DIR', dirname(__FILE__));
  12. define('BOOKEDFEA_PLUGIN_URL', WP_PLUGIN_URL . '/booked-frontend-agents');
  13. // Include the required class for plugin updates.
  14. require_once('updates/plugin-update-checker.php');
  15. $BookedFEA_BoxyUpdateChecker = PucFactory::buildUpdateChecker('http://boxyupdates.com/get/?action=get_metadata&slug=booked-frontend-agents', __FILE__, 'booked-frontend-agents');
  16. // Is Booked installed and active?
  17. if( in_array('booked/booked.php',apply_filters('active_plugins',get_option('active_plugins')))) {
  18. if(!class_exists('BookedFEA_Plugin')) {
  19. class BookedFEA_Plugin {
  20. public function __construct() {
  21. add_action('init', array(&$this, 'booked_fea_init') );
  22. add_action('wp_enqueue_scripts', array(&$this, 'front_end_styles'));
  23. add_action('wp_enqueue_scripts', array(&$this, 'front_end_scripts'));
  24. require_once(sprintf("%s/includes/functions.php", BOOKEDFEA_PLUGIN_DIR));
  25. require_once(sprintf("%s/includes/shortcodes.php", BOOKEDFEA_PLUGIN_DIR));
  26. require_once(sprintf("%s/includes/ajax.php", BOOKEDFEA_PLUGIN_DIR));
  27. $bookedfea_ajax = new BookedFEA_Ajax();
  28. }
  29. public function booked_fea_init(){
  30. if (is_user_logged_in() && current_user_can('edit_booked_appointments')):
  31. add_filter('booked_profile_tab_content', array(&$this, 'booked_fea_tabs'),1);
  32. add_filter('booked_profile_tabs',array(&$this, 'booked_fea_tabs'),1);
  33. endif;
  34. }
  35. public static function front_end_styles() {
  36. wp_enqueue_style('booked-fea-styles', BOOKEDFEA_PLUGIN_URL . '/css/styles.css', array(), BOOKED_VERSION);
  37. }
  38. public static function front_end_scripts() {
  39. wp_register_script('booked-fea-js', BOOKEDFEA_PLUGIN_URL . '/js/functions.js', array(), BOOKED_VERSION, true);
  40. $booked_fea_vars = array(
  41. 'ajax_url' => admin_url( 'admin-ajax.php' ),
  42. 'i18n_confirm_appt_delete' => __('Are you sure you want to cancel this appointment?','booked-frontend-agents'),
  43. 'i18n_confirm_appt_approve' => __('Are you sure you want to approve this appointment?','booked-frontend-agents')
  44. );
  45. wp_localize_script( 'booked-fea-js', 'booked_fea_vars', $booked_fea_vars );
  46. wp_enqueue_script('booked-fea-js');
  47. }
  48. public function booked_fea_tabs($custom_tabs){
  49. $custom_tabs = array(
  50. 'fea_appointments' => array(
  51. 'title' => __('Upcoming Appointments','booked-frontend-agents'),
  52. 'booked-icon' => 'booked-icon-calendar',
  53. 'class' => false
  54. ),
  55. 'fea_pending' => array(
  56. 'title' => __('Pending Appointments','booked-frontend-agents') . '<div class="counter"></div>',
  57. 'booked-icon' => 'booked-icon-clock',
  58. 'class' => false
  59. ),
  60. 'fea_history' => array(
  61. 'title' => __('Appointment History','booked-frontend-agents'),
  62. 'booked-icon' => 'booked-icon-calendar',
  63. 'class' => false
  64. ),
  65. 'edit' => array(
  66. 'title' => __('Edit Profile','booked-frontend-agents'),
  67. 'booked-icon' => 'booked-icon-pencil',
  68. 'class' => 'edit-button'
  69. )
  70. );
  71. return $custom_tabs;
  72. }
  73. }
  74. }
  75. add_action('plugins_loaded','init_bookedfea');
  76. } else {
  77. // Show notice when Booked is not active
  78. add_action('admin_notices', 'bookedfea_required_plugins_notice');
  79. }
  80. function init_bookedfea(){
  81. if(class_exists('BookedFEA_Plugin')) {
  82. $bookedfea_plugin = new BookedFEA_Plugin();
  83. }
  84. }
  85. function bookedfea_required_plugins_notice() {
  86. echo '<div class="update-nag">';
  87. echo sprintf( __('In order to use the %s plugin, you need to have %s installed and active.'), '<strong>Booked Front-End Agents</strong>', '<strong><a href="http://codecanyon.net/item/booked-appointment-booking-for-wordpress/9466968/?ref=boxystudio" target="_blank">Booked</a></strong>' );
  88. echo '</div>';
  89. }
  90. // Localization
  91. function booked_fea_local_init(){
  92. $domain = 'booked-frontend-agents';
  93. $locale = apply_filters('plugin_locale', get_locale(), $domain);
  94. load_textdomain($domain, WP_LANG_DIR.'/plugins/'.$domain.'/'.$domain.'-'.$locale.'.mo');
  95. load_plugin_textdomain($domain, FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
  96. }
  97. add_action('after_setup_theme', 'booked_fea_local_init');