Skip to content

Get Bootstrap css and js from child theme #52

Open
wants to merge 3 commits into from

2 participants

@jmjf
jmjf commented Apr 6, 2013

I've been getting a better handle on github and have rebuilt my repo. Meanwhile, here is a change that replaces a pair of earlier changes I submitted and you closed. Based on your comment at the time ("the theme customizer is the future") and the fact that I'd made the change in theme options, I'm resubmitting with the option added to the theme customizer instead.

I tested this change on localhost and viewed the page and page source to verify that files are pulling from the right place for Twitter, Child Theme Bootstrap options. I also viewed the page only to verify that Amelia, Journal, and Spruce were working as expected (spot check of Bootswatch themes). Note that Child Theme Bootstrap looks wrong in the customizer, but looks right on the page.

Image below shows what the theme customizer looks like after the change. After the image is the description from the first commit, which explains why I think allowing child themes to have custom Bootstrap files is a good idea. The other two commits are fixes to this branch applied during code review or testing.
CustomizerChange

Adds an option to the theme customizer (inc/theme-customizer.php) and
corresponding changes to functions.php that allows a person using a
child theme to choose to pull Bootstrap (css and js) from the child
theme's css and js directories.

This change allows people using the-bootstrap to compile a custom
version of Bootstrap css files with LESS without overwriting the parent
theme's css files and avoid overriding default colors, fonts, etc. in
their child theme's styles. This can significant simplify child theme
customization and reduce the total size of CSS to load. Tools like
bootswatchr.com make custom Bootstrap easy even for people who aren't
comfortable with LESS tools.

This change also allows theme users to update Bootstrap out of sync with
the parent theme without overwriting the parent's copies of Bootstrap
files. This makes it easier to identify if problems are caused by
Bootstrap customization (now isolated to the child) or are in
the-bootstrap without custom Bootstrap files.

jmjf added some commits Apr 6, 2013
@jmjf jmjf Allow bootstrap css and js from child theme
Adds an option to the theme customizer (inc/theme-customizer.php) and
corresponding changes to functions.php that allows a person using a
child theme to choose to pull Bootstrap (css and js) from the child
theme's css and js directories.

This change allows people using the-bootstrap to compile a custom
version of Bootstrap css files with LESS without overwriting the parent
theme's css files and avoid overriding default colors, fonts, etc. in
their child theme's styles. This can significant simplify child theme
customization and reduce the total size of CSS to load. Tools like
bootswatchr.com make custom Bootstrap easy even for people who aren't
comfortable with LESS tools.

This change also allows theme users to update Bootstrap out of sync with
the parent theme without overwriting the parent's copies of Bootstrap
files. This makes it easier to identify if problems are caused by
Bootstrap customization (now isolated to the child) or are in
the-bootstrap without custom Bootstrap files.
2fc82be
@jmjf jmjf formatting
forgot a space when making Yoda condition (per WP coding standards)
0009bad
@jmjf jmjf fix style name
Forgot to change stylesheet id for child theme bootstrap. Caused
bootstrap.min.css to fail loading when child-bootstrap selected.
Changing to 'child-bootstrap' worked in test.
bbf3b19
@jmjf
jmjf commented Apr 6, 2013

I should probably note that this also provides a simple solution for this issue.

#11

@obenland
Owner
obenland commented Apr 7, 2013

Hey @jmjf,

Thank you for your pull request!

I think a far easier solution would be for the child theme to dequeue the parent's bootstrap files, no?
With pulling the child themes' stylesheet in the_bootstrap_print_styles(), I was already trying to be too smart for my own good - many child theme devs do not expect that. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.