Skip to content

Instantly share code, notes, and snippets.

View polevaultweb's full-sized avatar

Iain Poulson polevaultweb

View GitHub Profile
@polevaultweb
polevaultweb / acf_pro_license_constant.php
Last active March 22, 2023 03:06
Define the Advanced Custom Fields Pro license key with a constant
<?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 December 5, 2018 10:55
Remove and UTM query strings after GA send so further shares don't have a conflated source
<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 ) {
@polevaultweb
polevaultweb / intagrate_maps.php
Last active November 14, 2018 11:12
Add Google Maps API key to Intagrate settings. Get a key from https://developers.google.com/maps/documentation/javascript/get-api-key
<?php
/**
* Add this file to `wp-content/mu-plugins/`
*/
add_filter( 'igp_google_maps_api_key', 'my_igp_google_maps_api_key' );
function my_igp_google_maps_api_key( $key ) {
return 'XXXXXX'; // replace with your key
}
<?php
namespace DeliciousBrains\Admin;
use DeliciousBrains\DBI;
class ACF {
public function init() {
add_filter( 'acf/settings/save_json', array( $this, 'get_local_json_path' ) );
<?php
add_filter( 'wpmdb_transfers_requests_options', function ( $options ) {
$hooks = new Requests_Hooks();
$hooks->register( 'curl.before_send', function ( $handle ) {
curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 0 );
curl_setopt( $handle, CURLOPT_TIMEOUT, 0 );
} );
@polevaultweb
polevaultweb / nf_saved_uploads.php
Created October 14, 2018 18:28
Workaround: Allow the temporary file on uploaded to be stored for a week for forms that use Save Progress
<?php
add_filter( 'ninja_forms_uploads_temp_file_delete_time', 'my_ninja_forms_uploads_temp_file_delete_time' );
function my_ninja_forms_uploads_temp_file_delete_time( $time ) {
return WEEK_IN_SECONDS;
}
<?php
// Always use PayPal test mode when on dev or staging
// The standard PayPal gateway controls IPN and other URLs even if using PayPal Express gateway.
add_filter( 'option_woocommerce_paypal_settings', function( $value ) {
// Maybe make this a better conditional with speciic environment constants
$value['testmode'] = defined( 'WP_DEBUG' ) && WP_DEBUG ? 'yes' : 'no';
return $value;
});
@polevaultweb
polevaultweb / list_hooks.sh
Created June 29, 2018 09:55
List all hooks and filters in a plugin
#!/usr/bin/env bash
cd `dirname $0`/../
rm -rf ./hooks
mkdir ./hooks
for d in ./src/*/ ; do
PLUGIN=$(basename "$d");
if [ "common" != $PLUGIN ];
@polevaultweb
polevaultweb / intagrate_date.php
Created June 8, 2018 08:37
Copy to /wp-content/mu-plugins/ (create the directory if needed)
<?php
function my_igp_date_format( $format ) {
return 'd. F Y | H:i Uhr';
}
add_filter( 'igp_date_format', 'my_igp_date_format' );
<?php
add_filter( 'wpmdb_preserved_options', 'my_wpmdb_preserved_options' );
function my_wpmdb_preserved_options( $options ) {
$options[] = 'blog_public';
return $options;
}