diff --git a/classes/Plugin.php b/classes/Plugin.php index adc91f2..4bb04eb 100644 --- a/classes/Plugin.php +++ b/classes/Plugin.php @@ -35,6 +35,22 @@ public function __construct( $file ) { \add_action( 'rest_api_init', function () { + \register_rest_field( + 'orbis_project', + 'orbis_project_id', + [ + 'get_callback' => function() { + $project_post = \get_post(); + + if ( ! $project_post instanceof WP_Post ) { + return null; + } + + return $project_post->project_id; + }, + ] + ); + \register_rest_field( 'orbis_project', 'select2_text', @@ -50,8 +66,8 @@ function () { '%s. %s - %s ( %s )', $project_post->project_id, $project_post->principal_name, - \get_the_title( $project_post ), - isset( $project->project_logged_time ) ? \orbis_time( $project_post->project_logged_time ) . ' / ' . \orbis_time( $project_post->project_number_seconds ) : \orbis_time( $project_post->project_number_seconds ) + $project_post->post_title, + isset( $project_post->project_logged_time ) ? \orbis_time( $project_post->project_logged_time ) . ' / ' . \orbis_time( $project_post->project_number_seconds ) : \orbis_time( $project_post->project_number_seconds ) ); }, ]