true, 'after' => true );
/**
* Args for the event post type
* @var array
*/
protected $postTypeArgs = array(
'public' => true,
'rewrite' => array( 'slug' => 'event', 'with_front' => false ),
'menu_position' => 6,
'supports' => array(
'title',
'editor',
'excerpt',
'author',
'thumbnail',
'custom-fields',
'comments',
),
'taxonomies' => array( 'post_tag' ),
'capability_type' => array( 'tribe_event', 'tribe_events' ),
'map_meta_cap' => true,
'has_archive' => true,
);
/**
* Args for venue post type
* @var array
*/
public $postVenueTypeArgs = array(
'public' => false,
'rewrite' => array( 'slug' => 'venue', 'with_front' => false ),
'show_ui' => true,
'show_in_menu' => 0,
'supports' => array( 'title', 'editor' ),
'capability_type' => array( 'tribe_venue', 'tribe_venues' ),
'map_meta_cap' => true,
'exclude_from_search' => true,
);
protected $taxonomyLabels;
/**
* Args for organizer post type
* @var array
*/
public $postOrganizerTypeArgs = array(
'public' => false,
'rewrite' => array( 'slug' => 'organizer', 'with_front' => false ),
'show_ui' => true,
'show_in_menu' => 0,
'supports' => array( 'title', 'editor' ),
'capability_type' => array( 'tribe_organizer', 'tribe_organizers' ),
'map_meta_cap' => true,
'exclude_from_search' => true,
);
public static $tribeUrl = 'http://tri.be/';
public static $tecUrl = 'http://theeventscalendar.com/';
public static $addOnPath = 'products/';
public static $dotOrgSupportUrl = 'http://wordpress.org/tags/the-events-calendar';
protected static $instance;
public $rewriteSlug = 'events';
public $rewriteSlugSingular = 'event';
public $taxRewriteSlug = 'event/category';
public $tagRewriteSlug = 'event/tag';
public $monthSlug = 'month';
/** @var Tribe__Events__Admin__Timezone_Settings */
public $timezone_settings;
// @todo remove in 4.0
public $upcomingSlug = 'upcoming';
public $pastSlug = 'past';
public $listSlug = 'list';
public $daySlug = 'day';
public $todaySlug = 'today';
protected $postExceptionThrown = false;
protected static $networkOptions;
public $displaying;
public $pluginDir;
public $pluginPath;
public $pluginUrl;
public $pluginName;
public $date;
protected $tabIndexStart = 2000;
public $metaTags = array(
'_EventAllDay',
'_EventStartDate',
'_EventEndDate',
'_EventStartDateUTC',
'_EventEndDateUTC',
'_EventDuration',
'_EventVenueID',
'_EventShowMapLink',
'_EventShowMap',
'_EventCurrencySymbol',
'_EventCurrencyPosition',
'_EventCost',
'_EventCostMin',
'_EventCostMax',
'_EventURL',
'_EventOrganizerID',
'_EventPhone',
'_EventHideFromUpcoming',
'_EventTimezone',
'_EventTimezoneAbbr',
self::EVENTSERROROPT,
);
public $venueTags = array(
'_VenueVenue',
'_VenueCountry',
'_VenueAddress',
'_VenueCity',
'_VenueStateProvince',
'_VenueState',
'_VenueProvince',
'_VenueZip',
'_VenuePhone',
'_VenueURL',
);
public $organizerTags = array(
'_OrganizerOrganizer',
'_OrganizerEmail',
'_OrganizerWebsite',
'_OrganizerPhone',
);
public $currentPostTimestamp;
public $daysOfWeekShort;
public $daysOfWeek;
public $daysOfWeekMin;
public $monthsFull;
public $monthsShort;
public $singular_venue_label;
public $plural_venue_label;
public $singular_organizer_label;
public $plural_organizer_label;
public $singular_event_label;
public $plural_event_label;
/** @var Tribe__Events__Default_Values */
private $default_values = null;
public static $tribeEventsMuDefaults;
/**
* Static Singleton Factory Method
*
* @return Tribe__Events__Main
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
$className = __CLASS__;
self::$instance = new $className;
}
return self::$instance;
}
/**
* Initializes plugin variables and sets up WordPress hooks/actions.
*/
protected function __construct() {
$this->pluginPath = trailingslashit( dirname( dirname( dirname( __FILE__ ) ) ) );
$this->pluginDir = trailingslashit( basename( $this->pluginPath ) );
$this->pluginUrl = plugins_url( $this->pluginDir );
// include the autolader class
require_once( $this->pluginPath . '/src/Tribe/Autoloader.php' );
$this->init_autoloading();
add_action( 'init', array( $this, 'loadTextDomain' ), 1 );
if ( self::supportedVersion( 'wordpress' ) && self::supportedVersion( 'php' ) ) {
$this->addHooks();
$this->loadLibraries();
} else {
// Either PHP or WordPress version is inadequate so we simply return an error.
add_action( 'admin_head', array( $this, 'notSupportedError' ) );
}
}
/**
* Load all the required library files.
*/
protected function loadLibraries() {
// Tribe common resources
require_once $this->pluginPath . 'vendor/tribe-common-libraries/tribe-common-libraries.class.php';
// Load CSV importer
require_once $this->pluginPath . 'src/io/csv/ecp-events-importer.php';
// Load Template Tags
require_once $this->pluginPath . 'src/functions/template-tags/query.php';
require_once $this->pluginPath . 'src/functions/template-tags/general.php';
require_once $this->pluginPath . 'src/functions/template-tags/month.php';
require_once $this->pluginPath . 'src/functions/template-tags/loop.php';
require_once $this->pluginPath . 'src/functions/template-tags/google-map.php';
require_once $this->pluginPath . 'src/functions/template-tags/organizer.php';
require_once $this->pluginPath . 'src/functions/template-tags/venue.php';
require_once $this->pluginPath . 'src/functions/template-tags/date.php';
require_once $this->pluginPath . 'src/functions/template-tags/link.php';
require_once $this->pluginPath . 'src/functions/template-tags/widgets.php';
require_once $this->pluginPath . 'src/functions/template-tags/meta.php';
require_once $this->pluginPath . 'src/functions/template-tags/tickets.php';
// Load Advanced Functions
require_once $this->pluginPath . 'src/functions/advanced-functions/event.php';
require_once $this->pluginPath . 'src/functions/advanced-functions/venue.php';
require_once $this->pluginPath . 'src/functions/advanced-functions/organizer.php';
// Load Deprecated Template Tags
if ( ! defined( 'TRIBE_DISABLE_DEPRECATED_TAGS' ) ) {
require_once $this->pluginPath . 'src/functions/template-tags/deprecated.php';
}
// Load multisite defaults
if ( is_multisite() ) {
$tribe_events_mu_defaults = array();
if ( file_exists( WP_CONTENT_DIR . '/tribe-events-mu-defaults.php' ) ) {
require_once WP_CONTENT_DIR . '/tribe-events-mu-defaults.php';
}
self::$tribeEventsMuDefaults = apply_filters( 'tribe_events_mu_defaults', $tribe_events_mu_defaults );
}
}
/**
* before_html_data_wrapper adds a persistant tag to wrap the event display with a
* way for jQuery to maintain state in the dom. Also has a hook for filtering data
* attributes for inclusion in the dom
*
* @param string $html
*
* @return string
*/
public function before_html_data_wrapper( $html ) {
global $wp_query;
if ( ! $this->show_data_wrapper['before'] ) {
return $html;
}
$tec = self::instance();
$data_attributes = array(
'live_ajax' => tribe_get_option( 'liveFiltersUpdate', true ) ? 1 : 0,
'datepicker_format' => tribe_get_option( 'datepickerFormat' ),
'category' => is_tax( $tec->get_event_taxonomy() ) ? get_query_var( 'term' ) : '',
);
// allow data attributes to be filtered before display
$data_attributes = (array) apply_filters( 'tribe_events_view_data_attributes', $data_attributes );
// loop through the attributes and build the html output
foreach ( $data_attributes as $id => $attr ) {
$attribute_html[] = sprintf(
'data-%s="%s"',
sanitize_title( $id ),
esc_attr( $attr )
);
}
$this->show_data_wrapper['before'] = false;
// return filtered html
return apply_filters( 'tribe_events_view_before_html_data_wrapper', sprintf( '
%s', implode( ' ', $attribute_html ), $html ), $data_attributes, $html );
}
/**
* after_html_data_wrapper close out the persistant dom wrapper
*
* @param string $html
*
* @return string
*/
public function after_html_data_wrapper( $html ) {
if ( ! $this->show_data_wrapper['after'] ) {
return $html;
}
$html .= '
';
$html .= tribe_events_promo_banner( false );
$this->show_data_wrapper['after'] = false;
return apply_filters( 'tribe_events_view_after_html_data_wrapper', $html );
}
/**
* Add filters and actions
*/
protected function addHooks() {
// Load Rewrite
add_action( 'plugins_loaded', array( Tribe__Events__Rewrite::instance(), 'hooks' ) );
add_action( 'init', array( $this, 'init' ), 10 );
add_action( 'admin_init', array( $this , 'admin_init' ) );
// Frontend Javascript
add_action( 'wp_enqueue_scripts', array( $this, 'loadStyle' ) );
add_filter( 'tribe_events_before_html', array( $this, 'before_html_data_wrapper' ) );
add_filter( 'tribe_events_after_html', array( $this, 'after_html_data_wrapper' ) );
// Styling
add_filter( 'post_class', array( $this, 'post_class' ) );
add_filter( 'body_class', array( $this, 'body_class' ) );
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
add_filter( 'post_type_archive_link', array( $this, 'event_archive_link' ), 10, 2 );
add_filter( 'query_vars', array( $this, 'eventQueryVars' ) );
add_filter( 'bloginfo_rss', array( $this, 'add_space_to_rss' ) );
add_filter( 'post_updated_messages', array( $this, 'updatePostMessage' ) );
/* Add nav menu item - thanks to http://wordpress.org/extend/plugins/cpt-archives-in-nav-menus/ */
add_filter( 'nav_menu_items_' . self::POSTTYPE, array( $this, 'add_events_checkbox_to_menu' ), null, 3 );
add_filter( 'wp_nav_menu_objects', array( $this, 'add_current_menu_item_class_to_events' ), null, 2 );
add_filter( 'template_redirect', array( $this, 'redirect_past_upcoming_view_urls' ), 11 );
/* Setup Tribe Events Bar */
add_filter( 'tribe-events-bar-views', array( $this, 'setup_listview_in_bar' ), 1, 1 );
add_filter( 'tribe-events-bar-views', array( $this, 'setup_gridview_in_bar' ), 5, 1 );
add_filter( 'tribe-events-bar-views', array( $this, 'setup_dayview_in_bar' ), 15, 1 );
add_filter( 'tribe-events-bar-filters', array( $this, 'setup_date_search_in_bar' ), 1, 1 );
add_filter( 'tribe-events-bar-filters', array( $this, 'setup_keyword_search_in_bar' ), 1, 1 );
add_filter( 'tribe-events-bar-views', array( $this, 'remove_hidden_views' ), 9999, 2 );
/* End Setup Tribe Events Bar */
add_action( 'admin_menu', array( $this, 'addEventBox' ) );
add_action( 'wp_insert_post', array( $this, 'addPostOrigin' ), 10, 2 );
add_action( 'save_post', array( $this, 'addEventMeta' ), 15, 2 );
/* Registers the list widget */
add_action( 'widgets_init', array( $this, 'register_list_widget' ), 90 );
add_action( 'save_post_' . self::VENUE_POST_TYPE, array( $this, 'save_venue_data' ), 16, 2 );
add_action( 'save_post_' . self::ORGANIZER_POST_TYPE, array( $this, 'save_organizer_data' ), 16, 2 );
add_action( 'save_post_' . self::POSTTYPE, array( $this, 'maybe_update_known_range' ) );
add_action( 'tribe_events_csv_import_complete', array( $this, 'rebuild_known_range' ) );
add_action( 'publish_' . self::POSTTYPE, array( $this, 'publishAssociatedTypes' ), 25, 2 );
add_action( 'delete_post', array( $this, 'maybe_rebuild_known_range' ) );
add_action( 'parse_query', array( $this, 'setDisplay' ), 51, 0 );
add_action( 'tribe_events_post_errors', array( 'Tribe__Events__Post_Exception', 'displayMessage' ) );
add_action( 'tribe_settings_top', array( 'Tribe__Events__Options_Exception', 'displayMessage' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_assets' ) );
add_filter( 'tribe_events_register_event_type_args', array( $this, 'setDashicon' ) );
add_action( 'trash_' . self::VENUE_POST_TYPE, array( $this, 'cleanupPostVenues' ) );
add_action( 'trash_' . self::ORGANIZER_POST_TYPE, array( $this, 'cleanupPostOrganizers' ) );
add_action( 'wp_ajax_tribe_event_validation', array( $this, 'ajax_form_validate' ) );
add_action( 'tribe_debug', array( $this, 'renderDebug' ), 10, 2 );
add_action( 'tribe_debug', array( $this, 'renderDebug' ), 10, 2 );
add_action( 'plugins_loaded', array( 'Tribe__Events__Cache_Listener', 'instance' ) );
add_action( 'plugins_loaded', array( 'Tribe__Events__Cache', 'setup' ) );
add_action( 'plugins_loaded', array( 'Tribe__Events__Support', 'getInstance' ) );
add_action( 'plugins_loaded', array( $this, 'set_meta_factory_global' ) );
add_action( 'plugins_loaded', array( 'Tribe__Events__App_Shop', 'instance' ) );
add_action( 'current_screen', array( $this, 'init_admin_list_screen' ) );
// Load organizer and venue editors
add_action( 'admin_menu', array( $this, 'addVenueAndOrganizerEditor' ) );
add_action( 'tribe_venue_table_top', array( $this, 'displayEventVenueDropdown' ) );
add_action( 'tribe_venue_table_top', array( $this, 'display_rich_snippets_helper' ), 5 );
add_action( 'template_redirect', array( $this, 'template_redirect' ) );
add_action( 'add_meta_boxes', array( 'Tribe__Events__Tickets__Metabox', 'maybe_add_meta_box' ) );
add_action( 'admin_enqueue_scripts', array( 'Tribe__Events__Tickets__Metabox', 'add_admin_scripts' ) );
// noindex grid view
add_action( 'wp_head', array( $this, 'noindex_months' ) );
add_action( 'wp', array( $this, 'issue_noindex_on_404' ), 10, 0 );
add_action( 'plugin_row_meta', array( $this, 'addMetaLinks' ), 10, 2 );
// organizer and venue
if ( ! defined( 'TRIBE_HIDE_UPSELL' ) || ! TRIBE_HIDE_UPSELL ) {
add_action( 'wp_dashboard_setup', array( $this, 'dashboardWidget' ) );
add_action( 'tribe_events_cost_table', array( $this, 'maybeShowMetaUpsell' ) );
}
// option pages
add_action( '_network_admin_menu', array( $this, 'initOptions' ) );
add_action( '_admin_menu', array( $this, 'initOptions' ) );
add_action( 'tribe_settings_do_tabs', array( $this, 'doSettingTabs' ) );
add_action( 'tribe_settings_do_tabs', array( $this, 'doNetworkSettingTab' ), 400 );
add_action( 'tribe_settings_content_tab_help', array( $this, 'doHelpTab' ) );
add_action( 'tribe_settings_validate_tab_network', array( $this, 'saveAllTabsHidden' ) );
add_action( 'load-tribe_events_page_tribe-events-calendar', array( 'Tribe__Events__Amalgamator', 'listen_for_migration_button' ), 10, 0 );
add_action( 'tribe_settings_after_save', array( $this, 'flushRewriteRules' ) );
add_action( 'load-edit-tags.php', array( $this, 'prepare_to_fix_tagcloud_links' ), 10, 0 );
add_action( 'update_option_' . self::OPTIONNAME, array( $this, 'fix_all_day_events' ), 10, 2 );
// Check for a page that might conflict with events archive
add_action( 'admin_init', array( Tribe__Events__Admin__Notice__Archive_Slug_Conflict::instance(), 'maybe_add_admin_notice' ) );
// add-on compatibility
if ( is_multisite() ) {
add_action( 'network_admin_notices', array( $this, 'checkAddOnCompatibility' ) );
} else {
add_action( 'admin_notices', array( $this, 'checkAddOnCompatibility' ) );
}
add_action( 'wp_before_admin_bar_render', array( $this, 'addToolbarItems' ), 10 );
add_action( 'all_admin_notices', array( $this, 'addViewCalendar' ) );
add_action( 'admin_head', array( $this, 'setInitialMenuMetaBoxes' ), 500 );
add_action( 'plugin_action_links_' . trailingslashit( $this->pluginDir ) . 'the-events-calendar.php', array( $this, 'addLinksToPluginActions' ) );
add_action( 'admin_menu', array( $this, 'addHelpAdminMenuItem' ), 50 );
// override default wp_terms_checklist arguments to prevent checked items from bubbling to the top. Instead, retain hierarchy.
add_filter( 'wp_terms_checklist_args', array( $this, 'prevent_checked_on_top_terms' ), 10, 2 );
add_action( 'tribe_events_pre_get_posts', array( $this, 'set_tribe_paged' ) );
// Upgrade material.
add_action( 'init', array( $this, 'run_updates' ), 0, 0 );
if ( defined( 'WP_LOAD_IMPORTERS' ) && WP_LOAD_IMPORTERS ) {
add_filter( 'wp_import_post_data_raw', array( $this, 'filter_wp_import_data_before' ), 10, 1 );
add_filter( 'wp_import_post_data_processed', array( $this, 'filter_wp_import_data_after' ), 10, 1 );
}
add_action( 'plugins_loaded', array( $this, 'init_ical' ), 2, 0 );
add_action( 'plugins_loaded', array( $this, 'init_day_view' ), 2 );
add_action( 'plugins_loaded', array( 'Tribe__Events__Bar', 'instance' ) );
add_action( 'plugins_loaded', array( 'Tribe__Events__Templates', 'init' ) );
add_action( 'init', array( $this, 'filter_cron_schedules' ) );
}
/**
* Load the ical template tags
* Loaded late due to potential upgrade conflict since moving them from pro
* @TODO move this require to be with the rest of the template tag includes in 3.9
*/
public function init_ical() {
//iCal
Tribe__Events__iCal::init();
require_once $this->pluginPath . 'src/functions/template-tags/ical.php';
}
/**
* Allow users to specify their own plural label for Venues
* @return string
*/
public function get_venue_label_plural() {
return apply_filters( 'tribe_venue_label_plural', __( 'Venues', 'tribe-events-calendar' ) );
}
/**
* Allow users to specify their own singular label for Venues
* @return string
*/
public function get_venue_label_singular() {
return apply_filters( 'tribe_venue_label_singular', __( 'Venue', 'tribe-events-calendar' ) );
}
/**
* Allow users to specify their own plural label for Organizers
* @return string
*/
public function get_organizer_label_plural() {
return apply_filters( 'tribe_organizer_label_plural', __( 'Organizers', 'tribe-events-calendar' ) );
}
/**
* Allow users to specify their own singular label for Organizers
* @return string
*/
public function get_organizer_label_singular() {
return apply_filters( 'tribe_organizer_label_singular', __( 'Organizer', 'tribe-events-calendar' ) );
}
/**
* Allow users to specify their own plural label for Events
* @return string
*/
public function get_event_label_plural() {
return apply_filters( 'tribe_event_label_plural', __( 'Events', 'tribe-events-calendar' ) );
}
/**
* Allow users to specify their own singular label for Events
* @return string
*/
public function get_event_label_singular() {
return apply_filters( 'tribe_event_label_singular', __( 'Event', 'tribe-events-calendar' ) );
}
/**
* Load the day view template tags
* Loaded late due to potential upgrade conflict since moving them from pro
* @TODO move this require to be with the rest of the template tag includes in 3.9
*/
public function init_day_view() {
// load day view functions
require_once $this->pluginPath . 'src/functions/template-tags/day.php';
}
/**
* Add code to tell search engines not to index the grid view of the
* calendar. Users were seeing 100s of months being indexed.
*/
public function noindex_months() {
if ( get_query_var( 'eventDisplay' ) == 'month' ) {
$this->print_noindex_meta();
}
}
public function issue_noindex_on_404() {
if ( is_404() ) {
global $wp_query;
if ( ! empty( $wp_query->tribe_is_event_query ) ) {
add_action( 'wp_head', array( $this, 'print_noindex_meta' ), 10, 0 );
}
}
}
public function print_noindex_meta() {
echo ' ' . "\n";
}
/**
* Run on applied action init
*/
public function init() {
$this->pluginName = __( 'The Events Calendar', 'tribe-events-calendar' );
$this->rewriteSlug = $this->getRewriteSlug();
$this->rewriteSlugSingular = $this->getRewriteSlugSingular();
$this->taxRewriteSlug = $this->getTaxRewriteSlug();
$this->tagRewriteSlug = $this->getTagRewriteSlug();
$this->monthSlug = sanitize_title( __( 'month', 'tribe-events-calendar' ) );
$this->listSlug = sanitize_title( __( 'list', 'tribe-events-calendar' ) );
$this->upcomingSlug = sanitize_title( __( 'upcoming', 'tribe-events-calendar' ) );
$this->pastSlug = sanitize_title( __( 'past', 'tribe-events-calendar' ) );
$this->daySlug = sanitize_title( __( 'day', 'tribe-events-calendar' ) );
$this->todaySlug = sanitize_title( __( 'today', 'tribe-events-calendar' ) );
$this->singular_venue_label = $this->get_venue_label_singular();
$this->plural_venue_label = $this->get_venue_label_plural();
$this->singular_organizer_label = $this->get_organizer_label_singular();
$this->plural_organizer_label = $this->get_organizer_label_plural();
$this->singular_event_label = $this->get_event_label_singular();
$this->plural_event_label = $this->get_event_label_plural();
$this->postTypeArgs['rewrite']['slug'] = sanitize_title( $this->rewriteSlugSingular );
$this->postVenueTypeArgs['rewrite']['slug'] = sanitize_title( $this->singular_venue_label );
$this->postVenueTypeArgs['show_in_nav_menus'] = class_exists( 'Tribe__Events__Pro__Main' ) ? true : false;
$this->postOrganizerTypeArgs['rewrite']['slug'] = sanitize_title( $this->singular_organizer_label );
$this->postOrganizerTypeArgs['show_in_nav_menus'] = class_exists( 'Tribe__Events__Pro__Main' ) ? true : false;
$this->postVenueTypeArgs['public'] = class_exists( 'Tribe__Events__Pro__Main' ) ? true : false;
$this->postOrganizerTypeArgs['public'] = class_exists( 'Tribe__Events__Pro__Main' ) ? true : false;
$this->currentDay = '';
$this->errors = '';
$this->default_values = apply_filters( 'tribe_events_default_value_strategy', new Tribe__Events__Default_Values() );
Tribe__Events__Query::init();
Tribe__Events__Backcompat::init();
Tribe__Events__Credits::init();
Tribe__Events__Timezones::init();
$this->registerPostType();
self::debug( sprintf( __( 'Initializing Tribe Events on %s', 'tribe-events-calendar' ), date( 'M, jS \a\t h:m:s a' ) ) );
$this->maybeSetTECVersion();
}
/**
* Initializes any admin-specific code (expects to be called when admin_init fires).
*/
public function admin_init() {
$this->timezone_settings = new Tribe__Events__Admin__Timezone_Settings;
}
/**
* Set the Calendar Version in the options table if it's not already set.
*
*/
public function maybeSetTECVersion() {
if ( version_compare( $this->getOption( 'latest_ecp_version' ), self::VERSION, '<' ) ) {
$previous_versions = $this->getOption( 'previous_ecp_versions' ) ? $this->getOption( 'previous_ecp_versions' ) : array();
$previous_versions[] = ( $this->getOption( 'latest_ecp_version' ) ) ? $this->getOption( 'latest_ecp_version' ) : '0';
$this->setOption( 'previous_ecp_versions', $previous_versions );
$this->setOption( 'latest_ecp_version', self::VERSION );
}
}
/**
* Check add-ons to make sure they are supported by currently running TEC version.
*
* @return void
*/
public function checkAddOnCompatibility() {
// Variable for storing output to admin notices.
$output = '';
// Array to store any plugins that are out of date.
$out_of_date_addons = array();
// Array to store all addons and their required CORE versions.
$tec_addons_required_versions = array();
// Is Core the thing that is out of date?
$tec_out_of_date = false;
// Get the addon information.
$tec_addons_required_versions = (array) apply_filters( 'tribe_tec_addons', $tec_addons_required_versions );
// Foreach addon, make sure that it is compatible with current version of core.
foreach ( $tec_addons_required_versions as $plugin ) {
// we're not going to check addons that we can't
if ( empty( $plugin['required_version'] ) || empty( $plugin['current_version'] ) ) {
continue;
}
// check if TEC is out of date
if ( version_compare( $plugin['required_version'], self::VERSION, '>' ) ) {
$tec_out_of_date = true;
break;
}
// check if the add-on is out of date
if ( version_compare( $plugin['current_version'], self::MIN_ADDON_VERSION, '<' ) ) {
$out_of_date_addons[] = $plugin['plugin_name'] . ' ' . $plugin['current_version'];
}
}
// If Core is out of date, generate the proper message.
if ( $tec_out_of_date == true ) {
$plugin_short_path = basename( dirname( dirname( __FILE__ ) ) ) . '/the-events-calendar.php';
$upgrade_path = wp_nonce_url(
add_query_arg(
array(
'action' => 'upgrade-plugin',
'plugin' => $plugin_short_path,
), get_admin_url() . 'update.php'
), 'upgrade-plugin_' . $plugin_short_path
);
$output .= '
';
$output .= '
' . sprintf( __( 'Your version of The Events Calendar is not up-to-date with one of your The Events Calendar add-ons. Please %supdate now.%s', 'tribe-events-calendar' ), '', '' ) . '
';
$output .= '
';
} elseif ( ! empty( $out_of_date_addons ) ) {
// Otherwise, if the addons are out of date, generate the proper messaging.
$output .= '
' . sprintf( __( 'The following plugins are out of date: %s. All add-ons contain dependencies on The Events Calendar and will not function properly unless paired with the right version. %sLearn More%s.', 'tribe-events-calendar' ), join( $out_of_date_addons, ', ' ), "", '' ) . '
';
$output .= '
';
}
// Make sure only to show the message if the user has the permissions necessary.
if ( current_user_can( 'edit_plugins' ) ) {
echo apply_filters( 'tribe_add_on_compatibility_errors', $output );
}
}
/**
* Init the settings API and add a hook to add your own setting tabs
*
* @return void
*/
public function initOptions() {
Tribe__Events__Settings::instance();
Tribe__Events__Activation_Page::init();
}
/**
* Trigger is_404 on single event if no events are found
* @return void
*/
public function template_redirect() {
global $wp_query;
// if JS is disabled, then we need to handle tribe bar submissions manually
if ( ! empty( $_POST['tribe-bar-view'] ) && ! empty( $_POST['submit-bar'] ) ) {
$this->handle_submit_bar_redirect( $_POST );
}
if ( $wp_query->tribe_is_event_query && self::instance()->displaying == 'single-event' && empty( $wp_query->posts ) ) {
$wp_query->is_404 = true;
}
}
/**
* handles tribe bar post submissions
*
* @param array $postdata Data from $_POST
*/
public function handle_submit_bar_redirect( $postdata ) {
$url = $postdata['tribe-bar-view'];
foreach ( $postdata as $key => $value ) {
if ( 'submit-bar' === $key || 'tribe-bar-view' === $key ) {
continue;
}
$url = add_query_arg( $key, $value, $url );
}
wp_redirect( esc_url_raw( $url ) );
die;
}//end handle_submit_bar_redirect
/**
* Create setting tabs
*
* @return void
*/
public function doSettingTabs() {
include_once( $this->pluginPath . 'src/admin-views/tribe-options-general.php' );
include_once( $this->pluginPath . 'src/admin-views/tribe-options-display.php' );
$showNetworkTabs = $this->getNetworkOption( 'showSettingsTabs', false );
new Tribe__Events__Settings_Tab( 'general', __( 'General', 'tribe-events-calendar' ), $generalTab );
new Tribe__Events__Settings_Tab( 'display', __( 'Display', 'tribe-events-calendar' ), $displayTab );
$this->do_licenses_tab();
new Tribe__Events__Settings_Tab( 'help', __( 'Help', 'tribe-events-calendar' ), array(
'priority' => 60,
'show_save' => false,
) );
}
/**
* Registers the license key management tab in the Events > Settings screen,
* only if premium addons are detected.
*/
protected function do_licenses_tab() {
$show_tab = ( current_user_can( 'update_plugins' ) && $this->have_addons() );
/**
* Provides an oppotunity to override the decision to show or hide the licenses tab
*
* Normally it will only show if the current user has the "update_plugins" capability
* and there are some currently-activated premium plugins.
*
* @var bool
*/
if ( ! apply_filters( 'tribe_events_show_licenses_tab', $show_tab ) ) {
return;
}
/**
* @var $licenses_tab
*/
include $this->pluginPath . 'src/admin-views/tribe-options-licenses.php';
/**
* Allows the fields displayed in the licenses tab to be modified.
*
* @var array
*/
$license_fields = apply_filters( 'tribe_license_fields', $licenses_tab );
new Tribe__Events__Settings_Tab( 'licenses', __( 'Licenses', 'tribe-events-calendar' ), array(
'priority' => '40',
'fields' => $license_fields,
'network_admin' => is_network_admin() ? true : false,
) );
}
/**
* Tries to discover if licensable addons are activated on the same site.
*
* @return bool
*/
protected function have_addons() {
$addons = apply_filters( 'tribe_licensable_addons', array() );
return ! empty( $addons );
}
/**
* Create the help tab
*/
public function doHelpTab() {
include_once( $this->pluginPath . 'src/admin-views/tribe-options-help.php' );
}
/**
* Updates the start/end time on all day events to match the EOD cutoff
*
* @see 'update_option_'.self::OPTIONNAME
*/
public function fix_all_day_events( $old_value, $new_value ) {
// avoid notices for missing indices
$default_value = '00:00';
if ( empty( $old_value['multiDayCutoff'] ) ) {
$old_value['multiDayCutoff'] = $default_value;
}
if ( empty( $new_value['multiDayCutoff'] ) ) {
$new_value['multiDayCutoff'] = $default_value;
}
if ( $old_value['multiDayCutoff'] == $new_value['multiDayCutoff'] ) {
// we only want to continue if the EOD cutoff was changed
return;
}
global $wpdb;
$event_start_time = $new_value['multiDayCutoff'] . ':00';
// mysql query to set the start times on all day events to the EOD cutoff
// this will fix all day events with any start time
$fix_start_dates = $wpdb->prepare( "UPDATE $wpdb->postmeta AS pm1
INNER JOIN $wpdb->postmeta pm2
ON (pm1.post_id = pm2.post_id AND pm2.meta_key = '_EventAllDay' AND pm2.`meta_value` = 'yes')
SET pm1.meta_value = CONCAT(DATE(pm1.meta_value), ' ', %s)
WHERE pm1.meta_key = '_EventStartDate'
AND DATE_FORMAT(pm1.meta_value, '%%H:%%i') <> %s", $event_start_time, $event_start_time );
// mysql query to set the end time to the start time plus the duration on every all day event
$fix_end_dates =
"UPDATE $wpdb->postmeta AS pm1
INNER JOIN $wpdb->postmeta pm2
ON (pm1.post_id = pm2.post_id AND pm2.meta_key = '_EventAllDay' AND pm2.meta_value = 'yes')
INNER JOIN $wpdb->postmeta pm3
ON (pm1.post_id = pm3.post_id AND pm3.meta_key = '_EventStartDate')
INNER JOIN $wpdb->postmeta pm4
ON (pm1.post_id = pm4.post_id AND pm4.meta_key = '_EventDuration')
SET pm1.meta_value = DATE_ADD(pm3.meta_value, INTERVAL pm4.meta_value SECOND )
WHERE pm1.meta_key = '_EventEndDate'";
$wpdb->query( $fix_start_dates );
$wpdb->query( $fix_end_dates );
}
/**
* Test PHP and WordPress versions for compatibility
*
* @param string $system - system to be tested such as 'php' or 'wordpress'
*
* @return boolean - is the existing version of the system supported?
*/
public function supportedVersion( $system ) {
if ( $supported = wp_cache_get( $system, 'tribe_version_test' ) ) {
return $supported;
} else {
switch ( strtolower( $system ) ) {
case 'wordpress' :
$supported = version_compare( get_bloginfo( 'version' ), '3.0', '>=' );
break;
case 'php' :
$supported = version_compare( phpversion(), '5.2', '>=' );
break;
}
$supported = apply_filters( 'tribe_events_supported_version', $supported, $system );
wp_cache_set( $system, $supported, 'tribe_version_test' );
return $supported;
}
}
/**
* Display a WordPress or PHP incompatibility error
*/
public function notSupportedError() {
if ( ! self::supportedVersion( 'wordpress' ) ) {
echo '
' . esc_html( sprintf( __( 'Sorry, The Events Calendar requires WordPress %s or higher. Please upgrade your WordPress install.', 'tribe-events-calendar' ), '3.0' ) ) . '
' . esc_html( sprintf( __( 'Sorry, The Events Calendar requires PHP %s or higher. Talk to your Web host about moving you to a newer version of PHP.', 'tribe-events-calendar' ), '5.2' ) ) . '
';
}
}
/**
* Add a menu item class to the event
*
* @param array $items
* @param array $args
*
* @return array
*/
public function add_current_menu_item_class_to_events( $items, $args ) {
foreach ( $items as $item ) {
if ( $item->url == $this->getLink() ) {
if ( is_singular( self::POSTTYPE )
|| is_singular( self::VENUE_POST_TYPE )
|| is_tax( self::TAXONOMY )
|| ( ( tribe_is_upcoming()
|| tribe_is_past()
|| tribe_is_month() )
&& isset( $wp_query->query_vars['eventDisplay'] ) )
) {
$item->classes[] = 'current-menu-item current_page_item';
}
break;
}
}
return $items;
}
/**
* Add a checkbox to the menu
*
* @param array $posts
* @param array $args
* @param string $post_type
*
* @return array
*/
public function add_events_checkbox_to_menu( $posts, $args, $post_type ) {
global $_nav_menu_placeholder, $wp_rewrite;
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : - 1;
$archive_slug = $this->getLink();
array_unshift(
$posts, (object) array(
'ID' => 0,
'object_id' => $_nav_menu_placeholder,
'post_content' => '',
'post_excerpt' => '',
'post_title' => $post_type['args']->labels->all_items,
'post_type' => 'nav_menu_item',
'type' => 'custom',
'url' => $archive_slug,
)
);
return $posts;
}
/**
* Tribe debug function. usage: self::debug( 'Message', $data, 'log' );
*
* @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 debug( $title, $data = false, $format = 'log' ) {
do_action( 'tribe_debug', $title, $data, $format );
}
/**
* 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 function renderDebug( $title, $data = false, $format = 'log' ) {
$format = ucfirst( $format );
if ( $this->getOption( 'debugEvents' ) ) {
error_log( $this->pluginName . " $format: $title" );
if ( $data && $data != '' ) {
error_log( $this->pluginName . " $format: " . print_r( $data, true ) );
}
}
}
/**
* Define an admin notice
*
* @param string $key
* @param string $notice
*
* @return bool
*/
public static function setNotice( $key, $notice ) {
self::instance()->notices[ $key ] = $notice;
return true;
}
/**
* Check to see if an admin notice exists
*
* @param string $key
*
* @return bool
*/
public static function isNotice( $key ) {
return ! empty( self::instance()->notices[ $key ] ) ? true : false;
}
/**
* Remove an admin notice
*
* @param string $key
*
* @return bool
*/
public static function removeNotice( $key ) {
if ( self::isNotice( $key ) ) {
unset( self::instance()->notices[ $key ] );
return true;
} else {
return false;
}
}
/**
* Get the admin notices
*
* @return array
*/
public static function getNotices() {
return self::instance()->notices;
}
/**
* Get the event taxonomy
*
* @return string
*/
public function get_event_taxonomy() {
return self::TAXONOMY;
}
/**
* Add space to the title in RSS
*
* @param string $title
*
* @return string
*/
public function add_space_to_rss( $title ) {
global $wp_query;
if ( get_query_var( 'eventDisplay' ) == 'upcoming' && get_query_var( 'post_type' ) == self::POSTTYPE ) {
return $title . ' ';
}
return $title;
}
/**
* Update body classes
*
* @param array $classes
*
* @return array
* @TODO move this to template class
*/
public function body_class( $classes ) {
if ( get_query_var( 'post_type' ) == self::POSTTYPE ) {
if ( ! is_admin() && tribe_get_option( 'liveFiltersUpdate', true ) ) {
$classes[] = 'tribe-filter-live';
}
}
return $classes;
}
/**
* Update post classes
*
* @param array $classes
*
* @return array
* @TODO move this to template class
*/
public function post_class( $classes ) {
global $post;
if ( is_object( $post ) && isset( $post->post_type ) && $post->post_type == self::POSTTYPE && $terms = get_the_terms( $post->ID, self::TAXONOMY ) ) {
foreach ( $terms as $term ) {
$classes[] = 'cat_' . sanitize_html_class( $term->slug, $term->term_taxonomy_id );
}
}
// Remove the .hentry class if it is a single event page (it is positioned elsewhere in the template markup)
if ( tribe_is_event( $post->ID ) && is_singular() && in_array( 'hentry', $classes ) ) {
unset( $classes[ array_search( 'hentry', $classes ) ] );
}
return $classes;
}
/**
* Register the post types.
*
* @return void
*/
public function registerPostType() {
$this->generatePostTypeLabels();
register_post_type( self::POSTTYPE, apply_filters( 'tribe_events_register_event_type_args', $this->postTypeArgs ) );
register_post_type( self::VENUE_POST_TYPE, apply_filters( 'tribe_events_register_venue_type_args', $this->postVenueTypeArgs ) );
register_post_type( self::ORGANIZER_POST_TYPE, apply_filters( 'tribe_events_register_organizer_type_args', $this->postOrganizerTypeArgs ) );
register_taxonomy(
self::TAXONOMY, self::POSTTYPE, array(
'hierarchical' => true,
'update_count_callback' => '',
'rewrite' => array(
'slug' => $this->taxRewriteSlug,
'with_front' => false,
'hierarchical' => true,
),
'public' => true,
'show_ui' => true,
'labels' => $this->taxonomyLabels,
'capabilities' => array(
'manage_terms' => 'publish_tribe_events',
'edit_terms' => 'publish_tribe_events',
'delete_terms' => 'publish_tribe_events',
'assign_terms' => 'edit_tribe_events',
)
)
);
if ( $this->getOption( 'showComments', 'no' ) == 'yes' ) {
add_post_type_support( self::POSTTYPE, 'comments' );
}
}
/**
* Get the rewrite slug
*
* @return string
*/
public function getRewriteSlug() {
return sanitize_title( $this->getOption( 'eventsSlug', 'events' ) );
}
/**
* Get the single post rewrite slug
*
* @return string
*/
public function getRewriteSlugSingular() {
return sanitize_title( $this->getOption( 'singleEventSlug', 'event' ) );
}
/**
* Get taxonomy rewrite slug
*
* @return mixed|void
*/
public function getTaxRewriteSlug() {
$slug = $this->getRewriteSlug() . '/' . sanitize_title( __( 'category', 'tribe-events-calendar' ) );
return apply_filters( 'tribe_events_category_rewrite_slug', $slug );
}
/**
* Get tag rewrite slug
*
* @return mixed|void
*/
public function getTagRewriteSlug() {
$slug = $this->getRewriteSlug() . '/' . sanitize_title( __( 'tag', 'tribe-events-calendar' ) );
return apply_filters( 'tribe_events_tag_rewrite_slug', $slug );
}
/**
* Get venue post type args
*
* @return array
*/
public function getVenuePostTypeArgs() {
return $this->postVenueTypeArgs;
}
/**
* Get organizer post type args
*
* @return array
*/
public function getOrganizerPostTypeArgs() {
return $this->postOrganizerTypeArgs;
}
/**
* Generate custom post type lables
*/
protected function generatePostTypeLabels() {
/**
* Provides an opportunity to modify the labels used for the event post type.
*
* @var array
*/
$this->postTypeArgs['labels'] = apply_filters( 'tribe_events_register_event_post_type_labels', array(
'name' => $this->plural_event_label,
'singular_name' => $this->singular_event_label,
'add_new' => __( 'Add New', 'tribe-events-calendar' ),
'add_new_item' => sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_event_label ),
'edit_item' => sprintf( __( 'Edit %s', 'tribe-events-calendar' ), $this->singular_event_label ),
'new_item' => sprintf( __( 'New %s', 'tribe-events-calendar' ), $this->singular_event_label ),
'view_item' => sprintf( __( 'View %s', 'tribe-events-calendar' ), $this->singular_event_label ),
'search_items' => sprintf( __( 'Search %s', 'tribe-events-calendar' ), $this->plural_event_label ),
'not_found' => sprintf( __( 'No %s found', 'tribe-events-calendar' ), strtolower( $this->plural_event_label ) ),
'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'tribe-events-calendar' ), strtolower( $this->plural_event_label ) ),
) );
/**
* Provides an opportunity to modify the labels used for the venue post type.
*
* @var array
*/
$this->postVenueTypeArgs['labels'] = apply_filters( 'tribe_events_register_venue_post_type_labels', array(
'name' => $this->plural_venue_label,
'singular_name' => $this->singular_venue_label,
'add_new' => __( 'Add New', 'tribe-events-calendar' ),
'add_new_item' => sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_venue_label ),
'edit_item' => sprintf( __( 'Edit %s', 'tribe-events-calendar' ), $this->singular_venue_label ),
'new_item' => sprintf( __( 'New %s', 'tribe-events-calendar' ), $this->singular_venue_label ),
'view_item' => sprintf( __( 'View %s', 'tribe-events-calendar' ), $this->singular_venue_label ),
'search_items' => sprintf( __( 'Search %s', 'tribe-events-calendar' ), $this->plural_venue_label ),
'not_found' => sprintf( __( 'No %s found', 'tribe-events-calendar' ), strtolower( $this->plural_venue_label ) ),
'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'tribe-events-calendar' ), strtolower( $this->plural_venue_label ) ),
) );
/**
* Provides an opportunity to modify the labels used for the organizer post type.
*
* @var array
*/
$this->postOrganizerTypeArgs['labels'] = apply_filters( 'tribe_events_register_organizer_post_type_labels', array(
'name' => $this->plural_organizer_label,
'singular_name' => $this->singular_organizer_label,
'add_new' => __( 'Add New', 'tribe-events-calendar' ),
'add_new_item' => sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_organizer_label ),
'edit_item' => sprintf( __( 'Edit %s', 'tribe-events-calendar' ), $this->singular_organizer_label ),
'new_item' => sprintf( __( 'New %s', 'tribe-events-calendar' ), $this->singular_organizer_label ),
'view_item' => sprintf( __( 'View %s', 'tribe-events-calendar' ), $this->singular_organizer_label ),
'search_items' => sprintf( __( 'Search %s', 'tribe-events-calendar' ), $this->plural_organizer_label ),
'not_found' => sprintf( __( 'No %s found', 'tribe-events-calendar' ), strtolower( $this->plural_organizer_label ) ),
'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'tribe-events-calendar' ), strtolower( $this->plural_organizer_label ) ),
) );
/**
* Provides an opportunity to modify the labels used for the event category taxonomy.
*
* @var array
*/
$this->taxonomyLabels = apply_filters( 'tribe_events_register_category_taxonomy_labels', array(
'name' => sprintf( __( '%s Categories', 'tribe-events-calendar' ), $this->singular_event_label ),
'singular_name' => sprintf( __( '%s Category', 'tribe-events-calendar' ), $this->singular_event_label ),
'search_items' => sprintf( __( 'Search %s Categories', 'tribe-events-calendar' ), $this->singular_event_label ),
'all_items' => sprintf( __( 'All %s Categories', 'tribe-events-calendar' ), $this->singular_event_label ),
'parent_item' => sprintf( __( 'Parent %s Category', 'tribe-events-calendar' ), $this->singular_event_label ),
'parent_item_colon' => sprintf( __( 'Parent %s Category:', 'tribe-events-calendar' ), $this->singular_event_label ),
'edit_item' => sprintf( __( 'Edit %s Category', 'tribe-events-calendar' ), $this->singular_event_label ),
'update_item' => sprintf( __( 'Update %s Category', 'tribe-events-calendar' ), $this->singular_event_label ),
'add_new_item' => sprintf( __( 'Add New %s Category', 'tribe-events-calendar' ), $this->singular_event_label ),
'new_item_name' => sprintf( __( 'New %s Category Name', 'tribe-events-calendar' ), $this->singular_event_label ),
) );
}
/**
* Update custom post type messages
*
* @param $messages
*
* @return mixed
*/
public function updatePostMessage( $messages ) {
global $post, $post_ID;
$messages[ self::POSTTYPE ] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( '%1$s updated. View %3$s', 'tribe-events-calendar' ), $this->singular_event_label, esc_url( get_permalink( $post_ID ) ), strtolower( $this->singular_event_label ) ),
2 => __( 'Custom field updated.', 'tribe-events-calendar' ),
3 => __( 'Custom field deleted.', 'tribe-events-calendar' ),
4 => sprintf( __( '%s updated.', 'tribe-events-calendar' ), $this->singular_event_label ),
/* translators: %s: date and time of the revision */
5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s', 'tribe-events-calendar' ), $this->singular_event_label, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf(
__( 'Event published. View %2$s', 'tribe-events-calendar' ),
esc_url( get_permalink( $post_ID ) ),
strtolower( $this->singular_event_label )
),
7 => sprintf( __( '%s saved.', 'tribe-events-calendar' ), $this->singular_event_label ),
8 => sprintf(
__( '%1$s submitted. Preview %3$s', 'tribe-events-calendar' ),
$this->singular_event_label,
esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ),
strtolower( $this->singular_event_label )
),
9 => sprintf(
__( '%1$s scheduled for: %2$s. Preview %4$s', 'tribe-events-calendar' ),
$this->singular_event_label,
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i', 'tribe-events-calendar' ), strtotime( $post->post_date ) ),
esc_url( get_permalink( $post_ID ) ),
strtolower( $this->singular_event_label )
),
10 => sprintf(
__( '%1$s draft updated. Preview %3$s', 'tribe-events-calendar' ),
$this->singular_event_label,
esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ),
strtolower( $this->singular_event_label )
),
);
$messages[ self::VENUE_POST_TYPE ] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( '%s updated.', 'tribe-events-calendar' ), $this->singular_venue_label ),
2 => __( 'Custom field updated.', 'tribe-events-calendar' ),
3 => __( 'Custom field deleted.', 'tribe-events-calendar' ),
4 => sprintf( __( '%s updated.', 'tribe-events-calendar' ), $this->singular_venue_label ),
/* translators: %s: date and time of the revision */
5 => isset( $_GET['revision'] ) ? sprintf( __( '%s restored to revision from %s', 'tribe-events-calendar' ), $this->singular_venue_label, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( '%s published.', 'tribe-events-calendar' ), $this->singular_venue_label ),
7 => sprintf( __( '%s saved.', 'tribe-events-calendar' ), $this->singular_venue_label ),
8 => sprintf( __( '%s submitted.', 'tribe-events-calendar' ), $this->singular_venue_label ),
9 => sprintf(
__( '%s scheduled for: %2$s.', 'tribe-events-calendar' ), $this->singular_venue_label,
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i', 'tribe-events-calendar' ), strtotime( $post->post_date ) )
),
10 => sprintf( __( '%s draft updated.', 'tribe-events-calendar' ), $this->singular_venue_label ),
);
$messages[ self::ORGANIZER_POST_TYPE ] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __( '%s updated.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
2 => __( 'Custom field updated.', 'tribe-events-calendar' ),
3 => __( 'Custom field deleted.', 'tribe-events-calendar' ),
4 => sprintf( __( '%s updated.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
/* translators: %s: date and time of the revision */
5 => isset( $_GET['revision'] ) ? sprintf( __( '%s restored to revision from %s', 'tribe-events-calendar' ), $this->singular_organizer_label, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __( '%s published.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
7 => sprintf( __( '%s saved.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
8 => sprintf( __( '%s submitted.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
9 => sprintf(
__( '%s scheduled for: %2$s.', 'tribe-events-calendar' ), $this->singular_organizer_label,
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i', 'tribe-events-calendar' ), strtotime( $post->post_date ) )
),
10 => sprintf( __( '%s draft updated.', 'tribe-events-calendar' ), $this->singular_organizer_label ),
);
return $messages;
}
/**
* Adds the submenu items for editing the Venues and Organizers.
* Used to be a PRO only feature, but as of 3.0, it is part of Core.
*
*
* @return void
*/
public function addVenueAndOrganizerEditor() {
add_submenu_page( 'edit.php?post_type=' . self::POSTTYPE, __( $this->plural_venue_label, 'tribe-events-calendar' ), __( $this->plural_venue_label, 'tribe-events-calendar' ), 'edit_tribe_venues', 'edit.php?post_type=' . self::VENUE_POST_TYPE );
add_submenu_page( 'edit.php?post_type=' . self::POSTTYPE, __( $this->plural_organizer_label, 'tribe-events-calendar' ), __( $this->plural_organizer_label, 'tribe-events-calendar' ), 'edit_tribe_organizers', 'edit.php?post_type=' . self::ORGANIZER_POST_TYPE );
add_submenu_page( 'edit.php?post_type=' . self::VENUE_POST_TYPE, sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_venue_label ), sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_venue_label ), 'edit_tribe_venues', 'post-new.php?post_type=' . self::VENUE_POST_TYPE );
add_submenu_page( 'edit.php?post_type=' . self::ORGANIZER_POST_TYPE, sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_organizer_label ), sprintf( __( 'Add New %s', 'tribe-events-calendar' ), $this->singular_organizer_label ), 'edit_tribe_organizers', 'post-new.php?post_type=' . self::ORGANIZER_POST_TYPE );
}
/**
* displays the saved venue dropdown in the event metabox
* Used to be a PRO only feature, but as of 3.0, it is part of Core.
*
* @param int $postId the event ID for which to create the dropdown
*/
public function displayEventVenueDropdown( $postId ) {
$VenueID = get_post_meta( $postId, '_EventVenueID', true );
if ( ( ! $postId || get_post_status( $postId ) == 'auto-draft' ) && ! $VenueID && ( ( is_admin() && get_current_screen()->action == 'add' ) || ! is_admin() ) ) {
$VenueID = $this->defaults()->venue_id();
}
$VenueID = apply_filters( 'tribe_display_event_venue_dropdown_id', $VenueID );
?>
';
}
/**
* Set the class property postExceptionThrown.
*
* return void
*/
public function setPostExceptionThrown( $thrown ) {
$this->postExceptionThrown = $thrown;
}
/**
* Get the thrown post exception.
*
* @return mixed
*/
public function getPostExceptionThrown() {
return $this->postExceptionThrown;
}
/**
* Echoes upsell stuff, if it should.
*
* @param int $postId
*
* @return void
*/
public function maybeShowMetaUpsell( $postId ) {
?>