/** * parse shortcodes * * @param array @args * @param string @content * @param string @tag * @return string $content */ function mgm_shortcode_parse($args, $content, $tag) { // current_user $current_user = wp_get_current_user(); // system $system_obj = mgm_get_class('system'); // issue#: 859 // add <p> to the beggining and </p> to the end of content // as WP pass $content with incomplete p tags $content = '<p>' . $content . '</p>'; // remove any '<p></p> found $content = str_replace(array('<p></p>'), '', $content); // @todo test with force_balance_tags(); // tag block switch ($tag) { case 'private': // [private] protected content [/private] if (mgm_protect_content() || mgm_post_is_purchasable()) { //issue #1687 if (mgm_content_post_access_delay($args)) { $content = mgm_replace_postdealy_content($content); } else { $content = mgm_replace_content_tags($tag, $content, $args); } } break; case 'private_or': // [private_or#member] protected content [/private_or] // [private_or membership_type="member"] protected content [/private_or] $membership_type = isset($args['membership_type']) ? $args['membership_type'] : str_replace('#', '', mgm_array_shift($args)); // match if ($membership_type) { $content = mgm_replace_content_tags($tag, $content, $membership_type); } break; case 'private_and': // [private_and#member] protected content [/private_and] // [private_and membership_type="member"] protected content [/private_and] $membership_type = isset($args['membership_type']) ? $args['membership_type'] : str_replace('#', '', mgm_array_shift($args)); // match if ($membership_type) { $content = mgm_replace_content_tags($tag, $content, $membership_type); } break; case 'payperpost_pack': // [payperpost_pack#1] : 1 = pack_id, packs to be created in MGM -> PayPerPost -> Post Packs, use the id here // [payperpost_pack id=1] : 1 = pack_id $pack_id = isset($args['id']) ? $args['id'] : str_replace('#', '', mgm_array_shift($args)); // match if ($pack_id) { $content = mgm_replace_content_tags($tag, $content, $pack_id); } break; case 'payperpost': // [payperpost#1] : 1 = post_id // [payperpost id=1] : 1 = post_id $pack_id = isset($args['id']) ? $args['id'] : str_replace('#', '', mgm_array_shift($args)); // match if ($pack_id) { $content = mgm_replace_content_tags($tag, $content, $pack_id); } break; case 'subscription_packs': // subscription packs / payment gateways $content = mgm_sidebar_register_links($current_user->user_login, true, 'page'); // @todo test break; case 'user_unsubscribe': // user unsubscribe $content = mgm_user_unsubscribe_info(null, $args); // view current user break; case 'user_other_subscriptions': // other subscriptions $content = mgm_user_other_subscriptions_info(); break; case 'membership_details': // user subscription $content = mgm_membership_details(); // view current user break; case 'user_upgrade': // user upgrade membership $content = mgm_get_upgrade_buttons($args); break; case 'user_purchase_another_membership': // purchase another subscription $content = mgm_get_purchase_another_subscription_button($args); break; case 'user_subscribe': case 'user_register': // named if ($method = mgm_get_var('method', '', true)) { // method switch ($method) { case 'login': $content = mgm_user_login_form(false); break; case 'lostpassword': $content = mgm_user_lostpassword_form(false); break; default: if (preg_match('/^payment/', $method)) { $content = mgm_transactions_page($args); } break; } } else { $content = mgm_user_register_form($args); } break; case 'user_profile': // user profile $content = mgm_user_profile_form(NULL, false, $args); // view break; case 'user_public_profile': // user profile $content = mgm_user_public_profile($args); // view break; case 'transactions': // user payments/transactions $content = mgm_transactions_page($args); break; case 'user_contents_by_membership': // user contents by membership level $content = mgm_membership_content_page(); break; case 'user_lostpassword': // user lost password form $content = mgm_user_lostpassword_form(false); break; case 'user_login': // user login form $content = mgm_user_login_form(false); break; case 'user_field': // user field $content = __('Experimental', 'mgm'); break; case 'membership_contents': // membership contents $content = mgm_membership_contents(); // view current user break; case 'logout_link': // custom logout link // [logout_link#Logout] // [logout_link label="Logout"] $label = isset($args['label']) ? $args['label'] : str_replace('#', '', mgm_array_shift($args)); // match $content = mgm_logout_link($label); break; case 'membership_extend_link': //INCOMPLETE // membership extend link // [membership_extend_link#Extend] // [membership_extend_link label="Extend"] $label = isset($args['label']) ? $args['label'] : str_replace('#', '', mgm_array_shift($args)); // match $content = mgm_membership_extend_link($label); break; case 'download_error': // content $content = isset($_GET['error_code']) ? mgm_download_error($_GET['error_code']) : ''; break; case 'user_payment_history': // content $content = mgm_user_payment_history(); // view current user break; case 'user_list': // content $content = mgm_generate_member_list($args); break; case 'user_facebook_login': // content $content = mgm_generate_facebook_login(); break; case 'user_facebook_registration': // content $content = mgm_generate_facebook_registration(); break; case 'user_purchased_contents': // content $content = mgm_generate_purchased_contents(); break; case 'user_purchasable_contents': // content $content = mgm_generate_purchasable_contents(); break; /*case 'addon': // content $content = mgm_purchase_addons($args); break;*/ /*case 'addon': // content $content = mgm_purchase_addons($args); break;*/ default: // default, which are not shortcode but content tags $args = str_replace('#', '', mgm_array_shift($args)); // match $content = mgm_replace_content_tags($tag, $content, $args); break; } // return return $content; }
</div> </div> <div class="postbox mgm_profile_membership_info"> <h3><b><?php _e('Membership Information', 'mgm'); ?> </b></h3> <div class="inside"> <?php echo mgm_user_membership_info(); ?> </div> </div> <?php if ($info = mgm_user_other_subscriptions_info()) { ?> <div class="postbox mgm_profile_other_subscriptions_info"> <h3><b><?php _e('Other Subscriptions Information', 'mgm'); ?> </b></h3> <div class="inside"> <?php echo $info; ?> </div> </div> <?php
function mgm_membership_details($user_id = NULL) { $css_group = mgm_get_css_group(); // get if ($user_id) { $user = get_userdata($user_id); } // get current user if (!isset($user->ID)) { $user = wp_get_current_user(); } // return when no user if (!$user->ID) { return sprintf(__('You need to <a href="%s">login</a> to see that Page'), mgm_get_custom_url('login')); // return mgm_redirect(mgm_get_custom_url('login'), NULL, 'javascript', true); } // init $html = ''; //issue #867 if ($css_group != 'none') { //expand this if needed $css_link_format = '<link rel="stylesheet" href="%s" type="text/css" media="all" />'; $css_file = MGM_ASSETS_URL . 'css/' . $css_group . '/mgm.pages.css'; $html .= sprintf($css_link_format, $css_file); } // error if (isset($_GET['unsubscribe_errors']) && !empty($_GET['unsubscribe_errors'])) { $errors = new WP_Error(); $errors->add('unsubscribe_errors', urldecode(strip_tags($_GET['unsubscribe_errors'])), isset($_GET['unsubscribed']) ? 'message' : 'error'); $html .= mgm_set_errors($errors, true); unset($errors); } // subscription_info if ($subinfo_html = mgm_user_subscription_info($user_id)) { $html .= sprintf('<h3>%s</h3><p>%s</p>', __('Subscription Information', 'mgm'), $subinfo_html); } // membership_info if ($membinfo_html = mgm_user_membership_info($user_id)) { $html .= sprintf('<h3>%s</h3><p>%s</p>', __('Membership Information', 'mgm'), $membinfo_html); } // other subscriptions if ($oth_subinfo_html = mgm_user_other_subscriptions_info()) { $html .= $oth_subinfo_html; } //issue #1635 $membership_details_html = '<div class="mgm_membership_details_container">' . $html . '</div>'; // return return $membership_details_html; }