luskaner / ojs-bridge

A bridge to use an OJS application and libraries in any PHP application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with the same name functions

jafamo opened this issue · comments

I created a new plugin in wordpress with MVC WP

private $ojsBridge;

public function __construct()
    {
        parent::__construct();
        $this->ojsBridge = new OJSBridge('/project/ojs/gitlab/ojs');

    }

    public function index(){
        echo "entrando";
        $application = $this->ojsBridge->start();
        $request = $application->getRequest();

My error:
Fatal error: Cannot redeclare __() (previously declared in /project/ojs/wordpress/wp-includes/l10n.php:201) in /project/ojs/gitlab/ojs/lib/pkp/classes/i18n/PKPLocale.inc.php on line 753

The function in wordpress:

function __( $text, $domain = 'default' ) {
	return translate( $text, $domain );
}

The function in OJS

function __($key, $params = array(), $locale = null) {
        return AppLocale::translate($key, $params, $locale);
}

Now I have two functions which name is the same.This functions are from core of App.
Two functions with different params ...
What can I do ?

Regards.

Hello @jafamo :
It seems you are using the initial version, try using the latest one (following the README.md), the code specifically check for this as can be seen in

if (function_exists('__')){
$this->rename_function('__', 'ojs_bridge_translate');
}

Hi @luskaner, thanks I solved my issue.

Regards,
xavi