Skip to content

How Marketers Delight builds its CSS

Marketers Delight generates its CSS from PHP templates. Each time you save a design or typography setting, the theme reads your saved values, evaluates the templates, and writes static CSS files to your uploads directory. This keeps the front end fast: the browser downloads a standard CSS file with no runtime processing.

The template pipeline

CSS source files live in css/ inside the theme directory. They are PHP files that output CSS, using <?php echo ... ?> to insert values from your settings. The main templates are:

  • css/--vars.php — the :root {} block of CSS custom properties
  • css/style.php — base site styles
  • css/helpers.php — utility and layout helper classes
  • css/block-editor.php — block editor canvas styles
  • Several other files for specific components

The md_css class reads this list, evaluates each template with ob_start() / ob_get_clean(), optionally minifies the result, and writes the output to the compiled assets directory.

Compiled output files

The compiled files are stored at wp-content/uploads/marketers-delight/. They are written by md_compiled_assets::write() and served as ordinary static files.

FilePurpose
style.cssThe site's main stylesheet, loaded on every front-end page
block-editor.cssStyles injected into the block editor canvas
classic-editor.cssStyles added to the classic editor's visual tab
font-icons.cssThe MD icon font declaration

When Print style.css inline is on in CSS Manager, the compiled CSS is stored in the database and printed in <head> instead of written to a file.

When a recompile runs

md_compile() runs automatically in these situations:

  • After any MD settings panel is saved (Design, Typography, Header, and others).
  • After the theme is activated or upgraded.
  • After a Drop-in is upgraded or deleted.
  • After a navigation menu is updated (menu names and items feed into the compiled CSS).

You can also trigger it manually from the command line:

md_compile();

Or via a URL parameter while logged in as an Administrator:

/wp-admin/?md=compile&_wpnonce=...

CSS Manager options

The Site Tools box on Theme → Settings has two CSS Manager options that change how the compiled output is delivered:

OptionEffect
Combine child theme CSS into style.cssAppends your child theme's style.css to MD's compiled stylesheet, saving one HTTP request
Print style.css inlineOutputs the compiled CSS inside <head> instead of as a linked file

Extending with a Drop-in

Drop-ins can register their own CSS templates through the md_css_files filter. The md_css class merges them into the compile pipeline, so Drop-in styles are included in the same compiled output and recompiled on the same triggers.

Critical CSS was removed in Marketers Delight 6.2. Sites that used it load the regular stylesheet again.

The CSS Manager options in the Site Tools box on Theme → Settings

CSS Manager controls how the compiled stylesheet is delivered.

Alex Mangini

Hi, I'm Alex! I started writing about web design and blogging at 13 years old, which turned into client work, which led to building my own software. 15 years later I'm still at it, and Marketers Delight is the epitome of my philosophy for building on the web.