' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
';
echo __( 'The file does not exist, please try again.', 'wordpress-importer' ) . '
' . __( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ) . '
'; echo '' . __( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ) . '
'; @@ -1343,7 +1343,7 @@ function greet() { * @param string $key The meta key to check * @return string|bool The key if we do want to import, false if not */ - function is_valid_meta_key( $key ) { + public function is_valid_meta_key( $key ) { // skip attachment metadata since we'll regenerate it from scratch // skip _edit_lock as not relevant for import if ( in_array( $key, array( '_wp_attached_file', '_wp_attachment_metadata', '_edit_lock' ), true ) ) { @@ -1358,7 +1358,7 @@ function is_valid_meta_key( $key ) { * * @return bool True if creating users is allowed */ - function allow_create_users() { + public function allow_create_users() { return apply_filters( 'import_allow_create_users', true ); } @@ -1369,7 +1369,7 @@ function allow_create_users() { * * @return bool True if downloading attachments is allowed */ - function allow_fetch_attachments() { + public function allow_fetch_attachments() { return apply_filters( 'import_allow_fetch_attachments', true ); } @@ -1379,7 +1379,7 @@ function allow_fetch_attachments() { * * @return int Maximum attachment file size to import */ - function max_attachment_size() { + public function max_attachment_size() { return apply_filters( 'import_attachment_size_limit', 0 ); } @@ -1387,12 +1387,12 @@ function max_attachment_size() { * Added to http_request_timeout filter to force timeout at 60 seconds during import * @return int 60 */ - function bump_request_timeout( $val ) { + public function bump_request_timeout( $val ) { return 60; } // return the difference in length between two strings - function cmpr_strlen( $a, $b ) { + public function cmpr_strlen( $a, $b ) { return strlen( $b ) - strlen( $a ); } diff --git a/src/parsers.php b/src/parsers.php index 0aef25f..d719542 100644 --- a/src/parsers.php +++ b/src/parsers.php @@ -9,13 +9,13 @@ _deprecated_file( basename( __FILE__ ), '0.7.0' ); /** WXR_Parser class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser.php'; +require_once __DIR__ . '/parsers/class-wxr-parser.php'; /** WXR_Parser_SimpleXML class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-simplexml.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-simplexml.php'; /** WXR_Parser_XML class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-xml.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-xml.php'; /** WXR_Parser_Regex class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-regex.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-regex.php'; diff --git a/src/parsers/class-wxr-parser-regex.php b/src/parsers/class-wxr-parser-regex.php index 45baf6f..4ac1a96 100644 --- a/src/parsers/class-wxr-parser-regex.php +++ b/src/parsers/class-wxr-parser-regex.php @@ -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 @@ function parse( $file ) { ); } - 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 ) == '' ) !== false ) { @@ -136,7 +136,7 @@ function get_tag( $string, $tag ) { 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 @@ function process_category( $c ) { 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 @@ function process_tag( $t ) { 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 @@ function process_term( $t ) { 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 @@ function process_meta( $string, $tag ) { 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 @@ function process_author( $a ) { ); } - 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 @@ function process_post( $post ) { 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 ); } diff --git a/src/parsers/class-wxr-parser-simplexml.php b/src/parsers/class-wxr-parser-simplexml.php index 00dd110..0c44d93 100644 --- a/src/parsers/class-wxr-parser-simplexml.php +++ b/src/parsers/class-wxr-parser-simplexml.php @@ -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 @@ function parse( $file ) { $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 ); diff --git a/src/parsers/class-wxr-parser-xml.php b/src/parsers/class-wxr-parser-xml.php index f7262f1..07be15d 100644 --- a/src/parsers/class-wxr-parser-xml.php +++ b/src/parsers/class-wxr-parser-xml.php @@ -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; @@ -118,7 +118,7 @@ function parse( $file ) { ); } - 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; @@ -173,7 +173,7 @@ function tag_open( $parse, $tag, $attr ) { } } - function cdata( $parser, $cdata ) { + public function cdata( $parser, $cdata ) { if ( ! trim( $cdata ) ) { return; } @@ -185,7 +185,7 @@ function cdata( $parser, $cdata ) { } } - 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 diff --git a/src/parsers/class-wxr-parser.php b/src/parsers/class-wxr-parser.php index 057bf9e..8c418cd 100644 --- a/src/parsers/class-wxr-parser.php +++ b/src/parsers/class-wxr-parser.php @@ -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 @@ function parse( $file ) { 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 @@ function parse( $file ) { } // 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 ); } } diff --git a/src/wordpress-importer.php b/src/wordpress-importer.php index 88cf9c6..f65825b 100644 --- a/src/wordpress-importer.php +++ b/src/wordpress-importer.php @@ -34,22 +34,22 @@ } /** Functions missing in older WordPress versions. */ -require_once dirname( __FILE__ ) . '/compat.php'; +require_once __DIR__ . '/compat.php'; /** WXR_Parser class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser.php'; +require_once __DIR__ . '/parsers/class-wxr-parser.php'; /** WXR_Parser_SimpleXML class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-simplexml.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-simplexml.php'; /** WXR_Parser_XML class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-xml.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-xml.php'; /** WXR_Parser_Regex class */ -require_once dirname( __FILE__ ) . '/parsers/class-wxr-parser-regex.php'; +require_once __DIR__ . '/parsers/class-wxr-parser-regex.php'; /** WP_Import class */ -require_once dirname( __FILE__ ) . '/class-wp-import.php'; +require_once __DIR__ . '/class-wp-import.php'; function wordpress_importer_init() { load_plugin_textdomain( 'wordpress-importer' ); diff --git a/wordpress-importer.php b/wordpress-importer.php index f3d4515..9fa5797 100644 --- a/wordpress-importer.php +++ b/wordpress-importer.php @@ -5,4 +5,4 @@ */ // This file is included purely for those using Git and checking out directly into wp-content/plugins/wordpress-importer/ -include dirname( __FILE__ ) . '/src/wordpress-importer.php'; +require_once __DIR__ . '/src/wordpress-importer.php';