Skip to content

Instantly share code, notes, and snippets.

View thomasfw's full-sized avatar
🌴
Working Remotely

Tom thomasfw

🌴
Working Remotely
  • Fresh Systems Ltd.
  • United Kingdom
View GitHub Profile
@thomasfw
thomasfw / wpmail-enhanced-attachments.php
Last active March 20, 2024 23:47
Enable non-filesystem attachments with wp_mail()
<?php
/**
* Plugin Name: Enhanced WP Mail Attachments
* Plugin URI: https://gist.github.com/thomasfw/5df1a041fd8f9c939ef9d88d887ce023/
* Version: 0.1
*/
/**
* Adds support for defining attachments as data arrays in wp_mail().
@thomasfw
thomasfw / _theme.scss
Last active August 11, 2022 11:48
Wordpress Gutenberg - Auto register a theme's color palette by parsing the stylesheet (uses `editor-color-palette`)
// Gutenberg Color Palette
// These are merged Bootstrap 4 $theme-colors from global variables.
// The compiled rules are also read and cached in 'functions.php'
// so they don't need to be registered manually.
$gutenberg-colors: map-merge( (
'dark' : #1A1A1A,
'green' : #68b678,
'red' : #E2574D,
), $theme-colors );
@thomasfw
thomasfw / rcp-update-billing-cycle.php
Last active December 22, 2016 10:29
Restrict Content Pro: Update a member's billing cycle in Stripe when their subscription's expiration is changed in WP
<?php // https://github.com/thomasfw
// Add to your functions.php, or somewhere else..
// The 'rcp_set_expiration_date' hook is used instead of 'rcp_edit_member' so we can access the $old_date
add_action( 'rcp_set_expiration_date', 'my_update_stripe_billing_cycle', PHP_INT_MAX, 3 );
function my_update_stripe_billing_cycle( $member_id, $new_date, $old_date )
{
// Check/verify we're in the edit_member form (given the limitations on error output, changing the expiry elsewhere will not fire the request to Stripe)
if( !isset($_POST['rcp_edit_member_nonce']) || !wp_verify_nonce( $_POST['rcp_edit_member_nonce'], 'rcp_edit_member_nonce' ) ) return;