mindkomm/theme-lib-links-phone
Composer 安装命令:
composer require mindkomm/theme-lib-links-phone
包简介
Collection of phone link helper functions for WordPress themes
README 文档
README
Collection of phone link helper functions for WordPress themes.
- Provides you with a set of functions to handle phone links.
- Automatically adds a
<meta name="format-detection" content="telephone=no">entry to your website to disable detection of phone links from third-party scripts.
Installation
You can install the package via Composer:
composer require mindkomm/theme-lib-links-phone
Usage
When you use Timber, you can use some of the provided functions in Twig.
Twig
<a {{ get_phone_link_attributes(number) }} aria-label="{{ phone_accessible(number) }}">{{ number }}</a>
Functions
| Name | Summary | Type | Returns/Description |
|---|---|---|---|
| get_phone_link_attributes | Gets phone number wrapped in proper HTML attributes. | string |
HTML attribute string. |
| phone_accessible | Formats phone number for screenreaders. | string |
Formatted telephone number for accessibility. |
| phone_raw | Gets phone number without any formatting. | string |
Formatted telephone number. |
phone_accessible
Formats phone number for screenreaders.
Will convert 052 203 45 00 to 0 5 2. 2 0 3. 4 5. 0 0. This makes a phone number easier to listen to. Adds
spaces and periods to the phone number. The spaces tell the screen reader to read each digit individually. The
periods tell the screen reader to pause (like at the end of a sentence).
Add the resulting string as an aria-label to your phone number link.
phone_accessible( string $phone_number )
Returns: string Formatted telephone number for accessibility.
| Name | Type | Description |
|---|---|---|
| $phone_number | string |
Telephone number. |
PHP
<?php $number = '052 203 45 00'; ?> <a href="tel:<?php echo $number; ?>" aria-label="<?php echo phone_accessible( $number ); ?>"><?php echo $number; ?></a>
Twig
<a href="tel:{{ number }}" aria-label="{{ phone_accessible(number) }}">{{ number }}</a>
phone_raw
Gets phone number without any formatting.
Example: From '+41 052 203 45 00' to '00410524500'
phone_raw( string $phone_number )
Returns: string Formatted telephone number.
| Name | Type | Description |
|---|---|---|
| $phone_number | string |
Telephone number. |
PHP
<a href="tel:<?php echo phone_raw( $phone_number ); ?>"><?php echo $phone_number; ?></a>
get_phone_link_attributes
Gets phone number wrapped in proper HTML attributes.
get_phone_link_attributes( string $phone_number )
Returns: string HTML attribute string.
| Name | Type | Description |
|---|---|---|
| $phone_number | string |
Telephone number. |
PHP
<a <?php echo get_phone_link_attributes( '+41 52 203 45 00' ); ?>>+41 52 203 45 00</a>
will result in
HTML
<a href="tel:0041522034500" rel="nofollow">+41 52 203 45 00</a>
Twig
<a {{ get_phone_link_attributes(phone_number) }}>{{ phone_number }}</a>
Twig functions
You need Timber to use these functions.
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-links-phone 适用场景与选型建议
mindkomm/theme-lib-links-phone 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 515 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mindkomm/theme-lib-links-phone 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mindkomm/theme-lib-links-phone 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 515
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-13