Skip to content

Instantly share code, notes, and snippets.

View kevincoop's full-sized avatar

Kevin Cooper kevincoop

View GitHub Profile
@kevincoop
kevincoop / wc-override-loop-show-cart-buttons.php
Created May 8, 2018 20:48 — forked from woogists/wc-override-loop-show-cart-buttons.php
[Frontend Snippets] Override loop template and show quantities next to add to cart buttons.
/**
* Override loop template and show quantities next to add to cart buttons
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$html .= woocommerce_quantity_input( array(), $product, false );
$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
$html .= '</form>';
@kevincoop
kevincoop / bootstrap-carousel.php
Created April 25, 2018 19:23
Bootstrap Carousel Integration with WordPress Loop. Displays post thumbnail and heading.
<?php
// NOTE: it's best practice to CLEAN YOUR INPUTS
// http://www.acunetix.com/websitesecurity/php-security-1.htm
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
@kevincoop
kevincoop / pug-bomb.php
Last active August 29, 2015 14:06 — forked from retgef/pug-bomb.php
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{