Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro-usermeta-in-email-data.php
Created March 19, 2018 15:50
This filter function creates a variable from Usermeta to be used with PMPro emails.
/**
* This filter function creates a variable from Usermeta to be used with PMPro emails.
*
* The function returns a variable prepared for the special html syntax within PMPro emails. In this example, the value of the array key 'favorite_color' is returned and can be used in emails with the html placeholder !!favorite_color!!.
*/
function pmpro_usermeta_in_email_data( $usermeta, $email ) {
global $current_user;
$usermeta['favorite_color'] = get_user_meta( $current_user->ID, 'favorite_color', false );
return $usermeta[0];
@pbrocks
pbrocks / basic_meta_box.php
Created March 23, 2018 02:26 — forked from thefuxia/basic_meta_box.php
WordPress meta box example
<?php # -*- coding: utf-8 -*-
declare( encoding = 'UTF-8' );
/**
* Plugin Name: Basic Meta Box
* Description: Create a simple meta box. Demo plugin.
* Version: 2012.02.05
* Required: 3.3
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: GPL
@pbrocks
pbrocks / pmpromyCRED.php
Created March 26, 2018 21:24 — forked from strangerstudios/pmpromyCRED.php
Award MyCRED points for members who sign up for Membership Level 1.
<?php
/*
Use this recipe in combination with MyCRED to award points to members when signing up
for Level 1 membership. This code gist could be customized to give points for another
membership level ID, award recurring points for each subscription payment, and more.
MyCRED can be downloaded/configured here: https://wordpress.org/plugins/mycred/
*/
// Register Hook for PMPro Membership Points at Signup
@pbrocks
pbrocks / load-script-to-footer.php
Created March 28, 2018 12:25
Load scripts in the footer of your site. The preferred method for WordPress would be to register and enqueue your javascript, but this will work at least for proof of concept.
@pbrocks
pbrocks / acf-customizer-patch.php
Created March 31, 2018 02:36 — forked from fabrizim/acf-customizer-patch.php
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch
@pbrocks
pbrocks / add-dashicons-to-wordpress-customizer.php
Created March 31, 2018 02:36 — forked from BoweFrankema/add-dashicons-to-wordpress-customizer.php
Add Dashicons to your Customizer Panels. You can find the dashicon CSS classes here: https://developer.wordpress.org/resource/dashicons/#id
<?php
/**
* Enqueue the stylesheet.
* http://aristeides.com/blog/modifying-wordpress-customizer/
*/
function my_enqueue_customizer_stylesheet() {
wp_register_style( 'my-customizer-css', YOUR_PLUGIN_URL. 'assets/css/customizer.css', NULL, NULL, 'all' );
wp_enqueue_style( 'my-customizer-css' );
@pbrocks
pbrocks / custom-field-register-helper.php
Last active April 9, 2018 13:17 — forked from andrewlimaza/custom-field-register-helper-checkout-email.php
Add custom field to Paid Memberships Pro Checkout Email using Register Helper
<?php
/**
* This will check for !!company_name!! in the emails body and replace it with the 'company_name' metadata (created by Register Helper).
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_body( $body, $email ) {
//only checkout emails + strict comparison
if ( false !== strpos( $email->template, 'checkout' ) ) {
global $current_user;
@pbrocks
pbrocks / redirect-for-confirmation.php
Created April 10, 2018 15:02
A function that will redirect users based on their PMPro membership level during confirmation.
<?php
/**
* The function some_kind_of_pmpro_redirection is an arbitrary name given to the
* function created to run this specific bit of code. You can name it anything
* meaningful that you like, assuming that it is unique to the code on the site.
*
* The name of the filter hook, however, is not arbitrary as this is something
* created by the PMPro plugin. In this case, pmpro_confirmation_url, tells
* WordPress when to run this code in the some_kind_of_pmpro_redirection function.
*
@pbrocks
pbrocks / WP_API_OAuth_Test_client.php
Created April 11, 2018 14:02 — forked from kosso/WP_API_OAuth_Test_client.php
Test PHP client for Wordpress REST API v2.0 / OAuth1.0a 0.3.0
<?php
//opcache_reset(); // Disable local dev MAMP cache
/*
WP_API_OAuth_Test_client.php
Tested with Wordpress 4.7.1
WordPress REST API - OAuth 1.0a Server v.0.3.0 - https://en-gb.wordpress.org/plugins/rest-api-oauth1/
@pbrocks
pbrocks / pmpro-adjust-email-content-to-level-checkout.php
Created April 17, 2018 15:13
This gist changes the output of the checkout email based on the member's level.
<?php
/**
* Change content of Checkout email based on membership level.
*
* @param string $body The contents of the email is a string of text that you can adjust here as you see fit or pull from another custom function.
* @param object $email This is the php object from which we extracting the appropriate level and to which we'll add the new email content.
* @return string Whichever condition applies in the function below will determine what string is supplied to the email object. If none of the conditions are met, the return string will be the original message content.
*/
function pmpro_adjust_email_content_to_level_checkout( $body, $email ) {