From 91195c5fcced34ac6374af7d5ed495a2fdd1466c Mon Sep 17 00:00:00 2001 From: th Date: Thu, 22 Oct 2020 10:35:57 +0200 Subject: [PATCH] Fixed taxonomy field load/save function to get right post id if field is located in a block --- includes/api/api-helpers.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/includes/api/api-helpers.php b/includes/api/api-helpers.php index 25cc2585..6b097d1e 100644 --- a/includes/api/api-helpers.php +++ b/includes/api/api-helpers.php @@ -2737,8 +2737,26 @@ function acf_get_post_id_info( $post_id = 0 ) { $info['type'] = $type; $info['id'] = (int) $id; - - // option + + // block + } elseif ($type == 'block') { + + $info['type'] = 'post'; + $realPostID = 0; + if(isset($GLOBALS['post']) && isset($GLOBALS['post']->ID)) { + $realPostID = $GLOBALS['post']->ID; + } elseif(isset($_REQUEST['post_id']) && is_numeric($_REQUEST['post_id'])) { + $realPostID = $_REQUEST['post_id']; + } elseif(isset($GLOBALS['HTTP_RAW_POST_DATA'])) { + $rawPostData = $GLOBALS['HTTP_RAW_POST_DATA']; + $postData = json_decode($rawPostData, true); + if(isset($postData['id'])) { + $realPostID = $postData['id']; + } + } + $info['id'] = (int) $realPostID; + + // option } else { $info['type'] = 'option';