最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Unable to activate wordpress importer after installing it

programmeradmin4浏览0评论

After installing wordpress importer from Tools option in wordpress, when I try to activate it, it gives fatal error.

The relevant php code:

class WXR_Parser {
    function parse( $file ) {
        // Attempt to use proper XML parsers first
        if ( extension_loaded( 'simplexml' ) ) {
            $parser = new WXR_Parser_SimpleXML;
            $result = $parser->parse( $file );

            // If SimpleXML succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() )
                return $result;
        } else if ( extension_loaded( 'xml' ) ) {
            $parser = new WXR_Parser_XML;
            $result = $parser->parse( $file );

            // If XMLParser succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() )
                return $result;
        }

        // We have a malformed XML file, so display the error and fallthrough to regex
        if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) {
            echo '<pre>';
            if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
                foreach  ( $result->get_error_data() as $error )
                    echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
            } else if ( 'XML_parse_error' == $result->get_error_code() ) {
                $error = $result->get_error_data();
                echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
            }
            echo '</pre>';
            echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />';
            echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>';
        }

        // use regular expressions if nothing else available or this is bad XML
        $parser = new WXR_Parser_Regex;
        return $parser->parse( $file );
    }
}

After installing wordpress importer from Tools option in wordpress, when I try to activate it, it gives fatal error.

The relevant php code:

class WXR_Parser {
    function parse( $file ) {
        // Attempt to use proper XML parsers first
        if ( extension_loaded( 'simplexml' ) ) {
            $parser = new WXR_Parser_SimpleXML;
            $result = $parser->parse( $file );

            // If SimpleXML succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() )
                return $result;
        } else if ( extension_loaded( 'xml' ) ) {
            $parser = new WXR_Parser_XML;
            $result = $parser->parse( $file );

            // If XMLParser succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() )
                return $result;
        }

        // We have a malformed XML file, so display the error and fallthrough to regex
        if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) {
            echo '<pre>';
            if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
                foreach  ( $result->get_error_data() as $error )
                    echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
            } else if ( 'XML_parse_error' == $result->get_error_code() ) {
                $error = $result->get_error_data();
                echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
            }
            echo '</pre>';
            echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />';
            echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>';
        }

        // use regular expressions if nothing else available or this is bad XML
        $parser = new WXR_Parser_Regex;
        return $parser->parse( $file );
    }
}
Share Improve this question edited Dec 28, 2016 at 20:42 Tunji 2,9611 gold badge18 silver badges28 bronze badges asked Dec 27, 2016 at 14:27 RahulRahul 2291 gold badge4 silver badges12 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 4

That error suggests that the WXR_Parser class is already "running" or declared. It's possible that a theme or another plugin has incorporated that class and did not check if it existed already before initializing. ie. if ( ! class_exists( 'WXR_Parser' ) ).

To locate the source of the conflict, deactivate each theme and plugin one-by-one. You should be left with just a default theme active (ie. TwentyFifteen).

This happened with me too.

I did not go to code section for this.

I changed the activated-theme to Twenty-Sixteen and then I tried to activate the plugin and succeed.

i had same error with a theme, then I switched to wordpress default theme, then installed the worpress importer.... its installed and working well. then I changed my favourite theme, which is working well. Thanks.

发布评论

评论列表(0)

  1. 暂无评论