Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / backupdb.sh
Created March 12, 2018 19:06
Shell script to back up a MySQL database and push it to Amazon S3
# change these
bucket="s3://bucketname"
backupdir="/var/www/vhosts/domain.com/backup"
dbuser="dbuser"
dbpass="dbpass"
dbname="db"
cd ~pmpro/backup/
mysqldump -u$dbuser -p$dbpass $dbname > $dbname_`date +'%Y-%m-%d'`.sql
gzip $dbname_`date +'%Y-%m-%d'`.sql
@ideadude
ideadude / disable_pmpro_https_status_filter.php
Created March 22, 2018 14:22
Disable the PMPro https_status_filter
/**
* Disable the PMPro https_status_filter
* It was interfering with logins
*/
function disable_pmpro_https_status_filter() {
remove_filter('wp_list_pages', 'pmpro_https_filter');
remove_filter('option_home', 'pmpro_https_filter');
remove_filter('option_siteurl', 'pmpro_https_filter');
remove_filter('logout_url', 'pmpro_https_filter');
remove_filter('login_url', 'pmpro_https_filter');
@ideadude
ideadude / remove_pmpro_level_description_and_confirmation_filters.php
Last active March 22, 2018 23:27
Remove the default the_content filter added to membership level descriptions and confirmation messages in Paid Memberships Pro
/**
* Remove the default the_content filter added to membership level descriptions
* and confirmation messages in PMPro.
* These filters will sometimes cause infinite loop conflicts, e.g. when using
* page builders like Site Origin.
* Add this code to a custom plugin.
*/
function remove_pmpro_level_description_and_confirmation_filters() {
remove_filter( 'the_content', 'pmpro_level_description' );
remove_filter( 'pmpro_level_description', 'pmpro_pmpro_level_description' );
@ideadude
ideadude / pmpro_level_description_on_checkout_page.php
Created April 5, 2018 14:21
Strip links out of the level description on the checkout page in Paid Memberships Pro
/*
Strip links out of the level description on the checkout page.
Add this code to a custom plugin.
*/
function pmpro_level_description_on_checkout_page( $description ) {
global $pmpro_pages;
if( is_page( $pmpro_pages['checkout'] ) ) {
$description = strip_tags( $description );
}
@ideadude
ideadude / full-width.php
Created April 24, 2018 20:54
Memberlite Full Width Template for Posts, Pages, and Products
<?php
/**
Template Name: Full Width
Template Post Type: post, page, product
**/
get_header(); ?>
<div id="primary" class="large-12 columns content-area">
<?php do_action('before_main'); ?>
@ideadude
ideadude / my_comment_author_show_membership_level.php
Last active April 12, 2021 20:21
Show membership level next to comments with Paid Memberships Pro.
/**
* Show membership level next to comments.
* This gist will work with PMPro and most WP themes.
* Add this code into a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_comment_author_show_membership_level( $author_text, $comment_ID ) {
$email = get_comment_author_email( $comment_ID );
if( empty( $email ) ) {
return $author_text;
}
@ideadude
ideadude / affiliate_discount_codes.php
Last active January 5, 2022 20:51 — forked from strangerstudios/pmpro_ld2aff.php
Link Paid Memberships Pro discount codes to affiliate accounts from another plugin/service.
<?php
/*
Link discount codes to affiliates.
*/
//this is the parameter we're looking for to find affiliates... based on which plugin/etc you are using
define('PMPRO_LDC2AFF_KEY', 'wpam_id'); //Affiliates Manager Plugin
//define('PMPRO_LDC2AFF_KEY', 'pa'); //WordPress Lightweight Affiliates
//define('PMPRO_LDC2AFF_KEY', 'ref'); //AffiliateWP
//helper function to get the values from options and make sure they are an array
@ideadude
ideadude / my_change_pmpro_sessions_start_and_stop.php
Created May 10, 2018 14:36
Change when Paid Memberships Pro starts and stops PHP sessions.
<?php
/**
* Change when Paid Memberships Pro starts and stops PHP sessions.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_change_pmpro_sessions_start_and_stop() {
// make sure PMPro has loaded
if( !function_exists( 'pmpro_start_session' ) ) {
return;
}
@ideadude
ideadude / gist:8e05f2429914ca2869319c68cebb50aa
Created June 6, 2018 15:33
Test a PayPal Standard IPN with Paid Memberships Pro
/**
* When you pass /?testipn=1 to a WP URL, load our fake IPN data and process it
* You can find the parameter string for an IPN notification from the IPN History in PayPal.
* Update the parameter string to match the data/orders/etc on your site.
*/
function init_test_ipn() {
if(!empty($_REQUEST['testipn'])) {
parse_str( "transaction_subject=Level 1 at YourSite&payment_date=08:11:17 Jun 06, 2018 PDT&txn_type=subscr_payment&subscr_id=I-725WNH95VPUX&last_name=buyer&residence_country=US&item_name=Level 1 at Your Site&payment_gross=10.00&mc_currency=USD&[email protected]&payment_type=instant&protection_eligibility=Eligible&verify_sign=AXOdEKNaKB34xXs1J9eIeoZ2zZOEAmIExVCQqjTzQT7L1yO6NFySiCY7&payer_status=verified&test_ipn=1&[email protected]&txn_id=04404971C88980238&[email protected]&first_name=test&payer_id=ZPTKKEWFN2F2N&receiver_id=6B3GHP8DY7MTG&item_number=79E46DE577&payment_status=Completed&payment_fee=0.59&mc_fee=0.59&mc_gross=10.00&charset=window
@ideadude
ideadude / bwawwp_localizing_nonstring_assets_1.php
Created June 10, 2018 15:13
Sample get_image wrapper for localizing non-string assets. (BWAWWP Blog)
<?php
// Gets the full URL for an image given the image filename.
function schoolpress_get_image( $image ) {
$dir = apply_filters(
'schoolpress_images_url',
SCHOOLPRESS_URL . '/images/'
);
return $dir . $image;
}
?>