Skip to content

Commit

Permalink
Update Plugin.php
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Feb 21, 2024
1 parent 1629adb commit 268157f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 )
);
},
]
Expand Down

0 comments on commit 268157f

Please sign in to comment.