pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.06k stars 265 forks source link

Fix parameter name on pods_field_display #7293

Open russell-edsvcs opened 2 months ago

russell-edsvcs commented 2 months ago

Description

The first parameter of pods_field_display is a $pod, but if you actually give it a pod object it doesn't work. Looking into this function, it passes this parameter to https://docs.pods.io/code/pods/ as the $type parameter. Therefore, the first parameter of pods_field_display should probably match pods() and be named $type.

Version

all

Testing Instructions

No response

Screenshots / Screencast

No response

Possible Workaround

No response

Site Health Information

No response

Pods Package

No response

sc0ttkclark commented 2 months ago

The code for that is currently:

/**
 * Get a field display value from a Pod.
 *
 * @param string|null  $pod    The pod name, or if you are in The Loop then you can just provide the field name to auto-detect pod/id using loop information.
 * @param mixed|null   $id     The ID or slug of the item.
 * @param string|array $name   The field name, or an associative array of parameters.
 * @param boolean      $single For tableless fields, to return the whole array or the just the first item.
 *
 * @return mixed Field value.
 *
 * @since 2.1.0
 */
function pods_field_display( $pod, $id = null, $name = null, $single = false ) {

Are you just saying that the name of the argument should match the older $type argument name used in pods()?

sc0ttkclark commented 2 months ago

Question for you -- what's the use case for calling pods_field_display() with a Pods object? Why wouldn't you call $pod->display( ... ) instead?

russell-edsvcs commented 2 months ago

The code for that is currently:

/**
 * Get a field display value from a Pod.
 *
 * @param string|null  $pod    The pod name, or if you are in The Loop then you can just provide the field name to auto-detect pod/id using loop information.
 * @param mixed|null   $id     The ID or slug of the item.
 * @param string|array $name   The field name, or an associative array of parameters.
 * @param boolean      $single For tableless fields, to return the whole array or the just the first item.
 *
 * @return mixed Field value.
 *
 * @since 2.1.0
 */
function pods_field_display( $pod, $id = null, $name = null, $single = false ) {

Are you just saying that the name of the argument should match the older $type argument name used in pods()?

Yes, that is what I was trying to say. It doesn't make sense to call the same thing two different names, and it confused me when I encountered it, so I thought I would report it. Side note, I have no idea why the heck I used the word therefore like that in my original post 🤪. I think that was left over from something else I was going to say. Ignore that.