Skip to content

Instantly share code, notes, and snippets.

View skyshab's full-sized avatar

Sky Shabatura skyshab

View GitHub Profile
@skyshab
skyshab / example.php
Created May 28, 2021 15:45
default rsvp attendees to be opted in to being displayed in attendees list
<?php
/**
* Block: RSVP
* Actions - Success - Toggle
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/tickets/v2/rsvp/actions/success/toggle.php
*
* See more documentation about our Blocks Editor templating system.
*
@skyshab
skyshab / example.php
Created May 24, 2021 15:36
Hide past or current events that started before today from the calendar views.
<?php
// Hide past or current events that started before today from the calendar views.
add_filter( 'tribe_events_views_v2_view_repository_args', function( $args, $context, $view ) {
$args['starts_on_or_after'] = current_time('Y-m-d H:i:s');
return $args;
}, 10, 3 );
@skyshab
skyshab / wc-force-regenerate-attendees.php
Created April 15, 2021 13:23 — forked from sc0ttkclark/wc-force-regenerate-attendees.php
This snippet will add functionality that adds a new "Regenerate Attendees" action and bulk action for WooCommerce order management.
<?php
// Register the action for the Edit order screen.
add_filter( 'woocommerce_order_actions', 'tec_event_tickets_plus_wc_register_force_regenerate_attendees' );
// Register the bulk action for the Orders screen.
add_filter( 'bulk_actions-edit-shop_order', 'tec_event_tickets_plus_wc_register_force_regenerate_attendees' );
/**
* Register the custom action to the list of order actions.
@skyshab
skyshab / example.php
Last active April 7, 2021 15:02
Fix for javascript errors due to Page Optimize conflict with Event Tickets plugins.
<?php
// Filter to remove tickets plugins scripts that conflict with the Page Optimize plugin.
add_filter( 'js_do_concat', function( $do_concat, $handle ) {
// Exclude any scripts with "tribe-" in the handle.
if ( strpos($handle, 'tribe-') !== false ) {
return false;
}
@skyshab
skyshab / example.php
Created April 2, 2021 12:42
Hide members only tickets from ticket form when using Paid Memberships Pro
<?php
// Hide members only tickets from ticket form when using Paid Memberships Pro.
// Works by assigning a product category and defining the membership needed.
add_filter( 'tribe_template_context', function($context, $file, $name, $obj){
// bail if not the target template, or if membership plugin isn't active
if ( 'v2/tickets' !== implode("/", $name) || ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return $context;
}
@skyshab
skyshab / example.php
Created March 30, 2021 13:17
Restore shortcode functionality on the Community Events page
<?php
add_action( 'tribe_events_community_form', function( $event_id, $event, $template ){
add_filter( 'the_content', 'do_shortcode', 999 );
}, 100, 3);
@skyshab
skyshab / example.php
Last active March 31, 2021 16:10
Allow all IAC attendees to view protected content
<?php
// Allow all IAC attendees to view protected content.
add_filter( 'tribe_tickets_shortcode_can_see_content', static function( $can_see_content, $filter_args ) {
// Only run our logic below if the user is logged in or if they cannot currently see the content.
if ( ! is_user_logged_in() || $can_see_content ) {
return $can_see_content;
}
// Get the logged in user.
@skyshab
skyshab / example.php
Created March 29, 2021 13:38
Prepend event name to ticket on creation
<?php
add_action( 'tribe_tickets_ticket_add', function( $post_id, $ticket ){
$post_title = get_the_title( $post_id );
if( strpos( $ticket->name, $post_title ) === 0 ) return;
$new_name = $post_title . ' - ' . $ticket->name;
@skyshab
skyshab / example.php
Created March 29, 2021 12:53
Dequeue / remove a tribe asset
<?php
// Remove an asset that was registered with Tribe Assets (v2 only).
// The asset name can be found by finding where the file is loaded
// in the site head. The value to use will be the ID of the style
// or script block.
add_action('wp_enqueue_scripts', function() {
tribe('assets')->remove('tribe-tickets-plus-modal-styles');
});
@skyshab
skyshab / example.php
Last active March 26, 2021 17:25
Fix for shared capacity tickets available being wrong after deleting attendee
<?php
// Replace this value with the event id
$my_event_id = 123;
// Replace this value with the correct number of capacity
// that should be displaying for shared capacity tickets.
$correct_remaining_tickets = 9;
add_action( 'init', function() {