private function do_updates()
 {
     set_time_limit(0);
     if ($this->is_version_in_db_less_than('3.5')) {
         $this->update_3_5();
     }
     tribe_update_option('pro-schema-version', self::SCHEMA_VERSION);
 }
 /**
  * Modify the database appropriately to reflect the current
  * recurring events status
  */
 public function toggle_recurring_events()
 {
     $current_status = tribe_get_option('recurring_events_are_hidden', false);
     if ($current_status == 'hidden' && $this->recurring) {
         $this->restore_hidden_events();
         tribe_update_option('recurring_events_are_hidden', 'exposed');
     } elseif ($current_status == 'exposed' && !$this->recurring) {
         $this->hide_recurring_events();
         tribe_update_option('recurring_events_are_hidden', 'hidden');
     } elseif (!$current_status) {
         tribe_update_option('recurring_events_are_hidden', $this->recurring ? 'exposed' : 'hidden');
     }
 }
 public function add_custom_field($label, $type = 'text', $default = '')
 {
     if (class_exists('Tribe__Events__Pro__Main')) {
         $custom_fields = tribe_get_option('custom-fields');
         $field_exists = false;
         // Check in case the "new" custom field is already present
         foreach ($custom_fields as $field) {
             if ($field['label'] === $label) {
                 $field_exists = true;
             }
         }
         // If it is not, add it
         if (false === $field_exists) {
             $index = count($custom_fields) + 1;
             $custom_fields[] = array('name' => "_ecp_custom_{$index}", 'label' => $label, 'type' => $type, 'values' => $default);
             tribe_update_option('custom-fields', $custom_fields);
         }
     }
 }
 /**
  * Intelligently updates our record of the earliest start date/latest event date in
  * the system. If the existing earliest/latest values have not been superseded by the new post's
  * start/end date then no update takes place.
  *
  * This is deliberately hooked into save_post, rather than save_post_tribe_events, to avoid issues
  * where the removal/restoration of hooks within addEventMeta() etc might stop this method from
  * actually being called (relates to a core WP bug).
  *
  * @param int $event_id
  */
 public function update_known_range($event_id)
 {
     $is_earliest_date_marker = in_array($event_id, tribe_get_option('earliest_date_markers', array()));
     $is_latest_date_marker = in_array($event_id, tribe_get_option('latest_date_markers', array()));
     if ($is_earliest_date_marker || $is_latest_date_marker) {
         $this->rebuild_known_range();
         return;
     }
     $current_min = tribe_events_earliest_date();
     $current_max = tribe_events_latest_date();
     $event_start = tribe_get_start_date($event_id, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
     $event_end = tribe_get_end_date($event_id, false, Tribe__Date_Utils::DBDATETIMEFORMAT);
     if ($current_min > $event_start) {
         $this->rebuild_known_range();
         tribe_update_option('earliest_date', $event_start);
     }
     if ($current_max < $event_end) {
         $this->rebuild_known_range();
         tribe_update_option('latest_date', $event_end);
     }
 }
Example #5
0
 /**
  * Determines whether or not to show the custom fields metabox for events.
  *
  * @return bool Whether to show or not.
  */
 public function displayMetaboxCustomFields()
 {
     $show_box = tribe_get_option('disable_metabox_custom_fields');
     if ($show_box == 'show') {
         return true;
     }
     if ($show_box == 'hide') {
         remove_post_type_support(Tribe__Events__Main::POSTTYPE, 'custom-fields');
         return false;
     }
     if (empty($show_box)) {
         global $wpdb;
         $meta_keys = $wpdb->get_results("SELECT DISTINCT pm.meta_key FROM {$wpdb->postmeta} pm\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id\n\t\t\t\t\t\t\t\t\t\tWHERE p.post_type = '" . Tribe__Events__Main::POSTTYPE . "'\n\t\t\t\t\t\t\t\t\t\tAND pm.meta_key NOT LIKE '_wp_%'\n\t\t\t\t\t\t\t\t\t\tAND pm.meta_key NOT IN (\n\t\t\t\t\t\t\t\t\t\t\t'_edit_last',\n\t\t\t\t\t\t\t\t\t\t\t'_edit_lock',\n\t\t\t\t\t\t\t\t\t\t\t'_thumbnail_id',\n\t\t\t\t\t\t\t\t\t\t\t'_EventConference',\n\t\t\t\t\t\t\t\t\t\t\t'_EventAllDay',\n\t\t\t\t\t\t\t\t\t\t\t'_EventHideFromUpcoming',\n\t\t\t\t\t\t\t\t\t\t\t'_EventOrigin',\n\t\t\t\t\t\t\t\t\t\t\t'_EventShowMap',\n\t\t\t\t\t\t\t\t\t\t\t'_EventVenueID',\n\t\t\t\t\t\t\t\t\t\t\t'_EventShowMapLink',\n\t\t\t\t\t\t\t\t\t\t\t'_EventCost',\n\t\t\t\t\t\t\t\t\t\t\t'_EventOrganizerID',\n\t\t\t\t\t\t\t\t\t\t\t'_EventRecurrence',\n\t\t\t\t\t\t\t\t\t\t\t'_EventStartDate',\n\t\t\t\t\t\t\t\t\t\t\t'_EventEndDate',\n\t\t\t\t\t\t\t\t\t\t\t'_EventDuration',\n\t\t\t\t\t\t\t\t\t\t\t'_FacebookID')");
         if (empty($meta_keys)) {
             remove_post_type_support(Tribe__Events__Main::POSTTYPE, 'custom-fields');
             $show_box = 'hide';
             $r = false;
         } else {
             $show_box = 'show';
             $r = true;
         }
         tribe_update_option('disable_metabox_custom_fields', $show_box);
         return $r;
     }
 }
Example #6
0
 /**
  * Determine the earliest start date and latest end date currently in the database
  * and store those values for future use.
  */
 public function rebuild_known_range()
 {
     global $wpdb;
     remove_action('deleted_post', array($this, 'rebuild_known_range'));
     $earliest = strtotime($wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT MIN(meta_value) FROM {$wpdb->postmeta}\n\t\t\t\tJOIN {$wpdb->posts} ON post_id = ID\n\t\t\t\tWHERE meta_key = '_EventStartDate'\n\t\t\t\tAND post_type = '%s'\n\t\t\t\tAND post_status IN ('publish', 'private', 'protected')\n\t\t\t", self::POSTTYPE)));
     $latest = strtotime($wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT MAX(meta_value) FROM {$wpdb->postmeta}\n\t\t\t\tJOIN {$wpdb->posts} ON post_id = ID\n\t\t\t\tWHERE meta_key = '_EventEndDate'\n\t\t\t\tAND post_type = '%s'\n\t\t\t\tAND post_status IN ('publish', 'private', 'protected')\n\t\t\t", self::POSTTYPE)));
     if ($earliest) {
         tribe_update_option('earliest_date', date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, $earliest));
     }
     if ($latest) {
         tribe_update_option('latest_date', date(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, $latest));
     }
 }
Example #7
0
 public function ajax_save_credentials()
 {
     if (empty($_POST['tribe_credentials_which'])) {
         $data = array('message' => __('Invalid credential save request', 'the-events-calendar'));
         wp_send_json_error($data);
     }
     $which = $_POST['tribe_credentials_which'];
     if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], "tribe-save-{$which}-credentials")) {
         $data = array('message' => __('Invalid credential save nonce', 'the-events-calendar'));
         wp_send_json_error($data);
     }
     if ('meetup' === $which) {
         if (empty($_POST['meetup_api_key'])) {
             $data = array('message' => __('The Meetup API key is required.', 'the-events-calendar'));
             wp_send_json_error($data);
         }
         tribe_update_option('meetup_api_key', trim(preg_replace('/[^a-zA-Z0-9]/', '', $_POST['meetup_api_key'])));
         $data = array('message' => __('Credentials have been saved', 'the-events-calendar'));
         wp_send_json_success($data);
     }
     $data = array('message' => __('Unable to save credentials', 'the-events-calendar'));
     wp_send_json_error($data);
 }
Example #8
0
 /**
  * Bump the :30 min EOD cutoff option to the next full hour
  *
  * @return void
  */
 public function remove_30_min_eod_cutoffs()
 {
     $eod_cutoff = tribe_event_end_of_day();
     if (Tribe__Events__Date_Utils::minutes_only($eod_cutoff) == '29') {
         $eod_cutoff = date_create('@' . (strtotime($eod_cutoff) + 1));
         $eod_cutoff->modify('+30 minutes');
         tribe_update_option('multiDayCutoff', $eod_cutoff->format('h:i'));
     }
 }
<?php

$displayPressTrendsDialogue = tribe_get_option('displayedPressTrendsDialogue', false);
$displayPressTrendsDialogueValue = $displayPressTrendsDialogue == false ? '1' : '0';
if ($displayPressTrendsDialogue == false) {
    tribe_update_option('displayedPressTrendsDialogue', true);
}
$generalTab = array('priority' => 10, 'fields' => apply_filters('tribe_general_settings_tab_fields', array('info-start' => array('type' => 'html', 'html' => '<div id="modern-tribe-info"><img src="' . plugins_url('resources/images/modern-tribe.png', dirname(__FILE__)) . '" alt="Modern Tribe Inc." title="Modern Tribe Inc.">'), 'upsell-heading' => array('type' => 'heading', 'label' => __('Finding & extending your calendar.', 'tribe-events-calendar'), 'conditional' => !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL), 'finding-heading' => array('type' => 'heading', 'label' => __('Finding your calendar.', 'tribe-events-calendar'), 'conditional' => defined('TRIBE_HIDE_UPSELL') && TRIBE_HIDE_UPSELL), 'view-calendar-link' => array('type' => 'html', 'html' => '<p>' . __('Where\'s my calendar?', 'tribe-events-calendar') . '<br /><a href="' . TribeEvents::getLink() . '">' . __('Right here', 'tribe-events-calendar') . '</a>.</p>'), 'upsell-info' => array('type' => 'html', 'html' => '<p>' . __('Looking for additional functionality including recurring events, custom meta, community events, ticket sales and more?', 'tribe-events-calendar') . '<br><a href="' . self::$tribeUrl . 'shop/?utm_source=generaltab&utm_medium=promolink&utm_campaign=plugin' . '">' . __('Check out the available Add-Ons', 'tribe-events-calendar') . '</a>.</p>', 'conditional' => !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL), 'donate-link-heading' => array('type' => 'heading', 'label' => __('We hope our plugin is helping you out.', 'tribe-events-calendar')), 'donate-link-info' => array('type' => 'html', 'html' => '<p>' . __('Are you thinking "Wow, this plugin is amazing! I should say thanks to Modern Tribe for all their hard work." The greatest thanks we could ask for is recognition. Add a small text only link at the bottom of your calendar pointing to The Events Calendar project.', 'tribe-events-calendar') . '<br><a href="' . plugins_url('resources/images/donate-link-screenshot.jpg', dirname(__FILE__)) . '" class="thickbox">' . __('See an example of the link', 'tribe-events-calendar') . '</a>.</p>', 'conditional' => !class_exists('TribeEventsPro')), 'donate-link-pro-info' => array('type' => 'html', 'html' => '<p>' . __('Are you thinking "Wow, this plugin is amazing! I should say thanks to Modern Tribe for all their hard work." The greatest thanks we could ask for is recognition. Add a small text only link at the bottom of your calendar pointing to The Events Calendar project.', 'tribe-events-calendar') . '<br><a href="' . plugins_url('resources/images/donate-link-pro-screenshot.jpg', dirname(__FILE__)) . '" class="thickbox">' . __('See an example of the link', 'tribe-events-calendar') . '</a>.</p>', 'conditional' => class_exists('TribeEventsPro')), 'donate-link' => array('type' => 'checkbox_bool', 'label' => __('Show Events Calendar Link', 'tribe-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'info-end' => array('type' => 'html', 'html' => '</div>'), 'viewOption' => array('type' => 'radio', 'label' => __('Default view for the Events', 'tribe-events-calendar'), 'default' => 'month', 'options' => array('month' => 'Calendar', 'upcoming' => 'Event List'), 'validation_type' => 'options'), 'unprettyPermalinksUrl' => array('type' => 'html', 'label' => __('Events URL slug', 'tribe-events-calendar'), 'html' => '<p class="tribe-field-indent tribe-field-description description">' . __('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=" ' . TribeEvents::getLink('home') . '">' . TribeEvents::getLink('home ') . '</a>. In order to edit the slug here, enable pretty permalinks.', 'tribe-events-calendar') . '</p>', 'conditional' => '' == get_option('permalink_structure')), 'eventsSlug' => array('type' => 'text', 'label' => __('Events URL slug', 'tribe-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">' . __('The slug used for building the events URL.', 'tribe-events-calendar') . sprintf(__('Your current Events URL is %s', 'tribe-events-calendar'), '<code><a href="' . 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">' . __('Here is the iCal feed URL for your events:', 'tribe-events-calendar') . ' ' . '<code>' . tribe_get_ical_link() . '</code></p>' : '', 'conditional' => function_exists('tribe_get_ical_link')), 'singleEventSlug' => array('type' => 'text', 'label' => __('Single Event URL slug', 'tribe-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(__('You <strong>cannot</strong> use the same slug as above. The above should ideally be plural, and this singular.<br />Your single Event URL is like: %s', 'tribe-events-calendar'), '<code>' . trailingslashit(home_url()) . tribe_get_option('singleEventSlug', 'event') . '/single-post-name/' . '</code>') . '</p>', 'conditional' => '' != get_option('permalink_structure')), 'postsPerPage' => array('type' => 'text', 'label' => __('Number of events to show per page', 'tribe-events-calendar'), 'size' => 'small', 'default' => get_option('posts_per_page'), 'validation_type' => 'positive_int'), 'showComments' => array('type' => 'checkbox_bool', 'label' => __('Show Comments', 'tribe-events-calendar'), 'tooltip' => __('Enable commenting on an event.', 'tribe-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'multiDayCutoff' => array('type' => 'dropdown', 'label' => __('Multiday Event Cutoff', 'tribe-events-calendar'), 'tooltip' => __('Hide final day from grid view if multi-day event ends before this time.', 'tribe-events-calendar'), 'validation_type' => 'options', 'size' => 'small', 'default' => '12:00', 'options' => array('12:00' => '12:00 am', '12:30' => '12:30 am', '01:00' => '01:00 am', '01:30' => '01:30 am', '02:00' => '02:00 am', '02:30' => '02:30 am', '03:00' => '03:00 am', '03:30' => '03:30 am', '04:00' => '04:00 am', '04:30' => '04:30 am', '05:00' => '05:00 am', '05:30' => '05:30 am', '06:00' => '06:00 am', '06:30' => '06:30 am', '07:00' => '07:00 am', '07:30' => '07:30 am', '08:00' => '08:00 am', '08:30' => '08:30 am', '09:00' => '09:00 am', '09:30' => '09:30 am', '10:00' => '10:00 am', '10:30' => '10:30 am', '11:00' => '11:00 am', '11:30' => '11:30 am')), 'embedGoogleMaps' => array('type' => 'checkbox_bool', 'label' => __('Enable Google Maps', 'tribe-events-calendar'), 'tooltip' => __('Turn on to enable backend map preview and frontend map.', 'tribe-events-calendar'), 'default' => true, 'class' => 'google-embed-size', 'validation_type' => 'boolean'), 'embedGoogleMapsHeight' => array('type' => 'text', 'label' => __('Google Maps Embed Height', 'tribe-events-calendar'), 'size' => 'small', 'default' => 350, 'tooltip' => __('Enter a number.', 'tribe-events-calendar'), 'class' => 'google-embed-field', 'validation_type' => 'positive_int'), 'embedGoogleMapsWidth' => array('type' => 'text', 'label' => __('Google Maps Embed Width', 'tribe-events-calendar'), 'size' => 'small', 'tooltip' => __('Enter a number or %.', 'tribe-events-calendar'), 'default' => '100%', 'class' => 'google-embed-field', 'validation_type' => 'number_or_percent'), 'embedGoogleMapsZoom' => array('type' => 'text', 'label' => __('Google Maps Default Zoom Level', 'tribe-events-calendar'), 'tooltip' => __('0 = zoomed out; 21 = zoomed in.', 'tribe_events_calendar'), 'size' => 'small', 'default' => 10, 'class' => 'google-embed-field', 'validation_type' => 'number_or_percent'), 'sendPressTrendsData' => array('type' => 'checkbox_bool', 'label' => __('Send PressTrends Data', 'tribe-events-calendar'), 'tooltip' => __('Help us out by sending analytics data about your usage of The Events Calendar.', 'tribe-events-calendar'), 'default' => false, 'validation_type' => 'boolean'), 'debugEvents' => array('type' => 'checkbox_bool', 'label' => __('Debug Mode', 'tribe-events-calendar'), 'tooltip' => sprintf(__('Enable this option to log debug information. By default this will log to your server PHP error log. If you\'d like to see the log messages in your browser, then we recommend that you install the %s and look for the "Tribe" tab in the debug output.', 'tribe-events-calendar'), '<a href="http://wordpress.org/extend/plugins/debug-bar/" target="_blank">' . __('Debug Bar Plugin', 'tribe-events-calendar') . '</a>'), 'default' => false, 'validation_type' => 'boolean'), 'maybeDisplayPressTrendsDialogue' => array('type' => 'html', 'html' => '<input type="hidden" name="maybeDisplayPressTrendsDialogue" value="' . $displayPressTrendsDialogueValue . '"></input>'), 'pressTrendsDialogue' => array('type' => 'html', 'html' => '<div id="presstrends-dialog" title="Send PressTrends Data" style="display: none;">' . __('Would you like to help us out and send analytics about your usage of The Events Calendar?', 'tribe-events-calendar') . '<br/></div>'))));
 public function clear_fb_credentials()
 {
     tribe_update_option('fb_token', null);
     tribe_update_option('fb_token_expires', null);
     tribe_update_option('fb_token_scopes', null);
 }
Example #11
0
 /**
  * Echo JSON results for key validation
  */
 public function ajax_validate_key()
 {
     $response = array();
     $response['status'] = 0;
     if (isset($_POST['key'])) {
         $queryArgs = array('pu_install_key' => trim($_POST['key']), 'pu_checking_for_updates' => '1');
         //include version info
         $queryArgs['pue_active_version'] = $this->get_installed_version();
         global $wp_version;
         $queryArgs['wp_version'] = $wp_version;
         // For multisite, return the network-level siteurl ... in
         // all other cases return the actual URL being serviced
         $queryArgs['domain'] = is_multisite() ? $this->get_network_domain() : $_SERVER['SERVER_NAME'];
         if (is_multisite()) {
             $queryArgs['multisite'] = 1;
             $queryArgs['network_activated'] = is_plugin_active_for_network($this->get_plugin_file());
             global $wpdb;
             $queryArgs['active_sites'] = $wpdb->get_var("SELECT count(blog_id) FROM {$wpdb->blogs} WHERE public = '1' AND archived = '0' AND spam = '0' AND deleted = '0'");
         } else {
             $queryArgs['multisite'] = 0;
             $queryArgs['network_activated'] = 0;
             $queryArgs['active_sites'] = 1;
         }
         $pluginInfo = $this->request_info($queryArgs);
         $expiration = isset($pluginInfo->expiration) ? $pluginInfo->expiration : esc_html__('unknown date', 'the-events-calendar');
         if (empty($pluginInfo)) {
             $response['message'] = esc_html__('Sorry, key validation server is not available.', 'the-events-calendar');
         } elseif (isset($pluginInfo->api_expired) && $pluginInfo->api_expired == 1) {
             $response['message'] = esc_html__('Sorry, this key is expired.', 'the-events-calendar');
         } elseif (isset($pluginInfo->api_upgrade) && $pluginInfo->api_upgrade == 1) {
             $problem = __('Sorry, this key is out of installs.', 'the-events-calendar');
             $helpful_link = sprintf('<a href="%s" target="_blank">%s</a>', 'http://m.tri.be/lz', __('Why am I seeing this message?'));
             $response['message'] = "{$problem} {$helpful_link}";
         } elseif (isset($pluginInfo->api_invalid) && $pluginInfo->api_invalid == 1) {
             $response['message'] = esc_html__('Sorry, this key is not valid.', 'the-events-calendar');
         } else {
             $api_secret_key = tribe_get_option($this->pue_install_key);
             if ($api_secret_key && $api_secret_key === $queryArgs['pu_install_key']) {
                 $default_success_msg = sprintf(esc_html__('Valid Key! Expires on %s', 'the-events-calendar'), $expiration);
             } else {
                 // Set the key
                 tribe_update_option($this->pue_install_key, $queryArgs['pu_install_key']);
                 $default_success_msg = sprintf(esc_html__('Thanks for setting up a valid key, it will expire on %s', 'the-events-calendar'), $expiration);
             }
             $response['status'] = isset($pluginInfo->api_message) ? 2 : 1;
             $response['message'] = isset($pluginInfo->api_message) ? wp_kses($pluginInfo->api_message, 'data') : $default_success_msg;
             $response['expiration'] = $expiration;
         }
     } else {
         $response['message'] = sprintf(esc_html__('Hmmm... something\'s wrong with this validator. Please contact %ssupport%s.', 'the-events-calendar'), '<a href="http://m.tri.be/1u">', '</a>');
     }
     echo json_encode($response);
     exit;
 }
Example #12
0
 /**
  * Sets the current logging level to the provided level (if it is a valid
  * level, else will set the level to 'default').
  *
  * @param string $level
  */
 public function set_level($level)
 {
     $available_levels = wp_list_pluck($this->get_logging_levels(), 0);
     if (!in_array($level, $available_levels)) {
         $level = self::DISABLE;
     }
     tribe_update_option('logging_level', $level);
     $this->current_level = $level;
 }
Example #13
0
 function tribe_ecp_deactivate()
 {
     if (function_exists('tribe_update_option')) {
         tribe_update_option('defaultValueReplace', true);
         tribe_update_option('defaultCountry', null);
     }
 }