Skip to content

Instantly share code, notes, and snippets.

Phil Kurth mishterk

View GitHub Profile
@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 / 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 / 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'
View procedural-wp-rest-api-get-requests.php
<?php
/**
* Really simple GET request
*/
add_action( 'rest_api_init', function ( WP_REST_Server $wp_rest_server ) {
register_rest_route( '/custom-namespace/v1', '/no-param', [
'methods' => 'GET',
'callback' => function ( WP_REST_Request $request ) {
if ( $throw_error = false ) {
@mishterk
mishterk / register-acf-options-page.php
Last active Sep 7, 2019
How to register options pages in Advanced Custom Fields for WordPress (ACF). See https://www.awesomeacf.com/snippets/register-options-page/ for more details.
View register-acf-options-page.php
<?php
// register a top-level options page
if ( function_exists( 'acf_add_options_page' ) ) {
acf_add_options_page( [
'page_title' => 'My Options Page',
'menu_title' => 'My Options Page',
'menu_slug' => 'my-options-page',
'capability' => 'edit_posts',
'parent_slug' => '',
View register-acf-json-load-directory.php
<?php
add_filter( 'acf/settings/load_json', function ( $paths ) {
$paths[] = get_template_directory() . '/some/custom/dir';
return $paths;
} );
@mishterk
mishterk / register-basic-wysiwyg-toolbar-for-acf.php
Last active Sep 7, 2019
Register custom WYSIWYG field toolbar options with Advanced Custom Fields for WordPress (ACF).
View register-basic-wysiwyg-toolbar-for-acf.php
<?php
add_filter( 'acf/fields/wysiwyg/toolbars', function ( $toolbars ) {
$toolbars['Bare'] = [];
$toolbars['Bare'][1] = [ 'forecolor', 'link', 'strikethrough', 'bold', 'italic' ];
return $toolbars;
} );
@mishterk
mishterk / ACFCDTvOneDotZeroDotAnyGetFieldInterceptBypass.php
Last active Sep 11, 2019
A hotfixed solution for bypassing custom database tables when using ACF's get_field() function. This will ONLY work with 1.0.x versions of the plugin. Version 1.1 will include built-in support for this capability.
View ACFCDTvOneDotZeroDotAnyGetFieldInterceptBypass.php
<?php
use ACFCustomDatabaseTables\Intercept\ACFGetFieldIntercept;
use ACFCustomDatabaseTables\Vendor\Pimple\Container;
/**
* Class ACFCDTvOneDotZeroDotAnyGetFieldInterceptBypass
*
* This provides a 'hotfixed' approach for disabling custom database table intercept when using ACF's get_field()
* function. This will only work with version 1.0.x versions of the plugin as a built-in tool will be available in
You can’t perform that action at this time.