This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function localize_schoolpress_images_url( $url ) { | |
$locale = apply_filters( 'plugin_locale', get_locale(), 'schoolpress' ); | |
if ( $locale != 'en_US' ) | |
$url = SCHOOLPRESS_URL . '/languages/' . $locale . '/images/'; | |
return $url; | |
} | |
add_filter( 'schoolpress_images_url', 'localize_schoolpress_images_url' ); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gets the full path for an email template given the email filename. | |
function schoolpress_get_email( $email ) { | |
$dir = apply_filters( | |
'schoolpress_emails_path', SCHOOLPRESS_PATH . '/emails/' | |
); | |
return $dir . $image; | |
} | |
// Filters the schoolpress_emails_path value based on locale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins. | |
*/ | |
function show_pmpro_address_fields_on_edit_profile() | |
{ | |
//require PMPro and PMPro Register Helper | |
if(!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION')) | |
return; | |
$address_fields = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace the default payment information HTML for the Stripe class. | |
* Add this code into a custom plugin. | |
* Note that you will need to monitor PMPro updates in case your custom code conflicts with new version of PMPro. | |
*/ | |
// Disable the defaults and load our own functions. | |
function my_stripe_checkout_html() { | |
//disable the defaults | |
remove_filter('pmpro_include_payment_information_fields', array('PMProGateway_stripe', 'pmpro_include_payment_information_fields')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use the pmprowoo_get_membership_price filter to set prices for variable products. | |
* Update the $membership_prices array. | |
* Each item in that array should have a key equal to the membership level id, | |
* and a value equal to an array of the form array( {variable_product_id} => {member_price} ) | |
* | |
* Add this code into a custom plugin. | |
*/ | |
function my_pmprowoo_get_membership_price( $discount_price, $level_id, $original_price, $product ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Consider member prices a "sale" so regular price is shown with a strikethrough | |
* If PMPro WooCommerce is active and setup to discount prices, | |
* then the calls to $product->get_price() will be filtered to return | |
* the member price. | |
* | |
* Add this code to a custom plugin. | |
*/ | |
function my_pmprowoo_woocommerce_product_is_on_sale( $on_sale, $product ) { | |
$regular_price = (float) $product->get_regular_price(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable the PMPro WooCommerce filter that restricts carts | |
* to only 1 membership product at a time. | |
* Add this code into a custom plugin. | |
*/ | |
function disable_pmprowoo_is_purchasble_filter() { | |
remove_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 ); | |
} | |
add_action( 'init', 'disable_pmprowoo_is_purchasble_filter' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Test if PHP Session Variables are working. | |
* Step 1: Add this code into a custom plugin or in a PHP file you know is being executed. | |
* Step 2: Navigate to /?test=123. You should see a blank old value and 123 as the new value. | |
* Step 3: Navigate to /?test=456. You should see 123 as the old value and 456 as the new value. | |
* If you see a blank old value again, that means that session variables are not enabled or otherwise broken. | |
* If the timestamp at the top is not being updated, the page may be cached. | |
* Step 4: Remove this code. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This gist will force run the pmpro_cleanup_memberships_users_table() | |
* function in PMPro. This function sets entries in the pmpro_memberships_users | |
* table to 'incative' if either (a) the level has been deleted or (b) there is a | |
* more recent active entry for the same level. | |
* | |
* IMPORTANT: Back up your database first. | |
* NOTE: This script may not fix all issues with the memberships_users table due to bad imports/etc. | |
* Add this code to a custom plugin, then visit /?cleanup_memberships_users_table=1 | |
* to kick off the script. Then remove the code from the custom plugin. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Based on the Register Helper example. | |
* We've added a "buddypress" option for each field | |
* set to the XProfile name we used when setting up | |
* the fields in the BuddyPress extended profile. | |
* If the PMPro BuddyPress Add On is activated | |
* then the fields will be synchronized. | |
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/ | |
*/ |