۱ حمزه بختیاری
مشکل در اجرای کد
جامعه وردپرس (برنامه نویسی) ایجاد شده در ۱۰ اردیبهشت ۱۴۰۰

سلام وقت بخیر 

کد زیر اجرا نمیشه لطفا برسی نمایید

 

<?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

 

کاش سورس کد هارو قرار میدادین

سلام خدمت شما

این را

 $this->dispatch_request($request_uri);---->در handle_routs()

با بلاک

try  catch

هندل کنید مشکل حل می‌شود

سورس کدها را فکر کنم با پشتیبانی تماس بگیرید در اختیارتون قرارمی دهند این موضوع را با پشتیبانی مطرح کنید ببینید 

پاسخ شان چیست

اگر مشکل حل نشد مجدد پیام بگذارید

موفق باشید

 

رضا محب ۱۱ اردیبهشت ۱۴۰۰، ۰۰:۳۲