Skip to content

Instantly share code, notes, and snippets.

View justlevine's full-sized avatar

Dovid Levine justlevine

View GitHub Profile
@justlevine
justlevine / functions.php
Created December 9, 2020 21:02
TEC fukter
add_filter( 'tribe_events_views_v2_view_repository_args', 'set_default_listview_date', 10, 2 );
/**
* Sets TEC list view date to '30 days ago' when the view is 'now'.
*
* @param array $args The default context args from the filter.
* @param array $context the default TEC context.
*/
function set_default_listview_date( $args, $context ) {
if ( 'now' === $args['ends_after'] ) {
$args['ends_after'] = '30 days ago';
@justlevine
justlevine / functions.php
Last active October 27, 2020 07:48
cpt_unique_slug_by_tax.php
<?php
add_filter( 'wp_unique_post_slug', 'cpt_unique_slug_by_tax', 10, 6 );
function cpt_unique_slug_by_tax( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
if ( 'guide' === $post_type ) {
global $wpdb;
$post_tax = get_the_terms( $post_ID, 'guide_cat' );
// Check if another CPT exists in the same taxonomy with the same name.
@justlevine
justlevine / functions.php
Last active May 8, 2019 14:17
Wordpress: Add dependency to preregistered script
/**
* Add dependency to a preregistered script. Returns false if script hasnt been registered.
*
* @param string $handle
* @param string $dependency
* @return bool
*/
function jl_add_script_dependency( $handle, $dependency ) {
global $wp_scripts;