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 / 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
<?php
class ResponsiveOEmbeds {
/**
* Regex patterns for matching specific embeddable URLs
*
* @var array
*/
@mishterk
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 https://support.hookturn.io.test/acf-custom-database-tables/doc/how-to-activate-support-for-a-custom-field-type/.
View acfcdt-how-to-activate-support-for-custom-field-type.php
<?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 ) {
$('#preview-container').html(value);
});
// 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
<?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'] );
View class-make-release-command.php
<?php
namespace WpLandingKitPlugin;
use WP_CLI;
use WP_CLI_Command;
View filter-acf-relationship-field-post-titles.php
<?php
add_filter( 'acf/fields/relationship/result/name=related_posts', function ( $title, WP_Post $post, $field_arr ) {
$posted_at = get_post_time( 'U', false, $post->ID );
$now = current_time( 'timestamp' );
$diff = human_time_diff( $posted_at, $now );
return $title . sprintf( ' (%s ago)', $diff );
}, 10, 3 );
View acf-load-field-options-example.php
<?php
add_filter( 'acf/load_field/name=countries', function ( $field ) {
$field['choices'] = [
'au' => 'Australia',
'nz' => 'New Zealand',
'gb' => 'United Kingdom',
'us' => 'United States',
// …
View php-alternative-syntax-example.php
<?php
get_header();
?>
<div class="Main">
<?php if ( have_posts() ): ?>
<?php while ( have_posts() ): ?>
<?php the_post(); ?>
View dump-all-defined-variables-formatted.php
<?php
echo '<pre>';
var_dump(get_defined_vars());
echo '</pre>;
View limit-login-attempts-unblock-all.sql
UPDATE wp_options SET option_value = '' WHERE option_name = 'limit_login_lockouts' LIMIT 1;
You can’t perform that action at this time.