WP Manifestindependent plugin directory
manifest / themes / theme-customizer

Kunoichi Theme Customizer

A utility class to integrate WordPress theme customizer API.

by Kunoichi INC. · github.com/kuno1/theme-customizer · website

1stars
144release downloads
≈10active sites
0forks

Install

The author publishes release zips, so WP-CLI can install straight from GitHub:

wp plugin install https://github.com/kuno1/theme-customizer/releases/download/1.2.1/theme-customizer.zip

Readme

Kunoichi Theme Customizer

A handy PHP class to integrate WordPress Theme Customizer.

Installation

composer require kunoichi/theme-customizer

In your theme's functions.php:

require __DIR__ . '/vendor/autoload.php';

How to Implement

This library is an abstract class, so you have to implement it.

<?php

namespace YourNameSpace\Customizer;

use Kunoichi\ThemeCustomizer\CustomizerSetting;

class YourClass extends CustomizerSetting {

    protected $section_id = 'your_custom_setting';

    /**
     * Override this function to register a new section.
     */
    protected function section_setting() {
        return [
            'title'      => __( 'My Theme Setting', 'domain' ),
            'priority'   => 100,
        ];
    }

    /**
     * Return associative array for each fields.
     *
     * @return array
     */
    protected function get_fields(): array {
        return [
            'yoru_serrint_id' => [
                'label'       => __( 'Ad after title', 'domain' ),
                'stored'      => 'option',  // 'option' or 'theme_mod'(default)
                'type'        => 'textarea' // Type of UI.
            ],
        ];
    }
}

And you can call them in your theme's functions.php.

YourNameSpace\Customizer\YourClass::get_instance();

Or, simply scan directory for convenience. Let's suppose that your theme is my-theme and directory is PSR-0 ready like below:

my-theme
└src
  └ MyBrand
     └ MyTheme
        └ Customizers
          ├ ColorSetting
          └ AdSetting

You should call like this:

Kunoichi\ThemeCustomizer::register( 'YourBrand\YourTheme\Customizers' );

Arguments

$namespace

Your PSR-0 name space. Directory will be scan recursively.

$direcotry

If not set, default is get_template_directory() . '/src, which seem to be a common location in theme development.

Predefined Classes

Some customizers are predefined for convenience. See src/Kunoichi\ThemeCustomizer\Pattern.

1. Meta and SEO

Kunoichi\ThemeCutomizer\Pattern\Seo adds HTML meta information like meta-description, OGP, etc.

This customizer is userful to provide basic SEO features. For more advanced features, you should recommmend some plugins.

  • Google Analytics or Google Tag Manager scirpt.
  • Default and Site top OGP image.
  • Top page description.
  • Option to stop all feature(in plugins' favor).

2. Sharing

Kunoichi\ThemeCutomizer\Pattern\Share adds share buttons for SNS. The only codes you should implement:

  • Write code to display share buttons via Kunoichi\ThemeCutomizer\Pattern\Share::render( $position )

Available services are listed in src/Kunoithi/ThemeCustomizer/Models/Brand

Development

wp-env is supported for instant development. You need node, npm, and docker installed.

# Install libraries.
npm install
# Start Container
npm start
# wp-env commands are available via npm.
npm run env stop

License

GPL 3.0 or later.

Read the full README on GitHub →

Releases

TagPublishedAssetDownloads
1.2.1 Apr 25, 2024 theme-customizer.zip 1
1.2.0 Dec 1, 2022 theme-customizer.zip 5
1.1.0 Dec 9, 2020 theme-customizer.zip 6
1.0.0 Sep 23, 2020 theme-customizer.zip 8
0.5.1 Aug 19, 2020 theme-customizer.zip 9
0.5.0 Jun 4, 2020 theme-customizer.zip 10
0.4.3 Jun 4, 2020 theme-customizer.zip 10
0.4.2 May 27, 2020 theme-customizer.zip 3
0.4.1 May 27, 2020 theme-customizer.zip 5
0.4.0 May 26, 2020 theme-customizer.zip 4
0.3.1 May 13, 2020 theme-customizer.zip 4
0.3.0 May 13, 2020 theme-customizer.zip 4
0.2.11 May 7, 2020 theme-customizer.zip 5
0.2.10 May 7, 2020 theme-customizer.zip 4
0.2.9 May 7, 2020 theme-customizer.zip 4
0.2.8 Mar 18, 2020 theme-customizer.zip 4
0.2.7 Nov 28, 2019 theme-customizer.zip 9
0.2.6 Nov 28, 2019 theme-customizer.zip 5
0.2.5 Nov 28, 2019 theme-customizer.zip 6
0.2.4 Nov 28, 2019 theme-customizer.zip 6
0.2.3 Nov 28, 2019 theme-customizer.zip 5
0.2.2 Jul 25, 2019 theme-customizer.zip 10
0.2.1 Jul 25, 2019 theme-customizer.zip 7
0.2.0 Jul 25, 2019 theme-customizer.zip 10

Active-site estimate ≈10 comes from the median of recent superseded releases. Method.