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 / CustomFields.php

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

59 lines 1.2 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 CustomFields
6 {
7 private $_name;
8 private $_prefix;
9 private $_fields = [];
10
11 public function __construct($name, $prefix)
12 {
13 $this->_name = $name;
14 $this->_prefix = $prefix;
15 }
16
17 public function get_prefix()
18 {
19 return $this->_prefix;
20 }
21
22 public function register_field($name, $args = [])
23 {
24 $id = isset($args['id']) ? $args['id'] : sanitize_title($name);
25 $type = isset($args['type']) ? $args['type'] : 'text';
26
27 $this->_fields[$id] = [
28 'id' => $id,
29 'name' => $name,
30 'type' => $type
31 ];
32 }
33
34 public function get_dropdown_fields()
35 {
36
37 $tmp_fields = [];
38 foreach ($this->_fields as $field_id => $field) {
39
40 $tmp_fields[] = [
41 'value' => $this->_prefix . '::' . $field['type'] . '::' . $field_id,
42 'label' => $this->_name . ' - ' . $field['name']
43 ];
44 }
45
46 return $tmp_fields;
47 }
48
49 public function get_fields()
50 {
51 return $this->_fields;
52 }
53
54 public function get_field($field_id)
55 {
56 return isset($this->_fields[$field_id]) ? $this->_fields[$field_id] : false;
57 }
58 }
59