PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.9.0
Import WP – CSV & XML Import Export for WordPress v2.9.0
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 / Importer / Template / TemplateManager.php

TemplateManager.php in Import WP – CSV & XML Import Export for WordPress 2.9.0, at class/Common/Importer/Template/TemplateManager.php

60 lines 1.5 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\Importer\Template;
4
5 use ImportWP\EventHandler;
6
7 class TemplateManager
8 {
9 /**
10 * @var EventHandler
11 */
12 protected $event_handler;
13
14 public function __construct(EventHandler $event_handler)
15 {
16 $this->event_handler = $event_handler;
17 }
18
19 /**
20 * @param string $name
21 * @return Template
22 */
23 public function load_template($name)
24 {
25 $template = new $name($this->event_handler);
26 return $template;
27 }
28
29 public static function get_template_unique_fields($template_class)
30 {
31 // Hard coded unique fields
32 $unique_fields = [];
33 $mapper_id = $template_class->get_mapper();
34 switch ($mapper_id) {
35 case 'user':
36 $unique_fields = ['user_email', 'user_login'];
37 break;
38 case 'page':
39 case 'post':
40 case 'custom-post-type':
41 case 'attachment':
42 $unique_fields = ['ID', 'post_name'];
43 break;
44 case 'attachment':
45 $unique_fields = ['ID', 'post_name', 'src'];
46 break;
47 case 'term':
48 $unique_fields = ['term_id', 'slug', 'name'];
49 break;
50 case 'comment':
51 $unique_fields = ['comment_ID', '_iwp_ref_id'];
52 break;
53 }
54
55 $unique_fields = apply_filters('iwp/mapper/unique_fields', $unique_fields, $mapper_id);
56
57 return $unique_fields;
58 }
59 }
60