Skip to content

Instantly share code, notes, and snippets.

@polevaultweb
polevaultweb / edd_perpetual_discounts.php
Last active June 28, 2022 08:31
EDD - Allow discounts to be set to apply to all renewals
<?php
// Add new Discount setting the to discount add and edit forms
add_action( 'edd_add_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_add_form' ) );
add_action( 'edd_edit_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_edit_form' ) );
// Handle saving the settings on form submission
add_filter( 'edd_update_discount', 'edd_perpetual_discounts_add_meta' );
add_filter( 'edd_insert_discount', 'edd_perpetual_discounts_add_meta' );
@davekiss
davekiss / gist:2639184ac066c53416b23c5a66f42d1e
Created February 2, 2019 17:44
EDD Weekly Domain Report via Email
/**
* Add a weekly email report that summarizes which domains that
* your products are being used on.
*/
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __('Once Weekly')
);
@ramiabraham
ramiabraham / gethooks
Last active April 21, 2023 13:38
Copy all actions and filters in a plugin and save to a file.
#!/bin/bash
#
# Prints all hooks in a dir to a .log file.
#
# Permissions issues:
# run: chmod +x gethooks
#
# gist: https://gist.github.com/ramiabraham/e8356e00130351ddcbe2c62125e6c52a
#
# Easy usage:
@johnbillion
johnbillion / wp_mail.md
Last active January 27, 2024 14:06
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@spivurno
spivurno / gw-gravity-forms-exclude-forms-form-list.php
Last active December 14, 2017 02:28
Gravity Wiz // Gravity Forms // Exclude Forms from Form List
<?php
/**
* Gravity Wiz // Gravity Forms // Exclude Forms from Form List
* http://gravitywiz.com
*/
add_filter( 'query', function( $query ) {
if( rgget( 'page' ) != 'gf_edit_forms' ) {
return $query;
}
@jchristopher
jchristopher / gist:53d98d2a21ffad14e440
Created June 22, 2015 14:32
Programmatically implement SearchWP synonyms (you do not need the Term Synonyms extension)
<?php
add_filter( 'searchwp_term_in', 'my_find_synonyms', 10, 2 );
add_filter( 'searchwp_and_logic', '__return_false' );
function my_find_synonyms( $term, $engine ) {
global $searchwp;
if( ! class_exists( 'SearchWP' ) || version_compare( $searchwp->version, '2.0.3', '<' ) ) {
return $term;
@rogerlos
rogerlos / searchwp_results_substitute_post_for_attachment.php
Created November 11, 2014 23:49
Wordpress SearchWP: Substitute Post for Attachment in Search Results
<?php
/**
* This function will see if a PDF or other "attachment" post-type returned by SearchWP
* is present in a custom field in a regular post, and will return that post instead. Note
* this will only process documents which are referenced via the "attachment" post type.
*
* For example, you may have a product specification PDF and would like it in the search
* results, but would rather people got to it by visiting the product page itself.
*
@Rarst
Rarst / append.php
Last active April 27, 2016 12:31
My xhprof/uprofiler setup, tweaked for WordPress and more easily profiling segments.
<?php
use Rarst\Profiler\Handler;
global $wp;
if ( Handler::$profiling && empty( $wp ) ) {
Handler::close();
}
@danielbachhuber
danielbachhuber / gist:8af274e2b7f21c8c3bb6
Created July 3, 2014 14:40
Post-style permalinks for your custom post types
<?php
/**
* Post-style permalinks for your custom post types
* e.g. %year%/%monthnum%/%day%/%postname%
*/
function dbx_get_post_types() {
return array(
// replace with your custom post types
'my-custom-post-type'
);
@jchristopher
jchristopher / gist:10730056
Created April 15, 2014 12:53
Throttle the SearchWP indexer
<?php
// pause the indexer for 1s in between passes
function my_searchwp_indexer_throttle() {
return 1;
}
add_filter( 'searchwp_indexer_throttle', 'my_searchwp_indexer_throttle' );