Skip to content

Instantly share code, notes, and snippets.

View jtcote's full-sized avatar

Jayson T. Cote jtcote

View GitHub Profile
@jtcote
jtcote / gumwp_media_lib_show_author_uploads_only.php
Last active December 22, 2015 22:59
WP media library filter to display only logged in users uploaded files
<?php
/**
* Media Library - View logged in author uploads only
*
* @package GUM WP Child Theme Functions
* @author Jayson T. Cote <askjayson@gmail.com>
* @copyright Copyright (c) 2013, Jayson T. Cote
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
@jtcote
jtcote / 0_reuse_code.js
Created April 9, 2014 16:15
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
@jtcote
jtcote / css_resources.md
Created April 9, 2014 16:16 — 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

@jtcote
jtcote / gumwp_plugins_tribe_events_condtional.php
Last active August 29, 2015 13:58
WP plugin - tribe events conditional statements
<?php
/**
* Plugin Functions
*
* @category WP Plugins
* @author Jayson T. Cote
* @link https://tri.be/shop/wordpress-events-calendar/
*/
if (tribe_is_event() || tribe_is_event_category() || tribe_is_in_main_loop() || tribe_is_view() || 'tribe_events' == get_post_type() || is_singular( 'tribe_events' )) {
@jtcote
jtcote / gumwp_plugin_tribe_events_wootix_show_cost.php
Last active February 14, 2016 22:06
Tribe Events Plugin - wootickets add-on, show ticket cost and availability
add_filter( 'tribe_get_cost', 'gum_wootickets_tribe_get_cost', 10, 3 );
function gum_wootickets_tribe_get_cost( $cost, $postId, $withCurrencySymbol ) {
if ( empty($cost) && class_exists('TribeWooTickets') ) {
// see if the event has tickets associated with it
$wootickets = TribeWooTickets::get_instance();
$ticket_ids = $wootickets->get_Tickets_ids( $postId );
if ( empty($ticket_ids) ) {
return '';
@jtcote
jtcote / maintenance_redirect.php
Last active August 29, 2015 14:16
WP maintenance page redirect function
/***** MAINTENANCE *****/
//* Redirect for temp landing page
add_action( 'template_redirect', 'gum_redirect_maintenance_page' );
function gum_redirect_maintenance_page() {
$redirect = FALSE;
$page = home_url( '/maintenance/' ); //slug for wp page
if ( $redirect && !is_user_logged_in() && trim( $_SERVER['REQUEST_URI'], '/' ) != 'maintenance' && $_SERVER['REQUEST_URI'] != '/wp-admin/' ) :
wp_redirect( $page );
exit;
@jtcote
jtcote / woo_remove_caps.php
Created November 13, 2015 21:55
Remove all Woocommerce custom capabilities from DB after deactivating Woo
//Delete old custom capabilities
add_action( 'admin_init', 'gum_delete_woo_caps' );
function gum_delete_woo_caps(){
$delete_caps = array(
'assign_product_terms',
'assign_shop_order_terms',
'assign_shop_webhook_terms',
'delete_others_products',
'delete_others_shop_coupons',
'delete_others_shop_orders',
@jtcote
jtcote / functions.php
Created March 30, 2016 19:58
Set WP Admin > Settings > Reading robots access //* Discourage search engines from indexing this site
//* Discourage search engines from indexing this site
add_action('init', 'gumtheme_set_robots_access');
function gumtheme_set_robots_access(){
if(WP_ENV == 'staging' && get_option('blog_public') == '1')
update_option('blog_public', '0');
if(WP_ENV == 'production' && get_option('blog_public') == '0')
update_option('blog_public', '1');
}
@jtcote
jtcote / functions.php
Created April 5, 2016 16:32
Restore WP get_shortlink function in editor
//* Restore get shortlinks in editor
add_filter( 'get_shortlink', 'gumtheme_restore_wp_getshortlink' );
function gumtheme_restore_wp_getshortlink( $shortlink ) {
return $shortlink;
}
@jtcote
jtcote / plugin.php
Last active April 20, 2016 20:06
WooCommerce Simple Wholesale Price
//** Wholesale pricing based on 'wholesaler' role
// checks if the current user is capable to have the wholesale pricing
function gum_woo_wholesale_pricing_applies(){
return (bool) ( current_user_can('wholesaler') && ( !is_admin() || is_ajax() ) );
}
// wholesale price when available for both Simple & Variable product type
function gum_woo_wholesale_price_get( $product ) {
if( $product->is_type( array('simple', 'variable') ) && get_post_meta( $product->id, '_wholesale_price', true ) > 0 ){
return get_post_meta( $product->id, '_wholesale_price', true );