PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 4.1.1
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v4.1.1
4.1.1 3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / libraries / XmlImportTemplate.php
wp-all-import / libraries Last commit date
ast 1 month ago XmlImportConfig.php 1 month ago XmlImportCsvParse.php 1 month ago XmlImportException.php 1 month ago XmlImportParser.php 1 month ago XmlImportReaderInterface.php 1 month ago XmlImportSQLParse.php 1 month ago XmlImportStringReader.php 1 month ago XmlImportTemplate.php 1 month ago XmlImportTemplateCodeGenerator.php 1 month ago XmlImportTemplateParser.php 1 month ago XmlImportTemplateScanner.php 3 days ago XmlImportToken.php 1 month ago XmlImportXLSParse.php 1 month ago wpaipclzip.lib.php 1 month ago
XmlImportTemplate.php
84 lines
1 <?php
2 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals
3 /**
4 * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com>
5 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
6 * @package General
7 */
8
9 require_once dirname(__FILE__) . '/XmlImportConfig.php';
10
11 /**
12 * Represents a template
13 */
14 class XmlImportTemplate {
15 /**
16 * Root element of the record that is being parsed
17 *
18 * @var SimpleXMLElement
19 */
20 protected $xml;
21
22 /**
23 * file name of the cached template
24 *
25 * @var string
26 */
27 protected $cachedTemplate;
28
29 protected $trimValues = TRUE;
30
31 /**
32 * Creates new instance
33 *
34 * @param SimpleXmlElement $xml
35 * @param string $cachedTemplate
36 */
37 public function __construct($xml, $cachedTemplate)
38 {
39 $this->xml = $xml;
40 $this->cachedTemplate = $cachedTemplate;
41 $this->trimValues = apply_filters('wp_all_import_is_trim_parsed_data', $this->trimValues);
42 }
43
44 /**
45 * Parses a template using {@see $this->xml}
46 *
47 * @return string
48 */
49 public function parse()
50 {
51
52 ob_start();
53 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
54 $err_lvl = error_reporting(E_ALL);
55 include $this->cachedTemplate;
56 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
57 error_reporting($err_lvl);
58
59 return ob_get_clean();
60 }
61
62 /**
63 * Get the value by XPath expression
64 *
65 * @param SimpleXmlElement $xpath XPath result
66 * @return mixed
67 */
68 protected function getValue($xpath = array())
69 {
70
71 if (is_array($xpath) && count($xpath) > 0) {
72 $result = array();
73 foreach ($xpath as $xp) { // concatenate multiple elements into 1 string
74 ob_start();
75 echo $xp; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Captured into output buffer for internal concatenation, not sent to response.
76 $result[] = $this->trimValues ? trim(ob_get_clean()) : ob_get_clean();
77 }
78 return implode(XmlImportConfig::getInstance()->getMultiGlue(), $result);
79 } else {
80 // return null if nothing found
81 return null;
82 }
83 }
84 }