Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro-hide-acf-fields.php
Last active June 18, 2018 15:15 — forked from kimcoleman/pmpro_hide_acf_fields.php
This code will filter ACF fields added to custom templates using the post's membership requirements.
<?php
/**
* pmpro_hide_acf_fields This code will filter ACF fields added to custom templates using the post's membership requirements.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* https://www.advancedcustomfields.com/resources/acf-format_value/
*
* @param mixed $value Value which was loaded from the database
<?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 / 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 / filter-wordpress-admin-tables-with-sticky-headers.php
Created May 11, 2018 01:57 — forked from bryanwillis/filter-wordpress-admin-tables-with-sticky-headers.php
Filters wordpress admin tables live and sticks the headers to top on scroll. Do not use as is, problem with updating tables.
<?php
if ( !function_exists( 'stick_scroll_filter_wp_list_tables' ) ) {
function stick_scroll_filter_wp_list_tables() {
$screen = get_current_screen();
$base = $screen->base;
$type = $screen->post_type;
$name = $screen->id;
if ( (($base === 'edit') && ($type == 'page' || $type == 'post')) && (wp_script_is( 'jquery', 'done' )) )
{ ?>
<style type="text/css">
@pbrocks
pbrocks / wp-hooks-filter.php
Created May 11, 2018 01:57 — forked from bueltge/wp-hooks-filter.php
Instruments Hooks for a Page of WordPress. Outputs during the Shutdown Hook after add get-params: ?instrument=hooks
<?php
/*
Plugin Name: Instrument Hooks for WordPress
Plugin URI: http://bueltge.de/
Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook after add get-params <code>?instrument=hooks</code>.
Version: 0.0.1
Author: Frank B&uuml;ltge
Author URI: http://bueltge.de/
*/