Skip to content

Instantly share code, notes, and snippets.

View philbirnie's full-sized avatar

Phil Birnie philbirnie

View GitHub Profile
@philbirnie
philbirnie / gf-spam-prevent.php
Created May 29, 2021 14:46
Gravity Forms Spam Prevention
<?php
/**
* SPAM filtering function
*
* @param string[] $result Current Result. Contains two keys 'is_valid' and 'message'.
* @param mixed $value Field value -could be string or string[].
* @param array $form Form Entity.
* @param array $field Field Entity.
*
* @return array
@philbirnie
philbirnie / media-deduper.php
Last active October 8, 2020 15:41
Wordpress Image Deduper (Beta)
<?php
require_once 'wp-config.php';
print 'Starting Image De-duper' . "\n";
global $table_prefix;
$host = DB_HOST;
$user = DB_USER;
@philbirnie
philbirnie / .htaccess
Created August 23, 2020 17:19
Expires Tags Example
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
@philbirnie
philbirnie / enqueue-modified-time.php
Created August 23, 2020 17:16
Enqueing via last modified
<?php
function my_theme_get_version() {
return filemtime( get_template_directory() . '/assets/styles/main.css' );
}
function my_theme_setup_styles() {
wp_register_style(
'main',
get_template_directory_uri() . '/assets/styles/main.css',
@philbirnie
philbirnie / acf-single-taxonomy-filter.php
Last active July 14, 2020 21:38
Custom Filter for ACF (Show Fields on Single Taxonomy Page)
<?php
/**
* Function Add "Specific Category" Selector to ACF Interface
*
* @param array $choices Existing choices.
*
* @return array Updated choices.
*/
function esc_acf_location_rule_post_category( $choices ): array {
$choices['Forms']['specific_category'] = __( 'Specific Category', 'esc' );
@philbirnie
philbirnie / magento2.xml
Created April 11, 2018 19:04
Magento 2 Code Styles for PHPStorm
<code_scheme name="Magento 2" version="173">
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="ALIGN_PHPDOC_PARAM_NAMES" value="true" />
<option name="ALIGN_PHPDOC_COMMENTS" value="true" />
<option name="ALIGN_ASSIGNMENTS" value="true" />
<option name="PHPDOC_BLANK_LINES_AROUND_PARAMETERS" value="true" />
<option name="PHPDOC_WRAP_LONG_LINES" value="true" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
@philbirnie
philbirnie / digital-ocean-docker-percona.md
Created March 27, 2018 15:47
Setting Up a Percona Server on Digital Ocean with Outside Access

Percona Setup

Reminder Notes on how you set this up.

Digital Ocean

  1. Spin up a new Droplet using a Docker image under “One Click Apps”
  2. Shell into Droplet.
@philbirnie
philbirnie / setup.md
Created January 3, 2018 19:20
Set up Sendmail on Vagrant

Login to Vagrant box as root (or obivously better, set up in provision file)

apt-get install sendmail

Update Name Servers (use 8.8.8.8), so that domains can resolve

vim /etc/resolv.conf

@philbirnie
philbirnie / xdebug-nginx.md
Last active June 2, 2017 19:20
xDebug Setup Cheat Sheet (NGINX + PHP-FPM)

Xdebug Setup Instruction

Basic overview of how to set up Xdebug on an nginx + fpm server (building from source)

  1. Go to X-debug and download the appropriate version (wget works well) for your PHP version.

  2. Untar (tar vxfz FILENAME)

  3. cd into untarred directory

@philbirnie
philbirnie / update.bsh
Created May 16, 2017 19:57
Update Node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable