Hi Team. For now your plugin doesn’t work with the Polylang Pro. Could you update your code base in lokalise/include/Provider/class-lokalise-provider-polylang.php file? You can see 2 modified methods below
public function isEnabled(): bool
{
$activePlugins = array_filter($this->getPluginFiles(), 'is_plugin_active');
return count($activePlugins) > 0;
}
/**
* @return string[]
*/
private function getPluginFiles(): array
{
return [
'polylang/polylang.php',
'polylang-pro/polylang.php',
];
}
]]>
Hi Team. Could you add ability to working together with Polylang Pro? I’ve update your code. Please see below
<?php
class Lokalise_Provider_Polylang extends Lokalise_Registrable implements Lokalise_Provider
{
public function register()
{
Lokalise_PluginProvider::registerProvider($this->getSlug(), $this);
}
public function isEnabled(): bool
{
$activePlugins = array_filter($this->getPluginFiles(), 'is_plugin_active');
return count($activePlugins) > 0;
}
public function getLocale()
{
return new Lokalise_Locales_Polylang();
}
public function getDecorator()
{
return new Lokalise_Decorator_Polylang();
}
public function getName()
{
return 'Polylang';
}
public function getSlug()
{
return 'polylang';
}
public function getPriority()
{
return 9;
}
private function getPluginFile()
{
return ['polylang/polylang.php', 'polylang-pro/polylang.php'];
}
/**
* @inheritDoc
*/
public function getTranslatablePosts()
{
if (!function_exists('PLL')) {
// Polylang API is not available
return [];
}
/**
* @var PLL_REST_Request $pll
*/
$pll = Pll();
return $pll->model->get_translated_post_types();
}
}
]]>
Hi. I get this error in some cases, when there are no languages and I’m adding a new post or when a post has autosave and maybe in some others
Fatal error: Uncaught TypeError: Argument 1 passed to Lokalise_Decorator_Polylang::getPostMetadata() must be an instance of WP_Term, bool given, called in /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Decorator/class-lokalise-decorator-polylang.php on line 52 and defined in /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Decorator/class-lokalise-decorator-polylang.php:104 Stack trace: #0 /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Decorator/class-lokalise-decorator-polylang.php(52): Lokalise_Decorator_Polylang->getPostMetadata() #1 /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Decorator/class-lokalise-decorator-polylang.php(40): Lokalise_Decorator_Polylang->updateResponseData() #2 /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Callback/class-lokalise-callback-get-posts.php(31): Lokalise_Decorator_Polylang->decorateResponse() #3 /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/class-lo in /media/renr/data/public_html/test/wp-content/plugins/lokalise/include/Decorator/class-lokalise-decorator-polylang.php on line 104
Some environments don’t have getallheaders() which will result in a fatal error. Consider adding a workaround or perhaps using $_SERVER[‘Authorization’] directly.
]]>The authorization.php template has get_header() but no get_footer() which results in a broken page
]]>