| Server IP : 104.26.4.103 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/aurointeriors/public_html/wp-content/plugins/metform/base/ |
Upload File : |
<?php
namespace MetForm\Base;
defined('ABSPATH') || exit;
abstract class Api
{
public $prefix = '';
public $param = '';
public $request = null;
public function __construct()
{
$this->config();
$this->init();
}
public abstract function config();
public function init()
{
add_action('rest_api_init', function () {
register_rest_route(untrailingslashit('metform/v1/' . $this->prefix), '/(?P<action>\w+)/' . ltrim($this->param, '/'), array(
'methods' => \WP_REST_Server::ALLMETHODS,
'callback' => [$this, 'action'],
'permission_callback' => '__return_true',
));
});
}
public function action($request)
{
$this->request = $request;
$action_class = strtolower($this->request->get_method()) . '_' . $this->request['action'];
if (method_exists($this, $action_class)) {
return $this->{$action_class}();
}
}
}