'',
'library' => '',
];
}
/**
* Render Icons control output in the editor.
*
* Used to generate the control HTML in the editor using Underscore JS
* template. The variables for the class are available using `data` JS
* object.
*
* @since 2.6.0
* @access public
*/
public function content_template() {
?>
<# if ( 'inline' === data.skin ) { #>
render_inline_skin(); ?>
<# } else { #>
render_media_skin(); ?>
<# } #>
get_control_uid();
?>
<# if ( data.description ) { #>
{{{ data.description }}}
<# } #>
true,
'dynamic' => [
'categories' => [ TagsModule::IMAGE_CATEGORY ],
'returnType' => 'object',
],
'search_bar' => true,
'recommended' => false,
'skin' => 'media',
'exclude_inline_options' => [],
];
}
public function support_svg_import( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
public function on_import( $settings ) {
if ( empty( $settings['library'] ) || 'svg' !== $settings['library'] || empty( $settings['value']['url'] ) ) {
return $settings;
}
add_filter( 'upload_mimes', [ $this, 'support_svg_import' ], 100 );
$imported = Plugin::$instance->templates_manager->get_import_images_instance()->import( $settings['value'] );
remove_filter( 'upload_mimes', [ $this, 'support_svg_import' ], 100 );
if ( ! $imported ) {
$settings['value'] = '';
$settings['library'] = '';
} else {
$settings['value'] = $imported;
}
return $settings;
}
}