cloggier
↑
/wp-content/plugins/chatway-live-chat
marsupiataab
hypermuffing
cloggier
hypermuffing
marsupiataab
Api.php
1,515 B
cloggier
marsupiataab
Assets.php
5,025 B
cloggier
marsupiataab
Base.php
2,172 B
cloggier
marsupiataab
ChatwayApi.php
21,085 B
cloggier
marsupiataab
ExternalApi.php
13,295 B
cloggier
marsupiataab
Front.php
10,529 B
cloggier
marsupiataab
Icons.php
904 B
cloggier
marsupiataab
Singleton.php
396 B
cloggier
marsupiataab
Url.php
4,780 B
cloggier
marsupiataab
User.php
3,238 B
cloggier
marsupiataab
View.php
7,671 B
cloggier
marsupiataab
<?php /** * Base for creating internal API * * @author : Chatway * @license : GPLv3 * */ namespace Chatway\App; defined( 'ABSPATH' ) || exit; abstract class Api { /** * @var string */ public $prefix = ''; /** * @var string */ public $param = ''; /** * @var \WP_REST_Request */ public $request; abstract public function config(); public function __construct() { $this->config(); $this->init(); } public function init() { add_action( 'rest_api_init', function () { register_rest_route( untrailingslashit( 'chatway/v1/' . $this->prefix ), '/(?P<action>\w+)/' . ltrim( $this->param, '/' ), [ 'methods' => \WP_REST_Server::ALLMETHODS, 'callback' => [$this, 'action'], 'permission_callback' => function () { return current_user_can( 'manage_options' ); } ] ); } ); } /** * @param $request * @return mixed */ public function action( \WP_REST_Request $request ) { $this->request = $request; $action_class = strtolower( $this->request->get_method() ) . '_' . sanitize_key( $this->request['action'] ); if ( method_exists( $this, $action_class ) ) { return $this->{$action_class}(); } } }
cloggier