# jc-importer/trunk/class/Common/Addon/AddonBaseData.php

Import WP – CSV &amp; XML Import Export for WordPress, version trunk. 69 lines.

- Page: https://pluginprobe.com/plugins/jc-importer/trunk/code/class/Common/Addon/AddonBaseData.php
- Raw: https://pluginprobe.com/plugins/jc-importer/trunk/raw/class/Common/Addon/AddonBaseData.php
- Modified: 2024-07-14T15:13:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jc-importer/trunk/code/class/Common/Addon/AddonBaseData.php#L10-L20`.

```php
<?php

namespace ImportWP\Common\Addon;

/**
 * @deprecated 2.14.0
 */
class AddonBaseData
{
    /**
     * @var callable
     */
    protected $_run_conditions;

    protected $_data;

    /**
     * @var AddonBase
     */
    protected $_addon;

    public function __construct($addon, $data)
    {
        $this->_data = $data;
        $this->_addon = $addon;
    }

    public function addon()
    {
        return $this->_addon;
    }

    public function data($key = false)
    {
        if ($key) {
            return isset($this->_data[$key]) ? $this->_data[$key] : false;
        }

        return $this->_data;
    }

    /**
     * When should the addon run?
     *
     * @param callable $callback
     */
    public function enabled($callback)
    {
        $this->_run_conditions = $callback;
        return $this;
    }

    /**
     * Is field allowed to be output?
     *
     * @param \ImportWP\Common\Importer\Template\Template $template
     * @param \ImportWP\Common\Model\ImporterModel $importer_model
     * @return bool
     */
    public function _is_allowed($template, $importer_model)
    {
        if (!is_null($this->_run_conditions) && is_callable($this->_run_conditions) && !call_user_func_array($this->_run_conditions, [$template, $importer_model])) {
            return false;
        }

        return true;
    }
}

```
