Skip to content

Instantly share code, notes, and snippets.

View donaldallen's full-sized avatar

Donald Allen donaldallen

View GitHub Profile
@donaldallen
donaldallen / gist:6308035
Created August 22, 2013 14:36
Foundation 4 short codes.
<?php
add_filter('widget_text', 'do_shortcode');
add_shortcode('row', function($attributes, $content = null) {
return '<div class="row">' . do_shortcode($content) . '</div>';
});
add_shortcode('column', function($attributes, $content = null) {
extract(shortcode_atts(
public function export()
{
$acf_posts = $_POST['acf_posts'];
foreach($acf_posts as $k => $v) {
$acfs = get_posts(array(
'numberposts' => -1,
'post_type' => 'acf',
'orderby' => 'menu_order title',
'order' => 'asc',
<?php
/**
* Advanced Custom Fields: Import Export
*
* Import and export values created by ACF.
*
* @package ACF_Import_Export
* @author Donald Allen <[email protected]>
* @link http://donaldallen.com
* @copyright 2013 Donald Allen
<?php
/**
* Advanced Custom Fields: Import Export
*
* @package ACF_Import_Export
* @author Donald Allen <[email protected]>
* @link http://donaldallen.com
* @copyright 2013 Donald Allen
*/
@donaldallen
donaldallen / gist:6540555
Last active December 22, 2015 22:29
WordPress: Tired of your shortcodes returning empty <p>s and random <br>s?
add_filter('the_content', function($content) {
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']',
']<br>' => ']'
);
return strtr($content, $array);
});
<?php
global $post;
$parents = get_post_ancestors($post->ID);
$id = ($parents) ? $parents[count($parents)-1]: $post->ID;
$parent = get_page($id);
wp_nav_menu(array(
'menu' => 'Sub Menu',
'submenu' => ucfirst($parent->post_name),
<nav class="contain-to-grid primary-sub-nav">
<div class="row">
<div class="large-12 columns">
<?php
global $post;
$parents = get_post_ancestors($post->ID);
$id = ($parents) ? $parents[count($parents)-1]: $post->ID;
$parent = get_page($id);
@donaldallen
donaldallen / wp_list_table
Created September 17, 2013 16:40
WP_List_Table example.
<?php
if ( ! class_exists('WP_List_Table')) {
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
class Events_List_Table extends WP_List_Table
{
function __construct()
{
global $status, $page;
@donaldallen
donaldallen / new_gist_file
Created September 17, 2013 20:17
Change WP Login and change the WP admin footer.
add_action('login_enqueue_scripts', function() {
wp_enqueue_style('login_css', get_template_directory_uri() . '/assets/css/login.css', false);
}, 10);
add_filter('login_headerurl', function() {
return home_url();
});
add_filter('login_headertitle', function() {
return get_option('blogname');
@donaldallen
donaldallen / gist:6695696
Created September 25, 2013 06:06
Need to fire a Google Analytics event on a form submit? Do it this way.
$('form').on('submit', function(e) {
e.preventDefault();
ga('send', 'event', 'buyers-guide', 'click', 'form-submitted');
setTimeout(functio() {
$(this).submit();
}, 300);
});