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
@mircobabini
mircobabini / pmpro-conpd-avoid-complete-cancellation.php
Last active December 14, 2023 09:50
PMPro snippet to disable the "Cancel" button when the auto-renew option is turned off.
<?php
/**
* Remove "Cancel" button for cancelled subscriptions.
*
* The user is still able to cancel auto-renew, but can't completely cancel the membership.
*/
add_filter( 'pmpro_member_action_links', function ( $pmpro_member_action_links ) {
global $current_user;
// bail if cancel link has been removed by someone else
-- 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")
@mircobabini
mircobabini / lib.markerclusterer-2.1.2.js
Last active November 17, 2023 13:35
MarkerClustererPlus for Google Maps V3 / v2.1.2
/**
* @name MarkerClustererPlus for Google Maps V3
* @version 2.1.2 [May 28, 2014]
* @author Gary Little
* @fileoverview
* The library creates and manages per-zoom-level clusters for large amounts of markers.
* <p>
* This is an enhanced V3 implementation of the
* <a href="http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/"
* >V2 MarkerClusterer</a> by Xiaoxi Wu. It is based on the
<?php
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'wpml-legacy-horizontal-list-0' );
wp_dequeue_style( 'wpml-menu-item-0' );
} );
#!/usr/bin/env bash
# inspired by
# https://gist.github.com/JannikArndt/feb720c1f5d210b4820b880af23f2a07
# which was inspired by
# https://github.com/fwartner/mac-cleanup/blob/master/cleanup.sh
# https://gist.github.com/jamesrampton/4503412
# https://github.com/mengfeng/clean-my-mac/blob/master/clean_my_mac.sh
# https://github.com/szymonkaliski/Dotfiles/blob/master/Scripts/clean-my-mac
# http://brettterpstra.com/2015/10/27/vacuuming-mail-dot-app-on-el-capitan/ / https://github.com/pbihq/tools/blob/master/MailDBOptimiser.sh
(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() {