带有允许标签的Wordpress摘录不起作用?

时间:2013-05-28 13:59:43

标签: wordpress-plugin wordpress

我正在尝试在Wordpress中创建简单的摘录插件。我用Google搜索了很多允许的标签不起作用,有人能给我一个如何做的建议吗?

   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'));
?>

修改

EXCERPT IMAGES

CONTENT IMAGE

第一张图片显示摘录内容,当我点击特定帖子获取链接但不摘录时即使我添加了摘录插件(我的)

1 个答案:

答案 0 :(得分:0)

错误:达到了'100'的最大功能嵌套级别,正在中止!在第453行的E:\ wamp \ www \ fp \ wp-includes \ cache.php

根据您上面报告的错误,我可以推测您陷入了递归函数调用循环。换句话说,您编写的函数(在callstack中的某个点)调用自身(或调用它的函数)。想象一下无限循环,但有功能。

由于无法看到您的所有代码,我无法确定这种情况发生在哪里。