Skip to content

Instantly share code, notes, and snippets.

🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@sc0ttkclark
sc0ttkclark / skc-404.php
Created Jul 3, 2020
My 404 handler for scottkclark.com
View skc-404.php
<?php
/**
* Handle 404's in a way that can trick Slack and other link previews.
*/
function skc_404_handler() {
if ( is_admin() || ! is_404() ) {
return;
}
View rest.json
{
"namespace": "pods/v1",
"routes": {
"/pods/v1": {
"namespace": "pods/v1",
"methods": [
"GET"
],
"endpoints": [
{
View pods-help.php
<?php
//pods: https://imgur.com/a/MflzgtI
$search = sanitize_text_field( $search );
$query = array();
$query[] = 'brand.meta_value = ' . absint( $_REQUEST['brand_id'] );
$query[] = '
d.asset_name LIKE "%' . pods_sanitize_like( $search ) . '%"
OR product_d.sku like "%' . pods_sanitize_like( $search ) . '%"
@sc0ttkclark
sc0ttkclark / event-tickets-support-html-descriptions.php
Last active Oct 8, 2019
Support HTML descriptions on Tickets for the Event Tickets plugin
View event-tickets-support-html-descriptions.php
<?php
// Allow (safe) HTML for ticket descriptions.
add_action( 'tribe_tickets_ticket_add', function( $post_id, $ticket, $data ) {
$ticket->description = isset( $data['ticket_description'] ) ? wp_kses_post( $data['ticket_description'] ) : '';
}, 10, 3 );
@sc0ttkclark
sc0ttkclark / debug-ep.php
Created Feb 26, 2019
ElasticPress debugging code for mu-plugins
View debug-ep.php
<?php
/**
* @param string $type
*
* @return bool
*/
function debug_ep_is_debug( $type = 'normal' ) {
if ( ! empty( $_GET['epdebug'] ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
@sc0ttkclark
sc0ttkclark / custom-pods-shortcode-total-text.php
Last active May 28, 2019
Custom `[pods]` shortcode handling for total text.
View custom-pods-shortcode-total-text.php
<?php
/*
* Ensure total_found() gets calculated right away, because in the [pods] shortcode
* it does other queries after the initial find().
*/
add_filter( 'pods_data_auto_calculate_total_found', '__return_true' );
/**
* Add custom shortcode handling for total text.
@sc0ttkclark
sc0ttkclark / import-example.php
Created Aug 29, 2017
Pods import csv example
View import-example.php
<?php
/**
* Import CSV example for Pods
*
* @param string $file File location
*
* @return true|WP_Error Returns true on success, WP_Error if there was a problem
*/
function my_import_csv( $file ) {
@sc0ttkclark
sc0ttkclark / prospress-command.php
Created Jul 18, 2017
Prospress command example for WP-CLI
View prospress-command.php
<?php
/**
* Prospress command for CLI actions.
*/
class Prospress_Command extends WP_CLI_Command {
/**
* Run scheduler
*
@sc0ttkclark
sc0ttkclark / tribe-fix-pods-handlebars-conflict.php
Created May 11, 2017
Fix for extending The Events Calendar content types in Pods (fixed in Pods 2.7 but it's not released yet)
View tribe-fix-pods-handlebars-conflict.php
<?php
add_action( 'admin_enqueue_scripts', 'tribe_fix_pods_handlebars_conflict', 16 );
/**
* The Events Calendar uses a newer version of Handlebars that conflicts
* when Pods tries to load it's outdated version of Handlebars.
*
* This removes the Pods handlebars
*/
function tribe_fix_pods_handlebars_conflict() {
@sc0ttkclark
sc0ttkclark / userscript.js
Created Oct 7, 2016
Papertrail JSON formatter (with addStyle fix)
View userscript.js
// ==UserScript==
// @name Papertrail JSON formatter
// @namespace https://papertrailapp.com/
// @version 0.1
// @description Format and colorize JSON log messages in Papertrail
// @match https://papertrailapp.com/*events*
// @copyright 2014+, Papertrail (http://wiki.creativecommons.org/Public_domain)
// @grant GM_addStyle
// ==/UserScript==
You can’t perform that action at this time.