2013-05-25 4 views
1

작동하지 나는이 플러그인 내 워드 프레스에 설치 : http://wordpress.org/plugins/put/워드 프레스 : 플러그인에서 사용 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]'). \t do_shortcode ('[end_tabset]'); \t \t return $ val; 차이가 없음 :/ – plexcell

+0

방금 ​​Google에서이 주소를 발견했습니다. PUT 플러그인이 do_shortcode()를 제대로 실행하고 있지 않음을 확인할 수 있습니다. –

답변

0

게시 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가 무슨 소리를 보내고 있는지는 단지 텍스트를 기침하는 것입니다.

포스트 UI 탭 플러그인이 쓰여지는 방식 때문에, 사용자가하려는 일을 수행하지 못할 수도 있습니다.