/** Links */ function ym_get_login_register_links() { $html = '<div id="ym_login_register_links">'; $html .= ym_get_login_link(); $html .= ' '; $html .= ym_get_register_link(); $html .= '</div>'; return $html; }
function ym_filter_message($message) { global $current_user, $ym_res; $logged_in = false; if ($current_user->ID > 0) { $logged_in = true; } /* * [[purchase_cost]] = Cost and currency of a purchasable post * [[login_register]] = Login or register form * [[login_register_links]] = Links for login and register * [[login_link]] = Login link only * [[register_link]] = Register link only * [[account_types]] = A list of membership levels that can see this post/page * [[duration]] = number of days that the user will have access for * [[buy_now]] = buy now button for single posts * [[paypal_button]] = Paypal image button * [[this_page]] = This page URL * [[p_id]] = This page/post ID * [[auto_buy_post]] = When used as a redirect will forward the user to paypal to buy the post they wanted */ $post_id = get_the_ID(); $currency = $ym_res->currency; $duration = get_post_meta($post_id, '_ym_post_purchasable_duration', 1); if (!$duration) { $duration = __('unlimited', 'ym'); } $cost = get_post_meta($post_id, '_ym_post_purchasable_cost', 1) . ' ' . $currency; $login_register_links = !$logged_in ? ym_get_login_register_links() : ''; $login_link = !$logged_in ? ym_get_login_link() : ''; $register_link = !$logged_in ? ym_get_register_link() : ''; $login_form = !$logged_in ? ym_login_form() : ''; if (!($account_types = str_replace(';', ', ', get_post_meta($post_id, '_ym_account_type', true)))) { if (ym_post_is_purchasable($post_id)) { $account_types = 'Purchasable Only'; } else { $account_types = 'No access'; } } $message = str_replace('[[purchase_cost]]', $cost, $message); $message = str_replace('[[login_register]]', $login_form, $message); $message = str_replace('[[login_register_links]]', $login_register_links, $message); $message = str_replace('[[login_link]]', $login_link, $message); $message = str_replace('[[register_link]]', $register_link, $message); $message = str_replace('[[account_types]]', $account_types, $message); $message = str_replace('[[duration]]', $duration, $message); $message = str_replace('[[this_page]]', get_permalink(), $message); $message = str_replace('[[p_id]]', get_the_ID(), $message); return $message; }