Skip to content

Instantly share code, notes, and snippets.

function pw_send_subscription_cancelled_to_admin( $sub_id, $subscription ) {
$email_to = '[email protected]';
$subject = 'Subscription Cancelled';
$message = 'Subscription cancelled for ' . $subscription->customer->email;
EDD()->emails->send( $email_to, $subject, $message );
}
add_action( 'edd_subscription_cancelled', 'pw_send_subscription_cancelled_to_admin', 10, 2 );
function pw_send_subscription_failed_to_admin( $subscription ) {
$email_to = '[email protected]';
@mintplugins
mintplugins / Debug to File Function
Created April 11, 2016 21:40
Write debugging text to a txt file
function pj_debug_to_txt_file( $debug_value, $filename, $append = true ){
$upload_dir = wp_upload_dir();
$filename = trailingslashit( $upload_dir['basedir'] ) . $filename . '.txt';
if ( false === $append ) {
// Blank out the log file if needed
@file_put_contents( $filename, '' );
@chmod( $filename, 0664 );
}
@mintplugins
mintplugins / MP Stacks PostGrid with Link in custom field
Created April 27, 2016 13:34
Make your posts in your PostGrid link to any URL in a custom field you choose
@mintplugins
mintplugins / JSX-Gutenberg-Blocks-without-Webpack.php
Created July 29, 2018 19:18
Build JSX Gutenberg Blocks without Webpack
<?php
function my_custom_gutenberg_block_enqueue_scripts(){
// Required thing to build Gutenberg Blocks
$required_js_files = array(
'wp-blocks',
'wp-i18n',
'wp-element',
'wp-editor'
);
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
registerBlockType( 'my-custom-gutenberg-block/static-jsx-example', {
title: __( 'Static Block Example with JSX' ),
icon: 'lock',
category: 'common',
edit() {
@mintplugins
mintplugins / disable-gutenberg.php
Last active May 8, 2020 14:53
Simple function to programmatically disable Gutenberg, and use the Classic Editor instead
if ( ! function_exists( 'disable_gutenberg' ) ) {
function disable_gutenberg() {
global $wp_filter;
$callbacks_array = $wp_filter['init']->callbacks;
foreach( $wp_filter as $tag => $priorities ) {
foreach( $priorities->callbacks as $priority => $callback_data ) {
foreach( $callback_data as $callback_function_name => $callback_function_data ) {
// Google Analytics
function my_website_google_analytics(){
// Don't track visits by logged-in administrators
if ( current_user_can( 'update_plugins' ) ) {
return;
}
?>
<!-- Replace me with Google Analytics Tracking Code -->
function get_my_plugin_data(){
// You'll likely replace this with some sort of API call home.
$plugin = json_decode(
json_encode(
array(
'new_version' => 89,
'stable_version' => 89,
'name' => 'My Fake Plugin',
'slug' => 'my-fake-plugin',
'url' => 'https://myfakeplugin.com',
<?php
function simple_theme_updater( $update_themes, $transient_name ) {
// We can use the active theme name, because if this code is running, we know this is the active theme.
$active_theme_slug = get_template();
$theme = json_decode(
json_encode(
array(
@mintplugins
mintplugins / edd-fix-child-licenses.php
Last active February 18, 2019 14:46
This is a simple plugin that can be used to set all child license keys expiration dates to their parent's. This is not for use in production, and is for example purposes only
<?php
/*
Plugin Name: Easy Digital Downloads - Fix child licenses
Description: Make the child licenses of all licensed bundles match the parent license expiration
Plugin URI: https://easydigitaldownlaods.com
Author: Phil Johnston
Author URI: https://easydigitaldownloads.com
Version: 1.0
License: GPL2
*/