A WordPress plugin that bridges the gap between WPML and the WordPress REST API, providing comprehensive multilingual support for modern WordPress applications.
Multilingual Bridge enhances WPML's functionality by adding full REST API support for multilingual content. It solves common challenges developers face when building headless WordPress applications or integrating with external systems that need language-aware content.
- No Native WPML REST API Support: WPML doesn't provide built-in REST API integration
- Complex Language Queries: Filtering posts by language in REST API requires custom implementation
- Missing Translation Links: No easy way to discover content translations via REST API
- Cumbersome WPML API: Simplifies complex WPML operations with helper functions
- Term Relationship Bugs: Works around WPML bugs when deleting term relationships across languages
- Automatically adds
language_code
field to all REST API responses - Includes translation links in the
_links
property with full embed support - Support for all post types with REST API enabled
- Simplified functions for common WPML operations
- Get post language with a single function call
- Retrieve all translations of a post easily
- Check translation completeness
- Safely delete term relationships across languages
- Full support for headless WordPress architectures
- Compatible with JavaScript frameworks (React, Vue, Next.js)
- Type-safe with PHPStan level 5
- WordPress coding standards compliant
- Language Debug tool for managing posts in unconfigured languages
- Bulk operations for cleaning up orphaned content
- Safe language reassignment for posts
- WordPress 5.0 or higher
- WPML plugin installed and activated
- PHP 8.0 or higher
- Download the plugin from the releases page
- Upload to your
/wp-content/plugins/
directory - Activate the plugin through the 'Plugins' menu in WordPress
- Ensure WPML is installed and activated
{
"id": 123,
"title": "Hello World",
"language_code": "en",
"_links": {
"translations": [
{
"href": "https://site.com/wp-json/wp/v2/posts/456",
"wpml_language": "de",
"title": "Translation: German",
"embeddable": true
}
]
}
}
use Multilingual_Bridge\Helpers\WPML_Post_Helper;
// Get post language
$language = WPML_Post_Helper::get_language($post_id);
// Get all translations
$translations = WPML_Post_Helper::get_language_versions($post_id);
// Check if post has all translations
if (WPML_Post_Helper::has_all_translations($post_id)) {
echo "Fully translated!";
}
// Safely delete term relationships
WPML_Post_Helper::safe_delete_term_relationships($post_id, 'category');
// Check if post is in unconfigured language
if (WPML_Post_Helper::is_post_in_unconfigured_language($post_id)) {
echo "Post is in a deactivated language!";
}
Comprehensive documentation is available in the /docs
directory:
- Language Fields and Translation Links - Automatic language information in REST responses with full embed support
- WPML Language Filtering - Information about WPML's native language filtering
- WPML Post Helper - Simplified WPML operations for developers
- Language Debug - Manage posts in unconfigured languages
- Headless WordPress: Build multilingual JAMstack sites with Next.js, Gatsby, or Nuxt
- Mobile Apps: Develop language-aware mobile applications
- External Integrations: Connect WordPress content to external systems
- Content Migration: Export/import multilingual content via REST API
- Custom Admin Interfaces: Build custom editing experiences with language support
multilingual-bridge/
βββ src/
β βββ Admin/ # Admin interface components
β βββ Helpers/ # WPML helper functions
β βββ REST/ # REST API functionality
βββ docs/ # Documentation
βββ languages/ # Translation files
The plugin maintains high code quality standards:
- PHPStan level 5 static analysis
- WordPress Coding Standards (WPCS)
- Comprehensive inline documentation
To run quality checks:
composer phpcs # Check coding standards
composer phpstan # Run static analysis
composer phpcbf # Auto-fix coding standards
Contributions are welcome! Please feel free to submit a Pull Request.
This plugin is licensed under GPL v2 or later.
Created by Justin Vogt and Citation Media
This plugin was created using the wordpress-plugin-boilerplate.