Skip to content

Instantly share code, notes, and snippets.

View skyshab's full-sized avatar

Sky Shabatura skyshab

  • taproot studios
  • Fayetteville, AR
View GitHub Profile
@skyshab
skyshab / example.php
Last active June 9, 2022 10:12
Protected download REST endpoint
<?php
add_action( 'rest_api_init', function() {
register_rest_route( 'protected-url/v1', '/rcp/addon/(?P<slug>.+)', [
'methods' => 'GET',
'callback' => 'rcp_protected_url',
'permission_callback' => '__return_true', // We will do the permission checking in the rcp_protected_url function so we can redirect.
] );
} );
@skyshab
skyshab / example.php
Last active April 12, 2022 10:31
Get cost description from block based event.
<?php
/**
* Get event cost description.
*
* @param $post_id - post id or post object.
* @return string
*/
function get_cost_description( int $post_id = 0 ) {
$post = get_post( $post_id );
@skyshab
skyshab / tec-datepicker-no-conflict.php
Created March 16, 2022 13:55
Must Use plugin for fixing conflicts between bootstrap datepicker and jQuery UI datepicker.
<?php
/**
* Plugin Name: Fix for TEC datepicker conflict.
* Description: Fixes conflict between bootstrap datepicker and jQuery UI datepicker
* Author: theeventscalendar.com
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
// Basic security, prevents file from being loaded directly.
@skyshab
skyshab / example.php
Created March 15, 2022 13:18
Genesis calendar fix simplified
<?php
/**
* Fix Calendar views in Genesis based themes.
*
* This snippet overrides the Genesis Content Archive settings for Event Views
* when Events > Settings > Display Tab > Events template is set to Default Page Template.
*
*/
add_action( 'get_header', function() {
if ( ! class_exists( 'Tribe__Events__Main' ) ) {
@skyshab
skyshab / example.php
Created March 1, 2022 18:30
Remove "subscribe to calendar" dropdown from the main calendar page
<?php
// Remove subscribe to calendar dropdown from main calendar page
add_filter( 'tribe_template_html:events/v2/components/subscribe-links/list', '__return_false' );
@skyshab
skyshab / example.php
Created July 27, 2021 18:35
Prevent RSVPs from sending a ticket email
<?php
// Prevent RSVPs from being sent
add_filter( 'tribe_tickets_rsvp_tickets_to_send', '__return_false' );
@skyshab
skyshab / example.php
Created July 26, 2021 13:48
Redirect to event page after checking out in WooCommerce
<?php
add_action( 'woocommerce_thankyou', function( $order_id ){
$order = wc_get_order( $order_id );
$has_tickets = get_post_meta( $order_id, '_tribe_has_tickets', true );
if ( empty( $has_tickets ) || ! $has_tickets ) {
return;
}
@skyshab
skyshab / example.php
Last active July 20, 2021 16:36
Remove actions related to attendee information in WooCommerce pages
<?php
// Remove actions related to attendee info in WooCommerce pages
add_action( 'init', function() {
// Remove action to add attendee meta on completed order page
remove_action( 'woocommerce_before_order_itemmeta', tribe_callback( 'tickets-plus.woo.enhanced-template-hooks', 'add_attendee_data_for_order_item' ) );
// Remove action to add "event" table heading from "Item" metabox on Woo order page
remove_action( 'woocommerce_admin_order_item_headers', tribe_callback( 'tickets-plus.woo.enhanced-template-hooks', 'add_event_title_header' ) );
@skyshab
skyshab / day.php
Created July 2, 2021 12:11
Add a class to month view day-cells when they contain events.
<?php
/**
* View: Month View - Day
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events/v2/month/calendar-body/day.php
*
* See more documentation about our views templating system.
*
* @link http://evnt.is/1aiy
@skyshab
skyshab / example.php
Created June 18, 2021 14:15
Hide tickets for non members based on user role. Membership plugins. Ultimate member.
<?php
add_filter( 'tribe_template_context', function($context, $file, $name, $obj){
// bail if not the target template
if ( 'v2/tickets' !== implode("/", $name) ) {
return $context;
}
// This is the name of a category added to members only products in WooCommerce.