GithubHelp home page GithubHelp logo

kirki-helpers's Introduction

kirki-helpers

Helper scripts for theme authors.

If you're starting a new theme based on underscores, we recommend you start using our fork from https://github.com/aristath/_s as it already includes both of the methods described below, and also has 2 example settings for typography.

Integrating Kirki in your themes

If you want to use Kirki in your themes, it is not recommended to include the plugin files in your theme. By recommending your users install Kirki as a plugin they can get bugfixes easier and faster. A lot of themes use TGMPA to recommend installing plugins, but if you only require Kirki then using TGMPA might be an overkill. In that case, you can use the include-kirki.php file to recommend the installation of Kirki.

When the user visits the customizer, if they don’t have Kirki installed they will see a button prompting them to install it. You can configure the description in that file and make sure you change the textdomain in that file from textdomain to the actual textdomain your theme uses.

Usage:

In your theme's functions.php file add the following line, changing '/inc/include-kirki.php' to the path where the file is located:

require_once get_template_directory() . '/inc/include-kirki.php';

Making sure that output works when Kirki is not installed

If you use the output argument in your fields, Kirki will automatically generate the CSS needed for your theme, as well as any Google-Fonts scripts. In order to make sure that user styles will continue to work even if they uninstall the Kirki plugin, you can include the class-my-theme-kirki file.

Usage:

  • Rename the file to use the actual name of your theme. Example: twentysixteen-kirki.php.
  • Inside the file, search for My_Theme_Kirki and replace it using your theme-name as a prefix. Example: Twentysixteen_Kirki.
  • In your theme's functions.php file add the following line, changing '/inc/class-my-theme-kirki' to the path where the file is located:
require_once get_template_directory() . '/inc/class-my-theme-kirki.php';

Once you do the above, instead of using Kirki to add your config, panels, sections & fields as documented in the Kirki Documentation examples, you will have to use your own class.

Example:

Good:

Twentysixteen_Kirki::add_config( 'my_theme', array(
	'capability'    => 'edit_theme_options',
	'option_type'   => 'theme_mod',
) );

Bad:

Kirki::add_config( 'my_theme', array(
	'capability'    => 'edit_theme_options',
	'option_type'   => 'theme_mod',
) );

The Twentysixteen_Kirki class will act as a proxy to the Kirki class. If the Kirki plugin is installed, then it will be used to add your panels, sections, fields etc. However if the plugin is not installed, the Twentysixteen_Kirki will make sure that all your CSS and google-fonts will still work.

kirki-helpers's People

Contributors

aristath avatar daviedr avatar josephgabito avatar rinkuyadav999 avatar

Watchers

 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.