Guest User

Untitled

a guest
Oct 6th, 2018
42
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /* # Plugin Name: Appointment Calendar
  3. # Version: 2.9.4
  4. # Description: Easily accept and manage online appointments on your WordPress blog.
  5. # Author: Scientech It Solution
  6. # Author URI: http://www.appointzilla.com
  7. # Plugin URI: http://appointzilla.com/see-a-demo/
  8.  
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 3 of the License, or
  12. # (at your option) any later version.
  13.  
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18.  
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22.  
  23. // Exit if accessed directly.
  24. if ( ! defined( 'ABSPATH' ) ) exit;
  25.  
  26. define("appointzilladir", plugin_dir_path( __FILE__ ));
  27. define("appointzillaurl", plugin_dir_url( __FILE__ ));
  28.  
  29. // Run 'Install' script on plugin activation
  30. register_activation_hook( __FILE__, 'appointzilla_installscript' );
  31. function appointzilla_installscript(){
  32. require_once('install-script.php');
  33. }
  34.  
  35. // Translate all text & labels of plugin
  36. add_action('plugins_loaded', 'appointzilla_loadpluginlanguage');
  37. function appointzilla_loadpluginlanguage() {
  38. load_plugin_textdomain('appointzilla', FALSE, dirname( plugin_basename(__FILE__)).'/languages/' );
  39. }
  40.  
  41. // Admin dashboard Menu Pages For Booking Calendar Plugin
  42. add_action('admin_menu','appointzilla_calendar_menu');
  43. function appointzilla_calendar_menu() {
  44.  
  45.  
  46. $user = wp_get_current_user();
  47. if ( in_array( 'editor', (array) $user->roles ) ) {
  48. //The user has the "author" role
  49. $user_role = 'editor';
  50.  
  51. } else {
  52.  
  53. $user_role = 'administrator';
  54. }
  55.  
  56.  
  57. //create new top-level menu 'appointment-calendar'
  58. $menu = add_menu_page('Appointment Calendar', __('Appointment Calendar', 'appointzilla'), $user_role, 'appointment-calendar', '', 'dashicons-calendar');
  59.  
  60. // Calendar Page
  61. $SubMenu1 = add_submenu_page( 'appointment-calendar', 'Admin Calendar', __('Admin Calendar', 'appointzilla'), $user_role, 'appointment-calendar', 'appointzilla_display_calendar_page' );
  62.  
  63. // Time sloat Page
  64. $SubMenu2 = add_submenu_page( '', 'Manage Time Slot', '', $user_role, 'time_slot', 'appointzilla_display_time_slot_page' );
  65.  
  66. // Data Save Page
  67. $SubMenu3 = add_submenu_page( '', 'Data Save', '', $user_role, 'data-save', 'appointzilla_display_data_save_page' );
  68.  
  69. // Service Page
  70. $SubMenu4 = add_submenu_page( 'appointment-calendar', 'Services', __('Services', 'appointzilla'), $user_role, 'service', 'appointzilla_display_service_page' );
  71.  
  72. // manage Service Page
  73. $SubMenu5 = add_submenu_page( '', 'Manage Service', '', $user_role, 'manage-service', 'appointzilla_display_manage_service_page' );
  74. // Time-Off Page
  75. $SubMenu6 = add_submenu_page( 'appointment-calendar', 'Time Off', __('Time Off', 'appointzilla'), $user_role, 'timeoff', 'appointzilla_display_time_off_page' );
  76.  
  77. // Update Time-Off Page
  78. $SubMenu7 = add_submenu_page( '', 'Update TimeOff', '', $user_role, 'update-time-off', 'appointzilla_display_update_time_off_page' );
  79.  
  80. // Manage Appointment Page
  81. $SubMenu8 = add_submenu_page( 'appointment-calendar', 'Appointments', __('Appointments', 'appointzilla'), $user_role, 'manage-appointments', 'appointzilla_display_manage_appointment_page' );
  82.  
  83. // Update Appointments Page
  84. $SubMenu9 = add_submenu_page( '', 'Update Appointment', '', $user_role, 'update-appointment', 'appointzilla_display_update_appointment_page' );
  85.  
  86. // Settings Page
  87. $SubMenu10 = add_submenu_page( 'appointment-calendar', 'Settings', __('Settings', 'appointzilla'), $user_role, 'settings', 'appointzilla_display_settings_page' );
  88.  
  89. // Export Lists
  90. $SubMenu17 = add_submenu_page( 'appointment-calendar', 'Export Lists', __('Export Appointments', 'appointzilla'), $user_role, 'apcal-export-lists', 'appointzilla_display_export_lists_page' );
  91.  
  92. // Remove Plugin
  93. $SubMenu14 = add_submenu_page( 'appointment-calendar', 'Remove Plugin Data', __('Remove Plugin Data', 'appointzilla'), $user_role, 'uninstall-plugin', 'appointzilla_display_uninstall_plugin_page' );
  94.  
  95. // Help & Support
  96. $SubMenu16 = add_submenu_page( 'appointment-calendar', 'Help & Support', __('Help & Support', 'appointzilla'), $user_role, 'help-support', 'appointzilla_display_help_and_support_page' );
  97.  
  98. // Get Premium Plugin
  99. $SubMenu15 = add_submenu_page( 'appointment-calendar', 'Get Appointment Calendar Premium Plugin', __('Premium Plugin', 'appointzilla'), $user_role, 'get-premium-plugin', 'appointzilla_display_get_premium_plugin_page' );
  100.  
  101. //Get Premium Themes
  102. $SubMenu18 = add_submenu_page( 'appointment-calendar', 'Webriti Premium Themes', __('Premium Themes', 'appointzilla'), $user_role, 'get-premium-themes', 'appointzilla_display_get_premium_themes_page' );
  103.  
  104. add_action( 'admin_print_styles-' . $menu, 'appointzilla_calendar_css_js' );
  105.  
  106. //calendar
  107. add_action( 'admin_print_styles-' . $SubMenu1, 'appointzilla_calendar_css_js' );
  108. add_action( 'admin_print_styles-' . $SubMenu2, 'appointzilla_calendar_css_js' );
  109. add_action( 'admin_print_styles-' . $SubMenu3, 'appointzilla_calendar_css_js' );
  110.  
  111. //service
  112. add_action( 'admin_print_styles-' . $SubMenu4, 'appointzilla_other_pages_css_js' );
  113.  
  114. add_action( 'admin_print_styles-' . $SubMenu5, 'appointzilla_other_pages_css_js' );
  115.  
  116. //time-off
  117. add_action( 'admin_print_styles-' . $SubMenu6, 'appointzilla_other_pages_css_js' );
  118.  
  119. add_action( 'admin_print_styles-' . $SubMenu7, 'appointzilla_other_pages_css_js' );
  120.  
  121. //manage app
  122. add_action( 'admin_print_styles-' . $SubMenu8, 'appointzilla_other_pages_css_js' );
  123.  
  124. add_action( 'admin_print_styles-' . $SubMenu9, 'appointzilla_other_pages_css_js' );
  125.  
  126. //calendar settings
  127. add_action( 'admin_print_styles-' . $SubMenu10, 'appointzilla_other_pages_css_js' );
  128.  
  129. //remove plugin
  130. add_action( 'admin_print_styles-' . $SubMenu14, 'appointzilla_other_pages_css_js' );
  131.  
  132. //Get Premium plugin
  133. add_action( 'admin_print_styles-' . $SubMenu15, 'appointzilla_other_pages_css_js' );
  134.  
  135. //help & support
  136. add_action( 'admin_print_styles-' . $SubMenu16, 'appointzilla_other_pages_css_js' );
  137.  
  138. //export lists
  139. add_action('admin_print_styles-' . $SubMenu17, 'appointzilla_other_pages_css_js');
  140.  
  141. //get premium themes
  142. add_action('admin_print_styles-' . $SubMenu18, 'appointzilla_other_pages_css_js');
  143.  
  144. }//end of menu function
  145.  
  146. function appointzilla_calendar_css_js() {
  147. wp_enqueue_script( 'jquery' );
  148. wp_enqueue_script( 'jquery-ui-core' );
  149. wp_enqueue_script( 'jquery-custom' );
  150. wp_enqueue_script( 'jquery-ui-slider' );
  151.  
  152. wp_enqueue_script('full-calendar-min-js', plugins_url('/menu-pages/fullcalendar-assets-new/js/fullcalendar.min.js', __FILE__),array('jquery-ui-datepicker'));
  153.  
  154. wp_register_style('bootstrap-css', plugins_url('/menu-pages/bootstrap-assets/css/bootstrap.css', __FILE__));
  155. wp_enqueue_style('bootstrap-css');
  156.  
  157. wp_enqueue_style('full-calendar-css', plugins_url('/menu-pages/fullcalendar-assets-new/css/fullcalendar.css', __FILE__));
  158. wp_enqueue_style('date-picker-css', plugins_url('/menu-pages/datepicker-assets/css/jquery-ui-1.8.23.custom.css', __FILE__));
  159.  
  160. //font-awesome js n css
  161. wp_enqueue_style('font-awesome-css', plugins_url('/menu-pages/font-awesome-assets/css/font-awesome.css', __FILE__));
  162.  
  163. }
  164.  
  165. function appointzilla_other_pages_css_js() {
  166. // bootstrap css files
  167. wp_register_style('bootstrap-css', plugins_url('/menu-pages/bootstrap-assets/css/bootstrap.css', __FILE__));
  168. wp_enqueue_style('bootstrap-css');
  169.  
  170. wp_enqueue_script( 'jquery' );
  171. wp_enqueue_script( 'jquery-ui-core' );
  172. wp_enqueue_script( 'jquery-custom' );
  173. wp_enqueue_script( 'jquery-ui-slider' );
  174.  
  175. wp_enqueue_script('tooltip', plugins_url('/menu-pages/bootstrap-assets/js/bootstrap-tooltip.js', __FILE__));
  176. wp_enqueue_script('bootstrap-affix', plugins_url('/menu-pages/bootstrap-assets/js/bootstrap-affix.js', __FILE__));
  177. wp_enqueue_script('bootstrap-application', plugins_url('/menu-pages/bootstrap-assets/js/application.js', __FILE__));
  178.  
  179. // font-awesome js n css
  180. wp_enqueue_style('font-awesome-css', plugins_url('/menu-pages/font-awesome-assets/css/font-awesome.css', __FILE__));
  181.  
  182. // date-picker-css
  183. wp_enqueue_style('date-picker-css', plugins_url('/menu-pages/datepicker-assets/css/jquery-ui-1.8.23.custom.css', __FILE__));
  184.  
  185. // export
  186. wp_enqueue_script('jquery-ui-timepicker', plugins_url('/menu-pages/timepicker-assets/js/jquery-ui-timepicker-addon.js', __FILE__),array('jquery-ui-datepicker'));
  187. wp_enqueue_script('jquery-date', plugins_url('/menu-pages/js/date.js', __FILE__));
  188.  
  189. // bootstrap js files
  190. wp_enqueue_script('bootstrap-js', plugins_url('/menu-pages/bootstrap-assets/js/bootstrap.js', __FILE__));
  191. wp_enqueue_script('bootstrap-min-js', plugins_url('/menu-pages/bootstrap-assets/js/bootstrap.min.js', __FILE__));
  192. wp_enqueue_script('bootstrap-tab-js', plugins_url('/menu-pages/bootstrap-assets/js/bootstrap-tab.js', __FILE__));
  193.  
  194. }
  195.  
  196.  
  197.  
  198. function appointzilla_short_code_detect() {
  199. global $wp_query;
  200. $posts = $wp_query->posts;
  201. $pattern = get_shortcode_regex();
  202. foreach ($posts as $post){
  203.  
  204. if(isset($post->post_content)){
  205.  
  206. if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( 'APCAL_PC', $matches[2] ) || in_array( 'APCAL_MOBILE', $matches[2] ) || in_array( 'APCAL', $matches[2] ) ) {
  207.  
  208. // full-calendar scripts
  209. wp_enqueue_style('fullcalendar-css', plugins_url('/menu-pages/fullcalendar-assets-new/css/fullcalendar.css', __FILE__));
  210.  
  211. wp_enqueue_script( 'jquery' );
  212. wp_enqueue_script( 'jquery-ui-core' );
  213. wp_enqueue_script( 'jquery-custom' );
  214. wp_enqueue_script( 'jquery-ui-slider' );
  215.  
  216. wp_enqueue_script('full-calendar', plugins_url('/menu-pages/fullcalendar-assets-new/js/fullcalendar.min.js', __FILE__),array('jquery-ui-datepicker'));
  217.  
  218. // calendar js
  219. wp_enqueue_script('calendar', plugins_url('calendar/calendar.js', __FILE__));
  220.  
  221. // moment min css
  222. wp_enqueue_script('moment-min', plugins_url('calendar/moment.min.js', __FILE__));
  223.  
  224. // bootstrap apcal
  225. wp_enqueue_style('bootstrap-apcal', plugins_url('/menu-pages/bootstrap-assets/css/bootstrap-apcal.css', __FILE__));
  226.  
  227. // datepicker css
  228. wp_enqueue_style('datepicker-css', plugins_url('/menu-pages/datepicker-assets/css/jquery-ui-1.8.23.custom.css', __FILE__));
  229. break;
  230. }
  231. }
  232.  
  233. }
  234. }
  235. add_action( 'wp', 'appointzilla_short_code_detect' );
  236.  
  237.  
  238.  
  239. //calendar page
  240. function appointzilla_display_calendar_page() {
  241. require_once('menu-pages/calendar.php');
  242. }
  243. //time slot page
  244. function appointzilla_display_time_slot_page() {
  245. require_once("menu-pages/appointment-form2.php");
  246. }
  247. //appointment save page
  248. function appointzilla_display_data_save_page() {
  249. require_once("menu-pages/data-save.php");
  250. }
  251. //service page
  252. function appointzilla_display_service_page() {
  253. require_once("menu-pages/service.php");
  254. }
  255. //manage service page
  256. function appointzilla_display_manage_service_page() {
  257. require_once("menu-pages/manage-service.php");
  258. }
  259. //time-off page
  260. function appointzilla_display_time_off_page() {
  261. require_once("menu-pages/timeoff.php");
  262. }
  263. //update-time-off page
  264. function appointzilla_display_update_time_off_page() {
  265. require_once("menu-pages/update-time-off.php");
  266. }
  267. //manage-appointment page
  268. function appointzilla_display_manage_appointment_page() {
  269. require_once("menu-pages/manage-appointments.php");
  270. }
  271. function appointzilla_display_update_appointment_page() {
  272. require_once("menu-pages/update-appointments.php");
  273. }
  274. //settings page
  275. function appointzilla_display_settings_page() {
  276. require_once("menu-pages/settings.php");
  277. }
  278. // Remove plugin
  279. function appointzilla_display_uninstall_plugin_page() {
  280. require_once("reset-plugin.php");
  281. }
  282. //get-premium-plugin page
  283. function appointzilla_display_get_premium_plugin_page() {
  284. require_once("menu-pages/get-premium-plugin.php");
  285. }
  286. //get-premium-themes page
  287. function appointzilla_display_get_premium_themes_page() {
  288. require_once("menu-pages/get-premium-themes.php");
  289. }
  290. //help & support page
  291. function appointzilla_display_help_and_support_page() {
  292. require_once("menu-pages/help-and-support.php");
  293. }
  294. //Export Lists
  295. function appointzilla_display_export_lists_page() {
  296. require_once("menu-pages/export-lists.php");
  297. }
  298.  
  299. // Delete all plugin data
  300. function appointzilla_delete_data()
  301. {
  302. global $wpdb;
  303.  
  304. //drop ap_appointments table
  305. $table_appointments = $wpdb->prefix . "ap_appointments";
  306. $wpdb->query("DROP TABLE `$table_appointments`");
  307.  
  308. //drop ap_events table
  309. $table_events = $wpdb->prefix . "ap_events";
  310. $events = "DROP TABLE `$table_events`";
  311. $wpdb->query($events);
  312.  
  313. //drop ap_services table
  314. $table_services = $wpdb->prefix . "ap_services";
  315. $services = "DROP TABLE `$table_services`";
  316. $wpdb->query($services);
  317.  
  318. //drop a service Category
  319. $table_service_category = $wpdb->prefix . "ap_service_category";
  320. $service_category = "DROP TABLE `$table_service_category`";
  321. $wpdb->query($service_category);
  322.  
  323. //delete all default calendar options & settings
  324. delete_option('apcal_calendar_settings');
  325.  
  326. //delete notification details
  327. delete_option('emailstatus');
  328. delete_option('emailtype');
  329. delete_option('emaildetails');
  330.  
  331. //delete notification messages
  332. delete_option('new_appointment_admin_subject');
  333. delete_option('new_appointment_admin_body');
  334.  
  335. delete_option('new_appointment_client_subject');
  336. delete_option('new_appointment_client_body');
  337.  
  338. delete_option('approve_appointment_client_subject');
  339. delete_option('approve_appointment_client_body');
  340.  
  341. delete_option('cancel_appointment_client_subject');
  342. delete_option('cancel_appointment_client_body');
  343. }
  344.  
  345. // Including Calendar Short-Code Page
  346. require_once("appointment-calendar-shortcode.php");
  347. require_once("appointment-calendar-mobile.php");
RAW Paste Data