PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.3
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.3
4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 All 201 releases
betterdocs / includes / Admin / Importer / Parsers / WXR_Parser.php

WXR_Parser.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.3, at includes/Admin/Importer/Parsers/WXR_Parser.php

49 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPDeveloper\BetterDocs\Admin\Importer\Parsers;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * WordPress extended RSS file parser implementations,
10 * Originally made by WordPress part of WordPress/Importer.
11 * https://plugins.trac.wordpress.org/browser/wordpress-importer/trunk/parsers/class-wxr-parser.php
12 *
13 * What was done (by Elementor):
14 * Reformat of the code.
15 * Changed text domain.
16 */
17
18 /**
19 * WordPress Importer class for managing parsing of WXR files.
20 */
21 class WXR_Parser {
22
23 public function parse( $file ) {
24 // Attempt to use proper XML parsers first.
25 if ( extension_loaded( 'simplexml' ) ) {
26 $parser = new WXR_Parser_SimpleXML();
27 $result = $parser->parse( $file );
28
29 // If SimpleXML succeeds or this is an invalid WXR file then return the results.
30 if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) {
31 return $result;
32 }
33 } elseif ( extension_loaded( 'xml' ) ) {
34 $parser = new WXR_Parser_XML();
35 $result = $parser->parse( $file );
36
37 // If XMLParser succeeds or this is an invalid WXR file then return the results.
38 if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) {
39 return $result;
40 }
41 }
42
43 // Use regular expressions if nothing else available or this is bad XML.
44 $parser = new WXR_Parser_Regex();
45
46 return $parser->parse( $file );
47 }
48 }
49