定制 mindkomm/theme-lib-links 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mindkomm/theme-lib-links

Composer 安装命令:

composer require mindkomm/theme-lib-links

包简介

Collection of link helper functions for WordPress themes

README 文档

README

Collection of link helper functions for WordPress themes.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-links

Functions

Name Summary Type Returns/Description
get_link_attributes Gets href attribute for a link tag with proper target and rel attributes. string or bool An href attribute with target and rel attributes, when necessary. Returns false if input is empty.
is_external_url Checks if a URL is external or internal. bool Whether the URL is external.
make_anchor_link Converts an URL to an anchor link. string The updated URL.
url_to_domain Converts an URL to just the domain name together with the TLD. string The domain part of the URL.

make_anchor_link

Converts an URL to an anchor link.

Prefix the last segment of a URL with a # to use it as an anchor link.

make_anchor_link( string $url )

Returns: string The updated URL.

Name Type Description
$url string URL to turn into an anchor link.

PHP

// Output: https://www.mind.ch/onepager#subsection
echo make_anchor_link( 'https://www.mind.ch/onepager/subsection' );

is_external_url

Checks if a URL is external or internal.

is_external_url( string $url )

Returns: bool Whether the URL is external.

Name Type Description
$url string URL to be parsed.

PHP

if ( is_external_url( 'https://example.org' ) ) {
    // Do something
}

Twig

{% if is_external_url('https://www.example.org') %}
    {# Do something #}
{% endif %}

url_to_domain

Converts an URL to just the domain name together with the TLD.

url_to_domain( string $url, bool $strip_www = false, int|bool $limit = false )

Returns: string The domain part of the URL.

Name Type Description
$url string The URL to convert.
$strip_www bool Optional. Whether to strip the "www" part of the domain. Default false.
$limit int|bool Optional. Limit to a certain amount of characters. Default false.

PHP

<?php $domain = 'https://www.mind.ch/post/blablabla?param=wow'; ?>
<a href="<?php echo $url; ?>"><?php echo url_to_domain( $domain ); ?></a>

Twig

{# url = 'https://www.mind.ch/post/blablabla?param=wow' #}
<a href="{{ url }}">{{ url_to_domain(url) }}</a>

get_link_attributes

Gets href attribute for a link tag with proper target and rel attributes.

Checks if the URL is internal or external. Adds a target="_blank" for external urls. Inspired by http://stackoverflow.com/a/25090564/1059980. To catch a security vulnerability, the attribute rel="noopener noreferrer" is added, see https://mathiasbynens.github.io/rel-noopener/ for more info.

get_link_attributes( string $url )

Returns: string|bool An href attribute with target and rel attributes, when necessary. Returns false if input is empty.

Name Type Description
$url string URL to be parsed.

PHP

<a <?php echo get_link_attributes( 'https://www.mind.ch/blog' ); ?>>MIND Blog</a>

Twig

<a {{ get_link_attributes(url) }}>MIND Blog</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 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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