Giter Site home page Giter Site logo

jp-pre's Introduction

JP PRE

A mini CSS preprocesser for easier output of color values set in the theme customizer. Based on an article I wrote for Tuts+.

This code is under development See discussion at https://www.facebook.com/groups/advancedwp/806575116071371/ of current status. Right now a new way of outputting the data using wp_add_inline_style() is being tested in the theme_support branch.

Usage

Add this file to your theme/ child theme and include it from functions.php preferably as a composer dependency or a Git submodule or if you must, copypasta.

Add a file to the root level of your theme/ child theme called customizer.css (or whatever you define in JP_PRE_FILE_NAME). In that file write CSS using the names of theme mods in brackets in place of the values. For example:

h1.post-title {
    color: [post_title_color];
}

FAQ

Why Are You Using wp_head for output not wp_add_inline_style()?

You're right wp_add_inline_style() is so much more doing it right. I'm not for two reasons:

  • I don't know what the handle you used when you added your theme's css.
  • You can use that same function with wp_add_inline_style()

How Can I Use wp_add_inline_style()?

You must follow these two easy steps:

  • Define JP_PRE_OUTPUT_IN_HEADER false in wp-config.
  • In a function hooked to wp_enqueue_scripts, after you've enqueued your main style sheet, do something like this:

wp_add_inline_style( 'handle-for-your-stylesheet', jp_pre_theme_customizer_output() );

How Can I Change The Name And/Or Location Of Customizer.css?

You can set the name by defining JP_PRE_FILE_NAME in wp-config.

You can change the path its loaded from using the filter 'jp_pre_customizer_css_file_path'

Can I Use This For Other Values Besides Color Values?

Probably. But, at some point it's going to make more sense to use a full PHP implementation of SASS or LESS. At that point, you should be asking yourself important questions re: bloat, options overload and your inability to make design decisions.

What If I'm Using Options Instead Of Theme Mods

You're doing it wrong.

jp-pre's People

Contributors

shelob9 avatar

Stargazers

Matt Cromwell avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.