Skip to content

Instantly share code, notes, and snippets.

View jkudish's full-sized avatar

Joey Kudish jkudish

View GitHub Profile
@jkudish
jkudish / tribe-settings-example.php
Created March 27, 2012 20:28
Tribe Settings Example
<?php
add_action('tribe_settings_do_tabs', 'tribe_add_general_tab');
function tribe_general_setting_tabs() {
$generalTab = array(
'priority' => 10,
'fields' => array(
'upsell-heading' => array(
'type' => 'heading',
'label' => __('Additional Functionality', 'tribe-events-calendar'),
'conditional' => ( !defined('TRIBE_HIDE_UPSELL') || !TRIBE_HIDE_UPSELL ),
@jkudish
jkudish / tribe-settings.md
Created March 14, 2012 22:30
Documentation for the new TribeSettings API available in The Events Calendar 2.0.5

Tribe Settings API

This is documentation for the new TribeSettings API available in The Events Calendar 2.0.5 and up

There are four classes that make up the new Tribe Settings API. All four are located in the /lib folder of the plugin. All four are also bootstrapped and loaded whenever the plugin runs.

Take note that each class represents a level of abstraction. If you are creating a new settings tab, you will be mostly concerned and interested in the fourth class TribeSettingsTab which neatly wraps the other 3 classes into a helpful & easy to use API.

Class TribeSettings

<?php
$args = array(
'Venue' => 'My great venue',
'Country' => 'Canada',
'Address' => '123 Fake St.',
'City' => 'Vancouver',
'Province' => 'BC',
);
$venue_id = tribe_create_venue($args);
update_post_meta($venue_id, 'ID', 'MCHS-MN-Rochester');
<?php
sprintf(
__('Mauris ligula est, venenatis id faucibus at, euismod vel felis. %s Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'the-events-calendar'), sprintf('<a href="http://google.com">%s</a>', __('My Link', 'the-events-calendar')
);
@jkudish
jkudish / gist:1981268
Created March 5, 2012 21:37
filtering years in The Events Calendar year dropdown - this will only work in 2.1+
<?php
// filter the number of years to go back
add_filter('tribe_years_to_go_back', 'my_tribe_years_to_go_back');
function my_tribe_years_to_go_back() {
return 2;
}
// filter the number of years to go forwards
add_filter('tribe_years_to_go_forward', 'tribe_years_to_go_forward');
@jkudish
jkudish / change-number-years.php
Created March 5, 2012 20:41
change the number of years in the dropdown for The Events Calendar
<?php
/**
* this is lines 563-573 of /lib/tribe-view-helpers.class.php
*/
private static function years( ) {
$year = ( int )date_i18n( 'Y' );
// Back two years, forward 5
$year_list = array( $year - 1, $year, $year + 1, $year + 2, $year + 3, $year + 4, $year + 5 );
@jkudish
jkudish / no-index-single-tribe-events.php
Created March 3, 2012 06:26
noindex single tribe_events
<?php
add_action('wp_head','tribe_dont_index_single_events');
function tribe_dont_index_single_events() {
if ( is_singular() && get_post_type() == TribeEvents::POSTTYPE )
echo '<meta name="robots" content="noindex">';
}
<?php
$role = get_role( 'administrator' );
$role->add_cap( 'edit_tribe_event' );
$role->add_cap( 'read_tribe_event' );
$role->add_cap( 'delete_tribe_event' );
$role->add_cap( 'edit_tribe_events' );
$role->add_cap( 'edit_others_tribe_events' );
$role->add_cap( 'publish_tribe_events' );
$role->add_cap( 'read_private_tribe_events' );
@jkudish
jkudish / single-no-pagination.php
Created February 24, 2012 03:45
show all events on a single day view
<?php
add_filter('pre_get_posts', 'tribe_filter_days_on_single_day', 20);
function tribe_filter_days_on_single_day($query) {
if (tribe_is_day()) {
$query->set('nopaging', true);
}
return $query;
}
@jkudish
jkudish / remove-scripts.php
Created February 24, 2012 03:21
remove tribe events scripts
<?php
add_action('wp_enqueue_scripts', 'tribe_remove_javascript');
function tribe_remove_javascript() {
wp_dequeue_script('sp-events-pjax');
wp_dequeue_script('sp-events-calendar-script');
}