Skip to content

Instantly share code, notes, and snippets.

View sc0ttkclark's full-sized avatar
🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@djrmom
djrmom / custom-hooks.php
Created February 8, 2018 14:54
facetwp index a field in a related post type
<?php
/**
** look up and index a value from a post relationship field
** set the datasource to the relationship field
** get the post id of that related post and use it to
** lookup its associated value
** for ACF you may want get_field() instead of get_post_meta()
** remember to do a full re-index after adding code
** check the wp_facetwp_index table if needed to see what values are being indexed
**/
@jamesgol
jamesgol / CPT-Admin-Fields.php
Created October 25, 2016 21:45
Pods CPT Admin Fields
<?php
/**
* Name: CPT Admin Fields
*
* Description: Allow adding fields to the CPT editor table.
*
* Version: 2.3
*
* Category: Advanced
*
@sc0ttkclark
sc0ttkclark / userscript.js
Created October 7, 2016 15:37
Papertrail JSON formatter (with addStyle fix)
// ==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==
@sc0ttkclark
sc0ttkclark / .htaccess
Last active May 3, 2016 17:57
Add these lines to your .htaccess file if you can't get cPanel Let's Encrypt installation or renewal working properly (tested on SiteGround). They MUST go above any WordPress rewrites but below the "RewriteEngine On RewriteBase /" portion.
# Stop processing any rewrites for /.well-known/ files
RewriteCond %{REQUEST_URI} ^/\.well-known/.*$ [NC]
RewriteRule ^ - [L]
@nkt
nkt / Results.md
Last active September 27, 2023 08:24
ReactPHP vs Node.js

wrk -t4 -c400 -d10s http://127.0.0.1:1337/

PHP

Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
 Latency 7.02ms 6.94ms 82.86ms 85.27%
@sc0ttkclark
sc0ttkclark / 0-README.md
Last active December 1, 2023 10:12
PhpStorm.app (Standalone) Mac integration with Tower.app for diff and merge - https://youtrack.jetbrains.com/issue/WI-26090

PhpStorm.app (Standalone) Mac integration with Tower.app for diff and merge

How to use this

  1. Add CompareTools.plist and phpstorm.sh files in the ~/Library/Application Support/com.fournova.Tower3/CompareTools/ directory. You may need to mkdir ~/Library/Application\ Support/com.fournova.Tower3/CompareTools if the folder does not already exist
  2. Run chmod +x ~/Library/Application\ Support/com.fournova.Tower3/CompareTools/phpstorm.sh
  3. Go into Tower.app Preference > Git Config > Select "PhpStorm" for "Diff tool" and "Compare tool", you can optionally enable "Perform directory diff"

Other variations

Preparing Plugins for Term Splitting

Historically, two terms in different taxonomies with the same slug (for instance, a tag and a category sharing the slug "news") have shared a single term ID. Beginning in WordPress 4.2, when one of these shared terms is updated, it will be split: the updated term will be assigned a new term ID.

In the vast majority of situations, this update will be seamless and uneventful. However, some plugins and themes store term IDs in options, post meta, user meta, or elsewhere. WP 4.2 will include two different tools to help authors of these plugins and themes with the transition.

The 'split_shared_term' action

When a shared term is assigned a new term ID, a new 'split_shared_term' action is fired. Plugins and themes that store term IDs should hook to this action to perform necessary migrations. The documentation for the hook is as follows:

@sc0ttkclark
sc0ttkclark / bbp-optimize.php
Last active June 28, 2019 16:41
bbPress Optimize -- Optimizes bbPress queries for large bbPress forums
<?php
/*
Plugin Name: bbPress Optimize
Plugin URI: https://www.scottkclark.com/
Description: Optimizes bbPress queries for large bbPress forums
Version: 1.1
Author: Scott Kingsley Clark
Author URI: https://www.scottkclark.com/
*/
@jtsternberg
jtsternberg / README.md
Last active June 8, 2023 16:53
Create a theme options page with CMB2
@ericandrewlewis
ericandrewlewis / gist:8290246
Last active January 2, 2016 10:29
WordPress Post Meta ideas
<?php
/**
* Post Meta Box view/controller class.
*
* Extends from a form object base class.
*
* Creates a meta box. Fields can be related to the meta box, but
* all business logic lives within the field object.
*/