protected function setup() { Tribe__Events__Main::instance()->displaying = 'day'; $this->shortcode->prepare_default(); Tribe__Events__Pro__Template_Factory::asset_package('ajax-dayview'); $this->shortcode->set_template_object(new Tribe__Events__Template__Day($this->shortcode->get_query_args())); }
/** * Constructor! */ protected function __construct() { $this->main = Tribe__Events__Main::instance(); $this->register_default_linked_post_types(); add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); }
/** * Sets up and renders the event meta box for the specified existing event * or for a new event (if $event === null). * * @param null $event */ public function __construct($event = null) { $this->tribe = Tribe__Events__Main::instance(); $this->get_event($event); $this->setup_data(); $this->do_meta_box(); }
public function render() { $aggregator = Tribe__Events__Aggregator::instance(); $event_id = get_the_ID(); $record = Tribe__Events__Aggregator__Records::instance()->get_by_event_id($event_id); $last_import = null; $source = null; $origin = null; if (is_wp_error($record)) { $last_import = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$updated_key, true); $source = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$source_key, true); $origin = get_post_meta($event_id, Tribe__Events__Aggregator__Event::$origin_key, true); } else { $last_import = $record->post->post_modified; $source_info = $record->get_source_info(); $source = $source_info['title']; $origin = $record->origin; } $origin = $aggregator->api('origins')->get_name($origin); $datepicker_format = Tribe__Date_Utils::datepicker_formats(tribe_get_option('datepickerFormat')); $last_import = $last_import ? tribe_format_date($last_import, true, $datepicker_format . ' h:i a') : null; $settings_link = Tribe__Settings::instance()->get_url(array('tab' => 'imports')); $import_setting = tribe_get_option('tribe_aggregator_default_update_authority', Tribe__Events__Aggregator__Settings::$default_update_authority); include Tribe__Events__Main::instance()->plugin_path . 'src/admin-views/aggregator/meta-box.php'; }
/** * Filters the bases used to generate TEC rewrite rules to use WPML managed translations. * * @param array $bases * @param string $method * @param array $domains * * @return array An array of bases each with its (optional) WPML managed translations set. */ public function filter_tribe_events_rewrite_i18n_slugs_raw($bases, $method, $domains) { /** @var SitePress $sitepress */ global $sitepress, $sitepress_settings; if (empty($sitepress) || !is_a($sitepress, 'SitePress')) { return $bases; } $tec = Tribe__Events__Main::instance(); // Grab all languages $langs = $sitepress->get_active_languages(); if (empty($langs)) { return $bases; } foreach ($langs as $lang) { $languages[] = $sitepress->get_locale($lang['code']); } // Prevent Duplicates and Empty langs $languages = array_filter(array_unique($languages)); // Query the Current Language $current_locale = $sitepress->get_locale($sitepress->get_current_language()); // Get the strings on multiple Domains and Languages // remove WPML filter to avoid the locale being set to the default one remove_filter('locale', array($sitepress, 'locale_filter')); $bases = $tec->get_i18n_strings($bases, $languages, $domains, $current_locale); // re-hook WPML filter add_filter('locale', array($sitepress, 'locale_filter')); $string_translation_active = function_exists('wpml_st_load_slug_translation'); $post_slug_translation_on = !empty($sitepress_settings['posts_slug_translation']['on']); if ($string_translation_active && $post_slug_translation_on) { $bases = $this->translate_single_slugs($bases); } return $bases; }
function wpv_tribe_single_gmap() { $the_id = tribe_get_venue_id($GLOBALS['wpv_single_event_id']); $the_address = Tribe__Events__Main::instance()->fullAddressString($the_id); if (get_post_meta($GLOBALS['wpv_single_event_id'], '_EventShowMap', true) == '1') { echo WPV_Gmap::shortcode(array('address' => $the_address, 'height' => 500, 'html' => $the_address, 'popup' => true, 'scrollwheel' => false)); } }
public function test_get_constant_update_callbacks() { $current_version = Tribe__Events__Main::VERSION; $updater = Tribe__Events__Main::instance()->updater(); $contant_updates = $updater->get_constant_update_callbacks(); foreach ($contant_updates as $contant_update_callable) { $this->assertTrue(is_callable($contant_update_callable), 'checking constant update function is callable'); } }
protected function setup() { Tribe__Events__Main::instance()->displaying = 'list'; $this->shortcode->set_current_page(); $this->shortcode->prepare_default(); Tribe__Events__Template_Factory::asset_package('ajax-list'); $this->template = new Tribe__Events__Template__List($this->shortcode->get_query_args()); $this->shortcode->set_template_object($this->template); }
/** * Hooks the action to show an admin notice if a page with the `/events` slug exists on the site. */ public function maybe_add_admin_notice() { $this->archive_slug = Tribe__Events__Main::instance()->getOption('eventsSlug', 'events'); $page = get_page_by_path($this->archive_slug); if (!$page || $page->post_status == 'trash') { return; } $this->page = $page; add_action('admin_notices', array($this, 'notice')); }
protected function setup() { Tribe__Events__Main::instance()->displaying = 'photo'; $this->shortcode->set_current_page(); $this->shortcode->prepare_default(); Tribe__Events__Pro__Main::instance()->enqueue_pro_scripts(); Tribe__Events__Pro__Template_Factory::asset_package('events-pro-css'); Tribe__Events__Pro__Template_Factory::asset_package('ajax-photoview'); $this->shortcode->set_template_object(new Tribe__Events__Pro__Templates__Photo($this->shortcode->get_query_args())); }
/** * Add the agenda view rewrite rule * * @param $wp_rewrite the WordPress rewrite rules object * @return void **/ function tribe_events_agenda_add_routes($wp_rewrite) { // Get the instance of the TribeEvents plugin, and the rewriteSlug that the plugin uses $tec = Tribe__Events__Main::instance(); $tec_rewrite_slug = trailingslashit($tec->rewriteSlug); // create new rule for the agenda view $newRules = array($tec_rewrite_slug . 'agenda/?$' => 'index.php?post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=agenda'); // Add the new rule to the global rewrite rules array $wp_rewrite->rules = $newRules + $wp_rewrite->rules; }
/** * Used by createEvent and updateEvent - saves all the various event meta * * @param int $event_id The event ID we are modifying meta for. * @param array $data The meta fields we want saved. * @param WP_Post The event itself. * */ public static function saveEventMeta($event_id, $data, $event = null) { $tec = Tribe__Events__Main::instance(); $data = self::prepare_event_date_meta($event_id, $data); if (empty($data['EventHideFromUpcoming'])) { delete_metadata('post', $event_id, '_EventHideFromUpcoming'); } update_metadata('post', $event_id, '_EventShowMapLink', isset($data['venue']['EventShowMapLink'])); update_metadata('post', $event_id, '_EventShowMap', isset($data['venue']['EventShowMap'])); if (isset($data['post_status'])) { $post_status = $data['post_status']; } else { $post_status = get_post_status($event_id); } // Handle the submission of linked post type posts (like venue and organizer) Tribe__Events__Linked_Posts::instance()->handle_submission($event_id, $data); // Ordinarily there is a single cost value for each event, but addons (ie, ticketing plugins) may need // to record a number of different pricepoints for the same event $event_cost = isset($data['EventCost']) ? (array) $data['EventCost'] : array(); $data['EventCost'] = (array) apply_filters('tribe_events_event_costs', $event_cost, $event_id); if (isset($data['FeaturedImage']) && !empty($data['FeaturedImage'])) { update_metadata('post', $event_id, '_thumbnail_id', $data['FeaturedImage']); unset($data['FeaturedImage']); } do_action('tribe_events_event_save', $event_id); //update meta fields foreach ($tec->metaTags as $tag) { $htmlElement = ltrim($tag, '_'); if (isset($data[$htmlElement]) && $tag != Tribe__Events__Main::EVENTSERROROPT) { if (is_string($data[$htmlElement])) { $data[$htmlElement] = filter_var($data[$htmlElement], FILTER_SANITIZE_STRING); } // Fields with multiple values per key if (is_array($data[$htmlElement])) { delete_metadata('post', $event_id, $tag); foreach ($data[$htmlElement] as $value) { add_metadata('post', $event_id, $tag, $value); } } else { update_metadata('post', $event_id, $tag, $data[$htmlElement]); } } } // Set sticky state for calendar view. if ($event instanceof WP_Post) { if (isset($data['EventShowInCalendar']) && $data['EventShowInCalendar'] == 'yes' && $event->menu_order != '-1') { $update_event = array('ID' => $event_id, 'menu_order' => '-1'); wp_update_post($update_event); } elseif ((!isset($data['EventShowInCalendar']) || $data['EventShowInCalendar'] != 'yes') && $event->menu_order == '-1') { $update_event = array('ID' => $event_id, 'menu_order' => '0'); wp_update_post($update_event); } } do_action('tribe_events_update_meta', $event_id, $data); }
public static function process_general_form_submission() { if (!empty($_POST['tribe-import-general-settings']) && wp_verify_nonce($_POST['tribe-import-general-settings'], 'tribe-import-general-settings')) { $options = apply_filters('tribe-import-available-options', self::$options); $core = Tribe__Events__Main::instance(); foreach ($options as $_option) { $core->setOption($_option, $_POST[$_option]); } add_action('tribe-import-under-heading', array(__CLASS__, 'settings_saved_message')); } }
/** * Output a link for the mini calendar month next nav, includes data attributes needed to update the month with ajax * * @return void **/ function tribe_events_the_mini_calendar_next_link() { $tribe_ecp = Tribe__Events__Main::instance(); $args = tribe_events_get_mini_calendar_args(); try { $html = '<a class="tribe-mini-calendar-nav-link next-month" href="#" data-month="' . $tribe_ecp->nextMonth($args['eventDate']) . '-01" title="' . tribe_get_next_month_text() . '"><span>»</span></a>'; } catch (OverflowException $e) { $html = ''; } echo apply_filters('tribe_events_the_mini_calendar_next_link', $html); }
public function __construct($event = null, $post_type = null) { $this->tribe = Tribe__Events__Main::instance(); $this->linked_posts = Tribe__Events__Linked_Posts::instance(); $this->post_type = $post_type; $this->singular_name = $this->linked_posts->linked_post_types[$this->post_type]['singular_name']; $this->singular_name_lowercase = $this->linked_posts->linked_post_types[$this->post_type]['singular_name_lowercase']; $this->get_event($event); add_action('wp', array($this, 'sticky_form_data'), 50); // Later than events-admin.js itself is enqueued }
/** * Setup all the hooks and filters * * @return void */ private function __construct() { $plugin = Tribe__Events__Main::instance(); // Hook the AJAX methods add_action('wp_ajax_tribe_convert_legacy_facebook_settings', array($this, 'ajax_convert_facebook_settings')); add_action('wp_ajax_tribe_convert_legacy_ical_settings', array($this, 'ajax_convert_ical_settings')); // Hook the Notice for the Migration tribe_notice('tribe-aggregator-migrate-legacy-settings', array($this, 'notice'), 'type=warning'); // Register Assets tribe_asset($plugin, 'tribe-migrate-legacy-settings', 'aggregator-admin-legacy-settings.js', array('jquery'), 'admin_enqueue_scripts'); }
/** * Adds content to the embed head tag * * The embed header DOES NOT have wp_head() executed inside of it. Instead, any scripts/styles * are explicitly output */ public function embed_head() { $css_path = Tribe__Events__Template_Factory::getMinFile(Tribe__Events__Main::instance()->plugin_url . 'src/resources/css/tribe-events-embed.css', true); $css_path = add_query_arg('ver', Tribe__Events__Main::VERSION, $css_path); ?> <link rel="stylesheet" id="tribe-events-embed-css" href="<?php echo esc_url($css_path); ?> " type="text/css" media="all"> <?php }
public function handle() { $http = is_ssl() ? 'https' : 'http'; $url = apply_filters('tribe_events_pro_google_maps_api', $http . '://maps.google.com/maps/api/js'); wp_register_script('tribe-gmaps', $url, array('tribe-events-pro')); $path = Tribe__Events__Template_Factory::getMinFile(tribe_events_pro_resource_url('tribe-events-ajax-maps.js'), true); wp_register_script('tribe-events-pro-geoloc', $path, array('tribe-gmaps', Tribe__Events__Template_Factory::get_placeholder_handle()), apply_filters('tribe_events_pro_js_version', Tribe__Events__Pro__Main::VERSION)); wp_enqueue_script('tribe-events-pro-geoloc'); $geoloc = Tribe__Events__Pro__Geo_Loc::instance(); $data = array('ajaxurl' => admin_url('admin-ajax.php', $http), 'nonce' => wp_create_nonce('tribe_geosearch'), 'map_view' => 'map' == Tribe__Events__Main::instance()->displaying ? true : false); wp_localize_script('tribe-events-pro-geoloc', 'GeoLoc', $data); }
/** * Google Calendar Link * * Returns an "add to Google Calendar link for a single event. Must be used in the loop * * @param int $postId (optional) * * @return string URL for google calendar. */ function tribe_get_gcal_link($postId = null) { $postId = Tribe__Events__Main::postIdHelper($postId); $output = Tribe__Events__Main::instance()->googleCalendarLink($postId); /** * Filters the Google Calendar gcal link * * @param string $output Gcal link * @param int $postId WP Post ID of an event */ return apply_filters('tribe_get_gcal_link', $output, $postId); }
/** * Get the IDs of all organizers associated with an event * * @param int $event_id The event post ID. Defaults to the current event. * * @return array */ function tribe_get_organizer_ids($event_id = null) { $event_id = Tribe__Events__Main::postIdHelper($event_id); $organizer_ids = array(); if (is_numeric($event_id) && $event_id > 0) { if (Tribe__Events__Main::instance()->isOrganizer($event_id)) { $organizer_ids[] = $event_id; } else { $organizer_ids = tribe_get_event_meta($event_id, '_EventOrganizerID', false); } } return apply_filters('tribe_get_organizer_ids', $organizer_ids, $event_id); }
public function test_update_only_runs_once() { Tribe__Events__Main::instance()->setOption('schema-version', 0); remove_action('wp_loaded', 'flush_rewrite_rules'); $this->assertFalse(has_action('wp_loaded', 'flush_rewrite_rules')); $updater = new Tribe__Events__Updater('3.10a0'); $updater->do_updates(); $this->assertNotEmpty(has_action('wp_loaded', 'flush_rewrite_rules')); remove_action('wp_loaded', 'flush_rewrite_rules'); if ($updater->update_required()) { $updater->do_updates(); } $this->assertFalse(has_action('wp_loaded', 'flush_rewrite_rules')); }
/** * Test a non-linear closest event list * * The order should be: * * ID EventStartDate * 2 2015-12-01 12:00:00 * 1 2015-12-02 15:00:00 * 3 2015-12-02 15:00:00 * 4 2015-12-02 15:00:00 * 5 2015-12-03 16:00:00 */ public function test_closest_event_non_linear() { $main = \Tribe__Events__Main::instance(); $settings = $this->post_example_settings; unset($settings['EventHideFromUpcoming']); $settings['EventStartDate'] = date('Y-m-d', strtotime('+2 days')); $settings['EventEndDate'] = date('Y-m-d', strtotime('+2 days')); $settings['EventStartHour'] = '3'; $settings['EventStartMinute'] = '00'; $settings['EventStartMeridian'] = 'pm'; $settings['EventEndHour'] = '4'; $settings['EventEndMinute'] = '00'; $settings['EventEndMeridian'] = 'pm'; $post_id = tribe_create_event($settings); $post_1 = tribe_get_events(array('p' => $post_id))[0]; $settings['post_title'] = 'Test event 2'; $settings['EventStartDate'] = date('Y-m-d', strtotime('+1 day')); $settings['EventEndDate'] = date('Y-m-d', strtotime('+1 day')); $settings['EventStartHour'] = '12'; $settings['EventEndHour'] = '1'; $post_id = tribe_create_event($settings); $post_2 = tribe_get_events(array('p' => $post_id))[0]; $settings['post_title'] = 'Test event 3'; $settings['EventStartDate'] = date('Y-m-d', strtotime('+2 days')); $settings['EventEndDate'] = date('Y-m-d', strtotime('+2 days')); $settings['EventStartHour'] = '3'; $settings['EventEndHour'] = '4'; $post_id = tribe_create_event($settings); $post_3 = tribe_get_events(array('p' => $post_id))[0]; $settings['post_title'] = 'Test event 4'; $post_id = tribe_create_event($settings); $post_4 = tribe_get_events(array('p' => $post_id))[0]; $settings['post_title'] = 'Test event 5'; $settings['EventStartDate'] = date('Y-m-d', strtotime('+3 days')); $settings['EventEndDate'] = date('Y-m-d', strtotime('+3 days')); $settings['EventStartHour'] = '4'; $settings['EventEndHour'] = '5'; $post_id = tribe_create_event($settings); $post_5 = tribe_get_events(array('p' => $post_id))[0]; $this->assertEquals($post_2->ID, $main->get_closest_event($post_1, 'previous')->ID, "Post 1's previous post should be Post 2"); $this->assertEquals($post_3->ID, $main->get_closest_event($post_1, 'next')->ID, "Post 1's next post should be Post 3"); $this->assertEquals(null, $main->get_closest_event($post_2, 'previous'), "Post 2's previous post should be null"); $this->assertEquals($post_1->ID, $main->get_closest_event($post_2, 'next')->ID, "Post 2's next post should be Post 1"); $this->assertEquals($post_1->ID, $main->get_closest_event($post_3, 'previous')->ID, "Post 3's previous post should be Post 1"); $this->assertEquals($post_4->ID, $main->get_closest_event($post_3, 'next')->ID, "Post 3's next post should be Post 4"); $this->assertEquals($post_3->ID, $main->get_closest_event($post_4, 'previous')->ID, "Post 4's previous post should be Post 3"); $this->assertEquals($post_5->ID, $main->get_closest_event($post_4, 'next')->ID, "Post 4's next post should be Post 5"); $this->assertEquals($post_4->ID, $main->get_closest_event($post_5, 'previous')->ID, "Post 5's previous post should be Post 4"); $this->assertEquals(null, $main->get_closest_event($post_5, 'next'), "Post 5's next post should be null"); }
/** * Organizer ID * * Returns the event Organizer ID. * * @param int $postId Can supply either event id or organizer id, if none specified, current post is used * * @return int Organizer */ function tribe_get_organizer_id($postId = null) { $postId = Tribe__Events__Main::postIdHelper($postId); $organizer_id = null; if (is_numeric($postId) && $postId > 0) { $tribe_ecp = Tribe__Events__Main::instance(); // check if $postId is an organizer id if ($tribe_ecp->isOrganizer($postId)) { $organizer_id = $postId; } else { $organizer_id = tribe_get_event_meta($postId, '_EventOrganizerID', true); } } return apply_filters('tribe_get_organizer_id', $organizer_id, $postId); }
/** * Get the IDs of all organizers associated with an event * * @param int $event_id The event post ID. Defaults to the current event. * * @return array */ function tribe_get_organizer_ids($event_id = null) { $event_id = Tribe__Events__Main::postIdHelper($event_id); $organizer_ids = array(); if (is_numeric($event_id) && $event_id > 0) { if (Tribe__Events__Main::instance()->isOrganizer($event_id)) { $organizer_ids[] = $event_id; } else { $organizer_ids = tribe_get_event_meta($event_id, '_EventOrganizerID', false); // for some reason we store a blank "0" element in this array. // let's scrub this garbage out $organizer_ids = array_filter((array) $organizer_ids); } } return apply_filters('tribe_get_organizer_ids', $organizer_ids, $event_id); }
/** * AJAX handler for Photo view * * @return void */ public function ajax_response() { $tec = Tribe__Events__Main::instance(); Tribe__Events__Query::init(); $tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1; $post_status = array('publish'); if (is_user_logged_in()) { $post_status[] = 'private'; } $args = array('eventDisplay' => 'list', 'post_type' => Tribe__Events__Main::POSTTYPE, 'post_status' => $post_status, 'paged' => $tribe_paged); $view_state = 'photo'; if (isset($_POST['tribe_event_category'])) { $args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category']; } /* if past view */ if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $view_state = 'past'; $args['eventDisplay'] = 'past'; $args['order'] = 'DESC'; } $query = Tribe__Events__Query::getEvents($args, true); $hash = $query->query_vars; $hash['paged'] = null; $hash['start_date'] = null; $hash_str = md5(maybe_serialize($hash)); if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) { $tribe_paged = 1; $args['paged'] = 1; $query = Tribe__Events__Query::getEvents($args, true); } $response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'view' => $view_state); global $wp_query, $post; $wp_query = $query; if (!empty($query->posts)) { $post = $query->posts[0]; } add_filter('tribe_events_list_pagination', array('Tribe__Events__Main', 'clear_module_pagination'), 10); $tec->displaying = 'photo'; ob_start(); tribe_get_view('pro/photo/content'); $response['html'] .= ob_get_clean(); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; }
/** * Filters the bases used to generate TEC rewrite rules to use WPML managed translations. * * @param array $bases * @param string $method * @param array $domains * * @return array An array of bases each with its (optional) WPML managed translations set. */ public function filter_tribe_events_rewrite_i18n_slugs_raw($bases, $method, $domains) { /** @var SitePress $sitepress */ global $sitepress, $sitepress_settings; if (empty($sitepress) || !is_a($sitepress, 'SitePress')) { return $bases; } $tec = Tribe__Events__Main::instance(); // Grab all languages $langs = $sitepress->get_active_languages(); if (empty($langs)) { return $bases; } foreach ($langs as $lang) { $languages[] = $sitepress->get_locale($lang['code']); } // Prevent Duplicates and Empty langs $languages = array_filter(array_unique($languages)); // Query the Current Language $current_locale = $sitepress->get_locale($sitepress->get_current_language()); // Get the strings on multiple Domains and Languages // remove WPML filter to avoid the locale being set to the default one remove_filter('locale', array($sitepress, 'locale_filter')); $bases = $tec->get_i18n_strings($bases, $languages, $domains, $current_locale); // re-hook WPML filter add_filter('locale', array($sitepress, 'locale_filter')); $string_translation_active = function_exists('wpml_st_load_slug_translation'); $post_slug_translation_on = !empty($sitepress_settings['posts_slug_translation']['on']); if ($string_translation_active && $post_slug_translation_on) { $supported_post_types = array(Tribe__Events__Main::POSTTYPE); foreach ($supported_post_types as $post_type) { // check that translations are active for this CPT $cpt_slug_is_not_translated = empty($sitepress_settings['posts_slug_translation']['types'][$post_type]); if ($cpt_slug_is_not_translated) { continue; } $slug_translations = WPML_Slug_Translation::get_translations($post_type); if (!(is_array($slug_translations) && isset($slug_translations[1]))) { continue; } $bases['single'] = array_merge($bases['single'], wp_list_pluck($slug_translations[1], 'value')); } } return $bases; }
public function action_assets() { $plugin = Tribe__Events__Main::instance(); $localize = array(); if (!empty($_GET['post']) && self::instance()->can_ignore($_GET['post'])) { $post = get_post($_GET['post']); if (self::$ignored_status === $post->post_status) { $localize['single'] = array('link_text' => esc_html__('Delete Permanently', 'the-events-calendar'), 'link_title' => esc_attr__('Ignored events that are deleted will be removed permanently. They can be recreated via import.', 'the-events-calendar'), 'link_nonce' => wp_create_nonce('delete-post_' . $post->ID), 'link_post' => $post->ID, 'link_status' => esc_html__('Ignored', 'the-events-calendar')); } else { $localize['single'] = array('link_text' => esc_html__('Hide & Ignore', 'the-events-calendar'), 'link_title' => esc_attr__('Ignored events do not show on the calendar but can be updated with future imports', 'the-events-calendar')); } } if (isset($_GET['post_status']) && self::$ignored_status === $_GET['post_status']) { $localize['archive'] = array('delete_label' => esc_html__('Delete Permanently', 'the-events-calendar')); } $args = array('localize' => array('name' => 'tribe_ignore_events', 'data' => $localize)); tribe_asset($plugin, 'tribe-ignored-events', 'admin-ignored-events.js', array('jquery'), 'admin_enqueue_scripts', $args); }
/** * Configures an admin bar object adding menus, groups and nodes to it. * * @param WP_Admin_Bar $wp_admin_bar * * @return array An array of menus to add to the admin bar. */ public function configure(WP_Admin_Bar $wp_admin_bar) { $main = Tribe__Events__Main::instance(); $wp_admin_bar->add_menu(array('id' => 'tribe-events', 'title' => '<span class="ab-icon dashicons-before dashicons-calendar"></span>' . sprintf(__('%s', 'the-events-calendar'), $main->plural_event_label), 'href' => $main->getLink('home'))); $wp_admin_bar->add_group(array('id' => 'tribe-events-group', 'parent' => 'tribe-events')); $wp_admin_bar->add_group(array('id' => 'tribe-events-add-ons-group', 'parent' => 'tribe-events')); $wp_admin_bar->add_group(array('id' => 'tribe-events-settings-group', 'parent' => 'tribe-events')); if (current_user_can('edit_tribe_events')) { $wp_admin_bar->add_group(array('id' => 'tribe-events-import-group', 'parent' => 'tribe-events-add-ons-group')); } $wp_admin_bar->add_menu(array('id' => 'tribe-events-view-calendar', 'title' => esc_html__('View Calendar', 'the-events-calendar'), 'href' => $main->getLink('home'), 'parent' => 'tribe-events-group')); if (current_user_can('edit_tribe_events')) { $wp_admin_bar->add_menu(array('id' => 'tribe-events-add-event', 'title' => sprintf(esc_html__('Add %s', 'the-events-calendar'), $main->singular_event_label), 'href' => trailingslashit(get_admin_url()) . 'post-new.php?post_type=' . Tribe__Events__Main::POSTTYPE, 'parent' => 'tribe-events-group')); } if (current_user_can('edit_tribe_events')) { $wp_admin_bar->add_menu(array('id' => 'tribe-events-edit-events', 'title' => sprintf(esc_html__('Edit %s', 'the-events-calendar'), $main->plural_event_label), 'href' => trailingslashit(get_admin_url()) . 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE, 'parent' => 'tribe-events-group')); } if (current_user_can('publish_tribe_events')) { $import_node = $wp_admin_bar->get_node('tribe-events-import'); if (!is_object($import_node)) { $wp_admin_bar->add_node(array('id' => 'tribe-events-import', 'title' => esc_html__('Import', 'the-events-calendar'), 'parent' => 'tribe-events-import-group', 'href' => esc_url(add_query_arg(array('post_type' => Tribe__Events__Main::POSTTYPE, 'page' => 'aggregator'), admin_url('edit.php'))))); } } if (current_user_can('manage_options')) { $hide_all_settings = Tribe__Settings_Manager::get_network_option('allSettingsTabsHidden', '0'); if ($hide_all_settings == '0') { $wp_admin_bar->add_menu(array('id' => 'tribe-events-settings', 'title' => esc_html__('Settings', 'the-events-calendar'), 'href' => Tribe__Settings::instance()->get_url(), 'parent' => 'tribe-events-settings-group')); } // Only show help link if it's not blocked in network admin. $hidden_settings_tabs = Tribe__Settings_Manager::get_network_option('hideSettingsTabs', array()); if (!in_array('help', $hidden_settings_tabs)) { $href = esc_url(add_query_arg(array('post_type' => Tribe__Events__Main::POSTTYPE, 'page' => 'tribe-help'), admin_url('edit.php'))); $wp_admin_bar->add_menu(array('id' => 'tribe-events-help', 'title' => esc_html__('Help', 'the-events-calendar'), 'href' => $href, 'parent' => 'tribe-events-settings-group')); } } }
/** * Returns the translation of an array of strings using WPML supported languages to do so. * * @param array $strings * * @param string $locale Optional; the locale the strings should be translated to; * should be in the "fr_FR" format. * * @return array */ public static function get_wpml_i18n_strings(array $strings, $locale = null, array $domains = null) { array_multisort($strings); $cache = new Tribe__Cache(); $cache_key = 'wpml-i18n-strings_' . md5(serialize($strings) . $locale . serialize($domains)); $cached_translations = $cache->get_transient($cache_key, 'wpml_updates'); if (!empty($cached_translations)) { return $cached_translations; } $tec = Tribe__Events__Main::instance(); $domains = apply_filters('tribe_events_rewrite_i18n_domains', array('default' => true, 'the-events-calendar' => $tec->pluginDir . 'lang/')); /** @var SitePress $sitepress */ global $sitepress; if (null === $locale) { // Grab all languages $langs = $sitepress->get_active_languages(); $languages = array(); foreach ($langs as $lang) { $languages[] = $sitepress->get_locale($lang['code']); } } else { $languages = array($locale); } // Prevent Duplicates and Empty langs $languages = array_filter(array_unique($languages)); // Query the Current Language $current_locale = $sitepress->get_locale($sitepress->get_current_language()); // Get the strings on multiple Domains and Languages // WPML filter is unhooked to avoid the locale being set to the default one remove_filter('locale', array($sitepress, 'locale_filter')); $translations = $tec->get_i18n_strings_for_domains($strings, $languages, $domains, $current_locale); add_filter('locale', array($sitepress, 'locale_filter')); // once an option is updated this cache is deprecated $cache->set_transient($cache_key, $translations, 0, 'wpml_updates'); return $translations; }
/** * Month View Ajax Handler * */ public function ajax_response() { if (isset($_POST['eventDate']) && $_POST['eventDate']) { Tribe__Events__Query::init(); Tribe__Events__Main::instance()->displaying = 'month'; global $wp_query; $wp_query = tribe_get_events($this->args, true); ob_start(); tribe_get_view('month/content'); $response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month'); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; } }