php - Wordpress(PHP):页面未找到标题但内容存在
问题描述
我有一个注册新端点的类,重写规则然后刷新它。它工作得很好,除了它也给出了 404 错误,使页面标题“找不到页面”并添加了一些我不想要的 css。我需要让它真正知道我的页面存在。
这是我写的课程:
<?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;
}
}
解决方案
推荐阅读
- java - 连接到 sqlite 数据库、执行准备好的语句并关闭与 java 的连接的正确方法是什么?
- reactjs - 类型错误:无法读取未定义的属性“地图”
- firebase - 如何在 Android O 中设置 Firebase 通知 ChannelID?
- excel - 参考单元格未显示小数点后 1 位或小数点后 2 位的值
- c++ - C++ 正则表达式字符类不匹配
- python-2.7 - Python - AttributeError:“DataFrame”对象没有属性
- oracle - 查询适用于 oracle 12c,但不适用于 11g
- javafx-3d - 为什么这些 JavaFX TriangleMesh 渲染时带有暗影伪影?
- java - 实体中的继承
- php - Laravel 重定向时没有消息错误