Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / undo-some-pmpro-gettext-filter.php
Created June 2, 2018 22:45
This gist will change back certain strings so the information on plugins.php will appear unchanged.
<?php
/**
* This filter will search your codebase for translatable strings and replace when an exact match is found.
*
* Here we're changing 'Membership' to 'Subscription' for Paid Memberships Pro.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*
<?php
/**
* Plugin Name: HM Autoloader
* Description: Provides a standard autoloader utility for the site to use
* Author: Human Made Limited
* Author URI: http://hmn.md/
*/
namespace HM;
@pbrocks
pbrocks / wp_mail.md
Created May 25, 2018 04:16 — forked from johnbillion/wp_mail.md
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 is accurate as of WordPress 4.9.

There are a few TODOs left. Please bear with me.

@pbrocks
pbrocks / my-pmpro-memberslist-extra-cols-header-startdate.php
Last active May 22, 2018 21:20 — forked from strangerstudios/my_pmpro_memberslist_extra_cols_header_startdate.php
Show start date of current membership on the PMPro members list.
<?php
/**
* Show start date of current membership on the members list
* and members list CSV export.
*
* By default, PMPro will show the "Join Date" on the members list,
* which is the date the WP user was created. If you need to know
* the date the user upgraded to their current level, you can
* add this code to your active theme's functions.php or a custom plugin.
*/
@pbrocks
pbrocks / a-gettext-filter-4-pmpro.php
Last active October 5, 2021 01:30
Sometimes we may want to change the wording of the language used in a plugin or theme, but don't want to edit code directly. A cleaner way to go is to use the built in filter that WordPress has called 'gettext'. This filter will search your codebase for translatable strings and replace when an exact match is found.
<?php
/**
* This filter will search your codebase for translatable strings and replace when an exact match is found.
*
* Here we're changing 'Membership' to 'Subscription' for Paid Memberships Pro.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*
@pbrocks
pbrocks / anonymize-comment-ip.php
Created May 20, 2018 05:02 — forked from soderlind/anonymize-comment-ip.php
GDPR: Anonymize WordPress user IP address in comments, supports IP4 and IP6
<?php
if ( true == apply_filters( 'is_gdpr', true ) ) {
add_filter( 'pre_comment_user_ip', function( $ip ) {
$packed_in_addr = inet_pton( $ip );
if ( 4 == strlen( $packed_in_addr ) ) {
return inet_ntop( inet_pton( $ip ) & inet_pton( '255.255.0.0' ) );
} else {
return inet_ntop( inet_pton( $ip ) & inet_pton( 'ffff:ffff:ffff:ffff:0000:0000:0000:0000' ) );
}
<?php
/**
* Sort meta-field company for PMPro member directory
*
* @param [type] $sqlQuery [description]
* @param [type] $levels [description]
* @param [type] $s [description]
* @param [type] $pn [description]
* @param [type] $limit [description]
* @param [type] $start [description]
#Check from Core PMPro
SELECT DISTINCT
mu.user_id,
mu.membership_id,
mu.startdate,
mu.enddate,
um.meta_value AS notice
FROM wp_pmpro_memberships_users AS mu
LEFT JOIN wp_usermeta AS um ON um.user_id = mu.user_id
AND um.meta_key = 'pmpro_expiration_notice'
@pbrocks
pbrocks / pmpro-pmproap-text-changes.php
Last active July 5, 2018 19:48
Add this your customizations plugin to alter text for PMPro Add On Packages.
<?php
/**
* Add to PMPro Customizations plugin. Be sure not to include the opening php tag in line 1.
*
* Add this your customizations plugin to alter text for PMPro Add On Packages.
*/
add_action( 'pmpro_invoice_bullets_top', 'pmproap_pmpro_invoice_links_top' );
add_action( 'pmpro_invoice_bullets_top', 'pmproap_pmpro_member_links_top' );
function pmproap_pmpro_invoice_links_top() {
$invoice_title = 'Purchased Add Ons';