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 / 0-readme.md
Last active Sep 13, 2019
A basic example for querying data from custom tables created using ACF Custom Database Tables. For more info see https://hookturn.io/2019/09/how-to-use-acf-custom-database-tables-data-with-wp_query-objects/
View 0-readme.md

How to use your custom table data with WP_Object queries

This example illustrates how to query an array of post IDs from a custom DB table then use the array in a WP_Query.

This can be much faster than using meta queries on a WP_Query object, particularly if you are matching multiple fields.

@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
@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;
} );
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-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' => '',
@mishterk
mishterk / bypass-elementors-maintenance-mode.php
Last active Aug 22, 2019
Using this snippet, you can bypass Elementor's maintenance mode by adding ?bypass_maintenance=1 to the query string
View bypass-elementors-maintenance-mode.php
<?php
add_filter( 'pre_option_elementor_maintenance_mode_mode', function ( $option ) {
$parameter = 'bypass_maintenance'; // change this to whatever you like
if ( isset( $_GET['bypass_maintenance'] ) and $_GET['bypass_maintenance'] ) {
return 0; // needs to be falsy but not FALSE
}
@mishterk
mishterk / custom-wordpress-menu-items-template.php
Last active Sep 10, 2019
How to render WordPress menu items without a custom walker
View custom-wordpress-menu-items-template.php
<?php $menu_location = 'some_menu_location'; ?>
<?php if ( has_nav_menu( $menu_location ) ): ?>
<?php $menu_items = wp_get_nav_menu_items( wp_get_nav_menu_name( $menu_location ) ); ?>
<?php foreach ( $menu_items as $menu_item ): ?>
<a href="<?= $menu_item->url ?>"
target="<?= $menu_item->target ?: '_self' ?>"
class="<?= implode( ' ', $menu_item->classes ) ?>"><?= $menu_item->title ?></a>
<?php endforeach; ?>
<?php endif; ?>
@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'
@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 / 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;
You can’t perform that action at this time.