| 1 |
<?php |
| 2 |
abstract class LP_REST_Jwt_Controller extends WP_REST_Controller { |
| 3 |
protected $namespace = 'learnpress/v1'; |
| 4 |
|
| 5 |
protected $rest_base = ''; |
| 6 |
|
| 7 |
private $_fields = null; |
| 8 |
|
| 9 |
private $_request = null; |
| 10 |
|
| 11 |
protected function add_additional_fields_schema( $schema ) { |
| 12 |
if ( empty( $schema['title'] ) ) { |
| 13 |
return $schema; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Can't use $this->get_object_type otherwise we cause an inf loop. |
| 18 |
*/ |
| 19 |
$object_type = $schema['title']; |
| 20 |
|
| 21 |
$additional_fields = $this->get_additional_fields( $object_type ); |
| 22 |
|
| 23 |
foreach ( $additional_fields as $field_name => $field_options ) { |
| 24 |
if ( ! $field_options['schema'] ) { |
| 25 |
continue; |
| 26 |
} |
| 27 |
|
| 28 |
$schema['properties'][ $field_name ] = $field_options['schema']; |
| 29 |
} |
| 30 |
|
| 31 |
$schema['properties'] = apply_filters( 'lp_jwt_rest_' . $object_type . '_schema', $schema['properties'] ); |
| 32 |
|
| 33 |
return $schema; |
| 34 |
} |
| 35 |
} |
| 36 |
|