$field ) { if ( ! is_array( $field ) || empty( $field['type'] ) || 'date' !== $field['type'] ) { continue; } // Use group ID for unique keys $key = $group['slug'] . ':' . $field_key; $options[ $key ] = $field['name']; } if ( empty( $options ) ) { continue; } foreach ( $options as $key => $value ) { $_fields[ $key ] = $value; } } if ( $_fields ) return $_fields; return false; } /** * Get Field Value * * Returns field value given a key and a post * * @since 2.1.0 * @param post_id|int The Post ID * @param key|string The key of the field * @return string|bool The formatted date or false */ public function get_field_value( $post_id, $key ) { // Fallback to current post if ( ! $post_id ) $post_id = get_the_ID(); // Double check for key and toolset function if ( ! $key || ! function_exists( 'types_render_field' ) ) return; list( $field_group, $field_key ) = explode( ':', $key ); $field = wpcf_admin_fields_get_field( $field_key ); $value = ''; if ( $field && ! empty( $field['type'] ) && 'date' === $field['type'] ) { $timestamp = types_render_field( $field_key, [ 'post_id' => $post_id, 'output' => 'raw', 'style' => 'text', ] ); if ( ! $timestamp ) return; $timestamp = (int)$timestamp; $value = date( 'Y-m-d', $timestamp ); } return wp_kses_post( $value ); } }