/** * parse and output post buy button * * @since 2.0 * * @param mixed $post_id * @return string $html */ function mgm_parse_post_template($post_id = null) { global $wpdb; //issue #1397 if (!isset($post_id) || $post_id == null || empty($post_id)) { $post_id = get_the_ID(); } // post $post = get_post($post_id); // issue #1397 // post title // $post_title = sprintf('<ul><li><a href="%s">%s</a></li></ul>', get_permalink($post_id), $post->post_title); // logged in if (is_user_logged_in()) { // return //return sprintf('<div>%s</div>%s', $post->post_title, mgm_get_post_purchase_button($post_id)); //issue #1706 return sprintf('%s', mgm_get_post_purchase_button($post_id)); } // login url $login_url = $post->ID > 0 ? mgm_get_custom_url('login', false, array('redirect_to' => get_permalink($post->ID))) : ''; // template $template = mgm_get_template('private_text_template', array(), 'templates'); // message $message = mgm_get_template('private_text_purchasable_login', array(), 'messages'); //issue #863 $message = str_replace('[purchase_options]', '', $message); $message = __($message, 'mgm'); $message .= '[purchase_options]'; // message $message = mgm_get_content_purchase_options($message, $login_url, $post_id); // message $message = str_replace('[message]', $message, $template); // return //return sprintf('<div>%s</div><div class="mgm_private_no_access">%s</div>', $post->post_title, $message); //issue #1706 return sprintf('<div class="mgm_private_no_access">%s</div>', $message); }
/** * private text tags replacement * * @param string text * @return string text */ function mgm_private_text_tags($text) { global $post; // login url $login_url = mgm_get_custom_url('login', false, array('redirect_to' => get_permalink($post->ID))); // [login] tag if (preg_match('/[login]/', $text)) { // login text $login_text = is_object($post) ? sprintf(' <a href="%s"><b>%s</b></a>', $login_url, __('Login', 'mgm')) : ''; // replace $text = str_replace('[login]', $login_text, $text); } // purchase options return $text = mgm_get_content_purchase_options($text, $login_url, $post->ID); }