WP Manifestindependent plugin directory
manifest / developer / wp-style-sets

WP Style Sets API

A WordPress plugin to allow programatic css, less (and possibly sass) queued style rendering.

by Brent Jett · github.com/brentjett/wp-style-sets

★ 0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/brentjett/wp-style-sets/archive/refs/heads/master.zip

WP Style Sets API - NOT UNDER ACTIVE DEVELOPMENT

A concept plugin for creating a set of styles to be compiled and output as either a file or style block.

The idea is that you can create a style set and then add pieces of css/less/sass to it that is ultimately rendered out and cached as a file or, if intended as a style block, in a transient field in the options table.

wp_register_style_set($handle, $args = array())
wp_enqueue_style_set($handle, $args = array())

wp_add_style_to_set($handle, $set_handle, $args = array())

Example

add_action('wp_enqueue_scripts', function() {
    wp_enqueue_style_set("basset-content-set", array(
        'name' => 'Basset Content Styles',
        'units' => array(
            'basset-vars' => array(
                'name' => 'Basset Variables',
                'lang' => 'css',
                'source' => 'my_test_function'
            ),
            'basset-tests' => array(
                'name' => 'Basset Tests',
                'lang' => 'css',
                'source' => function() {
                    return "body .page { background:#333; color:white; } p {text-align:center;}";
                }
            ),
            'test-less-file' => array(
                'name' => 'Test Less File',
                'lang' => 'less',
                'source' => __DIR__ . '/test-static.less'
            ),
            'test-scss-file' => array(
                'name' => 'Test SCSS File',
                'lang' => 'scss',
                'source' => __DIR__ . '/test-scss.scss'
            ),
        ),
        'vars' => array(
            'primary_color' => 'white',
            'primary_background_color' => 'navy'
        )
    ));
});