Skip to content

Instantly share code, notes, and snippets.

View j-cam's full-sized avatar

Jamie Campbell j-cam

View GitHub Profile
@BenMorel
BenMorel / viewport-units-ios.scss
Last active March 11, 2022 13:15
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.
@mackensen
mackensen / gulpfile.js
Created October 21, 2014 15:35
This is an example gulpfile for managing a WordPress theme with a custom (non-LESS) CSS stylesheet. It includes tools for bumping the version and updating the version references.
// List of modules used.
var gulp = require('gulp'),
bump = require('gulp-bump'), // Generates new version.
argv = require('yargs')
.default('release', 'patch')
.argv, // CLI parser.
fs = require('fs'), // Used by bump.
semver = require('semver'), // Used by bump.
git = require('gulp-git'), // Git wrapper.
jshint = require('gulp-jshint'), // Lints JS.
@rev087
rev087 / gulpfile.js
Last active September 29, 2017 14:59
Gulp task to bump semver
// This gulpfile adds three tasks to bump the semver release: bump:major, bump:minor, bump:patch.
// First, it checks if the git repository is clean, and fails with an alert otherwise, then:
// - Update manifests (in this example, package.json and Info.plist)
// - Add manifests to the git stage
// - Commit changes in the manifests with the message "Prepare for vX.Y.Z"
// - Tag the release
// All that is left for the user to do is push the commit/tag to the remote repo with `git push --tags`
var gulp = require('gulp');
var semver = require('semver');
<?php
/*
Plugin Name: Custom Post Type Archive Menu Links
Plugin URI: http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/
Description: Easily Add Custom Post Type Archives to the Nav Menus
Version: 1.1
Author: soulseekah
Author URI: http://codeseekah.com
License: GPL2
@bradyvercher
bradyvercher / gist:4343518
Created December 20, 2012 07:19
WordPress: Filter default image sizes on read to set custom sizes in a theme. Based on approach by Tammy Hart: http://10up.com/blog/2012/12/enforcing-wordpress-image-sizes-within-your-theme/
<?php
add_filter( 'pre_option_thumbnail_crop', 'themename_default_image_options' );
add_filter( 'pre_option_thumbnail_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_thumbnail_size_w', 'themename_default_image_options' );
add_filter( 'pre_option_medium_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_medium_size_w', 'themename_default_image_options' );
add_filter( 'pre_option_large_size_h', 'themename_default_image_options' );
add_filter( 'pre_option_large_size_w', 'themename_default_image_options' );
function themename_default_image_options( $value ) {
@krogsgard
krogsgard / custom-field-advanced-body-class.php
Created June 20, 2012 16:57
add a body class based on a post's custom field value
<?php
// check for '_my_custom_field' meta key on pages and page parents and add a body class if meta value equals 'some-value'
add_filter('body_class','krogs_custom_field_body_class');
function krogs_custom_field_body_class( $classes ) {
global $post;
@antoniofrignani
antoniofrignani / gist:2867532
Created June 4, 2012 09:49
[WP] - Filter search results by post type
// http://wpsnipp.com/index.php/functions-php/filter-search-results-by-post-type/
function search_posts_filter( $query ){
if ($query->is_search){
$query->set('post_type',array('post','custom_post_type1', 'custom_post_type2'));
}
return $query;
}
add_filter('pre_get_posts','search_posts_filter');