Skip to content

Instantly share code, notes, and snippets.

View lkoudal's full-sized avatar

Lars Koudal lkoudal

View GitHub Profile
@thefrosty
thefrosty / freemius.php
Created January 12, 2024 17:39
Create an override function, as to bypass Freemius in some less than smart plugins.
<?php
declare(strict_types=1);
/**
* Create an override function, as to bypass Freemius in stupid plugins.
* @wordpress-muplugin
* Plugin Name: Freemius Killer
* Description: Global override for Freemius' "loader".
* Version: 1.0.0
@wpt00ls
wpt00ls / freemius-hooks.js
Created March 13, 2023 04:28
Freemius javascript hooks
/** On Freemius purchase complete **/
jQuery(document).on(
"wpt-freemius-checkout",
function(event, response, handler_args){
});
@etherealite
etherealite / WpCsp.php
Created September 12, 2022 01:16
Wordpress class to enable Content Security Policies
<?php
class WpCsp {
public function register(): void
{
add_filter('script_loader_tag', [$this, 'filter_script_loader_tag'], 3, 50);
add_filter('wp_inline_script_attributes', [$this, 'action_wp_inline_script_attributes']);
@devinsays
devinsays / ActionSchedulerHighVolume.php
Last active September 21, 2024 15:47
Modifications to Action Scheduler in order to run higher volumes of actions.
<?php
/**
* High volume modifications to Action Scheduler.
*
* Adapted from https://github.com/woocommerce/action-scheduler-high-volume/
*
* Increase Action Scheduler batch size, concurrency, timeout period, and claim action query
* ORDER BY to process large queues of actions more quickly on servers with more server resources.
*
* @package UniversalYums\ActionScheduler
<?php
/*
* The ActionScheduler WordPress plugin removes 20 complete & canceled status actions older than
* the filtered `action_scheduler_retention_period` value in seconds. In large scale applications
* generating more than 20 actions per minute on average, this can cause run away growth of the
* wp_actionscheduler_actions and wp_actionscheduler_logs tables.
*
* This gist adds a second cleanup pass every time AS normally cleans up & runs the queue.
*
* No support provided. No warranties expressed or implied.
@alanef
alanef / freemius.php
Last active December 1, 2021 14:58
Handle contact form
<?php
/** @var \Freemius $myfreemiustag_fs Freemius global object. */
global $myfreemiustag_fs;
if ( ! isset( $myfreemiustag_fs ) ) {
// Include Freemius SDK.
require_once 'mypath/includes/vendor/freemius/wordpress-sdk/start.php';
$myfreemiustag_fs = fs_dynamic_init( array(
'id' => '10000',
(function(){
try {
let observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "class") {
let attributeValue = jQuery(mutation.target).prop(mutation.attributeName);
if (attributeValue.includes('disabled')) {
jQuery('.fs-modal').find('.button-deactivate').removeClass('disabled');;
}
}
<?php
// AppSumo AJAX form submission
add_action( 'wp_ajax_nopriv_deo_appsumo_submission', 'deo_appsumo_submission' );
add_action( 'wp_ajax_deo_appsumo_submission', 'deo_appsumo_submission' );
function deo_appsumo_submission() {
check_ajax_referer( 'deo_ajax_nonce', 'nonce' );
@maheshwaghmare
maheshwaghmare / get-heavy-options.php
Created June 8, 2020 11:00
Get autoload heavy options from the WordPress `wp_options` ($wpdb->options) table.
<?php
/**
* Get autoload heavy options from options table
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_get_heavy_autoload_options' ) ) :
function prefix_get_heavy_autoload_options() {
@maheshwaghmare
maheshwaghmare / get-autoload-options-size.php
Created June 8, 2020 10:44
Get the size of all options which are set as `autoload_size` in the WordPress `wp_options` ($wpdb->options) table.
<?php
/**
* Get Autoload Options Size
*
* Get the size of all options which are set as `autoload_size` in the WordPress `wp_options` ($wpdb->options) table.
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/