Skip to content

Instantly share code, notes, and snippets.

View nicdford's full-sized avatar

Nic Ford nicdford

View GitHub Profile
@nicdford
nicdford / gist:9e715f9661aa6fd0f688cc03c6e8064b
Created May 4, 2016 18:05
Add Pods Shortcode Wizard to Beaver Builder Text Editer Module
function show_pods_modal_button() {
$fl_builder = pods_v('fl_builder', 'get', 'url');
if (empty($fl_builder)) {
pods_view( PODS_DIR . 'ui/admin/shortcode.php', compact( array_keys( get_defined_vars() ) ) );
echo '<a href="#TB_inline?width=640&inlineId=pods_shortcode_form" class="thickbox button" id="add_pod_button" title="Pods Shortcode"><img style="padding: 0px 6px 0px 0px; margin: -3px 0px 0px;" src="' . PODS_URL . 'ui/images/icon16.png" alt="' . __('Pods Shortcode' ,'pods') . '" />' . __('Pods Shortcode' ,'pods') . '</a>';
}
}
@nicdford
nicdford / page-resources.php
Created December 3, 2015 01:05
A Pods Example on running a loop inside a loop.
<?php
/**
* Template Name: Library Resource List
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package asotin_county_library
@nicdford
nicdford / filters
Last active February 24, 2016 19:33
filters setup
<?php
$things_to_do = pods( 'things_to_do' );
$limit = 9;
$params = array(
'fields' => array(
'region',
'activity',
'legend_items'
),
@nicdford
nicdford / gulpfile.js
Created September 14, 2015 16:55
An example of a setup gulpfile to help speed up setup time for gulp driven projects
var gulp = require('gulp');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var iconify = require('gulp-iconify');
var autoprefixer = require('gulp-autoprefixer');
var googleWebFonts = require('gulp-google-webfonts');
var browserSync = require( 'browser-sync' );
var reload = browserSync.reload;
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
@nicdford
nicdford / page-thing-to-do.php
Created July 30, 2015 16:31
A page using Pods filters() and other handy functions
<?php
/**
* Template Name: Things to Do
*
* @package visitnci
*/
get_header(); ?>
<div id="primary" class="content-area">
@nicdford
nicdford / custom_shortcode_w_pods
Last active November 23, 2019 20:53
A custom shortcode that makes a pods query and returns the value when the shortcode is called.
// Display Wine Items
function cc_display_wine( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'wine_id' => '1',
), $atts )
);
@nicdford
nicdford / disable_yoast_on_admin
Last active August 29, 2015 14:24
Conditionally disable the Yoast Page Analysis on admin edit screens.
/**
* Helper function to determine if we're on the right edit screen.
*
* @global $pagenow
* @param $post_types array() optional post types we want to check.
* @return bool
*/
function prefix_is_edit_screen( $post_types = '' ) {
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
@nicdford
nicdford / gist:3ecb45803e0935cf9b49
Created July 7, 2015 17:21
Control output of looped items
/*========== In Pods Template, Use Function on Field Output ==========*/
{@legend_items,add_icons}
/*========== Add to functions.php ==========*/
function add_icons($items) {
// loop through items
foreach ($items as $item) :
@nicdford
nicdford / config.rb
Created June 10, 2015 18:18
Compass Config file for SASS
# Compass is a great cross-platform tool for compiling SASS.
# This compass config file will allow you to
# quickly dive right in.
# For more info about compass + SASS: http://net.tutsplus.com/tutorials/html-css-techniques/using-compass-and-sass-for-css-in-your-next-project/
#########
# 1. Set this to the root of your project when deployed:
http_path = "/"
# 2. probably don't need to touch these
@nicdford
nicdford / gist:e842ae674435e071c6e1
Created May 19, 2015 17:48
Featured Images Inside a Loop with image information
// add to page template
<?php if ( has_post_thumbnail() ) : ?>
<?php $attachment_meta = wp_get_attachment( get_post_thumbnail_id() ); ?>
<div class="featured-image">
<img src="<?=$attachment_meta['src'];?>" alt="<?=$attachment_meta['alt'];?>" title="<?=$attachment_meta['title'];?>">
</div>
<?php endif; ?>
// add below function to functions.php