Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

P. E. A. Lutz misfist

  • NYC
View GitHub Profile
@rliverman
rliverman / tribe_filter-bar_custom_filter
Created August 26, 2014 20:27
Add a custom filter to "The Events Calendar Pro" filter bar plugin based on a taxonomy
<?php
/**
* Adding a custom filter
* A simple copy and paste of the existing Category filter
* Find this new filter in: WP Admin > Events > Settings > Filterbar
* Docs for TribeEventsFilter: http://docs.tri.be/Filter-Bar/class-TribeEventsFilter.html
*/
class TribeEventsFilter_CustomClubs extends TribeEventsFilter {
public $type = 'select';
@cfxd
cfxd / acf_taxonomy_hierarchy.php
Last active February 9, 2017 22:47
Add taxonomy hierarchy (parent and child) matching to Advanced Custom Fields
<?php
function add_child_and_parent_to_acf_taxonomy_choices($choices) {
$tax_choices = array();
foreach($choices as $taxonomy => $c) {
$tax_choices[$taxonomy] = $c;
if($taxonomy != 'all' && is_taxonomy_hierarchical($taxonomy)) {
$tax_choices[$taxonomy.'-tax_parent'] = $c.' (parent)';
$tax_choices[$taxonomy.'-tax_child'] = $c.' (child)';
}
@jplhomer
jplhomer / disable-comments.sh
Created February 25, 2015 16:38
Disable all comments/pings in WordPress with WP-CLI
$ wp post list --format=ids | xargs wp post update --comment_status=closed
# Output:
# Success: Updated post 2514.
# Success: Updated post 2511.
# Success: Updated post 2504.
# Success: Updated post 2499.
# Success: Updated post 2441.
# etc...
@yoren
yoren / functions.php
Last active September 14, 2022 21:02
Add Featured Image Thumbnail URL to wp-json/wp/v2/posts Endpoint
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id );
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$data->data = $_data;
@wpchannel
wpchannel / mu-yoast-seo-disable-notifications.php
Last active April 16, 2023 08:33
Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Disable Yoast SEO Notifications
* Description: Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices.
* Version: 1.1
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/
@leepettijohn
leepettijohn / functions.php
Last active December 3, 2024 05:38
Add Event to The Events Calendar from a Gravity Form
//The following section is an add-on to this tutorial - https://tri.be/gravity-forms-events-calendar-submissions/
//Shout to CreativeSlice.com for their initial work
/* Before Starting:
- Make sure you have these three plugins installed
- Gravity Forms
- The Events Calendar
- Gravity Forms + Custom Post Types
- Once Gravity Forms is installed, create a form with these fields
- Single Line Text (Event Title)
- Paragraph Text (Event Description)
@SamuelChristie
SamuelChristie / tls_1_deprecation.md
Created November 2, 2015 16:08
Explanation of how to detect TLS 1.0 connections and, by way of custom headers, warn the user about the coming change to more modern TLS versions.
function bidirectional_acf_update_value( $value, $post_id, $field ) {
// vars
$field_name = $field['name'];
$global_name = 'is_updating_' . $field_name;
// bail early if this filter was triggered from the update_field() function called within the loop below
// - this prevents an inifinte loop
if( !empty($GLOBALS[ $global_name ]) ) return $value;
/**
* Add the field "spaceship" to REST API responses for posts read and write
*/
add_action( 'rest_api_init', 'slug_register_spaceship' );
function slug_register_spaceship() {
register_rest_field( 'post',
'starship',
array(
'get_callback' => 'slug_get_spaceship',
'update_callback' => 'slug_update_spaceship',
@jaredatch
jaredatch / functions.php
Last active August 7, 2024 15:24
WordPress Search Autocomplete using WP REST API v2
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',