Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / my_pre_get_posts_filter_rss.php
Created August 30, 2017 13:14
Tell WordPress to only include posts of type post in the RSS feed.
/*
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 August 17, 2017 16:45
Change the text "Membership" to "Package" whever it appears in PMPro.
/*
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 August 17, 2017 16:25
Discount a Paid Memberships Pro level half way through the year.
<?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 August 4, 2017 14:29
Disable the PMPro Expiration Warning Emails
add_filter('pmpro_send_expiration_warning_email', '__return_false');
@strangerstudios
strangerstudios / pmpro-customizations.php
Created August 3, 2017 15:46
A blank plugin file for customizations to your Paid Memberships Pro setup including a stylesheet for customizations.
<?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 December 5, 2023 12:19
A blank plugin file for customizations to your Paid Memberships Pro setup.
<?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 July 26, 2017 15:43
Add this to your .htaccess file to redirect the old PMPro PayFast ITN URL to the new one
# 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 July 18, 2017 15:58
Example where checking if a property of an object is empty fails when magic methods are involved.
//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 July 13, 2017 20:53
Add Custom SSL Seal to PMPro Checkout Page, Including SCRIPT Tags
/*
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 July 10, 2017 14:34
have PMPro treat info notices like posts with regards to protecting by category #member #access
/**
* 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;