/** * 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')); }
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())); }
/** * 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; }
/** * Get value for a specific option * * @param string $optionName name of option * @param string $default default value * * @return mixed results of option query */ public static function getOption($optionName, $default = '') { if (!$optionName) { return null; } $value = Tribe__Events__Main::getOption($optionName, $default); return apply_filters('tribe-import-setting-' . $optionName, $value, $default); }
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')); }
/** * Output the upcoming events associated with a venue * * @return string|null */ function tribe_venue_upcoming_events($post_id = false) { $post_id = Tribe__Events__Main::postIdHelper($post_id); if ($post_id) { $args = array('venue' => $post_id, 'eventDisplay' => 'list', 'posts_per_page' => apply_filters('tribe_events_single_venue_posts_per_page', 100)); $html = tribe_include_view_list($args); return apply_filters('tribe_venue_upcoming_events', $html); } return null; }
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); }
/** * 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 }
/** * 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'); }
/** * 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); }
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); }
/** * Set up the notices for this template * * @return void **/ public function set_notices() { parent::set_notices(); $events_label_singular = tribe_get_event_label_singular(); global $post; // Check if event has passed $gmt_offset = get_option('gmt_offset') >= '0' ? ' +' . get_option('gmt_offset') : " " . get_option('gmt_offset'); $gmt_offset = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $gmt_offset); if (!tribe_is_showing_all() && strtotime(tribe_get_end_date($post, false, 'Y-m-d G:i') . $gmt_offset) <= time()) { Tribe__Events__Main::setNotice('event-past', sprintf(__('This %s has passed.', 'tribe-events-calendar'), strtolower($events_label_singular))); } }
/** * Output the upcoming events associated with a venue * * @return void */ function tribe_venue_upcoming_events($post_id = false) { $post_id = Tribe__Events__Main::postIdHelper($post_id); if ($post_id) { // turn off the venue group tribe_set_the_meta_visibility('tribe_event_venue', false, 'meta_group'); $args = array('venue' => $post_id, 'eventDisplay' => 'list', 'posts_per_page' => apply_filters('tribe_events_single_venue_posts_per_page', 100)); $html = tribe_include_view_list($args); // housekeeping: turn on the venue meta group before we leave tribe_set_the_meta_visibility('tribe_event_venue', true, 'meta_group'); return apply_filters('tribe_venue_upcoming_events', $html); } }
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"); }
private function build_event_array(array $record) { $start_date = strtotime($this->get_event_start_date($record)); $end_date = strtotime($this->get_event_end_date($record)); $event = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'post_status' => Tribe__Events__Main::getOption('imported_post_status', 'publish'), 'post_content' => $this->get_value_by_key($record, 'event_description'), 'EventStartDate' => date('Y-m-d', $start_date), 'EventStartHour' => date('h', $start_date), 'EventStartMinute' => date('i', $start_date), 'EventStartMeridian' => date('a', $start_date), 'EventEndDate' => date('Y-m-d', $end_date), 'EventEndHour' => date('h', $end_date), 'EventEndMinute' => date('i', $end_date), 'EventEndMeridian' => date('a', $end_date), 'EventShowMapLink' => $this->get_boolean_value_by_key($record, 'event_show_map_link'), 'EventShowMap' => $this->get_boolean_value_by_key($record, 'event_show_map'), 'EventCost' => $this->get_value_by_key($record, 'event_cost'), 'EventAllDay' => $this->get_boolean_value_by_key($record, 'event_all_day', 'yes'), 'EventHideFromUpcoming' => $this->get_value_by_key($record, 'event_hide'), 'EventURL' => $this->get_value_by_key($record, 'event_website')); if ($organizer_id = $this->find_matching_organizer_id($record)) { $event['Organizer'] = array('OrganizerID' => $organizer_id); } if ($venue_id = $this->find_matching_venue_id($record)) { $event['Venue'] = array('VenueID' => $venue_id); } if ($cats = $this->get_value_by_key($record, 'event_category')) { $event['tax_input'][Tribe__Events__Main::TAXONOMY] = $this->translate_terms_to_ids(explode(',', $cats)); } return $event; }
/** * 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); }
/** * Returns the link to export the whole recurring series in iCal format. * * @param int|WP_Pos|null $event_id A event post object, an event post ID or null to use the globally defined post object. * * @return string The absolute URL to export the whole recurring series in iCal format. */ function tribe_get_recurrence_ical_link($event_id = null) { $event_id = Tribe__Events__Main::postIdHelper($event_id); if (empty($event_id) || !tribe_is_event($event_id)) { return ''; } $event = get_post($event_id); $parent_id = empty($event->post_parent) ? $event_id : $event->post_parent; $url = get_permalink($parent_id); $url_vars = array('ical' => '1'); if (tribe_is_recurring_event($parent_id)) { $child_events_ids = tribe_get_events(array('fields' => 'ids', 'post_parent' => $parent_id)); $event_ids = array_merge(array($parent_id), $child_events_ids); $url_vars['event_ids'] = implode(',', $event_ids); } $url = add_query_arg($url_vars, $url); return apply_filters('tribe_get_recurrence_ical_link', $url, $event_id); }
public static function get_default_post_status($type = 'csv') { $options = self::getOption('imported_post_status', array($type => 'publish')); // Legacy for Facebook Status if ('facebook' === $type && empty($options['facebook'])) { $options['facebook'] = Tribe__Events__Main::getOption('fb_default_status', 'publish'); } // A way to handle the legacy `imported_post_status` if (is_string($options)) { $options = array($type => $options); } if (!isset($options[$type])) { $options[$type] = apply_filters('tribe_import_default_post_status_non_saved', 'publish', $type); } /** * Allows users to filter */ return apply_filters('tribe_import_default_post_status', $options[$type], $type); }