Call to undefined function trailingslashit() WordPress PHP Fatal Error
When attempting a plugin update on a WordPress installation hosted by WP Engine, you may encounter a PHP Fatal error: Call to undefined function trailingslashit(). This specific error originates from /wp-includes/class-wp-textdomain-registry.php at line 103. While the error appears deep within core text domain logic, the root cause is almost invariably a mismatch between your active plugins and the version of WordPress you are running.
The stack trace provided in error reports often points to load_textdomain, which triggers during the initialization phase (wp-load.php) or when updating core components like plugins. The function trailingslashit() is a legacy utility used to ensure paths end with a forward slash. If PHP cannot find this function, it means the autoloader has failed to load the specific WordPress core file where that function resides, or the core file itself is corrupted.
In many cases involving WP Engine and similar managed hosts, this error manifests when a plugin tries to load translations before the core environment is fully initialized. The stack trace shows the call chain starting from WP_Textdomain_Registry, moving through wp_load_translations_early, and eventually triggering the fatal error during the maintenance or upgrade process. This often happens if a plugin attempts to register text domains immediately upon activation, bypassing standard WordPress hooks that would normally ensure core functions are registered first.
The most common culprit for this specific "undefined function" error is an outdated version of the WPML (WordPress Multilingual) plugin or its associated language packs. WPML relies heavily on custom translation loading mechanisms. If a plugin is forcing the loading of text domains before the plugins_loaded hook has fully completed, it can access core functions that haven't been defined yet in that specific execution context.
To resolve this without losing data, follow these steps:
- Access via SSH: Since the admin dashboard may become inaccessible due to the fatal error, connect to your server via SSH using a tool like
sshor the WP Engine CLI if available. - Disable Problematic Plugins: Navigate to the plugins directory within your document root (e.g.,
/var/www/your-site/wp-content/plugins). You can temporarily rename the folders of suspected plugins, particularly WPML or its sub-plugins, to disable them without deleting them.mv /var/www/your-site/wp-content/plugins/wpml /var/www/your-site/wp-content/plugins/wpml-backup mv /var/www/your-site/wp-content/plugins/sitepress-multilingual-cms /var/www/your-site/wp-content/plugins/sitepress-multilingual-cms-backup - Verify Core Integrity: Ensure that the
wp-includesdirectory is not missing files. Sometimes, partial updates or failed deployments can leave core files incomplete. Check thatclass-wp-textdomain-registry.phpexists in the/wp-includes/directory.
Once the plugins are disabled, attempt to run a plugin update again through the dashboard. If the error disappears, you have confirmed that one of the renamed plugins was incompatible with your current WordPress version or core state.
If disabling WPML resolves the issue but you need to restore its functionality, consider updating the WPML plugin and all related language packs to their latest versions. In some instances, the issue stems from a conflict between an old WPML version and new translation loading standards in recent WordPress updates. You may also need to clear the object cache or transient options via your hosting control panel or by flushing wp- tables if you are comfortable with direct database access.
There is no single "magic switch" for this error, but identifying that the fault lies in the text domain initialization sequence allows you to isolate the plugin causing the premature load attempt. By renaming the plugin directory and re-checking the update process, you effectively force WordPress to initialize its core functions correctly before any external code attempts to hook into them. This approach bypasses the autoloader error without requiring a full site rebuild.