Skip to content

Instantly share code, notes, and snippets.

Iain Poulson polevaultweb

Block or report user

Report or block polevaultweb

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
@polevaultweb
polevaultweb / wpum_resize_avatars.php
Created Oct 15, 2019
WP User Manager - Resize avatar uploads to a specific size
View wpum_resize_avatars.php
<?php
add_filter( 'wpum_upload_file_pre_upload', 'wpum_resize_avatar_images', 10, 2 );
function wpum_resize_avatar_images( $file, $args ) {
if ( ! isset( $args['file_key'] ) || 'user_avatar' !== $args['file_key'] ) {
return $file;
}
$editor = wp_get_image_editor( $file['tmp_name'] );
if ( is_wp_error( $editor ) ) {
@polevaultweb
polevaultweb / redirect_to_account_tab.php
Created Oct 14, 2019
Redirect to the account tab after saving the setting in WP User Manager
View redirect_to_account_tab.php
<?php
add_filter( 'wp_redirect', function ( $location ) {
if ( ! isset( $_POST['wpum_form'] ) || 'profile' !== $_POST['wpum_form'] ) {
return $location;
}
if ( empty( $_POST['_wp_http_referer'] ) ) {
return $location;
}
@polevaultweb
polevaultweb / nf_fu_acf_gallery.php
Created Oct 2, 2019
Use Ninja Forms File Upload fields as the source of an ACF Gallery field, when using the Post Creation addon.
View nf_fu_acf_gallery.php
@polevaultweb
polevaultweb / nf_fu_acf_gallery.php
Created Oct 2, 2019
Use Ninja Forms File Upload fields as the source of an ACF Gallery field, when using the Post Creation addon.
View nf_fu_acf_gallery.php
@polevaultweb
polevaultweb / ninja-forms-uploads-dropbox-filename.php
Created Jul 22, 2019
Make sure any uploads to Dropbox don't have the random timestamp prefix.
View ninja-forms-uploads-dropbox-filename.php
<?php
add_filter( 'ninja_forms_uploads_dropbox_filename', 'my_dropbox_filename', 10, 2 );
function my_dropbox_filename( $filename, $original_filename ) {
return $original_filename;
}
@polevaultweb
polevaultweb / ninja-forms-uploads-debugger.php
Created May 16, 2019
Debug data about Ninja Forms File Uploads, install as a normal plugin or as an mu-plugin.
View ninja-forms-uploads-debugger.php
<?php
/**
* Plugin Name: Ninja Forms Uploads Debugger
* Plugin URI: https://ninjaforms.com/extensions/file-uploads/
* Description: Debugger plugin
* Version: 3.0
* Author: polevaultweb
* Author URI: https://polevaultweb.com
*/
@polevaultweb
polevaultweb / dbi-woo-slack-command.php
Last active May 15, 2019
WooCommerce Slack Slash Command WordPress plugin
View dbi-woo-slack-command.php
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'dbi', 'slash-woo/', array(
'methods' => 'POST',
'callback' => 'slack_woo_command',
) );
} );
function slack_woo_command( $request ) {
$command = filter_input( INPUT_POST, 'command', FILTER_SANITIZE_STRING );
View wpmdb_process_column_as_binary.php
<?php
add_filter( 'wpmdb_process_column_as_binary', function( Bool $process_as_binary, stdClass $struct ) {
return ( true == $process_as_binary ) ? true :
in_array( strtolower( trim( $struct->Type ) ), [
'geometry',
'point',
'linestring',
'polygon',
'multipoint',
@polevaultweb
polevaultweb / acf_pro_license_constant.php
Last active Sep 19, 2019
Define the Advanced Custom Fields Pro license key with a constant
View acf_pro_license_constant.php
<?php
function my_filter_acf_pro_license_option( $pre ) {
if ( ! defined( 'ACF_PRO_LICENSE' ) || empty( ACF_PRO_LICENSE ) ) {
return $pre;
}
$data = array(
'key' => ACF_PRO_LICENSE,
'url' => home_url(),
@polevaultweb
polevaultweb / remove_utms_pageview.js
Created Dec 5, 2018
Remove and UTM query strings after GA send so further shares don't have a conflated source
View remove_utms_pageview.js
<script>
function my_remove_utms() {
if ( window.location.search.indexOf( 'utm_' ) != -1 && history.replaceState ) {
var clean_search = window.location.search.replace( /utm_[^&]+&?/g, '' ).replace( /&$/, '' ).replace( /^\?$/, '' );
history.replaceState( {}, '', window.location.pathname + clean_search + window.location.hash );
}
}
if ( -1 === document.cookie.indexOf( 'my_admin=1' ) ) {
(function( i, s, o, g, r, a, m ) {
You can’t perform that action at this time.