Skip to content

Instantly share code, notes, and snippets.

View nickdavis's full-sized avatar

Nick Davis nickdavis

View GitHub Profile
@nickdavis
nickdavis / acf-fields-repeater.php
Created November 10, 2016 10:59
Advanced Custom Fields > Repeater field example (set programatically)
<?php
add_action( 'acf/init', 'nd_acf_add_local_field_groups' );
/**
* Add Advanced Custom Fields programatically (Repeater field).
*
* @link https://www.advancedcustomfields.com/resources/register-fields-via-php/
* @link https://support.advancedcustomfields.com/forums/topic/register-two-locations-via-php-doesnt-work/
* @link https://support.advancedcustomfields.com/forums/topic/adding-additional-layout-to-flexible_content-field-in-child-theme/
*
@nickdavis
nickdavis / acf-fields-flexible-content.php
Created November 10, 2016 11:05
Advanced Custom Fields > Flexible Content field example (set programatically)
<?php
add_action( 'acf/init', 'nd_acf_add_local_field_groups' );
/**
* Add Advanced Custom Fields programatically (Flexible Content field).
*
* @link https://www.advancedcustomfields.com/resources/register-fields-via-php/
* @link https://support.advancedcustomfields.com/forums/topic/register-two-locations-via-php-doesnt-work/
* @link https://support.advancedcustomfields.com/forums/topic/adding-additional-layout-to-flexible_content-field-in-child-theme/
*
@nickdavis
nickdavis / responsive-menu.js
Created November 19, 2016 13:02
Always show expanded menu (and hide menu pulldown button) on larger screens in Remobile Pro theme by StudioPress (regular 'mobile' menu continues to work in correct way). As seen on GenesisWP.guide at the time of writing.
jQuery(function( $ ){
// Enable responsive menu icon for mobile
$(".nav-primary .genesis-nav-menu").addClass("responsive-menu").after('<div class="responsive-menu-icon"></div>');
$(".responsive-menu-icon").click(function(){
$(".nav-primary .genesis-nav-menu").slideToggle();
});
$(window).resize(function(){
@nickdavis
nickdavis / style.css
Created November 23, 2016 09:30
Fix for Kickstart Pro v1.3.6 (and earlier) Home Row #4 post alignment issue which may occur under certain configurations of the Genesis - Featured Posts widget. If you are unsure how to tweak the CSS of your website, see: https://themevalet.com/making-wordpress-css-adjustments-without-editing-theme/
.home-row4 .post:nth-child(odd) {
margin-left: initial;
}
.home-row4 .post:nth-of-type(odd) {
clear: left;
}
.home-row4 .post:nth-of-type(even) {
margin-left: 18%;
@nickdavis
nickdavis / functions.php
Last active December 16, 2016 14:06
Unserialize array in PHP (from Advanced Custom Fields PRO, in this example)
<?php
/**
* Get one value from an serialized array example
*
* @link http://stackoverflow.com/questions/8192789/getting-one-value-out-of-a-serialized-array-in-php#8192803
*
* @author Nick Davis
*
* @return array
@nickdavis
nickdavis / style.css
Created December 30, 2016 21:50
Add a comma after the testimonial name displayed by the Testimonials by WooThemes widget
.testimonials span[itemprop="name"]::after {
content: ",";
}
@nickdavis
nickdavis / settings.txt
Created January 3, 2017 19:52
HTML Post-Processing to fix mixed content CDN warning on WP Engine with Let's Encrypt SSL (goes in WP Engine > General Settings) in WordPress admin
#https?://mydomain.com.com/wp-(content|includes)# => https://mydomain.com/wp-$1
#https?://mydomain.com.com/blog/# => https://mydomain.com/wp-$1
#http://installname-wpengine\.netdna-ssl\.com# => https://installname-wpengine.netdna-ssl.com
@nickdavis
nickdavis / style.css
Last active January 12, 2017 16:18
How to right align the Kickstart Pro slider excerpt box
/* Find the following section in your theme's style.css file (should be around line 2353) and add the line below */
.home-top .widget,
html > body div.slide-excerpt-border {
background-color: #fff;
bottom: 50px;
font-size: 36px;
position: absolute;
right: 0; /* Add this line */
width: 40%;
@nickdavis
nickdavis / x-disable-wpe-sec.php
Created January 15, 2017 20:46
Disable WP Engine 'forced' https (SSL) redirection / AJAX breaking on non https site (WP Engine Support said it is a known issue happening on a few random installs). To install place in your mu-plugins folder (and, of course, remove when you want SSL in future)
<?php
add_action( 'widgets_init', 'wpe_remove_encourage_tls', 0 );
function wpe_remove_encourage_tls() {
remove_action( 'init', 'wpesec_encourage_tls' );
}
@nickdavis
nickdavis / jquery.plugin.js
Created January 17, 2017 08:47
Starting jQuery file structure from KnowTheCode.io
;(function($, window, document, undefined){
'use strict';
var init = function() {
}
/**
* Strictly not necessary because you're already loading this script in the
* footer, but sometimes there will be other scripts that didn't fire yet