From 95a822ed0493b50698ef1d51823152d1e2c632b1 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Thu, 21 Sep 2023 11:26:00 -0500 Subject: [PATCH 1/3] Update readme text for conditional logic and Layout fields --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 21c889cee6..07e277a8dc 100644 --- a/readme.txt +++ b/readme.txt @@ -19,6 +19,7 @@ Manage all your custom content needs in one location with the Pods Framework. * **Extend and customize content types** including Posts, Pages, Categories, Tags, Users, and Media with one easy click * **Create custom settings pages** easily within seconds * **Add custom fields** to *any* content type +* **Conditionally show fields** based on the value of other fields with Conditional Logic * **Group your fields** however you'd like into their own sections and add additional headings to help organize * **Show your fields** anywhere using our [blocks](https://docs.pods.io/displaying-pods/pods-blocks/), [shortcodes](https://docs.pods.io/displaying-pods/pods-shortcode/), [widgets](https://docs.pods.io/displaying-pods/pods-widgets/), or the non-coder [Pods Template](https://docs.pods.io/displaying-pods/pods-templates/) approach along with our [automatic theme integration](https://docs.pods.io/displaying-pods/pods-templates/auto-templates/) * **Create connections** between any of your content with [relationship fields](https://docs.pods.io/fields/relationship/) to keep your content organized @@ -57,6 +58,7 @@ You can also control visibility by role/capability and [other advanced options]( * **Relationships / Media:** File / Image / Video (Media library and basic upload options available), Avatar (for extended Users), oEmbed, Relationship (Dropdown, Multi Select, Autocomplete, Checkboxes, Radio Buttons, and List View available) * **Checkbox** (Yes / No) * **Color Picker** +* **Layout Fields:** Heading text, HTML content = Relationships to rule the world with = From f2b38c9dd277904a1ba8cfd0d9f62aac44edcea5 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Fri, 22 Sep 2023 10:59:34 -0500 Subject: [PATCH 2/3] Fix ID lookups for tableless fields on Settings pods that are DB-based to use the Pod ID for Item ID --- classes/Pods.php | 13 ++++++++++--- classes/PodsAPI.php | 23 +++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/classes/Pods.php b/classes/Pods.php index 4c37fe78ff..12363395f7 100644 --- a/classes/Pods.php +++ b/classes/Pods.php @@ -1048,9 +1048,16 @@ public function field( $name, $single = null, $raw = false ) { } } else { // Dot-traversal. - $pod = $this->pod_data['name']; - $ids = array( $this->id() ); - $all_fields = array(); + $pod = $this->pod_data['name']; + $ids = []; + + if ( 'settings' === $pod_type && $this->pod_data['id'] ) { + $ids[] = $this->pod_data['id']; + } else { + $ids[] = $this->id(); + } + + $all_fields = []; $lookup = $params->traverse; diff --git a/classes/PodsAPI.php b/classes/PodsAPI.php index 57c23e53bc..b086f5756f 100644 --- a/classes/PodsAPI.php +++ b/classes/PodsAPI.php @@ -5720,6 +5720,12 @@ public function save_pod_item( $params ) { // Save relationship / file data if ( ! empty( $rel_fields ) ) { + $item_id_for_lookup = $params->id; + + if ( 'settings' === $pod['type'] && $pod['id'] ) { + $item_id_for_lookup = $pod['id']; + } + foreach ( $rel_fields as $type => $data ) { foreach ( $data as $field_name => $value_data ) { $field_data = $fields[ $field_name ]; @@ -5731,10 +5737,10 @@ public function save_pod_item( $params ) { $related_data = pods_static_cache_get( $field_name . '/' . $field_id, 'PodsField_Pick/related_data' ) ?: []; // Get current values - if ( 'pick' === $type && isset( $related_data[ 'current_ids_' . $params->id ] ) ) { - $related_ids = $related_data[ 'current_ids_' . $params->id ]; + if ( 'pick' === $type && isset( $related_data[ 'current_ids_' . $item_id_for_lookup ] ) ) { + $related_ids = $related_data[ 'current_ids_' . $item_id_for_lookup ]; } else { - $related_ids = $this->lookup_related_items( $field_id, $pod['id'], $params->id, $field_data, $pod ); + $related_ids = $this->lookup_related_items( $field_id, $pod['id'], $item_id_for_lookup, $field_data, $pod ); } // Get ids to remove @@ -5742,12 +5748,12 @@ public function save_pod_item( $params ) { // Delete relationships if ( ! empty( $remove_ids ) ) { - $this->delete_relationships( $params->id, $remove_ids, $pod, $field_data ); + $this->delete_relationships( $item_id_for_lookup, $remove_ids, $pod, $field_data ); } // Save relationships if ( ! empty( $value_ids ) ) { - $this->save_relationships( $params->id, $value_ids, $pod, $field_data ); + $this->save_relationships( $item_id_for_lookup, $value_ids, $pod, $field_data ); } $pick_save_params = $params; @@ -5757,7 +5763,7 @@ public function save_pod_item( $params ) { $pick_save_params->remove_ids = $remove_ids; // Run save function for field type (where needed). - PodsForm::save( $type, $field_save_values, $params->id, $field_name, $field_data, $all_fields, $pod, $pick_save_params ); + PodsForm::save( $type, $field_save_values, $item_id_for_lookup, $field_name, $field_data, $all_fields, $pod, $pick_save_params ); } // Unset data no longer needed @@ -9582,6 +9588,11 @@ public function handle_field_validation( &$value, $field, $object_fields, $field * @uses pods_query() */ public function lookup_related_items( $field_id, $pod_id, $ids, $field = null, $pod = null ) { + // Handle settings lookups slightly differently. + if ( $pod && 'settings' === $pod['type'] && $pod['id'] && ! is_array( $ids ) && ! is_numeric( $ids ) ) { + $ids = $pod['id']; + } + $params = [ 'field_id' => $field_id, 'pod_id' => $pod_id, From b527d3c6cea09de33bef558884b0d717aa6faec9 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Fri, 22 Sep 2023 14:24:08 -0500 Subject: [PATCH 3/3] Update changelog --- changelog.txt | 4 ++++ init.php | 4 ++-- package.json | 2 +- readme.txt | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index fc741b4109..d09f567444 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,10 @@ Found a bug? Have a great feature idea? Get on GitHub and tell us about it and w Our GitHub has the full list of all prior releases of Pods: https://github.com/pods-framework/pods/releases += 3.0.3 - September 22nd, 2023 = + +* Fixed: Settings pods handling for relationships for Pods that are registered by DB / Code / File now normalize as necessary for relationships stored in the `wp_podsrel` index table for which item ID is used to relate from. (@sc0ttkclark) + = 3.0.2 - September 21st, 2023 = * Feature: You can now disable the Add New forms for a Post Type pod under the Advanced tab. (@sc0ttkclark) diff --git a/init.php b/init.php index 70c376fc4a..c17ef8591a 100644 --- a/init.php +++ b/init.php @@ -10,7 +10,7 @@ * Plugin Name: Pods - Custom Content Types and Fields * Plugin URI: https://pods.io/ * Description: Pods is a framework for creating, managing, and deploying customized content types and fields - * Version: 3.0.2 + * Version: 3.0.3 * Author: Pods Framework Team * Author URI: https://pods.io/about/ * Text Domain: pods @@ -43,7 +43,7 @@ add_action( 'init', 'pods_deactivate_pods_ui' ); } else { // Current version. - define( 'PODS_VERSION', '3.0.2' ); + define( 'PODS_VERSION', '3.0.3' ); // Current database version, this is the last version the database changed. define( 'PODS_DB_VERSION', '2.3.5' ); diff --git a/package.json b/package.json index add357f15c..2f9844716f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pods", - "version": "3.0.2", + "version": "3.0.3", "description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.", "author": "Pods Foundation, Inc", "homepage": "https://pods.io/", diff --git a/readme.txt b/readme.txt index 07e277a8dc..183f01055e 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields, Requires at least: 6.0 Tested up to: 6.3 Requires PHP: 7.2 -Stable tag: 3.0.2 +Stable tag: 3.0.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -177,6 +177,10 @@ Pods really wouldn't be where it is without all the contributions from our [dono == Changelog == += 3.0.3 - September 22nd, 2023 = + +* Fixed: Settings pods handling for relationships for Pods that are registered by DB / Code / File now normalize as necessary for relationships stored in the `wp_podsrel` index table for which item ID is used to relate from. (@sc0ttkclark) + = 3.0.2 - September 21st, 2023 = * Feature: You can now disable the Add New forms for a Post Type pod under the Advanced tab. (@sc0ttkclark)