> For the complete documentation index, see [llms.txt](https://kb.moomoo.agency/uni-cpo-4-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.moomoo.agency/uni-cpo-4-documentation/for-developers/extending-uni-cpo.md).

# Extending Uni CPO

### Adding new options

New option must be a class that follow specific naming convention and extends abstract 'Uni\_Cpo\_Option' class and implements the same interface as other option related classes. The easiest solution would be to make a copy of one of the existing classes and modify it according to your needs.

The naming convention examples:

* if option type is 'fantasy\_option' then its class must be called 'Uni\_Cpo\_Option\_Fantasy\_Option'
* if option type is 'radio\_special\_links' then its class must be called 'Uni\_Cpo\_Option\_Radio\_Special\_Links'

#### Filters

```
uni_cpo_option_types
```

This filter accepts one argument - an array of unique option names.

Example of using:

```php
add_filter( 'uni_cpo_option_types', 'my_option_types', 10, 1 )
function my_option_types($types) {
        $types[] = 'fantasy_option';
        return $types;
}
```

\------------------------

```
uni_cpo_option_classes / uni_cpo_option_classes_pro
```

This filter accepts one argument - an array of paths to php file with class of the option. The filter prefixed with 'pro' will be used only in PRO version of the plugin.

Example of using:

```php
add_filter( 'uni_cpo_option_classes', 'my_option_classes', 10, 1 )
function my_option_classes($pathes) {
        $pathes[] = $this->plugin_path() . '/inc/class-uni-cpo-option-fantasy-option.php';
        return $pathes;
}
```

### Adding new settings

Similar to new option class name, setting class name follows the same naming convention and extends one of the abstract classes. The easiest way would be to make a copy of existing setting class and then modify it.

#### Filters

```
uni_cpo_setting_types
```

This filter accepts one argument - an array of unique setting names.

Example of using:

```php
add_filter( 'uni_cpo_setting_types', 'my_settings_types', 10, 1 )
function my_settings_types($types) {
        $types[] = 'super_setting';
        return $types;
}
```

\------------------------

```
uni_cpo_settings_classes / uni_cpo_settings_classes_pro
```

This filter accepts one argument - an array of paths to php file with class of the setting. The filter prefixed with 'pro' will be used only in PRO version of the plugin.

Example of using:

```php
add_filter( 'uni_cpo_settings_classes', 'my_settings_classes', 10, 1 )
function my_settings_classes($pathes) {
        $pathes[] = $this->plugin_path() . '/inc/class-uni-cpo-setting-super-setting.php';
        return $pathes;
}
```

###
