Library that allows to edit simple text options in preview part of WordPress Customizer, on frontend.
$ composer require viktor777/wp-customizable-options
register_customizable_options();
the_customizable_text( $option, $default = false );
By default text is wrapped in tag 'span' when admin is in Customizer. You can change it with filter:
add_filter( 'the_customizable_text_wrapper_tag', function () {
return 'div';
} );
There is 'esc_html' function is implemented to text by default. You can change it with next code:
/**
* 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 );
} );
- 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'