PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.7.5
Import WP – CSV & XML Import Export for WordPress v2.7.5
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
jc-importer / class / Common / Addon / AddonBaseData.php

AddonBaseData.php in Import WP – CSV & XML Import Export for WordPress 2.7.5, at class/Common/Addon/AddonBaseData.php

66 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImportWP\Common\Addon;
4
5 class AddonBaseData
6 {
7 /**
8 * @var callable
9 */
10 protected $_run_conditions;
11
12 protected $_data;
13
14 /**
15 * @var AddonBase
16 */
17 protected $_addon;
18
19 public function __construct($addon, $data)
20 {
21 $this->_data = $data;
22 $this->_addon = $addon;
23 }
24
25 public function addon()
26 {
27 return $this->_addon;
28 }
29
30 public function data($key = false)
31 {
32 if ($key) {
33 return isset($this->_data[$key]) ? $this->_data[$key] : false;
34 }
35
36 return $this->_data;
37 }
38
39 /**
40 * When should the addon run?
41 *
42 * @param callable $callback
43 */
44 public function enabled($callback)
45 {
46 $this->_run_conditions = $callback;
47 return $this;
48 }
49
50 /**
51 * Is field allowed to be output?
52 *
53 * @param \ImportWP\Common\Importer\Template\Template $template
54 * @param \ImportWP\Common\Model\ImporterModel $importer_model
55 * @return bool
56 */
57 public function _is_allowed($template, $importer_model)
58 {
59 if (!is_null($this->_run_conditions) && is_callable($this->_run_conditions) && !call_user_func_array($this->_run_conditions, [$template, $importer_model])) {
60 return false;
61 }
62
63 return true;
64 }
65 }
66