diff --git a/CHANGELOG.md b/CHANGELOG.md index c686270..8f00443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 2.3.0 + +## Update Notice + +This release refactored some internals regarding how Clone fields and Group fields behave. There was no intentional breaking changes to the Schema, but if you are using Clone and Group fields there is a chance that if you were benefiting from a "bug as a feature" there might be some changes that could impact your Schema and/or resolvers, we recommend testing this update on a staging site to ensure things are still working for you as expected. Should you run into any problems, please [open a new issue](https://github.com/wp-graphql/wpgraphql-acf/issues/new/choose) and provide as much detail as possible to help us reproduce the scenario. Thanks! 🙏 + +## New Features + +- [#193](https://github.com/wp-graphql/wpgraphql-acf/pull/193): feat: improved handling of clone and group fields + +## Chores / Bugfixes + +- [#194](https://github.com/wp-graphql/wpgraphql-acf/pull/194): ci: test against WordPress 6.5 + ## 2.2.0 ## New Features diff --git a/readme.txt b/readme.txt index 2f5c275..c9c6a99 100644 --- a/readme.txt +++ b/readme.txt @@ -104,6 +104,10 @@ Learn more about how [Appsero collects and uses data](https://appsero.com/privac == Upgrade Notice == += 2.3.0 = + +This release refactored some internals regarding how Clone fields and Group fields behave. There was no intentional breaking changes to the Schema, but if you are using Clone and Group fields there is a chance that if you were benefiting from a "bug as a feature" there might be some changes that could impact your Schema and/or resolvers, we recommend testing this update on a staging site to ensure things are still working for you as expected. Should you run into any problems, please [open a new issue](https://github.com/wp-graphql/wpgraphql-acf/issues/new/choose) and provide as much detail as possible to help us reproduce the scenario. Thanks! 🙏 + = 2.1.0 = While fixing some [performance issues](https://github.com/wp-graphql/wpgraphql-acf/pull/152) we had to adjust the fallback logic for mapping ACF Field Groups to the Schema if they do not have "graphql_types" defined. @@ -116,6 +120,12 @@ This release is a complete re-architecture of WPGraphQL for ACF, introducing bre == Changelog == += 2.3.0 = + +**New Features** + +**Chores / Bugfixes** + = 2.2.0 = **New Features** diff --git a/src/FieldConfig.php b/src/FieldConfig.php index 67bf30a..655bbdd 100644 --- a/src/FieldConfig.php +++ b/src/FieldConfig.php @@ -541,20 +541,6 @@ static function ( $opt ) { $value = apply_filters( 'the_content', $value ); } - if ( ! empty( $acf_field_config['type'] ) && in_array( - $acf_field_config['type'], - [ - 'date_picker', - 'time_picker', - 'date_time_picker', - ], - true - ) ) { - if ( ! empty( $value ) && ! empty( $acf_field_config['return_format'] ) ) { - $value = gmdate( $acf_field_config['return_format'], strtotime( $value ) ); - } - } - if ( ! empty( $acf_field_config['type'] ) && in_array( $acf_field_config['type'], [ 'number', 'range' ], true ) ) { $value = (float) $value ?: null; } diff --git a/src/FieldType/DatePicker.php b/src/FieldType/DatePicker.php index 32a7e41..c03c818 100644 --- a/src/FieldType/DatePicker.php +++ b/src/FieldType/DatePicker.php @@ -1,6 +1,7 @@ static function ( $root, $args, $context, $info, $field_type, FieldConfig $field_config ) { $value = $field_config->resolve_field( $root, $args, $context, $info ); - if ( empty( $value ) ) { - return null; - } - - $acf_field = $field_config->get_acf_field(); - - // Get the return format from the ACF Field - $return_format = $acf_field['return_format'] ?? null; - - if ( empty( $return_format ) ) { - return $value; - } - - $date_time = \DateTime::createFromFormat( $return_format . '|', $value ); + $timestamp = strtotime( $value ); - if ( empty( $date_time ) ) { + if ( false === $timestamp ) { return null; } - // appending '|' to the format prevents the minutes and seconds from being determined from the current time - return $date_time->format( \DateTimeInterface::RFC3339 ); + return gmdate( DateTimeInterface::RFC3339, $timestamp ); }, ] ); diff --git a/src/FieldType/DateTimePicker.php b/src/FieldType/DateTimePicker.php index c87c83f..5e4616f 100644 --- a/src/FieldType/DateTimePicker.php +++ b/src/FieldType/DateTimePicker.php @@ -29,22 +29,13 @@ public static function register_field_type(): void { return null; } - $acf_field = $field_config->get_acf_field(); + $timestamp = strtotime( $value ); - // Get the return format from the ACF Field - $return_format = $acf_field['return_format'] ?? null; - - if ( empty( $return_format ) ) { - return $value; - } - - $date_time = \DateTime::createFromFormat( $return_format, $value ); - - if ( empty( $date_time ) ) { + if ( false === $timestamp ) { return null; } - return $date_time->format( DateTimeInterface::RFC3339 ); + return gmdate( DateTimeInterface::RFC3339, $timestamp ); }, ] ); diff --git a/wpgraphql-acf.php b/wpgraphql-acf.php index 02851aa..205da09 100644 --- a/wpgraphql-acf.php +++ b/wpgraphql-acf.php @@ -4,7 +4,7 @@ * Description: WPGraphQL for ACF seamlessly integrates Advanced Custom Fields with WPGraphQL. * Author: WPGraphQL, Jason Bahl * Author URI: https://www.wpgraphql.com - * Version: 2.2.0 + * Version: 2.3.0 * Text Domain: wpgraphql-acf * Requires PHP: 7.3 * Requires at least: 5.9 @@ -31,7 +31,7 @@ } if ( ! defined( 'WPGRAPHQL_FOR_ACF_VERSION' ) ) { - define( 'WPGRAPHQL_FOR_ACF_VERSION', '2.2.0' ); + define( 'WPGRAPHQL_FOR_ACF_VERSION', '2.3.0' ); } if ( ! defined( 'WPGRAPHQL_FOR_ACF_VERSION_WPGRAPHQL_REQUIRED_MIN_VERSION' ) ) {