0

我有一个加密内容的功能:

function rewrite_text( $article, $case_sensitive=false ) {

    $workwith=$article;
    *(hide line code for copyright)....(hide line code for copyright)*
    $codul='<script type="text/javascript">
document.write(String.fromCharCode('.$numbers.'));
</script>';
        $workwith=$codul;
        }
    return $workwith;
}
add_filter('the_content', 'rewrite_text', 100);

在我的 wordpress 主题(deTube wordpress 主题)中有一个显示 youtube 播放器的功能(在 theme_name/functions.php 中):

function dp_video($post_id, $autoplay = false) {    
    $file = get_post_meta($post_id, 'dp_video_file', true);
    $file = !empty($file) ? explode("\n", $file) : array();
    $url = trim(get_post_meta($post_id, 'dp_video_url', true));
    $code = trim(get_post_meta($post_id, 'dp_video_code', true));
    if(!empty($code)) {
        $code = do_shortcode($code);
        if(function_exists('jwplayer_tag_callback'))
            $code = jwplayer_tag_callback($code);
        $code = extend_video_html($code, $autoplay);        
        echo '<div class="video-wrap">'.$code.'</div>';
    } elseif(!empty($url)) {
        $youtube_id = getYouTubeIdFromURL($url);
        $video = "<div class=\"video-wrap\"><embed src=\"http://www.youtube.com/v/".$youtube_id."?modestbranding=1&version=3&hl=vi_VN&rel=0&autoplay=1&showsearch=0&iv_load_policy=3&theme=light\" type=\"application/x-shockwave-flash\" allowFullScreen=\"true\" allowScriptAccess=\"always\" width=\"100%\" height=\"100%\"/></div>";
        echo $video;

我想通过 add_filter 函数 dp_video 加密 youtube 链接(youtube 播放器代码),使用:

add_filter('dp_video', 'rewrite_text', 100);

但它不工作!你能帮我为 dp_video 功能添加过滤器吗?非常感谢!

4

1 回答 1

0

如果你这样做add_filter('dp_video'),一定有一个apply_filters('dp_video')地方。例如,如果您想过滤 $video,您可以将最后一行更改为

echo apply_filters('dp_video', $video);
于 2012-10-25T13:06:15.063 回答