Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The
Child Theme Dilemma
WordCamp Milano 2016
Torsten Landsiedel
Hello!
Torsten Landsiedel
WordPress- Freelancer
Moderator German Supportforum
Editor Team de.w.org
Translation Contributor...
Child Theme Usage
Who has used Child Themes?
Child Theme Usage
Why?
Child Theme Problems
Security
Extensibility
Performance
Security Problems
Parent Theme
search.php (with
vulnerability)
Child Theme
search.php (with
vulnerability)
Parent Theme
se...
Child Themes aren’t safe?
Why nobody told us?
Extensibility
Pluggable Functions:
if ( ! function_exists( 'theme_special_nav' ) ) {
function theme_special_nav() {
// Do ...
Missing extensibilities
Framework Theme + Premium Child Theme?
WordPress.org Theme + Child Theme?
Where to put the customi...
Missing extensibilities
Why shouldn’t there be Grandchild Themes?
Missing extensibilities
This idea of releasing advanced child themes just creates
the same problem child themes were meant...
Update of Parent Theme
Without any problems?
It depends …
filter/actions removed?
CSS classes changed?
Markup changed?
Pat...
Performance problems
Many Child Themes are using @import
@import url(../parent-theme/style.css);
But @import stops paralle...
Solution:
De-register styles und re-register/re-enqeue parent and
child styles
function twentytwelve_child_scripts() {
wp_...
Even simpler:
Enqueue parent styles. Done! Just works if
get_stylesheet is used (and just this) in the parent
theme.
// Fa...
New problem:
Many themes are not build that way.
Hardcoded stylesheets in the header.php for example:
<link rel="styleshee...
Performance problems
Or the theme is not compatible with using a child
theme.
Or you have to de-register everything to pre...
Performance problems
Can be very complicated for beginners ...
Performance problems
Justin Tadlocks brilliant solution for the parent theme:
function my_enqueue_styles() {
/* If using a...
Hey Torsten!
Grab some water.
Don’t speak too fast.
:)
Child Theme Problems
Security
Extensibilities
Performance ✓
Idea 1: Child Theme Lite
“Child themes from theme developers should be nothing
more than a stylesheet and a few functions....
Idea 1: Child Theme Lite
Child Theme just contains functions.php
and style.css.
All changes should just be made with hooks...
Idea 1: Child Theme Lite
Problem:
How many themes do something like that?
Idea 2: Child Theme Check
Every template file in the theme is getting a version
number in the file header.
@version 1.0.0
...
Idea 2: Child Theme Check
DEMO!
Child Theme Check
Voilá!
Child Theme Check
Child Theme Check
http://de.wordpress.org/plugins/child-theme-check/
https://github.com/Zodiac1978/tl-template-checker
- T...
Child Theme Problems
Security ✓
Extensibilities (✓)
Performance ✓
Spread the word!
The new default theme is using it, too!
https://github.com/WordPress/twentyseventeen/issues/72
● Italian Translation is waiting for you!
https://translate.wordpress.org/locale/it/default/wp-plugins/chi
ld-theme-check
...
Discussion!
Questions? Contradiction? Alternative solutions?
Theme Shop/Theme Developer: Interested?
Let’s speak about it!...
Thank you for your time!
Have a great coffee break.
Don’t miss the talk about
Child Plugins from Bernhard Kau
(Track 1 - 1...
Upcoming SlideShare
Loading in …5
×

The Child Theme Dilemma (EN) - Milano Edition

2,043 views

Published on

Talk about the problems of child themes in WordPress (incl. solution per plugin) from WordCamp Milano 20156 (updated version)

Published in: Internet
  • Be the first to comment

  • Be the first to like this

The Child Theme Dilemma (EN) - Milano Edition

  1. 1. The Child Theme Dilemma WordCamp Milano 2016 Torsten Landsiedel
  2. 2. Hello! Torsten Landsiedel WordPress- Freelancer Moderator German Supportforum Editor Team de.w.org Translation Contributor and Editor Co-Organisator WP Meetup Hamburg Co-Organisator WordCamp Hamburg @zodiac1978
  3. 3. Child Theme Usage Who has used Child Themes?
  4. 4. Child Theme Usage Why?
  5. 5. Child Theme Problems Security Extensibility Performance
  6. 6. Security Problems Parent Theme search.php (with vulnerability) Child Theme search.php (with vulnerability) Parent Theme search.php (without vulnerability) Child Theme search.php (with vulnerability) update overwrites no update!overwrites
  7. 7. Child Themes aren’t safe? Why nobody told us?
  8. 8. Extensibility Pluggable Functions: if ( ! function_exists( 'theme_special_nav' ) ) { function theme_special_nav() { // Do something. } } Attention: Now you have to maintain the code!
  9. 9. Missing extensibilities Framework Theme + Premium Child Theme? WordPress.org Theme + Child Theme? Where to put the customizations? There are no Grandchild Themes :(
  10. 10. Missing extensibilities Why shouldn’t there be Grandchild Themes?
  11. 11. Missing extensibilities This idea of releasing advanced child themes just creates the same problem child themes were meant to solve: upgradability. – Justin Tadlock http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-an d-grandchild-themes
  12. 12. Update of Parent Theme Without any problems? It depends … filter/actions removed? CSS classes changed? Markup changed? Paths changed?
  13. 13. Performance problems Many Child Themes are using @import @import url(../parent-theme/style.css); But @import stops parallel loading in all browsers. http://www.stevesouders.com/blog/2009/04/09/dont-use-import/
  14. 14. Solution: De-register styles und re-register/re-enqeue parent and child styles function twentytwelve_child_scripts() { wp_deregister_style( 'twentytwelve-style' ); wp_register_style( 'twentytwelve-style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'twentytwelve-child-style', get_stylesheet_uri(), array( 'twentytwelve-style' ) ); } add_action( 'wp_enqueue_scripts', 'twentytwelve_child_scripts', 11 ); Performance problems
  15. 15. Even simpler: Enqueue parent styles. Done! Just works if get_stylesheet is used (and just this) in the parent theme. // Faster than @import add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' ); function my_child_theme_scripts() { wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' ); } Performance problems
  16. 16. New problem: Many themes are not build that way. Hardcoded stylesheets in the header.php for example: <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> Performance problems
  17. 17. Performance problems Or the theme is not compatible with using a child theme. Or you have to de-register everything to preserve the correct order. wp_enqueue_style( 'base_styles', get_template_directory_uri() . '/css/base.css' ); wp_enqueue_style( 'responsive_styles', get_template_directory_uri() . '/css/mobile.css' ); wp_enqueue_style( 'ie_styles', get_template_directory_uri() . '/css/ie.css' );
  18. 18. Performance problems Can be very complicated for beginners ...
  19. 19. Performance problems Justin Tadlocks brilliant solution for the parent theme: function my_enqueue_styles() { /* If using a child theme, auto-load the parent theme style. */ if ( is_child_theme() ) { wp_enqueue_style( 'parent-style', trailingslashit( get_template_directory_uri() ) . 'style.css' ); } /* Always load active theme's style.css. */ wp_enqueue_style( 'style', get_stylesheet_uri() ); } add_action( 'wp_enqueue_scripts', 'my_enqueue_styles' ); http://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes
  20. 20. Hey Torsten! Grab some water. Don’t speak too fast. :)
  21. 21. Child Theme Problems Security Extensibilities Performance ✓
  22. 22. Idea 1: Child Theme Lite “Child themes from theme developers should be nothing more than a stylesheet and a few functions.” – Justin Tadlock http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes
  23. 23. Idea 1: Child Theme Lite Child Theme just contains functions.php and style.css. All changes should just be made with hooks and filters. This would be made within a plugin. Child Theme remains update-ability.
  24. 24. Idea 1: Child Theme Lite Problem: How many themes do something like that?
  25. 25. Idea 2: Child Theme Check Every template file in the theme is getting a version number in the file header. @version 1.0.0 Check of the version number via plugin (or even better via WordPress core). Differences between files can be shown via wp_text_diff().
  26. 26. Idea 2: Child Theme Check DEMO!
  27. 27. Child Theme Check Voilá!
  28. 28. Child Theme Check
  29. 29. Child Theme Check http://de.wordpress.org/plugins/child-theme-check/ https://github.com/Zodiac1978/tl-template-checker - This is a Twitter opportunity! -
  30. 30. Child Theme Problems Security ✓ Extensibilities (✓) Performance ✓
  31. 31. Spread the word! The new default theme is using it, too! https://github.com/WordPress/twentyseventeen/issues/72
  32. 32. ● Italian Translation is waiting for you! https://translate.wordpress.org/locale/it/default/wp-plugins/chi ld-theme-check ● Found a bug? Just open an issue on Github: https://github.com/Zodiac1978/tl-template-checker/issues ● Help me to get this as a recommendation in the Theme Check Plugin (https://de.wordpress.org/plugins/theme-check/): https://github.com/WordPress/theme-check/issues/115 Conribute? Great!
  33. 33. Discussion! Questions? Contradiction? Alternative solutions? Theme Shop/Theme Developer: Interested? Let’s speak about it! @zodiac1978 http://torstenlandsiedel.de/kontakt
  34. 34. Thank you for your time! Have a great coffee break. Don’t miss the talk about Child Plugins from Bernhard Kau (Track 1 - 17:10 h)

×