Skip to content

Instantly share code, notes, and snippets.

View dparker1005's full-sized avatar

David Parker dparker1005

  • Stranger Studios
View GitHub Profile
@dparker1005
dparker1005 / my_pmpro_sws_levels_page_hide_banner.php
Created July 2, 2019 14:57
Hides the PMPro SWS banner while on the levels page
<?php
function my_pmpro_sws_levels_page_hide_banner() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['levels'] ) ) {
?>
<script>
var banners = document.getElementsByClassName("pmpro_sws_banner ");
if(banners.length > 0) {
banners[0].style.display = "none";
@dparker1005
dparker1005 / my_pmproga_move_checkout_field.php
Last active August 20, 2021 12:46
Currently, PMPro Gift Aid puts its checkout box above the 'insert discount code' option. This will move it to below that option. There are two different code options for accomplishing this: a simple one and one that lets you customize the checkout box.
<?php
/**
* Moves and modifies the Gift Aid field.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@dparker1005
dparker1005 / my_pmproarc_move_checkout_field.php
Last active July 11, 2019 13:14
Currently, PMPro Auto-Renewal Checkbox puts its checkout box at the bottom of the page. This will move it to after the level cost. There are two different code options for accomplishing this: a simple one and one that lets you customize the checkout box.
<?php
// Use the below code to simply move the field
// ===============================================================================
function my_pmproarc_move_checkout_field() {
remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
add_action( 'pmpro_checkout_after_level_cost', 'pmproarc_pmpro_checkout_boxes', 5 );
}
add_action( 'init', 'my_pmproarc_move_checkout_field' );
// ===============================================================================
@dparker1005
dparker1005 / pmpro_flat_tax_rate.php
Last active September 30, 2019 10:05
Based off of https://www.paidmembershipspro.com/custom-tax-structure-using-the-pmpro_tax-hook/ to add a flat tax rate to all purchases. Make sure to change tax rate before use.
<?php
/*
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- We update the price description to include the tax amount.
*/
function my_pmpro_tax($tax, $values, $order)
{
$tax = round((float)$values[price] * 0.055, 2);
<?php
// Define the groups of levels. array(1,2) means that levels 1 and 2 are in a group and options will be shown for both levels at checkout for those levels.
global $pmpro_level_groups;
$pmpro_level_groups = array( array( 1,2 ) );
// Show the "Select a Payment Plan" box with options at checkout.
function pmpro_level_groups_pmpro_checkout_boxes() {
global $pmpro_level_groups, $pmpro_level, $discount_code, $wpdb;
// No groups found? return.
if ( empty( $pmpro_level_groups) || empty( $pmpro_level ) ) {
@dparker1005
dparker1005 / my_pmpro_payment_plan_checkout_boxes.php
Last active January 14, 2021 14:48
Define payment plans by mapping a level to discount codes representing payment plan options
<?php
// Copy from below here
/**
* Define payment plans by mapping a level to discount codes representing payment plan options
* Useful for offering multiple pricing structures for membership (i.e. Monthly, Annually)
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@dparker1005
dparker1005 / my_pmpro_add_name_placeholder.php
Last active July 29, 2019 16:30
Adds placeholder to name fields during checkout
<?php
// Copy from below this line
function my_pmpro_add_name_placeholder() {
?>
<script>
jQuery("#bfirstname").attr("placeholder", "Type your first name here...");
jQuery("#blastname").attr("placeholder", "Type your last name here...");
</script>
@dparker1005
dparker1005 / my_pmpro_add_name_checkout_hints.php
Created July 29, 2019 16:39
Adds a hint to the first and last name fields at checkout.
<?php
// Copy from below here
function my_pmpro_add_name_checkout_hints() {
?>
<script>
jQuery("#bfirstname").parent().append("<p><small class='lite'>I am a hint for first name.</small></p>");
jQuery("#blastname").parent().append("<p><small class='lite'>I am a hint for last name.</small></p>");
</script>
@dparker1005
dparker1005 / pmproaffl_offsite_billing_fields.php
Created July 31, 2019 14:01
When using "PMPro Capture Name & Address for Free Levels or for Offsite Gateway", this Gist will only show billing fields for offsite gateways and not for free levels.
<?php
// Copy from below here
/**
* Stop adding billing fields to everywhere
*/
function my_pmproaffl_init() {
remove_action( 'init', 'my_pmproaffl_init_include_address_fields_at_checkout', 30 );
}
@dparker1005
dparker1005 / x_button_on_banner.html
Created July 31, 2019 15:37
An 'x' button that you can put into a PMPro LPV banner. Styling should be customized.
<span id='close' onclick="jQuery('#close').parent().hide();">x</span>
<style>
#close {
float:right;
display:inline-block;
padding:2px 5px;
}
#close:hover {
float:right;
display:inline-block;