Skip to content

Instantly share code, notes, and snippets.

View lelandf's full-sized avatar

Leland Fiegel lelandf

View GitHub Profile
@lelandf
lelandf / snippet.php
Created November 16, 2022 22:18
[TEC] Remove price block from Event bock template
<?php
add_filter( 'tribe_events_editor_default_template', function( $template ) {
// collect an array of template values, like "tribe/event-price" and tribe/event-venue"
$template_search = array_column( $template, 0 );
// Get the index of the "tribe/event-price"
$price = array_search( "tribe/event-price", $template_search );
// @link: https://www.php.net/manual/en/function.array-splice.php
array_splice(
@lelandf
lelandf / teccom-kb-edit-links.user.js
Last active May 12, 2023 18:38
Tampermonkey helper script for editing TECCOM KB articles on
@lelandf
lelandf / snippet.php
Last active October 12, 2022 17:01
[RCP] Example of space between currency and price
<?php
// Both of these examples are specific to Swiss Franc, hence the "chf" in the filter name
// Replace with different currency accordingly
// This is if currency position is set to "before"
add_filter( 'rcp_chf_currency_filter_before', function( $formatted, $currency, $price ) {
$formatted = $currency . ' ' . rcp_format_amount( $price );
return $formatted;
}, 10, 3 );
@lelandf
lelandf / snippet.php
Last active October 20, 2022 08:43
[RCP] Example of checking if user has content dripped yet
<?php
// Requires both RCP & Drip Content active
add_action( 'wp_footer', function() {
$membership_id = 1;
$post_id = 31;
$membership = rcp_get_membership( $membership_id );
$can_access = \RCP\Addon\DripContent\Visibility\membership_can_access( true, $membership_id, $post_id, $membership );
@lelandf
lelandf / snippet.php
Last active September 29, 2022 14:24
[TEC] Replace plugin icon image on /wp-admin/update-core.php
<?php
add_action( 'admin_print_footer_scripts-update-core.php', function() {
?>
<script>
( () => {
// saving this plugin row class because we'll be using it in multiple places
const ROW_CLASS = 'plugin-title';
// collecting names of all plugins with updates available
const plugins = document.querySelectorAll( `.${ ROW_CLASS } strong` );
@lelandf
lelandf / snippet.php
Created August 23, 2022 19:47
LearnDash: Change the "Sample Lesson" string to something else
<?php
// Change 'Sample Lesson' to exactly how the text appears on your site.
// This could change depending on your use of Custom Labels and translations
// Change 'Free Module' to whatever you want to replace it with
add_filter( 'learndash_course_step_attributes', function( $attributes ) {
if (
isset( $attributes[0]['label'] ) &&
'Sample Lesson' === $attributes[0]['label']
) {
@lelandf
lelandf / force-list-view-search.php
Created May 24, 2022 21:47
[TEC] Ensure searches always occur in list view.
<?php
add_action( 'wp_footer', function() { ?>
<script>
jQuery( document ).on( 'afterOnSubmit.tribeEvents', () => {
// Select list link
const listLink = document.querySelector( '.tribe-events-c-view-selector__list-item--list a' );
// No list link? Stop!
if ( ! listLink ) {
@lelandf
lelandf / snippet-example.php
Last active March 10, 2022 16:33
Open /event/ links in new window
<?php
add_action( 'wp_footer', function() {
// Evaluate conditional here
// Maybe an is_page conditional? https://developer.wordpress.org/reference/functions/is_page/
if ( true === true ) :
?>
<script>
(function () {
// CUSTOMIZE DOMAIN NAME HERE
@lelandf
lelandf / event.php
Last active March 9, 2022 17:28
Override of list event template with "Book Now" button.
<?php
/**
* View: List Event
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events/v2/list/event.php
*
* See more documentation about our views templating system.
*
* @link http://evnt.is/1aiy
{
"replies": [
{
"title": "Premium product",
"content": "Test"
},
{
"title": "Conflict test",
"content": "Hey"
},