我正在尝试在 Wordpress 中创建简单的摘录插件。我用谷歌搜索了很多允许的标签不起作用,谁能给我一个建议如何做到这一点?
class fpexcerpt {
function __construct() {
require_once('inc/template.php');
if(isset($_POST['reset'])) {
add_action('admin_init',array($this,'fpexcerptrestore'));
}
}
function fpexcerptdefault() {
add_option('fpexcerptcount',55);
add_option('fpexcerptmore','[...]');
}
function fpexcerptrestore() {
delete_option('fpexcerpttag');
delete_option('fpexcerptcount');
delete_option('fpexcerptmore');
fpexcerpt::fpexcerptdefault();
}
function fpexcerptadmin() {
add_submenu_page('options-general.php','Fantastic Excerpt', 'Fantastic Excerpt', 'manage_options','fpexcerptadmin', 'fpexcerptadmin_menu');
}
function fpexcerptupdate() {
register_setting('fpexcpt','fpexcerpttag');
register_setting('fpexcpt','fpexcerptcount');
register_setting('fpexcpt','fpexcerptmore');
}
function improved_trim_excerpt($text) {
global $post;
if ( '' == $text ) {
$text = get_the_excerpt();
$text = apply_filters('the_excerpt',$text);
// $text = str_replace('\]\]\>', ']]>', $text);
$text = strip_tags($text, '<a>');
$excerpt_length = 80;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
}
return $text;
}
}
$new = new fpexcerpt();
register_activation_hook(__FILE__,array('fpexcerpt','fpexcerptdefault'));
//remove_all_filters('wp_trim_excerpt');
//add_filter('get_the_excerpt', array('fpexcerpt','fpexcerptprocess'));
remove_filter('get_the_excerpt',array('fpexcerpt','wp_trim_excerpt'));
add_filter('get_the_excerpt', array('fpexcerpt','improved_trim_excerpt'));
add_action('admin_menu',array('fpexcerpt','fpexcerptadmin'));
add_action('admin_init',array('fpexcerpt','fpexcerptupdate'));
?>
编辑:
第一张图片是在我单击特定帖子时显示摘录内容,但即使我添加了摘录插件(我的),它也不会出现在摘录中