PHPackages                             enesakarsu/shortcode-hunter - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. enesakarsu/shortcode-hunter

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

enesakarsu/shortcode-hunter
===========================

The PHP Shortcode Hunter - PHP shortcode class, nested shortcodes and custom shortcodes

v0.1(4y ago)114MITPythonPHP &gt;=5.3

Since Nov 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/enesakarsu/shortcode-hunter)[ Packagist](https://packagist.org/packages/enesakarsu/shortcode-hunter)[ RSS](/packages/enesakarsu-shortcode-hunter/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

shortcode-hunter
================

[](#shortcode-hunter)

The Shortcode Hunter - PHP shortcode class, nested shortcodes and custom shortcodes

### Installation

[](#installation)

```
composer require enesakarsu/shortcode-hunter
```

### Syntax of shortcodes

[](#syntax-of-shortcodes)

Shortcodes are written in square brackets.Every opened shortcodes should be closed. Usage example;

```
[example]shortcode[/example] and example text
```

You can send parameters to the shortcodes if you want. Parameters are written in two curly braces. Usage example;

```
[post id={{22}}][/post]
and
[text color={{red}}]colored text[/text]
```

### Why do shortcodes use?

[](#why-do-shortcodes-use)

You can capture shortcodes in a text and make them do whatever you want.

Example: `[post id={{1}}][/post]`

We can capture this shortcode in the text and pull the content with an id value of 1 from the database.

Example: `[date][/date]`

We can create a shortcode named "date" and print the current time in text.

What you (guys)can do is totally up to your imagination.

Usage Example
=============

[](#usage-example)

### Creating a shortcode

[](#creating-a-shortcode)

To create a shortcode, open the `shortcode-hunter/src/shortcodes.php` file and create the shortcode you want like the example below. While creating the shortcode, we write the name of our shortcode as the first parameter and the name of the function we want to run as the second parameter.

Normal function:

```
$shortcode->create("example", "exampleFunction");
```

Class method:

```
$shortcode->create("example", "class@method");
```

Above, we asked it to run the function named "exampleFunction" for the "example" shortcode. Now let's create that function in the `shortcode-hunter/src/functions.php` file.

---

**NOTE**

The first parameter of the function to be created should be $values ​​and the second parameter should be $content. Otherwise, parameters and content cannot be accessed.

---

```
function exampleFunction($values, $content){
return "hello";
}
```

### Parsing the shortcode

[](#parsing-the-shortcode)

Create an index.php file and include the shortcode-hunter class in the file. Then send some text as a parameter to the shortcode's unparse method.

```

```

If I run the index.php file, the output I will get is:

Output: `hello`

### Accessing the content of the shortcode

[](#accessing-the-content-of-the-shortcode)

If I want to access the content of the shortcode;

```
function exampleFunction($values, $content){
return $content;
}
```

Output: `shortcode`

### Getting parameters sent to shortcode

[](#getting-parameters-sent-to-shortcode)

`[example id={{22}}]shortcode[/example]`If we are sending parameters to the shortcode, we can capture them like this;

```
function exampleFunction($values, $content){
return $values["id"];
}
```

Output: `22`

---

**NOTE**

If you echo instead of return in the function that the shortcode will run, it will appear at the very beginning of the text. To avoid this you need to do output buffering.

```
ob_start();

//your codes
//your codes

$output = ob_get_contents();
ob_end_clean();

return $output;
```

Example;

```
function exampleFunction($values, $content){

ob_start();

$fruits = ["apple", "banana", "strawberry"];

foreach($fruits as $fruit){
echo $fruit;
}

$output = ob_get_contents();
ob_end_clean();

return $output;

}
```

---

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1686d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77109670?v=4)[Enes Akarsu](/maintainers/enesakarsu)[@enesakarsu](https://github.com/enesakarsu)

---

Top Contributors

[![enesakarsu](https://avatars.githubusercontent.com/u/77109670?v=4)](https://github.com/enesakarsu "enesakarsu (18 commits)")

---

Tags

parserengineshortcodephp shortcodephp shortcode class

### Embed Badge

![Health badge](/badges/enesakarsu-shortcode-hunter/health.svg)

```
[![Health](https://phpackages.com/badges/enesakarsu-shortcode-hunter/health.svg)](https://phpackages.com/packages/enesakarsu-shortcode-hunter)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k954.1M2.4k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k959.2M159](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.1k156.8M864](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k437.5M1.0k](/packages/league-commonmark)[thunderer/shortcode

Advanced shortcode (BBCode) parser and engine for PHP

3952.8M51](/packages/thunderer-shortcode)[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M319](/packages/masterminds-html5)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
