Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / custom-edd-sale-pricing-template-functions.php
Created October 31, 2024 09:19
Custom EDD Template Functions For Sale Pricing
function __get_wp_fusion_auto_applied_discount()
{
$user_tags = wpf_get_tags(false, true);
$args = [
"post_status" => "active",
"meta_query" => [
[
"key" => "wpf_settings",
@danieliser
danieliser / functions.php
Created October 25, 2024 07:19
Attempts at enabling Bricks Builder for Popup Maker, needed safe place to store the code outside Popup Maker core files for now.
<?php
/**
* Check if the current page is the Bricks editor preview.
*
* @return bool
*/
function pm_is_bricks_editor_preview() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
return isset( $_GET['bricks_preview'] );
}
@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 ) {