I made a custom endpoint. Getting page not found title but content is there.
-
I have a class that registers a new endpoint, rewrites rules and then flushes it. It works perfectly except that it also gives a 404 error, making the page title “page not found” and adding some css which I dont want. I need to make it so that it actually knows my page exists. The added css and page title change are problems I need to resolve. This is the class I use, but it might not have anything to do with the problem:
<?php use Jigoshop\Helper\Render as RenderCore; use Jigoshop\Frontend\Page\PageInterface; use Jigoshop\Integration\Helper\Render; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class twizo_Jigoshop_TFASettings implements PageInterface { function __construct() { Render::addLocation('twizo-verification', __DIR__); add_action('init', function () { add_rewrite_endpoint("twizo-verification", EP_ROOT | EP_PAGES | EP_PERMALINK); add_filter('generate_rewrite_rules', function ($rewrite) { $mySettings = [ '^account/twizo-verification/?$' => 'index.php? pagename=twizo-verification' ]; $rewrite->rules = $mySettings + $rewrite->rules; return $rewrite->rules; }); flush_rewrite_rules(); }); add_filter('jigoshop.frontend.page_resolver.page', function ($args) { global $wp_query; if ($wp_query->query['pagename'] == 'twizo-verification') { return $this; } return $args; }); } public function action() { $this->renderTFASettings(); } public function render() { } public function renderTFASettings() { add_action('jigoshop\template\shop\content\before', function () { echo '<h1>My account » 2FA Settings</h1>'; }); add_action('jigoshop\template\shop\content\after', function() { echo '<br><a href="./" class="btn btn-default">Go back to My account</a>'; }); switch(get_template()) { case "twentyfifteen": RenderCore::output('layout/twentyfifteen', [ 'content' => Render::get('twizo-verification', 'tfa- settings-body', array()) ]); break; case "twentysixteen": RenderCore::output('layout/twentysixteen', [ 'content' => Render::get('twizo-verification', 'tfa- settings-body', array()) ]); break; case "twentyseventeen": RenderCore::output('layout/twentyseventeen', [ 'content' => Render::get('twizo-verification', 'tfa- settings-body', array()) ]); break; default: RenderCore::output('layout/default', [ 'content' => Render::get('twizo-verification', 'tfa- settings-body', array()) ]); break; } exit; } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘I made a custom endpoint. Getting page not found title but content is there.’ is closed to new replies.