PHPackages                             mindkomm/theme-lib-content - 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-content

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

mindkomm/theme-lib-content
==========================

Collection of content helper functions for WordPress themes

1.1.0(6y ago)1356MITPHPPHP &gt;=7.0.0

Since Feb 13Pushed 6y ago3 watchersCompare

[ Source](https://github.com/mindkomm/theme-lib-content)[ Packagist](https://packagist.org/packages/mindkomm/theme-lib-content)[ RSS](/packages/mindkomm-theme-lib-content/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Content
=======

[](#content)

A collection of content helper functions for WordPress themes.

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

[](#installation)

You can install the package via Composer:

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

Usage
-----

[](#usage)

### The content filter

[](#the-content-filter)

A `content` filter that you can use for text [that is not the main content](https://themehybrid.com/weblog/how-to-apply-content-filters).

```
{{ post.custom_text|apply_filters('content') }}
```

Functions
---------

[](#functions)

NameSummaryTypeReturns/Description[gender](#gender)Gets string by gender.`string`[lines\_to\_array](#lines_to_array)Turns each line of a text into an array.`array`[strip\_control\_characters](#strip_control_characters)Strips out forbidden Control Characters that came from copy-pasting text into WYSIWYG editor.`string`The filtered text.[truncate\_close](#truncate_close)Truncates a text close a certain number of characters.`string`Truncated string.### strip\_control\_characters

[](#strip_control_characters)

Strips out forbidden Control Characters that came from copy-pasting text into WYSIWYG editor.

You can’t see these Control Characters when you look at the text, yet they can still lead to unexpected behavior.

`strip_control_characters( string $text )`

**Returns:** `string` The filtered text.

NameTypeDescription$text`string`The text to filter.---

### lines\_to\_array

[](#lines_to_array)

Turns each line of a text into an array.

`lines_to_array( string $string )`

**Returns:** `array`

NameTypeDescription$string`string`Multiline string.**Twig**

```

{% for line in multiline_text|lines_to_array %}
    {{ line }}
{% endfor %}

```

---

### truncate\_close

[](#truncate_close)

Truncates a text close a certain number of characters.

This function doesn’t cut off words, but only adds the words that still fit into the maximum width.

`truncate_close( string $string, int $desired_width = 200, string $more = &nbsp;&hellip; )`

**Returns:** `string` Truncated string.

NameTypeDescription$string`string`String to truncate.$desired\_width`int`Optional. The amount of characters you want to end up with.$more`string`Optional. The text to append as 'more'. Default is a non-breaking space followed by an ellipsis.**Twig**

```
{{ post.content|truncate_close }}
```

---

### gender

[](#gender)

Gets string by gender.

Yes, for now, this supports only male and female genders.

`gender( string $male, string $female, string $gender, array $female_identifiers = [] )`

**Returns:** `string`

NameTypeDescription$male`string`Male representation of string.$female`string`Female representation of string.$gender`string`Gender identifier.$female\_identifiers`array`Identifier keys for female representation. Default `[ 'f', 'female' ]`.**PHP**

```
