|
@@ 235-270 (lines=36) @@
|
| 232 |
|
* @param string $type Custom field type (optional). |
| 233 |
|
* @return mixed Meta value. |
| 234 |
|
*/ |
| 235 |
|
public static function get_term_meta( $id, $name, $type = null ) { |
| 236 |
|
$name = $name[0] == '_' ? $name: '_' . $name; |
| 237 |
|
|
| 238 |
|
switch ( $type ) { |
| 239 |
|
case 'complex': |
| 240 |
|
$value = self::get_complex_fields( 'Term_Meta', $name, $id ); |
| 241 |
|
break; |
| 242 |
|
|
| 243 |
|
case 'map': |
| 244 |
|
case 'map_with_address': |
| 245 |
|
$value = array( |
| 246 |
|
'lat' => (float) get_metadata( 'term', $id, $name . '-lat', true ), |
| 247 |
|
'lng' => (float) get_metadata( 'term', $id, $name . '-lng', true ), |
| 248 |
|
'address' => get_metadata( 'term', $id, $name . '-address', true ), |
| 249 |
|
'zoom' => (int) get_metadata( 'term', $id, $name . '-zoom', true ), |
| 250 |
|
); |
| 251 |
|
|
| 252 |
|
if ( ! array_filter( $value ) ) { |
| 253 |
|
$value = array(); |
| 254 |
|
} |
| 255 |
|
break; |
| 256 |
|
|
| 257 |
|
case 'association': |
| 258 |
|
$raw_value = get_metadata( 'term', $id, $name, true ); |
| 259 |
|
$value = self::parse_relationship_field( $raw_value, $type ); |
| 260 |
|
break; |
| 261 |
|
|
| 262 |
|
default: |
| 263 |
|
$value = get_metadata( 'term', $id, $name, true ); |
| 264 |
|
|
| 265 |
|
// backward compatibility for the old Relationship field |
| 266 |
|
$value = self::maybe_old_relationship_field( $value ); |
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
return $value; |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
/** |
| 273 |
|
* Retrieve user meta field for a user. |
|
@@ 280-315 (lines=36) @@
|
| 277 |
|
* @param string $type Custom field type (optional). |
| 278 |
|
* @return mixed Meta value. |
| 279 |
|
*/ |
| 280 |
|
public static function get_user_meta( $id, $name, $type = null ) { |
| 281 |
|
$name = $name[0] == '_' ? $name: '_' . $name; |
| 282 |
|
|
| 283 |
|
switch ( $type ) { |
| 284 |
|
case 'complex': |
| 285 |
|
$value = self::get_complex_fields( 'User_Meta', $name, $id ); |
| 286 |
|
break; |
| 287 |
|
|
| 288 |
|
case 'map': |
| 289 |
|
case 'map_with_address': |
| 290 |
|
$value = array( |
| 291 |
|
'lat' => (float) get_metadata( 'user', $id, $name . '-lat', true ), |
| 292 |
|
'lng' => (float) get_metadata( 'user', $id, $name . '-lng', true ), |
| 293 |
|
'address' => get_metadata( 'user', $id, $name . '-address', true ), |
| 294 |
|
'zoom' => (int) get_metadata( 'user', $id, $name . '-zoom', true ), |
| 295 |
|
); |
| 296 |
|
|
| 297 |
|
if ( ! array_filter( $value ) ) { |
| 298 |
|
$value = array(); |
| 299 |
|
} |
| 300 |
|
break; |
| 301 |
|
|
| 302 |
|
case 'association': |
| 303 |
|
$raw_value = get_metadata( 'user', $id, $name, true ); |
| 304 |
|
$value = self::parse_relationship_field( $raw_value, $type ); |
| 305 |
|
break; |
| 306 |
|
|
| 307 |
|
default: |
| 308 |
|
$value = get_metadata( 'user', $id, $name, true ); |
| 309 |
|
|
| 310 |
|
// backward compatibility for the old Relationship field |
| 311 |
|
$value = self::maybe_old_relationship_field( $value ); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
return $value; |
| 315 |
|
} |
| 316 |
|
|
| 317 |
|
/** |
| 318 |
|
* Retrieve comment meta field for a comment. |
|
@@ 325-360 (lines=36) @@
|
| 322 |
|
* @param string $type Custom field type (optional). |
| 323 |
|
* @return mixed Meta value. |
| 324 |
|
*/ |
| 325 |
|
public static function get_comment_meta( $id, $name, $type = null ) { |
| 326 |
|
$name = $name[0] == '_' ? $name: '_' . $name; |
| 327 |
|
|
| 328 |
|
switch ( $type ) { |
| 329 |
|
case 'complex': |
| 330 |
|
$value = self::get_complex_fields( 'Comment_Meta', $name, $id ); |
| 331 |
|
break; |
| 332 |
|
|
| 333 |
|
case 'map': |
| 334 |
|
case 'map_with_address': |
| 335 |
|
$value = array( |
| 336 |
|
'lat' => (float) get_metadata( 'comment', $id, $name . '-lat', true ), |
| 337 |
|
'lng' => (float) get_metadata( 'comment', $id, $name . '-lng', true ), |
| 338 |
|
'address' => get_metadata( 'comment', $id, $name . '-address', true ), |
| 339 |
|
'zoom' => (int) get_metadata( 'comment', $id, $name . '-zoom', true ), |
| 340 |
|
); |
| 341 |
|
|
| 342 |
|
if ( ! array_filter( $value ) ) { |
| 343 |
|
$value = array(); |
| 344 |
|
} |
| 345 |
|
break; |
| 346 |
|
|
| 347 |
|
case 'association': |
| 348 |
|
$raw_value = get_metadata( 'comment', $id, $name, true ); |
| 349 |
|
$value = self::parse_relationship_field( $raw_value, $type ); |
| 350 |
|
break; |
| 351 |
|
|
| 352 |
|
default: |
| 353 |
|
$value = get_metadata( 'comment', $id, $name, true ); |
| 354 |
|
|
| 355 |
|
// backward compatibility for the old Relationship field |
| 356 |
|
$value = self::maybe_old_relationship_field( $value ); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
return $value; |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
/** |
| 363 |
|
* Adds the field/container template(s) to the templates stack. |