PHPackages                             pressgang-wp/pressgang-snippets - 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. pressgang-wp/pressgang-snippets

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

pressgang-wp/pressgang-snippets
===============================

A collection of reusable snippets for WordPress themes, specifically tailored for integration with the PressGang parent theme framework.

v2.0.0(3mo ago)0136MITPHPPHP ^8.0

Since Feb 6Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/pressgang-wp/pressgang-snippets)[ Packagist](https://packagist.org/packages/pressgang-wp/pressgang-snippets)[ RSS](/packages/pressgang-wp-pressgang-snippets/feed)WikiDiscussions main Synced 1mo ago

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

PressGang Snippets
==================

[](#pressgang-snippets)

**Stop copy-pasting from `functions.php`. Start composing.**

PressGang Snippets is a library of 45+ self-contained, Composer-installable WordPress theme components for [PressGang](https://github.com/pressgang-wp/pressgang) themes. Each snippet is a single PHP class that does one thing well — from injecting Google Analytics to disabling emojis to generating breadcrumbs — and can be enabled or disabled with a single line of config.

🤔 Why Snippets?
---------------

[](#-why-snippets)

Every WordPress developer has done this: you need Google Analytics on a new site, so you open `functions.php`, paste in 30 lines you copied from the last project, tweak a couple of values, and move on. Six months later that file is 800 lines of unrelated code that nobody wants to touch.

**Snippets fix this.** Instead of a monolithic `functions.php`, each piece of functionality lives in its own class:

```
// config/snippets.php — your entire "functions.php" replacement
return [
    'PressGang\\Snippets\\Theme\\DisableEmojis'    => [],
    'PressGang\\Snippets\\Google\\Analytics'      => [],
    'PressGang\\Snippets\\Theme\\ImageSizes'       => [
        'hero' => ['width' => 1920, 'height' => 600, 'crop' => true],
    ],
    'PressGang\\Snippets\\Content\\DuplicatePost'  => [],
    'PressGang\\Snippets\\Seo\\OpenGraph'          => [],
];
```

That's it. Five features enabled, zero boilerplate, fully reversible by deleting a line.

Traditional approachPressGang SnippetsCopy-paste between projects`composer require` once, use everywhereEnable/disable by commenting codeAdd or remove a config lineOne massive `functions.php`One focused class per concernArguments buried in codeConfiguration passed explicitlyNo standard structureEvery snippet implements `SnippetInterface`📦 Installation
--------------

[](#-installation)

```
composer require pressgang-wp/pressgang-snippets
```

That's all. PressGang automatically discovers the package's Twig templates — no path configuration needed.

⚙️ Configuration
----------------

[](#️-configuration)

Activate snippets in your child theme's `config/snippets.php`. Each entry maps a class name to an arguments array:

```
