Example #1
0
 /**
  * initializes all required libraries
  */
 public function init_libraries()
 {
     Tribe__Debug::instance();
     Tribe__Settings_Manager::instance();
     require_once $this->plugin_path . 'src/functions/template-tags/general.php';
     require_once $this->plugin_path . 'src/functions/template-tags/date.php';
 }
Example #2
0
 /**
  * initializes all required libraries
  */
 public function init_libraries()
 {
     Tribe__Debug::instance();
     Tribe__Settings_Manager::instance();
     require_once $this->plugin_path . 'src/functions/template-tags/general.php';
     require_once $this->plugin_path . 'src/functions/template-tags/date.php';
     // Starting the log manager needs to wait until after the tribe_*_option() functions have loaded
     $this->log = new Tribe__Log();
 }
 /**
  * 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'));
 }
Example #4
0
 /**
  * Render the debug logging to the php error log. This can be over-ridden by removing the filter.
  *
  * @param string      $title  - message to display in log
  * @param string|bool $data   - optional data to display
  * @param string      $format - optional format (log|warning|error|notice)
  *
  * @return void
  */
 public static function render($title, $data = false, $format = 'log')
 {
     $format = ucfirst($format);
     if (Tribe__Settings_Manager::instance()->get_option('debugEvents')) {
         $plugin = basename(dirname(Tribe__Main::instance()->plugin_path));
         error_log("{$plugin}/common -  {$format}: {$title}");
         if ($data && $data != '') {
             error_log("{$plugin}/common - {$format}: " . print_r($data, true));
         }
     }
 }
 /**
  * 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'));
 }
 public function test_update_only_runs_once()
 {
     $settings = Tribe__Settings_Manager::instance();
     $settings::set_option('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'));
 }
Example #7
0
 /**
  * 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);
 }
 /**
  * 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'));
         }
     }
 }
Example #10
0
 /**
  * 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>';
     }
 }
 /**
  * enforce saving on additional fields tab
  * @return void
  */
 public static function force_save_meta()
 {
     $options = Tribe__Settings_Manager::get_options();
     $options = self::save_meta_options($options);
     Tribe__Settings_Manager::set_options($options);
 }
 /**
  * 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($this->args['version_history_slug']);
     return empty($previous_versions) || end($previous_versions) == '0';
 }
Example #14
0
 /**
  * Add help menu item to the admin (unless blocked via network admin settings).
  */
 public function addHelpAdminMenuItem()
 {
     _deprecated_function(__METHOD__, '4.0', 'Tribe__Settings_Manager::add_help_admin_menu_item');
     Tribe__Settings_Manager::instance()->add_help_admin_menu_item();
 }
<?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 &amp; 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;
Example #16
0
 /**
  * Collect system information for support
  *
  * @return array of system data for support
  */
 public function getSupportStats()
 {
     $user = wp_get_current_user();
     $plugins = array();
     if (function_exists('get_plugin_data')) {
         $plugins_raw = wp_get_active_and_valid_plugins();
         foreach ($plugins_raw as $k => $v) {
             $plugin_details = get_plugin_data($v);
             $plugin = $plugin_details['Name'];
             if (!empty($plugin_details['Version'])) {
                 $plugin .= sprintf(' version %s', $plugin_details['Version']);
             }
             if (!empty($plugin_details['Author'])) {
                 $plugin .= sprintf(' by %s', $plugin_details['Author']);
             }
             if (!empty($plugin_details['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $plugin_details['AuthorURI']);
             }
             $plugins[] = $plugin;
         }
     }
     $network_plugins = array();
     if (is_multisite() && function_exists('get_plugin_data')) {
         $plugins_raw = wp_get_active_network_plugins();
         foreach ($plugins_raw as $k => $v) {
             $plugin_details = get_plugin_data($v);
             $plugin = $plugin_details['Name'];
             if (!empty($plugin_details['Version'])) {
                 $plugin .= sprintf(' version %s', $plugin_details['Version']);
             }
             if (!empty($plugin_details['Author'])) {
                 $plugin .= sprintf(' by %s', $plugin_details['Author']);
             }
             if (!empty($plugin_details['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $plugin_details['AuthorURI']);
             }
             $network_plugins[] = $plugin;
         }
     }
     $mu_plugins = array();
     if (function_exists('get_mu_plugins')) {
         $mu_plugins_raw = get_mu_plugins();
         foreach ($mu_plugins_raw as $k => $v) {
             $plugin = $v['Name'];
             if (!empty($v['Version'])) {
                 $plugin .= sprintf(' version %s', $v['Version']);
             }
             if (!empty($v['Author'])) {
                 $plugin .= sprintf(' by %s', $v['Author']);
             }
             if (!empty($v['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $v['AuthorURI']);
             }
             $mu_plugins[] = $plugin;
         }
     }
     $keys = apply_filters('tribe-pue-install-keys', array());
     $systeminfo = array('url' => 'http://' . $_SERVER['HTTP_HOST'], 'name' => $user->display_name, 'email' => $user->user_email, 'install keys' => $keys, 'WordPress version' => get_bloginfo('version'), 'PHP version' => phpversion(), 'plugins' => $plugins, 'network plugins' => $network_plugins, 'mu plugins' => $mu_plugins, 'theme' => wp_get_theme()->get('Name'), 'multisite' => is_multisite(), 'settings' => Tribe__Settings_Manager::get_options(), 'WordPress timezone' => get_option('timezone_string', esc_html__('Unknown or not set', 'tribe-common')), 'server timezone' => date_default_timezone_get(), 'common library dir' => $GLOBALS['tribe-common-info']['dir'], 'common library version' => $GLOBALS['tribe-common-info']['version']);
     if ($this->rewrite_rules_purged) {
         $systeminfo['rewrite rules purged'] = esc_html__('Rewrite rules were purged on load of this help page. Chances are there is a rewrite rule flush occurring in a plugin or theme!', 'tribe-common');
     }
     $systeminfo = apply_filters('tribe-events-pro-support', $systeminfo);
     return $systeminfo;
 }
Example #17
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);
 }
Example #18
0
 /**
  * Collect system information for support
  *
  * @return array of system data for support
  */
 public function getSupportStats()
 {
     global $wpdb;
     $user = wp_get_current_user();
     $plugins = array();
     if (function_exists('get_plugin_data')) {
         $plugins_raw = wp_get_active_and_valid_plugins();
         foreach ($plugins_raw as $k => $v) {
             $plugin_details = get_plugin_data($v);
             $plugin = $plugin_details['Name'];
             if (!empty($plugin_details['Version'])) {
                 $plugin .= sprintf(' version %s', $plugin_details['Version']);
             }
             if (!empty($plugin_details['Author'])) {
                 $plugin .= sprintf(' by %s', $plugin_details['Author']);
             }
             if (!empty($plugin_details['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $plugin_details['AuthorURI']);
             }
             $plugins[] = $plugin;
         }
     }
     $network_plugins = array();
     if (is_multisite() && function_exists('get_plugin_data')) {
         $plugins_raw = wp_get_active_network_plugins();
         foreach ($plugins_raw as $k => $v) {
             $plugin_details = get_plugin_data($v);
             $plugin = $plugin_details['Name'];
             if (!empty($plugin_details['Version'])) {
                 $plugin .= sprintf(' version %s', $plugin_details['Version']);
             }
             if (!empty($plugin_details['Author'])) {
                 $plugin .= sprintf(' by %s', $plugin_details['Author']);
             }
             if (!empty($plugin_details['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $plugin_details['AuthorURI']);
             }
             $network_plugins[] = $plugin;
         }
     }
     $mu_plugins = array();
     if (function_exists('get_mu_plugins')) {
         $mu_plugins_raw = get_mu_plugins();
         foreach ($mu_plugins_raw as $k => $v) {
             $plugin = $v['Name'];
             if (!empty($v['Version'])) {
                 $plugin .= sprintf(' version %s', $v['Version']);
             }
             if (!empty($v['Author'])) {
                 $plugin .= sprintf(' by %s', $v['Author']);
             }
             if (!empty($v['AuthorURI'])) {
                 $plugin .= sprintf('(%s)', $v['AuthorURI']);
             }
             $mu_plugins[] = $plugin;
         }
     }
     $keys = apply_filters('tribe-pue-install-keys', array());
     //Obfuscate the License Keys for Security
     if (is_array($keys) && !empty($keys)) {
         $secure_keys = array();
         foreach ($keys as $plugin => $license) {
             $secure_keys[$plugin] = preg_replace('/^(.{4}).*(.{4})$/', '$1' . str_repeat('#', 32) . '$2', $license);
         }
         $keys = $secure_keys;
     }
     //Server
     $server = explode(' ', $_SERVER['SERVER_SOFTWARE']);
     $server = explode('/', reset($server));
     //PHP Information
     $php_info = array();
     $php_vars = array('max_execution_time', 'memory_limit', 'upload_max_filesize', 'post_max_size', 'display_errors', 'log_errors');
     foreach ($php_vars as $php_var) {
         if (isset($wpdb->qm_php_vars) && isset($wpdb->qm_php_vars[$php_var])) {
             $val = $wpdb->qm_php_vars[$php_var];
         } else {
             $val = ini_get($php_var);
         }
         $php_info[$php_var] = $val;
     }
     $systeminfo = array('Home URL' => get_home_url(), 'Site URL' => get_site_url(), 'Site Language' => get_option('WPLANG') ? get_option('WPLANG') : esc_html__('English', 'tribe-common'), 'Character Set' => get_option('blog_charset'), 'Name' => $user->display_name, 'Email' => $user->user_email, 'Install keys' => $keys, 'WordPress version' => get_bloginfo('version'), 'PHP version' => phpversion(), 'PHP' => $php_info, 'Server' => $server[0], 'SAPI' => php_sapi_name(), 'Plugins' => $plugins, 'Network Plugins' => $network_plugins, 'MU Plugins' => $mu_plugins, 'Theme' => wp_get_theme()->get('Name'), 'Multisite' => is_multisite(), 'Settings' => Tribe__Settings_Manager::get_options(), 'WP Timezone' => get_option('timezone_string') ? get_option('timezone_string') : esc_html__('Unknown or not set', 'tribe-common'), 'WP GMT Offset' => get_option('gmt_offset') ? ' ' . get_option('gmt_offset') : esc_html__('Unknown or not set', 'tribe-common'), 'Server Timezone' => date_default_timezone_get(), 'WP Date Format' => get_option('date_format'), 'WP Time Format' => get_option('time_format'), 'Week Starts On' => get_option('start_of_week'), 'Common Library Dir' => $GLOBALS['tribe-common-info']['dir'], 'Common Library Version' => $GLOBALS['tribe-common-info']['version']);
     if ($this->rewrite_rules_purged) {
         $systeminfo['rewrite rules purged'] = esc_html__('Rewrite rules were purged on load of this help page. Chances are there is a rewrite rule flush occurring in a plugin or theme!', 'tribe-common');
     }
     $systeminfo = apply_filters('tribe-events-pro-support', $systeminfo);
     return $systeminfo;
 }
Example #19
0
 /**
  * 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);
     }
 }
<?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 &amp; 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;
Example #21
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
     $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);
 }
Example #22
0
 * 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');
?>
Example #23
0
 /**
  * Get Network 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_network_option($optionName, $default = '')
 {
     return Tribe__Settings_Manager::get_network_option($optionName, $default);
 }
 /**
  * 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);
 }
Example #25
0
 /**
  * save the settings
  *
  * @return void
  */
 public function save()
 {
     // some hooks
     do_action('tribe_settings_save');
     do_action('tribe_settings_save_tab_' . $this->currentTab);
     // we'll need this later
     $parent_options = array();
     /**
      * loop through each validated option and either
      * save it as is or figure out its parent option ID
      * (in that case, it's a serialized option array and
      * will be saved in the next loop)
      */
     if (!empty($this->validated)) {
         foreach ($this->validated as $field_id => $validated_field) {
             // get the value and filter it
             $value = $validated_field->value;
             $value = apply_filters('tribe_settings_save_field_value', $value, $field_id, $validated_field);
             // figure out the parent option [could be set to false] and filter it
             if (is_network_admin()) {
                 $parent_option = isset($validated_field->field['parent_option']) ? $validated_field->field['parent_option'] : Tribe__Main::OPTIONNAMENETWORK;
             }
             if (!is_network_admin()) {
                 $parent_option = isset($validated_field->field['parent_option']) ? $validated_field->field['parent_option'] : Tribe__Main::OPTIONNAME;
             }
             $parent_option = apply_filters('tribe_settings_save_field_parent_option', $parent_option, $field_id);
             $network_option = isset($validated_field->field['network_option']) ? (bool) $validated_field->field['network_option'] : false;
             // some hooks
             do_action('tribe_settings_save_field', $field_id, $value, $validated_field);
             do_action('tribe_settings_save_field_' . $field_id, $value, $validated_field);
             if (!$parent_option) {
                 if ($network_option || is_network_admin()) {
                     update_site_option($field_id, $value);
                 } else {
                     update_option($field_id, $value);
                 }
             } else {
                 // set the parent option
                 $parent_options[$parent_option][$field_id] = $value;
             }
         }
     }
     /**
      * loop through parent option arrays
      * and save them
      * NOTE: in the case of the main option Tribe Options,
      * this will save using the Tribe__Settings_Manager::set_options method.
      */
     foreach ($parent_options as $option_id => $new_options) {
         // get the old options
         if ($option_id == Tribe__Main::OPTIONNAME) {
             $old_options = (array) get_option($option_id);
         } else {
             $old_options = (array) get_site_option($option_id);
         }
         // set the options by parsing old + new and filter that
         $options = apply_filters('tribe_settings_save_option_array', wp_parse_args($new_options, $old_options), $option_id);
         if ($option_id == Tribe__Main::OPTIONNAME) {
             // save using the Tribe__Settings_Manager method
             Tribe__Settings_Manager::set_options($options);
         } elseif ($option_id == Tribe__Main::OPTIONNAMENETWORK) {
             Tribe__Settings_Manager::set_network_options($options);
         } else {
             // save using regular WP method
             if (is_network_admin()) {
                 update_site_option($option_id, $options);
             } else {
                 update_option($option_id, $options);
             }
         }
     }
     do_action('tribe_settings_after_save');
     do_action('tribe_settings_after_save_' . $this->currentTab);
     remove_action('shutdown', array($this, 'deleteOptions'));
     add_option('tribe_settings_sent_data', $_POST);
     add_option('tribe_settings_errors', $this->errors);
     add_option('tribe_settings_major_error', $this->major_error);
     wp_redirect(esc_url_raw(add_query_arg(array('saved' => true), $this->url)));
     exit;
 }
 /**
  * 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);
 }
Example #27
0
 /**
  * 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];
 }
 /**
  * Saves the network options for the plugin
  *
  * @param array $options formatted the same as from get_options()
  * @param bool  $apply_filters
  *
  * @return void
  */
 public static function set_network_options($options, $apply_filters = true)
 {
     if (!is_array($options)) {
         return;
     }
     if ($apply_filters == true) {
         $options = apply_filters('tribe-events-save-network-options', $options);
     }
     // @TODO use getNetworkOptions + force
     if (update_site_option(Tribe__Main::OPTIONNAMENETWORK, $options)) {
         self::$network_options = apply_filters('tribe_get_network_options', $options);
     } else {
         self::$network_options = self::get_network_options();
     }
 }
Example #29
0
 public function migrate_from_sp_options()
 {
     $tec_options = Tribe__Settings_Manager::get_options();
     $option_names = array('spEventsTemplate' => 'tribeEventsTemplate', 'spEventsBeforeHTML' => 'tribeEventsBeforeHTML', 'spEventsAfterHTML' => 'tribeEventsAfterHTML');
     foreach ($option_names as $old_name => $new_name) {
         if (isset($tec_options[$old_name]) && empty($tec_options[$new_name])) {
             $tec_options[$new_name] = $tec_options[$old_name];
             unset($tec_options[$old_name]);
         }
     }
     Tribe__Settings_Manager::set_options($tec_options);
 }
 /**
  * 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';
 }