Skip to content

Instantly share code, notes, and snippets.

View barryhughes's full-sized avatar
🇨🇦

Barry Hughes barryhughes

🇨🇦
  • Automattic
  • Vancouver Island, Canada
View GitHub Profile
@barryhughes
barryhughes / gcal-link-use-excerpt.php
Created April 13, 2015 15:02
This can be added to a custom plugin/theme functions.php file to make the GCal link use the excerpt in place of the description.
@barryhughes
barryhughes / modify-venue-post-type.php
Created April 13, 2015 18:22
Can be added to a custom plugin/theme functions.php: changes venue post type properties
/**
* Alter the venue post type properties.
*
* Remmber that if rewrite-related properties (such as the post type slug) are
* changed you may need to flush permalinks by visting the Permalink Settings
* screen.
*/
function modify_venue_type_properties( $properties ) {
// Change the slug
$properties['rewrite']['slug'] = 'custom_venue_slug';
@barryhughes
barryhughes / no-events-settings.php
Created April 23, 2015 14:10
May be useful for devs/designers not wishing their customers to modify event display settings, etc
add_action( '_admin_menu', 'remove_tribe_settings_page', 50 );
function remove_tribe_settings_page() {
remove_action( 'admin_menu', array( TribeSettings::instance(), 'addPage' ) );
}
@barryhughes
barryhughes / conditionally-stop-events-before-html.php
Created April 30, 2015 15:03
Prevent the before-event-html field from operating on specific pages (in this example, the Community Events editor)
function conditionally_remove_tribe_before_html( $html ) {
if ( ! function_exists( 'tribe_is_community_edit_event_page' ) ) return $html;
if ( ! tribe_is_community_edit_event_page() ) return $html;
return '';
}
add_filter( 'tribe_events_before_html', 'conditionally_remove_tribe_before_html' );
@barryhughes
barryhughes / fix-apm-search-subsubsub.php
Created May 5, 2015 14:27
Fix odd issue with APM/pro admin styles blocking out subsubsub links in mobile (ECP 3.9.3)
add_action( 'admin_print_styles', 'tribe_fix_apm_search_issue_mobile' );
function tribe_fix_apm_search_issue_mobile() {
global $pagenow, $post;
if ( ! class_exists( 'TribeEvents' ) || ! class_exists( 'TribeEventsPro' ) ) return;
if ( 'edit.php' !== $pagenow && TribeEvents::POSTTYPE !== get_post_type( $post ) ) return;
echo '
<style>
@barryhughes
barryhughes / alter-posts-per-page-map-view.php
Created May 8, 2015 10:42
Alter the number of events listed on a specific view (in this case, map view | tested with PRO 3.9.3)
/**
* Change the number of events displaying per page within map view.
*
* @param $query
*/
function adjust_tribe_map_posts_per_page( $query ) {
if ( 'map' !== $query->get( 'eventDisplay') ) return;
$query->set( 'posts_per_page', 100 ); // Change 100 to -1 for "unlimited"
}
@barryhughes
barryhughes / custom-tribe-before-html-submission-form.php
Created May 8, 2015 20:25
This could be added to the theme's functions.php file in order to add a custom message to the Community Events submission page
function tribe_before_html_community_events( $html ) {
if ( ! function_exists( 'tribe_is_community_edit_event_page' ) ) return $html;
if ( ! tribe_is_community_edit_event_page() ) return $html;
return 'My custom message';
}
add_filter( 'tribe_events_before_html', 'tribe_before_html_community_events' );
<?php
class Tribe__Events__User_Functions {
protected static $paths = array(
'tribe-events/functions.php'
);
/**
* Registers a plugin-specific functions.php file to be loaded if it exists.
*
* The file needn't actually be named functions.php, however, and the path should
add_action( 'tribe_events_after_the_event_title', 'add_ticket_form_to_list_view' );
function add_ticket_form_to_list_view() {
if ( ! class_exists( 'TribeWooTickets' ) || ! function_exists( 'tribe_is_list_view' ) ) return;
if ( tribe_is_list_view() ) TribeWooTickets::get_instance()->front_end_tickets_form( '' );
}
@barryhughes
barryhughes / event-tax-descriptions.php
Last active August 29, 2015 14:22
Show event category description(s) for the current event (TEC 3.9.3)
<?php
// Get all event categories assigned to the current post
$event_categories = get_the_terms( TribeEvents::postIdHelper(), TribeEvents::TAXONOMY );
// Display the description for each
if ( is_array( $event_categories ) )
foreach ( $event_categories as $cat ) esc_html_e( $cat->description );
?>