Skip to content

Instantly share code, notes, and snippets.

@mcguffin
mcguffin / acf-get-field-key.php
Last active Oct 5, 2021
WordPress Advanced Custom Fields get field key from field name
View acf-get-field-key.php
<?php
/**
* Get field key for field name.
* Will return first matched acf field key for a give field name.
*
* ACF somehow requires a field key, where a sane developer would prefer a human readable field name.
* http://www.advancedcustomfields.com/resources/update_field/#field_key-vs%20field_name
*
* This function will return the field_key of a certain field.
@mcguffin
mcguffin / .htaccess
Last active Sep 16, 2021
Generic Cachify .htaccess for ssl enabled sites
View .htaccess
# BEGIN CACHIFY
<IfModule mod_rewrite.c>
# ENGINE ON
RewriteEngine on
RewriteBase /
# set hostname directory
RewriteCond %{HTTPS} on
RewriteRule .* - [E=CACHIFY_HOST:https-%{HTTP_HOST}]
@mcguffin
mcguffin / .htaccess
Last active Sep 1, 2021
1und1: Cachify .htaccess for ssl enabled sites
View .htaccess
# BEGIN CACHIFY
<IfModule mod_rewrite.c>
# ENGINE ON
RewriteEngine on
RewriteBase /
# set hostname directory
RewriteCond %{HTTPS} on
RewriteRule .* - [E=CACHIFY_HOST:https-%{HTTP_HOST}]
RewriteCond %{HTTPS} off
@mcguffin
mcguffin / composer.json
Last active Jul 21, 2021
PHPCS WordPress security check
View composer.json
{
"name": "mcguffin/wp-package-security-check",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"homepage": "https://gist.github.com/mcguffin/255909d4d7fcc241fe63363012553268",
"require": {
"composer/installers": "~1.2"
},
"require-dev": {
"squizlabs/php_codesniffer": "*",
@mcguffin
mcguffin / acf-quick-edit-rgba-color-picker.php
Last active Jun 29, 2021
ACF RGBA Color Picker + ACF Quick Edit Fields
View acf-quick-edit-rgba-color-picker.php
<?php
/**
* Bringing ACF RGBA Color Picker and ACF QuickEdit Fields together.
* https://github.com/mcguffin/acf-quick-edit-fields
* https://wordpress.org/plugins/acf-rgba-color-picker/
*/
/**
* Add field support
*/
@mcguffin
mcguffin / git-release
Last active Jan 20, 2021
Shell script to create GitHub release
View git-release
#!/bin/bash
MESSAGE="0"
VERSION="0"
DRAFT="false"
PRE="false"
BRANCH="master"
GITHUB_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
# get repon name and owner
@mcguffin
mcguffin / git-release.py
Last active Nov 16, 2020
Python script to create GitHub release
View git-release.py
#!/usr/bin/env python3
import argparse, glob, json, re, subprocess, urllib.request, os, sys
class version_number:
major=0
minor=0
release=0
View 000-fix-core-42656.php
<?php
/*
Plugin Name: Fix core issue 42656
Description: Fix PHP Warning undefined index pagenow on login popup. Place this into wp-content/mu-plugins/
Author: McGuffin
Author URI: http://github.org/mcguffin
Version: 0.0.1
*/
@mcguffin
mcguffin / polylang-fix-acf-relational.php
Created Oct 26, 2015
Polylang: Fix missing value on ACF relational fields
View polylang-fix-acf-relational.php
<?php
/*
Plugin Name: Polylang: Fix missing value on ACF relational fields
Plugin Description: ACF relational Field value for translated posts types where not displayed when Admin langauge differs from post language.
Author: Jörn Lund
Author URI: http://github.org/mcguffin
Version: 0.0.1
*/
View acf-nested-repeater.json
[
{
"key": "group_5a3593ed877c0",
"title": "Nested Repeaeter",
"fields": [
{
"key": "field_5a3593f76e021",
"label": "Outer",
"name": "outer",
"type": "repeater",