2013-05-25 22 views
1

我有我的WordPress安装这个插件: http://wordpress.org/plugins/put/WordPress的:在使用插件不do_shortcode工作

我试着去制作一个使用UI选项卡插件我自己的插件内的插件。

我的插件至今代码:

function load_jquery(){ 
    echo '<link rel=\'stylesheet\' id=\'jquery-ui-tabs-css\' href=\'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/smoothness/jquery-ui.css?ver=1.9.2\' type=\'text/css\' media=\'all\' />'; 
} 

add_action('wp_head','load_jquery'); 

function print_tabs(){ 
    echo do_shortcode('[tab name="Tab"]-[/tab]'); 
    echo do_shortcode('[end_tabset]'); 
} 

add_shortcode('print_tabs', 'print_tabs'); 

现在,如果我在新页面中使用[print_tabs]简码,它应该是这样的: http://img835.imageshack.us/img835/4905/workingp.png

但它不工作,它看起来像这样: http://imageshack.us/a/img62/9772/notworkingm.png

这里有什么问题?

+0

简码应该'返回'他们的数据,而不是'回声'它。 –

+0

$ val = do_shortcode('[tab name =“Tab”] - [/ tab]')。 \t do_shortcode('[end_tabset]'); \t \t return $ val; 没有任何区别:/ – plexcell

+0

我刚刚通过Google找到了这个。我可以确认PUT插件没有正确运行do_shortcode()。 –

回答

0

这个问题,从我在post UI标签插件的put.php中可以看到的是,短代码只在名为“on_the_content”的函数的“the_content”过滤器中添加。

add_filter('the_content',  array($this, 'on_the_content'), 7); // Priority 7 - before wpautop 

(线put.php 96)

而且该功能看起来像:

public function on_the_content($content) { 

    $this->has_tabs = (bool) apply_filters('put_decide_has_tabs', $this->has_tabs); 

    if(!$this->has_tabs) 
     return $content; 

    global $shortcode_tags; 

    // Backup current registered shortcodes and clear them all out 
    $orig_shortcode_tags = $shortcode_tags; 
    $shortcode_tags = array(); 

    add_shortcode('tab',  array($this, 'on_tab_shortcode')); 
    add_shortcode('end_tabset', array($this, 'on_tab_end_shortcode')); 

    // Do the shortcode(only the tab shortcode is registered at this point) 
    $content = do_shortcode($content); 

    // Put the original shortcodes back 
    $shortcode_tags = $orig_shortcode_tags; 

    return $content; 
} 

因此,考虑如何(在行put.php的118起)这个插件是通过用一个过滤器修改内容来编写的,而过滤器在运行该过滤器时又添加了短代码,您所看到的可能是因为当您调用“do_shortcode”时,这些代码不会实现y存在。

什么呼应do_shortcode正在做什么,只是咳嗽文本。

不幸的是,由于Post UI Tabs插件的写法,你可能无法做你想做的事情。

相关问题