سلام وقت بخیر
کد زیر اجرا نمیشه لطفا برسی نمایید
<?php
class Router
{
public function __construct()
{
add_action('init',[$this,'handle_routs']);
}
public function handle_routs()
{
$request_uri = $_SERVER['REQUEST_URI'];
$this->dispatch_request($request_uri);
}
private function dispatch_request($request_uri){
$handler = $this->parse_uri($request_uri);
$handler_name = $this->format_handler_name($handler);
if (!$this->is_handler_valid($handler_name)){
throw new Exception('no page valid');
}
$handler_path = $this->get_handler_file($handler_name);
include_once $handler_path;
new $handler_name;
exit;
}
private function parse_uri($uri)
{
$uri_parts=explode('/',$uri);
return end($uri_parts);
}
private function is_handler_valid($handler){
$handler_file_path =$this->get_handler_file($handler);
return file_exists($handler_file_path) && is_readable($handler_file_path);
}
private function get_handler_file($handler){
$handler_file_path = PP_DIR.DIRECTORY_SEPARATOR.'panel/handlers/'.$handler.'.php';
return $handler_file_path;
}
private function format_handler_name($handler){
$formatted_handler = ucfirst($handler) . 'Handler';
return $formatted_handler;
}
}
ارور زیر رو داره
Fatal error: Uncaught Exception: no page valid in C:\xampp\htdocs\wxpert\www\wp-content\plugins\panel-pro\router.php:24 Stack trace: #0 C:\xampp\htdocs\wxpert\www\wp-content\plugins\panel-pro\router.php(16): Router->dispatch_request('/wp-admin/plugi...') #1 C:\xampp\htdocs\wxpert\www\wp-includes\class-wp-hook.php(292): Router->handle_routs('') #2 C:\xampp\htdocs\wxpert\www\wp-includes\class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #3 C:\xampp\htdocs\wxpert\www\wp-includes\plugin.php(484): WP_Hook->do_action(Array) #4 C:\xampp\htdocs\wxpert\www\wp-settings.php(560): do_action('init') #5 C:\xampp\htdocs\wxpert\www\wp-config.php(90): require_once('C:\\xampp\\htdocs...') #6 C:\xampp\htdocs\wxpert\www\wp-load.php(37): require_once('C:\\xampp\\htdocs...') #7 C:\xampp\htdocs\wxpert\www\wp-admin\admin.php(34): require_once('C:\\xampp\\htdocs...') #8 C:\xampp\htdocs\wxpert\www\wp-admin\plugins.php(10): require_once('C:\\xampp\\htdocs...') #9 {main} thrown in C:\xampp\htdocs\wxpert\www\wp-content\plugins\panel-pro\router.php on line 24
کاش سورس کد هارو قرار میدادین