plugin updates

This commit is contained in:
Tony Volpe
2024-10-24 12:57:16 -04:00
parent 8217f0dbed
commit 5e040c9234
399 changed files with 3377 additions and 46318 deletions

View File

@@ -19,11 +19,11 @@ class WXR_Parser_Regex {
public $base_blog_url = '';
public $has_gzip;
function __construct() {
public function __construct() {
$this->has_gzip = is_callable( 'gzopen' );
}
function parse( $file ) {
public function parse( $file ) {
$wxr_version = false;
$in_multiline = false;
@@ -114,8 +114,8 @@ class WXR_Parser_Regex {
);
}
function get_tag( $string, $tag ) {
preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
public function get_tag( $text, $tag ) {
preg_match( "|<$tag.*?>(.*?)</$tag>|is", $text, $return );
if ( isset( $return[1] ) ) {
if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
@@ -136,7 +136,7 @@ class WXR_Parser_Regex {
return $return;
}
function process_category( $c ) {
public function process_category( $c ) {
$term = array(
'term_id' => $this->get_tag( $c, 'wp:term_id' ),
'cat_name' => $this->get_tag( $c, 'wp:cat_name' ),
@@ -153,7 +153,7 @@ class WXR_Parser_Regex {
return $term;
}
function process_tag( $t ) {
public function process_tag( $t ) {
$term = array(
'term_id' => $this->get_tag( $t, 'wp:term_id' ),
'tag_name' => $this->get_tag( $t, 'wp:tag_name' ),
@@ -169,7 +169,7 @@ class WXR_Parser_Regex {
return $term;
}
function process_term( $t ) {
public function process_term( $t ) {
$term = array(
'term_id' => $this->get_tag( $t, 'wp:term_id' ),
'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ),
@@ -187,10 +187,10 @@ class WXR_Parser_Regex {
return $term;
}
function process_meta( $string, $tag ) {
public function process_meta( $text, $tag ) {
$parsed_meta = array();
preg_match_all( "|<$tag>(.+?)</$tag>|is", $string, $meta );
preg_match_all( "|<$tag>(.+?)</$tag>|is", $text, $meta );
if ( ! isset( $meta[1] ) ) {
return $parsed_meta;
@@ -206,7 +206,7 @@ class WXR_Parser_Regex {
return $parsed_meta;
}
function process_author( $a ) {
public function process_author( $a ) {
return array(
'author_id' => $this->get_tag( $a, 'wp:author_id' ),
'author_login' => $this->get_tag( $a, 'wp:author_login' ),
@@ -217,7 +217,7 @@ class WXR_Parser_Regex {
);
}
function process_post( $post ) {
public function process_post( $post ) {
$post_id = $this->get_tag( $post, 'wp:post_id' );
$post_title = $this->get_tag( $post, 'title' );
$post_date = $this->get_tag( $post, 'wp:post_date' );
@@ -314,32 +314,32 @@ class WXR_Parser_Regex {
return $postdata;
}
function _normalize_tag( $matches ) {
public function _normalize_tag( $matches ) {
return '<' . strtolower( $matches[1] );
}
function fopen( $filename, $mode = 'r' ) {
public function fopen( $filename, $mode = 'r' ) {
if ( $this->has_gzip ) {
return gzopen( $filename, $mode );
}
return fopen( $filename, $mode );
}
function feof( $fp ) {
public function feof( $fp ) {
if ( $this->has_gzip ) {
return gzeof( $fp );
}
return feof( $fp );
}
function fgets( $fp, $len = 8192 ) {
public function fgets( $fp, $len = 8192 ) {
if ( $this->has_gzip ) {
return gzgets( $fp, $len );
}
return fgets( $fp, $len );
}
function fclose( $fp ) {
public function fclose( $fp ) {
if ( $this->has_gzip ) {
return gzclose( $fp );
}

View File

@@ -10,7 +10,7 @@
* WXR Parser that makes use of the SimpleXML PHP extension.
*/
class WXR_Parser_SimpleXML {
function parse( $file ) {
public function parse( $file ) {
$authors = array();
$posts = array();
$categories = array();
@@ -19,7 +19,7 @@ class WXR_Parser_SimpleXML {
$internal_errors = libxml_use_internal_errors( true );
$dom = new DOMDocument;
$dom = new DOMDocument();
$old_value = null;
if ( function_exists( 'libxml_disable_entity_loader' ) && PHP_VERSION_ID < 80000 ) {
$old_value = libxml_disable_entity_loader( true );

View File

@@ -73,7 +73,7 @@ class WXR_Parser_XML {
public $base_url;
public $base_blog_url;
function parse( $file ) {
public function parse( $file ) {
$this->wxr_version = false;
$this->in_post = false;
$this->cdata = false;
@@ -90,9 +90,8 @@ class WXR_Parser_XML {
$xml = xml_parser_create( 'UTF-8' );
xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
xml_set_object( $xml, $this );
xml_set_character_data_handler( $xml, 'cdata' );
xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
xml_set_character_data_handler( $xml, array( $this, 'cdata' ) );
xml_set_element_handler( $xml, array( $this, 'tag_open' ), array( $this, 'tag_close' ) );
if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
$current_line = xml_get_current_line_number( $xml );
@@ -119,7 +118,7 @@ class WXR_Parser_XML {
);
}
function tag_open( $parse, $tag, $attr ) {
public function tag_open( $parse, $tag, $attr ) {
if ( in_array( $tag, $this->wp_tags, true ) ) {
$this->in_tag = substr( $tag, 3 );
return;
@@ -174,7 +173,7 @@ class WXR_Parser_XML {
}
}
function cdata( $parser, $cdata ) {
public function cdata( $parser, $cdata ) {
if ( ! trim( $cdata ) ) {
return;
}
@@ -186,7 +185,7 @@ class WXR_Parser_XML {
}
}
function tag_close( $parser, $tag ) {
public function tag_close( $parser, $tag ) {
switch ( $tag ) {
case 'wp:comment':
unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data

View File

@@ -10,10 +10,10 @@
* WordPress Importer class for managing parsing of WXR files.
*/
class WXR_Parser {
function parse( $file ) {
public function parse( $file ) {
// Attempt to use proper XML parsers first
if ( extension_loaded( 'simplexml' ) ) {
$parser = new WXR_Parser_SimpleXML;
$parser = new WXR_Parser_SimpleXML();
$result = $parser->parse( $file );
// If SimpleXML succeeds or this is an invalid WXR file then return the results
@@ -21,7 +21,7 @@ class WXR_Parser {
return $result;
}
} elseif ( extension_loaded( 'xml' ) ) {
$parser = new WXR_Parser_XML;
$parser = new WXR_Parser_XML();
$result = $parser->parse( $file );
// If XMLParser succeeds or this is an invalid WXR file then return the results
@@ -47,7 +47,7 @@ class WXR_Parser {
}
// use regular expressions if nothing else available or this is bad XML
$parser = new WXR_Parser_Regex;
$parser = new WXR_Parser_Regex();
return $parser->parse( $file );
}
}