From 52d6f59c91d2b026430c2aaf9fa4fd13ec349cee Mon Sep 17 00:00:00 2001 From: Panos Kountanis Date: Mon, 15 Jan 2024 12:42:14 +0200 Subject: [PATCH] Fix rest-api php warning. --- includes/class-wp-job-manager-rest-api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-wp-job-manager-rest-api.php b/includes/class-wp-job-manager-rest-api.php index 17137b28a..2c8ac7f29 100644 --- a/includes/class-wp-job-manager-rest-api.php +++ b/includes/class-wp-job-manager-rest-api.php @@ -36,6 +36,10 @@ public static function prepare_job_listing( $response, $post ) { $fields = WP_Job_Manager_Post_Types::get_job_listing_fields(); $data = $response->get_data(); + if ( ! isset( $data['meta'] ) ) { + $data['meta'] = []; + } + foreach ( $data['meta'] as $meta_key => $meta_value ) { if ( isset( $fields[ $meta_key ] ) && is_callable( $fields[ $meta_key ]['auth_view_callback'] ) ) { $is_viewable = call_user_func( $fields[ $meta_key ]['auth_view_callback'], false, $meta_key, $post->ID, $current_user->ID );