public function process_shortcode($args = array(), $content = '') { global $appointments; $args = wp_parse_args($args, $this->_defaults_to_args()); $services = $appointments->get_services($args['order_by']); $model = App_Locations_Model::get_instance(); $locations = array(); foreach ($services as $srv) { if (empty($srv->ID)) { continue; } $location_id = App_Locations_ServiceLocations::service_to_location_id($srv->ID); if (!empty($location_id)) { $locations[$location_id] = $model->find_by('id', $location_id); } } $locations = array_values(array_filter($locations)); if (empty($locations)) { return $content; } $ret = ''; $ret .= '<div class="app_service_locations">'; $ret .= '<div class="app_service_locations_dropdown">'; $ret .= '<div class="app_service_locations_dropdown_title">'; $ret .= $args['select']; $ret .= '</div>'; $ret .= '<div class="app_service_locations_dropdown_select">'; $ret .= '<select name="app_service_location">'; foreach ($locations as $location) { /** @var App_Locations_DefaultLocation $location */ $ret .= '<option value="' . esc_attr($location->get_id()) . '" ' . selected($this->_requested_location_id, $location->get_id(), false) . '>' . esc_html($location->get_display_markup(false)) . '</option>'; } $ret .= '</select>'; if (empty($args['autorefresh'])) { $ret .= '<input type="button" class="app_service_locations_button" value="' . esc_attr($args['show']) . '">'; } $ret .= '</div>'; $ret .= '</div>'; $href = add_query_arg('app_service_location', '::asl::', remove_query_arg(array('app_provider_location', 'app_provider_id'))); $script = <<<EO_SELECTION_JAVASCRIPT function app_service_locations_redirect () { \tvar selected = \$(".app_service_locations_dropdown_select select").first().val(); \twindow.location = '{$href}'.replace(/::asl::/, selected); } \$(".app_service_locations_button").click(app_service_locations_redirect); EO_SELECTION_JAVASCRIPT; if (!empty($args['autorefresh'])) { $script .= '$(".app_service_locations_dropdown_select select").change(app_service_locations_redirect);'; } $appointments->add2footer($script); return $ret; }
public function initialize() { if (!class_exists('App_Locations_Model')) { return false; } global $appointments; $this->_data = $appointments->options; if (empty($this->_data['service_locations'])) { $this->_data['service_locations'] = array(); } $this->_locations = App_Locations_Model::get_instance(); if (empty($this->_data['service_locations']['insert']) || 'manual' == $this->_data['service_locations']['insert']) { add_shortcode('app_service_location', array($this, 'process_shortcode')); } else { add_shortcode('app_service_location', '__return_false'); add_filter('app-services-service_description', array($this, 'inject_location_markup'), 10, 3); } if (!class_exists('App_Shortcode_ServiceLocationsShortcode')) { require_once dirname(__FILE__) . '/lib/app_service_locations_shortcode.php'; App_Shortcode_ServiceLocationsShortcode::serve(); App_Shortcode_RequiredServiceLocationsShortcode::serve(); } }
public function initialize() { global $appointments; $this->_data = $appointments->options; if (!class_exists('App_Locations_Model')) { require_once dirname(__FILE__) . '/lib/app_locations.php'; } $this->_locations = App_Locations_Model::get_instance(); if (!empty($this->_data['google_maps']['my_appointments'])) { add_filter('app_my_appointments_after_table', array($this, 'add_joint_my_appointments_map'), 10, 2); } if (!empty($this->_data['google_maps']['all_appointments'])) { add_filter('app_all_appointments_after_table', array($this, 'add_joint_my_appointments_map'), 10, 2); } }
public function initialize() { global $appointments; $this->_data = $appointments->options; if (!class_exists('App_Locations_Model')) { require_once dirname(__FILE__) . '/lib/app_locations.php'; } $this->_locations = App_Locations_Model::get_instance(); do_action('app-locations-initialized'); if (!empty($this->_data['locations_settings']['my_appointments'])) { $injection_point = $this->_data['locations_settings']['my_appointments']; add_filter('app_my_appointments_column_name', array($this, 'my_appointments_headers'), 1); add_filter('app-shortcode-my_appointments-' . $injection_point, array($this, 'my_appointments_address'), 1, 2); } if (!empty($this->_data['locations_settings']['all_appointments'])) { $injection_point = $this->_data['locations_settings']['all_appointments']; add_filter('app_all_appointments_column_name', array($this, 'all_appointments_headers'), 1); add_filter('app-shortcode-all_appointments-' . $injection_point, array($this, 'all_appointments_address'), 1, 2); } // Add macro expansion filtering add_filter('app-codec-macros', array($this, 'add_to_macro_list')); add_filter('app-codec-macro_default-replace_location', array($this, 'expand_location_macro'), 10, 3); add_filter('app-codec-macro_default-replace_location_address', array($this, 'expand_location_address_macro'), 10, 2); // Email filters add_filter('app_notification_message', array($this, 'expand_location_macro'), 10, 2); add_filter('app_notification_message', array($this, 'expand_location_address_macro'), 10, 2); add_filter('app_confirmation_message', array($this, 'expand_location_macro'), 10, 2); add_filter('app_confirmation_message', array($this, 'expand_location_address_macro'), 10, 2); add_filter('app_reminder_message', array($this, 'expand_location_macro'), 10, 2); add_filter('app_reminder_message', array($this, 'expand_location_address_macro'), 10, 2); add_filter('app_removal_notification_message', array($this, 'expand_location_macro'), 10, 2); add_filter('app_removal_notification_message', array($this, 'expand_location_address_macro'), 10, 2); // GCal expansion filters add_filter('app-gcal-set_summary', array($this, 'expand_location_macro'), 10, 2); add_filter('app-gcal-set_summary', array($this, 'expand_location_address_macro'), 10, 2); add_filter('app-gcal-set_description', array($this, 'expand_location_macro'), 10, 2); add_filter('app-gcal-set_description', array($this, 'expand_location_address_macro'), 10, 2); }