Another proof of concept. The custom control
You create a custom control by extending the WP_Customize_Control class. I check for WP_Customizer_Control existence before adding custom control because WP_Customize_Control is loaded on customizer page only.
<?php
if ( class_exists( ‘WP_Customize_Control’ ) ) {
/**
* Custom customizer option control
*/
class DSS_SVG_Picker_Option extends WP_Customize_Control {
public $type = ‘svg’;
public function render_content() {
?>
<label>
<?php if ( ! empty( $this->label ) ) : ?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php endif; ?>
<?php echo list_svg( esc_attr( $this->value() ) ); ?>
<input type="hidden" id="selected_svg" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />
</label>
<?php
}
}
}
list_svg()
Create a option list with URLs to SVG files. The SVG files are defined in svg.json
<?php
function list_svg( $selected_value = ” ) {
$ret = ”;
$svg_data_file = dirname( __FILE__ ) . ‘/svg.json’;
if ( file_exists(
Source: https://managewp.org/articles/13861/an-svg-logo-custom-control-for-the-wordpress-customizer-per-s-derlind
source https://williechiu40.wordpress.com/2016/11/18/an-svg-logo-custom-control-for-the-wordpress-customizer-per-soderlind/
No comments:
Post a Comment