Custom post type
-
Hi,
Your plugin is great! Please continue to develop this awesome plugin.I have some problems trying to display only one category from my custom-post-type. My case –> Post type: Events, Category: Featured.
I was able to set it up to show only my events, but not only the featured ones.
Can you advice me how to address this?
-
Do your post type(Events) has support for category ? If has then you can easily select it from category drop-drown under Query section of each template. Remember there is no support for custom taxonomy in current version.
Thanx! I have custom taxonomy ??
Support for custom taxonomy will be added soon.
Hi Dionto,
I love your plugin, so simple and effective:) Do you have any idea when you will add custom taxonomy?
Hi Digonto
i have the same need about display events
i think this is the main code of the plugin
<?php /** * Central Tribe Events Calendar class. */ // Don't load directly if ( !defined('ABSPATH') ) { die('-1'); } if ( !class_exists( 'TribeEvents' ) ) { /** * The Events Calendar Class * * This is where all the magic happens, the unicorns run wild and the leprechauns use WordPress to schedule events. */ class TribeEvents { const EVENTSERROROPT = '_tribe_events_errors'; const OPTIONNAME = 'tribe_events_calendar_options'; const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options'; const TAXONOMY = 'tribe_events_cat'; const POSTTYPE = 'tribe_events'; const VENUE_POST_TYPE = 'tribe_venue'; const ORGANIZER_POST_TYPE = 'tribe_organizer'; const VERSION = '3.7'; const FEED_URL = 'https://tri.be/category/products/feed/'; const INFO_API_URL = 'https://wpapi.org/api/plugin/the-events-calendar.php'; const WP_PLUGIN_URL = 'https://www.ads-software.com/extend/plugins/the-events-calendar/'; /** * Notices to be displayed in the admin * @var array */ protected $notices = array(); /** * Maybe display data wrapper * @var array */ private $show_data_wrapper = array( 'before' => 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 ); /** * 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 = 'https://tri.be/'; public static $addOnPath = 'products/'; public static $dotOrgSupportUrl = 'https://www.ads-software.com/tags/the-events-calendar'; protected static $instance; public $rewriteSlug = 'events'; public $rewriteSlugSingular = 'event'; public $taxRewriteSlug = 'event/category'; public $tagRewriteSlug = 'event/tag'; protected $monthSlug = 'month'; protected $pastSlug = 'past'; protected $upcomingSlug = 'upcoming'; public $daySlug = 'day'; public $todaySlug = 'today'; protected $postExceptionThrown = false; protected static $options; protected static $networkOptions; public $displaying; public $pluginDir; public $pluginPath; public $pluginUrl; public $pluginName; public $date; protected $tabIndexStart = 2000; public $metaTags = array( '_EventAllDay', '_EventStartDate', '_EventEndDate', '_EventDuration', '_EventVenueID', '_EventShowMapLink', '_EventShowMap', '_EventCurrencySymbol', '_EventCurrencyPosition', '_EventCost', '_EventURL', '_EventOrganizerID', '_EventPhone', '_EventHideFromUpcoming', 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 static $tribeEventsMuDefaults; /** * Static Singleton Factory Method * @return TribeEvents */ 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(__FILE__) ) ); $this->pluginDir = trailingslashit( basename( $this->pluginPath ) ); $this->pluginUrl = plugins_url().'/'.$this->pluginDir; add_action( 'init', array( $this, 'loadTextDomain' ), 1 ); if (self::supportedVersion('wordpress') && self::supportedVersion('php')) { if ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) { register_deactivation_hook( __FILE__, array( $this, 'on_deactivate' ) ); } $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() { // Exceptions Helper require_once 'tribe-event-exception.class.php'; // Tribe common resources require_once $this->pluginPath . 'vendor/tribe-common-libraries/tribe-common-libraries.class.php'; // Load Template Tags require_once $this->pluginPath.'public/template-tags/query.php'; require_once $this->pluginPath.'public/template-tags/general.php'; require_once $this->pluginPath.'public/template-tags/month.php'; require_once $this->pluginPath.'public/template-tags/loop.php'; require_once $this->pluginPath.'public/template-tags/google-map.php'; require_once $this->pluginPath.'public/template-tags/organizer.php'; require_once $this->pluginPath.'public/template-tags/venue.php'; require_once $this->pluginPath.'public/template-tags/date.php'; require_once $this->pluginPath.'public/template-tags/link.php'; require_once $this->pluginPath.'public/template-tags/widgets.php'; require_once $this->pluginPath.'public/template-tags/meta.php'; // Load Advanced Functions require_once $this->pluginPath.'public/advanced-functions/event.php'; require_once $this->pluginPath.'public/advanced-functions/venue.php'; require_once $this->pluginPath.'public/advanced-functions/organizer.php'; // Load Deprecated Template Tags if ( ! defined( 'TRIBE_DISABLE_DEPRECATED_TAGS' ) ) { require_once $this->pluginPath.'public/template-tags/deprecated.php'; } // Load Classes require_once 'tribe-meta-factory.class.php'; require_once 'widget-list.class.php'; require_once 'tribe-admin-events-list.class.php'; require_once 'tribe-date-utils.class.php'; require_once 'tribe-template-factory.class.php'; require_once 'tribe-templates.class.php'; require_once 'tribe-event-api.class.php'; require_once 'tribe-event-query.class.php'; require_once 'tribe-view-helpers.class.php'; require_once 'tribe-events-bar.class.php'; require_once 'tribe-the-events-calendar-import.class.php'; require_once 'tribe-support.class.php'; require_once 'tribe-amalgamator.php'; require_once 'tribe-events-update.class.php'; // Load Template Classes require_once 'template-classes/month.php'; require_once 'template-classes/list.php'; require_once 'template-classes/day.php'; require_once 'template-classes/single-event.php'; // caching require_once 'tribe-events-cache.class.php'; // App Shop if ( ! defined( 'TRIBE_HIDE_UPSELL' ) || TRIBE_HIDE_UPSELL !== true ) require_once 'tribe-app-shop.class.php'; // Tickets require_once 'tickets/tribe-tickets-pro.php'; require_once 'tickets/tribe-ticket-object.php'; require_once 'tickets/tribe-tickets.php'; require_once 'tickets/tribe-tickets-metabox.php'; // CSV Importer require_once 'io/csv/ecp-events-importer.php'; // PUE require_once 'pue/pue-client.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 */ function before_html_data_wrapper( $html ){ global $wp_query; if( !$this->show_data_wrapper['before'] ) return $html; $tec = TribeEvents::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( '<div id="tribe-events" class="tribe-no-js" %s>%s', implode(' ', $attribute_html ), $html ), $data_attributes, $html ); } /** * after_html_data_wrapper close out the persistant dom wrapper * @param string $html * @return string */ function after_html_data_wrapper( $html ){ if( !$this->show_data_wrapper['after'] ) return $html; $html .= '</div><!-- #tribe-events -->'; $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() { add_action( 'init', array( $this, 'init'), 10 ); // 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( 'query_vars', array( $this, 'eventQueryVars' ) ); add_filter( 'wp_title', array($this, 'maybeAddEventTitle' ), 10, 2 ); add_filter( 'bloginfo_rss', array($this, 'add_space_to_rss' ) ); add_filter( 'post_updated_messages', array($this, 'updatePostMessage') ); /* Add nav menu item - thanks to https://www.ads-software.com/extend/plugins/cpt-archives-in-nav-menus/ */ add_filter( 'nav_menu_items_' . TribeEvents::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( 'generate_rewrite_rules', array( $this, 'filterRewriteRules' ) ); /* 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_filter( 'tribe_get_day_link', array( $this, 'add_empty_date_dayview_link' ), 10, 2 ); add_filter( 'admin_footer_text', array( $this, 'tribe_admin_footer_text' ), 1, 2 ); add_action( 'admin_menu', array( $this, 'addEventBox' ) ); add_action( 'wp_insert_post', array( $this, 'addPostOrigin' ), 10, 2 ); add_action( 'save_post_'.self::POSTTYPE, array( $this, 'addEventMeta' ), 15, 2 ); 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', array( $this, 'addToPostAuditTrail' ), 10, 2 ); add_action( 'save_post', array( $this, 'update_earliest_latest' ), 20 ); add_action( 'tribe_events_csv_import_complete', array( $this, 'rebuild_earliest_latest' ) ); add_action( 'publish_'.self::POSTTYPE, array( $this, 'publishAssociatedTypes'), 25, 2 ); add_action( 'delete_post', array( $this, 'maybe_rebuild_earliest_latest' ) ); add_action( 'parse_query', array( $this, 'setDisplay' ), 51, 0); add_action( 'tribe_events_post_errors', array( 'TribeEventsPostException', 'displayMessage' ) ); add_action( 'tribe_settings_top', array( 'TribeEventsOptionsException', 'displayMessage') ); add_action( 'admin_enqueue_scripts', array( $this, 'addAdminScriptsAndStyles' ) ); add_filter( 'tribe_events_register_event_type_args', array( $this, 'setDashicon' ) ); add_action( "trash_" . TribeEvents::VENUE_POST_TYPE, array($this, 'cleanupPostVenues')); add_action( "trash_" . TribeEvents::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('TribeEventsCacheListener', 'instance') ); add_action( 'plugins_loaded', array('TribeEventsCache', 'setup') ); // Load organizer and venue editors add_action( 'admin_menu', array( $this, 'addVenueAndOrganizerEditor' ) ); add_action( 'tribe_venue_table_top', array( $this, 'displayEventVenueDropdown' ) ); add_action( 'tribe_organizer_table_top', array( $this, 'displayEventOrganizerDropdown' ) ); add_action( 'template_redirect', array( $this, 'template_redirect') ); if( defined('TRIBE_SHOW_EVENT_AUDITING') && TRIBE_SHOW_EVENT_AUDITING ) add_action('tribe_events_details_bottom', array($this,'showAuditingData') ); // 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_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-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( 'admin_notices', array( $this, 'activationMessage' ) ); 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 ); /* VIEWS AJAX CALLS */ add_action( 'wp_ajax_tribe_calendar', array( $this, 'calendar_ajax_call' ) ); add_action( 'wp_ajax_nopriv_tribe_calendar', array( $this, 'calendar_ajax_call' ) ); add_action( 'wp_ajax_tribe_list', array( $this, 'list_ajax_call' ) ); add_action( 'tribe_events_pre_get_posts', array( $this, 'set_tribe_paged' ) ); add_action( 'wp_ajax_nopriv_tribe_list', array( $this, 'list_ajax_call' ) ); add_action( 'wp_ajax_tribe_event_day', array( $this, 'wp_ajax_tribe_event_day' ) ); add_action( 'wp_ajax_nopriv_tribe_event_day', array( $this, 'wp_ajax_tribe_event_day' ) ); // Upgrade material. add_action( 'admin_init', array( $this, 'checkSuiteIfJustUpdated' ) ); // backwards compatibility add_filter( 'tribe_get_single_option', array( $this, 'filter_multiday_cutoff' ), 10, 3 ); 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 ); } public function tribe_admin_footer_text( $footer_text ) { global $current_screen; // only display custom text on Tribe Admin Pages if ( isset($current_screen->id) && strpos( $current_screen->id, 'tribe' ) !== false ) { return sprintf( __( 'Rate <strong>The Events Calendar</strong> <a href="%1$s" target="_blank">★★★★★</a> on <a href="%1$s" target="_blank">www.ads-software.com</a> to keep this plugin free. Thanks from the friendly folks at Modern Tribe.' ), __( 'https://www.ads-software.com/support/view/plugin-reviews/the-events-calendar?filter=5' ) ); } else { return $footer_text; } } public function init_ical() { //iCal if ( !class_exists('TribeiCal' ) ) { require_once 'tribe-ical.class.php' ; TribeiCal::init(); require_once $this->pluginPath.'public/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' ) ); } /** * 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.8 */ public function init_day_view() { // load day view functions require_once $this->pluginPath . 'public/template-tags/day.php'; } /** * Enqueue ajax handling for calendar grid view */ function enqueue_for_ajax_calendar() { if ( $this->displaying === 'month' ) { Tribe_Template_Factory::asset_package( 'ajax-calendar' ); } } /** * 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 ' <meta name="robots" content="noindex,follow" />'."\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->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->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( 'TribeEventsPro' ) ? true : false; $this->postOrganizerTypeArgs['rewrite']['slug'] = sanitize_title( $this->singular_organizer_label ); $this->postOrganizerTypeArgs['show_in_nav_menus'] = class_exists( 'TribeEventsPro' ) ? true : false; $this->postVenueTypeArgs['public'] = class_exists( 'TribeEventsPro' ) ? true : false; $this->postOrganizerTypeArgs['public'] = class_exists( 'TribeEventsPro' ) ? true : false; $this->currentDay = ''; $this->errors = ''; TribeEventsQuery::init(); $this->registerPostType(); self::debug(sprintf(__('Initializing Tribe Events on %s','tribe-events-calendar'),date('M, jS \a\t h:m:s a'))); $this->maybeMigrateDatabase(); $this->maybeSetTECVersion(); } /** * Upgrade the database if an older version of events was installed. * */ public function maybeMigrateDatabase( ) { // future migrations should actually check the db_version $installed_version = get_option('tribe_events_db_version'); if( !$installed_version ) { global $wpdb; // rename option update_option(self::OPTIONNAME, get_option('sp_events_calendar_options')); delete_option('sp_events_calendar_options'); // update post type names $wpdb->update($wpdb->posts, array( 'post_type' => self::POSTTYPE ), array( 'post_type' => 'sp_events') ); $wpdb->update($wpdb->posts, array( 'post_type' => self::VENUE_POST_TYPE ), array( 'post_type' => 'sp_venue') ); $wpdb->update($wpdb->posts, array( 'post_type' => self::ORGANIZER_POST_TYPE ), array( 'post_type' => 'sp_organizer') ); // update taxonomy names $wpdb->update($wpdb->term_taxonomy, array( 'taxonomy' => self::TAXONOMY ), array( 'taxonomy' => 'sp_events_cat') ); $installed_version = '2.0.1'; update_option('tribe_events_db_version', $installed_version); } if ( version_compare( $installed_version, '2.0.6', '<' ) ) { $option_names = array( 'spEventsTemplate' => 'tribeEventsTemplate', 'spEventsBeforeHTML' => 'tribeEventsBeforeHTML', 'spEventsAfterHTML' => 'tribeEventsAfterHTML', ); $old_option_names = array_keys( $option_names ); $new_option_names = array_values( $option_names ); $new_options = array(); $current_options = self::getOptions(); for ( $i = 0; $i < count( $old_option_names ); $i++ ) { $new_options[$new_option_names[$i]] = $this->getOption( $old_option_names[$i] ); unset( $current_options[$old_option_names[$i]] ); } $this->setOptions( wp_parse_args( $new_options, $current_options ) ); $installed_version = '2.0.6'; update_option('tribe_events_db_version', $installed_version); } if ( version_compare( get_option('tribe_events_db_version'), '3', '<' ) ) { $installed_version = '3.0.0'; update_option('tribe_events_db_version', $installed_version); } } /** * 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. $bad_versions = array(); // Array to store all addons and their required CORE versions. $tec_addons_required_versions = array(); // Array to store NAMES ONLY of any plugins that are out of date. $out_of_date_addons = 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) { if ( !strstr( self::VERSION, $plugin['required_version'] ) ) { if ( isset( $plugin['current_version'] ) ) $bad_versions[] = $plugin; if ( ( isset( $plugin['plugin_dir_file'] ) ) ) $addon_short_path = $plugin['plugin_dir_file']; else $addon_short_path = null; } // Check to make sure Core isn't the thing that is out of date. if ( version_compare( $plugin['required_version'], self::VERSION, '>' ) ) { $tec_out_of_date = true; } } // 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 .= '<div class="error">'; $output .= '<p>' . 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'), '<a href="' . $upgrade_path . '">', '</a>') .'</p>'; $output .= '</div>'; } else { // Otherwise, if the addons are out of date, generate the proper messaging. if ( !empty($bad_versions) ) { foreach ($bad_versions as $plugin) { if ( $plugin['current_version'] ) $out_of_date_addons[] = $plugin['plugin_name'] . ' ' . $plugin['current_version']; else $out_of_date_addons[] = $plugin['plugin_name']; } $output .= '<div class="error">'; $link = add_query_arg( array( 'utm_campaign' => 'in-app', 'utm_medium' => 'plugin-tec', 'utm_source' => 'notice' ), self::$tribeUrl . 'version-relationships-in-modern-tribe-pluginsadd-ons/' ); $output .= '<p>'.sprintf( __('The following plugins are out of date: <b>%s</b>. All add-ons contain dependencies on The Events Calendar and will not function properly unless paired with the right version. %sWant to pair an older version%s?', 'tribe-events-calendar'), join( $out_of_date_addons, ', ' ), "<a href='$link' target='_blank'>", '</a>' ).'</p>'; $output .= '</div>'; } } // 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() { require_once( 'tribe-settings.class.php' ); require_once( 'tribe-settings-tab.class.php' ); require_once( 'tribe-field.class.php' ); require_once( 'tribe-validate.class.php' ); TribeSettings::instance(); } /** * Trigger is_404 on single event if no events are found * @return void */ function template_redirect(){ global $wp_query; if ( $wp_query->tribe_is_event_query && TribeEvents::instance()->displaying == 'single-event' && empty( $wp_query->posts ) ) { $wp_query->is_404 = true; } } /** * Create setting tabs * * @return void */ public function doSettingTabs() { include_once($this->pluginPath.'admin-views/tribe-options-general.php'); include_once($this->pluginPath.'admin-views/tribe-options-display.php'); $showNetworkTabs = $this->getNetworkOption( 'showSettingsTabs', false ); $link = add_query_arg( array( 'utm_campaign' => 'in-app', 'utm_medium' => 'plugin-tec', 'utm_source' => 'notice' ), self::$tribeUrl . 'license-keys/' ); $tribe_licences_tab_fields = array( 'info-start' => array( 'type' => 'html', 'html' => '<div id="modern-tribe-info">' ), 'info-box-title' => array( 'type' => 'html', 'html' => '<h2>' . __('Licenses', 'tribe-events-calendar') . '</h2>', ), 'info-box-description' => array( 'type' => 'html', 'html' => sprintf( __('<p>The license key you received when completing your purchase from %s will grant you access to support and updates until it expires. You do not need to enter the key below for the plugins to work, but you will need to enter it to get automatic updates. <strong>Find your license keys at <a href="%s" target="_blank">%s</a></strong>.</p> <p>Each paid add-on has its own unique license key. Simply paste the key into its appropriate field on below, and give it a moment to validate. You know you\'re set when a green expiration date appears alongside a "valid" message.</p> <p>If you\'re seeing a red message telling you that your key isn\'t valid or is out of installs, visit <a href="%s" target="_blank">%s</a> to manage your installs or renew / upgrade your license.</p><p>Not seeing an update but expecting one? In WordPress, go to <a href="%s">Dashboard > Updates</a> and click "Check Again".</p>', 'tribe-events-calendar'), self::$tribeUrl, $link, self::$tribeUrl . 'license-keys/', $link, self::$tribeUrl . 'license-keys/', admin_url('/update-core.php') ), ), 'info-end' => array( 'type' => 'html', 'html' => '</div>' ), 'tribe-form-content-start' => array( 'type' => 'html', 'html' => '<div class="tribe-settings-form-wrap">' ), // TODO: Figure out how properly close this wrapper after the license content 'tribe-form-content-end' => array( 'type' => 'html', 'html' => '</div>' ) ); new TribeSettingsTab( 'general', __('General', 'tribe-events-calendar'), $generalTab ); new TribeSettingsTab( 'display', __('Display', 'tribe-events-calendar'), $displayTab ); // If none of the addons are activated, do not show the licenses tab. $addons = apply_filters( 'tribe_licensable_addons', array() ); if ( !empty($addons) ) { $license_fields = apply_filters( 'tribe_license_fields', $tribe_licences_tab_fields ); if ( is_multisite() ) { new TribeSettingsTab( 'licenses', __('Licenses', 'tribe-events-calendar'), array('priority' => '40', 'network_admin' => true, 'fields' => $license_fields ) ); } else { new TribeSettingsTab( 'licenses', __('Licenses', 'tribe-events-calendar'), array('priority' => '40', 'fields' => $license_fields ) ); } } new TribeSettingsTab( 'help', __('Help', 'tribe-events-calendar'), array('priority' => 60, 'show_save' => false) ); } /** * Create the help tab */ public function doHelpTab() { include_once($this->pluginPath.'admin-views/tribe-options-help.php'); } /** * 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 '<div class="error"><p>'.sprintf(__('Sorry, The Events Calendar requires WordPress %s or higher. Please upgrade your WordPress install.', 'tribe-events-calendar'),'3.0').'</p></div>'; } if ( !self::supportedVersion('php') ) { echo '<div class="error"><p>'.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').'</p></div>'; } } /** * 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( TribeEvents::POSTTYPE ) || is_singular( TribeEvents::VENUE_POST_TYPE ) || is_tax(TribeEvents::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: TribeEvents::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') == TribeEvents::POSTTYPE) { return $title . ' '; } return $title; } /** * Sorts the meta to ensure we are getting the real start date * @deprecated since 3.4 * @param int $postId * @return string */ public static function getRealStartDate( $postId ) { return TribeEvents::get_series_start_date($postId); } /** * Add event title where appropriate * * @param string $title * @param string|null $sep * @return mixed|void */ public function maybeAddEventTitle( $title, $sep = null ){ switch( get_query_var('eventDisplay') ) { case 'upcoming': $new_title = apply_filters( 'tribe_upcoming_events_title', __("Upcoming Events", 'tribe-events-calendar') . ' ' . $sep . ' ' . $title, $sep ); break; case 'past': $new_title = apply_filters( 'tribe_past_events_title', __("Past Events", 'tribe-events-calendar') . ' ' . $sep . ' ' . $title, $sep ); break; case 'month': if(get_query_var('eventDate')){ $title_date = date_i18n(tribe_get_option('monthAndYearFormat', 'F Y') ,strtotime(get_query_var('eventDate'))); $new_title = apply_filters( 'tribe_month_grid_view_title', sprintf(__("Events for %s", 'tribe-events-calendar'), $title_date ) . ' ' . $sep . ' ' . $title, $sep, $title_date ); }else{ $new_title = apply_filters( 'tribe_events_this_month_title', sprintf(__("Events this month", 'tribe-events-calendar'), get_query_var('eventDate') ) . ' ' . $sep . ' ' . $title, $sep ); } break; case 'day': $title_date = date_i18n(tribe_get_date_format(true),strtotime(get_query_var('eventDate'))); $new_title = apply_filters( 'tribe_events_day_view_title', sprintf(__("Events for %s", 'tribe-events-calendar'), $title_date) . ' ' . $sep . ' ', $sep, $title_date ); break; default: $new_title = $title; break; } return apply_filters( 'tribe_events_add_title', $new_title, $title, $sep ); } /** * 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; } /** * Add capabilities to Events * * @return void */ private function addCapabilities() { $role = get_role( 'administrator' ); if ( $role ) { $role->add_cap( 'edit_tribe_event' ); $role->add_cap( 'read_tribe_event' ); $role->add_cap( 'delete_tribe_event' ); $role->add_cap( 'delete_tribe_events'); $role->add_cap( 'edit_tribe_events' ); $role->add_cap( 'edit_others_tribe_events' ); $role->add_cap( 'delete_others_tribe_events' ); $role->add_cap( 'publish_tribe_events' ); $role->add_cap( 'edit_published_tribe_events' ); $role->add_cap( 'delete_published_tribe_events' ); $role->add_cap( 'delete_private_tribe_events' ); $role->add_cap( 'edit_private_tribe_events' ); $role->add_cap( 'read_private_tribe_events' ); $role->add_cap( 'edit_tribe_venue' ); $role->add_cap( 'read_tribe_venue' ); $role->add_cap( 'delete_tribe_venue' ); $role->add_cap( 'delete_tribe_venues'); $role->add_cap( 'edit_tribe_venues' ); $role->add_cap( 'edit_others_tribe_venues' ); $role->add_cap( 'delete_others_tribe_venues' ); $role->add_cap( 'publish_tribe_venues' ); $role->add_cap( 'edit_published_tribe_venues' ); $role->add_cap( 'delete_published_tribe_venues' ); $role->add_cap( 'delete_private_tribe_venues' ); $role->add_cap( 'edit_private_tribe_venues' ); $role->add_cap( 'read_private_tribe_venues' ); $role->add_cap( 'edit_tribe_organizer' ); $role->add_cap( 'read_tribe_organizer' ); $role->add_cap( 'delete_tribe_organizer' ); $role->add_cap( 'delete_tribe_organizers'); $role->add_cap( 'edit_tribe_organizers' ); $role->add_cap( 'edit_others_tribe_organizers' ); $role->add_cap( 'delete_others_tribe_organizers' ); $role->add_cap( 'publish_tribe_organizers' ); $role->add_cap( 'edit_published_tribe_organizers' ); $role->add_cap( 'delete_published_tribe_organizers' ); $role->add_cap( 'delete_private_tribe_organizers' ); $role->add_cap( 'edit_private_tribe_organizers' ); $role->add_cap( 'read_private_tribe_organizers' ); } $editor = get_role( 'editor' ); if ( $editor ) { $editor->add_cap( 'edit_tribe_event' ); $editor->add_cap( 'read_tribe_event' ); $editor->add_cap( 'delete_tribe_event' ); $editor->add_cap( 'delete_tribe_events'); $editor->add_cap( 'edit_tribe_events' ); $editor->add_cap( 'edit_others_tribe_events' ); $editor->add_cap( 'delete_others_tribe_events' ); $editor->add_cap( 'publish_tribe_events' ); $editor->add_cap( 'edit_published_tribe_events' ); $editor->add_cap( 'delete_published_tribe_events' ); $editor->add_cap( 'delete_private_tribe_events' ); $editor->add_cap( 'edit_private_tribe_events' ); $editor->add_cap( 'read_private_tribe_events' ); $editor->add_cap( 'edit_tribe_venue' ); $editor->add_cap( 'read_tribe_venue' ); $editor->add_cap( 'delete_tribe_venue' ); $editor->add_cap( 'delete_tribe_venues'); $editor->add_cap( 'edit_tribe_venues' ); $editor->add_cap( 'edit_others_tribe_venues' ); $editor->add_cap( 'delete_others_tribe_venues' ); $editor->add_cap( 'publish_tribe_venues' ); $editor->add_cap( 'edit_published_tribe_venues' ); $editor->add_cap( 'delete_published_tribe_venues' ); $editor->add_cap( 'delete_private_tribe_venues' ); $editor->add_cap( 'edit_private_tribe_venues' ); $editor->add_cap( 'read_private_tribe_venues' ); $editor->add_cap( 'edit_tribe_organizer' ); $editor->add_cap( 'read_tribe_organizer' ); $editor->add_cap( 'delete_tribe_organizer' ); $editor->add_cap( 'delete_tribe_organizers'); $editor->add_cap( 'edit_tribe_organizers' ); $editor->add_cap( 'edit_others_tribe_organizers' ); $editor->add_cap( 'delete_others_tribe_organizers' ); $editor->add_cap( 'publish_tribe_organizers' ); $editor->add_cap( 'edit_published_tribe_organizers' ); $editor->add_cap( 'delete_published_tribe_organizers' ); $editor->add_cap( 'delete_private_tribe_organizers' ); $editor->add_cap( 'edit_private_tribe_organizers' ); $editor->add_cap( 'read_private_tribe_organizers' ); } $author = get_role( 'author' ); if ( $author ) { $author->add_cap( 'edit_tribe_event' ); $author->add_cap( 'read_tribe_event' ); $author->add_cap( 'delete_tribe_event' ); $author->add_cap( 'delete_tribe_events' ); $author->add_cap( 'edit_tribe_events' ); $author->add_cap( 'publish_tribe_events' ); $author->add_cap( 'edit_published_tribe_events' ); $author->add_cap( 'delete_published_tribe_events' ); $author->add_cap( 'edit_tribe_venue' ); $author->add_cap( 'read_tribe_venue' ); $author->add_cap( 'delete_tribe_venue' ); $author->add_cap( 'delete_tribe_venues' ); $author->add_cap( 'edit_tribe_venues' ); $author->add_cap( 'publish_tribe_venues' ); $author->add_cap( 'edit_published_tribe_venues' ); $author->add_cap( 'delete_published_tribe_venues' ); $author->add_cap( 'edit_tribe_organizer' ); $author->add_cap( 'read_tribe_organizer' ); $author->add_cap( 'delete_tribe_organizer' ); $author->add_cap( 'delete_tribe_organizers' ); $author->add_cap( 'edit_tribe_organizers' ); $author->add_cap( 'publish_tribe_organizers' ); $author->add_cap( 'edit_published_tribe_organizers' ); $author->add_cap( 'delete_published_tribe_organizers' ); } $contributor = get_role( 'contributor' ); if ( $contributor ) { $contributor->add_cap( 'edit_tribe_event' ); $contributor->add_cap( 'read_tribe_event' ); $contributor->add_cap( 'delete_tribe_event' ); $contributor->add_cap( 'delete_tribe_events' ); $contributor->add_cap( 'edit_tribe_events' ); $contributor->add_cap( 'edit_tribe_venue' ); $contributor->add_cap( 'read_tribe_venue' ); $contributor->add_cap( 'delete_tribe_venue' ); $contributor->add_cap( 'delete_tribe_venues' ); $contributor->add_cap( 'edit_tribe_venues'); $contributor->add_cap( 'edit_tribe_organizer' ); $contributor->add_cap( 'read_tribe_organizer' ); $contributor->add_cap( 'delete_tribe_organizer' ); $contributor->add_cap( 'delete_tribe_organizers' ); $contributor->add_cap( 'edit_tribe_organizers' ); } $subscriber = get_role( 'subscriber' ); if ( $subscriber ) { $subscriber->add_cap( 'read_tribe_event' ); $subscriber->add_cap( 'read_tribe_organizer' ); $subscriber->add_cap( 'read_tribe_venue' ); } } /** * 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) ); if ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) $this->addCapabilities(); 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() { $this->postTypeArgs['labels'] = array( 'name' => __('Events', 'tribe-events-calendar'), 'singular_name' => __('Event', 'tribe-events-calendar'), 'add_new' => __('Add New', 'tribe-events-calendar'), 'add_new_item' => __('Add New Event', 'tribe-events-calendar'), 'edit_item' => __('Edit Event', 'tribe-events-calendar'), 'new_item' => __('New Event', 'tribe-events-calendar'), 'view_item' => __('View Event', 'tribe-events-calendar'), 'search_items' => __('Search Events', 'tribe-events-calendar'), 'not_found' => __('No events found', 'tribe-events-calendar'), 'not_found_in_trash' => __('No events found in Trash', 'tribe-events-calendar'), ); $this->postVenueTypeArgs['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 )), ); $this->postOrganizerTypeArgs['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 )), ); $this->taxonomyLabels = array( 'name' => __( 'Event Categories', 'tribe-events-calendar' ), 'singular_name' => __( 'Event Category', 'tribe-events-calendar' ), 'search_items' => __( 'Search Event Categories', 'tribe-events-calendar' ), 'all_items' => __( 'All Event Categories', 'tribe-events-calendar' ), 'parent_item' => __( 'Parent Event Category', 'tribe-events-calendar' ), 'parent_item_colon' => __( 'Parent Event Category:'
- The topic ‘Custom post type’ is closed to new replies.