Skip to content

Instantly share code, notes, and snippets.

Phil Kurth mishterk

Block or report user

Report or block mishterk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mishterk
mishterk / example-table-definition-for-post-post-type.json
Created Feb 20, 2018
ACF Custom Database Tables plugin: Table definition JSON example for post type of 'post'
View example-table-definition-for-post-post-type.json
{
"name": "post_metadata",
"columns": [
"post_layout",
"read_time",
"show_stats"
]
}
@mishterk
mishterk / example-table-definition-for-page-post-type.json
Created Feb 20, 2018
ACF Custom Database Tables plugin: Table definition JSON example for post type of 'page'
View example-table-definition-for-page-post-type.json
{
"name": "page_metadata",
"relationship": "page",
"columns": [
"show_page_banner",
"page_layout",
"read_time"
]
}
@mishterk
mishterk / example-table-definition-for-user-type.json
Created Feb 20, 2018
ACF Custom Database Tables plugin: Table definition JSON example for user type
View example-table-definition-for-user-type.json
{
"name": "user_metadata",
"relationship": "user",
"columns": [
"profession",
"age",
"sex",
"is_member",
"instagram_url"
]
@mishterk
mishterk / example-bypassing-core-tables.php
Last active Feb 20, 2018
ACF Custom Database Tables plugin: Bypassing core meta tables example.
View example-bypassing-core-tables.php
<?php
/*
* This will prevent data from being stored in WordPress' core meta tables where a custom database table has been set up instead.
* This will not affect meta data that does not have a custom database table – that meta data will be stored as usual.
*/
add_filter('acfcdt/settings/bypass_post_meta_table', '__return_true');
@mishterk
mishterk / post-revision-meta.sql
Last active Apr 17, 2018
Useful SQL snippets for WordPress DB analysis
View post-revision-meta.sql
# Lists revision post IDs and their meta data count in descending order
SELECT post_id, count(*) AS count FROM wp_postmeta LEFT JOIN wp_posts ON post_id = ID WHERE post_type = 'revision' GROUP BY post_id ORDER BY count DESC;
# Tells you how many (total figure) meta rows belong to revision posts
SELECT count(*) as total_revision_meta FROM wp_postmeta INNER JOIN wp_posts ON post_id = ID WHERE post_type = 'revision';
# Lists the post_id number of revisions for posts in descending order by number of revisions
SELECT post_parent as post_id, count(*) AS n_revisions FROM wp_posts WHERE post_type = 'revision' GROUP BY post_parent ORDER BY n_revisions DESC;
View BenchMarker.php
<?php
/**
* Class BenchMarker
* @author Phil Kurth <phil@philkurth.com.au>
*
* A simple benchmarking utility. Easiest way to use this:
*
* BenchMarker::start();
*
* … run stuff here …
@mishterk
mishterk / example-table-definition-structure.json
Last active May 27, 2018
ACF Custom Database Tables plugin: Table definition JSON structure
View example-table-definition-structure.json
{
"name": "{custom_database_table_name}",
"relationship": "{post_type}",
"columns": [
"{acf_field_name_1}",
"{acf_field_name_1}",
"{acf_field_name_3}"
]
}
@mishterk
mishterk / acfcdt-relevanssi-support.php
Created Mar 11, 2019
How to add custom table data to Relevanssi's search index
View acfcdt-relevanssi-support.php
<?php
add_filter( 'relevanssi_content_to_index', 'acfcdt_relevanssi_support', 10, 2 );
add_filter( 'relevanssi_excerpt_content', 'acfcdt_relevanssi_support', 10, 2 );
function acfcdt_relevanssi_support( $content, $post ) {
/**
* Approach A (recommended): Using SQL to minimise database queries during Relevanssi's indexing process.
*/
global $wpdb;
@mishterk
mishterk / CustomOrderEmail.php
Last active Mar 19, 2019
Registering custom emails for WooCommerce
View CustomOrderEmail.php
<?php
class CustomOrderEmail extends \WC_Email {
// This is a just a simple example. See \WC_Email and child classes for more examples
public function __construct() {
$this->id = 'custom_order_email';
$this->title = 'Custom Order Email';
@mishterk
mishterk / 0-readme.md
Last active Apr 14, 2019
A basic, static view handler for WordPress
View 0-readme.md

Basic Usage

// set up
View::$view_dir = '/some/path';

// echos the view
View::render('relative/template', [
  'var1' => 'data',
  'var2' => 'more data'
You can’t perform that action at this time.