Theme / Plugin Developers
Yabe Siul is developer friendly. You can easily integrate Yabe Siul into your theme or plugin with the available function and WordPress hooks.
Using Play CDN
Section titled Using Play CDNThe Play CDN is designed for development purposes only. Please use the cached CSS file in production.
During development, Yabe Siul uses the Play CDN to dynamically create the required styles. As the Tailwind JIT engine is loaded, it will reactively create the required styles for the design on-the-fly.
In the front end or editor’s canvas view, you may want to load the Play CDN. This is the recommended approach for the best development experience.
The Play CDN consists of two parts:
- The
importmap
- The Play CDN (the Tailwind JIT engine,
main.css
, andpreset.js
)
Both must be loaded in respective order.
Importmap
Section titled ImportmapThe importmap
must be loaded earlier on the head
of the HTML document.
The importmap
is a JSON file that maps the package names to the URLs of the JavaScript modules that define them. It is used to load the minimum required JavaScript modules that will be used by the Tailwind JIT engine and the preset.js
.
Play CDN
Section titled Play CDNThe Play CDN comprises the Tailwind JIT engine, main.css
, and preset.js
.
Cached CSS
Section titled Cached CSSThe cached CSS is designed for production purposes only. Please use the Play CDN in development.
In production, Yabe Siul uses the cached CSS file for the best performance.
In the front end, you may want to load the cached CSS file. This is the recommended approach for the best performance as the cached CSS file is pre-generated by scanning the designs.
Check if the cached CSS file exists.
Get the URL of the cached CSS file.
Get the path of the cached CSS file.
Default behavior
Section titled Default behaviorYabe Siul by default will load the Play CDN or the cached CSS file in the front end via the wp_head
hook.
If your theme has used the wp_head
hook, it may benefit from this default behavior.
To disable the default behavior, you can use the several available filters hooks to control the behavior.
Entirely turn off the default behavior
Section titled Entirely turn off the default behaviorTo prevent the Play CDN, cached CSS file, and Autocomplete engine from loading in the front end, you can use the f!yabe/siul/core/runtime:is_prevent_load
filter hook.
Exclude cached CSS or force Play CDN for specific user
Section titled Exclude cached CSS or force Play CDN for specific userTo exclude the cached CSS file from loading in the front end for specific user or to force the Play CDN to load, you can use the f!yabe/siul/core/runtime:append_header.exclude_admin
filter hook.
Autocomplete engine
Section titled Autocomplete engineYabe Siul has Autocomplete engine built-in. It can be used to generate suggestions for Tailwind CSS class names on-the-fly.
If the default behavior is not disabled by the user, the Autocomplete engine will be loaded along with the Play CDN in the front end via the wp_head
hook.
Using the Autocomplete engine suggestions
Section titled Using the Autocomplete engine suggestionsIf the global wp.hooks
object is available, you can query the Autocomplete engine suggestions using the filter hook.
If the global wp.hooks
object is not available, you can use the siul.module.autocomplete.query
object to query the suggestions.
Main.CSS
Section titled Main.CSSIf you want to prepend or append the main.css
file, you can use the available filter hooks. The appended content will not be loaded to the code editor in the plugin’s settings page. It will only be loaded in the front end, editor’s canvas view, or Compile engine.
tailwind.config.js
Section titled tailwind.config.jsIf you want to prepend or append the tailwind.config.js
file, you can use the available filter hooks.
Compiler’s scanners
Section titled Compiler’s scannersDuring the cached CSS generation process, the Compiler scans the designs and generates the required styles. The design payload can be an HTML string, a JSON string, or a PHP array/object.
The Compiler’s scanners are composed of several Provider
. Each Provider
is responsible for scanning the design payload and feeding the Compiler with the design payload.
Each registered Provider
will be listed in the plugin’s settings page. The user can enable or disable the Provider
from the settings page.
Registering a Provider
Section titled Registering a ProviderTo register a Provider
, you can use the 'f!yabe/siul/core/cache:compile.providers'
filter hook.
The Provider’s callback
Section titled The Provider’s callbackThe callback
key is the callable function that will be called to get the data. It can be a function name, a closure, or an array of class and method name.
The callback
function must return the design payload as an array of [ 'name' => '...', 'content' => '...' ]
.