From 90aefd81c9784639e479ea2a55b3c515c37b89b9 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Sun, 1 Jun 2025 18:59:01 +0200 Subject: [PATCH] Fixes for wordpress frontend --- index.php | 43 ++++++++++++++++++++++++++++++++++--------- libraries/Routes.php | 16 +++++++++++++--- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/index.php b/index.php index 46578a3..0e47347 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,8 @@ use PhangoApp\PhaUtils\Utils; +ob_start(); + include('libraries/Utils.php'); include('libraries/Routes.php'); @@ -27,26 +29,49 @@ if(is_file(__DIR__.'/vendor/autoload.php')) { } -ob_start(); +//ob_start(); Utils::load_config('config'); -if(!PhangoApp\PhaRouter\Config::$get_path_info) { +if(!PhangoApp\PhaRouter\Config::$on_other) { - $path_info=isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; -} -else { + if(!PhangoApp\PhaRouter\Config::$get_path_info) { - $path_info=str_replace(PhangoApp\PhaRouter\Config::$base_url.'index.php', '', $_SERVER['REQUEST_URI']); + $path_info=isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; + } + else { - if($path_info===PhangoApp\PhaRouter\Config::$base_url) { + $path_info=str_replace(PhangoApp\PhaRouter\Config::$base_url.'index.php', '', $_SERVER['REQUEST_URI']); - $path_info=''; + if($path_info===PhangoApp\PhaRouter\Config::$base_url) { + + $path_info=''; + + } } +} +else { + + if(!isset($_GET['path_info'])) { + + $path_info=''; + + } + else { + + $path_info=$_GET['path_info']; + + } + } echo \PhangoApp\PhaRouter\get_route($path_info); -ob_end_flush(); +//ob_end_flush(); +$final_content=ob_get_contents(); + +ob_end_clean(); + +echo $final_content; diff --git a/libraries/Routes.php b/libraries/Routes.php index 2fad5f4..519682f 100644 --- a/libraries/Routes.php +++ b/libraries/Routes.php @@ -16,6 +16,8 @@ class Config { static public $index_file='index.php/'; static public $get_path_info=false; + + static public $on_other=false; } @@ -52,7 +54,11 @@ function get_controller($controller, $args=[]) { echo 'Page not found'; - http_response_code(404); + if(!\PhangoApp\PhaRouter\Config::$on_other) { + + http_response_code(404); + + } exit(1); @@ -138,8 +144,12 @@ function get_route($path_info) { //If not return, page not found. echo 'Page not found'; - - http_response_code(404); + + if(!\PhangoApp\PhaRouter\Config::$on_other) { + + http_response_code(404); + + } exit(1);