/** * Get value for a specific option * * @param string $optionName name of option * @param string $default default value * * @return mixed results of option query */ public static function getOption($optionName, $default = '') { if (!$optionName) { return null; } $value = Tribe__Events__Main::getOption($optionName, $default); return apply_filters('tribe-import-setting-' . $optionName, $value, $default); }
private function build_event_array(array $record) { $start_date = strtotime($this->get_event_start_date($record)); $end_date = strtotime($this->get_event_end_date($record)); $event = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'post_status' => Tribe__Events__Main::getOption('imported_post_status', 'publish'), 'post_content' => $this->get_value_by_key($record, 'event_description'), 'EventStartDate' => date('Y-m-d', $start_date), 'EventStartHour' => date('h', $start_date), 'EventStartMinute' => date('i', $start_date), 'EventStartMeridian' => date('a', $start_date), 'EventEndDate' => date('Y-m-d', $end_date), 'EventEndHour' => date('h', $end_date), 'EventEndMinute' => date('i', $end_date), 'EventEndMeridian' => date('a', $end_date), 'EventShowMapLink' => $this->get_boolean_value_by_key($record, 'event_show_map_link'), 'EventShowMap' => $this->get_boolean_value_by_key($record, 'event_show_map'), 'EventCost' => $this->get_value_by_key($record, 'event_cost'), 'EventAllDay' => $this->get_boolean_value_by_key($record, 'event_all_day', 'yes'), 'EventHideFromUpcoming' => $this->get_value_by_key($record, 'event_hide'), 'EventURL' => $this->get_value_by_key($record, 'event_website')); if ($organizer_id = $this->find_matching_organizer_id($record)) { $event['Organizer'] = array('OrganizerID' => $organizer_id); } if ($venue_id = $this->find_matching_venue_id($record)) { $event['Venue'] = array('VenueID' => $venue_id); } if ($cats = $this->get_value_by_key($record, 'event_category')) { $event['tax_input'][Tribe__Events__Main::TAXONOMY] = $this->translate_terms_to_ids(explode(',', $cats)); } return $event; }
public static function get_default_post_status($type = 'csv') { $options = self::getOption('imported_post_status', array($type => 'publish')); // Legacy for Facebook Status if ('facebook' === $type && empty($options['facebook'])) { $options['facebook'] = Tribe__Events__Main::getOption('fb_default_status', 'publish'); } // A way to handle the legacy `imported_post_status` if (is_string($options)) { $options = array($type => $options); } if (!isset($options[$type])) { $options[$type] = apply_filters('tribe_import_default_post_status_non_saved', 'publish', $type); } /** * Allows users to filter */ return apply_filters('tribe_import_default_post_status', $options[$type], $type); }
<div class="tribe-settings-form"> <form method="POST"> <div class="tribe-settings-form-wrap"> <h3><?php esc_html_e('Import Settings', 'tribe-events-calendar'); ?> </h3> <p> <?php esc_html_e('Default imported event status:', 'tribe-events-calendar'); $import_statuses = array('publish' => __('Published', 'tribe-events-calendar'), 'pending' => __('Pending', 'tribe-events-calendar'), 'draft' => __('Draft', 'tribe-events-calendar')); ?> <select name="imported_post_status"> <?php foreach ($import_statuses as $key => $value) { echo '<option value="' . esc_attr($key) . '" ' . selected($key, Tribe__Events__Main::getOption('imported_post_status', 'publish')) . '> ' . $value . ' </option>'; } ?> </select> </p> <?php wp_nonce_field('tribe-import-general-settings', 'tribe-import-general-settings'); ?> <p> <input type="submit" name="tribe-events-importexport-general-settings-submit" class="button-primary" value="Save Settings"/> </p> </div> </form>
/** * 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__Events__Main::OPTIONNAMENETWORK; } if (!is_network_admin()) { $parent_option = isset($field['parent_option']) ? $field['parent_option'] : Tribe__Events__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__Events__Main::OPTIONNAME) { // get the options from Tribe__Events__Main if we're getting the main array $value = Tribe__Events__Main::getOption($key, $default); } elseif ($parent_option == Tribe__Events__Main::OPTIONNAMENETWORK) { $value = Tribe__Events__Main::instance()->getNetworkOption($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__Events__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-events-calendar') . '</p>'; } }
} ?> <th class="essential"><?php _e('Start Date', 'tribe-events-community'); ?> </th> <th class="essential"><?php _e('End Date', 'tribe-events-community'); ?> </th> </tr> </thead><!-- #my-events-display-headers --> <tbody id="the-list"><tr> <?php $rewriteSlugSingular = Tribe__Events__Main::getOption('singleEventSlug', 'event'); global $post; $old_post = $post; while ($events->have_posts()) { $e = $events->next_post(); $post = $e; ?> <tr> <td><?php if (isset($icons[$post->post_status])) { echo wpv_shortcode_icon(array('name' => $icons[$post->post_status], 'size' => 16)); } else { echo TribeCommunityEvents::instance()->getEventStatusIcon($post->post_status); }