interfaces
1 year ago
traits
2 years ago
dynamic-rest-url-trait.php
2 years ago
rest-api-controller-base.php
2 years ago
rest-api-endpoint-base.php
7 months ago
rest-api-private-endpoint-base.php
8 months ago
rest-endpoint.php
2 years ago
rest-response.php
2 years ago
route.php
1 year ago
dynamic-rest-url-trait.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace JFB_Components\Rest_Api; |
| 5 | |
| 6 | use Jet_Form_Builder\Classes\Http\Http_Tools; |
| 7 | |
| 8 | // If this file is called directly, abort. |
| 9 | if ( ! defined( 'WPINC' ) ) { |
| 10 | die; |
| 11 | } |
| 12 | |
| 13 | trait Dynamic_Rest_Url_Trait { |
| 14 | |
| 15 | public static function get_dynamic_base( array $path_args ): string { |
| 16 | return Http_Tools::replace_path_args( static::get_rest_base(), $path_args ); |
| 17 | } |
| 18 | |
| 19 | public static function dynamic_rest_url( array $path ): string { |
| 20 | return rest_url( self::dynamic_base( $path ) ); |
| 21 | } |
| 22 | |
| 23 | public static function dynamic_base( array $path_args ): string { |
| 24 | return ( '/' . static::get_namespace() . '/' . static::get_dynamic_base( $path_args ) ); |
| 25 | } |
| 26 | |
| 27 | public static function dynamic_rest_base( array $path_args ): string { |
| 28 | return ( '/' . rest_get_url_prefix() . self::dynamic_base( $path_args ) ); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |