sanitize_color($_POST['_term_bg_color'])
);
}
}
/**
* Loads the required media files for the media manager and scripts for media widgets.
*/
public function load_scripts()
{
wp_enqueue_media();
// Enqueue Style
wp_enqueue_style('aarambha-kits-term', AARAMBHA_KITS_URL . 'assets/build/css/term.css', array('wp-color-picker'), AARAMBHA_KITS_VERSION, 'all');
// Enqueue Script
wp_enqueue_script('wp-color-picker-alpha', AARAMBHA_KITS_URL . 'assets/build/library/wp-color-picker-alpha/wp-color-picker-alpha.js', array('jquery', 'wp-color-picker'), '3.0.2', true);
wp_enqueue_script('aarambha-kits-term', AARAMBHA_KITS_URL . 'assets/build/js/term.js', array('wp-color-picker-alpha'), AARAMBHA_KITS_VERSION, true);
$locale = apply_filters(
'aarambha_kits_term_var',
array(
'upload_image' => esc_html__('Choose Image', 'aarambha-kits'),
'use_image' => esc_html__('Select', 'aarambha-kits'),
)
);
wp_localize_script('aarambha-kits-term', 'AARAMBHA_KITS', $locale);
}
/**
* Sanitize the color.
*
* @param string $color Input from the term colorpicker field
*
* @return string
*/
public function sanitize_color($color)
{
if ('' === $color) {
return '';
}
// To allow hex, rgba(), and var() values or custom values like transparent run through custom preg_replace to remove most special characters and spaces.
if (strpos($color, '#') === 0) {
return sanitize_hex_color($color);
} else {
return preg_replace('/[^A-Za-z0-9_)(\-,.]/', '', $color);
}
}
}
// Class needed only in the admin
if (is_admin()) {
Aarambha_Kits_Admin_Term::get_instance();
}