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
← All changes | includes/Admin/Importer/Parsers/WXR_Parser_SimpleXML.php +70 -70 3.5.0 → 4.9.3 View file →
@@ -28,17 +28,17 @@
28 28 *
29 29 * @return array|WP_Error
30 30 */
31 31 public function parse( $file ) {
32 - $authors = [];
33 - $posts = [];
32 + $authors = [];
33 + $posts = [];
34 34 $categories = [];
35 - $tags = [];
36 - $terms = [];
35 + $tags = [];
36 + $terms = [];
37 37
38 38 libxml_use_internal_errors( true );
39 39
40 - $dom = new \DOMDocument();
40 + $dom = new \DOMDocument();
41 41 $old_value = null;
42 42
43 43 $libxml_disable_entity_loader_exists = function_exists( 'libxml_disable_entity_loader' );
44 44
@@ -100,34 +100,34 @@
100 100 }
101 101
102 102 // Grab authors.
103 103 foreach ( $xml->xpath( '/rss/channel/wp:author' ) as $author_arr ) {
104 - $a = $author_arr->children( $namespaces['wp'] );
105 - $login = (string) $a->author_login;
104 + $a = $author_arr->children( $namespaces['wp'] );
105 + $login = (string) $a->author_login;
106 106 $authors[ $login ] = [
107 - 'author_id' => (int) $a->author_id,
108 - 'author_login' => $login,
109 - 'author_email' => (string) $a->author_email,
107 + 'author_id' => (int) $a->author_id,
108 + 'author_login' => $login,
109 + 'author_email' => (string) $a->author_email,
110 110 'author_display_name' => (string) $a->author_display_name,
111 - 'author_first_name' => (string) $a->author_first_name,
112 - 'author_last_name' => (string) $a->author_last_name,
111 + 'author_first_name' => (string) $a->author_first_name,
112 + 'author_last_name' => (string) $a->author_last_name,
113 113 ];
114 114 }
115 115
116 116 // Grab cats, tags and terms.
117 117 foreach ( $xml->xpath( '/rss/channel/wp:category' ) as $term_arr ) {
118 - $t = $term_arr->children( $namespaces['wp'] );
118 + $t = $term_arr->children( $namespaces['wp'] );
119 119 $category = [
120 - 'term_id' => (int) $t->term_id,
121 - 'category_nicename' => (string) $t->category_nicename,
122 - 'category_parent' => (string) $t->category_parent,
123 - 'cat_name' => (string) $t->cat_name,
120 + 'term_id' => (int) $t->term_id,
121 + 'category_nicename' => (string) $t->category_nicename,
122 + 'category_parent' => (string) $t->category_parent,
123 + 'cat_name' => (string) $t->cat_name,
124 124 'category_description' => (string) $t->category_description,
125 125 ];
126 126
127 127 foreach ( $t->termmeta as $meta ) {
128 128 $category['termmeta'][] = [
129 - 'key' => (string) $meta->meta_key,
129 + 'key' => (string) $meta->meta_key,
130 130 'value' => (string) $meta->meta_value,
131 131 ];
132 132 }
133 133
@@ -134,19 +134,19 @@
134 134 $categories[] = $category;
135 135 }
136 136
137 137 foreach ( $xml->xpath( '/rss/channel/wp:tag' ) as $term_arr ) {
138 - $t = $term_arr->children( $namespaces['wp'] );
138 + $t = $term_arr->children( $namespaces['wp'] );
139 139 $tag = [
140 - 'term_id' => (int) $t->term_id,
141 - 'tag_slug' => (string) $t->tag_slug,
142 - 'tag_name' => (string) $t->tag_name,
140 + 'term_id' => (int) $t->term_id,
141 + 'tag_slug' => (string) $t->tag_slug,
142 + 'tag_name' => (string) $t->tag_name,
143 143 'tag_description' => (string) $t->tag_description,
144 144 ];
145 145
146 146 foreach ( $t->termmeta as $meta ) {
147 147 $tag['termmeta'][] = [
148 - 'key' => (string) $meta->meta_key,
148 + 'key' => (string) $meta->meta_key,
149 149 'value' => (string) $meta->meta_value,
150 150 ];
151 151 }
152 152
@@ -153,21 +153,21 @@
153 153 $tags[] = $tag;
154 154 }
155 155
156 156 foreach ( $xml->xpath( '/rss/channel/wp:term' ) as $term_arr ) {
157 - $t = $term_arr->children( $namespaces['wp'] );
157 + $t = $term_arr->children( $namespaces['wp'] );
158 158 $term = [
159 - 'term_id' => (int) $t->term_id,
160 - 'term_taxonomy' => (string) $t->term_taxonomy,
161 - 'slug' => (string) $t->term_slug,
162 - 'term_parent' => (string) $t->term_parent,
163 - 'term_name' => (string) $t->term_name,
159 + 'term_id' => (int) $t->term_id,
160 + 'term_taxonomy' => (string) $t->term_taxonomy,
161 + 'slug' => (string) $t->term_slug,
162 + 'term_parent' => (string) $t->term_parent,
163 + 'term_name' => (string) $t->term_name,
164 164 'term_description' => (string) $t->term_description,
165 165 ];
166 166
167 167 foreach ( $t->termmeta as $meta ) {
168 168 $term['termmeta'][] = [
169 - 'key' => (string) $meta->meta_key,
169 + 'key' => (string) $meta->meta_key,
170 170 'value' => (string) $meta->meta_value,
171 171 ];
172 172 }
173 173
@@ -177,32 +177,32 @@
177 177 // Grab posts.
178 178 foreach ( $xml->channel->item as $item ) {
179 179 $post = [
180 180 'post_title' => (string) $item->title,
181 - 'guid' => (string) $item->guid,
181 + 'guid' => (string) $item->guid,
182 182 ];
183 183
184 - $dc = $item->children( 'http://purl.org/dc/elements/1.1/' );
184 + $dc = $item->children( 'http://purl.org/dc/elements/1.1/' );
185 185 $post['post_author'] = (string) $dc->creator;
186 186
187 - $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' );
188 - $excerpt = $item->children( $namespaces['excerpt'] );
187 + $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' );
188 + $excerpt = $item->children( $namespaces['excerpt'] );
189 189 $post['post_content'] = (string) $content->encoded;
190 190 $post['post_excerpt'] = (string) $excerpt->encoded;
191 191
192 - $wp = $item->children( $namespaces['wp'] );
193 - $post['post_id'] = (int) $wp->post_id;
194 - $post['post_date'] = (string) $wp->post_date;
195 - $post['post_date_gmt'] = (string) $wp->post_date_gmt;
192 + $wp = $item->children( $namespaces['wp'] );
193 + $post['post_id'] = (int) $wp->post_id;
194 + $post['post_date'] = (string) $wp->post_date;
195 + $post['post_date_gmt'] = (string) $wp->post_date_gmt;
196 196 $post['comment_status'] = (string) $wp->comment_status;
197 - $post['ping_status'] = (string) $wp->ping_status;
198 - $post['post_name'] = (string) $wp->post_name;
199 - $post['status'] = (string) $wp->status;
200 - $post['post_parent'] = (int) $wp->post_parent;
201 - $post['menu_order'] = (int) $wp->menu_order;
202 - $post['post_type'] = (string) $wp->post_type;
203 - $post['post_password'] = (string) $wp->post_password;
204 - $post['is_sticky'] = (int) $wp->is_sticky;
197 + $post['ping_status'] = (string) $wp->ping_status;
198 + $post['post_name'] = (string) $wp->post_name;
199 + $post['status'] = (string) $wp->status;
200 + $post['post_parent'] = (int) $wp->post_parent;
201 + $post['menu_order'] = (int) $wp->menu_order;
202 + $post['post_type'] = (string) $wp->post_type;
203 + $post['post_password'] = (string) $wp->post_password;
204 + $post['is_sticky'] = (int) $wp->is_sticky;
205 205
206 206 if ( isset( $wp->attachment_url ) ) {
207 207 $post['attachment_url'] = (string) $wp->attachment_url;
208 208 }
@@ -210,10 +210,10 @@
210 210 foreach ( $item->category as $c ) {
211 211 $att = $c->attributes();
212 212 if ( isset( $att['nicename'] ) ) {
213 213 $post['terms'][] = [
214 - 'name' => (string) $c,
215 - 'slug' => (string) $att['nicename'],
214 + 'name' => (string) $c,
215 + 'slug' => (string) $att['nicename'],
216 216 'domain' => (string) $att['domain'],
217 217 ];
218 218 }
219 219 }
@@ -219,9 +219,9 @@
219 219 }
220 220
221 221 foreach ( $wp->postmeta as $meta ) {
222 222 $post['postmeta'][] = [
223 - 'key' => (string) $meta->meta_key,
223 + 'key' => (string) $meta->meta_key,
224 224 'value' => (string) $meta->meta_value,
225 225 ];
226 226 }
227 227
@@ -229,9 +229,9 @@
229 229 $meta = [];
230 230 if ( isset( $comment->commentmeta ) ) {
231 231 foreach ( $comment->commentmeta as $m ) {
232 232 $meta[] = [
233 - 'key' => (string) $m->meta_key,
233 + 'key' => (string) $m->meta_key,
234 234 'value' => (string) $m->meta_value,
235 235 ];
236 236 }
237 237 }
@@ -236,21 +236,21 @@
236 236 }
237 237 }
238 238
239 239 $post['comments'][] = [
240 - 'comment_id' => (int) $comment->comment_id,
241 - 'comment_author' => (string) $comment->comment_author,
240 + 'comment_id' => (int) $comment->comment_id,
241 + 'comment_author' => (string) $comment->comment_author,
242 242 'comment_author_email' => (string) $comment->comment_author_email,
243 - 'comment_author_IP' => (string) $comment->comment_author_IP,
244 - 'comment_author_url' => (string) $comment->comment_author_url,
245 - 'comment_date' => (string) $comment->comment_date,
246 - 'comment_date_gmt' => (string) $comment->comment_date_gmt,
247 - 'comment_content' => (string) $comment->comment_content,
248 - 'comment_approved' => (string) $comment->comment_approved,
249 - 'comment_type' => (string) $comment->comment_type,
250 - 'comment_parent' => (string) $comment->comment_parent,
251 - 'comment_user_id' => (int) $comment->comment_user_id,
252 - 'commentmeta' => $meta,
243 + 'comment_author_IP' => (string) $comment->comment_author_IP,
244 + 'comment_author_url' => (string) $comment->comment_author_url,
245 + 'comment_date' => (string) $comment->comment_date,
246 + 'comment_date_gmt' => (string) $comment->comment_date_gmt,
247 + 'comment_content' => (string) $comment->comment_content,
248 + 'comment_approved' => (string) $comment->comment_approved,
249 + 'comment_type' => (string) $comment->comment_type,
250 + 'comment_parent' => (string) $comment->comment_parent,
251 + 'comment_user_id' => (int) $comment->comment_user_id,
252 + 'commentmeta' => $meta,
253 253 ];
254 254 }
255 255
256 256 $posts[] = $post;
@@ -256,21 +256,21 @@
256 256 $posts[] = $post;
257 257 }
258 258
259 259 return [
260 - 'authors' => $authors,
261 - 'posts' => $posts,
262 - 'categories' => $categories,
263 - 'tags' => $tags,
264 - 'terms' => $terms,
265 - 'base_url' => $base_url,
260 + 'authors' => $authors,
261 + 'posts' => $posts,
262 + 'categories' => $categories,
263 + 'tags' => $tags,
264 + 'terms' => $terms,
265 + 'base_url' => $base_url,
266 266 'base_blog_url' => $base_blog_url,
267 267 'page_on_front' => $page_on_front,
268 - 'version' => $wxr_version,
268 + 'version' => $wxr_version,
269 269 ];
270 270 }
271 271
272 - /**
272 + /**
273 273 * @param $file
274 274 * @param mixed ...$args
275 275 * @return false|string
276 276 */