<?php
/**
* @ASCOOS-NAME : Ascoos OS
* @ASCOOS-VERSION : 26.0.0
* @ASCOOS-SUPPORT : support@ascoos.com
* @ASCOOS-BUGS : https://issues.ascoos.com
*
*
* @CASE-STUDY : wp_joomla_in_aos.php
* @fileNo : ASCOOS-OS-CASESTUDY-SEC00080
*
* @desc <English> CiC example combining WordPress and Joomla in Ascoos OS for Web5 interoperability.
* @desc <Greek> ?????????? CiC ??? ????????? WordPress ??? Joomla ??? Ascoos OS ??? ?????????????????? Web5.
*
* @since PHP 8.2.0+
*/
declare(strict_types=1);
// ??????? Ascoos OS autoloader
global $AOS_LIBS_PATH;
// <English> Loading the Joomla CMS core. It must be implemented by the Joomla team.
// <Greek> ??????? ??? ?????? ??? Joomla cms. ?????? ?? ?? ?????????? ? ????? ??? Joomla.
require_once $AOS_LIBS_PATH . '/joomla/autoload.php';
// <English> Loading the core of the WordPress CMS. It needs to be implemented by the WordPress team.
// <Greek> ??????? ??? ?????? ??? Wordpress cms. ?????? ?? ?????????? ? ????? ??? Wordpress.
require_once $AOS_LIBS_PATH . '/wp/autoload.php';
use ASCOOS\OS\Kernel\CMS\Interpreters\{
TWordpressInterpreterHandler,
TWordpressHookTranslatorHandler,
TJoomlaApiBridgeHandler
};
use ASCOOS\OS\Kernel\Arrays\Macros\TMacroHandler;
try {
$macroEngine = new TMacroHandler();
// <English> WordPress hook
// <Greek> WordPress hook
$wpInterpreter = new TWordpressInterpreterHandler(['cms' => ['cmsType' => 'wordpress']]);
$wpHook = $wpInterpreter->interpretHooks("add_action('wp_head', 'my_custom_head', 10, 1)");
$wpTranslator = new TWordpressHookTranslatorHandler();
$wpMacro = $wpTranslator->translate($wpHook, ['hook' => 'wp_head']);
$macroEngine->addConditionalMacro(
$wpMacro->condition->condition,
fn(...$p) => $wpMacro->executeIfTrue(...$p)
);
// <English> Joomla API call
// <Greek> ????? API ??? Joomla
$joomlaApiBridge = new TJoomlaApiBridgeHandler();
$userData = $joomlaApiBridge->bridge('JFactory::getUser', []);
// <English> Combination of results
// <Greek> ?????????? ?????????????
$macroEngine->runAllConditional();
echo "@render_combined({$userData['name']})\n"; // Result: @render_combined(Ascoos user)
$wpTranslator->Free();
$wpInterpreter->Free();
$macroEngine->Free();
} catch (Exception $e) {
echo "Error: {$e->getMessage()}";
}
?>
|