PHP Classes

File: aos-SEC00080-wp_joomla_in_aos.php

Recommend this page to a friend!
  Packages of Christos Drogidis   Ascoos OS - CiC (Cross-Interpreter Communication)   aos-SEC00080-wp_joomla_in_aos.php   Download  
File: aos-SEC00080-wp_joomla_in_aos.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Ascoos OS - CiC (Cross-Interpreter Communication)
combine WordPress and Joomla in a shared runtime
Author: By
Last change:
Date: 4 months ago
Size: 2,648 bytes
 

Contents

Class file image Download
<?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()}";
}
?>