DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Utilities Module
  2. Assets Service

Styles Handler

PreviousScripts HandlerNextCRON Events Service

Last updated 4 years ago

Was this helpful?

exposes the following public methods:

  • register_public_style for adding a style to the internal frontend registration queue

  • deregister_public_style for removing a style from the internal frontend registration queue

  • enqueue_public_style for adding a style to the internal frontend enqueueing queue

  • dequeue_public_style for removing a style from the internal frontend enqueueing queue

  • register_admin_style for adding a style to the internal admin-side registration queue

  • deregister_admin_style for removing a style from the internal admin-side registration queue

  • enqueue_admin_style for adding a style to the internal admin-side enqueueing queue

  • dequeue_admin_style for removing a style from the internal admin-side enqueueing queue

  • add_inline_style for registering a CSS string to be outputted before or after another enqueued file

The methods follow almost 1-to-1 the WP scripts API, in particular the function, the function, and the function.

The register_admin_style and enqueue_admin_style methods accept a specialized argument $hook_suffixes. By default it's null, but it can be set to an array to conditionally register/enqueue the scripts only when the global variable $hook_suffix is set to one of the values.

As mentioned on the page, the handler will automatically attempt to register/enqueue the minified version of your script (if it exists in the same folder and has the .min.css extension) and will attempt to set the file version to the result of the PHP filemtime function.

For assets being loaded from an external URL, the $fallback_version argument will be used by default instead of trying to call filmemtime on the script.

The styles handler
wp_register_style
wp_enqueue_style
wp_add_inline_style
Assets Service