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 / 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 / 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
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 / 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 / Update remote repo
Last active Sep 16, 2019
Transfer repo from Bitbucket to Github
View Update remote repo
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@mandiwise
mandiwise / Stop tracking directory in Git repo
Last active Feb 11, 2019
A command to stop tracking and entire directory in a Git repo
View Stop tracking directory in Git repo
// Reference: http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git
$ git rm --cached -r <dir>
@mandiwise
mandiwise / Count lines in Git repo
Last active Sep 16, 2019
A command to calculate lines of code in all tracked files in a Git repo
View Count lines in Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@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 Mar 25, 2018
Create, display and save an URL field in a WP custom metabox
View functions.php
<?php
/**
* Add the metabox.
*/
function my_url_add_metabox() {
add_meta_box(
'my_url_section', // The HTML id attribute for the metabox section
'My URL Metabox Title', // The title of your metabox section
You can’t perform that action at this time.