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
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;
View class-view.php
<?php
class View {
public static $view_dir = '';
/**
* Render View Template With Data
@mishterk
mishterk / app.php
Last active Oct 22, 2019
An example illustrating PHP's ability to return data from included files. For more info, see https://philkurth.com.au/tips/included-files-can-return-values-which-is-a-great-way-to-manage-app-configurations/
View app.php
<?php
$config = include 'config.php';
echo $config['some']; // 'config'
You can’t perform that action at this time.