Skip to content

Instantly share code, notes, and snippets.

Mandi Wise mandiwise

Block or report user

Report or block mandiwise

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mandiwise
mandiwise / Gravity Forms Custom Validation Example
Last active Aug 29, 2015
Checking to see if the field contained "Vancouver" and failing validation if it does.
View Gravity Forms Custom Validation Example
function my_custom_validation( $validation_result ) {
$form = $validation_result["form"];
// Sorry, you don't get to live in Vancouver...
if ( $_POST['input_1'] == 'Vancouver' ) {
$validation_result["is_valid"] = false;
foreach ( $form["fields"] as &$field ) {
@mandiwise
mandiwise / Launch Chrome with file access flag
Created Sep 13, 2014
Allows you to run LESS locally in Chrome by launching it from the terminal with the "allow-file-access-from-files" flag
View Launch Chrome with file access flag
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files
@mandiwise
mandiwise / highlighting.bash
Created Oct 9, 2015
Use Highlight to copy and paste code with syntax highlight.
View highlighting.bash
pbpaste | highlight -S css -O rtf --style moria | pbcopy
@mandiwise
mandiwise / hide-default-posts.php
Last active Nov 30, 2015
Hide post-related screens in the WordPress admin area, including Categories and Tags.
View hide-default-posts.php
<?php
/**
* Plugin Name: Hide Default Posts
* Plugin URI: https://gist.github.com/mandiwise/2ea571ae0773b340af5a
* Description: Hide post-related screens in the WP admin area, including Categories and Tags.
* Version: 1.0.0
* Author: Mandi Wise
* Author URI: http://mandiwise.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@mandiwise
mandiwise / functions.php
Last active Nov 30, 2015
Customize archive title in WP
View functions.php
<?php
/**
* Customize the Product archive title
*/
function red_archive_title( $title ) {
if ( is_post_type_archive( 'product' ) ) {
$title = 'Our Products Are Made Fresh Daily';
} elseif ( is_tax( 'product-type' ) ) {
$title = sprintf( '%1$s', single_term_title( '', false ) );
} elseif ( is_post_type_archive( 'testimonial' ) ) {
@mandiwise
mandiwise / functions.php
Last active Nov 30, 2015
Auto-populate page title of previously-viewed page in a Gravity Form field
View functions.php
<?php
function awi_autopopulate_workshop_title( $value ){
$referer_id = url_to_postid( wp_get_referer() );
$workshop_title = get_the_title( $referer_id );
return $workshop_title;
}
add_filter( 'gform_field_value_workshop_title', 'awi_autopopulate_workshop_title' );
// Usage:
// Add code to functions.php or similar
@mandiwise
mandiwise / functions.php
Last active Nov 30, 2015
Custom WP excerpts (with allowed HTML tags and custom read more link)
View functions.php
<?php
/**
* Customize excerpt length and style.
*
* @param string The raw post content.
* @return string
*/
function red_wp_trim_excerpt( $text ) {
$raw_excerpt = $text;
@mandiwise
mandiwise / nav.js
Last active Nov 30, 2015
A simple nav-bar locking jQuery script.
View nav.js
/**
* Navbar Locking
*/
$(function () {
var $window = $(window),
$mainNav = $('.main-navigation'), // nav wrapper element
stickyNavTop = $mainNav.offset().top;
@mandiwise
mandiwise / .bash_profile
Created Feb 19, 2016
Customize bash prompt with highlighted git branch
View .bash_profile
txtcyn=$'\e[0;36m' # Cyan
txtred=$'\e[0;31m' # Red
txtwht=$'\e[0;37m' # White
txtrst=$'\e[0m' # Text Reset
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[$txtcyn\]\$(parse_git_branch) \[$txtrst\]\$ " # fancify Terminal prompt
@mandiwise
mandiwise / Gravity Forms and Fancybox
Last active Mar 8, 2016
Using Gravity Forms with a modal and ajax
View Gravity Forms and Fancybox
<div id="voting-form" style="display:none">
<?php echo do_shortcode( '[gravityform id="6" title="false" description="false" ajax="true"]' ) ?>
</div>
<a href="#voting-form" class="fancybox button">Vote Now</a>
You can’t perform that action at this time.