Skip to content

Instantly share code, notes, and snippets.

View mattpramschufer's full-sized avatar

Matt Pramschufer mattpramschufer

View GitHub Profile
@mattpramschufer
mattpramschufer / isDuringBlackOutTime.php
Last active January 11, 2017 14:04
Figures out if the current time is during our black out period which we do not want to text users
<?php
/**
* Figures out if the current time is during our black out period which we do not want to text users
*
* @return bool
*/
static public function isDuringBlackOutTime() {
$currentTime = Carbon::now();
if($currentTime->format('A') == 'AM'){
@mattpramschufer
mattpramschufer / functions.php
Last active January 11, 2017 14:04
Add Offset to Wordpress RSS Feed
<?php
function rss_pre_get_posts($query) {
if (isset($_GET['days_past']) && is_feed()) {
$query->set('date_query', array(array('after' => $_GET['days_past'] . ' days ago',)));
}
if (isset($_GET['offset']) && is_feed()) {
$query->set('offset', $_GET['offset']);
}
if (isset($_GET['cat']) && is_feed()) {
$query->set('cat', $_GET['cat']);
@mattpramschufer
mattpramschufer / functions.php
Created January 11, 2017 14:04
Add Featured Image to RSS Feed Description and Create separate image Node in Wordpress,
<?php
// Add the image and thumbnail node to RSS feed
function add_rss_node_image_thumbnail() {
global $post;
if (has_post_thumbnail($post->ID)):
echo "<image>" . get_the_post_thumbnail_url($post->ID, 'medium') . "</image>\n";
endif;
}
add_action('rss2_item', 'add_rss_node_image_thumbnail');
@mattpramschufer
mattpramschufer / gist:957039753ea7a0bc3344e2f817304156
Created December 11, 2017 18:21 — forked from corsonr/gist:7215762
WooCommerce: Hide Checkout Fields For Virtual Products
<?php
add_filter( 'woocommerce_checkout_fields' , 'woo_remove_billing_checkout_fields' );
/**
* Remove unwanted checkout fields
*
* @return $fields array
*/
function woo_remove_billing_checkout_fields( $fields ) {
@mattpramschufer
mattpramschufer / gist:7645f0b61c8f4e2fe8921bedac259d0f
Created February 14, 2018 14:22
Extend WooCommerce Subscriptions Timeframes
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add custom billing & subscription intervals to WooCommerce Subscriptions
* Author: Matt Pramschufer
* Author URI: https://emoxie.com
* Version: 1.0
* License: GPL v2
*/
@mattpramschufer
mattpramschufer / woocommerce-subscription-export.php
Created February 14, 2018 14:35
Export WooCommerce Subscriptions Shipping Information
<?php
/*
Plugin Name: WooCommerce Subscription Export
Plugin URI: https://emoxie.com
Description: Custom plugin to export shipping data for Magazine Subscribers
Version: 1.0.0
Author: Matt Pramschufer
Author URI:
*/
defined( 'ABSPATH' ) or exit;
@mattpramschufer
mattpramschufer / functions.php
Created February 14, 2018 14:50
Adding custom fields to Wordpress User Profile
<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) { ?>
<h3><?php _e("LEGACY IMPORTED USER DATA", "blank"); ?></h3>
<table class="form-table">
<tr>
@mattpramschufer
mattpramschufer / functions.php
Created February 14, 2018 14:51
Modify WooCommerce Subscriptions Subscription Strings
<?php
add_filter('woocommerce_subscriptions_product_price_string', 'modified_subscription_strings', 10, 3);
function modified_subscription_strings($subscription_string, $product, $include){
switch($product->get_slug()){
case 'green-magazine-subscription':
case 'classic-farm-tractor-subscription':
case 'little-green-magazine-subscription':
return '$' . number_format($product->get_price(), 2, '.', '') . ' / year';
break;
@mattpramschufer
mattpramschufer / woocommerce-email-admin-on-address-change.php
Created February 14, 2018 15:27
Email Admin when WooCommerce Customer Changes Address
<?php
/**
* Plugin Name: WooCommerce Email Customer Address
* Description: Email the site admin when a customer changes their address
* Author: Matt Pramschufer
* Version: 1.0.0
*
*/
function greenmagazine_email_customer_address( $user_id ) {
@mattpramschufer
mattpramschufer / shortcode-purchased.php
Created June 28, 2018 14:37
DataTables Integration for WooCommerce Pay Per Post Plugin
<?php
/**
* Do not edit this file directly. You can copy this file to your theme directory
* in /your-theme/woocommerce-pay-per-post/shortcode-purchased.php
* The $purchased variable is a WP Posts Object of purchased posts.
*/
?>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<div class="wc-ppp-purchased-container">