sweet child o' themes
TRANSCRIPT
![Page 1: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/1.jpg)
Sweet Child O’ Themes
![Page 2: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/2.jpg)
Breno AlvesDesenvolvedor full-stack na Monocromo.
Contribui para alguns projetos e comunidades open-source.
Atualmente trabalha somente com projetos em WordPress.
![Page 3: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/3.jpg)
O que é um child theme?
Um tema que herda funcionalidades e estilos de um outro tema (parent theme).
É a forma mais recomendada para fazer modificações em qualquer tema WordPress.
![Page 4: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/4.jpg)
O que dá pra fazer com ele?
Em geral, você pode adicionar, remover ou modificar qualquer funcionalidade de um parent theme.
![Page 5: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/5.jpg)
■ Menus
■ Sidebars
■ Widgets
■ Templates
■ Scripts
■ Shortcodes
■ Metaboxes
■ Hooks
![Page 6: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/6.jpg)
Pequenas agências e freelancers
Muitas vezes o processo de desenvolvimento é complexo. Por que não buscar uma alternativa viável e de baixo custo para seus projetos?
![Page 7: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/7.jpg)
■ Redução de custos
■ Menor tempo de desenvolvimento
■ Flexibilidade
■ Fidelização de pequenos clientes
![Page 8: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/8.jpg)
Como eu faço um child theme?
![Page 9: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/9.jpg)
/*
Theme Name: Child Theme
Author: Breno Alves
Description: Um novo child theme de exemplo.
Version: 1.0.0
Template: parent-theme
*/
style.css
![Page 10: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/10.jpg)
Ao trabalhar no contexto de um child theme, você deverá sempre utilizar como referência o stylesheet do tema, pois as funções de template ficam associadas ao parent theme.
E apenas um cuidado!get_template_directory != get_stylesheet_directory
![Page 11: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/11.jpg)
Códigos úteis
![Page 12: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/12.jpg)
<?php
// Adiciona a action após carregar o tema
add_action( 'after_setup_theme', 'remove_menus' );
// Desregistra os menus
function remove_menus() {
unregister_nav_menu( 'nome-do-menu' );
}
?>
Menus
![Page 13: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/13.jpg)
<?php
// Adiciona a action após a inicialização dos widgets
add_action( 'widgets_init', 'remove_widgets' );
// Remove o widget de calendário padrão do WordPress
function remove_widgets() {
unregister_widget( 'WP_Widget_Calendar' );
}
?>
Widgets
![Page 14: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/14.jpg)
<?php
// Adiciona a action após o enfileiramente dos scripts
add_action( 'wp_enqueue_scripts', 'remove_widgets' );
// Remove um script
function remove_widgets() {
wp_dequeue_style( 'parent-style' );
}
?>
Scripts
![Page 15: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/15.jpg)
Exemplos
![Page 20: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/20.jpg)
“Ah legal, mas tem problema de performance, né?”
![Page 21: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/21.jpg)
Nem tudo são flores, mas...
Usar um child theme pode trazer algumas desvantagens, mas tudo dependerá do contexto do projeto em que você estiver.
Para projetos que não exigem tanto de desempenho a diferença é muito pequena (quase nenhuma) pois o WordPress cuida de todo o carregamento de forma inteligente.
![Page 22: Sweet Child O' Themes](https://reader034.vdocuments.com.br/reader034/viewer/2022050723/55b70e4dbb61ebdb3b8b468f/html5/thumbnails/22.jpg)
Em geral, o bom desempenho de um child theme está ligado à qualidade de desenvolvimento do seu parent theme.
Verificar se o parent theme oferece o suporte adequado e segue às melhores práticas é essencial para que o seu child theme não tenha problemas.