Hotaru Docs

 [həʊdɒks]

Including Files

In order for users to save their customizations from unwanted overwrites when plugins are upgraded, Hotaru allows them to move files out of a plugin and into their theme, where those files will still work equally well (explained here).

To use this functionality correctly, please follow these rules:

1. Put all template files in a folder called "templates"

Use like this:

$h->displayTemplate('template_name'); // No file extension


2. Put all language files in a folder called "languages"

For a single file, name it plugin_name_language.php, e.g. "submit_language.php".

Language files are automatically included when each plugin function is called.

Read more about language files here.


3. Put all css files in a folder called "css"

For a single css file name plugin_name.css, include them in a header_include function, with the function includeCss(), like this:

$h->includeCss();

For additional .css files named other_name.css, include each like this:

$h->includeCss('filename'); // No file extensions

Note: CSS files included this way will be merged with other plugin stylesheets into a single, minified .css file.


4. Put all .js files in a folder called "javascript"

For a single javascript file name plugin_name.js, include them in a header_include function, with the function includeJs(), like this:

$h->includeJs();

For additional .js files named other_name.js, include each like this:

$h->includeJs('filename'); // No file extensions


Note: JavaScript files included this way will be merged with other plugin JavaScript files into a single, minified .js file.


Include CSS and JavaScript Files Automatically

Hotaru is smart enough to include files for you if they share the same name as the plugin. For example, imagine you have a plugin called OzzleFloppy with a single CSS file and/or a single JavaScript file in their respective folders, like so:

  • ozzle_floppy
    • ozzle_floppy.php
      • css
        • ozzle_floppy.css
      • javascript
        • ozzle_floppy.js

Because the names of the .css and .js files match the name of your plugin folder, Hotaru can automatically detect them and include those files. All you need to do is make sure you have header_include in your list of plugin hooks at the top of your main plugin file. You don't need to make a header_include function because hotaru will fall back on the default functions in /Hotaru.php and include your files for you

Include CSS and JS Only Once Without Merging

Hotaru 1.3~ introduces two new functions that automatically add the HTML for including a specified CSS or JavaScript file into the header. This is better than manually adding the HTML to your header because Hotaru checks to see if a customized CSS/JS file exists in a user's theme first.

The best place for these is in the header_include_raw function:

$h->includeOnceCss(array('file_one', 'file_two'), 'my_plugin');
$h->includeOnceJs(array('file_one', 'file_two'), 'my_plugin');

The first parameter is an array of file names to include (without .css or .js) and the second parameter is the plugin name. If no plugin name is provided it will default to the current plugin.

Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting