Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / my_pre_get_posts_filter_rss.php
Created Aug 30, 2017
Tell WordPress to only include posts of type post in the RSS feed.
View my_pre_get_posts_filter_rss.php
/*
Only posts of type post in the RSS feed.
*/
function my_pre_get_posts_filter_rss($query) {
if ($query->is_feed) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','my_pre_get_posts_filter_rss');
@strangerstudios
strangerstudios / my_gettext_membership_to_package.php
Created Aug 17, 2017
Change the text "Membership" to "Package" whever it appears in PMPro.
View my_gettext_membership_to_package.php
/*
Change the text "Membership" to "Package" whever it appears in PMPro.
Add this code to a custom plugin.
*/
function my_gettext_membership_to_package( $translated_text, $text, $domain )
{
if($domain == "pmpro" || $domain == "paid-memberships-pro") {
$translated_text = str_replace('Membership', 'Package', $translated_text);
$translated_text = str_replace('membership', 'package', $translated_text);
@strangerstudios
strangerstudios / pmpro_checkout_level.php
Created Aug 17, 2017
Discount a Paid Memberships Pro level half way through the year.
View pmpro_checkout_level.php
<?php
/*
Add this code into a custom plugin. Combine this with the pmpro-set-expiration-date and/or pmpro-subscription-delay plugins
to have memberships expire/renew on the same date, e.g. Y2-01-01 to expire/renew on Jan 1 next year.
You can update the logic to check for different months or adjust the price in a different way. The code below divides the
initial payment by 2 July 1 through Dec 31.
*/
function pmpro_checkout_level_half_off_mid_year($level) {
$month = date('n', current_time('timestamp');
@strangerstudios
strangerstudios / pmpro_send_expiration_warning_email.php
Created Aug 4, 2017
Disable the PMPro Expiration Warning Emails
View pmpro_send_expiration_warning_email.php
add_filter('pmpro_send_expiration_warning_email', '__return_false');
@strangerstudios
strangerstudios / pmpro-customizations.php
Created Aug 3, 2017
A blank plugin file for customizations to your Paid Memberships Pro setup including a stylesheet for customizations.
View pmpro-customizations.php
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
@strangerstudios
strangerstudios / pmpro-customizations.php
Last active Oct 1, 2017
A blank plugin file for customizations to your Paid Memberships Pro setup.
View pmpro-customizations.php
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
@strangerstudios
strangerstudios / htaccess.txt
Created Jul 26, 2017
Add this to your .htaccess file to redirect the old PMPro PayFast ITN URL to the new one
View htaccess.txt
# BEGIN REDIRECT OLD PAYFAST ITN URL
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/plugin/paid-membership-pro/services/payfast_itn_handler.php$ /wp-admin/admin-ajax.php?action=pmpro_payfast_itn_handler [L]
# END REDIRECT OLD PAYFAST ITN URL
@strangerstudios
strangerstudios / example_where_empty_check_fails.php
Created Jul 18, 2017
Example where checking if a property of an object is empty fails when magic methods are involved.
View example_where_empty_check_fails.php
//this check will fail if $user->user_email is not set already
//it usese a PHP "magic method" to fetch the value, but
//the empty check will return true instead of actually
//checking the value
if ( empty( $user->user_email ) ) //in a lot of cases $user->user_email is always empty, even if the user has email address
return;
//this check will work no matter what
$email = $user->user_email;
@strangerstudios
strangerstudios / my_option_pmpro_sslseal.php
Created Jul 13, 2017
Add Custom SSL Seal to PMPro Checkout Page, Including SCRIPT Tags
View my_option_pmpro_sslseal.php
/*
Add SSL Seal to PMPro Checkout Page
Add this code to a custom plugin or your active theme's functions.php.
Custom code is necessary for this now that PMPro 1.9.3 for security reasons
doesn't allow script tags in the SSL Seal setting text area.
The example below is for an AlphaSSL certificate. Replace the $seal string below with
your own seals code. Be careful if the seal has single quotes in it.
@strangerstudios
strangerstudios / my_pmpro_membership_access_post.php
Last active Jul 10, 2017
have PMPro treat info notices like posts with regards to protecting by category #member #access
View my_pmpro_membership_access_post.php
/**
* Have PMPro treat info notices like posts with regards to protecting by category
* Add this code to a custom plugin.
* #pmpro #notices
*/
function pmpro_membership_access_post_info_notice($post) {
if($post->post_type == 'info-notice')
$post->post_type = 'post';
return $post;
You can’t perform that action at this time.