I seguenti filtri possono essere utilizzati per modificare Thematic attraverso un child theme utilizzando il file functions.php o un plugin.
Head
thematic_create_doctype()
Genera il <DOCTYPE> all’ inizio del nostro documento HTML. Se per esempio volessimo usare il doctype XHTML strict per il nostro blog, dovremmo usare il seguente codice:
function childtheme_create_doctype($content) {$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';$content .= "n";$content .= '<html xmlns="http://www.w3.org/1999/xhtml"';return $content;}add_filter('thematic_create_doctype', 'childtheme_create_doctype');
NB: Questa funzionalita’ richiede di aggiornare Thematic all’ ultima versione disponibile via SVN.
thematic_doctitle()
Mostra il tag <TITLE> nella sezione <HEAD> del documento. L’esempio seguente ci mostra come includere il titolo del blog in tutte le pagine e gli articoli e come modificare il separatore.
function childtheme_doctitle() {$site_name= get_bloginfo('name');// Cambiamo il separatore$separator='»';// teniamo il codice originaleif( is_single() ) {$content= single_post_title('', FALSE);}elseif( is_home() || is_front_page() ) {$content= get_bloginfo('description');}elseif( is_page() ) {$content= single_post_title('', FALSE);}elseif( is_search() ) {$content= __('Search Results for:','thematic');$content.=' '. wp_specialchars(stripslashes(get_search_query()), true);}elseif( is_category() ) {$content= __('Category Archives:','thematic');$content.=' '. single_cat_title("", false);;}elseif( is_tag() ) {$content= __('Tag Archives:','thematic');$content.=' '. thematic_tag_query();}elseif( is_404() ) {$content= __('Not Found','thematic');}else{$content= get_bloginfo('description');}if(get_query_var('paged')) {$content.=' '.$separator.' ';$content.='Page';$content.=' ';$content.= get_query_var('paged');}// fino a qui. Vogliamo il nome del sito ovunque?// ok, ecco come fare$my_elements=array('site_name'=> $site_name,'separator'=> $separator,'content'=> $content);if(!( is_home() || is_front_page() )) {$my_elements=array_reverse($my_elements);}}// Aggiungiamo il filtro alla funzione originaleadd_filter('thematic_doctitle', 'childtheme_doctitle');
thematic_create_contenttype()
Questo filtro crea l’ elemento <META> Content-Type nella sezione <HEAD>del documento.
thematic_canonical_url()
Genera l’ URL canonica. Per maggiori informazioni su questo tag, visitiamo Google, Yahoo o Microsoft.
Possiamo usare il seguente codice se il nostro plugin per SEO gestisce autonomamente e quindi non farlo gestire da Thematic:
function childtheme_canonical_url() {// svuotiamo la funzione}add_filter('thematic_canonical_url','childtheme_canonical_url')
thematic_use_excerpt()
thematic_use_autoexcerpt()
thematic_create_description()
thematic_show_description()
thematic_create_robots()
thematic_show_robots()
thematic_create_stylesheet()
thematic_head_scripts()
Mostra i link ai plugin jQuery inclusi in Thematic. Se non ci piace il menu drop-down, eliminiamolo dal nostro child theme:
// Filter away the default scripts loaded with Thematicfunction childtheme_head_scripts() {// Abscence makes the heart grow fonder}add_filter('thematic_head_scripts','childtheme_head_scripts');
thematic_dropdown_options()
Filtra il link a thematic-dropdowns.js. Possiamo modificare le impostazioni di base del menu drop-down:
// Filter the default drop-down options// http://users.tpg.com.au/j_birch/plugins/superfish/#optionsfunction childtheme_dropdown_options($dropdown_options) { ?><script type="text/javascript">jQuery.noConflict();jQuery(document).ready(function(){jQuery("ul.sf-menu").supersubs({minWidth: 12, // minimum width of sub-menus in em unitsmaxWidth: 27, // maximum width of sub-menus in em unitsextraWidth: 1 // extra width can ensure lines don't sometimes turn over// due to slight rounding differences and font-family}).superfish({delay: 800, // delay on mouseoutanimation: {opacity:'show',height:'show'}, // fade-in and slide-down animation});});</script><?php}add_filter('thematic_dropdown_options','childtheme_dropdown_options');
thematic_show_rss()
thematic_show_commentsrss()
thematic_show_pingback()
thematic_show_commentreply()
Contenuto
thematic_time_title()
thematic_time_display()
thematic_postheader()
thematic_postfooter()
thematic_commenter_link()
Barra laterale
thematic_sidebar()
Footer
thmfooter_theme_link()
Se siamo sviluppatori di child theme e intendiamo rilasciarli, possiamo aggiungere facilmente un link alla pagina del nostro child theme usando gli shorttcode che Thematic Framework per WordPress ci memtte a disposizione.
Ecco il codice da aggiungere al file functions.php del nostro child theme:
// Add a link back to your Child Theme release page in the <a class="theme-link" href="http://themeshaper.com/thematic-for-wordpress" title="Thematic Theme Framework" rel="designer">Thematic Theme Framework</a> shortcodefunction childtheme_theme_link($themelink) {return $themelink . ' & <a class="child-theme-link" href="http://example.com/" title="Awesome Theme" rel="designer">};Awesome Theme</a>';add_filter('thematic_theme_link', 'childtheme_theme_link');
Questo esempio mostrera’ sia il link a Thematic che quello al nostro child theme. Se vogliamo solamente mostrare quello al nostro child theme il codice è il seguente:
// Add a link back to your Child Theme release page in the <a class="theme-link" href="http://themeshaper.com/thematic-for-wordpress" title="Thematic Theme Framework" rel="designer">Thematic Theme Framework</a> shortcodefunction childtheme_theme_link($themelink) {return '<a class="child-theme-link" href="http://example.com/" title="Awesome Theme" rel="designer">Awesome Theme</a>';}add_filter('thematic_theme_link', 'childtheme_theme_link');