Skip to content

Instantly share code, notes, and snippets.

View polevaultweb's full-sized avatar

Iain Poulson polevaultweb

View GitHub Profile
<?php
add_filter('acf/settings/l10n', '__return_true' );
add_filter('acf/settings/l10n_textdomain', function( $textdomain ) {
return 'my-text-domain';
} );
@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' );
input#mce-EMAIL {
width: 300px;
margin-top: 2rem;
border: none;
padding: 1rem;
border-radius: 5px;
}
input#mc-embedded-subscribe {
padding: 1rem;
<?php
/**
* Plugin Name: Ninja Forms Uploads Connect Submissions
* Plugin URI: https://ninjaforms.com/extensions/file-uploads/
* Description: Debug plugin
* Version: 3.0
* Author: polevaultweb
* Author URI: https://polevaultweb.com
*/
@polevaultweb
polevaultweb / pvw_logging.php
Created September 25, 2020 09:59
WordPress mu-plugin for logging stacktraces in WordPress code
<?php
// Add this file to the wp-content/mu-plugins/ directory.
// It may need to be created if it doesn't exist
/**
* These constants must be set in wp-config.php
*
* define('WP_DEBUG', true);
* define('WP_DEBUG_LOG', true);
<?php
add_filter( 'igp_date_format', 'my_igp_date_format' );
function my_igp_date_format() {
return 'M d, Y';
}
<?php
add_filter( 'igp_image_post_taxonomy_terms', 'first_tag_to_category', 10, 4 );
function first_tag_to_category( $terms, $image, $post_id, $taxonomy ) {
$tags = isset( $image->tags ) ? maybe_unserialize( $image->tags ) : array();
if ( empty( $tags ) ) {
return $terms;
}
$first_tag = reset( $tags );
<?php
/**
* Get matching hashtag regex.
* Based on https://github.com/ngnpope/twitter-text-php
*
* @return string Regex pattern.
*/
protected function valid_hashtag_regex() {
$tmp = array();
<?php
add_filter( 'igp_image_post_taxonomy_terms', function ( $terms, $image, $post_id, $taxonomy ) {
$tags = isset( $image->tags ) ? maybe_unserialize( $image->tags ) : array();
if ( empty( $tags ) ) {
return $terms;
}
$tag_cat_mapping = array(
'whizalternatives' => 'alternatives',
@polevaultweb
polevaultweb / edd_best_sales_day.sql
Created June 25, 2020 15:13
Get your best sales day total for an Easy Digital Downloads WordPress store
SELECT Date(post_date) as Date,
Round(Sum(pm.meta_value - pm1.meta_value)) as Total
FROM wp_posts p
INNER JOIN wp_postmeta pm
ON p.id = pm.post_id
AND pm.meta_key = '_edd_payment_total'
INNER JOIN wp_postmeta pm1
ON p.id = pm1.post_id
AND pm1.meta_key = '_edd_payment_tax'
WHERE post_type = 'edd_payment'