PHPackages                             mindkomm/theme-lib-links - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mindkomm/theme-lib-links

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mindkomm/theme-lib-links
========================

Collection of link helper functions for WordPress themes

2.0.0(1y ago)06131[1 PRs](https://github.com/mindkomm/theme-lib-links/pulls)1MITPHPPHP &gt;=7.0.0

Since Feb 13Pushed 1y ago3 watchersCompare

[ Source](https://github.com/mindkomm/theme-lib-links)[ Packagist](https://packagist.org/packages/mindkomm/theme-lib-links)[ RSS](/packages/mindkomm-theme-lib-links/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (1)

Links
=====

[](#links)

Collection of link helper functions for WordPress themes.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require mindkomm/theme-lib-links
```

Functions
---------

[](#functions)

NameSummaryTypeReturns/Description[get\_link\_attributes](#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](#is_external_url)Checks if a URL is external or internal.`bool`Whether the URL is external.[make\_anchor\_link](#make_anchor_link)Converts an URL to an anchor link.`string`The updated URL.[url\_to\_domain](#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

[](#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.

NameTypeDescription$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

[](#is_external_url)

Checks if a URL is external or internal.

`is_external_url( string $url )`

**Returns:** `bool` Whether the URL is external.

NameTypeDescription$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

[](#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.

NameTypeDescription$url`string`The URL to convert.$strip\_www`bool`Optional. Whether to strip the "www" part of the domain. Default false.$limit`int&#124;bool`Optional. Limit to a certain amount of characters. Default false.**PHP**

```
