Skip to content

Instantly share code, notes, and snippets.

View polevaultweb's full-sized avatar

Iain Poulson polevaultweb

View GitHub Profile
@polevaultweb
polevaultweb / wp-install-core-sub-dir.sh
Last active November 8, 2023 01:30
This script installs WordPress inside a sub directory
#!/bin/bash
# Installation:
## Download the script to your home directory
# Make sure it has execute permissions (`chmod +x wp-install-core-sub-dir.sh`).
# Install the script in one of the folders in your PATH. (`mv wp-install-core-sub-dir.sh /usr/local/bin/wp-install-core-sub-dir`)
#Usage:
<?php
add_filter('acf/settings/l10n', '__return_true' );
add_filter('acf/settings/l10n_textdomain', function( $textdomain ) {
return 'my-text-domain';
} );
@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(),
<?php
/**
* Generated by the WordPress Option Page generator
* at http://jeremyhixon.com/wp-tools/option-page/
*/
class MyExamplePlugin {
private $my_example_plugin_options;
<?php
namespace DeliciousBrains\Admin;
use DeliciousBrains\DBI;
class ACF {
public function init() {
add_filter( 'acf/settings/save_json', array( $this, 'get_local_json_path' ) );
@polevaultweb
polevaultweb / edd_perpetual_discounts.php
Last active June 28, 2022 08:31
EDD - Allow discounts to be set to apply to all renewals
<?php
// Add new Discount setting the to discount add and edit forms
add_action( 'edd_add_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_add_form' ) );
add_action( 'edd_edit_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_edit_form' ) );
// Handle saving the settings on form submission
add_filter( 'edd_update_discount', 'edd_perpetual_discounts_add_meta' );
add_filter( 'edd_insert_discount', 'edd_perpetual_discounts_add_meta' );
@polevaultweb
polevaultweb / nf_fu_acf_gallery.php
Created October 2, 2019 10:33
Use Ninja Forms File Upload fields as the source of an ACF Gallery field, when using the Post Creation addon.
@polevaultweb
polevaultweb / ssl.sh
Created January 31, 2018 07:16
Easily create local SSL certificates for development sites that work with you own Certificate Authority https://deliciousbrains.com/ssl-certificate-authority-for-local-https-development/
#!/bin/sh
if [ "$#" -ne 1 ]
then
echo "Usage: Must supply a domain"
exit 1
fi
DOMAIN=$1
# replace 'file' with the array key you want to extract
SELECT
SUBSTRING_INDEX(
SUBSTRING_INDEX(
SUBSTRING(pm.meta_value, ( INSTR( pm.meta_value, CONCAT( 'file', '";' ) ) + CHAR_LENGTH( 'file') + 1 ) ),
'"', 2 ),
'"', -1 ) as attachment_file
FROM wp_posts p
INNER JOIN wp_postmeta pm
ON p.ID = pm.post_id
@polevaultweb
polevaultweb / pvw_logging.php
Created September 25, 2020 09:59
WordPress mu-plugin for logging stacktraces in WordPress code
<?php
// Add this file to the wp-content/mu-plugins/ directory.
// It may need to be created if it doesn't exist
/**
* These constants must be set in wp-config.php
*
* define('WP_DEBUG', true);
* define('WP_DEBUG_LOG', true);