PHPackages                             unematiii/wp-shortcode-tree - 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. unematiii/wp-shortcode-tree

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

unematiii/wp-shortcode-tree
===========================

Parses (nested) shortcodes into tree hierarcy. Find nodes, manipulate and re-serialize into string. Convenient for processing VisualComposer generated content in the backend.

1.0.0(5y ago)35701[2 issues](https://github.com/unematiii/wp-shortcode-tree/issues)[1 PRs](https://github.com/unematiii/wp-shortcode-tree/pulls)MITPHP

Since Oct 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/unematiii/wp-shortcode-tree)[ Packagist](https://packagist.org/packages/unematiii/wp-shortcode-tree)[ Docs](https://github.com/unematiii/wp-shortcode-tree)[ RSS](/packages/unematiii-wp-shortcode-tree/feed)WikiDiscussions develop Synced 5d ago

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

WordPress Shortcode Tree
========================

[](#wordpress-shortcode-tree)

[![Build Status](https://camo.githubusercontent.com/ce297a1d184eec3489deb47d29db72b0c0ef7d60f728b9d4b8a69dea35a9cab2/68747470733a2f2f7472617669732d63692e6f72672f756e656d61746969692f77702d73686f7274636f64652d747265652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/unematiii/wp-shortcode-tree)[![Coverage Status](https://camo.githubusercontent.com/b09c17b1cdc042abfaba12eecdf4a63b2f8e9a155e2cb3fbef011e3f2be2275b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f756e656d61746969692f77702d73686f7274636f64652d747265652f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/unematiii/wp-shortcode-tree)

Parses (nested) [shortcodes](https://codex.wordpress.org/Shortcode_API) into tree hierarchy. Find nodes, manipulate and re-serialize into string. Convenient for processing Visual Composer generated content in the backend.

Basic Usage
-----------

[](#basic-usage)

Consider a WordPress post with the following content:

```
[folder name="SampleFolder"]
  [document type="image/png" size="64000" path="/path/to/image.png" name="File 1"]
  [document type="image/png" size="64000" path="/path/to/image.png" name="File 2"]
  [folder name="SampleFolder2"]
    [document type="image/png" size="64000" path="/path/to/image.png" name="File 3"]
    [document type="image/png" size="64000" path="/path/to/image.png" name="File 4"]
  [/folder]
[/folder]

```

Parse:

```
$content = \WordPress\ShortcodeTree::fromString( $page->post_content );
$folder  = $content->getRoot();
```

Get all documents &amp; modify:

```
$documents = $folder->findAll( 'document' );

// Prepend 'My ' to filename
foreach ($documents as $doc) {
    $doc->attr( 'name', 'My ' . $doc->attr( 'name' ) );
}
```

Serialize and save:

```
// Write content
wp_update_post(
    array(
        'ID' => $post_id,
        // $content is automatically serialized from ShortcodeTree to a string
        // when __toString() is called automagically
        'post_content' => $content,
    )
);
```

Development
-----------

[](#development)

### Requirements

[](#requirements)

[Composer](https://getcomposer.org/) needs to be available. If you don't have it, you can get it [here](https://getcomposer.org/download/).

### Install dev dependencies

[](#install-dev-dependencies)

```
composer i

```

### Running unit tests

[](#running-unit-tests)

```
./vendor/bin/phpunit

```

### Code style

[](#code-style)

This project uses slightly modified [WordPress coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/) with [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) built into CI pipeline.

#### Detecting problems

[](#detecting-problems)

```
./vendor/bin/phpcs .

```

#### Auto-fixing problems

[](#auto-fixing-problems)

```
./vendor/bin/phpcbf .

```

#### VS Code integration

[](#vs-code-integration)

You need to install and enable [phpcs](https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs) plugin. Configuration for it is provided by this project and it should work out of the box.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.6% 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

2037d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4154230?v=4)[Mati Kärner](/maintainers/unematiii)[@unematiii](https://github.com/unematiii)

---

Top Contributors

[![unematiii](https://avatars.githubusercontent.com/u/4154230?v=4)](https://github.com/unematiii "unematiii (33 commits)")[![Connum](https://avatars.githubusercontent.com/u/13076806?v=4)](https://github.com/Connum "Connum (31 commits)")

---

Tags

wordpresstreeshortcodevisual composer

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/unematiii-wp-shortcode-tree/health.svg)

```
[![Health](https://phpackages.com/badges/unematiii-wp-shortcode-tree/health.svg)](https://phpackages.com/packages/unematiii-wp-shortcode-tree)
```

###  Alternatives

[knplabs/knp-menu

An object oriented menu library

1.4k55.8M287](/packages/knplabs-knp-menu)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

19013.0M263](/packages/php-stubs-wordpress-stubs)[pingpong/shortcode

Laravel - Simple shortcode based on wordpress shortcode

4040.0k1](/packages/pingpong-shortcode)

PHPackages © 2026

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