Skip to content

Instantly share code, notes, and snippets.


Phil Kurth mishterk

View GitHub Profile
mishterk / acfcdt-prefix-post-title-with-meta-id.php
Created Nov 26, 2020
Prefixing a WordPress post title with the ID of an ACF Custom Database Tables meta data row.
View acfcdt-prefix-post-title-with-meta-id.php
add_action( 'acf/save_post', function ( $post_id ) {
global $wpdb;
// Get the meta ID from the custom DB table.
$table_name = 'my_custom_db_table';
$meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM {$wpdb->prefix}{$table_name} WHERE `post_id` = %d", $post_id ) );
// Choose a prefix format.
mishterk / advanced-forms-pro-prefill-fields-using-custom-data.php
Created Oct 21, 2020
How to use ACF Forms to manage non ACF controlled meta fields with Advanced Forms Pro.
View advanced-forms-pro-prefill-fields-using-custom-data.php
add_filter( 'af/field/prefill_value', 'prefill_form_field', 10, 4 );
* @param mixed $value
* @param array $field
* @param array $form
* @param array $args
mishterk / advanced-forms-pro-dynamic-user-editing.php
Last active Oct 21, 2020
Using a custom query parameter to dynamically specify a user ID for editing with Advanced Forms Pro.
View advanced-forms-pro-dynamic-user-editing.php
add_filter( 'af/form/args', 'afp_demo_support_dynamic_user_editing', 10, 2 );
* @param array $args
* @param array $form
* @return array
mishterk / register-wordpress-admin-columns.php
Created Oct 14, 2020
A quick snippet for registering custom admin columns for a post type in WordPress.
View register-wordpress-admin-columns.php
$post_type = 'my-post-type';
add_filter( 'manage_' . $post_type . '_posts_columns', function ( $defaults ) {
$defaults['custom-one'] = 'One';
$defaults['custom-two'] = 'Two';
return $defaults;
} );
mishterk / filter-repeater-sub-fields-before-insert-into-custom-database-tables.php
Last active Aug 4, 2020
How to filter repeater sub field values before they are stored in a custom table in ACF Custom Database Tables version 1.1
View filter-repeater-sub-fields-before-insert-into-custom-database-tables.php
add_filter( 'acfcdt/filter_value_before_update', 'xyz_filter_repeater_value_before_insert', 10, 3 );
* @param mixed $value The field value being stored.
* @param string $selector Either the post ID or a compound ACF selector depending on the object type. e.g; user_1.
* @param array $field_array The ACF field array.
* @return mixed
mishterk / _markup.html
Created May 20, 2020
Delegate jQuery event handlers when working with dynamic content. For more info see
View _markup.html
<div class="PostsGrid">
<!-- This is our div containing our post items -->
<div class="PostsGrid__posts">
<a href="#" class="PostsGrid__post"><!-- …Post grid item here… --></a>
<a href="#" class="PostsGrid__post"><!-- …Post grid item here… --></a>
<a href="#" class="PostsGrid__post"><!-- …Post grid item here… --></a>
<!-- A button to load more posts -->
mishterk / responsive-oembeds-class-for-wp.php
Created Jan 9, 2020
Wraps oEmbed output in markup which we can then target with CSS for fluid responsiveness.
View responsive-oembeds-class-for-wp.php
class ResponsiveOEmbeds {
* Regex patterns for matching specific embeddable URLs
* @var array
mishterk / acfcdt-how-to-activate-support-for-custom-field-type.php
Last active Jan 7, 2020
How to activate support for a custom field type when using the ACF Custom Database Tables plugin. For more information, see
View acfcdt-how-to-activate-support-for-custom-field-type.php
// This will register a custom field type as supported by the plugin.
// This affects table definition generation and can go in your functions.php
// file or a plugin.
add_filter( 'acfcdt/is_supported_field', function ( $is_supported, $field ) {
if ( $field['type'] === 'custom_acf_field_type' ) {
$is_supported = true;
View advanced-forms-pro-calculated-field-update-intercept.js
// This will intercept the rendered calculated field and insert the markup
// into an element with the id `#preview-container`
acf.addAction( 'af/field/calculated/value_updated', function( value, field, form ) {
// You may intercept the return values of specific fields by field name
acf.addAction( 'af/field/calculated/value_updated/name=FIELD_NAME', function( value, field, form ) {
// …
View unset-woocommerce-order-actions.php
add_filter( 'woocommerce_order_actions', function ( $actions ) {
// Unset whatever actions you don't need available in the
// WooCommerce order edit screen.
unset( $actions['send_order_details_admin'] );
unset( $actions['send_order_details'] );
unset( $actions['regenerate_download_permissions'] );
You can’t perform that action at this time.