| @@ 309-322 (lines=14) @@ | ||
| 306 | * @param bool $single return first found meta with key, or all with $key |
|
| 307 | * @return mixed |
|
| 308 | */ |
|
| 309 | public function get_meta( $key = '', $single = true ) { |
|
| 310 | $meta_ids = array_keys( wp_list_pluck( $this->_meta_data, 'key' ), $key ); |
|
| 311 | $value = ''; |
|
| 312 | ||
| 313 | if ( $meta_ids ) { |
|
| 314 | if ( $single ) { |
|
| 315 | $value = $this->_meta_data[ current( $meta_ids ) ]->value; |
|
| 316 | } else { |
|
| 317 | $value = array_intersect_key( $this->_meta_data, $meta_ids ); |
|
| 318 | } |
|
| 319 | } |
|
| 320 | ||
| 321 | return $value; |
|
| 322 | } |
|
| 323 | ||
| 324 | /** |
|
| 325 | * Set all meta data from array. |
|
| @@ 360-373 (lines=14) @@ | ||
| 357 | * @param bool $single return first found meta with key, or all with $key |
|
| 358 | * @return mixed |
|
| 359 | */ |
|
| 360 | public function get_meta( $key = '', $single = true ) { |
|
| 361 | $meta_ids = array_keys( wp_list_pluck( $this->_meta_data, 'key' ), $key ); |
|
| 362 | $value = ''; |
|
| 363 | ||
| 364 | if ( $meta_ids ) { |
|
| 365 | if ( $single ) { |
|
| 366 | $value = $this->_meta_data[ current( $meta_ids ) ]->value; |
|
| 367 | } else { |
|
| 368 | $value = array_intersect_key( $this->_meta_data, $meta_ids ); |
|
| 369 | } |
|
| 370 | } |
|
| 371 | ||
| 372 | return $value; |
|
| 373 | } |
|
| 374 | ||
| 375 | /** |
|
| 376 | * Set all meta data from array. |
|