Custom Icons In Icon Block
-
Is there a way to add custom icons to the list of icons in the icon block?
Viewing 2 replies - 1 through 2 (of 2 total)
-
Hi @yoanwai,
Thanks for getting in touch with us.
I am afraid this is not possible with the provided options in Spectra. We’d love to take this as a feature request. I will surely convey your feedback to our concerned developers. We are always keen to listen to our customers and to receive their feedback. This is the best way to improve our products and services and maintain our client’s satisfaction. ??
Have a nice day!
Before we decided to leave Spectra, I wrote this small proof-of-concept snippet to add our custom icons. We haven’t used it in production, but feel free to take inspiration from it.
/**
* PoC Add Custom Icons to UAGB (Spectra)
*
* Adds additional icons and icon categories to UAGB (Spectra). Hooks into
* the undocumented uagb_icons_chunks filter. The categories seem to be in
* the last item of the array (!?) among the icons. See spectra-icons-v6-3.php.
*
* @todo Re-sort categories by title, move code to Spectra tweaker class, and
* move icons to resource file.
*
* @param mixed $icon_chunks Probably an array with icons and categories.
* @return mixed Probably an array with icons and categories.
*/
function opal_poc_add_uagb_icons( $icon_chunks ) {
if ( ! is_array( $icon_chunks) ) {
return $icon_chunks;
}
$last_chunk = absint( count( $icon_chunks ) - 1 ); // The categories are here for some reason.
// Add additional icons.
$opal_icons = array(
'ns-nikka-systems' => array(
'svg' => array(
'solid' => array(
'width' => 512,
'height' => 512,
'path' => 'm255.89-.04h227.7v129.69l-58.64-31.25v-35.47H90.22l335.14,178.91v-113.99l58.65,32.89v178.95C358.61,273.13,152.56,163.62,28.19,96.43V-.04h227.7Zm-118.78,456.4c-45.54-52.83-49.97-128.89-50.82-195.08-.21-16.4-.03-32.82.18-44.52l294.9,157.09c-34.75,34.29-84.25,59.01-125.48,72.59-47.7-15.72-106.45-46.32-140.63-89.42,6.07,91.05,61.73,131,140.63,154.29,80.47-23.76,176.69-77.97,212.92-157.56C321.99,275.71,174.94,197.43,28,119.16v142.1c0,83.88,36.54,148.69,109.11,195.1Z' ) ),
'label' => __( 'Nikka Systems', 'opal' ),
'custom_categories' => array( 'brands', 'opal' ) ),
'ns-sakerhetsbubblan' => array(
'svg' => array(
'solid' => array(
'width' => 512,
'height' => 512,
'path' => 'm256.01,46.96h0c36.86.02,73.18,9.84,105.03,28.41,48.16,28.08,82.51,73.23,96.71,127.15,14.2,53.91,6.56,110.13-21.52,158.29-18.73,32.12-45.64,58.66-77.82,76.74-31.3,17.59-66.82,26.89-102.73,26.89s-72.96-9.84-104.88-28.45l-24.73-14.42-24.16,15.37c-1.22.78-2.45,1.54-3.68,2.28,1.11-2.94,2.16-5.92,3.14-8.94l7.86-24.16-15.91-19.81c-29.65-36.92-45.98-83.33-45.97-130.69,0-55.74,21.72-108.14,61.14-147.55,39.41-39.41,91.81-61.11,147.54-61.11m.03-47C114.83-.06.34,114.4.33,255.61c0,58.23,19.87,114.72,56.33,160.12-14.47,44.48-49.54,82.16-49.99,82.69-2.14,2.24-2.71,5.55-1.45,8.38,1.17,2.8,3.91,4.62,6.94,4.62.03,0,.06,0,.09,0,48.86,0,88.33-17.97,114.86-34.84,40.5,23.61,84.83,34.85,128.56,34.85,88,0,173.63-45.46,221.15-126.96,71.13-122.01,29.89-278.58-92.11-349.71C345.65,11.99,301.25-.02,256.03-.04h0Zm-40.4,199.5v-43.07c-.47-21.21,16.34-38.78,37.55-39.25,21.21-.47,38.78,16.34,39.25,37.55.01.57.01,1.13,0,1.7v41.68c10.58,3.48,20.49,8.45,29.49,14.64.03-.85.05-1.7.05-2.55v-41.19h0v-12.57c.62-37.53-29.29-68.45-66.82-69.08s-68.45,29.29-69.08,66.82c-.01.75-.01,1.51,0,2.26v53.77c0,1.78.08,3.55.22,5.3,8.88-6.66,18.74-12.08,29.32-16Zm38.4,2.79c-58.71,0-106.31,47.6-106.31,106.31s47.6,106.31,106.31,106.31,106.31-47.6,106.31-106.31-47.6-106.31-106.31-106.31Zm1.83,133.78c-15.17,0-27.47-12.3-27.47-27.47s12.3-27.47,27.47-27.47,27.47,12.3,27.47,27.47-12.3,27.47-27.47,27.47Z' ) ),
'label' => __( 'S?kerhetsbubblan', 'opal' ),
'custom_categories' => array( 'brands', 'opal' ) ) );
$icon_chunks[ $last_chunk ] = array_merge( $icon_chunks[ $last_chunk ], $opal_icons );
// Add custom category.
$icon_chunks[ $last_chunk ]['uagb_category_list'][] = array(
'slug' => 'opal',
'title' => __('Opal', 'ultimate-addons-for-gutenberg') );
return $icon_chunks;
}
add_filter( 'uagb_icons_chunks', 'opal_poc_add_uagb_icons', 10, 1 );
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.