Skip to content

Commit

Permalink
Add fallback for $pod->field() and the find argument in case the …
Browse files Browse the repository at this point in the history
…Pods object is not returned
  • Loading branch information
sc0ttkclark committed Aug 31, 2024
1 parent e93f06c commit cae1001
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion includes/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2186,12 +2186,26 @@ function pods_shortcode_run( $tags, $content = null, $blog_is_switched = false,
pods_debug_log_data( [ 'field_name' => $tags['related_field'], 'sql' => $params ], 'shortcode-field-params', __METHOD__, __LINE__ );

// Override the Pods object.
$pod = $pod->field( [
$pod_check = $pod->field( [
'name' => $tags['related_field'],
'output' => 'find',
'params' => $params,
] );

if ( ! $pod_check instanceof Pods ) {
$related_field = $pod->pod_data->get_field( $tags['related_field'] );

if ( $related_field instanceof Field ) {
$related_object = $related_field->get_related_object();

if ( $related_object instanceof Pod ) {
$pod_check = pods( $related_object->get_name() );
}
}
}

$pod = $pod_check;

if ( ! $pod instanceof Pods ) {
return pods_message(
sprintf(
Expand Down

0 comments on commit cae1001

Please sign in to comment.