Skip to content

Commit

Permalink
Merge pull request #7178 from pods-framework/release/3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Sep 22, 2023
2 parents 5e18c27 + b527d3c commit 99bb7f7
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions classes/Pods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 17 additions & 6 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand All @@ -5731,23 +5737,23 @@ 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
$remove_ids = array_diff( $related_ids, $value_ids );

// 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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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 =

Expand Down Expand Up @@ -175,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)
Expand Down

0 comments on commit 99bb7f7

Please sign in to comment.