|
Server IP : 168.119.101.163 / Your IP : 216.73.217.54 Web Server : Apache/2 System : Linux web02.webzuiver.nl 4.18.0-553.126.2.lve.el8.x86_64 #1 SMP Thu May 28 14:12:30 UTC 2026 x86_64 User : equine ( 1027) PHP Version : 8.1.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0755) : /home/equine/public_html/wp-content/plugins/elementor-pro/core/utils/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
namespace ElementorPro\Core\Utils;
use \Elementor\Core\Utils\Collection as Collection_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// TODO: Move to Core.
class Collection extends Collection_Base implements \JsonSerializable {
/**
* Change the items key by an item field.
*
* @param string $key
*
* @return Collection
*/
public function key_by( $key ) {
return $this->map_with_keys( function ( $item ) use ( $key ) {
return [ $item->{$key} => $item ];
} );
}
/**
* Flatten the items recursively.
*
* @return array
*/
public function flatten_recursive() {
$output = [];
$items = $this->all();
array_walk_recursive($items, function( $item ) use ( &$output ) {
$output[] = $item;
} );
return $output;
}
/**
* Run array_diff between the collection and other array or collection.
*
* @param $filter
*
* @return $this
*/
public function diff( $filter ) {
if ( $filter instanceof Collection_Base ) {
$filter = $filter->all();
}
return new static( array_diff( $this->all(), $filter ) );
}
/**
* Reverse the array
*
* @param false $preserve_keys
*
* @return $this
*/
public function reverse( $preserve_keys = false ) {
return new static(
array_reverse( $this->all(), $preserve_keys )
);
}
/**
* Return a JSON serialized representation of the Collection.
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return $this->all();
}
}