Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / rename-plugins-after-update.php
Last active November 28, 2022 18:40
This code works to update addon/extension plugin slugs during update from a premapped list. Code likely needs to be run in separate plugin/theme/mu-plugin/drop-in.
<?php
/**
* This code works to update addon/extension plugin slugs during update from a premapped list.
*
* Code likely needs to be run in separate plugin/theme/mu-plugin/drop-in.
*
* Tested Working On:
* - Single Site: Updates Page - Singe Plugin.
@danieliser
danieliser / functions.php
Created November 3, 2022 22:41
EDD Subscription Cancellation UX using Gravity Forms & WP Fusion
<?php
/**
* Assumptions:
* - Form ID is #28
* - Page ID is 406200
* - Fields include radio for reason & extra details where needed.
*/
@danieliser
danieliser / class-edd-sl-api-endpoint.php
Created October 24, 2022 18:23
EDD Software Licensing Optimized Endpoint
<?php
/**
* Plugin Name: EDD Software Licensing Endpoint
* Plugin URI: https://github.com/Frosty-Media/edd-sl-api-endpoint
* Description: Endpoint for Easy Digital Downloads Software Licensing add-on.
* Version: 1.0.1
* License: GPL version 2 or any later version
* Author: Danny van Kooten
* Author URI: https://github.com/dannyvankooten/
*/
@danieliser
danieliser / custom-email-template.php
Created October 22, 2022 09:49
Allow overloading WP email templates with custom wrappers and dynamic data
<?php
function get_custom_email_template() {
ob_start();
include __DIR__ . '/index.php';
$content = ob_get_clean();
ob_end_clean();
return $content;
}
@danieliser
danieliser / index.js
Last active August 25, 2022 22:54
broken @wordpress/core-data
import domReady from '@wordpress/dom-ready';
import { render } from '@wordpress/element';
import {
createRegistry,
RegistryProvider,
useSelect
} from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
@danieliser
danieliser / edd_perpetual_discounts.php
Created February 18, 2022 09:55 — forked from polevaultweb/edd_perpetual_discounts.php
EDD - Allow discounts to be set to apply to all renewals
<?php
add_filter( 'edd_update_discount', 'edd_perpetual_discounts_add_meta' );
add_filter( 'edd_insert_discount', 'edd_perpetual_discounts_add_meta' );
add_action( 'edd_edit_discount_form_before_use_once', 'edd_perpetual_discounts_setting', 10, 2 );
add_filter( 'edd_get_option_recurring_one_time_discounts', 'edd_perpetual_discounts_discounts' );
function edd_perpetual_discounts_add_meta( $meta ) {
$meta['use_renewals'] = 0;
@danieliser
danieliser / SyncGamesToNAS.ps1
Last active February 14, 2022 09:53
Sync Steam Library to NAS / Secondary Drive using PowerShell & Robocopy
<# Source game library #>
$dir = dir "D:\Game Libraries\Steam Library\steamapps\common\" | ?{$_.PSISContainer};
<# Mapped network drive / destination path. #>
$nasPath = "G:\Steam Library\steamapps\common";
$log = "E:\gamecopy.log";
Remove-Item $log;
$dir | ForEach-Object {
@danieliser
danieliser / helpers.php
Created November 22, 2020 10:00
Extracting shortcodes & attributes from content in WordPress. These helper functions can help extracting shortcodes and their attributes from WordPress content.
<?php
/**
* Extract shortcodes from content.
*
* @param string $content Content containing shortcodes.
*
* @return array Array of shortcodes found.
*/
function get_shortcodes_from_content( $content ) {
@danieliser
danieliser / eddsl-auto-activate.php
Created October 21, 2020 20:22 — forked from zackkatz/eddsl-auto-activate.php
Auto-activate sites on Easy Digital Downloads Software Licensing
<?php
add_filter( 'edd_sl_is_site_active', 'your_namespace_is_site_active_auto_activate_site', 10, 3 );
/**
* Allow active licenses to get updates if they're not at the limit, no matter what.
*
* @param false $is_active
* @param int $license_id
* @param string $passed_site_url
@danieliser
danieliser / force-pm-asset-caching-on.php
Created June 23, 2020 07:52
Force Popup Maker asset caching on.
<?php
add_action( 'wp_enqueue_scripts', 'custom_force_pm_asset_caching', 11 );
function custom_force_pm_asset_caching() {
wp_deregister_script( 'popup-maker-site' );
$cached = get_option( 'pum-has-cached-js' );
if ( ! $cached ) {
PUM_AssetCache::cache_js();
$cached = get_option( 'pum-has-cached-js' );