function __construct() { $this->plugin_dir = plugin_dir_path(__FILE__); $this->plugin_url = plugins_url(basename(dirname(__FILE__))); // Read all options at once $this->options = get_option('appointments_options'); // To follow WP Start of week, time, date settings $this->local_time = current_time('timestamp'); if (!($this->start_of_week = get_option('start_of_week'))) { $this->start_of_week = 0; } $this->time_format = get_option('time_format'); if (empty($this->time_format)) { $this->time_format = "H:i"; } $this->date_format = get_option('date_format'); if (empty($this->date_format)) { $this->date_format = "Y-m-d"; } $this->datetime_format = $this->date_format . " " . $this->time_format; add_action('delete_user', array(&$this, 'delete_user')); // Modify database in case a user is deleted add_action('wpmu_delete_user', array(&$this, 'delete_user')); // Same as above add_action('remove_user_from_blog', array(&$this, 'remove_user_from_blog'), 10, 2); // Remove his records only for that blog add_action('plugins_loaded', array(&$this, 'localization')); // Localize the plugin add_action('init', array(&$this, 'init'), 20); // Initial stuff add_action('init', array(&$this, 'cancel'), 19); // Check cancellation of an appointment add_filter('the_posts', array(&$this, 'load_styles')); // Determine if we use shortcodes on the page add_action('wp_ajax_nopriv_app_paypal_ipn', array(&$this, 'handle_paypal_return')); // Send Paypal to IPN function // Add/edit some fields on the user pages add_action('show_user_profile', array(&$this, 'show_profile')); add_action('edit_user_profile', array(&$this, 'show_profile')); add_action('personal_options_update', array(&$this, 'save_profile')); add_action('edit_user_profile_update', array(&$this, 'save_profile')); // Admin hooks add_action('admin_menu', array(&$this, 'admin_init')); // Creates admin settings window add_action('admin_notices', array(&$this, 'admin_notices')); // Warns admin add_action('admin_print_scripts', array(&$this, 'admin_scripts')); // Load scripts add_action('admin_print_styles', array(&$this, 'admin_css')); // Add style to all admin pages //add_action( 'admin_print_styles-appointments_page_app_settings', array( &$this, 'admin_css_settings' ) ); // Add style to settings page - DEPRECATED since v1.4.2-BETA-2 add_action('right_now_content_table_end', array($this, 'add_app_counts')); // Add app counts add_action('wp_ajax_delete_log', array(&$this, 'delete_log')); // Clear log add_action('wp_ajax_inline_edit', array(&$this, 'inline_edit')); // Add/edit appointments add_action('wp_ajax_inline_edit_save', array(&$this, 'inline_edit_save')); // Save edits add_action('wp_ajax_js_error', array(&$this, 'js_error')); // Track js errors add_action('wp_ajax_app_export', array(&$this, 'export')); // Export apps // Front end ajax hooks add_action('wp_ajax_pre_confirmation', array(&$this, 'pre_confirmation')); // Get pre_confirmation results add_action('wp_ajax_nopriv_pre_confirmation', array(&$this, 'pre_confirmation')); // Get pre_confirmation results add_action('wp_ajax_post_confirmation', array(&$this, 'post_confirmation')); // Do after final confirmation add_action('wp_ajax_nopriv_post_confirmation', array(&$this, 'post_confirmation')); // Do after final confirmation add_action('wp_ajax_cancel_app', array(&$this, 'cancel')); // Cancel appointment from my appointments add_action('wp_ajax_nopriv_cancel_app', array(&$this, 'cancel')); // Cancel appointment from my appointments // API login after the options have been initialized add_action('init', array($this, 'setup_api_logins'), 10); // Widgets require_once $this->plugin_dir . '/includes/widgets.php'; add_action('widgets_init', array(&$this, 'widgets_init')); // Buddypress require_once $this->plugin_dir . '/includes/class_app_buddypress.php'; if (class_exists('App_BuddyPress')) { App_BuddyPress::serve(); } // Membership2 Integration $m2_integration = $this->plugin_dir . '/includes/class_app_membership2.php'; if (file_exists($m2_integration)) { require_once $m2_integration; } // Caching if ('yes' == @$this->options['use_cache']) { add_filter('the_content', array(&$this, 'pre_content'), 8); // Check content before do_shortcode add_filter('the_content', array(&$this, 'post_content'), 100); // Serve this later than do_shortcode add_action('wp_footer', array(&$this, 'save_script'), 8); // Save script to database add_action('permalink_structure_changed', array(&$this, 'flush_cache')); // Clear cache in case permalink changed add_action('save_post', array(&$this, 'save_post'), 10, 2); // Clear cache if it has shortcodes } $this->pages_to_be_cached = array(); $this->had_filter = false; // There can be a wpautop filter. We will check this later on. // Membership integration $this->membership_active = false; add_action('plugins_loaded', array(&$this, 'check_membership_plugin')); // Marketpress integration $this->marketpress_active = $this->mp = false; $this->mp_posts = array(); add_action('plugins_loaded', array(&$this, 'check_marketpress_plugin')); $this->gcal_api = false; add_action('init', array($this, 'setup_gcal_sync'), 10); // Database variables global $wpdb; $this->db =& $wpdb; $this->wh_table = $wpdb->prefix . "app_working_hours"; $this->exceptions_table = $wpdb->prefix . "app_exceptions"; $this->services_table = $wpdb->prefix . "app_services"; $this->workers_table = $wpdb->prefix . "app_workers"; $this->app_table = $wpdb->prefix . "app_appointments"; $this->transaction_table = $wpdb->prefix . "app_transactions"; $this->cache_table = $wpdb->prefix . "app_cache"; // DB version $this->db_version = get_option('app_db_version'); // Set log file location $uploads = wp_upload_dir(); if (isset($uploads["basedir"])) { $this->uploads_dir = $uploads["basedir"] . "/"; } else { $this->uploads_dir = WP_CONTENT_DIR . "/uploads/"; } $this->log_file = $this->uploads_dir . "appointments-log.txt"; // Other default settings $this->script = $this->uri = $this->error_url = ''; $this->location = $this->service = $this->worker = 0; $this->gcal_image = '<img src="' . $this->plugin_url . '/images/gc_button1.gif" />'; $this->locale_error = false; // Create a salt, if it doesn't exist from the previous installation if (!($salt = get_option("appointments_salt"))) { $salt = mt_rand(); add_option("appointments_salt", $salt); // Save it to be used until it is cleared manually } $this->salt = $salt; // Deal with zero-priced appointments auto-confirm if ('yes' == $this->options['payment_required'] && !empty($this->options['allow_free_autoconfirm'])) { if (!defined('APP_CONFIRMATION_ALLOW_FREE_AUTOCONFIRM')) { define('APP_CONFIRMATION_ALLOW_FREE_AUTOCONFIRM', true); } } }
function __construct() { include_once 'includes/helpers.php'; $this->plugin_dir = plugin_dir_path(__FILE__); $this->plugin_url = plugins_url(basename(dirname(__FILE__))); // Read all options at once $this->options = get_option('appointments_options'); // To follow WP Start of week, time, date settings $this->local_time = current_time('timestamp'); if (!($this->start_of_week = get_option('start_of_week'))) { $this->start_of_week = 0; } $this->time_format = get_option('time_format'); if (empty($this->time_format)) { $this->time_format = "H:i"; } $this->date_format = get_option('date_format'); if (empty($this->date_format)) { $this->date_format = "Y-m-d"; } $this->datetime_format = $this->date_format . " " . $this->time_format; add_action('delete_user', array(&$this, 'delete_user')); // Modify database in case a user is deleted add_action('wpmu_delete_user', array(&$this, 'delete_user')); // Same as above add_action('remove_user_from_blog', array(&$this, 'remove_user_from_blog'), 10, 2); // Remove his records only for that blog add_action('plugins_loaded', array(&$this, 'localization')); // Localize the plugin add_action('init', array(&$this, 'init'), 20); // Initial stuff add_action('init', array(&$this, 'cancel'), 19); // Check cancellation of an appointment add_filter('the_posts', array(&$this, 'load_styles')); // Determine if we use shortcodes on the page add_action('admin_init', array($this, 'maybe_upgrade')); include_once 'includes/class-app-service.php'; include_once 'includes/class-app-worker.php'; include_once 'includes/class-app-appointment.php'; if (is_admin()) { include_once 'admin/class-app-admin.php'; $this->admin = new Appointments_Admin(); } if (defined('DOING_AJAX') && DOING_AJAX) { include_once 'includes/class-app-ajax.php'; new Appointments_AJAX(); } // API login after the options have been initialized add_action('init', array($this, 'setup_api_logins'), 10); // Check for cookies if (!empty($this->options['login_required']) && 'yes' === $this->options['login_required']) { // If we require a login and we had an user logged in, // we don't need cookies after they log out add_action('wp_logout', array($this, 'drop_cookies_on_logout')); } // Widgets require_once $this->plugin_dir . '/includes/widgets.php'; add_action('widgets_init', array(&$this, 'widgets_init')); // Buddypress require_once $this->plugin_dir . '/includes/class_app_buddypress.php'; if (class_exists('App_BuddyPress')) { App_BuddyPress::serve(); } // Membership2 Integration $m2_integration = $this->plugin_dir . '/includes/class_app_membership2.php'; if (file_exists($m2_integration)) { require_once $m2_integration; } // Caching if ('yes' == @$this->options['use_cache']) { add_filter('the_content', array(&$this, 'pre_content'), 8); // Check content before do_shortcode add_filter('the_content', array(&$this, 'post_content'), 100); // Serve this later than do_shortcode add_action('wp_footer', array(&$this, 'save_script'), 8); // Save script to database add_action('permalink_structure_changed', array(&$this, 'flush_cache')); // Clear cache in case permalink changed add_action('save_post', array(&$this, 'save_post'), 10, 2); // Clear cache if it has shortcodes } $this->pages_to_be_cached = array(); $this->had_filter = false; // There can be a wpautop filter. We will check this later on. // Membership integration $this->membership_active = false; add_action('plugins_loaded', array(&$this, 'check_membership_plugin')); // Marketpress integration $this->marketpress_active = $this->mp = false; $this->mp_posts = array(); add_action('plugins_loaded', array(&$this, 'check_marketpress_plugin')); $this->gcal_api = false; add_action('init', array($this, 'setup_gcal_sync'), 10); // Database variables global $wpdb; $this->db =& $wpdb; $this->wh_table = $wpdb->prefix . "app_working_hours"; $this->exceptions_table = $wpdb->prefix . "app_exceptions"; $this->services_table = $wpdb->prefix . "app_services"; $this->workers_table = $wpdb->prefix . "app_workers"; $this->app_table = $wpdb->prefix . "app_appointments"; $this->transaction_table = $wpdb->prefix . "app_transactions"; $this->cache_table = $wpdb->prefix . "app_cache"; // DB version $this->db_version = get_option('app_db_version'); // Set log file location $uploads = wp_upload_dir(); if (isset($uploads["basedir"])) { $this->uploads_dir = $uploads["basedir"] . "/"; } else { $this->uploads_dir = WP_CONTENT_DIR . "/uploads/"; } $this->log_file = $this->uploads_dir . "appointments-log.txt"; // Other default settings $this->script = $this->uri = $this->error_url = ''; $this->location = $this->service = $this->worker = 0; $this->gcal_image = '<img src="' . $this->plugin_url . '/images/gc_button1.gif" />'; $this->locale_errlocale_error = false; // Create a salt, if it doesn't exist from the previous installation if (!($salt = get_option("appointments_salt"))) { $salt = mt_rand(); add_option("appointments_salt", $salt); // Save it to be used until it is cleared manually } $this->salt = $salt; // Deal with zero-priced appointments auto-confirm if (isset($this->options['payment_required']) && 'yes' == $this->options['payment_required'] && !empty($this->options['allow_free_autoconfirm'])) { if (!defined('APP_CONFIRMATION_ALLOW_FREE_AUTOCONFIRM')) { define('APP_CONFIRMATION_ALLOW_FREE_AUTOCONFIRM', true); } } }