How to capture subscription period in a shortcode
-
Hi there,
I’m quite new to plugin and php development; I’m stuck with this development issue and I hope somebody can help! I’ve emailed Leaky Paywall earlier but I had no code at the time so hopefully my question will make more sense now:)
I’m trying to create a new shortcode that would capture subscription period for our monthly/yearly membership options. I’m thinking shortcode would be best because I’d like to have subscription period printed for individual users in several places of membership and registration pages (in terms and conditions etc). Here’s the code I’ve pulled from functions file:if ( !function_exists( ‘leaky_paywall_subscription_options’ ) ) {
function leaky_paywall_subscription_options() {
$results .= ‘<div class=”leaky_paywall_subscription_price”>’;
$results .= ‘<p>’;if ( !empty( $level[‘price’] ) ) {
if ( !empty( $level[‘recurring’] ) && ‘on’ === $level[‘recurring’] && apply_filters( ‘leaky_paywall_subscription_options_price_recurring_on’, true, $current_level ) ) {
$results .= sprintf( __( ‘%s%s %s (recurring)’, ‘issuem-leaky-paywall’ ), leaky_paywall_human_readable_interval( $level[‘interval_count’], $level[‘interval’] ) );
$results .= apply_filters( ‘leaky_paywall_before_subscription_options_recurring_price’, ” );
} else {
$results .= sprintf( __( ‘%s%s %s’, ‘issuem-leaky-paywall’ ), leaky_paywall_human_readable_interval( $level[‘interval_count’], $level[‘interval’] ) );
$results .= apply_filters( ‘leaky_paywall_before_subscription_options_non_recurring_price’, ” );
}}
}$results .= ‘</p>’;
$results .= ‘</div>’;
}
}
add_shortcode (‘membership_length’, ‘leaky_paywall_subscription_options’);For the time being [membership_length] prints all of subscription options section, and not ‘leaky_paywall_subscription_price’ only.
Any ideas how to change the function to print only what I need? Or am I getting this wrong and should start somewhere completely else? Any help would be very welcome:) Thanks!
- The topic ‘How to capture subscription period in a shortcode’ is closed to new replies.