Need help in the process of creating your own WordPress theme?
The Cookbook ia a collection of specific recipes that explain how to correctly solve the most recurrent problems that developers face in their day to day work.
An extension can be disabled by adding it to the blacklist. Blacklist is an array in theme config:
// file: framework-customizations/theme/config.php
$cfg['extensions_blacklist'] = array('extension_name', 'another_extension_name');
Child extensions will not be activated if parent extension will return false;
from _init()
.
<?php if (!defined('FW')) die('Forbidden');
class FW_Extension_Example extends FW_Extension
{
/**
* @internal
*/
protected function _init()
{
// ...
if ($this->something_is_wrong()) {
return false; // prevent child extensions activation
}
}
}
The parent extension has the possibility to check each child extension if it’s valid or not. If the child extension is not valid, it will not be activated. To do that, the parent extension must overwrite the _child_extension_is_valid()
method.
The method should return true
if child extension is valid, and false
if not.
<?php if (!defined('FW')) die('Forbidden');
class FW_Extension_Example extends FW_Extension
{
/**
* {@inheritdoc}
*/
public function _child_extension_is_valid($child_extension_instance)
{
// force child extensions to extend some custom class, instead of FW_Extension
return is_subclass_of($child_extension_instance, 'FW_Ext_Demo_Custom_Class');
}
// ...
}