{ "branches": { "parent": "child rewrites, hooks", "templating": "some examples" } }
CSS PHP JavaScript
Pull request Compare This branch is 14 commits ahead, 1032 commits behind roots:master.
Latest commit f62504e Aug 25, 2013 @leoj3n composer.json add
Permalink
Failed to load latest commit information.
assets
doc/assets/img
lang
lib
tasks Fix names for enqueued CSS/JS Mar 1, 2013
templates
.editorconfig
.gitignore
.gitmodules
.jshintrc
404.php Simplify alerts Feb 12, 2013
CHANGELOG.md
CONTRIBUTING.md Roots 6.5.0 Aug 23, 2013
Gruntfile.js
LICENSE.md
README.md
base.php Merge branch 'master' of git://github.com/retlehs/roots into parent Jul 22, 2013
composer.json
functions.php
index.php
package.json
page.php Add theme wrapper, re-organize template files Aug 18, 2012
screenshot.png
single.php
style.css
template-custom.php

README.md

Roots Theme — Parent

Proof of concept using Roots Theme as a parent theme without removing theme support for root-relative-urls or rewrites. Also implements Theme Hook Alliance.

Theme Hook Alliance

You must initialize the submodule: git submodule init && git submodule update.

Example Code

Example code for your child's functions.php

Common enqueues/dequeues:

add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts', 101 );
function my_enqueue_scripts() {
  // dequeue style.css
  wp_dequeue_style( 'roots_child' );

  // enqueue child_plugins.js
  wp_enqueue_script( 'my_child_plugins',
    trailingslashit( get_stylesheet_directory_uri() ) . 'assets/js/child_plugins.js', array(), false );

  // enqueue main.js with custom dependencies
  wp_dequeue_script( 'roots_main' );
  wp_enqueue_script( 'my_main',
    trailingslashit( get_stylesheet_directory_uri() ) . 'assets/js/main.js', array( 'jquery', 'my_child_plugins' ), false );
}

Tips

  • Copy lib/config.php to lib/config.php in the root of your child theme. Now you have full control over sidebar display, generated classes and other configurations from the child.
  • If permalinks/rewrites are working and being used, assets in the child will successfully override parent assets. If rewrites aren't activated, the child assets must be explicitly registered, and the parents unregistered. To test the override, create assets/js/main.js or assets/css/app.css in the child; it should get included instead of the parent version of the same file.

Reference

This is what your .htaccess would look like using roots-simple-child:


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{DOCUMENT_ROOT}/app/themes/roots-simple-child/$1 -f
RewriteRule ^(.*[^/])/?$ /app/themes/roots-simple-child/$1 [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/app/themes/roots/$1 -f
RewriteRule ^(.*[^/])/?$ /app/themes/roots/$1 [QSA,L]
RewriteRule ^plugins/(.*) /app/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Contributing

Screencast