Drupal Association members fund grants that make connections all over the world.
This is related to theme feature toggles provided by Drupal core. Themes and plug-ins can define sets of features adding to the pool of available features.
They must be set from the theme .info or plug-in .pinfo file.
feature set[FEATURE_KEY_1] = FEATURE_NAME_1 feature set[FEATURE_KEY_2] = FEATURE_NAME_2 ; etc…
FEATURE_KEY is the machine readable name and
FEATURE_NAME is the human readable name used in the theme settings form. All feature keys must be unique and they cannot be overridden.
If the features are set within a plug-in, enabling it through the theme settings form will enable the plug-in. If none of the features are enabled for a plug-in, none of the code associated with the plug-in will ever load. This can keep code associated with the feature very focused on its purpose.
To get the state of the feature toggle, a simple call to
hex_settings() is all that's needed. Prefixing
toggle_ with the
FEATURE_KEY defined from the info file, e.g.,
hex_settings('toggle_FEATURE_KEY'). Features defined from plug-ins must be prefixed with the plug-in name (
hex_settings('PLUGIN_KEY.toggle_FEATURE_KEY')). This is required for any setting that's specific to a plug-in to keep its association clear.
When the list of features displayed in the theme settings form grows out of control, it can be limited by defining the features you want to make available in the theme .info file. This is the default behavior in Drupal core and this pattern is continued here. If this is not set, all available features will be visible.
features = FEATURE_KEY_1 features = FEATURE_KEY_2 ; etc…
Note that the defined order set from the info file will be reflected in the theme settings form.
Plug-ins are very simple to set-up. All that is required is a .pinfo file. An optional .plug.inc file can host the php code which will load only when the plug-in is active.
Here is an example .pinfo file:
; Human readable name. This should always be set. name = My Plug-in ; Description, not used currently but could be used in the future. description = Description of my plug-in. ; The hex api version. This is required. hexapi = 2.x ; If protected, overriding the plug-in is not possible. This is useful when the ; plug-in provides critical features that should not be altered. Overriding is ; as simple as copying the plug-in hosted in a parent theme and placing it into ; a sub-theme. protected = false ; Setting this to true will automatically enable it when it doesn't depend on ; other components or when all defined dependents are already available. auto enable = false ; Plug-in dependencies. If this plug-in is explicitly enabled, the dependencies ; will enable themselves. 'auto enable' will not enable dependent plug-ins. dependencies = foo ; Other dependencies. It can contain themes or modules. This is extensible. requirements = my_theme requirements = views ; Add styles just like it's done in theme .info files… stylesheets[all] = style.css ; …or scripts. scripts = script.js
The .plug.inc should host functions that should always be available when it is active. Plug-ins and