2013-04-22 2 views
0

에서 함수를 필터링 :내가 아이 테마를하고 난 다음 필터링하려고 WP

// add the function to the init hook 
add_action('init', 'options_typography_get_google_fonts'); 

// add a font to the $google_fonts variable 
function options_typography_get_google_fonts() { 

    // Google Font Defaults 
    global $google_faces; 
    $google_faces = array(

     'Great Vibes, cursive' => '*Great Vibes'  
     ); 

    return $google_faces; 

} 

좀 더 추가 글꼴을 구글 수 있도록이를 필터링하는 가장 좋은 방법은 무엇입니까?

답변

0

귀하의 질문은 그래서 여기에 몇 가지 옵션이 있습니다, 조금 모호 :

(1) 만약 options_typography_get_google_fonts 기능을 사용하면 자녀의 테마를 재 선언하여 기능을 대체 할 수 있습니다 (function_exists 포함)가있는 경우 부모 테마 검사 .

(2) 부모 테마하지 않는 경우, 당신은 당신의 childtheme에서 작업을 제거 할 수 있어야한다 : 함수 당신을 기반으로 자신의 (비슷하지만 확장) 기능을

remove_action('init', 'options_typography_get_google_fonts');

및 구축 방금 제거되었습니다.

당신이 자식 테마를 구축하고 있으며, 글꼴의 목록을 필터링 할 수 있도록 사용자를 원하시면

(3), 당신은 필터링 배열을 반환해야합니다 :

return apply_filters('my_options_typography_get_google_fonts_filter', $google_faces);