Skip to content

Instantly share code, notes, and snippets.

View joelstransky's full-sized avatar

Joel Stransky joelstransky

View GitHub Profile
@joelstransky
joelstransky / functions::paginate_links_as_bootstrap.php
Last active May 25, 2017 20:10
Wraps WordPress paginate_links data in Twitter bootstrap pagination component
@joelstransky
joelstransky / functions::acf_settings_load_json.php
Created May 10, 2017 02:25
Advanced Custom Fields acf-json support for child themes
<?php
/**
* Child theme support for acf-json
* This will load acf-json from the parent theme first.
* That way if a child theme's acf-json folder contains a .json
* file with the same name as the parent, it will get loaded second
*/
add_filter('acf/settings/save_json', function() {
return get_stylesheet_directory() . '/acf-json';
});
@joelstransky
joelstransky / functions::paginate_links_as_bootstrap.php
Last active May 19, 2020 08:30
Display pagination in WordPress! using Twitter Bootstrap 3's pagination component
<?php
/**
* This is a temporary fix needed to repair the issue mentioned here:
* https://core.trac.wordpress.org/ticket/40090
*/
add_filter( 'wp_nav_menu_args', 'replace_default_menu_walker', 10, 1 );
function replace_default_menu_walker( $args ) {
if ( empty($args['walker']) )
$args['walker'] = new Walker_Nav_Menu_40090;
return $args;
@joelstransky
joelstransky / write-log.php
Created March 8, 2017 00:02
Write string, array or objects to log in php
<?php
if ( ! function_exists('write_log')) {
function write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
<?php
class F6_DRILL_MENU_WALKER extends Walker_Nav_Menu
{
/*
* Add vertical menu class
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"vertical menu\">\n";
@joelstransky
joelstransky / main.scss
Last active December 16, 2016 00:27
Sticky footer for WordPress
/**
* https://philipwalton.com/articles/normalizing-cross-browser-flexbox-bugs/
* 1. Avoid the IE 10-11 `min-height` bug.
* 2. Set `flex-shrink` to `0` to prevent Chrome, Opera, and Safari from
* letting these items shrink to smaller than their content's default
* minimum size.
*/
.Site {
display: flex;
flex-direction: column;
@joelstransky
joelstransky / bootstrap3-fixed-width-columns-mixins.scss
Created December 14, 2016 23:52
Bootstrap3 Fixed Width Columns mixin
// demo: http://codepen.io/JoelStransky/pen/VKPVAG
// breakpoint list ('column type', 'screen breakpoint', 'container width @ break point')
$breakpoints: ( ('xs', $screen-xs, $screen-xs), ('sm', $screen-sm, $container-sm), ('md', $screen-md, $container-md), ('lg', $screen-lg, $container-lg) );
@mixin make-fixed-grid() {
@each $item in $breakpoints {
@media (min-width: #{nth($item, 2)} ) {
// background: red;
@include make-fixed-grid-columns( $grid-columns, nth($item, 1), width, nth($item, 3) );
}
@joelstransky
joelstransky / get_field_object.php
Last active December 8, 2016 21:55
Display a single ACF field form view
<?php $field = get_field_object('field_123a456b78c90'); ?>
@joelstransky
joelstransky / step_1.php
Last active December 8, 2016 21:23
Inject non-acf fields during the rendering of acf-form
<?php
add_filter('acf/prepare_field', 'acf_prepare_field__inject_form_fields');
function acf_prepare_field__inject_form_fields( $field ) {
if ( ! is_admin() ) {
// look for the field AFTER where we want to inject something
// I used a switch to make it easier to react to multiple insertion points
switch ($field['key']) {
case 'field_123a456b78c90':
acf_form_inject__excerpt();
break;