Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Last active August 22, 2018 18:12
Show Gist options
  • Save pbrocks/89f2be2e5f1d4f45b15b0c60a548df6d to your computer and use it in GitHub Desktop.
Save pbrocks/89f2be2e5f1d4f45b15b0c60a548df6d to your computer and use it in GitHub Desktop.
A checkout page diagnostic to see how to change the text of what Paid Memberships Pro produces and also highlights each of the areas where special actions can be run to insert text or other dynamic information.
<?php // if placed in Customizations plugin, do not include this line.
/**
* This is a Checkout page diagnostic to see how to change the text of what
* Paid Memberships Pro produces and also highlights each of the areas where
* special actions can be run to insert text or other dynamic information.
*/
/**
* Plugin Name: Checkout Page Text Changes
*
* if placed in Customizations plugin, do not include this doc block.
*/
function checkout_page_text_changes( $output_text, $input_text, $domain ) {
if ( 'paid-memberships-pro' === $domain ) {
$output_text = str_replace( 'Membership Level', 'Membership Level text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
$output_text = str_replace( 'Account Information', 'Account Information text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
$output_text = str_replace( 'Billing Address', 'Billing Address text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
$output_text = str_replace( 'First Name', 'First Name text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
$output_text = str_replace( 'Postal Code', 'Postal Code text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
$output_text = str_replace( 'Payment Information', 'Payment Information text changed here: ' . basename( __FILE__ ) . ' on Line ' . __LINE__, $output_text );
}
return $output_text;
}
add_filter( 'gettext', 'checkout_page_text_changes', 10, 3 );
add_action( 'pmpro_checkout_boxes', 'text_on_checkout_after_username' );
function text_on_checkout_after_username() {
$label = ucwords( preg_replace( '/-+/', ' ', substr( basename( __FILE__ ), 0, -4 ) ) );
echo '<h4> The filter, <span style="color:salmon;">' . current_filter() . '</span>, calls this function: <span style="color:salmon;">' . __FUNCTION__ . '</span> on Line ' . __LINE__ . ' of the file ' . basename( __FILE__ ) . ' in the ' . $label . ' plugin</h4>';
}
add_action( 'pmpro_checkout_after_pricing_fields', 'text_on_checkout_after_pricing_fields' );
function text_on_checkout_after_pricing_fields() {
$label = ucwords( preg_replace( '/-+/', ' ', substr( basename( __FILE__ ), 0, -4 ) ) );
echo '<h4> The filter, <span style="color:salmon;">' . current_filter() . '</span>, calls this function: <span style="color:salmon;">' . __FUNCTION__ . '</span> on Line ' . __LINE__ . ' of the file ' . basename( __FILE__ ) . ' in the ' . $label . ' plugin</h4>';
}
add_action( 'pmpro_checkout_after_user_fields', 'text_on_checkout_after_user_fields' );
function text_on_checkout_after_user_fields() {
$label = ucwords( preg_replace( '/-+/', ' ', substr( basename( __FILE__ ), 0, -4 ) ) );
echo '<h4> The filter, <span style="color:salmon;">' . current_filter() . '</span>, calls this function: <span style="color:salmon;">' . __FUNCTION__ . '</span> on Line ' . __LINE__ . ' of the file ' . basename( __FILE__ ) . ' in the ' . $label . ' plugin</h4>';
}
add_action( 'pmpro_checkout_after_billing_fields', 'text_on_checkout_after_billing_fields' );
function text_on_checkout_after_billing_fields() {
$label = ucwords( preg_replace( '/-+/', ' ', substr( basename( __FILE__ ), 0, -4 ) ) );
echo '<h4> The filter, <span style="color:salmon;">' . current_filter() . '</span>, calls this function: <span style="color:salmon;">' . __FUNCTION__ . '</span> on Line ' . __LINE__ . ' of the file ' . basename( __FILE__ ) . ' in the ' . $label . ' plugin</h4>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment