public function test_get_version_from_db() { $version_from_settings_manager = Tribe__Settings_Manager::get_option('schema-version'); $updater = Tribe__Events__Main::instance()->updater(); $version_from_updater = $updater->get_version_from_db(); $this->assertEquals($version_from_updater, $version_from_settings_manager, 'checking that the version from Settings Manager matches the version from Updater'); }
/** * 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__Settings_Manager::get_option('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')); }
/** * 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__Settings_Manager::get_option('eventsSlug', 'events'); $page = get_page_by_path($this->archive_slug); if (!$page || $page->post_status == 'trash') { return; } $this->page = $page; $dismissed_notices = get_user_meta(get_current_user_id(), 'tribe-dismiss-notice'); if (is_array($dismissed_notices) && in_array('archive-slug-conflict', $dismissed_notices)) { return; } add_action('admin_notices', array($this, 'notice')); }
/** * 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__Settings_Manager::get_option($optionName, $default); if (has_filter('tribe-import-setting-' . $optionName)) { /** * Remove this Filter on 4.3 * @deprecated */ _doing_it_wrong('tribe-import-setting-' . $optionName, sprintf(esc_html__('This Filter has been deprecated, to comply with WordPress Standards we are now using Underscores (_) instead of Dashes (-). From: "%s" To: "%s"', 'the-events-calendar'), 'tribe-import-setting-' . $optionName, 'tribe_import_setting_' . $optionName), '4.0'); $value = apply_filters('tribe-import-setting-' . $optionName, $value, $default); } return apply_filters('tribe_import_setting_' . $optionName, $value, $default); }
/** * Return Default Post Status Per Import Method * * @param string $type * * @return mixed|void */ 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__Settings_Manager::get_option('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); }
<?php $tec = Tribe__Events__Main::instance(); $general_tab_fields = Tribe__Main::array_insert_after_key('info-start', $general_tab_fields, array('upsell-heading' => array('type' => 'heading', 'label' => esc_html__('Finding & extending your calendar.', 'the-events-calendar'), 'conditional' => !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL), 'finding-heading' => array('type' => 'heading', 'label' => esc_html__('Finding your calendar.', 'the-events-calendar'), 'conditional' => defined('TRIBE_HIDE_UPSELL') && TRIBE_HIDE_UPSELL), 'view-calendar-link' => array('type' => 'html', 'html' => '<p>' . esc_html__('Where\'s my calendar?', 'the-events-calendar') . ' <a href="' . esc_url(Tribe__Events__Main::instance()->getLink()) . '">' . esc_html__('Right here', 'the-events-calendar') . '</a>.</p>'))); $general_tab_fields = Tribe__Main::array_insert_before_key('debugEvents', $general_tab_fields, array('tribeEventsDisplayThemeTitle' => array('type' => 'html', 'html' => '<h3>' . esc_html__('General Settings', 'the-events-calendar') . '</h3>'), 'postsPerPage' => array('type' => 'text', 'label' => esc_html__('Number of events to show per page', 'the-events-calendar'), 'size' => 'small', 'default' => get_option('posts_per_page'), 'validation_type' => 'positive_int'), 'liveFiltersUpdate' => array('type' => 'checkbox_bool', 'label' => esc_html__('Use Javascript to control date filtering', 'the-events-calendar'), 'tooltip' => tribe_get_option('tribeDisableTribeBar', false) == true ? esc_html__('This option is disabled when "Disable the Event Search Bar" is checked on the Display settings tab.', 'the-events-calendar') : esc_html__('Enable live ajax for datepicker on front end (User submit not required).', 'the-events-calendar'), 'attributes' => tribe_get_option('tribeDisableTribeBar', false) == true ? array('disabled' => 'disabled') : null, 'default' => true, 'validation_type' => 'boolean', 'class' => tribe_get_option('tribeDisableTribeBar', false) == true ? 'tribe-fieldset-disabled' : null), 'showComments' => array('type' => 'checkbox_bool', 'label' => esc_html__('Show comments', 'the-events-calendar'), 'tooltip' => esc_html__('Enable comments on event pages.', 'the-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'showEventsInMainLoop' => array('type' => 'checkbox_bool', 'label' => esc_html__('Include events in main blog loop', 'the-events-calendar'), 'tooltip' => esc_html__('Show events with the site\'s other posts. When this box is checked, events will also continue to appear on the default events page.', 'the-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'unprettyPermalinksUrl' => array('type' => 'html', 'label' => esc_html__('Events URL slug', 'the-events-calendar'), 'html' => '<p>' . sprintf(__('You cannot edit the slug for your events page as you do not have pretty permalinks enabled. The current URL for your events page is <a href="%1$s">%2$s</a>. In order to edit the slug here, <a href="%3$soptions-permalink.php">enable pretty permalinks</a>.', 'the-events-calendar'), esc_url($tec->getLink('home')), $tec->getLink('home '), esc_url(trailingslashit(get_admin_url()))) . '</p>', 'conditional' => '' == get_option('permalink_structure')), 'eventsSlug' => array('type' => 'text', 'label' => esc_html__('Events URL slug', 'the-events-calendar'), 'default' => 'events', 'validation_type' => 'slug', 'conditional' => '' != get_option('permalink_structure')), 'current-events-slug' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . esc_html__('The slug used for building the events URL.', 'the-events-calendar') . sprintf(esc_html__('Your current events URL is: %s', 'the-events-calendar'), '<code><a href="' . esc_url(tribe_get_events_link()) . '">' . tribe_get_events_link() . '</a></code>') . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'ical-info' => array('type' => 'html', 'display_callback' => function_exists('tribe_get_ical_link') ? '<p id="ical-link" class="tribe-field-indent tribe-field-description description">' . esc_html__('Here is the iCal feed URL for your events:', 'the-events-calendar') . ' <code>' . tribe_get_ical_link() . '</code></p>' : '', 'conditional' => function_exists('tribe_get_ical_link')), 'singleEventSlug' => array('type' => 'text', 'label' => esc_html__('Single event URL slug', 'the-events-calendar'), 'default' => 'event', 'validation_type' => 'slug', 'conditional' => '' != get_option('permalink_structure')), 'current-single-event-slug' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . sprintf(__('The above should ideally be plural, and this singular.<br />Your single event URL is: %s', 'the-events-calendar'), '<code>' . trailingslashit(home_url()) . tribe_get_option('singleEventSlug', 'event') . '/single-post-name/</code>') . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'multiDayCutoff' => array('type' => 'dropdown', 'label' => esc_html__('End of day cutoff', 'the-events-calendar'), 'validation_type' => 'options', 'size' => 'small', 'default' => '12:00', 'options' => array('00:00' => '12:00 am', '01:00' => '01:00 am', '02:00' => '02:00 am', '03:00' => '03:00 am', '04:00' => '04:00 am', '05:00' => '05:00 am', '06:00' => '06:00 am', '07:00' => '07:00 am', '08:00' => '08:00 am', '09:00' => '09:00 am', '10:00' => '10:00 am', '11:00' => '11:00 am')), 'multiDayCutoffHelper' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . sprintf(esc_html__("Have an event that runs past midnight? Select a time after that event's end to avoid showing the event on the next day's calendar.", 'the-events-calendar')) . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'defaultCurrencySymbol' => array('type' => 'text', 'label' => esc_html__('Default currency symbol', 'the-events-calendar'), 'tooltip' => esc_html__('Set the default currency symbol for event costs. Note that this only impacts future events, and changes made will not apply retroactively.', 'the-events-calendar'), 'validation_type' => 'textarea', 'size' => 'small', 'default' => '$'), 'reverseCurrencyPosition' => array('type' => 'checkbox_bool', 'label' => esc_html__('Currency symbol follows value', 'the-events-calendar'), 'tooltip' => esc_html__('The currency symbol normally precedes the value. Enabling this option positions the symbol after the value.', 'the-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'amalgamateDuplicates' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('Duplicate Venues & Organizers', 'the-events-calendar') . '</legend><div class="tribe-field-wrap">' . Tribe__Events__Amalgamator::migration_button(esc_html__('Merge Duplicates', 'the-events-calendar')) . '<p class="tribe-field-indent description">' . esc_html__('You might find duplicate venues and organizers when updating The Events Calendar from a pre-3.0 version. Click this button to automatically merge identical venues and organizers.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>', 'conditional' => Tribe__Settings_Manager::get_option('organizer_venue_amalgamation', 0) < 1), 'tribeEventsMiscellaneousTitle' => array('type' => 'html', 'html' => '<h3>' . esc_html__('Miscellaneous Settings', 'the-events-calendar') . '</h3>'))); $general_tab_fields = Tribe__Main::array_insert_after_key('tribeEventsMiscellaneousTitle', $general_tab_fields, array('viewWelcomePage' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('View Welcome Page', 'the-events-calendar') . '</legend><div class="tribe-field-wrap"><a href="' . Tribe__Settings::instance()->get_url(array(Tribe__Events__Main::instance()->activation_page->welcome_slug => 1)) . '" class="button">' . esc_html__('View Welcome Page', 'the-events-calendar') . '</a><p class="tribe-field-indent description">' . esc_html__('View the page that displayed when you initially installed the plugin.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>'), 'viewUpdatePage' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('View Update Page', 'the-events-calendar') . '</legend><div class="tribe-field-wrap"><a href="' . Tribe__Settings::instance()->get_url(array(Tribe__Events__Main::instance()->activation_page->update_slug => 1)) . '" class="button">' . esc_html__('View Update Page', 'the-events-calendar') . '</a><p class="tribe-field-indent description">' . esc_html__('View the page that displayed when you updated the plugin.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>'))); $general_tab_fields = Tribe__Main::array_insert_before_key('tribeEventsMiscellaneousTitle', $general_tab_fields, array('tribeEventsDisplayTitle' => array('type' => 'html', 'html' => '<h3>' . esc_html__('Map Settings', 'the-events-calendar') . '</h3>'), 'embedGoogleMaps' => array('type' => 'checkbox_bool', 'label' => esc_html__('Enable Google Maps', 'the-events-calendar'), 'tooltip' => esc_html__('Check to enable maps for events and venues.', 'the-events-calendar'), 'default' => true, 'class' => 'google-embed-size', 'validation_type' => 'boolean'), 'embedGoogleMapsZoom' => array('type' => 'text', 'label' => esc_html__('Google Maps default zoom level', 'the-events-calendar'), 'tooltip' => esc_html__('0 = zoomed out; 21 = zoomed in.', 'the-events-calendar'), 'size' => 'small', 'default' => 10, 'class' => 'google-embed-field', 'validation_type' => 'number_or_percent'))); return $general_tab_fields;
/** * Returns various internal events-related URLs * * @param string $type type of link. See switch statement for types. * @param string $secondary for $type = month, pass a YYYY-MM string for a specific month's URL * for $type = week, pass a Week # string for a specific week's URL * @param int|bool|null $term * * @return string The link. */ public function getLink($type = 'home', $secondary = false, $term = null) { // if permalinks are off or user doesn't want them: ugly. if ('' === get_option('permalink_structure')) { return esc_url_raw($this->uglyLink($type, $secondary)); } // account for semi-pretty permalinks if (false !== strpos(get_option('permalink_structure'), 'index.php')) { $event_url = home_url('/index.php/'); } else { $event_url = home_url('/'); } // URL Arguments on home_url() pre-check $url_query = @parse_url($event_url, PHP_URL_QUERY); $url_args = wp_parse_args($url_query, array()); // Remove the "args" if (!empty($url_query)) { $event_url = str_replace('?' . $url_query, '', $event_url); } // Append Events structure $event_url .= trailingslashit(sanitize_title(Tribe__Settings_Manager::get_option('eventsSlug', 'events'))); // if we're on an Event Cat, show the cat link, except for home and days. if ($type !== 'home' && is_tax(self::TAXONOMY) && $term !== false && !is_numeric($term)) { $term_link = get_term_link(get_query_var('term'), self::TAXONOMY); if (!is_wp_error($term_link)) { $event_url = trailingslashit($term_link); } } else { if ($term) { $term_link = get_term_link((int) $term, self::TAXONOMY); if (!is_wp_error($term_link)) { $event_url = trailingslashit($term_link); } } } switch ($type) { case 'home': $event_url = trailingslashit(esc_url_raw($event_url)); break; case 'month': if ($secondary) { $event_url = trailingslashit(esc_url_raw($event_url . $secondary)); } else { $event_url = trailingslashit(esc_url_raw($event_url . $this->monthSlug)); } break; case 'list': $event_url = trailingslashit(esc_url_raw($event_url . $this->listSlug)); break; case 'upcoming': $event_url = trailingslashit(esc_url_raw($event_url . $this->listSlug)); break; case 'past': $event_url = esc_url_raw(add_query_arg('tribe_event_display', 'past', trailingslashit($event_url . $this->listSlug))); break; case 'dropdown': $event_url = esc_url_raw($event_url); break; case 'single': global $post; $p = $secondary ? $secondary : $post; $link = trailingslashit(get_permalink($p)); $event_url = trailingslashit(esc_url_raw($link)); break; case 'day': if (empty($secondary)) { $secondary = $this->todaySlug; } else { $secondary = tribe_format_date($secondary, false, Tribe__Date_Utils::DBDATEFORMAT); } $event_url = trailingslashit(esc_url_raw($event_url . $secondary)); break; default: $event_url = esc_url_raw($event_url); break; } // Filter get link $event_url = apply_filters('tribe_events_get_link', $event_url, $type, $secondary, $term, $url_args); // @todo deprecate on 4.2 $event_url = apply_filters('tribe_events_getLink', $event_url, $type, $secondary, $term, $url_args); // Add the Arguments back $event_url = add_query_arg($url_args, $event_url); return $event_url; }
/** * Get the base slugs for the Plugin Rewrite rules * * WARNING: Don't mess with the filters below if you don't know what you are doing * * @param string $method Use "regex" to return a Regular Expression with the possible Base Slugs using l10n * @return object Return Base Slugs with l10n variations */ public function get_bases($method = 'regex') { $tec = Tribe__Events__Main::instance(); /** * If you want to modify the base slugs before the i18n happens filter this use this filter * All the bases need to have a key and a value, they might be the same or not. * * Each value is an array of possible slugs: to improve robustness the "original" English * slug is supported in addition to translated forms for month, list, today and day: this * way if the forms are altered (whether through i18n or other custom mods) *after* links * have already been promulgated, there will be less chance of visitors hitting 404s. * * @var array $bases */ $bases = apply_filters('tribe_events_rewrite_base_slugs', array('month' => array('month', $tec->monthSlug), 'list' => array('list', $tec->listSlug), 'today' => array('today', $tec->todaySlug), 'day' => array('day', $tec->daySlug), 'tag' => array('tag', $tec->tag_slug), 'tax' => array('category', $tec->category_slug), 'page' => (array) 'page', 'all' => (array) 'all', 'single' => (array) Tribe__Settings_Manager::get_option('singleEventSlug', 'event'), 'archive' => (array) Tribe__Settings_Manager::get_option('eventsSlug', 'events'))); // Remove duplicates (no need to have 'month' twice if no translations are in effect, etc) $bases = array_map('array_unique', $bases); // By default we always have `en_US` to avoid 404 with older URLs $languages = apply_filters('tribe_events_rewrite_i18n_languages', array_unique(array('en_US', get_locale()))); // By default we load the Default and our plugin domains $domains = apply_filters('tribe_events_rewrite_i18n_domains', array('default' => true, 'the-events-calendar' => Tribe__Events__Main::instance()->pluginDir . 'lang/')); // If WPML exists we treat the multiple languages if ($this->is_wpml_active()) { global $sitepress; // Grab all languages $langs = $sitepress->get_active_languages(); 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 $bases = Tribe__Events__Main::instance()->get_i18n_strings($bases, $languages, $domains, $current_locale); } if ('regex' === $method) { foreach ($bases as $type => $base) { $bases[$type] = '(?:' . implode('|', $base) . ')'; } } /** * Use `tribe_events_rewrite_i18n_slugs` to modify the final version of the l10n slugs bases */ return (object) apply_filters('tribe_events_rewrite_i18n_slugs', $bases, $method); }
/** * Get Options * * Retrieve specific key from options array, optionally provide a default return value * * @category Events * @param string $optionName Name of the option to retrieve. * @param string $default Value to return if no such option is found. * * @return mixed Value of the option if found. * @todo Abstract this function out of template tags or otherwise secure it from other namespace conflicts. */ function tribe_get_option($optionName, $default = '') { return apply_filters('tribe_get_option', Tribe__Settings_Manager::get_option($optionName, $default), $optionName, $default); }
/** * displays the content for the tab * * @return void */ public function doContent() { if ($this->display_callback && is_callable($this->display_callback)) { call_user_func($this->display_callback); return; } $sent_data = get_option('tribe_settings_sent_data', array()); if (is_array($this->fields) && !empty($this->fields)) { foreach ($this->fields as $key => $field) { if (isset($sent_data[$key])) { // if we just saved [or attempted to], get the value that was inputed $value = $sent_data[$key]; } else { // Some options should always be stored at network level $network_option = isset($field['network_option']) ? (bool) $field['network_option'] : false; if (is_network_admin()) { $parent_option = isset($field['parent_option']) ? $field['parent_option'] : Tribe__Main::OPTIONNAMENETWORK; } if (!is_network_admin()) { $parent_option = isset($field['parent_option']) ? $field['parent_option'] : Tribe__Main::OPTIONNAME; } // get the field's parent_option in order to later get the field's value $parent_option = apply_filters('tribe_settings_do_content_parent_option', $parent_option, $key); $default = isset($field['default']) ? $field['default'] : null; $default = apply_filters('tribe_settings_field_default', $default, $field); if (!$parent_option) { // no parent option, get the straight up value if ($network_option || is_network_admin()) { $value = get_site_option($key, $default); } else { $value = get_option($key, $default); } } else { // there's a parent option if ($parent_option == Tribe__Main::OPTIONNAME) { // get the options from Tribe__Settings_Manager if we're getting the main array $value = Tribe__Settings_Manager::get_option($key, $default); } elseif ($parent_option == Tribe__Main::OPTIONNAMENETWORK) { $value = Tribe__Settings_Manager::get_network_option($key, $default); } else { // else, get the parent option normally if (is_network_admin()) { $options = (array) get_site_option($parent_option); } else { $options = (array) get_option($parent_option); } $value = isset($options[$key]) ? $options[$key] : $default; } } } // escape the value for display if (!empty($field['esc_display']) && function_exists($field['esc_display'])) { $value = $field['esc_display']($value); } elseif (is_string($value)) { $value = esc_attr(stripslashes($value)); } // filter the value $value = apply_filters('tribe_settings_get_option_value_pre_display', $value, $key, $field); // create the field new Tribe__Field($key, $field, $value); } } else { // no fields setup for this tab yet echo '<p>' . esc_html__('There are no fields setup for this tab yet.', 'tribe-common') . '</p>'; } }
/** * Returns the formatted and converted distance from the db (always in kms.) to the unit selected * by the user in the 'defaults' tab of our settings. * * @param $distance_in_kms * * @return mixed * @todo remove tribe_formatted_distance filter in 3.11 */ function tribe_get_distance_with_unit($distance_in_kms) { $tec = Tribe__Events__Main::instance(); $unit = Tribe__Settings_Manager::get_option('geoloc_default_unit', 'miles'); $distance = round(tribe_convert_units($distance_in_kms, 'kms', $unit), 2); if (has_filter('tribe_formatted_distance')) { _deprecated_function("The 'tribe_formatted_distance' filter", '3.9', " the 'tribe_get_distance_with_unit' filter"); $distance = apply_filters('tribe_formatted_distance', $distance . ' ' . $unit); } return apply_filters('tribe_get_distance_with_unit', $distance, $distance_in_kms, $unit); }
public function get_version_from_db() { return Tribe__Settings_Manager::get_option($this->version_option); }
/** * Filters the rewrite slugs to use for the map view taking WPML existence into account. * * @param array $rewrite_slugs * * @return array */ public function filter_tribe_events_pro_geocode_rewrite_slugs(array $rewrite_slugs) { // use the non translated version, we'll translate it below $geoloc_rewrite_slug = Tribe__Settings_Manager::get_option('geoloc_rewrite_slug', 'map'); $translations = Tribe__Events__Integrations__WPML__Utils::get_wpml_i18n_strings(array($geoloc_rewrite_slug)); return $translations[0]; }
<?php $tec = Tribe__Events__Main::instance(); $general_tab_fields = Tribe__Main::array_insert_after_key('info-start', $general_tab_fields, array('upsell-heading' => array('type' => 'heading', 'label' => esc_html__('Finding & extending your calendar.', 'the-events-calendar'), 'conditional' => !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL), 'finding-heading' => array('type' => 'heading', 'label' => esc_html__('Finding your calendar.', 'the-events-calendar'), 'conditional' => defined('TRIBE_HIDE_UPSELL') && TRIBE_HIDE_UPSELL), 'view-calendar-link' => array('type' => 'html', 'html' => '<p>' . esc_html__('Where\'s my calendar?', 'the-events-calendar') . ' <a href="' . esc_url(Tribe__Events__Main::instance()->getLink()) . '">' . esc_html__('Right here', 'the-events-calendar') . '</a>.</p>'))); $general_tab_fields = Tribe__Main::array_insert_before_key('defaultCurrencySymbol', $general_tab_fields, array('postsPerPage' => array('type' => 'text', 'label' => esc_html__('Number of events to show per page', 'the-events-calendar'), 'size' => 'small', 'default' => get_option('posts_per_page'), 'validation_type' => 'positive_int'), 'liveFiltersUpdate' => array('type' => 'checkbox_bool', 'label' => esc_html__('Use Javascript to control date filtering', 'the-events-calendar'), 'tooltip' => tribe_get_option('tribeDisableTribeBar', false) == true ? esc_html__('This option is disabled when "Disable the Event Search Bar" is checked on the Display settings tab.', 'the-events-calendar') : esc_html__('Enable live ajax for datepicker on front end (User submit not required).', 'the-events-calendar'), 'attributes' => tribe_get_option('tribeDisableTribeBar', false) == true ? array('disabled' => 'disabled') : null, 'default' => true, 'validation_type' => 'boolean', 'class' => tribe_get_option('tribeDisableTribeBar', false) == true ? 'tribe-fieldset-disabled' : null), 'showComments' => array('type' => 'checkbox_bool', 'label' => esc_html__('Show comments', 'the-events-calendar'), 'tooltip' => esc_html__('Enable comments on event pages.', 'the-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'showEventsInMainLoop' => array('type' => 'checkbox_bool', 'label' => esc_html__('Include events in main blog loop', 'the-events-calendar'), 'tooltip' => esc_html__('Show events with the site\'s other posts. When this box is checked, events will also continue to appear on the default events page.', 'the-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'unprettyPermalinksUrl' => array('type' => 'html', 'label' => esc_html__('Events URL slug', 'the-events-calendar'), 'html' => '<p>' . sprintf(__('You cannot edit the slug for your events page as you do not have pretty permalinks enabled. The current URL for your events page is <a href="%1$s">%2$s</a>. In order to edit the slug here, <a href="%3$soptions-permalink.php">enable pretty permalinks</a>.', 'the-events-calendar'), esc_url($tec->getLink('home')), $tec->getLink('home '), esc_url(trailingslashit(get_admin_url()))) . '</p>', 'conditional' => '' == get_option('permalink_structure')), 'eventsSlug' => array('type' => 'text', 'label' => esc_html__('Events URL slug', 'the-events-calendar'), 'default' => 'events', 'validation_type' => 'slug', 'conditional' => '' != get_option('permalink_structure')), 'current-events-slug' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . esc_html__('The slug used for building the events URL.', 'the-events-calendar') . sprintf(esc_html__('Your current events URL is: %s', 'the-events-calendar'), '<code><a href="' . esc_url(tribe_get_events_link()) . '">' . tribe_get_events_link() . '</a></code>') . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'ical-info' => array('type' => 'html', 'display_callback' => function_exists('tribe_get_ical_link') ? '<p id="ical-link" class="tribe-field-indent tribe-field-description description">' . esc_html__('Here is the iCal feed URL for your events:', 'the-events-calendar') . ' <code>' . tribe_get_ical_link() . '</code></p>' : '', 'conditional' => function_exists('tribe_get_ical_link')), 'singleEventSlug' => array('type' => 'text', 'label' => esc_html__('Single event URL slug', 'the-events-calendar'), 'default' => 'event', 'validation_type' => 'slug', 'conditional' => '' != get_option('permalink_structure')), 'current-single-event-slug' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . sprintf(__('The above should ideally be plural, and this singular.<br />Your single event URL is: %s', 'the-events-calendar'), '<code>' . trailingslashit(home_url()) . tribe_get_option('singleEventSlug', 'event') . '/single-post-name/</code>') . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'multiDayCutoff' => array('type' => 'dropdown', 'label' => esc_html__('End of day cutoff', 'the-events-calendar'), 'validation_type' => 'options', 'size' => 'small', 'default' => '12:00', 'options' => array('00:00' => '12:00 am', '01:00' => '01:00 am', '02:00' => '02:00 am', '03:00' => '03:00 am', '04:00' => '04:00 am', '05:00' => '05:00 am', '06:00' => '06:00 am', '07:00' => '07:00 am', '08:00' => '08:00 am', '09:00' => '09:00 am', '10:00' => '10:00 am', '11:00' => '11:00 am')), 'multiDayCutoffHelper' => array('type' => 'html', 'html' => '<p class="tribe-field-indent tribe-field-description description">' . sprintf(esc_html__("Have an event that runs past midnight? Select a time after that event's end to avoid showing the event on the next day's calendar.", 'the-events-calendar')) . '</p>', 'conditional' => '' != get_option('permalink_structure')))); $general_tab_fields = Tribe__Main::array_insert_before_key('tribeEventsMiscellaneousTitle', $general_tab_fields, array('amalgamateDuplicates' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('Duplicate Venues & Organizers', 'the-events-calendar') . '</legend><div class="tribe-field-wrap">' . Tribe__Events__Amalgamator::migration_button(esc_html__('Merge Duplicates', 'the-events-calendar')) . '<p class="tribe-field-indent description">' . esc_html__('You might find duplicate venues and organizers when updating The Events Calendar from a pre-3.0 version. Click this button to automatically merge identical venues and organizers.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>', 'conditional' => Tribe__Settings_Manager::get_option('organizer_venue_amalgamation', 0) < 1))); $general_tab_fields = Tribe__Main::array_insert_before_key('tribeEventsMiscellaneousTitle', $general_tab_fields, array('tribeEventsDisplayTitle' => array('type' => 'html', 'html' => '<h3>' . esc_html__('Map Settings', 'the-events-calendar') . '</h3>'), 'embedGoogleMaps' => array('type' => 'checkbox_bool', 'label' => esc_html__('Enable Google Maps', 'the-events-calendar'), 'tooltip' => esc_html__('Check to enable maps for events and venues.', 'the-events-calendar'), 'default' => true, 'class' => 'google-embed-size', 'validation_type' => 'boolean'), 'embedGoogleMapsZoom' => array('type' => 'text', 'label' => esc_html__('Google Maps default zoom level', 'the-events-calendar'), 'tooltip' => esc_html__('0 = zoomed out; 21 = zoomed in.', 'the-events-calendar'), 'size' => 'small', 'default' => 10, 'class' => 'google-embed-field', 'validation_type' => 'number_or_percent'))); $general_tab_fields = Tribe__Main::array_insert_after_key('tribeEventsMiscellaneousTitle', $general_tab_fields, array('viewWelcomePage' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('View Welcome Page', 'the-events-calendar') . '</legend><div class="tribe-field-wrap"><a href="' . Tribe__Settings::instance()->get_url(array('tec-welcome-message' => true)) . '" class="button">' . esc_html__('View Welcome Page', 'the-events-calendar') . '</a><p class="tribe-field-indent description">' . esc_html__('View the page that displayed when you initially installed the plugin.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>'), 'viewUpdatePage' => array('type' => 'html', 'html' => '<fieldset class="tribe-field tribe-field-html"><legend>' . esc_html__('View Update Page', 'the-events-calendar') . '</legend><div class="tribe-field-wrap"><a href="' . Tribe__Settings::instance()->get_url(array('tec-update-message' => true)) . '" class="button">' . esc_html__('View Update Page', 'the-events-calendar') . '</a><p class="tribe-field-indent description">' . esc_html__('View the page that displayed when you updated the plugin.', 'the-events-calendar') . '</p></div></fieldset><div class="clear"></div>'))); return $general_tab_fields;
/** * The previous_ecp_versions option will be empty or set to 0 * if the current version is the first version to be installed. * * @return bool * @see Tribe__Events__Main::maybeSetTECVersion() */ protected function is_new_install() { $previous_versions = Tribe__Settings_Manager::get_option($this->args['version_history_slug']); return empty($previous_versions) || end($previous_versions) == '0'; }
/** * Get the base slugs for the Plugin Rewrite rules * * WARNING: Don't mess with the filters below if you don't know what you are doing * * @param string $method Use "regex" to return a Regular Expression with the possible Base Slugs using l10n * @return object Return Base Slugs with l10n variations */ public function get_bases($method = 'regex') { $tec = Tribe__Events__Main::instance(); /** * If you want to modify the base slugs before the i18n happens filter this use this filter * All the bases need to have a key and a value, they might be the same or not. * * Each value is an array of possible slugs: to improve robustness the "original" English * slug is supported in addition to translated forms for month, list, today and day: this * way if the forms are altered (whether through i18n or other custom mods) *after* links * have already been promulgated, there will be less chance of visitors hitting 404s. * * @var array $bases */ $bases = apply_filters('tribe_events_rewrite_base_slugs', array('month' => array('month', $tec->monthSlug), 'list' => array('list', $tec->listSlug), 'today' => array('today', $tec->todaySlug), 'day' => array('day', $tec->daySlug), 'tag' => array('tag', $tec->tag_slug), 'tax' => array('category', $tec->category_slug), 'page' => (array) 'page', 'all' => (array) 'all', 'single' => (array) Tribe__Settings_Manager::get_option('singleEventSlug', 'event'), 'archive' => (array) Tribe__Settings_Manager::get_option('eventsSlug', 'events'))); // Remove duplicates (no need to have 'month' twice if no translations are in effect, etc) $bases = array_map('array_unique', $bases); // By default we always have `en_US` to avoid 404 with older URLs $current_locale = get_locale(); $languages = apply_filters('tribe_events_rewrite_i18n_languages', array_unique(array('en_US', $current_locale))); // By default we load the Default and our plugin domains $domains = apply_filters('tribe_events_rewrite_i18n_domains', array('default' => true, 'the-events-calendar' => $tec->plugin_dir . 'lang/')); if ($current_locale !== 'en_US') { // get the translated version of each base in the site locale $bases = $tec->get_i18n_strings($bases, $languages, $domains, $current_locale); } /** * Use `tribe_events_rewrite_i18n_slugs_raw` to modify the raw version of the l10n slugs bases. * * This is useful to modify the bases before the method is taken into account. * * @param array $bases An array of rewrite bases that have been generated. * @param string $method The method that's being used to generate the bases; defaults to `regex`. * @param array $domains An associative array of language domains to use; these would be plugin or themes language * domains with a `'plugin-slug' => '/absolute/path/to/lang/dir'` */ $bases = apply_filters('tribe_events_rewrite_i18n_slugs_raw', $bases, $method, $domains); if ('regex' === $method) { foreach ($bases as $type => $base) { // Escape all the Bases $base = array_map('preg_quote', $base); // Add the non accented version of each base $base = $this->add_non_accented_bases_to_for($base); // Create the Regular Expression $bases[$type] = '(?:' . implode('|', $base) . ')'; } } /** * Use `tribe_events_rewrite_i18n_slugs` to modify the final version of the l10n slugs bases * * At this stage the method has been applied already and this filter will work with the * finalized version of the bases. * * @param array $bases An array of rewrite bases that have been generated. * @param string $method The method that's being used to generate the bases; defaults to `regex`. * @param array $domains An associative array of language domains to use; these would be plugin or themes language * domains with a `'plugin-slug' => '/absolute/path/to/lang/dir'` */ return (object) apply_filters('tribe_events_rewrite_i18n_slugs', $bases, $method, $domains); }
/** * Set the Event Tickets version in the options table if it's not already set. */ public function maybe_set_et_version() { if (version_compare(Tribe__Settings_Manager::get_option('latest_event_tickets_version'), self::VERSION, '<')) { $previous_versions = Tribe__Settings_Manager::get_option('previous_event_tickets_versions') ? Tribe__Settings_Manager::get_option('previous_event_tickets_versions') : array(); $previous_versions[] = Tribe__Settings_Manager::get_option('latest_event_tickets_version') ? Tribe__Settings_Manager::get_option('latest_event_tickets_version') : '0'; Tribe__Settings_Manager::set_option('previous_event_tickets_versions', $previous_versions); Tribe__Settings_Manager::set_option('latest_event_tickets_version', self::VERSION); } }
/** * Adds the rewrite rules to make the map view work * * @param $wp_rewrite */ public function add_routes($wp_rewrite) { $tec = Tribe__Events__Main::instance(); $base = trailingslashit(Tribe__Settings_Manager::get_option('eventsSlug', 'events')); $baseTax = trailingslashit($tec->taxRewriteSlug); $baseTax = '(.*)' . $baseTax . '(?:[^/]+/)*'; $baseTag = trailingslashit($tec->tagRewriteSlug); $baseTag = '(.*)' . $baseTag; $newRules = array(); $newRules[$base . $this->rewrite_slug] = 'index.php?post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; $newRules[$baseTax . '([^/]+)/' . $this->rewrite_slug . '/?$'] = 'index.php?tribe_events_cat=' . $wp_rewrite->preg_index(2) . '&post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; $newRules[$baseTag . '([^/]+)/' . $this->rewrite_slug . '/?$'] = 'index.php?tag=' . $wp_rewrite->preg_index(2) . '&post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; $wp_rewrite->rules = $newRules + $wp_rewrite->rules; }
/** * The previous_ecp_versions option will be empty or set to 0 * if the current version is the first version to be installed. * * @return bool * @see Tribe__Events__Main::maybeSetTECVersion() */ protected function is_new_install() { $previous_versions = Tribe__Settings_Manager::get_option('previous_ecp_versions'); return empty($previous_versions) || end($previous_versions) == '0'; }
/** * Checks whether default custom field translation option values have been for the current installation. * * @return bool Whether defaaults have been set already or not. */ public function has_set_defaults() { return false !== Tribe__Settings_Manager::get_option($this->defaults_option_name, false); }
* Hook to this action to print More information on the Instructions Box */ do_action('tribe_import_general_infobox'); ?> </div> <div class="tribe-settings-form"> <form method="POST"> <?php /** * Hook to this filter to print More fields on the Importer Settings page */ $fields = apply_filters('tribe_import_general_settings', array()); foreach ($fields as $key => $field_args) { if (strpos($key, 'imported_post_status') === false) { $value = Tribe__Settings_Manager::get_option($key, null); } else { /** * Regular Expression to match "suboption_name" given "option_name[suboption_name]" */ if (preg_match('/\\[([^\\]]+)\\]/i', $key, $match)) { $type = end($match); } else { $type = 'csv'; } $value = Tribe__Events__Importer__Options::get_default_post_status($type); } new Tribe__Field($key, $field_args, $value); } wp_nonce_field('tribe-import-general-settings', 'tribe-import-general-settings'); ?>
/** * Adds the rewrite rules to make the map view work * * @param $wp_rewrite */ public function add_routes($wp_rewrite) { $tec = Tribe__Events__Main::instance(); $base = trailingslashit(Tribe__Settings_Manager::get_option('eventsSlug', 'events')); $baseTax = trailingslashit($tec->taxRewriteSlug); $baseTax = '(.*)' . $baseTax . '(?:[^/]+/)*'; $baseTag = trailingslashit($tec->tagRewriteSlug); $baseTag = '(.*)' . $baseTag; $newRules = array(); /** * Filters the rewrite slugs used to generate the geocode based rewrite rules. * * @param array $rewrite_slugs An array of rewrite slugs to use; defaults to [ 'map' ], the * default geocode-based rewrite slug. */ $rewrite_slugs = apply_filters('tribe_events_pro_geocode_rewrite_slugs', array($this->rewrite_slug)); foreach ($rewrite_slugs as $rewrite_slug) { $newRules[$base . $rewrite_slug] = 'index.php?post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; $newRules[$baseTax . '([^/]+)/' . $rewrite_slug . '/?$'] = 'index.php?tribe_events_cat=' . $wp_rewrite->preg_index(2) . '&post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; $newRules[$baseTag . '([^/]+)/' . $rewrite_slug . '/?$'] = 'index.php?tag=' . $wp_rewrite->preg_index(2) . '&post_type=' . Tribe__Events__Main::POSTTYPE . '&eventDisplay=map'; } $wp_rewrite->rules = $newRules + $wp_rewrite->rules; }