Updating my WordPress to 4.4 I have that error:

Fatal error: Class ‘WP_Rewrite’ not found

The page who have the error is my custom ajax with the following code:

<?php
// Constantes propias para ajax
define("SHORTINIT",true);
define('WP_USE_THEMES', false);
define('WP_ALLOW_MULTISITE', false);
if (!defined("AUTH_COOKIE")){
    define("AUTH_COOKIE",false);
}
if (!defined("LOGGED_IN_COOKIE")){
    define("LOGGED_IN_COOKIE",false);
}
require_once ("../../../../wp-load.php");
//Loading code from wp-settings after SHORTINIT    
require( ABSPATH . WPINC . '/l10n.php' );
require( ABSPATH . WPINC . '/formatting.php' );
require( ABSPATH . WPINC . '/capabilities.php' );
require( ABSPATH . WPINC . '/query.php' );
require( ABSPATH . WPINC . '/user.php' );
require( ABSPATH . WPINC . '/meta.php' );
require( ABSPATH . WPINC . '/general-template.php' );
require( ABSPATH . WPINC . '/link-template.php' );
require( ABSPATH . WPINC . '/post.php' );
require( ABSPATH . WPINC . '/comment.php' );
require( ABSPATH . WPINC . '/rewrite.php' );
require( ABSPATH . WPINC . '/script-loader.php' );
require( ABSPATH . WPINC . '/taxonomy.php' );
require( ABSPATH . WPINC . '/theme.php' );
require( ABSPATH . WPINC . '/class-wp-walker.php' );
require( ABSPATH . WPINC . '/post-template.php' );
require( ABSPATH . WPINC . '/post-thumbnail-template.php' );
require( ABSPATH . WPINC . '/shortcodes.php' );
require( ABSPATH . WPINC . '/media.php' );

create_initial_taxonomies();
create_initial_post_types();

require( ABSPATH . WPINC . '/pluggable.php' );

wp_set_internal_encoding();
wp_functionality_constants( );

$GLOBALS['wp_the_query'] = new WP_Query();
$GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
$GLOBALS['wp'] = new WP();
$GLOBALS['wp']->init();
wp();

if (!defined("WP_CONTENT_URL")){
    define("WP_CONTENT_URL",get_option('siteurl').'/wp-content');
}
require_once ('ajax-funciones.php');
// There I have some acctions

die();
?>

Before update WordPress that works but now, I have the error with WP_Rewrite(). That class is in the file rewrite.php if you looking for in the codex and that is include.

What can be the problem?

2 Answers
2

I can fixed the problem including this files:

require( ABSPATH . WPINC . '/class-wp-rewrite.php' );
require( ABSPATH . WPINC . '/class-wp-user.php' );
require( ABSPATH . WPINC . '/class-wp-tax-query.php' );
require( ABSPATH . WPINC . '/class-wp-meta-query.php' );
require( ABSPATH . WPINC . '/class-wp-term.php' );
require( ABSPATH . WPINC . '/class-wp-post.php' );
require( ABSPATH . WPINC . '/class-wp-roles.php' );
require( ABSPATH . WPINC . '/class-wp-role.php' );

Following the errors in the code and looking for in the wordpress codex.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *