Skip to content

Instantly share code, notes, and snippets.

View greenhornet79's full-sized avatar
👽
Craft

Jeremy Green greenhornet79

👽
Craft
View GitHub Profile
@greenhornet79
greenhornet79 / leaky-paywall-restore-level.php
Created July 26, 2023 16:32
restore a leaky paywall level
<?php
add_action ('admin_init', 'zeen_restore_level_by_id' );
function zeen_restore_level_by_id() {
$settings = get_leaky_paywall_settings();
$level_id = 1; // the id of the level you want to restore
$settings['levels'][$level_id]['deleted'] = 0; // this will "undelete" the level
<?php
add_filter('leaky_paywall_cancel_subscription_description', 'endo_change_cancel_description' );
function endo_change_cancel_description( $description ) {
$new_description = '<p>Please click the first link below to cancel your subscription.</p>';
return $new_description;
}
<?php
// add toc field to registration form
add_action('leaky_paywall_after_password_registration_field', 'zeen_custom_tos_registration_fields');
function zeen_custom_tos_registration_fields()
{
?>
<div class="form-row">
<input style="display: inline;" type="checkbox" required id="tos" name="tos"> <label for="tos" style="display: inline;">I understand I will be automatically billed on my renewal date unless I cancel, and I agree to all <a target="_blank" href="<?php echo home_url('subscription-terms'); ?>">terms and conditions</a>.</label>
<?php
add_action( 'leaky_paywall_after_update_stripe_subscription', 'zeen101_charge_proration_after_upgrade', 10, 3 );
function zeen101_charge_proration_after_upgrade( $cu, $sub, $level ) {
$invoice_items = \Stripe\InvoiceItem::all(["limit" => 3]);
foreach( $invoice_items->data as $item ) {
<?php
add_filter( 'leaky_paywall_subscribe_or_login_message', 'zeen_hide_nag', 20, 4 );
function zeen_hide_nag( $new_content, $message, $content, $post_id ) {
// return either original content or an empty string
// return $content;
return '';
<?php
add_filter( 'leaky_paywall_userdata_before_user_create', 'zeen_lp_use_different_role' );
function zeen_lp_use_different_role( $userdata ) {
$userdata['role'] = 'digital_subscriber';
return $userdata;
}
<?php
add_filter('leaky_paywall_subscribe_or_login_message', 'zeen101_custom_subscribe_content', 10, 4 );
function zeen101_custom_subscribe_content( $new_content, $message, $content, $post_id ) {
$settings = get_leaky_paywall_settings();
$lead_in = str_replace( $message, '', $new_content);
$subscribe_nag = '<div class="leaky_paywall_message_wrap"><div id="leaky_paywall_message">';
<?php
add_filter('leaky_paywall_subscribe_or_login_message', 'zeen101_custom_subscribe_content', 10, 4 );
function zeen101_custom_subscribe_content( $new_content, $message, $content, $post_id ) {
$thumbnail = get_the_post_thumbnail();
return '<p>' . $content . '</p>' . $thumbnail . $message;
}
<?php
add_filter( 'leaky_paywall_level_id_for_simplecirc_subscriber', 'zeen_set_level_id_by_price', 20, 2 );
function zeen_set_level_id_by_price( $level_id, $subscriber ) {
if ( !isset( $subscriber->subscriptions[0]->last_order->amount_paid ) ) {
return 1;
}
<?php
add_action( 'template_redirect', 'zeen101_custom_redirects' );
function zeen101_custom_redirects() {
if ( !is_category() ) {
return;
}