PHPackages                             seothemes/dynamic-stylesheet - 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. seothemes/dynamic-stylesheet

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

seothemes/dynamic-stylesheet
============================

Simple drop-in class for generating dynamic stylesheets in WordPress themes or plugins.

411PHP

Since May 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/seothemes/dynamic-stylesheet)[ Packagist](https://packagist.org/packages/seothemes/dynamic-stylesheet)[ RSS](/packages/seothemes-dynamic-stylesheet/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Dynamic Stylesheet
==================

[](#dynamic-stylesheet)

Simple drop in class for generating dynamic stylesheets in WordPress.

About
-----

[](#about)

This class will try to write the custom CSS to a static file in the `wp-content/cache/` directory. If there is no write access, it will load the dynamic stylesheet instead.

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

[](#installation)

**Composer (recommended)**

Run the following command from the root directory of your theme or plugin:

```
composer require seothemes/dynamic-stylesheet
```

**Manual**

Copy the `loader.php` file somewhere in your theme or plugin and then include it using `require_once`, e.g:

```
// Include loader class (not required if using composer).
require_once __DIR__ . 'path/to/loader.php';
```

Usage
-----

[](#usage)

Pass a string of custom CSS to the Loader class parameters and then load the hooks using the `run` method. It is recommended to generate your CSS inside a function that is also hooked to `wp_enqueue_scripts` to enable live preview in the Customizer. The stylesheet handle and option name can also be specified when initializing the Loader class with the second parameter:

```
add_action( 'wp_enqueue_scripts', 'prefix_custom_css', 15 );
/**
 * Generate custom CSS and add inline styles to Customizer preview.
 *
 * @since 1.0.0
 *
 * @return string
 */
function prefix_custom_css() {
	$custom_color = get_option( 'custom-color', '#eee' );

	$custom_css   = 'body { background-color: ' . $custom_color . ' !important; }';

	if ( is_customize_preview() ) {
		wp_add_inline_style( 'my-prefix', $custom_css );
	}

	return $custom_css;
}

// Initialize Loader class (pass custom CSS as parameter here).
$dynamic_css = new SeoThemes\DynamicStylesheet\Loader( prefix_custom_css(), 'my-prefix' );

// Load hooks.
$dynamic_css->run();
```

Testing
-------

[](#testing)

**Customizer Settings**

To test that the Customizer settings are working correctly, add the following code snippet:

```
add_action( 'customize_register', function ( $wp_customize ) {
	$wp_customize->add_setting( 'custom-color', [
		'type' => 'option',
	] );

	$wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'custom-color', [
		'label'    => 'Custom Color',
		'section'  => 'colors',
		'settings' => 'custom-color',
	] ) );
} );
```

This will add a simple color control under the Colors section of the Customizer. If changes are not applied, try clearing the browser cache.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/55b9ce7d3453d6c0c149cd77f4441a19bf692d968bf58b7f3dbc3cf9450c2051?d=identicon)[seothemes](/maintainers/seothemes)

---

Top Contributors

[![seothemes](https://avatars.githubusercontent.com/u/24793388?v=4)](https://github.com/seothemes "seothemes (15 commits)")

### Embed Badge

![Health badge](/badges/seothemes-dynamic-stylesheet/health.svg)

```
[![Health](https://phpackages.com/badges/seothemes-dynamic-stylesheet/health.svg)](https://phpackages.com/packages/seothemes-dynamic-stylesheet)
```

###  Alternatives

[flagstudio/nova-actions-left

Laravel Nova actions on the left

2258.2k](/packages/flagstudio-nova-actions-left)[humanmade/popup

An exit intent popup block that shows when someone may be about to leave the site

144.8k](/packages/humanmade-popup)

PHPackages © 2026

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