PluginProbe
Import WP – CSV & XML Import Export for WordPress / trunk
Import WP – CSV & XML Import Export for WordPress vtrunk
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 trunk 0.1.6 All 142 releases
jc-importer / class / Common / AddonAPI / Importer / Template / Field.php

Field.php in Import WP – CSV & XML Import Export for WordPress trunk, at class/Common/AddonAPI/Importer/Template/Field.php

79 lines 1.8 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\AddonAPI\Importer\Template;
4
5 class Field
6 {
7 private $_id;
8 private $_name;
9 private $_type = 'text';
10 private $_group;
11 private $_args = [];
12
13 public function __construct($name, $args = [])
14 {
15 $this->_id = $args['id'] ?? sanitize_title($name);
16 $this->_name = $name;
17
18 if (isset($args['type'])) {
19 $this->_type = $args['type'];
20 }
21
22 if (isset($args['group'])) {
23
24 if (is_a($args['group'], \ImportWP\Common\AddonAPI\Importer\Template\Panel::class)) {
25 $this->_group = $args['group']->get_id();
26 } elseif (is_string($args['group'])) {
27 $this->_group = $args['group'];
28 }
29 }
30
31 $this->_args = $args;
32 }
33
34 public function get_id()
35 {
36 return $this->_id;
37 }
38
39 public function get_name()
40 {
41 return $this->_name;
42 }
43
44 public function get_type()
45 {
46 return $this->_type;
47 }
48
49 public function get_group()
50 {
51 return $this->_group;
52 }
53
54 public function get_args()
55 {
56 return $this->_args;
57 }
58
59 public function get_arg($key)
60 {
61 return isset($this->_args[$key]) ? $this->_args[$key] : null;
62 }
63
64 /**
65 * @param \ImportWP\Common\Importer\Template\Template $template
66 * @return []
67 */
68 public function get_template_data($template)
69 {
70 switch ($this->_type) {
71 case 'text':
72 return $template->register_field($this->get_name(), $this->get_id(), $this->get_args());
73 case 'attachment':
74 return $template->register_attachment_fields($this->get_name(), $this->get_id(), $this->get_arg('field_label'), $this->get_args());
75 }
76 return false;
77 }
78 }
79