Last active
May 24, 2017 09:03
-
-
Save Youhan/237346bdf841bb925044ec13d992f289 to your computer and use it in GitHub Desktop.
Update vc_icon and add your own to the list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1- update map for vc_icons | |
add_action( 'vc_after_init', 'hubble_vc_icon_settings' ); | |
function hubble_vc_icon_settings() { | |
if ( ! WPBMap::exists('vc_icon') ) | |
return false; | |
$vc_icon_map = WPBMap::getShortCode('vc_icon'); | |
//$params = $vc_icon_map['params']; | |
$vc_icon_map['params'][0]['value'] = array( | |
__( 'Hubble Icons', 'hubble' ) => 'hubbleicons', | |
__( 'Font Awesome', 'hubble' ) => 'fontawesome', | |
__( 'Open Iconic', 'hubble' ) => 'openiconic', | |
__( 'Typicons', 'hubble' ) => 'typicons', | |
__( 'Entypo', 'hubble' ) => 'entypo', | |
__( 'Linecons', 'hubble' ) => 'linecons', | |
__( 'Mono Social', 'hubble' ) => 'monosocial', | |
__( 'Material', 'hubble' ) => 'material', | |
); | |
$insert_icon = array( | |
array( | |
'type' => 'iconpicker', | |
'heading' => esc_html__( 'Icon', 'hubble' ), | |
'param_name' => 'icon_hubbleicons', | |
'value' => 'oli oli-heart', | |
'settings' => array( | |
'emptyIcon' => false, | |
'type' => 'hubbleicons', | |
'iconsPerPage' => 4000, | |
), | |
'dependency' => array( | |
'element' => 'type', | |
'value' => 'hubbleicons', | |
), | |
'description' => esc_html__( 'Select icon from library.', 'hubble' ), | |
) | |
); | |
array_splice( $vc_icon_map['params'], 1, 0, $insert_icon ); // splice in at position 3 | |
vc_map_update('vc_icon', 'params', $vc_icon_map['params']); | |
} | |
// 2- add your icon set | |
function hubble_iconpicker_type_hubbleicons($icons) | |
{ | |
$hubble_icons = array( | |
array( 'oli oli-Orcid'=>'Orcid' ), | |
array( 'oli oli-GoogleScholar'=>'GoogleScholar' ), | |
array( 'oli oli-GoogleScholar2'=>'GoogleScholar2' ), | |
array( 'oli oli-ResearchGate'=>'ResearchGate' ), | |
array( 'oli oli-ResearchGate2'=>'ResearchGate2' ), | |
array( 'oli oli-Mendeley'=>'Mendeley' ) | |
// ... | |
); | |
return array_merge( $icons, $hubble_icons ); | |
} | |
add_filter( 'vc_iconpicker-type-hubbleicons', 'hubble_iconpicker_type_hubbleicons' ); | |
// 3- enqueue your icon set ad admin | |
function hubble_enqueue_kelpericons_css($font){ | |
wp_register_style( 'kelpericons', HUBBLE_CSS . '/ol-icons.css',array(),HUBBLE_THEME_VERSION); | |
wp_enqueue_style( 'kelpericons' ); | |
} | |
add_action('admin_enqueue_scripts', 'hubble_enqueue_kelpericons_css'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment