Skip to content

Instantly share code, notes, and snippets.

@jazbek
jazbek / gist:4525380
Last active December 22, 2020 23:03
// sfw endpoint
add_action( 'init', 'add_sfw_endpoint' );
function add_sfw_endpoint()
{
add_rewrite_endpoint( 'sfw', EP_ALL );
}
add_action( 'pre_get_posts', 'sfw_pre_get_posts' );
function sfw_pre_get_posts($query)
{
@jazbek
jazbek / gist:7442734
Last active January 4, 2019 05:10
Fix for broken tag archives
<?php
add_action( 'parse_query', 'tribe_fix_tag_query' );
function tribe_fix_tag_query( $query ) {
if ( $query->is_tag && (array) $query->get( 'post_type' ) != array( TribeEvents::POSTTYPE ) ) {
if ( empty( $query->query_vars['post_type'] ) ) {
$query->query_vars['post_type'] = array( 'post' );
}
if ( ! ( $query->query_vars['post_type'] == array( 'post' ) || $query->query_vars == 'post' ) ) {
remove_action( 'parse_query', array( 'TribeEventsQuery', 'parse_query' ), 50 );
@jazbek
jazbek / w3tc-mu.md
Last active February 8, 2018 05:29 — forked from wturnerharris/w3tc-mu.md

###W3TC MU-Plugins Install

  1. ####Add Nginx Rewrite Rule -> .htaccess:

    • rewrite ^/(?:[_0-9a-zA-Z-]+/)?wp-content/plugins/w3-total-cache/(.*) /wp-content/mu-plugins/plugins/w3-total-cache/$1 last;
  2. ####Add WP-Config Option -> wp-config.php:

    • define('W3TC_DIR', dirname(FILE).'/wp-content/mu-plugins/w3-total-cache');
  3. ####Add w3tc plugin -> mu-plugins/:

  • Upload entire plugin to mu-plugins/w3-total-cache/
@jazbek
jazbek / gist:3794987
Created September 27, 2012 16:34
Allow 'post_type' passed as an arg to get_terms (useful for taxonomies shared between post types)
/**
* terms_clauses
*
* filter the terms clauses in get_terms(), allow post_type arg
*
* @param $clauses array
* @param $taxonomy string
* @param $args array
* @return array
* @author Jessica Yazbek
@jazbek
jazbek / gist:8428371
Created January 15, 2014 00:00
Fix broken sliders in some themes with The Events Calendar 3.2+
<?php
add_filter( 'tribe_events_query_posts_fields', 'tribe_fix_multi_posttype_fields', 10, 2 );
function tribe_fix_multi_posttype_fields( $fields, $query ) {
global $wpdb;
if ( $query->tribe_is_multi_posttype ) {
foreach ( $fields as $key => $field ) {
$fields[$key] = str_replace( $wpdb->postmeta, 'tribe_event_postmeta', $field );
@jazbek
jazbek / gist:8312881
Created January 8, 2014 07:00
Fix photo view losing the category when paginated
<?php
add_filter( 'tribe_events_pro_pre_get_posts', 'tribe_fix_photo_category_pagination' );
function tribe_fix_photo_category_pagination( $query ) {
// check & set event category
if ( isset( $_POST['tribe_event_category'] ) && $query->get( TribeEvents::TAXONOMY ) == '' ) {
$query->set( TribeEvents::TAXONOMY, $_POST['tribe_event_category'] );
}
return $query;
@jazbek
jazbek / gist:7491289
Created November 15, 2013 20:47
Fix google maps on https
<?php
add_filter( 'tribe_get_embedded_map', 'tribe_fix_google_maps_https' );
function tribe_fix_google_maps_https( $html ) {
if ( is_ssl() ) {
$html = str_replace( 'http://', 'https://', $html );
}
return $html;
}
@jazbek
jazbek / gist:7440874
Created November 12, 2013 23:45
Dequeue google maps
add_action('wp_enqueue_scripts', 'tribe_dequeue_google_maps', 11);
function tribe_dequeue_google_maps() {
wp_dequeue_script('gmaps');
}
@jazbek
jazbek / gist:7240619
Created October 30, 2013 21:29
Fix datepicker for satellite7 theme
<?php
add_action('admin_print_scripts', 'fix_satellite7_datepicker', 21);
function fix_satellite7_datepicker() {
global $typenow;
if ( class_exists('TribeEvents') && $typenow == TribeEvents::POSTTYPE ) {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.datepicker').datepicker('destroy');
@jazbek
jazbek / gist:7129020
Created October 24, 2013 00:07
Order events by their post date
<?php
add_action( 'pre_get_posts', 'tribe_post_date_ordering', 51 );
function tribe_post_date_ordering( $query ) {
if ( $query->tribe_is_multi_posttype) {
remove_filter( 'posts_fields', array( 'TribeEventsQuery', 'multi_type_posts_fields' ) );
$query->set( 'order', 'DESC' );
}
}