acf_get_object_id()
Extract the ID of a given object/array. This supports all expected types handled by our update_fields() and load_fields() callbacks.
Хуков нет.
Возвращает
int|Разное|null
.
Использование
acf_get_object_id( $object );
- $object(WP_Post|WP_User|WP_Term|WP_Comment|массив) (обязательный)
- -
Код acf_get_object_id() acf get object id ACF 6.0.4
function acf_get_object_id( $object ) { if ( is_object( $object ) ) { switch ( get_class( $object ) ) { case WP_User::class: case WP_Post::class: return (int) $object->ID; case WP_Term::class: return (int) $object->term_id; case WP_Comment::class: return (int) $object->comment_ID; } } elseif ( isset( $object['id'] ) ) { return (int) $object['id']; } elseif ( isset( $object['ID'] ) ) { return (int) $object['ID']; } return null; }