Skip to content

Instantly share code, notes, and snippets.

View tankbar's full-sized avatar

Tankbar tankbar

View GitHub Profile
@tankbar
tankbar / wc-add-images-order-email-table.php
Created September 29, 2017 12:20 — forked from bekarice/wc-add-images-order-email-table.php
Add images to WooCommerce emails
// Edit order items table template defaults
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),
'show_download_links' => $show_download_links,
@tankbar
tankbar / functions.php
Created January 24, 2017 08:00 — forked from gregrickaby/functions.php
Show me dev info in WordPress
add_action( 'wp_footer', 'wds_debug' );
/*
* Show me some dev info during development! DELETE ME BEFORE GOING LIVE!!!
*
*/
function wds_debug() {
global $template; ?><br />
<?php echo $template; ?><br />
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds<br />
Server load: <?php $load = sys_getloadavg(); echo $load[0]; ?>%<br />
@tankbar
tankbar / display-social-media-counts.php
Created January 24, 2017 07:58 — forked from gregrickaby/display-social-media-counts.php
Display Likes, Tweets, Pageviews, and Comment Counts. Use transient cache to store data for 30 minutes.
<?php
/**
* Get tweet count from Twitter API (v1.1)
*/
function wds_post_tweet_count( $post_id ) {
// Check for transient
if ( ! ( $count = get_transient( 'wds_post_tweet_count' . $post_id ) ) ) {
@tankbar
tankbar / jquery-ajax-modal.js
Created January 24, 2017 07:57 — forked from gregrickaby/jquery-ajax-modal.js
Simple jQuery Ajax Modal with fail-safe.
/**
* Loading Modal
*/
$(body).on({
// When ajaxStart is fired, add 'loading' to body class
ajaxStart: function() {
$(this).addClass('modal-loading');
@tankbar
tankbar / grd_functions.php
Created January 24, 2017 07:56 — forked from gregrickaby/grd_functions.php
A "must use" plugin to help save theme-agnostic functions
<?php
/**
* Must-Use Functions
*
* A class filled with functions that will never go away upon theme deactivation.
*
* @package WordPress
* @subpackage GRD
*/
class GRD_Functions {
/**
* Be sure to include library scripts in this order. Can be placed either
* in the header or footer.
*/
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-infinitescroll/2.0b2.120519/jquery.infinitescroll.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/masonry/3.1.2/masonry.pkgd.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js"></script>
@tankbar
tankbar / functions.php
Created January 24, 2017 07:54 — forked from gregrickaby/functions.php
Customize the excerpt length, strip tags, append, and change the "Read More" text
<?php
// DO NOT INCLUDE OPENING PHP TAG
/**
* Customize the excerpt length and strip tags
*/
function custom_excerpt ( $text ) {
global $post;
@tankbar
tankbar / remove-emoji-support.php
Created January 24, 2017 07:52 — forked from gregrickaby/remove-emoji-support.php
Remove WordPress Emoji Support
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php
/**
* Remove emoji support.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@tankbar
tankbar / functions.php
Created January 24, 2017 07:51 — forked from gregrickaby/functions.php
Filter a custom post type after it's been registered
<?php
/**
* Filter the Products CPT to register more options.
*
* @param $args array The original CPT args.
* @param $post_type string The CPT slug.
*
* @return array
*/
@tankbar
tankbar / gravity-forms-ajax-spinner
Last active September 14, 2016 12:25
Change the Default Gravity Forms AJAX Spinner - If you want to change the default Gravity Forms AJAX spinner, Gravity Forms provides us with a filter to do so: gform_ajax_spinner_url. Paste the following code into your installed and activated custom snippets plugin.
add_filter( 'gform_ajax_spinner_url', 'cwwp_custom_gforms_spinner' );
/**
* Changes the default Gravity Forms AJAX spinner.
*
* @since 1.0.0
*
* @param string $src The default spinner URL
* @return string $src The new spinner URL
*/
function cwwp_custom_gforms_spinner( $src ) {