我有一个wordpress插件,可以在所有页面的末尾添加.php。
但是,现在确实可以将其添加到帖子和自定义帖子类型中。
下面是插件代码,任何人都可以通过改编来提供帮助吗?
谢谢
<?php
/*
Plugin Name: .php on PAGES
Plugin URI: http://www.introsites.co.uk/33~php-wordpress-permalink-on-pages-plugin.php
Description: Adds .php to pages.
Author: IntroSites
Version: 1.1
Author URI: http://www.introsites.co.uk/
*/
add_action('init', 'php_page_permalink', -1);
register_activation_hook(__FILE__, 'active');
register_deactivation_hook(__FILE__, 'deactive');
function php_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.php')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.php';
}
}
add_filter('user_trailingslashit', 'no_page_slash',66,2);
function no_page_slash($string, $type){
global $wp_rewrite;
if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
return untrailingslashit($string);
}else{
return $string;
}
}
function active() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.php')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.php';
}
$wp_rewrite->flush_rules();
}
function deactive() {
global $wp_rewrite;
$wp_rewrite->page_structure = str_replace(".php","",$wp_rewrite->page_structure);
$wp_rewrite->flush_rules();
}
?>