Skip to content

Instantly share code, notes, and snippets.

View lelandf's full-sized avatar

Leland Fiegel lelandf

View GitHub Profile
@lelandf
lelandf / add-required-message-to-community-edit-event-page.php
Last active January 4, 2022 19:26
[TEC] Add (required) to required custom fields on community edit event page.
add_action( 'wp_footer', function() {
// Stop if we're not on the community edit event page
if ( ! tribe_is_community_edit_event_page() ) {
return;
}
?>
<script>
@lelandf
lelandf / snippet.php
Last active October 20, 2021 20:24
Override "Untitled" filter in Twenty Twenty-One theme
<?php
add_filter( 'the_title', function( $title, $id ) {
if ( 0 === $id && 'Untitled' === $title ) {
$title = '';
}
return $title;
}, 11, 2 );
@lelandf
lelandf / snippet.php
Last active October 8, 2021 20:37
[TEC] Remove events/feed link
<?php
// Might be overengineering this with the str_contains polyfill
// Just checking to see if the string contains "events/feed" before returning null
// @link https://www.php.net/manual/en/function.str-contains.php#Hcom126277
// @link https://developer.wordpress.org/reference/functions/get_post_type_archive_link/
if ( ! function_exists( 'str_contains' ) ) {
function str_contains( string $haystack, string $needle ) {
return empty( $needle ) || strpos( $haystack, $needle ) !== false;
}
@lelandf
lelandf / snippet.php
Created September 29, 2021 14:30
[TEC] working redirect sample
<?php
add_action( 'template_redirect', function() {
if ( is_user_logged_in() ) {
return;
}
if (
tribe_is_event() ||
tribe_is_event_category() ||
tribe_is_in_main_loop() ||
@lelandf
lelandf / snippet.php
Created September 28, 2021 20:06
[TEC] Require event category on community events form
<?php
add_filter( 'tribe_events_community_required_fields', function( $fields ) {
$fields[] = 'tax_input.tribe_events_cat';
return $fields;
});
@lelandf
lelandf / snippet.php
Last active September 27, 2021 20:35
[TEC] Remove date from calendar day view (WP conditional sample)
<?php
add_action( 'wp_footer', function() {
// Replace with your own Page ID.
// Reference: https://developer.wordpress.org/reference/functions/is_page/
if ( is_page( 2 ) ) :
?>
<script>
(function () {
const dates = document.querySelectorAll( '.tribe-events-calendar-day__event-datetime .tribe-event-date-start' );
@lelandf
lelandf / snippet.php
Last active September 24, 2021 20:52
[TEC] for troubleshooting tribe_get_events
<?php
add_action( 'wp_footer', function() {
$args = [
'start_date' => 'now',
'posts_per_page' => 10,
'post_status' => 'publish',
];
$events = tribe_get_events( $args );
foreach ( $events as $key => $event ) {
@lelandf
lelandf / snippet.php
Created September 24, 2021 19:39
[TEC] Remove date from calendar day view
<?php
add_action( 'wp_footer', function() { ?>
<script>
(function () {
const dates = document.querySelectorAll( '.tribe-events-calendar-day__event-datetime .tribe-event-date-start' );
if ( ! dates ) {
return;
}
@lelandf
lelandf / snippet.php
Created September 24, 2021 19:00
[TEC] Change featured image size
<?php
add_filter( 'tribe_event_featured_image_size', function() {
return 'large';
} );
@lelandf
lelandf / snippet.php
Created September 23, 2021 21:05
[TEC] increase number of events in events list widget
<?php
// Use at your own risk!
// No warranty, no support provided
// There are performance implications of querying more posts than your database server can handle
add_filter( 'tribe_widget_args_to_context', function( $alterations, $arguments ) {
// Is this the Events List widget?
if ( 'tribe-widget-events-list' === $arguments['widget_obj']->id_base ) {
// Adjust number of events displayed here.
$alterations['events_per_page'] = 99;