PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-dev3
Elementor Website Builder – more than just a page builder v3.30.0-dev3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / data / v2 / base / endpoint / index / sub-index-endpoint.php

sub-index-endpoint.php in Elementor Website Builder – more than just a page builder 3.30.0-dev3, at data/v2/base/endpoint/index/sub-index-endpoint.php

43 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Data\V2\Base\Endpoint\Index;
3
4 use Elementor\Data\V2\Base\Endpoint\Index;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9 /**
10 * Class SubIndexEndpoint is default `Base\Endpoint\Index` of `SubController`,
11 * it was created to handle base_route and format for child controller, index endpoint.
12 * In case `SubController` were used and the default method of `Controller::register_index_endpoint` ain't overridden.
13 * this class will give support to have such routes, eg: 'alpha/{id}/beta/{sub_id}' without using additional endpoints.
14 */
15 final class Sub_Index_Endpoint extends Index {
16 /***
17 * @var \Elementor\Data\V2\Base\Controller
18 */
19 public $controller;
20
21 public function get_format() {
22 return $this->controller->get_parent()->get_name() . '/{id}/' . $this->controller->get_name() . '/{sub_id}';
23 }
24
25 public function get_base_route() {
26 $parent_controller = $this->controller->get_parent();
27 $parent_index_endpoint = $parent_controller->index_endpoint;
28 $parent_controller_route = '';
29
30 // In case `$parent_index_endpoint` is AllChildren, it cannot support id_arg_name.
31 if ( ! $parent_index_endpoint instanceof AllChildren ) {
32 $parent_controller_route = "(?P<{$parent_index_endpoint->id_arg_name}>[\w]+)";
33 }
34
35 return untrailingslashit('/' . implode( '/', array_filter( [
36 trim( $parent_index_endpoint->get_base_route(), '/' ),
37 $parent_controller_route,
38 $this->controller->get_name(),
39 $this->get_public_name(),
40 ] ) ) );
41 }
42 }
43