/** * Check pages for the presence of Membership special pages. * * Related Action Hooks: * - template_redirect * * @since 1.0.0 */ public function check_for_membership_pages() { global $post, $wp_query; // For invoice page purchase process $fields = array('gateway', 'ms_relationship_id', 'step'); if (!empty($post) && isset($post->post_type) && $post->post_type == MS_Model_Invoice::get_post_type() && self::validate_required($fields) && self::STEP_PROCESS_PURCHASE == $_POST['step']) { do_action('ms_controller_frontend_signup_process_purchase', $this); } $the_page = MS_Model_Pages::current_page(); if ($the_page) { // Fix the main query flags for best theme support: // Our Membership-Pages are always single pages... $wp_query->is_single = false; $wp_query->is_page = true; $wp_query->is_singular = true; $wp_query->is_home = false; $wp_query->is_frontpage = false; $wp_query->tax_query = null; $the_type = MS_Model_Pages::get_page_type($the_page); switch ($the_type) { case MS_Model_Pages::MS_PAGE_MEMBERSHIPS: if (!MS_Model_Member::is_logged_in()) { wp_safe_redirect(MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER)); exit; } if (MS_Helper_Membership::MEMBERSHIP_ACTION_CANCEL == $this->get_action()) { $this->membership_cancel(); } else { $this->signup_process(); } break; case MS_Model_Pages::MS_PAGE_REGISTER: if (MS_Model_Member::is_logged_in()) { wp_safe_redirect(MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_MEMBERSHIPS)); exit; } if (MS_Helper_Membership::MEMBERSHIP_ACTION_CANCEL == $this->get_action()) { $this->membership_cancel(); } else { $this->signup_process(); } break; case MS_Model_Pages::MS_PAGE_ACCOUNT: $this->user_account_manager(); break; case MS_Model_Pages::MS_PAGE_PROTECTED_CONTENT: // Set up the protection shortcode. $scode = MS_Plugin::instance()->controller->controllers['membership_shortcode']; $scode->page_is_protected(); break; case MS_Model_Pages::MS_PAGE_REG_COMPLETE: // Do nothing... break; default: // Do nothing... break; } } }
/** * Filter returns the default contents of a Membership Page if the URL param * &ms-default=1 is set. * * Effectively this will display the default contents inside the Post-Editor * without changing the page itself. Only after the user saves the content * it will affect the Membership page * * @since 1.0.0 * @param string $content Default page content. * @return string Modified page content. */ public function show_default_content($content) { static $Message = false; global $post, $post_type; if (!isset($_GET['ms-default'])) { return $content; } if ('1' != $_GET['ms-default']) { return $content; } if ('page' != $post_type) { return $content; } $ms_page = MS_Model_Pages::get_page_by('id', $post->ID); if (empty($ms_page)) { return $content; } $type = MS_Model_Pages::get_page_type($ms_page); if (!$Message) { $Message = true; lib3()->ui->admin_message(__('<strong>Tipp</strong>:<br />' . 'The page content is reset to the default content but is <em>not saved yet</em>!<br />' . 'You can simply close this page to keep your current page contents.', 'membership2')); } return MS_Model_Pages::get_default_content($type); }