fix: 检测 index.php 固定链接并给出管理提示
This commit is contained in:
@@ -211,6 +211,16 @@ function kjweji_setup_pages() {
|
|||||||
flush_rewrite_rules();
|
flush_rewrite_rules();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── 检查固定链接格式 ──────────────────────────
|
||||||
|
// 如果启用了 /index.php/ 前缀,自定义文章类型的路由会失效
|
||||||
|
add_action('admin_notices', 'kjweji_permalink_notice');
|
||||||
|
function kjweji_permalink_notice() {
|
||||||
|
$permalink = get_option('permalink_structure');
|
||||||
|
if ($permalink && strpos($permalink, 'index.php') !== false) {
|
||||||
|
echo '<div class="notice notice-warning is-dismissible"><p><strong>空笺未寄主题提示:</strong>检测到固定链接包含 <code>/index.php/</code>,会导致「微言」和「拾影」页面无法访问。建议在「设置 → 固定链接」中改用不含 <code>index.php</code> 的格式(如 <code>/%postname%/</code>)。</p></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 自定义文章类型:拾影
|
// 自定义文章类型:拾影
|
||||||
add_action('init', 'kjweji_register_photo');
|
add_action('init', 'kjweji_register_photo');
|
||||||
function kjweji_register_photo() {
|
function kjweji_register_photo() {
|
||||||
|
|||||||
Reference in New Issue
Block a user