Skip to content

Instantly share code, notes, and snippets.

View patrickgilmour's full-sized avatar

Pat Gilmour patrickgilmour

  • Self-employed
  • Brookyln, New York, USA
View GitHub Profile
@patrickgilmour
patrickgilmour / 0_reuse_code.js
Created June 19, 2014 14:38
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@patrickgilmour
patrickgilmour / javascript_resources.md
Created June 19, 2014 14:39 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@patrickgilmour
patrickgilmour / css_resources.md
Created June 19, 2014 14:39 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@patrickgilmour
patrickgilmour / wp_remove_capabilities.php
Created June 20, 2014 00:03
[WordPress] Remove custom capabilities in WordPress and Roles
/**
* Remove WordPress Capabilities
*
*/
add_action( 'admin_init', 'pgwp_clean_unwanted_caps' );
function pgwp_clean_unwanted_caps(){
$delete_caps = array('edit_issues', 'publish_issues', 'edit_other_issues', 'read_private_issues', 'delete_issue', 'edit_issue');
global $wp_roles;
@patrickgilmour
patrickgilmour / wp_get_nav_menu_object_name.php
Created June 22, 2014 20:52
[WordPress] Retrieve and show the name of a WordPress menu using #wp_get_nav_menu_object
/**
* Get the name of a WordPress menu using wp_get_nav_menu_object'
*
*/
add_filter( 'the_content' , 'pg_show_nav_menu_title' );
function pg_show_nav_menu_title ( $content ) {
// ID of the menu you want
$nav_menu_id = 13;
@patrickgilmour
patrickgilmour / woocommerce_show_posts_term_children.php
Created June 27, 2014 00:47
WooCommerce - show a product's single child category (term) from a defined Parent term in the WooCommerce Products taxonomy, 'product_cat'. Works on the Single Product Page.
<?php
/**
* Show a Product's Child Category of a Parent
*
* For example, A parent called "Brand" and a child called "Apple"
*/
add_action('woocommerce_after_single_product', 'my_woocommerce_after_single_product' );
function my_woocommerce_after_single_product () {
@patrickgilmour
patrickgilmour / google_analytics_exclude_local.js
Created July 7, 2014 22:07
Google Analytics - only track live/production site hits and don't send hits from localhost or other development domains.
<script>
// Replace MYLIVEDOMAIN.com with your domain.
// Google Analytics will now not receive hits from cloned development versions of your site on localhost etc.
// Also checkout `Block Yourself from Analytics` plugin for Chrome
// see also: http://stackoverflow.com/questions/1251922/is-there-a-way-to-stop-google-analytics-counting-development-work-as-hits
if (document.location.hostname.search("MYLIVEDOMAIN.com") !== -1) {
/* Google Analytics Code here */
/**
* WooCommerce enqueues 3 stylesheets by default. You can disable them all using:
*
* see http://docs.woothemes.com/document/disable-the-default-stylesheet/
*/
add_filter( 'woocommerce_enqueue_styles', '__return_false' );
@patrickgilmour
patrickgilmour / option_page_capability.php
Last active August 29, 2015 14:27
option_page_capability
<?php
/**
* Allow users with capability 'my_edit_settings' to edit the `my_plugin_options` settings of your Plugin
*
* This avoids giving them 'manage_options' capabilities
*
* @category WordPress
* @see https://codex.wordpress.org/Function_Reference/add_options_page
*
@patrickgilmour
patrickgilmour / gravity-forms-scroll-jump.php
Last active August 30, 2015 20:45
On submitting a Gravity Form (with id of 25), the response page will jump to top of the page minus 1 px
/**
* Gravity Forms - scroll to the top of page on form submit
*
* Returns a value of 1px from the top.
*/
add_filter( 'gform_confirmation_anchor_25', function() {
return 1;
} );