/** * This hook is called when the correct page is determined by wordpress to process. We check here * if that page is a MM core page and then make any checks we might want to for that particular * core page before we get too deep into the execution process and before any headers might be * sent incase redirect is needed */ public function checkCorePageTypeInput() { $corePage = new MM_CorePage(); if ($corePage->isDefaultCorePage(get_the_ID())) { $corePageInfo = $corePage->getCorePageInfo(get_the_ID()); if (!is_null($corePageInfo)) { switch ($corePageInfo->core_page_type_id) { case MM_CorePageType::$RESET_PASSWORD: $result = MM_ResetPasswordForm::checkInput(); if ($result['success'] === false) { MM_Messages::addError($result['message']); wp_redirect(MM_CorePageEngine::getUrl(MM_CorePageType::$LOGIN_PAGE)); exit; } break; } } } }
/** * This function keeps default core page from being trashed */ public function trashPostHandler($post_id) { if (MM_CorePage::isDefaultCorePage($post_id)) { MM_Messages::addError("MemberMouse default core pages cannot be deleted."); wp_publish_post($post_id); wp_redirect("edit.php?post_type=page"); exit; } if (MM_CorePageEngine::isCorePage($post_id)) { // We don't want non-default core pages sitting in the trash to retain their associations because it // can cause issues with other non-default core pages that are currently published, so let's treat even // sending a non-default core page to trash just the same as permanently deleting the page altogether $this->deletePostHandler($post_id); } }