2017 © Pedro Peláez
 

library wp-customizable-options

Library for live editing in preview part of WordPress Customizer.

image

viktor777/wp-customizable-options

Library for live editing in preview part of WordPress Customizer.

  • Friday, July 8, 2016
  • by Viktor777
  • Repository
  • 2 Watchers
  • 2 Stars
  • 0 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WordPress Customizable Options

Library that allows to edit simple text options in preview part of WordPress Customizer, on frontend., (*1)

Installation

Composer

$ composer require viktor777/wp-customizable-options

Usage

Initialization

register_customizable_options();

Editable option

the_customizable_text( $option, $default = false );

Change default wrapper

By default text is wrapped in tag 'span' when admin is in Customizer. You can change it with filter:, (*2)

add_filter( 'the_customizable_text_wrapper_tag', function () {
    return 'div';
} );

Change default filter

There is 'esc_html' function is implemented to text by default. You can change it with next code:, (*3)

/**
 * Remove default filter
 */
remove_filter( 'the_customizable_text_value', '_the_customizable_text_value' );
/**
 * Lets use e.g. 'esc_url' as filter
 */
add_filter( 'the_customizable_text_value', function () {
    return is_bool( $value ) ? $value : esc_url( $value );
} );

Demo

https://youtu.be/pCT5_stDPYM, (*4)

Notes

  • If you do not add setting in Customizer with your code, it will be stored in section which is called 'Customizable Options' by default
  • Label of control in Customizer will be generated from option name by default, e.g. 'customizable_option' => 'Customizable Option'

The Versions

08/07 2016

dev-master

9999999-dev

Library for live editing in preview part of WordPress Customizer.

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0