| @@ 584-603 (lines=20) @@ | ||
| 581 | * @param array $ids Object IDs. |
|
| 582 | * @return array Array of objects. |
|
| 583 | */ |
|
| 584 | public function get_objects_by_id( $object_type, $ids ) { |
|
| 585 | if ( empty( $ids ) || empty( $object_type ) || 'callable' !== $object_type ) { |
|
| 586 | return array(); |
|
| 587 | } |
|
| 588 | ||
| 589 | $objects = array(); |
|
| 590 | foreach ( (array) $ids as $id ) { |
|
| 591 | $object = $this->get_object_by_id( $object_type, $id ); |
|
| 592 | ||
| 593 | if ( 'CALLABLE-DOES-NOT-EXIST' !== $object ) { |
|
| 594 | if ( 'all' === $id ) { |
|
| 595 | // If all was requested it contains all options and can simply be returned. |
|
| 596 | return $object; |
|
| 597 | } |
|
| 598 | $objects[ $id ] = $object; |
|
| 599 | } |
|
| 600 | } |
|
| 601 | ||
| 602 | return $objects; |
|
| 603 | } |
|
| 604 | ||
| 605 | /** |
|
| 606 | * Retrieve a callable by its name. |
|
| @@ 295-312 (lines=18) @@ | ||
| 292 | * @param array $ids Object IDs. |
|
| 293 | * @return array Array of objects. |
|
| 294 | */ |
|
| 295 | public function get_objects_by_id( $object_type, $ids ) { |
|
| 296 | if ( empty( $ids ) || empty( $object_type ) || 'constant' !== $object_type ) { |
|
| 297 | return array(); |
|
| 298 | } |
|
| 299 | ||
| 300 | $objects = array(); |
|
| 301 | foreach ( (array) $ids as $id ) { |
|
| 302 | $object = $this->get_object_by_id( $object_type, $id ); |
|
| 303 | ||
| 304 | if ( 'all' === $id ) { |
|
| 305 | // If all was requested it contains all options and can simply be returned. |
|
| 306 | return $object; |
|
| 307 | } |
|
| 308 | $objects[ $id ] = $object; |
|
| 309 | } |
|
| 310 | ||
| 311 | return $objects; |
|
| 312 | } |
|
| 313 | ||
| 314 | /** |
|
| 315 | * Retrieve a constant by its name. |
|
| @@ 420-440 (lines=21) @@ | ||
| 417 | * @param array $ids Object IDs. |
|
| 418 | * @return array Array of objects. |
|
| 419 | */ |
|
| 420 | public function get_objects_by_id( $object_type, $ids ) { |
|
| 421 | if ( empty( $ids ) || empty( $object_type ) || 'option' !== $object_type ) { |
|
| 422 | return array(); |
|
| 423 | } |
|
| 424 | ||
| 425 | $objects = array(); |
|
| 426 | foreach ( (array) $ids as $id ) { |
|
| 427 | $object = $this->get_object_by_id( $object_type, $id ); |
|
| 428 | ||
| 429 | // Only add object if we have the object. |
|
| 430 | if ( 'OPTION-DOES-NOT-EXIST' !== $object ) { |
|
| 431 | if ( 'all' === $id ) { |
|
| 432 | // If all was requested it contains all options and can simply be returned. |
|
| 433 | return $object; |
|
| 434 | } |
|
| 435 | $objects[ $id ] = $object; |
|
| 436 | } |
|
| 437 | } |
|
| 438 | ||
| 439 | return $objects; |
|
| 440 | } |
|
| 441 | ||
| 442 | /** |
|
| 443 | * Retrieve an option by its name. |
|