Skip to content

Instantly share code, notes, and snippets.

View lkoudal's full-sized avatar

Lars Koudal lkoudal

View GitHub Profile
@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']);
@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
*/
@maheshwaghmare
maheshwaghmare / extract-links-from-content.php
Last active June 11, 2020 23:15
Get image & other links from the given content.
@maheshwaghmare
maheshwaghmare / custom-sortable-columns.php
Created May 22, 2020 09:38
WordPress - Add custom sortable columns for custom post type.
<?php
/**
* Add custom column
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_add_custom_column' ) ) :
function prefix_add_custom_column( $columns = array() ) {
@thetwopct
thetwopct / functions.php
Created February 8, 2020 12:33
Preload any footer JS files in the header
/**
* Preload any footer JS files in the header
*
* originally from: https://macarthur.me/posts/preloading-javascript-in-wordpress
*/
add_action('wp_head', function () {
global $wp_scripts;