Child Theme Library
, (*1)
Note: This project is no longer maintained. Please use d2/core instead., (*2)
A config-based composer package that provides a set of modules to extend Genesis child theme development., (*3)
Description
The main purpose of the Child Theme Library is to provide a shareable codebase for commercial Genesis child themes. This is achieved by using configuration-based architecture to separate the theme's reusable logic from it's configuration. Using this approach, we are able to use a single codebase which can be heavily customized by passing in different configs. This project is inspired by the Genesis Theme Toolkit by Gary Jones, but contains additional functionality specific to commercial themes, including support for older versions of PHP. See the Genesis Starter Theme as an example., (*4)
Requirements
Installation
Include the package in your child theme's composer.json
file (an example composer.json
file can be found here)., (*5)
composer require seothemes/child-theme-library
Optionally install the TGMPA composer package:, (*6)
composer require tgmpa/tgm-plugin-activation
Usage
There are three steps to include the Child Theme Library in your project:, (*7)
- Include the Composer
autoload.php
file
- Store the library as a global variable for use throughout your theme
- Initialize the child theme library
All changes to the child theme should be made via the theme configuration file. An example config can be found here., (*8)
The following is an example of how to achieve the steps mentioned above. This code should be placed in your functions.php
file, before any custom code is loaded:, (*9)
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
$child_theme = new SEOThemes\ChildThemeLibrary\Theme();
$child_theme->init();
}
Storing the Child Theme Library object as a global variable provides access to the library's public properties and methods. For example, to print the name of the theme you can do the following:, (*10)
echo $child_theme->name;
Or, to use the Minify CSS helper function:, (*11)
$css = 'body { background-color: red; }';
echo $child_theme->utilities->minify_css( $css );
Structure
The Child Theme Library follows the PHP Package Development Standard folder structure and uses PSR-4 Autoloading., (*12)
./
โโโ docs/
โ โโโ example-config.php
โโโ src/
โ โโโ Admin.php
โ โโโ Attributes.php
โ โโโ Customizer.php
โ โโโ Defaults.php
โ โโโ DemoImport.php
โ โโโ Enqueue.php
โ โโโ HeroSection.php
โ โโโ Layout.php
โ โโโ Markup.php
โ โโโ Plugins.php
โ โโโ Setup.php
โ โโโ Shortcodes.php
โ โโโ Structure.php
โ โโโ Templates.php
โ โโโ Theme.php
โ โโโ Utilities.php
โ โโโ WidgetsAreas.php
โโโ tests/
โโโ .editorconfig
โโโ .gitattributes
โโโ .gitignore
โโโ composer.json
โโโ phpcs.xml
โโโ CHANGELOG.md
โโโ CONTRIBUTING.md
โโโ LICENSE.md
โโโ README.md
Hooks
Name |
Type |
Description |
child_theme_after_title_area |
action |
Runs after the title area |
child_theme_hero_section |
action |
Runs during the hero section |
child_theme_front_page_widgets |
action |
Runs during the front page loop |
child_theme_constants |
filter |
Filters the array of constants |
child_theme_config |
filter |
Filters the path to the config |
child_theme_latest_posts_title |
filter |
Filters the latest posts title |
child_theme_latest_posts_excerpt |
filter |
Filters the latest posts excerpt |
child_theme_footer_backtotop |
filter |
Filters the backtotop shortcode |
Support
Please visit https://github.com/seothemes/child-theme-library/issues/ to open a new issue., (*13)
License
This project is licensed under the GNU General Public License - see the LICENSE.md file for details., (*14)
Authors
See also the list of contributors who participated in this project., (*15)
Acknowledgments
A shout out to anyone who's code was used in or provided inspiration to this project:, (*16)
Christoph Herr,
Gary Jones,
Craig Simpson,
Tim Jensen,
Bill Erickson,
Sridhar Katakam,
Chinmoy Paul,
Nathan Rice,
Brian Gardner, (*17)