Edit File by line
/home/barbar84/www/wp-admin
File: link-parse-opml.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Parse OPML XML files and store in globals.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
die();
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* @global string $opml
[13] Fix | Delete
*/
[14] Fix | Delete
global $opml;
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* XML callback function for the start of a new XML tag.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 0.71
[20] Fix | Delete
* @access private
[21] Fix | Delete
*
[22] Fix | Delete
* @global array $names
[23] Fix | Delete
* @global array $urls
[24] Fix | Delete
* @global array $targets
[25] Fix | Delete
* @global array $descriptions
[26] Fix | Delete
* @global array $feeds
[27] Fix | Delete
*
[28] Fix | Delete
* @param resource $parser XML Parser resource.
[29] Fix | Delete
* @param string $tag_name XML element name.
[30] Fix | Delete
* @param array $attrs XML element attributes.
[31] Fix | Delete
*/
[32] Fix | Delete
function startElement( $parser, $tag_name, $attrs ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[33] Fix | Delete
global $names, $urls, $targets, $descriptions, $feeds;
[34] Fix | Delete
[35] Fix | Delete
if ( 'OUTLINE' === $tag_name ) {
[36] Fix | Delete
$name = '';
[37] Fix | Delete
if ( isset( $attrs['TEXT'] ) ) {
[38] Fix | Delete
$name = $attrs['TEXT'];
[39] Fix | Delete
}
[40] Fix | Delete
if ( isset( $attrs['TITLE'] ) ) {
[41] Fix | Delete
$name = $attrs['TITLE'];
[42] Fix | Delete
}
[43] Fix | Delete
$url = '';
[44] Fix | Delete
if ( isset( $attrs['URL'] ) ) {
[45] Fix | Delete
$url = $attrs['URL'];
[46] Fix | Delete
}
[47] Fix | Delete
if ( isset( $attrs['HTMLURL'] ) ) {
[48] Fix | Delete
$url = $attrs['HTMLURL'];
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
// Save the data away.
[52] Fix | Delete
$names[] = $name;
[53] Fix | Delete
$urls[] = $url;
[54] Fix | Delete
$targets[] = isset( $attrs['TARGET'] ) ? $attrs['TARGET'] : '';
[55] Fix | Delete
$feeds[] = isset( $attrs['XMLURL'] ) ? $attrs['XMLURL'] : '';
[56] Fix | Delete
$descriptions[] = isset( $attrs['DESCRIPTION'] ) ? $attrs['DESCRIPTION'] : '';
[57] Fix | Delete
} // End if outline.
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* XML callback function that is called at the end of a XML tag.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 0.71
[64] Fix | Delete
* @access private
[65] Fix | Delete
*
[66] Fix | Delete
* @param resource $parser XML Parser resource.
[67] Fix | Delete
* @param string $tag_name XML tag name.
[68] Fix | Delete
*/
[69] Fix | Delete
function endElement( $parser, $tag_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[70] Fix | Delete
// Nothing to do.
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
// Create an XML parser.
[74] Fix | Delete
if ( ! function_exists( 'xml_parser_create' ) ) {
[75] Fix | Delete
trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
[76] Fix | Delete
wp_die( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
$xml_parser = xml_parser_create();
[80] Fix | Delete
[81] Fix | Delete
// Set the functions to handle opening and closing tags.
[82] Fix | Delete
xml_set_element_handler( $xml_parser, 'startElement', 'endElement' );
[83] Fix | Delete
[84] Fix | Delete
if ( ! xml_parse( $xml_parser, $opml, true ) ) {
[85] Fix | Delete
printf(
[86] Fix | Delete
/* translators: 1: Error message, 2: Line number. */
[87] Fix | Delete
__( 'XML Error: %1$s at line %2$s' ),
[88] Fix | Delete
xml_error_string( xml_get_error_code( $xml_parser ) ),
[89] Fix | Delete
xml_get_current_line_number( $xml_parser )
[90] Fix | Delete
);
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
// Free up memory used by the XML parser.
[94] Fix | Delete
xml_parser_free( $xml_parser );
[95] Fix | Delete
unset( $xml_parser );
[96] Fix | Delete
[97] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function