apiki / carbon-field-icon
Carbon Fields extension, that adds a Icon field type.
Installs: 1 446
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 14
Language:JavaScript
Requires
- htmlburger/carbon-fields: ^3.0
- dev-master
- v3.1.1
- v3.1.0
- v3.0.0
- 2.2.0
- 2.2.0-beta.1
- 2.0.0
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/browserify-sign-4.2.2
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/babel/traverse-7.23.2
- dev-dependabot/npm_and_yarn/fsevents-1.2.13
- dev-dependabot/npm_and_yarn/debug-2.6.9
- dev-development
This package is auto-updated.
Last update: 2025-03-01 00:24:27 UTC
README
Provides the ability to select an icon or a glyph.
Supported glyphs
- Font Awesome (v5.8.1)
- Dashicons
- Custom
Usage
Font Awesome only (default):
Field::make( 'icon', 'social_site_icon', __( 'Icon', 'crb' ) ),
Dashicons only:
Field::make( 'icon', 'social_site_icon', __( 'Icon', 'crb' ) ) ->add_dashicons_options(),
Dashicons and Font Awesome:
Field::make( 'icon', 'social_site_icon', __( 'Icon', 'crb' ) ) ->add_dashicons_options() ->add_fontawesome_options(),
Custom icon list:
Field::make( 'icon', 'social_site_icon', __( 'Icon', 'crb' ) ) ->set_options( array( // Minimal settings: 'my-custom-icon-1' => array( 'name' => __( 'My Custom Icon 1' ), 'icon' => get_template_directory() . '/icons/my-custom-icon-1.svg', ), // Full settings: 'my-custom-icon-2' => array( 'name' => __( 'My Custom Icon 2' ), 'icon' => get_template_directory() . '/icons/my-custom-icon-2.svg', 'id' => 'my-custom-icon-2', 'class' => 'my-custom-prefix-class', 'search_terms' => array( 'shop', 'checkout', 'product' ), ), ) ),
Custom icon list (using providers):
class Custom_Icon_Provider implements Carbon_Field_Icon\Providers\Icon_Provider_Interface { public function parse_options() { return array( // Minimal settings: 'custom-icon-1' => array( 'name' => __( 'Custom Icon 1' ), 'icon' => get_template_directory() . '/icons/custom-icon-1.svg', ), // Full settings: 'custom-icon-2' => array( 'name' => __( 'Custom Icon 2' ), 'icon' => get_template_directory() . '/icons/custom-icon-2.svg', 'id' => 'custom-icon-2', 'class' => 'custom-prefix-class', 'search_terms' => array( 'shop', 'checkout', 'product' ), ), ); } } add_action( 'carbon_fields_icon_field_loaded', 'crb_register_custom_icon_field_provider' ); function crb_register_custom_icon_field_provider() { $provider_id = 'custom'; \Carbon_Fields\Carbon_Fields::instance()->ioc['icon_field_providers'][ $provider_id ] = function( $container ) { return new Custom_Icon_Provider(); }; \Carbon_Field_Icon\Icon_Field::add_provider( [ $provider_id ] ); } Container::make( 'theme_options', __( 'Theme Options', 'crb' ) ) ->set_page_file( 'crbn-theme-options.php' ) ->add_fields( array( Field::make( 'icon', 'crb_custom_icon', __( 'Choose Custom Icon', 'crb' ) ) ->add_provider_options( 'custom' ), ) );