2013-04-22 61 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);