PHPackages                             castlegate/monolith-wordpress - 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. castlegate/monolith-wordpress

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

castlegate/monolith-wordpress
=============================

Basic utilities and functions for WordPress development.

v1.0.5(4y ago)029MITPHP

Since Nov 11Pushed 3y ago2 watchersCompare

[ Source](https://github.com/castlegateit/monolith-wordpress)[ Packagist](https://packagist.org/packages/castlegate/monolith-wordpress)[ RSS](/packages/castlegate-monolith-wordpress/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (7)Used By (0)

Monolith WordPress Module
=========================

[](#monolith-wordpress-module)

Monolith is a collection of utility functions and classes that make PHP and WordPress development a little bit easier. The WordPress module uses the `\Cgit\Monolith\WordPress` namespace.

Install
-------

[](#install)

Monolith WordPress is available on [Packagist](https://packagist.org/) and can be installed via [Composer](https://getcomposer.org/):

```
composer require castlegate/monolith-wordpress

```

Functions
---------

[](#functions)

- `enqueue($file, $deps = [], $script = null, $parent = null)` Enqueues a CSS or JavaScript file with cache-busting, dependencies (based on handles), and automatic style or script detection. This function returns the automatically generated resource handle so you can use it in other dependency lists. Files can be specified by handle, relative path, absolute path, or URL.
- `labels($single, $plural = null)` Generates a complete set of labels for a [custom post type](https://developer.wordpress.org/reference/functions/register_post_type/#parameters) or [custom taxonomy](https://developer.wordpress.org/reference/functions/register_taxonomy/#parameters).
- `pagination($args = [])` Wrapper for `paginate_links()` with sensible default values.
- `embedSvg($file, $args = [])` Similar to the function of the same name in `Core` described above, but relative file paths are assumed to be in the active theme directory.
- `send404()` Send an immediate 404 response and display the 404 template, overriding all other responses and output.
- `pageFromTemplate($template, $multiple = false)` Identify and return the page(s) that use a particular template.

Classes
-------

[](#classes)

### Post

[](#post)

Based on the original Terminus Post class, this provides convenient access to the final, filtered content of posts:

```
$foo = new \Cgit\Monolith\WordPress\Post(16);

echo $foo->id();
echo $foo->title();
echo $foo->url();
echo $foo->content();
echo $foo->excerpt();
```

It also provides the `field($field)` method, which retrieves an [Advanced Custom Fields](https://www.advancedcustomfields.com/) value from the post, and the `image()` method, which returns an `Image` instance for the post's featured image.

### Image

[](#image)

Based on the original Terminus Image class, this provides a consistent interface for getting URLs. Its constructor accepts an image attachment object, an image ID, a post object, a post ID, or an ACF custom field name.

```
use \Cgit\Monolith\WordPress\Image;

$foo = new Image($image_id); // image attachment
$foo = new Image($post_id); // featured image for post
$foo = new Image($field); // ACF image for current post
$foo = new Image($field, $post_id); // ACF image by post object or ID
```

You can then obtain various information about the image or generate an HTML `` element:

```
$foo->url(); // URL of original image
$foo->url('medium'); // URL of image at a particular size
$foo->meta(); // get all meta information as an array
$foo->meta('alt'); // get particular meta field
$foo->element(); // get image element with fill size image
$foo->element('medium'); // get image element at a particular size
$foo->data('medium'); // get data URI
```

The `element()` method can also take an associative array of attribute keys and values to be added to the HTML element. If the `element()` method is provided with an associative array of sizes, it generates a responsive `` element:

```
$foo->element([
    'medium' => '(max-width: 480px)',
    'large' => '(max-width: 960px)',
]);
```

### PostType

[](#posttype)

The `PostType` class is an abstract class that can be extended to define custom post types with taxonomies, custom fields, and custom query parameters quickly and easily:

```
class Book extends PostType
{
    $this->type = 'book';

    $this->args = [
        'label' => 'Books',
        'label_single' => 'Book',
    ];

    $this->taxons = [
        'book-category' => [],
        'book-tag' => [],
    ];

    $this->queryArgs = [
        'posts_per_page' => 20,
    ];

    $this->fields = [
        [
            // ACF field group parameters
        ],
    ];
}
```

#### Properties

[](#properties)

The `args` property is an array of `register_post_type` parameters, plus an optional `label_single` parameter that is used to generate a full set of labels automatically.

The `taxons` property is a nested array of taxonomy parameters. The keys are the taxonomy names and the values are the arrays of parameters passed to the `register_taxonomy` function.

The `queryArgs` property is an array of `WP_Query` parameters set via the `pre_get_posts` action.

The `fields` property is a nested array of ACF field groups, allowing you to add multiple to the post type. The `location` parameter can be omitted and will be set the current post type automatically.

#### Methods

[](#methods)

You do not need to use any methods to define a post type. However, the class does call some methods can be extended in your child class, perhaps to set the post type parameters:

- `init` is run immediately on instantiation.
- `preInit` is run on the `init` action before any of the plugin methods have run.
- `postInit` is run on the `init` action after all the plugin methods have run.

### Resource

[](#resource)

The `Resource` class does the heavy lifting for the `enqueue` function and shouldn't need to be used directly.

```
$foo = new \Cgit\Monolith\WordPress\Resource($source, $deps);

$foo->enqueue(); // enqueue resource
$foo->setScript(true); // resource should be enqueued as a script
$foo->setParent(true); // resource path is relative to parent theme
$foo->getHandle(); // return generated resource handle
```

License
-------

[](#license)

Released under the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE](LICENSE) for details.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Every ~142 days

Recently: every ~177 days

Total

6

Last Release

1714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2feb1ac070be953a53f8c4d902436a8844884b7d968be6b2bac234e617be614e?d=identicon)[jkhughes](/maintainers/jkhughes)

---

Top Contributors

[![johnkhughes](https://avatars.githubusercontent.com/u/1375434?v=4)](https://github.com/johnkhughes "johnkhughes (5 commits)")[![ajreading](https://avatars.githubusercontent.com/u/363404?v=4)](https://github.com/ajreading "ajreading (2 commits)")

### Embed Badge

![Health badge](/badges/castlegate-monolith-wordpress/health.svg)

```
[![Health](https://phpackages.com/badges/castlegate-monolith-wordpress/health.svg)](https://phpackages.com/packages/castlegate-monolith-wordpress)
```

###  Alternatives

[maatoo/mautic-referrals-bundle

This plugin enables referrals in mautic.

142.7k](/packages/maatoo-mautic-referrals-bundle)

PHPackages © 2026

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