PHP8 Fix for
Warning: Undefined variable $libraries in color_field_library() (line 60 of /var/www/html/sites/all/modules/contrib/color_field/color_field.module)
Needs a patch submitted.
color_field.module
Old
function color_field_library() {
if ($path = libraries_get_path('jquery-simple-color')) {
$libraries['jquery-simple-color'] = array(
'title' => 'recurser jquery simple color',
'website' => 'https://github.com/recurser/jquery-simple-color',
'version' => '1.2.1',
'js' => array(
$path . '/jquery.simple-color.min.js' => array(),
),
);
}
if ($path = libraries_get_path('bgrins-spectrum')) {
$libraries['bgrins-spectrum'] = array(
'title' => 'color_field_spectrum_color_picker',
'website' => 'http://bgrins.github.io/spectrum/',
'version' => '1.6.0',
'js' => array(
$path . '/spectrum.js' => array(),
),
'css' => array(
$path . '/spectrum.css' => array(),
),
);
}
if ($path = libraries_get_path('dematte-color-picker')) {
$libraries['dematte-color-picker'] = array(
'title' => 'color_field_dematte_color_picker',
'website' => 'http://www.dematte.at/colorPicker/',
'version' => '0.9',
'js' => array(
$path . '/colorPicker.js' => array(),
),
);
}
if ($path = libraries_get_path('eyecon-color-picker')) {
$libraries['eyecon-color-picker'] = array(
'title' => 'color_field_eyecon_color_picker',
'website' => 'http://www.eyecon.ro/colorpicker/',
'version' => 'latest',
'js' => array(
$path . '/js/colorpicker.js' => array(),
),
);
}
return $libraries;
}
New
/**
* Implements hook_library().
*/
function color_field_library(): array
{
$libraries = [];
if ($path = libraries_get_path('jquery-simple-color')) {
$libraries['jquery-simple-color'] = [
'title' => 'recurser jquery simple color',
'website' => 'https://github.com/recurser/jquery-simple-color',
'version' => '1.2.1',
'js' => [
$path . '/jquery.simple-color.min.js' => [],
],
];
}
if ($path = libraries_get_path('bgrins-spectrum')) {
$libraries['bgrins-spectrum'] = [
'title' => 'color_field_spectrum_color_picker',
'website' => 'http://bgrins.github.io/spectrum/',
'version' => '1.6.0',
'js' => [
$path . '/spectrum.js' => [],
],
'css' => [
$path . '/spectrum.css' => [],
],
];
}
if ($path = libraries_get_path('dematte-color-picker')) {
$libraries['dematte-color-picker'] = [
'title' => 'color_field_dematte_color_picker',
'website' => 'http://www.dematte.at/colorPicker/',
'version' => '0.9',
'js' => [
$path . '/colorPicker.js' => [],
],
];
}
if ($path = libraries_get_path('eyecon-color-picker')) {
$libraries['eyecon-color-picker'] = [
'title' => 'color_field_eyecon_color_picker',
'website' => 'http://www.eyecon.ro/colorpicker/',
'version' => 'latest',
'js' => [
$path . '/js/colorPicker.js' => [],
],
];
}
return $libraries;
}
Disclaimer: generated via Google Gemini