mindkomm/theme-lib-icons 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mindkomm/theme-lib-icons

Composer 安装命令:

composer require mindkomm/theme-lib-icons

包简介

Collection of icon sprite helper functions for WordPress themes

README 文档

README

Collection of icon sprite helper functions for WordPress themes.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-icons

Functions

Name Summary Type Returns/Description
get_icon Get an icon string The HTML to be used in a template.
get_icon_url Get the URI to the icon sprite. string The URI to the icon sprite. Default build/icons/icons.svg
get_svg_icon Return HTML for an accessible SVG icon in an icon sprite. string The HTML to be used in a template.
prepare_html_tag_attribute Turn a value and a name into an HTML attribute. string

get_icon

Get an icon

This function is a wrapper that makes it easier to include an icon by only providing the name of the icon and not the whole path. By adding this function, it’s also possible to use the theme version constant for cache busting.

get_icon( string $icon_name, string $width, string $height, array $args = [] )

Returns: string The HTML to be used in a template.

Name Type Description
$icon_name string The slug of the icon.
$width string Width in pixel the icon should be displayed at.
$height string Height in pixel the icon should be displayed at.
$args array Optional. Array of arguments for SVG icon. See get_svg_icon() function.

PHP

<?php
echo get_icon( 'angle-down', 12, 12, [ 'class' => 'icon icon-dropdown' ] );

get_svg_icon

Return HTML for an accessible SVG icon in an icon sprite.

Has the possibility to add a description for the icon to provide better accessibility.

get_svg_icon( string $path, string $width = '', string $height = '', array $args = [] )

Returns: string The HTML to be used in a template.

Name Type Description
$path string Absolute URL to the icon in an icon sprite.
$width string Width in pixel the icon should be displayed at.
$height string Height in pixel the icon should be displayed at.
$args array Optional. Array of arguments for SVG icon.

  • $class
    string Class names for the SVG icon.
  • $id
    string ID of the SVG icon.
  • $description
    string Description of the icon for better accessibility. Don’t describe the icon, but describe what it means.

PHP

<?php
echo get_svg_icon(
    'https://www.mind.ch/wp-content/theme/theme-mind/build/icons/icon-sprite.svg#arrow-right',
    20, 20,
    [ 'class' => 'icon']
);

prepare_html_tag_attribute

Turn a value and a name into an HTML attribute.

prepare_html_tag_attribute( string $value = '', string $name = '' )

Returns: string

Name Type Description
$value string The value to use.
$name string The attribute’s name.

get_icon_url

Get the URI to the icon sprite.

Returns: string The URI to the icon sprite. Default build/icons/icons.svg

Filters

get_icon_url

The default location for the icon sprite is build/icons/icons.svg. If you’ve set up your theme with a different folder structure, you can use the get_icon_url filter to use a different URL throughout this library:

add_filter( 'get_icon_url', function( $icon_url ) {
    return 'absolute/path/to/your/icon/sprite.svg';
} );

Twig Functions

You need Timber to use this.

icon

Shorthand function for get_icon().

{{ icon('angle-down', 12, 12, { class: 'icon icon-dropdown' }) }}

Support

This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.

mindkomm/theme-lib-icons 适用场景与选型建议

mindkomm/theme-lib-icons 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 361 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mindkomm/theme-lib-icons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mindkomm/theme-lib-icons 我们能提供哪些服务?
定制开发 / 二次开发

基于 mindkomm/theme-lib-icons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 361
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-13