Example #1
0
 public function replace_variables($message)
 {
     $settings = $this->get_settings();
     if (0 === $settings['page_for_subscription']) {
         $subscription_url = get_bloginfo('wpurl') . '/?subscription';
     } else {
         $subscription_url = get_page_link($settings['page_for_subscription']);
     }
     if (0 === $settings['page_for_profile']) {
         $my_account_url = get_bloginfo('wpurl') . '/?my-account';
     } else {
         $my_account_url = get_page_link($settings['page_for_profile']);
     }
     $message = str_ireplace('{{SUBSCRIBE_LOGIN_URL}}', $subscription_url, $message);
     $message = str_ireplace('{{SUBSCRIBE_URL}}', $subscription_url, $message);
     $message = str_ireplace('{{MY_ACCOUNT_URL}}', $my_account_url, $message);
     if (0 === $settings['page_for_login']) {
         $login_url = get_bloginfo('wpurl') . '/?login';
     } else {
         $login_url = get_page_link($settings['page_for_login']);
     }
     $message = str_ireplace('{{LOGIN_URL}}', $login_url, $message);
     //Deprecated
     if (!empty($settings['price'])) {
         $message = str_ireplace('{{PRICE}}', $settings['price'], $message);
     }
     if (!empty($settings['interval_count']) && !empty($settings['interval'])) {
         $message = str_ireplace('{{LENGTH}}', leaky_paywall_human_readable_interval($settings['interval_count'], $settings['interval']), $message);
     }
     return $message;
 }
Example #2
0
 function leaky_paywall_subscription_options()
 {
     global $blog_id;
     $settings = get_leaky_paywall_settings();
     $current_level_ids = leaky_paywall_subscriber_current_level_ids();
     $results = apply_filters('leaky_paywall_subscription_options', '');
     //If someone wants to completely override this, they can with the above filter
     if (empty($results)) {
         $has_allowed_value = false;
         $results .= '<h2>' . __('Subscription Options', 'issuem-leaky-paywall') . '</h2>';
         $results .= apply_filters('leaky_paywall_subscription_options_header', '');
         if (!empty($settings['levels'])) {
             $results .= apply_filters('leaky_paywall_before_subscription_options', '');
             $results .= '<div class="leaky_paywall_subscription_options">';
             foreach (apply_filters('leaky_paywall_subscription_levels', $settings['levels']) as $level_id => $level) {
                 if (!empty($level['deleted'])) {
                     continue;
                 }
                 if (is_multisite_premium() && !empty($level['site']) && 'all' != $level['site'] && $blog_id != $level['site']) {
                     continue;
                 }
                 $level = apply_filters('leaky_paywall_subscription_options_level', $level, $level_id);
                 $payment_options = '';
                 $allowed_content = '';
                 if (in_array($level_id, $current_level_ids)) {
                     $current_level = 'current-level';
                 } else {
                     $current_level = '';
                 }
                 $results .= '<div id="option-' . $level_id . '" class="leaky_paywall_subscription_option ' . $current_level . '">';
                 $results .= '<h3>' . stripslashes($level['label']) . '</h3>';
                 $results .= '<div class="leaky_paywall_subscription_allowed_content">';
                 foreach ($level['post_types'] as $post_type) {
                     /* @todo: We may need to change the site ID during this process, some sites may have different post types enabled */
                     $post_type_obj = get_post_type_object($post_type['post_type']);
                     if (!empty($post_type_obj)) {
                         if (0 <= $post_type['allowed_value']) {
                             $has_allowed_value = true;
                             $allowed_content .= '<p>' . sprintf(__('Access %s %s*', 'issuem-leaky-paywall'), $post_type['allowed_value'], $post_type_obj->labels->name) . '</p>';
                         } else {
                             $allowed_content .= '<p>' . sprintf(__('Unlimited %s', 'issuem-leaky-paywall'), $post_type_obj->labels->name) . '</p>';
                         }
                     }
                 }
                 $results .= apply_filters('leaky_paywall_subscription_options_allowed_content', $allowed_content, $level_id, $level);
                 $results .= '</div>';
                 $currency = $settings['leaky_paywall_currency'];
                 $currencies = leaky_paywall_supported_currencies();
                 $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 .= '<strong>' . sprintf(__('%s%s %s (recurring)', 'issuem-leaky-paywall'), $currencies[$currency]['symbol'], number_format($level['price'], 2), leaky_paywall_human_readable_interval($level['interval_count'], $level['interval'])) . '</strong>';
                         $results .= apply_filters('leaky_paywall_before_subscription_options_recurring_price', '');
                     } else {
                         $results .= '<strong>' . sprintf(__('%s%s %s', 'issuem-leaky-paywall'), $currencies[$currency]['symbol'], number_format($level['price'], 2), leaky_paywall_human_readable_interval($level['interval_count'], $level['interval'])) . '</strong>';
                         $results .= apply_filters('leaky_paywall_before_subscription_options_non_recurring_price', '');
                     }
                     if (!empty($level['trial_period'])) {
                         $results .= '<span class="leaky-paywall-trial-period">' . sprintf(__('Free for the first %s day(s)', 'issuem-leaky-paywall'), $level['trial_period']) . '</span>';
                     }
                 } else {
                     $results .= '<strong>' . __('Free', 'issuem-leaky-paywall') . '</strong>';
                 }
                 $results .= '</p>';
                 $results .= '</div>';
                 //Don't show payment options if the users is currently subscribed to this level
                 if (!in_array($level_id, $current_level_ids)) {
                     $results .= '<div class="leaky_paywall_subscription_payment_options">';
                     $results .= apply_filters('leaky_paywall_subscription_options_payment_options', $payment_options, $level, $level_id);
                     $results .= '</div>';
                 } else {
                     $results .= '<div class="leaky_paywall_subscription_current_level">';
                     $results .= __('Current Subscription', 'issuem-leaky-paywall');
                     $results .= '</div>';
                 }
                 $results .= '</div>';
             }
             $results .= '</div>';
             $results .= apply_filters('leaky_paywall_subscription_options_after_subscription_options', '');
             if ($has_allowed_value) {
                 $results .= '<div class="leaky_paywall_subscription_limit_details">';
                 $results .= '*' . ucfirst(leaky_paywall_human_readable_interval($settings['cookie_expiration'], $settings['cookie_expiration_interval']));
                 $results .= '</div>';
             }
         }
         $results .= apply_filters('leaky_paywall_subscription_options_footer', '');
     }
     return $results;
 }