Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
@mircobabini
mircobabini / pmpro-stripe-webhook-permitted-applications.php
Created April 10, 2024 08:38
Define which Stripe webhook applications are permitted, then exclude any other webhook request coming through
<?php
/**
* Define which Stripe webhook applications are permitted, then exclude any other webhook request coming through.
*
* This is expecially useful when you have multiple websites sharing the same Stripe account.
* Then, you gonna see multiple webhook requests coming from different applications.
* This snippet will allow you to filter out the ones you don't want to process.
*/
<?php
/**
* Don't apply coupons to the product addons from PPOM for WooCommerce plugin.
ì */
add_filter( 'woocommerce_coupon_get_discount_amount', function ( $discount, $discounting_amount, $cart_item, $single, $coupon ) {
if ( ! function_exists( 'ppom_get_field_prices' ) || ! function_exists( 'ppom_price_get_addon_total' ) ) {
return $discount;
}
if ( $coupon->is_type( 'percent' ) ) {
@mircobabini
mircobabini / BeamNG.Hooks.md
Created December 15, 2023 16:00 — forked from codecat/BeamNG.Hooks.md
BeamNG Extension hooks

BeamNG Extension hooks

These are called in extensions. For example, the following module has some hooks:

local M = {}

M.onBeamNGTrigger = function(data)
	-- ...
end
<?php
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'wpml-legacy-horizontal-list-0' );
wp_dequeue_style( 'wpml-menu-item-0' );
} );
-- Simhub telemetry mod, Wotever 2023
local M = {}
local ip = "127.0.0.1"
local port = 9999
local updateRate = 100
local udpSocket = nil
local lastSimHubFrameData = nil
local abs = math.abs
local ffi = require("ffi")
(function () {
jQuery(function ($) {
// iubenda + vimeo: don't suppress dnt=1 videos
$(document).on('elementor/popup/show', sedweb_gdpr_unsuppress_vimeo_dnt);
sedweb_gdpr_unsuppress_vimeo_dnt();
function sedweb_gdpr_unsuppress_vimeo_dnt() {
let suppressedIframes = $('iframe[suppressedsrc]');
suppressedIframes.each(function () {
<?php
// these are the hooks sg-cachepress uses
add_action( 'upgrader_process_complete', 'clean_cache_after_critical_action' );
add_action( 'automatic_updates_complete', 'clean_cache_after_critical_action' );
add_action( '_core_updated_successfully', 'clean_cache_after_critical_action' );
// this has been found in litespeed-cache
add_action( 'admin_action_do-plugin-upgrade', 'clean_cache_after_critical_action' );
function clean_cache_after_critical_action() {
<?php
$courses_ids = get_posts( 'post_type=stm-courses&numberposts=-1&fields=ids' );
$fixed_curriculums = [];
foreach ( $courses_ids as $course_id ) {
$curriculum = get_post_meta( $course_id, 'curriculum', true );
$items = explode( ',', $curriculum );
if ( ! empty( $items ) && is_numeric( reset( $items ) ) ) {
<?php
add_filter( 'pmpro_include_billing_address_fields', function ( $include ) {
// if someone forced to include the fields
// but it's set to NOT include them in settings
// and Stripe Checkout is active
// and Stripe Checkout is set to include billing address fields on its checkout page
// => don't include them, bc it's a conflict with some other add-on or snippet
if ( $include && ! pmpro_getOption( "stripe_billingaddress" ) && 'checkout' === pmpro_getOption( 'stripe_payment_flow' ) && pmpro_getOption( 'stripe_checkout_billing_address' ) ) {
$include = false;
<?php
add_filter( 'iubenda_initial_output', function ( $final_output ) {
// https://www.tagmanageritalia.it/guida-gdpr-disabilitare-cookie-youtube-e-google-maps/
$final_output = str_replace( 'maps.google.com', 'maps.googleapis.com', $final_output );
$final_output = str_replace( 'www.google.com/maps', 'maps.googleapis.com/maps', $final_output );
return $final_output;
} );