Skip to content

Instantly share code, notes, and snippets.

View jo-snips's full-sized avatar

Jonah West jo-snips

View GitHub Profile
<?php
// use this method to replace the orininal in v1.0.5 (line 273 in the-events-calendar-facebook-importer.php)
function get_facebook_photo( $object_id ) {
$api_url = $this->build_url_with_access_token( $object_id . '/', array( 'fields' => 'cover', 'return_ssl_resources' => 1 ) );
$api_request = $this->json_retrieve( $api_url );
$new_path = $api_request->cover->source;
$get_photo = wp_remote_get( $api_request->cover->source );
// setup return object
$photo['url'] = $new_path;
@jo-snips
jo-snips / exclude-events-by-cat.php
Last active June 5, 2023 01:02
The Events Calendar - Exclude Events by Category (pre_get_posts)
<?php
add_action( 'pre_get_posts', 'exclude_events_category' );
function exclude_events_category( $query ) {
if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {
$query->set( 'tax_query', array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array('zoo'),
@jo-snips
jo-snips / register-objects-for-post-type.php
Created March 29, 2013 14:41
Register Taxonomies For Post Types
<?php
/*-----------------------------------------------------------------------------------*/
/* Register Taxes for Post Types
/*-----------------------------------------------------------------------------------*/
function run_init() {
register_taxonomy_for_object_type('category', 'tribe_events');
register_taxonomy_for_object_type('post_tag', 'tribe_events');
register_taxonomy_for_object_type('tribe_events_cat', 'post');
@jo-snips
jo-snips / filter-ical-description.php
Last active December 15, 2015 12:09
The Events Calendar - Filter iCal Description
<?php
function filter_ical_description($item, $eventPost) {
$description = preg_replace( "/[\n\t\r]/", ' ', strip_tags( strip_shortcodes( $eventPost->post_content ) ) );
$description .= '<a href="http://www.mysite.com">Back to site</a>';
$item[] = 'X-ALT-DESC;FMTTYPE=text/html:' . str_replace( ',','\,', $description );
return $item;
}
add_filter('tribe_ical_feed_item','filter_ical_description', 10, 2);
<?php
//Add to your theme's functions.php
add_filter( 'tribe_ical_feed_item', 'tribe_ical_modify_event', 10, 2 );
function tribe_ical_modify_event( $item, $eventPost ) {
$searchValue = "DESCRIPTION";
$fl_array = preg_grep('/^' . "$searchValue" . '.*/', $item);
$key = array_values($fl_array);
$keynum = key($fl_array);
@jo-snips
jo-snips / custom-venue-wpquery.php
Created March 21, 2013 22:38
The Events Calendar - Custom Venue WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::VENUE_POST_TYPE),
'posts_per_page'=>10,
'order'=>'DESC'
);
$get_posts = null;
$get_posts = new WP_Query();
@jo-snips
jo-snips / category_tag_support_for_events.php
Created March 18, 2013 18:48
The Events Calendar - Add Category/Tag Support
<?php
/*-----------------------------------------------------------------------------------*/
/* Register Category/Tag Support for Events
/*-----------------------------------------------------------------------------------*/
function add_category_tag_support() {
register_taxonomy_for_object_type('post_tag', 'tribe_events');
register_taxonomy_for_object_type('tribe_events_cat', 'tribe_venue');
}
add_action('init','add_category_tag_support');
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@jo-snips
jo-snips / custom-events-wp_query.php
Last active December 3, 2024 05:39
The Events Calendar - Custom Query Using WP_Query
<?php
$args = array(
'post_status'=>'publish',
'post_type'=>array(TribeEvents::POSTTYPE),
'posts_per_page'=>10,
//order by startdate from newest to oldest
'meta_key'=>'_EventStartDate',
'orderby'=>'_EventStartDate',
'order'=>'DESC',
<?php
// Add Tribe Event Namespace
add_filter( 'rss2_ns', 'events_rss2_namespace' );
function events_rss2_namespace() {
echo 'xmlns:ev="http://purl.org/rss/2.0/modules/event/"';
}
// Add Event Date to RSS Feeds
add_action('rss_item','tribe_rss_feed_add_eventdate');