Skip to content

Instantly share code, notes, and snippets.

View digisavvy's full-sized avatar

Alex Vasquez digisavvy

View GitHub Profile
@digisavvy
digisavvy / children of children navigation
Created September 28, 2012 15:30
Custom Secondary Menu based on Bill Erickson's Code
/**
* Section Menu
* Displays the subpages of subpages of the current section
*
* @author Bill Erickson
* @link http://www.billerickson.net/custom-secondary-menu
*/
function be_section_menu_2() {
// Only run on pages
@digisavvy
digisavvy / gist:5807775
Last active December 18, 2015 15:58
Just a simple query put together using WP_Query. I used this on a site to list out course materials (custom post type) to the currently logged-in user. The user will only see courses that they have the capability to see. This is used in Conjunction with Jigoshop and the Groups/Subscriptions plugin from Itthinx.
<?php
$args = array(
'post_type' => 'courses',
'perm' => 'readable',
'order' => 'DESC',
'orderby' => 'title',
'posts_per_page' => -1
);
@digisavvy
digisavvy / Soliloquy Dynamic Slider
Last active December 19, 2015 01:48
This bit of code will generate a slider based on the post ID of the current page. Just drop this code into your template (functions.php, or elsewhere in your theme's files) and then upload files to your post (don't insert the images into the post, just upload them as attachments) and kaboom! Requires the Soliloquy Dynamic Slider Add-on (sold sep…
function add_image_to_content() {
global $post;
$dg_post_id = $post->ID;
if ( function_exists( 'soliloquy_dynamic' ) )
soliloquy_dynamic(
array( 'id' => "$dg_post_id"
) );
}
// The following are just action hooks and could be removed, if you're not hooking into anything specifically.
@digisavvy
digisavvy / gist:6359522
Created August 27, 2013 21:39
Allows dynamic switching of database credentials based on the current defined site URL.
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** DB switch statement */
$wufunc_getServName = $_SERVER['SERVER_NAME'];
switch ($i) {
case 'localdev.siteurl.com':
/** JH local */
@digisavvy
digisavvy / gist:9363261
Created March 5, 2014 08:23
Soliloquy Dynamic Slider. Retriever the Current Post ID, exclude an ACF Image ID from Slider
function add_image_to_content() {
global $post;
$imageArray = get_field('project_cover_image'); // Array returned by Advanced Custom Fields
$imageID = $imageArray['id']; // Grab, from the array, the 'alt'
// echo "$imageID";
$dg_post_id = $post->ID;
if ( function_exists( 'soliloquy_dynamic' ) ) soliloquy_dynamic( array( 'id' => "$dg_post_id", 'exclude' => "$imageID" ) );
<?php
add_filter( 'soliloquy_output_slide', 'tgm_soliloquy_custom_html', 10, 4 );
function tgm_soliloquy_custom_html( $html, $id, $image, $data ) {
// If the ID doesn't match the one we want to modify, return the default HTML output. Change 324 to your slider ID.
$slider_id = $data['id'];
ob_start(); ?>
<span class="social-m">
<?php $summary = get_field('short_description');?>
@digisavvy
digisavvy / gist:b2862b0c44b62807b72a
Created September 19, 2014 07:19
My Browser Sync config
// Browser Sync
gulp.task('browser-sync', function() {
browserSync.init({
files: ["./**/*.php", "./**./*.html"],
proxy: "my-project.dev"
});
});
@digisavvy
digisavvy / gulpfile.js
Created September 22, 2014 17:05
Gulpfile config
// Load plugins
var gulp = require('gulp'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
@digisavvy
digisavvy / if_user_caps
Created October 7, 2014 23:52
If user has caps
if ( current_user_can('moderate_comments') ) {
echo 'The current user can moderate comments';
} else {
echo 'Well, not everyone has nice hair like Alex!'
}
@digisavvy
digisavvy / composer.json
Last active August 29, 2015 14:07
composer.json
{
"name": "DigiSavvy Project Boilerplate",
"description": "Plugins and Theme for Use with DigiSavvy Projects",
"repositories":[
{
"type":"composer",
"url":"http://wpackagist.org"
},
{
"type": "package",