芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/jet-tabs/includes/rest-api/rest-api.php
_endpoints = array(); $this->register_endpoint( new Endpoints\Elementor_Template() ); $this->register_endpoint( new Endpoints\Plugin_Settings() ); $this->register_endpoint( new Endpoints\Clear_Tabs_Cache() ); do_action( 'jet-tabs/rest/init-endpoints', $this ); } /** * Register new endpoint * * @param object $endpoint_instance Endpoint instance * @return void */ public function register_endpoint( $endpoint_instance = null ) { if ( $endpoint_instance ) { $this->_endpoints[ $endpoint_instance->get_name() ] = $endpoint_instance; } } /** * Returns all registererd API endpoints * * @return [type] [description] */ public function get_endpoints() { if ( null === $this->_endpoints ) { $this->init_endpoints(); } return $this->_endpoints; } /** * Returns endpoints URLs */ public function get_endpoints_urls() { $result = array(); $endpoints = $this->get_endpoints(); foreach ( $endpoints as $endpoint ) { $key = str_replace( '-', '', ucwords( $endpoint->get_name(), '-' ) ); $result[ $key ] = get_rest_url( null, $this->api_namespace . '/' . $endpoint->get_name() . '/' . $endpoint->get_query_params() , 'rest' ); } return $result; } /** * Returns route to passed endpoint * * @return [type] [description] */ public function get_route( $endpoint = '', $full = false ) { $path = $this->api_namespace . '/' . $endpoint . '/'; if ( ! $full ) { return $path; } else { return get_rest_url( null, $path ); } } // Register our routes. public function register_routes() { $endpoints = $this->get_endpoints(); foreach ( $endpoints as $endpoint ) { $args = array( 'methods' => $endpoint->get_method(), 'callback' => array( $endpoint, 'callback' ), 'permission_callback' => array( $endpoint, 'permission_callback' ), ); if ( ! empty( $endpoint->get_args() ) ) { $args['args'] = $endpoint->get_args(); } $route = '/' . $endpoint->get_name() . '/' . $endpoint->get_query_params(); register_rest_route( $this->api_namespace, $route, $args ); } } }