Skip to content

Instantly share code, notes, and snippets.

@asifpix
Created December 25, 2018 11:12
Show Gist options
  • Save asifpix/e34531201c16c56c6fd522e2d808068d to your computer and use it in GitHub Desktop.
Save asifpix/e34531201c16c56c6fd522e2d808068d to your computer and use it in GitHub Desktop.
Adding Custom Icon in Elementor's default icons array. This snippet created by Asif Islam from iThemesLab.
<?php
function itl_icons_filters( $controls_registry ) {
// Get existing icons
$icons = $controls_registry->get_control( 'icon' )->get_settings( 'options' );
//Create array with your icon set
$newIcons = array(
'icon-001-worldwide' => 'worldwide',
'icon-008-like' => 'like',
'icon-025-globe' => 'globe',
'icon-017-mobile' => 'mobile',
);
//Inject new icon set into default icon list array
if ( !empty($newIcons) && is_array( $newIcons ) ) {
$icons = array_merge( $newIcons, $icons);
}
// send back new array
$controls_registry->get_control( 'icon' )->set_settings( 'options', $icons );
}
add_action( 'elementor/controls/controls_registered', 'itl_icons_filters', 10, 1);
// enqueue css file into editor
function itl_new_icon(){
wp_enqueue_style( 'new-icon', plugins_url( 'YOUR_ICON_CSS_PATH', __FILE__ ) );
}
add_action( 'elementor/editor/after_enqueue_styles', 'itl_new_icon' );
//enqueue css file for front-end
function seokit_core_assets() {
wp_enqueue_style( 'new-icon', plugins_url( 'YOUR_ICON_CSS_PATH', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'seokit_core_assets' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment