pip_maybe_get()
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don’t provide support for code customizations or 3rd party development.
Object version of acf_maybe_get()
/**
* Pilo'Press version of acf_maybe_get
* (that also handles object type)
*
* @see acf_maybe_get()
*
* @param int $key
* @param null $default
* @param $data
*
* @return mixed|null
*/
function pip_maybe_get( $data, $key = 0, $default = null ) {
if ( is_object( $data ) ) {
$data = (object) $data;
return isset( $data->$key ) ? $data->$key : $default;
} elseif ( is_array( $data ) ) {
$data = (array) $data;
return isset( $data[ $key ] ) ? $data[ $key ] : $default;
}
return $default;
}
Our home port
15 Rue Cavenne, 69007 Lyon
And from everywhere in the world thanks to Hangout and Skype !
Useful links