Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../parsers
File: class-wxr-parser-xml.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress eXtended RSS file parser implementations
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Importer
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* WXR Parser that makes use of the XML Parser PHP extension.
[9] Fix | Delete
*/
[10] Fix | Delete
class WXR_Parser_XML {
[11] Fix | Delete
public $wp_tags = array(
[12] Fix | Delete
'wp:post_id',
[13] Fix | Delete
'wp:post_date',
[14] Fix | Delete
'wp:post_date_gmt',
[15] Fix | Delete
'wp:comment_status',
[16] Fix | Delete
'wp:ping_status',
[17] Fix | Delete
'wp:attachment_url',
[18] Fix | Delete
'wp:status',
[19] Fix | Delete
'wp:post_name',
[20] Fix | Delete
'wp:post_parent',
[21] Fix | Delete
'wp:menu_order',
[22] Fix | Delete
'wp:post_type',
[23] Fix | Delete
'wp:post_password',
[24] Fix | Delete
'wp:is_sticky',
[25] Fix | Delete
'wp:term_id',
[26] Fix | Delete
'wp:category_nicename',
[27] Fix | Delete
'wp:category_parent',
[28] Fix | Delete
'wp:cat_name',
[29] Fix | Delete
'wp:category_description',
[30] Fix | Delete
'wp:tag_slug',
[31] Fix | Delete
'wp:tag_name',
[32] Fix | Delete
'wp:tag_description',
[33] Fix | Delete
'wp:term_taxonomy',
[34] Fix | Delete
'wp:term_parent',
[35] Fix | Delete
'wp:term_name',
[36] Fix | Delete
'wp:term_description',
[37] Fix | Delete
'wp:author_id',
[38] Fix | Delete
'wp:author_login',
[39] Fix | Delete
'wp:author_email',
[40] Fix | Delete
'wp:author_display_name',
[41] Fix | Delete
'wp:author_first_name',
[42] Fix | Delete
'wp:author_last_name',
[43] Fix | Delete
);
[44] Fix | Delete
public $wp_sub_tags = array(
[45] Fix | Delete
'wp:comment_id',
[46] Fix | Delete
'wp:comment_author',
[47] Fix | Delete
'wp:comment_author_email',
[48] Fix | Delete
'wp:comment_author_url',
[49] Fix | Delete
'wp:comment_author_IP',
[50] Fix | Delete
'wp:comment_date',
[51] Fix | Delete
'wp:comment_date_gmt',
[52] Fix | Delete
'wp:comment_content',
[53] Fix | Delete
'wp:comment_approved',
[54] Fix | Delete
'wp:comment_type',
[55] Fix | Delete
'wp:comment_parent',
[56] Fix | Delete
'wp:comment_user_id',
[57] Fix | Delete
);
[58] Fix | Delete
[59] Fix | Delete
public $wxr_version;
[60] Fix | Delete
public $in_post;
[61] Fix | Delete
public $cdata;
[62] Fix | Delete
public $data;
[63] Fix | Delete
public $sub_data;
[64] Fix | Delete
public $in_tag;
[65] Fix | Delete
public $in_sub_tag;
[66] Fix | Delete
public $authors;
[67] Fix | Delete
public $posts;
[68] Fix | Delete
public $term;
[69] Fix | Delete
public $category;
[70] Fix | Delete
public $tag;
[71] Fix | Delete
public $base_url;
[72] Fix | Delete
public $base_blog_url;
[73] Fix | Delete
[74] Fix | Delete
function parse( $file ) {
[75] Fix | Delete
$this->wxr_version = false;
[76] Fix | Delete
$this->in_post = false;
[77] Fix | Delete
$this->cdata = false;
[78] Fix | Delete
$this->data = false;
[79] Fix | Delete
$this->sub_data = false;
[80] Fix | Delete
$this->in_tag = false;
[81] Fix | Delete
$this->in_sub_tag = false;
[82] Fix | Delete
$this->authors = array();
[83] Fix | Delete
$this->posts = array();
[84] Fix | Delete
$this->term = array();
[85] Fix | Delete
$this->category = array();
[86] Fix | Delete
$this->tag = array();
[87] Fix | Delete
[88] Fix | Delete
$xml = xml_parser_create( 'UTF-8' );
[89] Fix | Delete
xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
[90] Fix | Delete
xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
[91] Fix | Delete
xml_set_object( $xml, $this );
[92] Fix | Delete
xml_set_character_data_handler( $xml, 'cdata' );
[93] Fix | Delete
xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
[94] Fix | Delete
[95] Fix | Delete
if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
[96] Fix | Delete
$current_line = xml_get_current_line_number( $xml );
[97] Fix | Delete
$current_column = xml_get_current_column_number( $xml );
[98] Fix | Delete
$error_code = xml_get_error_code( $xml );
[99] Fix | Delete
$error_string = xml_error_string( $error_code );
[100] Fix | Delete
return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) );
[101] Fix | Delete
}
[102] Fix | Delete
xml_parser_free( $xml );
[103] Fix | Delete
[104] Fix | Delete
if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) {
[105] Fix | Delete
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
return array(
[109] Fix | Delete
'authors' => $this->authors,
[110] Fix | Delete
'posts' => $this->posts,
[111] Fix | Delete
'categories' => $this->category,
[112] Fix | Delete
'tags' => $this->tag,
[113] Fix | Delete
'terms' => $this->term,
[114] Fix | Delete
'base_url' => $this->base_url,
[115] Fix | Delete
'base_blog_url' => $this->base_blog_url,
[116] Fix | Delete
'version' => $this->wxr_version,
[117] Fix | Delete
);
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
function tag_open( $parse, $tag, $attr ) {
[121] Fix | Delete
if ( in_array( $tag, $this->wp_tags, true ) ) {
[122] Fix | Delete
$this->in_tag = substr( $tag, 3 );
[123] Fix | Delete
return;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
if ( in_array( $tag, $this->wp_sub_tags, true ) ) {
[127] Fix | Delete
$this->in_sub_tag = substr( $tag, 3 );
[128] Fix | Delete
return;
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
switch ( $tag ) {
[132] Fix | Delete
case 'category':
[133] Fix | Delete
if ( isset( $attr['domain'], $attr['nicename'] ) ) {
[134] Fix | Delete
if ( false === $this->sub_data ) {
[135] Fix | Delete
$this->sub_data = array();
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
$this->sub_data['domain'] = $attr['domain'];
[139] Fix | Delete
$this->sub_data['slug'] = $attr['nicename'];
[140] Fix | Delete
}
[141] Fix | Delete
break;
[142] Fix | Delete
case 'item':
[143] Fix | Delete
$this->in_post = true;
[144] Fix | Delete
break;
[145] Fix | Delete
case 'title':
[146] Fix | Delete
if ( $this->in_post ) {
[147] Fix | Delete
$this->in_tag = 'post_title';
[148] Fix | Delete
}
[149] Fix | Delete
break;
[150] Fix | Delete
case 'guid':
[151] Fix | Delete
$this->in_tag = 'guid';
[152] Fix | Delete
break;
[153] Fix | Delete
case 'dc:creator':
[154] Fix | Delete
$this->in_tag = 'post_author';
[155] Fix | Delete
break;
[156] Fix | Delete
case 'content:encoded':
[157] Fix | Delete
$this->in_tag = 'post_content';
[158] Fix | Delete
break;
[159] Fix | Delete
case 'excerpt:encoded':
[160] Fix | Delete
$this->in_tag = 'post_excerpt';
[161] Fix | Delete
break;
[162] Fix | Delete
[163] Fix | Delete
case 'wp:term_slug':
[164] Fix | Delete
$this->in_tag = 'slug';
[165] Fix | Delete
break;
[166] Fix | Delete
case 'wp:meta_key':
[167] Fix | Delete
$this->in_sub_tag = 'key';
[168] Fix | Delete
break;
[169] Fix | Delete
case 'wp:meta_value':
[170] Fix | Delete
$this->in_sub_tag = 'value';
[171] Fix | Delete
break;
[172] Fix | Delete
}
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
function cdata( $parser, $cdata ) {
[176] Fix | Delete
if ( ! trim( $cdata ) ) {
[177] Fix | Delete
return;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
if ( false !== $this->in_tag || false !== $this->in_sub_tag ) {
[181] Fix | Delete
$this->cdata .= $cdata;
[182] Fix | Delete
} else {
[183] Fix | Delete
$this->cdata .= trim( $cdata );
[184] Fix | Delete
}
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
function tag_close( $parser, $tag ) {
[188] Fix | Delete
switch ( $tag ) {
[189] Fix | Delete
case 'wp:comment':
[190] Fix | Delete
unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
[191] Fix | Delete
if ( ! empty( $this->sub_data ) ) {
[192] Fix | Delete
$this->data['comments'][] = $this->sub_data;
[193] Fix | Delete
}
[194] Fix | Delete
$this->sub_data = false;
[195] Fix | Delete
break;
[196] Fix | Delete
case 'wp:commentmeta':
[197] Fix | Delete
$this->sub_data['commentmeta'][] = array(
[198] Fix | Delete
'key' => $this->sub_data['key'],
[199] Fix | Delete
'value' => $this->sub_data['value'],
[200] Fix | Delete
);
[201] Fix | Delete
break;
[202] Fix | Delete
case 'category':
[203] Fix | Delete
if ( ! empty( $this->sub_data ) ) {
[204] Fix | Delete
$this->sub_data['name'] = $this->cdata;
[205] Fix | Delete
$this->data['terms'][] = $this->sub_data;
[206] Fix | Delete
}
[207] Fix | Delete
$this->sub_data = false;
[208] Fix | Delete
break;
[209] Fix | Delete
case 'wp:postmeta':
[210] Fix | Delete
if ( ! empty( $this->sub_data ) ) {
[211] Fix | Delete
$this->data['postmeta'][] = $this->sub_data;
[212] Fix | Delete
}
[213] Fix | Delete
$this->sub_data = false;
[214] Fix | Delete
break;
[215] Fix | Delete
case 'item':
[216] Fix | Delete
$this->posts[] = $this->data;
[217] Fix | Delete
$this->data = false;
[218] Fix | Delete
break;
[219] Fix | Delete
case 'wp:category':
[220] Fix | Delete
case 'wp:tag':
[221] Fix | Delete
case 'wp:term':
[222] Fix | Delete
$n = substr( $tag, 3 );
[223] Fix | Delete
array_push( $this->$n, $this->data );
[224] Fix | Delete
$this->data = false;
[225] Fix | Delete
break;
[226] Fix | Delete
case 'wp:termmeta':
[227] Fix | Delete
if ( ! empty( $this->sub_data ) ) {
[228] Fix | Delete
$this->data['termmeta'][] = $this->sub_data;
[229] Fix | Delete
}
[230] Fix | Delete
$this->sub_data = false;
[231] Fix | Delete
break;
[232] Fix | Delete
case 'wp:author':
[233] Fix | Delete
if ( ! empty( $this->data['author_login'] ) ) {
[234] Fix | Delete
$this->authors[ $this->data['author_login'] ] = $this->data;
[235] Fix | Delete
}
[236] Fix | Delete
$this->data = false;
[237] Fix | Delete
break;
[238] Fix | Delete
case 'wp:base_site_url':
[239] Fix | Delete
$this->base_url = $this->cdata;
[240] Fix | Delete
if ( ! isset( $this->base_blog_url ) ) {
[241] Fix | Delete
$this->base_blog_url = $this->cdata;
[242] Fix | Delete
}
[243] Fix | Delete
break;
[244] Fix | Delete
case 'wp:base_blog_url':
[245] Fix | Delete
$this->base_blog_url = $this->cdata;
[246] Fix | Delete
break;
[247] Fix | Delete
case 'wp:wxr_version':
[248] Fix | Delete
$this->wxr_version = $this->cdata;
[249] Fix | Delete
break;
[250] Fix | Delete
[251] Fix | Delete
default:
[252] Fix | Delete
if ( $this->in_sub_tag ) {
[253] Fix | Delete
if ( false === $this->sub_data ) {
[254] Fix | Delete
$this->sub_data = array();
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
$this->sub_data[ $this->in_sub_tag ] = ! empty( $this->cdata ) ? $this->cdata : '';
[258] Fix | Delete
$this->in_sub_tag = false;
[259] Fix | Delete
} elseif ( $this->in_tag ) {
[260] Fix | Delete
if ( false === $this->data ) {
[261] Fix | Delete
$this->data = array();
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
$this->data[ $this->in_tag ] = ! empty( $this->cdata ) ? $this->cdata : '';
[265] Fix | Delete
$this->in_tag = false;
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
$this->cdata = false;
[270] Fix | Delete
}
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function